@bikdotai/bik-component-library 0.0.831-beta.3 → 0.0.831-beta.4

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.
@@ -1,25 +1,25 @@
1
- import { jsxs as rt, Fragment as Ot, jsx as c } from "react/jsx-runtime";
2
- import { useState as r, useRef as v, useMemo as wt, useCallback as a } from "react";
3
- import Kt from "styled-components";
4
- import { addUnique as it } from "../../../utils/arrayUtils.js";
1
+ import { jsxs as it, Fragment as Ot, jsx as c } from "react/jsx-runtime";
2
+ import { useState as r, useRef as h, useMemo as Kt, useCallback as a } from "react";
3
+ import Nt from "styled-components";
4
+ import { addUnique as lt } from "../../../utils/arrayUtils.js";
5
5
  import { COLORS as F } from "../../../constants/Theme.js";
6
- import { AGENT_CHAR_LIMITS as Nt } from "../constants/charLimits.js";
7
- import { CONFIG_TOOL_SOURCES as Dt, ToolSource as p } from "../constants/tools.js";
8
- import { buildAgentMentionItems as Gt, buildCustomToolMentionItems as Bt, restApiMentionItem as Pt, configToolMentionItem as zt, restApiToolName as Lt, configToolName as Ht, toolSourceLabel as Ut } from "../utils/mentionSerialization.js";
9
- import { sourceIcon as j, SOURCE_ICONS as lt, renderSourceIcon as at } from "../utils/sourceIcons.js";
10
- import { buildToolActions as $t } from "../utils/toolActions.js";
11
- import { ConfigToolPanel as Ft } from "./ConfigToolPanel.js";
12
- import { DRAWER_BODY_STYLE as jt, DRAWER_HEADER_STYLE as Wt, DrawerHeaderText as Yt } from "./DrawerHeaderText.js";
13
- import { MentionEditor as ct } from "./MentionEditor.js";
14
- import { RestApiToolPanel as Xt } from "./RestApiToolPanel.js";
15
- import { SelectableListSection as Zt } from "./SelectableListSection.js";
16
- import { SideModal as qt } from "../../side-modal/SideModal.js";
17
- import { Input as Jt } from "../../input/Input.js";
18
- import { Toaster as Qt } from "../../toaster/Toaster.js";
19
- const Vt = 1e3, W = 1002, ut = (x, f) => {
6
+ import { AGENT_CHAR_LIMITS as Dt } from "../constants/charLimits.js";
7
+ import { CONFIG_TOOL_SOURCES as Gt, ToolSource as p } from "../constants/tools.js";
8
+ import { buildAgentMentionItems as Bt, buildCustomToolMentionItems as Pt, restApiMentionItem as zt, configToolMentionItem as Lt, restApiToolName as Ht, configToolName as Ut, toolSourceLabel as $t } from "../utils/mentionSerialization.js";
9
+ import { sourceIcon as j, SOURCE_ICONS as at, renderSourceIcon as ct } from "../utils/sourceIcons.js";
10
+ import { buildToolActions as Ft } from "../utils/toolActions.js";
11
+ import { ConfigToolPanel as jt } from "./ConfigToolPanel.js";
12
+ import { DRAWER_BODY_STYLE as Wt, DRAWER_HEADER_STYLE as Yt, DrawerHeaderText as Xt } from "./DrawerHeaderText.js";
13
+ import { MentionEditor as ut } from "./MentionEditor.js";
14
+ import { RestApiToolPanel as Zt } from "./RestApiToolPanel.js";
15
+ import { SelectableListSection as qt } from "./SelectableListSection.js";
16
+ import { SideModal as Jt } from "../../side-modal/SideModal.js";
17
+ import { Input as Qt } from "../../input/Input.js";
18
+ import { Toaster as Vt } from "../../toaster/Toaster.js";
19
+ const te = 1e3, W = 1002, dt = (x, f) => {
20
20
  const s = x ?? [];
21
21
  return s.some((u) => u.id === f.id) ? s.map((u) => u.id === f.id ? f : u) : [...s, f];
22
- }, dt = Kt.button`
22
+ }, mt = Nt.button`
23
23
  align-self: flex-start;
24
24
  border: 1px solid ${F.stroke.primary};
25
25
  color: ${F.content.primary};
@@ -35,7 +35,7 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
35
35
  cursor: default;
36
36
  opacity: 0.6;
37
37
  }
38
- `, To = ({
38
+ `, be = ({
39
39
  onClose: x,
40
40
  onSave: f,
41
41
  availableTools: s,
@@ -45,33 +45,37 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
45
45
  title: Z = "Create sub-agent",
46
46
  initial: g,
47
47
  appLabel: q = "Manifest",
48
- charLimits: h = Nt
48
+ charLimits: T = Dt
49
49
  }) => {
50
- const [M, mt] = r(g?.name ?? ""), [b, A] = r(g?.instructions ?? ""), [T, R] = r(g?.guardrail ?? ""), [O, _] = r(g?.tools ?? []), [m, w] = r(
50
+ const [M, pt] = r(g?.name ?? ""), [b, A] = r(g?.instructions ?? ""), [I, R] = r(g?.guardrail ?? ""), [w, _] = r(g?.tools ?? []), [m, O] = r(
51
51
  g?.configTools ?? []
52
52
  ), [d, K] = r(
53
53
  g?.restApiTools ?? []
54
- ), [i, y] = r(null), E = v(0), [J, Q] = r(!1), [pt, N] = r(0), [ft, D] = r(0), [I, V] = r(null), G = wt(
54
+ ), [i, y] = r(null), E = h(0), [J, Q] = r(!1), [ft, N] = r(0), [gt, D] = r(0), [S, V] = r(null), G = Kt(
55
55
  () => [
56
- ...Gt(s, [], q),
57
- ...Bt(m, d)
56
+ ...Bt(s, [], q),
57
+ ...Pt(m, d)
58
58
  ],
59
59
  [s, q, m, d]
60
- ), k = v({}), B = v("instructions"), gt = a((t) => {
60
+ ), k = h({}), B = h("instructions"), yt = a((t) => {
61
61
  k.current.instructions = t ?? void 0;
62
- }, []), yt = a((t) => {
62
+ }, []), ht = a((t) => {
63
63
  k.current.guardrail = t ?? void 0;
64
- }, []), ht = a(() => {
64
+ }, []), Tt = a(() => {
65
65
  B.current = "instructions";
66
66
  }, []), bt = a(() => {
67
67
  B.current = "guardrail";
68
- }, []), tt = a(
69
- (t, o) => {
70
- t === "tool" && _((e) => it(e, o));
68
+ }, []), tt = h(/* @__PURE__ */ new Set());
69
+ tt.current = new Set(
70
+ [...m, ...d].map((t) => t.id)
71
+ );
72
+ const et = a(
73
+ (t, e) => {
74
+ t === "tool" && !tt.current.has(e) && _((o) => lt(o, e));
71
75
  },
72
76
  []
73
- ), C = a((t, o) => {
74
- (k.current[B.current] ?? k.current.instructions)?.("tool", t, o);
77
+ ), C = a((t, e) => {
78
+ (k.current[B.current] ?? k.current.instructions)?.("tool", t, e);
75
79
  }, []), P = a((t) => {
76
80
  E.current += 1, y({
77
81
  key: E.current,
@@ -79,97 +83,97 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
79
83
  initialRest: t
80
84
  });
81
85
  }, []), z = a(
82
- (t, o) => {
86
+ (t, e) => {
83
87
  E.current += 1, y({
84
88
  key: E.current,
85
89
  kind: "config",
86
90
  toolKey: t,
87
- initialConfig: o
91
+ initialConfig: e
88
92
  });
89
93
  },
90
94
  []
91
- ), Tt = a(
95
+ ), It = a(
92
96
  (t) => {
93
- const o = Dt[t];
94
- o ? z(o) : P();
97
+ const e = Gt[t];
98
+ e ? z(e) : P();
95
99
  },
96
100
  [z, P]
97
- ), It = a(
101
+ ), St = a(
98
102
  (t) => {
99
- const o = !d.some((e) => e.id === t.id);
100
- K((e) => ut(e, t)), o && C(t.id, Pt(t).label), y(null);
103
+ const e = !d.some((o) => o.id === t.id);
104
+ K((o) => dt(o, t)), e && C(t.id, zt(t).label), y(null);
101
105
  },
102
106
  [d, C]
103
107
  ), Ct = a(
104
108
  (t) => {
105
- const o = !m.some((e) => e.id === t.id);
106
- w((e) => ut(e, t)), o && C(t.id, zt(t).label), y(null);
109
+ const e = !m.some((o) => o.id === t.id);
110
+ O((o) => dt(o, t)), e && C(t.id, Lt(t).label), y(null);
107
111
  },
108
112
  [m, C]
109
113
  ), [L, H] = r(
110
114
  null
111
- ), U = v(null), ot = v(0), St = (t) => {
112
- const o = s.find((n) => n.tool_id === t)?.display_name ?? d.find((n) => n.id === t)?.name ?? "Tool", e = `{{tool:${t}}}`, l = (n) => n.split(e).join("");
115
+ ), U = h(null), ot = h(0), vt = (t) => {
116
+ 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("");
113
117
  U.current = {
114
118
  instructions: b,
115
- guardrail: T,
116
- tools: O,
119
+ guardrail: I,
120
+ tools: w,
117
121
  configTools: m,
118
122
  restApiTools: d
119
- }, A((n) => l(n)), R((n) => l(n)), _((n) => n.filter((S) => S !== t)), w((n) => n.filter((S) => S.id !== t)), K((n) => n.filter((S) => S.id !== t)), N((n) => n + 1), D((n) => n + 1), ot.current += 1, H({ id: ot.current, message: `Tool "${o}" removed` });
120
- }, vt = () => {
123
+ }, A((n) => l(n)), R((n) => l(n)), _((n) => n.filter((v) => v !== t)), O((n) => n.filter((v) => v.id !== t)), K((n) => n.filter((v) => v.id !== t)), N((n) => n + 1), D((n) => n + 1), ot.current += 1, H({ id: ot.current, message: `Tool "${e}" removed` });
124
+ }, xt = () => {
121
125
  const t = U.current;
122
- t && (A(t.instructions), R(t.guardrail), _(t.tools), w(t.configTools), K(t.restApiTools), N((o) => o + 1), D((o) => o + 1), U.current = null), H(null);
123
- }, et = M.trim().length > 0 && (b.trim().length > 0 || T.trim().length > 0), xt = O.map((t) => {
124
- const o = s.find((e) => e.tool_id === t);
125
- return o ? {
126
+ t && (A(t.instructions), R(t.guardrail), _(t.tools), O(t.configTools), K(t.restApiTools), N((e) => e + 1), D((e) => e + 1), U.current = null), H(null);
127
+ }, nt = M.trim().length > 0 && (b.trim().length > 0 || I.trim().length > 0), At = w.map((t) => {
128
+ const e = s.find((o) => o.tool_id === t);
129
+ return e ? {
126
130
  id: t,
127
- label: o.display_name,
128
- icon: j(o.source ?? p.Manifest)
131
+ label: e.display_name,
132
+ icon: j(e.source ?? p.Manifest)
129
133
  } : null;
130
- }).filter((t) => t !== null), At = d.map((t) => ({
134
+ }).filter((t) => t !== null), Rt = d.map((t) => ({
131
135
  id: t.id,
132
- label: Lt(t),
133
- icon: lt[p.RestApi],
136
+ label: Ht(t),
137
+ icon: at[p.RestApi],
134
138
  onConfigure: () => P(t)
135
- })), Rt = m.map((t) => ({
139
+ })), _t = m.map((t) => ({
136
140
  id: t.id,
137
- label: Ht(t),
138
- icon: lt[t.tool_key === "send_slack_message" ? p.Slack : p.EmailHandover],
141
+ label: Ut(t),
142
+ icon: at[t.tool_key === "send_slack_message" ? p.Slack : p.EmailHandover],
139
143
  onConfigure: () => z(t.tool_key, t)
140
- })), _t = [
141
- ...xt,
144
+ })), Et = [
142
145
  ...At,
143
- ...Rt
144
- ], $ = $t(
146
+ ...Rt,
147
+ ..._t
148
+ ], $ = Ft(
145
149
  X,
146
- Tt
147
- ), nt = i?.kind === "config" && i.toolKey ? X?.[i.toolKey] : void 0, Et = s.map((t) => ({
150
+ It
151
+ ), st = i?.kind === "config" && i.toolKey ? X?.[i.toolKey] : void 0, kt = s.map((t) => ({
148
152
  label: t.display_name,
149
153
  value: t.tool_id,
150
- leadingIcon: at(j(t.source ?? p.Manifest)) ?? void 0
151
- })), kt = (() => {
152
- const t = [], o = /* @__PURE__ */ new Map();
153
- return s.forEach((e) => {
154
- const l = e.source ?? p.Manifest;
155
- o.has(l) || (o.set(l, []), t.push(l)), o.get(l)?.push({
156
- label: e.display_name,
157
- value: e.tool_id,
158
- leadingIcon: at(j(e.source ?? p.Manifest)) ?? void 0
154
+ leadingIcon: ct(j(t.source ?? p.Manifest)) ?? void 0
155
+ })), Mt = (() => {
156
+ const t = [], e = /* @__PURE__ */ new Map();
157
+ return s.forEach((o) => {
158
+ const l = o.source ?? p.Manifest;
159
+ e.has(l) || (e.set(l, []), t.push(l)), e.get(l)?.push({
160
+ label: o.display_name,
161
+ value: o.tool_id,
162
+ leadingIcon: ct(j(o.source ?? p.Manifest)) ?? void 0
159
163
  });
160
- }), t.map((e) => ({
161
- source: e,
162
- label: Ut(e),
163
- options: o.get(e) ?? []
164
+ }), t.map((o) => ({
165
+ source: o,
166
+ label: $t(o),
167
+ options: e.get(o) ?? []
164
168
  }));
165
- })(), Mt = async () => {
166
- if (!et || J)
169
+ })(), wt = async () => {
170
+ if (!nt || J)
167
171
  return;
168
172
  const t = f({
169
173
  name: M.trim(),
170
174
  instructions: b,
171
- guardrail: T,
172
- tools: O,
175
+ guardrail: I,
176
+ tools: w,
173
177
  configTools: m,
174
178
  restApiTools: d
175
179
  });
@@ -181,43 +185,43 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
181
185
  Q(!1);
182
186
  }
183
187
  }
184
- }, st = async (t) => {
185
- if (!(!u || I)) {
188
+ }, rt = async (t) => {
189
+ if (!(!u || S)) {
186
190
  V(t);
187
191
  try {
188
- const e = await u(t, t === "instructions" ? b : T);
189
- t === "instructions" ? (A(e), N((l) => l + 1)) : (R(e), D((l) => l + 1));
192
+ const o = await u(t, t === "instructions" ? b : I);
193
+ t === "instructions" ? (A(o), N((l) => l + 1)) : (R(o), D((l) => l + 1));
190
194
  } finally {
191
195
  V(null);
192
196
  }
193
197
  }
194
198
  };
195
- return /* @__PURE__ */ rt(Ot, { children: [
196
- /* @__PURE__ */ rt(
197
- qt,
199
+ return /* @__PURE__ */ it(Ot, { children: [
200
+ /* @__PURE__ */ it(
201
+ Jt,
198
202
  {
199
203
  header: Z,
200
204
  closeOnEscapeKey: !1,
201
- zIndex: Vt,
205
+ zIndex: te,
202
206
  headerCustomComponent: /* @__PURE__ */ c(
203
- Yt,
207
+ Xt,
204
208
  {
205
209
  title: Z,
206
210
  subtitle: "Each sub-agent handles one piece of the job. Use @ in the main instructions to call them."
207
211
  }
208
212
  ),
209
213
  width: "421px",
210
- headerStyle: Wt,
211
- bodyStyle: jt,
214
+ headerStyle: Yt,
215
+ bodyStyle: Wt,
212
216
  onClose: x,
213
217
  saveButtonProps: {
214
218
  "data-test": "subagent-save",
215
219
  buttonText: "Save",
216
220
  buttonType: "primary",
217
221
  size: "small",
218
- disabled: !et,
222
+ disabled: !nt,
219
223
  isLoading: J,
220
- onClick: Mt
224
+ onClick: wt
221
225
  },
222
226
  cancelButtonProps: {
223
227
  "data-test": "subagent-cancel",
@@ -228,92 +232,92 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
228
232
  },
229
233
  children: [
230
234
  /* @__PURE__ */ c(
231
- Jt,
235
+ Qt,
232
236
  {
233
237
  "data-test": "subagent-name",
234
238
  labelText: "Agent name",
235
239
  labelTextBold: !0,
236
240
  placeholder: "Enter agent name",
237
241
  value: M,
238
- maxCharLimit: h.name,
242
+ maxCharLimit: T.name,
239
243
  maxCharLimitPosition: "TOP",
240
244
  maxCharStyle: { fontSize: 12, lineHeight: "16px" },
241
- onChangeText: mt
245
+ onChangeText: pt
242
246
  }
243
247
  ),
244
248
  /* @__PURE__ */ c(
245
- ct,
249
+ ut,
246
250
  {
247
251
  "data-test": "subagent-instructions",
248
252
  label: "Instructions",
249
253
  value: b,
250
254
  onChange: A,
251
- maxLength: h.instructions,
255
+ maxLength: T.instructions,
252
256
  placeholder: "Write the steps in plain English. Type @ to reference a tool.",
253
257
  minHeight: "160px",
254
- resetKey: `instr-${pt}`,
258
+ resetKey: `instr-${ft}`,
255
259
  mentionItems: G,
256
260
  tools: s,
257
261
  toolActions: $,
258
- onMentionSelect: tt,
259
- onFocus: ht,
260
- registerInsert: gt,
262
+ onMentionSelect: et,
263
+ onFocus: Tt,
264
+ registerInsert: yt,
261
265
  action: u ? /* @__PURE__ */ c(
262
- dt,
266
+ mt,
263
267
  {
264
268
  type: "button",
265
269
  "data-test": "subagent-improve-instructions",
266
- disabled: I !== null,
267
- onClick: () => st("instructions"),
268
- children: I === "instructions" ? "Improving…" : "Improve with AI"
270
+ disabled: S !== null,
271
+ onClick: () => rt("instructions"),
272
+ children: S === "instructions" ? "Improving…" : "Improve with AI"
269
273
  }
270
274
  ) : void 0
271
275
  }
272
276
  ),
273
277
  /* @__PURE__ */ c(
274
- ct,
278
+ ut,
275
279
  {
276
280
  "data-test": "subagent-guardrail",
277
281
  label: "Guardrails",
278
- value: T,
282
+ value: I,
279
283
  onChange: R,
280
- maxLength: h.guardrail,
284
+ maxLength: T.guardrail,
281
285
  placeholder: "e.g. Never discuss competitor pricing. Type @ to reference a tool.",
282
286
  minHeight: "160px",
283
- resetKey: `guard-${ft}`,
287
+ resetKey: `guard-${gt}`,
284
288
  mentionItems: G,
285
289
  tools: s,
286
290
  toolActions: $,
287
- onMentionSelect: tt,
291
+ onMentionSelect: et,
288
292
  onFocus: bt,
289
- registerInsert: yt,
293
+ registerInsert: ht,
290
294
  action: u ? /* @__PURE__ */ c(
291
- dt,
295
+ mt,
292
296
  {
293
297
  type: "button",
294
298
  "data-test": "subagent-improve-guardrail",
295
- disabled: I !== null,
296
- onClick: () => st("guardrail"),
297
- children: I === "guardrail" ? "Improving…" : "Improve with AI"
299
+ disabled: S !== null,
300
+ onClick: () => rt("guardrail"),
301
+ children: S === "guardrail" ? "Improving…" : "Improve with AI"
298
302
  }
299
303
  ) : void 0
300
304
  }
301
305
  ),
302
306
  /* @__PURE__ */ c(
303
- Zt,
307
+ qt,
304
308
  {
305
309
  title: "Tools this agent can use",
306
310
  dataTestPrefix: "subagent-tools",
307
- items: _t,
308
- addableOptions: Et,
309
- sourceGroups: kt,
311
+ items: Et,
312
+ addableOptions: kt,
313
+ sourceGroups: Mt,
310
314
  mentionItems: G,
311
315
  actionSources: $,
312
316
  emptyText: "No tools added yet.",
313
317
  onAdd: (t) => {
314
- C(t), _((o) => it(o, t));
318
+ C(t), _((e) => lt(e, t));
315
319
  },
316
- onRemove: St,
320
+ onRemove: vt,
317
321
  confirmDelete: { noun: "tool", zIndex: W + 1 }
318
322
  }
319
323
  )
@@ -321,24 +325,24 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
321
325
  }
322
326
  ),
323
327
  i?.kind === "restapi" && /* @__PURE__ */ c(
324
- Xt,
328
+ Zt,
325
329
  {
326
330
  initial: i.initialRest,
327
- charLimits: h,
331
+ charLimits: T,
328
332
  onImprove: Y,
329
333
  onClose: () => y(null),
330
- onSave: It,
334
+ onSave: St,
331
335
  zIndex: W
332
336
  },
333
337
  i.key
334
338
  ),
335
- i?.kind === "config" && i.toolKey && nt && /* @__PURE__ */ c(
336
- Ft,
339
+ i?.kind === "config" && i.toolKey && st && /* @__PURE__ */ c(
340
+ jt,
337
341
  {
338
342
  toolKey: i.toolKey,
339
- template: nt,
343
+ template: st,
340
344
  initial: i.initialConfig,
341
- charLimits: h,
345
+ charLimits: T,
342
346
  onImprove: Y,
343
347
  onClose: () => y(null),
344
348
  onSave: Ct,
@@ -347,7 +351,7 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
347
351
  i.key
348
352
  ),
349
353
  L && /* @__PURE__ */ c(
350
- Qt,
354
+ Vt,
351
355
  {
352
356
  text: L.message,
353
357
  type: "info",
@@ -357,7 +361,7 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
357
361
  buttonProps: {
358
362
  buttonText: "Undo",
359
363
  showButton: !0,
360
- onButtonClick: () => (vt(), {})
364
+ onButtonClick: () => (xt(), {})
361
365
  },
362
366
  onCloseToast: () => H(null)
363
367
  },
@@ -366,6 +370,6 @@ const Vt = 1e3, W = 1002, ut = (x, f) => {
366
370
  ] });
367
371
  };
368
372
  export {
369
- To as CreateSubAgentPanel
373
+ be as CreateSubAgentPanel
370
374
  };
371
375
  //# sourceMappingURL=CreateSubAgentPanel.js.map