@bikdotai/bik-component-library 0.0.849-beta.4 → 0.0.849-beta.6
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/AddDataPill.js +10 -0
- package/dist/cjs/components/agent-builder/components/AddDataPill.js.map +1 -0
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +10 -10
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +2 -2
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +49 -25
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +9 -8
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/VariableInlineField.js +56 -0
- package/dist/cjs/components/agent-builder/components/VariableInlineField.js.map +1 -0
- package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js +6 -5
- package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +4 -4
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +5 -3
- package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
- package/dist/cjs/editor/BikEditor.types.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AddDataPill.d.ts +18 -0
- package/dist/esm/components/agent-builder/components/AddDataPill.js +32 -0
- package/dist/esm/components/agent-builder/components/AddDataPill.js.map +1 -0
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +165 -148
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +15 -13
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +7 -2
- package/dist/esm/components/agent-builder/components/MentionEditor.js +119 -102
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +30 -29
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +199 -165
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +3 -2
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +160 -193
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +20 -19
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/VariableInlineField.d.ts +26 -0
- package/dist/esm/components/agent-builder/components/VariableInlineField.js +142 -0
- package/dist/esm/components/agent-builder/components/VariableInlineField.js.map +1 -0
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.d.ts +19 -0
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +113 -72
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +26 -20
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +24 -18
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.js +5 -3
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/editor/BikEditor.types.d.ts +9 -0
- package/dist/esm/editor/BikEditor.types.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
import { TitleSmall as
|
|
7
|
-
import { COLORS as
|
|
8
|
-
import { FieldBlock as
|
|
9
|
-
import { AGENT_CHAR_LIMITS as
|
|
10
|
-
import { DRAWER_BODY_STYLE as
|
|
11
|
-
import { ToolInstructionsField as
|
|
12
|
-
import {
|
|
13
|
-
import { SideModal as
|
|
14
|
-
import { Input as
|
|
15
|
-
import { Dropdown as
|
|
16
|
-
import { unwrapDropdownValue as
|
|
17
|
-
import { Button as
|
|
18
|
-
import { BikEditor as
|
|
19
|
-
const
|
|
20
|
-
label:
|
|
21
|
-
value:
|
|
22
|
-
})),
|
|
23
|
-
onClose:
|
|
24
|
-
onSave:
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import U from "../../../assets/icons/delete.svg.js";
|
|
3
|
+
import W from "../../../assets/icons/plus.svg.js";
|
|
4
|
+
import { useState as a } from "react";
|
|
5
|
+
import T from "styled-components";
|
|
6
|
+
import { TitleSmall as p } from "../../TypographyStyle.js";
|
|
7
|
+
import { COLORS as s } from "../../../constants/Theme.js";
|
|
8
|
+
import { FieldBlock as d } from "../AgentBuilder.styled.js";
|
|
9
|
+
import { AGENT_CHAR_LIMITS as Y } from "../constants/charLimits.js";
|
|
10
|
+
import { DRAWER_BODY_STYLE as V, DRAWER_HEADER_STYLE as K, DrawerHeaderText as Q } from "./DrawerHeaderText.js";
|
|
11
|
+
import { ToolInstructionsField as X } from "./ToolInstructionsField.js";
|
|
12
|
+
import { VariableInlineField as k } from "./VariableInlineField.js";
|
|
13
|
+
import { SideModal as Z } from "../../side-modal/SideModal.js";
|
|
14
|
+
import { Input as A } from "../../input/Input.js";
|
|
15
|
+
import { Dropdown as ee } from "../../dropdown/Dropdown.js";
|
|
16
|
+
import { unwrapDropdownValue as te } from "../../dropdown/utils.js";
|
|
17
|
+
import { Button as re } from "../../button/Button.js";
|
|
18
|
+
import { BikEditor as P } from "../../../editor/BikEditor.js";
|
|
19
|
+
const oe = ["GET", "POST", "PUT", "PATCH", "DELETE"], ne = oe.map((i) => ({
|
|
20
|
+
label: i,
|
|
21
|
+
value: i
|
|
22
|
+
})), Ee = ({
|
|
23
|
+
onClose: i,
|
|
24
|
+
onSave: L,
|
|
25
25
|
initial: n,
|
|
26
|
-
onImprove:
|
|
27
|
-
charLimits:
|
|
28
|
-
zIndex:
|
|
29
|
-
existingNames:
|
|
26
|
+
onImprove: O,
|
|
27
|
+
charLimits: S = Y,
|
|
28
|
+
zIndex: B,
|
|
29
|
+
existingNames: M = [],
|
|
30
30
|
variablesData: c
|
|
31
31
|
}) => {
|
|
32
|
-
const [
|
|
32
|
+
const [h, _] = a(n?.name ?? ""), [b, $] = a(n?.instructions ?? ""), [u, N] = a(n?.url ?? "https://"), [f, q] = a(
|
|
33
33
|
n?.method ?? "POST"
|
|
34
|
-
), [
|
|
34
|
+
), [y, x] = a(
|
|
35
35
|
n?.headers ?? [{ key: "", value: "" }]
|
|
36
|
-
), [
|
|
36
|
+
), [C, j] = a(n?.requestBody ?? ""), [R, z] = a(
|
|
37
37
|
n?.responseSample ?? ""
|
|
38
|
-
), [
|
|
39
|
-
(o) => o.map((
|
|
40
|
-
),
|
|
41
|
-
(e) => e.trim().toLowerCase() ===
|
|
42
|
-
),
|
|
43
|
-
return /* @__PURE__ */
|
|
44
|
-
|
|
38
|
+
), [H, w] = a(!1), E = (e, r) => x(
|
|
39
|
+
(o) => o.map((m, J) => J === e ? { ...m, ...r } : m)
|
|
40
|
+
), F = () => x((e) => [...e, { key: "", value: "" }]), G = (e) => x((r) => r.filter((o, m) => m !== e)), g = h.trim(), v = g.length > 0 && M.some(
|
|
41
|
+
(e) => e.trim().toLowerCase() === g.toLowerCase()
|
|
42
|
+
), I = g.length > 0 && u.trim().length > 0 && !v;
|
|
43
|
+
return /* @__PURE__ */ l(
|
|
44
|
+
Z,
|
|
45
45
|
{
|
|
46
46
|
header: "Rest API",
|
|
47
47
|
closeOnEscapeKey: !1,
|
|
48
|
-
zIndex:
|
|
48
|
+
zIndex: B,
|
|
49
49
|
headerCustomComponent: /* @__PURE__ */ t(
|
|
50
|
-
|
|
50
|
+
Q,
|
|
51
51
|
{
|
|
52
52
|
title: "Rest API",
|
|
53
53
|
subtitle: "Connect to any API endpoint. Define the request and a sample response for the agent to reference."
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
56
|
width: "431px",
|
|
57
|
-
headerStyle:
|
|
58
|
-
bodyStyle:
|
|
59
|
-
onClose:
|
|
57
|
+
headerStyle: K,
|
|
58
|
+
bodyStyle: V,
|
|
59
|
+
onClose: i,
|
|
60
60
|
saveButtonProps: {
|
|
61
61
|
"data-test": "restapi-save",
|
|
62
62
|
buttonText: "Save",
|
|
63
63
|
buttonType: "primary",
|
|
64
64
|
size: "small",
|
|
65
|
-
disabled:
|
|
66
|
-
isLoading:
|
|
65
|
+
disabled: !I,
|
|
66
|
+
isLoading: H,
|
|
67
67
|
onClick: async () => {
|
|
68
|
-
if (
|
|
68
|
+
if (!I || H)
|
|
69
69
|
return;
|
|
70
70
|
const e = {
|
|
71
71
|
id: n?.id ?? `restapi_${Date.now().toString(36)}`,
|
|
72
|
-
name:
|
|
73
|
-
instructions:
|
|
74
|
-
url:
|
|
75
|
-
method:
|
|
72
|
+
name: h.trim(),
|
|
73
|
+
instructions: b,
|
|
74
|
+
url: u.trim(),
|
|
75
|
+
method: f,
|
|
76
76
|
// Drop fully-empty header rows.
|
|
77
|
-
headers:
|
|
78
|
-
requestBody:
|
|
79
|
-
responseSample:
|
|
80
|
-
}, r =
|
|
77
|
+
headers: y.filter((o) => o.key.trim() || o.value.trim()),
|
|
78
|
+
requestBody: C,
|
|
79
|
+
responseSample: R
|
|
80
|
+
}, r = L(e);
|
|
81
81
|
if (r && typeof r.then == "function") {
|
|
82
|
-
|
|
82
|
+
w(!0);
|
|
83
83
|
try {
|
|
84
84
|
await r;
|
|
85
85
|
} finally {
|
|
86
|
-
|
|
86
|
+
w(!1);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -93,225 +93,192 @@ const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
|
|
|
93
93
|
buttonText: "Cancel",
|
|
94
94
|
buttonType: "tertiaryGray",
|
|
95
95
|
size: "small",
|
|
96
|
-
onClick:
|
|
96
|
+
onClick: i
|
|
97
97
|
},
|
|
98
98
|
children: [
|
|
99
99
|
/* @__PURE__ */ t(
|
|
100
|
-
|
|
100
|
+
A,
|
|
101
101
|
{
|
|
102
102
|
"data-test": "restapi-name",
|
|
103
103
|
variant: "small",
|
|
104
104
|
labelText: "Name",
|
|
105
105
|
labelTextBold: !0,
|
|
106
106
|
placeholder: "Enter action name",
|
|
107
|
-
value:
|
|
108
|
-
maxCharLimit:
|
|
109
|
-
state:
|
|
110
|
-
errorMessage:
|
|
111
|
-
onChangeText:
|
|
107
|
+
value: h,
|
|
108
|
+
maxCharLimit: S.name,
|
|
109
|
+
state: v ? "invalid" : void 0,
|
|
110
|
+
errorMessage: v ? "A tool with this name already exists" : void 0,
|
|
111
|
+
onChangeText: _
|
|
112
112
|
}
|
|
113
113
|
),
|
|
114
114
|
/* @__PURE__ */ t(
|
|
115
|
-
|
|
115
|
+
X,
|
|
116
116
|
{
|
|
117
117
|
"data-test": "restapi-instructions",
|
|
118
118
|
label: "Instructions",
|
|
119
|
-
value:
|
|
120
|
-
onChange:
|
|
121
|
-
maxLength:
|
|
119
|
+
value: b,
|
|
120
|
+
onChange: $,
|
|
121
|
+
maxLength: S.instructions,
|
|
122
122
|
placeholder: "Describe how should the LLM generate the rest API",
|
|
123
|
-
onImprove:
|
|
123
|
+
onImprove: O,
|
|
124
124
|
variablesData: c
|
|
125
125
|
}
|
|
126
126
|
),
|
|
127
|
-
/* @__PURE__ */ t(
|
|
128
|
-
|
|
127
|
+
/* @__PURE__ */ t(d, { children: /* @__PURE__ */ t(
|
|
128
|
+
k,
|
|
129
129
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
f,
|
|
137
|
-
{
|
|
138
|
-
"data-test": "restapi-url",
|
|
139
|
-
variant: "small",
|
|
140
|
-
labelText: "Request URL",
|
|
141
|
-
labelTextBold: !0,
|
|
142
|
-
placeholder: "https://",
|
|
143
|
-
type: "url",
|
|
144
|
-
value: T,
|
|
145
|
-
onChangeText: k
|
|
146
|
-
}
|
|
147
|
-
)
|
|
130
|
+
"data-test": "restapi-url",
|
|
131
|
+
label: "Request URL",
|
|
132
|
+
placeholder: "https://",
|
|
133
|
+
value: u,
|
|
134
|
+
onChange: N,
|
|
135
|
+
variablesData: c
|
|
148
136
|
}
|
|
149
137
|
) }),
|
|
150
|
-
/* @__PURE__ */ d
|
|
151
|
-
/* @__PURE__ */ t(
|
|
138
|
+
/* @__PURE__ */ l(d, { children: [
|
|
139
|
+
/* @__PURE__ */ t(p, { color: s.content.primary, children: "HTTP method" }),
|
|
152
140
|
/* @__PURE__ */ t(
|
|
153
|
-
|
|
141
|
+
ee,
|
|
154
142
|
{
|
|
155
143
|
"data-test": "restapi-method",
|
|
156
144
|
size: "small",
|
|
157
145
|
width: "100%",
|
|
158
146
|
dropdownWidth: "399px",
|
|
159
|
-
options:
|
|
160
|
-
defaultOptions: [{ label:
|
|
147
|
+
options: ne,
|
|
148
|
+
defaultOptions: [{ label: f, value: f }],
|
|
161
149
|
onSelect: (e) => {
|
|
162
|
-
const r =
|
|
163
|
-
r &&
|
|
150
|
+
const r = te(e);
|
|
151
|
+
r && q(r);
|
|
164
152
|
}
|
|
165
153
|
}
|
|
166
154
|
)
|
|
167
155
|
] }),
|
|
168
|
-
/* @__PURE__ */ d
|
|
169
|
-
/* @__PURE__ */ t(
|
|
170
|
-
|
|
156
|
+
/* @__PURE__ */ l(d, { children: [
|
|
157
|
+
/* @__PURE__ */ t(p, { color: s.content.primary, children: "Headers" }),
|
|
158
|
+
y.map((e, r) => (
|
|
159
|
+
// Key includes the row count: the value field is an uncontrolled
|
|
160
|
+
// editor, so add/remove must remount rows or a deleted row's text
|
|
161
|
+
// would linger in its reused neighbour.
|
|
171
162
|
// eslint-disable-next-line react/no-array-index-key
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
value: e.key,
|
|
180
|
-
onChangeText: (o) => S(r, { key: o })
|
|
181
|
-
}
|
|
182
|
-
),
|
|
183
|
-
/* @__PURE__ */ t(
|
|
184
|
-
h,
|
|
185
|
-
{
|
|
186
|
-
variablesData: c,
|
|
187
|
-
onInsert: (o, a) => {
|
|
188
|
-
const m = a ?? e.value.length;
|
|
189
|
-
S(r, {
|
|
190
|
-
value: `${e.value.slice(0, m)}${o}${e.value.slice(m)}`
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
children: /* @__PURE__ */ t(
|
|
194
|
-
f,
|
|
163
|
+
/* @__PURE__ */ l(
|
|
164
|
+
ae,
|
|
165
|
+
{
|
|
166
|
+
"data-test": `restapi-header-${r}`,
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ t(
|
|
169
|
+
A,
|
|
195
170
|
{
|
|
196
171
|
variant: "small",
|
|
197
172
|
hideInputHeader: !0,
|
|
173
|
+
placeholder: "Enter name",
|
|
174
|
+
value: e.key,
|
|
175
|
+
onChangeText: (o) => E(r, { key: o })
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ t(
|
|
179
|
+
k,
|
|
180
|
+
{
|
|
198
181
|
placeholder: "Enter value",
|
|
199
182
|
value: e.value,
|
|
200
|
-
|
|
183
|
+
onChange: (o) => E(r, { value: o }),
|
|
184
|
+
variablesData: c
|
|
201
185
|
}
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
/* @__PURE__ */ t(
|
|
206
|
-
pe,
|
|
207
|
-
{
|
|
208
|
-
type: "button",
|
|
209
|
-
"aria-label": "Remove header",
|
|
210
|
-
"data-test": `restapi-header-remove-${r}`,
|
|
211
|
-
onClick: () => V(r),
|
|
212
|
-
children: /* @__PURE__ */ t(
|
|
213
|
-
K,
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ t(
|
|
188
|
+
le,
|
|
214
189
|
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
190
|
+
type: "button",
|
|
191
|
+
"aria-label": "Remove header",
|
|
192
|
+
"data-test": `restapi-header-remove-${r}`,
|
|
193
|
+
onClick: () => G(r),
|
|
194
|
+
children: /* @__PURE__ */ t(
|
|
195
|
+
U,
|
|
196
|
+
{
|
|
197
|
+
width: 16,
|
|
198
|
+
height: 16,
|
|
199
|
+
color: s.content.secondary
|
|
200
|
+
}
|
|
201
|
+
)
|
|
218
202
|
}
|
|
219
203
|
)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
`${r}:${y.length}`
|
|
207
|
+
)
|
|
223
208
|
)),
|
|
224
|
-
/* @__PURE__ */ t(
|
|
225
|
-
|
|
209
|
+
/* @__PURE__ */ t(se, { children: /* @__PURE__ */ t(
|
|
210
|
+
re,
|
|
226
211
|
{
|
|
227
212
|
"data-test": "restapi-add-header",
|
|
228
213
|
buttonType: "dashRegular",
|
|
229
214
|
size: "small",
|
|
230
|
-
LeadingIcon:
|
|
215
|
+
LeadingIcon: W,
|
|
231
216
|
buttonText: "Add header",
|
|
232
|
-
onClick:
|
|
217
|
+
onClick: F
|
|
233
218
|
}
|
|
234
219
|
) })
|
|
235
220
|
] }),
|
|
236
|
-
/* @__PURE__ */ d
|
|
237
|
-
/* @__PURE__ */ t(
|
|
221
|
+
/* @__PURE__ */ l(d, { children: [
|
|
222
|
+
/* @__PURE__ */ t(p, { color: s.content.primary, children: "Request " }),
|
|
238
223
|
/* @__PURE__ */ t(
|
|
239
|
-
|
|
224
|
+
P,
|
|
240
225
|
{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
features: { jsonMode: !0 },
|
|
249
|
-
initialContent: B,
|
|
250
|
-
style: _,
|
|
251
|
-
placeholder: "Type or paste JSON here",
|
|
252
|
-
onChange: (e) => U(e.text),
|
|
253
|
-
minHeight: "120px",
|
|
254
|
-
maxHeight: "240px"
|
|
255
|
-
}
|
|
256
|
-
)
|
|
226
|
+
features: { jsonMode: !0 },
|
|
227
|
+
initialContent: C,
|
|
228
|
+
style: D,
|
|
229
|
+
placeholder: "Type or paste JSON here",
|
|
230
|
+
onChange: (e) => j(e.text),
|
|
231
|
+
minHeight: "120px",
|
|
232
|
+
maxHeight: "240px"
|
|
257
233
|
}
|
|
258
234
|
)
|
|
259
235
|
] }),
|
|
260
|
-
/* @__PURE__ */ d
|
|
261
|
-
/* @__PURE__ */ t(
|
|
236
|
+
/* @__PURE__ */ l(d, { children: [
|
|
237
|
+
/* @__PURE__ */ t(p, { color: s.content.primary, children: "Response " }),
|
|
262
238
|
/* @__PURE__ */ t(
|
|
263
|
-
|
|
239
|
+
P,
|
|
264
240
|
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
features: { jsonMode: !0 },
|
|
273
|
-
style: _,
|
|
274
|
-
initialContent: P,
|
|
275
|
-
placeholder: "Type or paste JSON here",
|
|
276
|
-
onChange: (e) => W(e.text),
|
|
277
|
-
minHeight: "120px",
|
|
278
|
-
maxHeight: "240px"
|
|
279
|
-
}
|
|
280
|
-
)
|
|
241
|
+
features: { jsonMode: !0 },
|
|
242
|
+
style: D,
|
|
243
|
+
initialContent: R,
|
|
244
|
+
placeholder: "Type or paste JSON here",
|
|
245
|
+
onChange: (e) => z(e.text),
|
|
246
|
+
minHeight: "120px",
|
|
247
|
+
maxHeight: "240px"
|
|
281
248
|
}
|
|
282
249
|
)
|
|
283
250
|
] })
|
|
284
251
|
]
|
|
285
252
|
}
|
|
286
253
|
);
|
|
287
|
-
},
|
|
288
|
-
display:
|
|
254
|
+
}, ae = T.div`
|
|
255
|
+
display: grid;
|
|
256
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 32px;
|
|
289
257
|
align-items: center;
|
|
290
258
|
gap: 8px;
|
|
291
|
-
`,
|
|
259
|
+
`, se = T.div`
|
|
292
260
|
display: flex;
|
|
293
|
-
`,
|
|
261
|
+
`, le = T.button`
|
|
294
262
|
display: inline-flex;
|
|
295
263
|
align-items: center;
|
|
296
264
|
justify-content: center;
|
|
297
265
|
flex-shrink: 0;
|
|
298
266
|
width: 32px;
|
|
299
267
|
height: 32px;
|
|
300
|
-
border: 1px solid ${
|
|
268
|
+
border: 1px solid ${s.stroke.primary};
|
|
301
269
|
border-radius: 4px;
|
|
302
|
-
background: ${
|
|
270
|
+
background: ${s.surface.standard};
|
|
303
271
|
cursor: pointer;
|
|
304
272
|
|
|
305
273
|
&:hover {
|
|
306
|
-
border-color: ${
|
|
274
|
+
border-color: ${s.content.secondary};
|
|
307
275
|
}
|
|
308
|
-
`,
|
|
276
|
+
`, D = {
|
|
309
277
|
borderRadius: "4px",
|
|
310
278
|
overflow: "hidden"
|
|
311
279
|
};
|
|
312
280
|
export {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
M as jsonQuoteToken
|
|
281
|
+
D as JsonFieldBox,
|
|
282
|
+
Ee as RestApiToolPanel
|
|
316
283
|
};
|
|
317
284
|
//# sourceMappingURL=RestApiToolPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestApiToolPanel.js","sources":["../../../../../src/components/agent-builder/components/RestApiToolPanel.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { BikEditor, BikEditorRef } from '@src/editor';\nimport React, { useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type { VariableListInterfaceV3 } from '../../variable-picker-v3/model';\nimport {\n\tRestApiHeader,\n\tRestApiMethod,\n\tRestApiToolConfig,\n} from '../AgentBuilder.model';\nimport { FieldBlock } from '../AgentBuilder.styled';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { ToolInstructionsField } from './ToolInstructionsField';\nimport { VariableTriggerArea } from './VariableTriggerArea';\n\ninterface RestApiToolPanelProps {\n\tonClose: () => void;\n\t/** Persist the config. A pending promise shows the Save loader. */\n\tonSave: (config: RestApiToolConfig) => void | Promise<void>;\n\t/** Seed values when editing an existing tool. */\n\tinitial?: RestApiToolConfig;\n\t/** Optional \"Improve with AI\" for the instructions field. Omit to hide it. */\n\tonImprove?: (text: string) => Promise<string>;\n\tcharLimits?: AgentCharLimits;\n\t/** SideModal stacking order — raise it when opened over another drawer. */\n\tzIndex?: number;\n\t/** Names of the OTHER tools — a new tool can't reuse one of these. */\n\texistingNames?: string[];\n\t/**\n\t * Variable catalog for the `@` trigger. When non-empty, `@` opens the\n\t * variable picker directly in Instructions / Request URL / header values /\n\t * Request / Response. Absent → the drawer behaves exactly as before.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n}\n\nconst METHODS: RestApiMethod[] = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];\nconst METHOD_OPTIONS: SingleOption[] = METHODS.map((m) => ({\n\tlabel: m,\n\tvalue: m,\n}));\n\n/**\n * Keep the Request / Response bodies valid JSON: wrap the picked token in\n * quotes (`\"email\": \"{{variable:customer.email}}\"`) — unless the `@` was typed\n * inside a string literal already (odd number of unescaped `\"` before it, e.g.\n * `\"Bearer @`), where the bare token interpolates into the existing string.\n */\nexport const jsonQuoteToken = (\n\ttoken: string,\n\tctx: { textBefore: string },\n): string => {\n\tconst quotes = ctx.textBefore.match(/(?<!\\\\)\"/g)?.length ?? 0;\n\treturn quotes % 2 === 1 ? token : `\"${token}\"`;\n};\n\n/**\n * Right-side drawer to configure a \"Rest API\" tool: the endpoint the agent can\n * call, plus a JSON request-body template and a sample response. Mount it fresh\n * per open (key it) so `initial` seeds the state. Built on the shared `SideModal`\n * shell and the BikEditor JSON body mode for the Request / Response editors.\n */\nexport const RestApiToolPanel: React.FC<RestApiToolPanelProps> = ({\n\tonClose,\n\tonSave,\n\tinitial,\n\tonImprove,\n\tcharLimits = AGENT_CHAR_LIMITS,\n\tzIndex,\n\texistingNames = [],\n\tvariablesData,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\t// `@`-picked variables insert into the JSON editors at their own cursor.\n\tconst requestEditorRef = useRef<BikEditorRef>(null);\n\tconst responseEditorRef = useRef<BikEditorRef>(null);\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\t// New tools start with the scheme pre-filled so the user only types the host.\n\tconst [url, setUrl] = useState(initial?.url ?? 'https://');\n\tconst [method, setMethod] = useState<RestApiMethod>(\n\t\tinitial?.method ?? 'POST',\n\t);\n\tconst [headers, setHeaders] = useState<RestApiHeader[]>(\n\t\tinitial?.headers ?? [{ key: '', value: '' }],\n\t);\n\tconst [requestBody, setRequestBody] = useState(initial?.requestBody ?? '');\n\tconst [responseSample, setResponseSample] = useState(\n\t\tinitial?.responseSample ?? '',\n\t);\n\tconst [saving, setSaving] = useState(false);\n\n\tconst patchHeader = (i: number, patch: Partial<RestApiHeader>) =>\n\t\tsetHeaders((prev) =>\n\t\t\tprev.map((h, idx) => (idx === i ? { ...h, ...patch } : h)),\n\t\t);\n\tconst addHeader = () =>\n\t\tsetHeaders((prev) => [...prev, { key: '', value: '' }]);\n\tconst removeHeader = (i: number) =>\n\t\tsetHeaders((prev) => prev.filter((_, idx) => idx !== i));\n\n\tconst nameTrimmed = name.trim();\n\t// Case-insensitive: two tools can't share a name (the LLM references them by it).\n\tconst isDuplicateName =\n\t\tnameTrimmed.length > 0 &&\n\t\texistingNames.some(\n\t\t\t(n) => n.trim().toLowerCase() === nameTrimmed.toLowerCase(),\n\t\t);\n\tconst canSave =\n\t\tnameTrimmed.length > 0 && url.trim().length > 0 && !isDuplicateName;\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst config: RestApiToolConfig = {\n\t\t\tid: initial?.id ?? `restapi_${Date.now().toString(36)}`,\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\turl: url.trim(),\n\t\t\tmethod,\n\t\t\t// Drop fully-empty header rows.\n\t\t\theaders: headers.filter((h) => h.key.trim() || h.value.trim()),\n\t\t\trequestBody,\n\t\t\tresponseSample,\n\t\t};\n\t\tconst result = onSave(config);\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\treturn (\n\t\t<SideModal\n\t\t\theader=\"Rest API\"\n\t\t\tcloseOnEscapeKey={false}\n\t\t\tzIndex={zIndex}\n\t\t\theaderCustomComponent={\n\t\t\t\t<DrawerHeaderText\n\t\t\t\t\ttitle=\"Rest API\"\n\t\t\t\t\tsubtitle=\"Connect to any API endpoint. Define the request and a sample response for the agent to reference.\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\twidth=\"431px\"\n\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\tonClose={onClose}\n\t\t\tsaveButtonProps={{\n\t\t\t\t'data-test': 'restapi-save',\n\t\t\t\tbuttonText: 'Save',\n\t\t\t\tbuttonType: 'primary',\n\t\t\t\tsize: 'small',\n\t\t\t\tdisabled: !canSave,\n\t\t\t\tisLoading: saving,\n\t\t\t\tonClick: handleSave,\n\t\t\t}}\n\t\t\tcancelButtonProps={{\n\t\t\t\t'data-test': 'restapi-cancel',\n\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\tsize: 'small',\n\t\t\t\tonClick: onClose,\n\t\t\t}}\n\t\t>\n\t\t\t<Input\n\t\t\t\tdata-test=\"restapi-name\"\n\t\t\t\tvariant=\"small\"\n\t\t\t\tlabelText=\"Name\"\n\t\t\t\tlabelTextBold\n\t\t\t\tplaceholder=\"Enter action name\"\n\t\t\t\tvalue={name}\n\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\tstate={isDuplicateName ? 'invalid' : undefined}\n\t\t\t\terrorMessage={\n\t\t\t\t\tisDuplicateName ? 'A tool with this name already exists' : undefined\n\t\t\t\t}\n\t\t\t\tonChangeText={setName}\n\t\t\t/>\n\n\t\t\t<ToolInstructionsField\n\t\t\t\tdata-test=\"restapi-instructions\"\n\t\t\t\tlabel=\"Instructions\"\n\t\t\t\tvalue={instructions}\n\t\t\t\tonChange={setInstructions}\n\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\tplaceholder=\"Describe how should the LLM generate the rest API\"\n\t\t\t\tonImprove={onImprove}\n\t\t\t\tvariablesData={variablesData}\n\t\t\t/>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<VariableTriggerArea\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\tonInsert={(token, caret) =>\n\t\t\t\t\t\tsetUrl((u) => {\n\t\t\t\t\t\t\tconst at = caret ?? u.length;\n\t\t\t\t\t\t\treturn `${u.slice(0, at)}${token}${u.slice(at)}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"restapi-url\"\n\t\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\t\tlabelText=\"Request URL\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"https://\"\n\t\t\t\t\t\ttype=\"url\"\n\t\t\t\t\t\tvalue={url}\n\t\t\t\t\t\tonChangeText={setUrl}\n\t\t\t\t\t/>\n\t\t\t\t</VariableTriggerArea>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>HTTP method</TitleSmall>\n\t\t\t\t<Dropdown\n\t\t\t\t\tdata-test=\"restapi-method\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\tdropdownWidth=\"399px\"\n\t\t\t\t\toptions={METHOD_OPTIONS}\n\t\t\t\t\tdefaultOptions={[{ label: method, value: method }]}\n\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\tsetMethod(v as RestApiMethod);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Headers</TitleSmall>\n\t\t\t\t{headers.map((h, i) => (\n\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t<HeaderRow key={i} data-test={`restapi-header-${i}`}>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\t\t\thideInputHeader\n\t\t\t\t\t\t\tplaceholder=\"Enter name\"\n\t\t\t\t\t\t\tvalue={h.key}\n\t\t\t\t\t\t\tonChangeText={(v) => patchHeader(i, { key: v })}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<VariableTriggerArea\n\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t\tonInsert={(token, caret) => {\n\t\t\t\t\t\t\t\tconst at = caret ?? h.value.length;\n\t\t\t\t\t\t\t\tpatchHeader(i, {\n\t\t\t\t\t\t\t\t\tvalue: `${h.value.slice(0, at)}${token}${h.value.slice(at)}`,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\t\t\t\thideInputHeader\n\t\t\t\t\t\t\t\tplaceholder=\"Enter value\"\n\t\t\t\t\t\t\t\tvalue={h.value}\n\t\t\t\t\t\t\t\tonChangeText={(v) => patchHeader(i, { value: v })}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</VariableTriggerArea>\n\t\t\t\t\t\t<IconBtn\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\taria-label=\"Remove header\"\n\t\t\t\t\t\t\tdata-test={`restapi-header-remove-${i}`}\n\t\t\t\t\t\t\tonClick={() => removeHeader(i)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</IconBtn>\n\t\t\t\t\t</HeaderRow>\n\t\t\t\t))}\n\t\t\t\t<AddHeaderRow>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"restapi-add-header\"\n\t\t\t\t\t\tbuttonType=\"dashRegular\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\tbuttonText=\"Add header\"\n\t\t\t\t\t\tonClick={addHeader}\n\t\t\t\t\t/>\n\t\t\t\t</AddHeaderRow>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Request </TitleSmall>\n\t\t\t\t<VariableTriggerArea\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\ttransformToken={jsonQuoteToken}\n\t\t\t\t\tonInsert={(token) =>\n\t\t\t\t\t\trequestEditorRef.current?.insertInlineContent(token)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BikEditor\n\t\t\t\t\t\tref={requestEditorRef}\n\t\t\t\t\t\tfeatures={{ jsonMode: true }}\n\t\t\t\t\t\tinitialContent={requestBody}\n\t\t\t\t\t\tstyle={JsonFieldBox}\n\t\t\t\t\t\tplaceholder=\"Type or paste JSON here\"\n\t\t\t\t\t\tonChange={(c) => setRequestBody(c.text)}\n\t\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\t\tmaxHeight=\"240px\"\n\t\t\t\t\t/>\n\t\t\t\t</VariableTriggerArea>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Response </TitleSmall>\n\t\t\t\t<VariableTriggerArea\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\ttransformToken={jsonQuoteToken}\n\t\t\t\t\tonInsert={(token) =>\n\t\t\t\t\t\tresponseEditorRef.current?.insertInlineContent(token)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BikEditor\n\t\t\t\t\t\tref={responseEditorRef}\n\t\t\t\t\t\tfeatures={{ jsonMode: true }}\n\t\t\t\t\t\tstyle={JsonFieldBox}\n\t\t\t\t\t\tinitialContent={responseSample}\n\t\t\t\t\t\tplaceholder=\"Type or paste JSON here\"\n\t\t\t\t\t\tonChange={(c) => setResponseSample(c.text)}\n\t\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\t\tmaxHeight=\"240px\"\n\t\t\t\t\t/>\n\t\t\t\t</VariableTriggerArea>\n\t\t\t</FieldBlock>\n\t\t</SideModal>\n\t);\n};\n\nconst HeaderRow = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n`;\n\nconst AddHeaderRow = styled.div`\n\tdisplay: flex;\n`;\n\nconst IconBtn = styled.button`\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex-shrink: 0;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\tbackground: ${COLORS.surface.standard};\n\tcursor: pointer;\n\n\t&:hover {\n\t\tborder-color: ${COLORS.content.secondary};\n\t}\n`;\n\nexport const JsonFieldBox = {\n\tborderRadius: '4px',\n\toverflow: 'hidden',\n};\n"],"names":["METHODS","METHOD_OPTIONS","m","jsonQuoteToken","token","ctx","RestApiToolPanel","onClose","onSave","initial","onImprove","charLimits","AGENT_CHAR_LIMITS","zIndex","existingNames","variablesData","name","setName","useState","requestEditorRef","useRef","responseEditorRef","instructions","setInstructions","url","setUrl","method","setMethod","headers","setHeaders","requestBody","setRequestBody","responseSample","setResponseSample","saving","setSaving","patchHeader","i","patch","prev","h","idx","addHeader","removeHeader","_","nameTrimmed","isDuplicateName","n","canSave","jsxs","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","config","result","Input","ToolInstructionsField","FieldBlock","VariableTriggerArea","caret","u","at","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","HeaderRow","IconBtn","DeleteIcon","AddHeaderRow","Button","PlusIcon","BikEditor","JsonFieldBox","c","styled"],"mappings":";;;;;;;;;;;;;;;;;;AAkDA,MAAMA,KAA2B,CAAC,OAA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AA;AAAA;AAAA;AAAA,kBAIpBA,EAAO,QAAQ,SAAS;AAAA;AAAA,GAI7BY,IAAe;AAAA,EAC3B,cAAc;AAAA,EACd,UAAU;AACX;"}
|
|
1
|
+
{"version":3,"file":"RestApiToolPanel.js","sources":["../../../../../src/components/agent-builder/components/RestApiToolPanel.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { BikEditor } from '@src/editor';\nimport React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport type { VariableListInterfaceV3 } from '../../variable-picker-v3/model';\nimport {\n\tRestApiHeader,\n\tRestApiMethod,\n\tRestApiToolConfig,\n} from '../AgentBuilder.model';\nimport { FieldBlock } from '../AgentBuilder.styled';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { ToolInstructionsField } from './ToolInstructionsField';\nimport { VariableInlineField } from './VariableInlineField';\n\ninterface RestApiToolPanelProps {\n\tonClose: () => void;\n\t/** Persist the config. A pending promise shows the Save loader. */\n\tonSave: (config: RestApiToolConfig) => void | Promise<void>;\n\t/** Seed values when editing an existing tool. */\n\tinitial?: RestApiToolConfig;\n\t/** Optional \"Improve with AI\" for the instructions field. Omit to hide it. */\n\tonImprove?: (text: string) => Promise<string>;\n\tcharLimits?: AgentCharLimits;\n\t/** SideModal stacking order — raise it when opened over another drawer. */\n\tzIndex?: number;\n\t/** Names of the OTHER tools — a new tool can't reuse one of these. */\n\texistingNames?: string[];\n\t/**\n\t * Variable catalog for the `@` trigger. When non-empty, `@` opens the\n\t * variable picker directly in Instructions / Request URL / header values.\n\t * (Request / Response JSON editors are deliberately not wired for now.)\n\t * Absent → the drawer behaves exactly as before.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n}\n\nconst METHODS: RestApiMethod[] = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];\nconst METHOD_OPTIONS: SingleOption[] = METHODS.map((m) => ({\n\tlabel: m,\n\tvalue: m,\n}));\n\n/**\n * Keep the Request / Response bodies valid JSON: wrap the picked token in\n * quotes (`\"email\": \"{{variable:customer.email}}\"`) — unless the `@` was typed\n * inside a string literal already (odd number of unescaped `\"` before it, e.g.\n * `\"Bearer @`), where the bare token interpolates into the existing string.\n */\nexport const jsonQuoteToken = (\n\ttoken: string,\n\tctx: { textBefore: string },\n): string => {\n\tconst quotes = ctx.textBefore.match(/(?<!\\\\)\"/g)?.length ?? 0;\n\treturn quotes % 2 === 1 ? token : `\"${token}\"`;\n};\n\n/**\n * Right-side drawer to configure a \"Rest API\" tool: the endpoint the agent can\n * call, plus a JSON request-body template and a sample response. Mount it fresh\n * per open (key it) so `initial` seeds the state. Built on the shared `SideModal`\n * shell and the BikEditor JSON body mode for the Request / Response editors.\n */\nexport const RestApiToolPanel: React.FC<RestApiToolPanelProps> = ({\n\tonClose,\n\tonSave,\n\tinitial,\n\tonImprove,\n\tcharLimits = AGENT_CHAR_LIMITS,\n\tzIndex,\n\texistingNames = [],\n\tvariablesData,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\t// New tools start with the scheme pre-filled so the user only types the host.\n\tconst [url, setUrl] = useState(initial?.url ?? 'https://');\n\tconst [method, setMethod] = useState<RestApiMethod>(\n\t\tinitial?.method ?? 'POST',\n\t);\n\tconst [headers, setHeaders] = useState<RestApiHeader[]>(\n\t\tinitial?.headers ?? [{ key: '', value: '' }],\n\t);\n\tconst [requestBody, setRequestBody] = useState(initial?.requestBody ?? '');\n\tconst [responseSample, setResponseSample] = useState(\n\t\tinitial?.responseSample ?? '',\n\t);\n\tconst [saving, setSaving] = useState(false);\n\n\tconst patchHeader = (i: number, patch: Partial<RestApiHeader>) =>\n\t\tsetHeaders((prev) =>\n\t\t\tprev.map((h, idx) => (idx === i ? { ...h, ...patch } : h)),\n\t\t);\n\tconst addHeader = () =>\n\t\tsetHeaders((prev) => [...prev, { key: '', value: '' }]);\n\tconst removeHeader = (i: number) =>\n\t\tsetHeaders((prev) => prev.filter((_, idx) => idx !== i));\n\n\tconst nameTrimmed = name.trim();\n\t// Case-insensitive: two tools can't share a name (the LLM references them by it).\n\tconst isDuplicateName =\n\t\tnameTrimmed.length > 0 &&\n\t\texistingNames.some(\n\t\t\t(n) => n.trim().toLowerCase() === nameTrimmed.toLowerCase(),\n\t\t);\n\tconst canSave =\n\t\tnameTrimmed.length > 0 && url.trim().length > 0 && !isDuplicateName;\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst config: RestApiToolConfig = {\n\t\t\tid: initial?.id ?? `restapi_${Date.now().toString(36)}`,\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\turl: url.trim(),\n\t\t\tmethod,\n\t\t\t// Drop fully-empty header rows.\n\t\t\theaders: headers.filter((h) => h.key.trim() || h.value.trim()),\n\t\t\trequestBody,\n\t\t\tresponseSample,\n\t\t};\n\t\tconst result = onSave(config);\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\treturn (\n\t\t<SideModal\n\t\t\theader=\"Rest API\"\n\t\t\tcloseOnEscapeKey={false}\n\t\t\tzIndex={zIndex}\n\t\t\theaderCustomComponent={\n\t\t\t\t<DrawerHeaderText\n\t\t\t\t\ttitle=\"Rest API\"\n\t\t\t\t\tsubtitle=\"Connect to any API endpoint. Define the request and a sample response for the agent to reference.\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\twidth=\"431px\"\n\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\tonClose={onClose}\n\t\t\tsaveButtonProps={{\n\t\t\t\t'data-test': 'restapi-save',\n\t\t\t\tbuttonText: 'Save',\n\t\t\t\tbuttonType: 'primary',\n\t\t\t\tsize: 'small',\n\t\t\t\tdisabled: !canSave,\n\t\t\t\tisLoading: saving,\n\t\t\t\tonClick: handleSave,\n\t\t\t}}\n\t\t\tcancelButtonProps={{\n\t\t\t\t'data-test': 'restapi-cancel',\n\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\tsize: 'small',\n\t\t\t\tonClick: onClose,\n\t\t\t}}\n\t\t>\n\t\t\t<Input\n\t\t\t\tdata-test=\"restapi-name\"\n\t\t\t\tvariant=\"small\"\n\t\t\t\tlabelText=\"Name\"\n\t\t\t\tlabelTextBold\n\t\t\t\tplaceholder=\"Enter action name\"\n\t\t\t\tvalue={name}\n\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\tstate={isDuplicateName ? 'invalid' : undefined}\n\t\t\t\terrorMessage={\n\t\t\t\t\tisDuplicateName ? 'A tool with this name already exists' : undefined\n\t\t\t\t}\n\t\t\t\tonChangeText={setName}\n\t\t\t/>\n\n\t\t\t<ToolInstructionsField\n\t\t\t\tdata-test=\"restapi-instructions\"\n\t\t\t\tlabel=\"Instructions\"\n\t\t\t\tvalue={instructions}\n\t\t\t\tonChange={setInstructions}\n\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\tplaceholder=\"Describe how should the LLM generate the rest API\"\n\t\t\t\tonImprove={onImprove}\n\t\t\t\tvariablesData={variablesData}\n\t\t\t/>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<VariableInlineField\n\t\t\t\t\tdata-test=\"restapi-url\"\n\t\t\t\t\tlabel=\"Request URL\"\n\t\t\t\t\tplaceholder=\"https://\"\n\t\t\t\t\tvalue={url}\n\t\t\t\t\tonChange={setUrl}\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t/>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>HTTP method</TitleSmall>\n\t\t\t\t<Dropdown\n\t\t\t\t\tdata-test=\"restapi-method\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\tdropdownWidth=\"399px\"\n\t\t\t\t\toptions={METHOD_OPTIONS}\n\t\t\t\t\tdefaultOptions={[{ label: method, value: method }]}\n\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\tsetMethod(v as RestApiMethod);\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Headers</TitleSmall>\n\t\t\t\t{headers.map((h, i) => (\n\t\t\t\t\t// Key includes the row count: the value field is an uncontrolled\n\t\t\t\t\t// editor, so add/remove must remount rows or a deleted row's text\n\t\t\t\t\t// would linger in its reused neighbour.\n\t\t\t\t\t// eslint-disable-next-line react/no-array-index-key\n\t\t\t\t\t<HeaderRow\n\t\t\t\t\t\tkey={`${i}:${headers.length}`}\n\t\t\t\t\t\tdata-test={`restapi-header-${i}`}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\t\t\thideInputHeader\n\t\t\t\t\t\t\tplaceholder=\"Enter name\"\n\t\t\t\t\t\t\tvalue={h.key}\n\t\t\t\t\t\t\tonChangeText={(v) => patchHeader(i, { key: v })}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<VariableInlineField\n\t\t\t\t\t\t\tplaceholder=\"Enter value\"\n\t\t\t\t\t\t\tvalue={h.value}\n\t\t\t\t\t\t\tonChange={(v) => patchHeader(i, { value: v })}\n\t\t\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<IconBtn\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\taria-label=\"Remove header\"\n\t\t\t\t\t\t\tdata-test={`restapi-header-remove-${i}`}\n\t\t\t\t\t\t\tonClick={() => removeHeader(i)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</IconBtn>\n\t\t\t\t\t</HeaderRow>\n\t\t\t\t))}\n\t\t\t\t<AddHeaderRow>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"restapi-add-header\"\n\t\t\t\t\t\tbuttonType=\"dashRegular\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\tbuttonText=\"Add header\"\n\t\t\t\t\t\tonClick={addHeader}\n\t\t\t\t\t/>\n\t\t\t\t</AddHeaderRow>\n\t\t\t</FieldBlock>\n\n\t\t\t{/* Variables intentionally NOT wired here (yet) — the JSON editors are\n\t\t\t plain code fields; @ types a literal @. */}\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Request </TitleSmall>\n\t\t\t\t<BikEditor\n\t\t\t\t\tfeatures={{ jsonMode: true }}\n\t\t\t\t\tinitialContent={requestBody}\n\t\t\t\t\tstyle={JsonFieldBox}\n\t\t\t\t\tplaceholder=\"Type or paste JSON here\"\n\t\t\t\t\tonChange={(c) => setRequestBody(c.text)}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"240px\"\n\t\t\t\t/>\n\t\t\t</FieldBlock>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>Response </TitleSmall>\n\t\t\t\t<BikEditor\n\t\t\t\t\tfeatures={{ jsonMode: true }}\n\t\t\t\t\tstyle={JsonFieldBox}\n\t\t\t\t\tinitialContent={responseSample}\n\t\t\t\t\tplaceholder=\"Type or paste JSON here\"\n\t\t\t\t\tonChange={(c) => setResponseSample(c.text)}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"240px\"\n\t\t\t\t/>\n\t\t\t</FieldBlock>\n\t\t</SideModal>\n\t);\n};\n\n// Fixed tracks (name / value / delete): minmax(0, …) lets the fields shrink\n// below their content width, so a long value scrolls inside its field and the\n// delete button can never be pushed off the row.\nconst HeaderRow = styled.div`\n\tdisplay: grid;\n\tgrid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 32px;\n\talign-items: center;\n\tgap: 8px;\n`;\n\nconst AddHeaderRow = styled.div`\n\tdisplay: flex;\n`;\n\nconst IconBtn = styled.button`\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex-shrink: 0;\n\twidth: 32px;\n\theight: 32px;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\tbackground: ${COLORS.surface.standard};\n\tcursor: pointer;\n\n\t&:hover {\n\t\tborder-color: ${COLORS.content.secondary};\n\t}\n`;\n\nexport const JsonFieldBox = {\n\tborderRadius: '4px',\n\toverflow: 'hidden',\n};\n"],"names":["METHODS","METHOD_OPTIONS","m","RestApiToolPanel","onClose","onSave","initial","onImprove","charLimits","AGENT_CHAR_LIMITS","zIndex","existingNames","variablesData","name","setName","useState","instructions","setInstructions","url","setUrl","method","setMethod","headers","setHeaders","requestBody","setRequestBody","responseSample","setResponseSample","saving","setSaving","patchHeader","i","patch","prev","h","idx","addHeader","removeHeader","_","nameTrimmed","isDuplicateName","n","canSave","jsxs","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","config","result","Input","ToolInstructionsField","FieldBlock","VariableInlineField","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","HeaderRow","IconBtn","DeleteIcon","AddHeaderRow","Button","PlusIcon","BikEditor","JsonFieldBox","c","styled"],"mappings":";;;;;;;;;;;;;;;;;;AAmDA,MAAMA,KAA2B,CAAC,OAAO,QAAQ,OAAO,SAAS,QAAQ,GACnEC,KAAiCD,GAAQ,IAAI,CAACE,OAAO;AAAA,EAC1D,OAAOA;AAAA,EACP,OAAOA;AACR,EAAE,GAsBWC,KAAoD,CAAC;AAAA,EACjE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC,IAAaC;AAAA,EACb,QAAAC;AAAA,EACA,eAAAC,IAAgB,CAAA;AAAA,EAChB,eAAAC;AACD,MAAM;AACL,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAST,GAAS,QAAQ,EAAE,GAC9C,CAACU,GAAcC,CAAe,IAAIF,EAAST,GAAS,gBAAgB,EAAE,GAEtE,CAACY,GAAKC,CAAM,IAAIJ,EAAST,GAAS,OAAO,UAAU,GACnD,CAACc,GAAQC,CAAS,IAAIN;AAAA,IAC3BT,GAAS,UAAU;AAAA,EAAA,GAEd,CAACgB,GAASC,CAAU,IAAIR;AAAA,IAC7BT,GAAS,WAAW,CAAC,EAAE,KAAK,IAAI,OAAO,IAAI;AAAA,EAAA,GAEtC,CAACkB,GAAaC,CAAc,IAAIV,EAAST,GAAS,eAAe,EAAE,GACnE,CAACoB,GAAgBC,CAAiB,IAAIZ;AAAA,IAC3CT,GAAS,kBAAkB;AAAA,EAAA,GAEtB,CAACsB,GAAQC,CAAS,IAAId,EAAS,EAAK,GAEpCe,IAAc,CAACC,GAAWC,MAC/BT;AAAA,IAAW,CAACU,MACXA,EAAK,I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