@bikdotai/bik-component-library 0.0.849-beta.2 → 0.0.849-beta.3
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/ConfigToolPanel.js +11 -11
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +5 -5
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +7 -7
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js +9 -0
- package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js.map +1 -0
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
- package/dist/cjs/editor/extensions/mention/MentionDropdown.js.map +1 -1
- package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
- package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.d.ts +8 -0
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +151 -124
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +90 -88
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +7 -0
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +174 -133
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.d.ts +9 -0
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +65 -47
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.d.ts +27 -0
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +70 -0
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.js.map +1 -0
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +93 -91
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionDropdown.js +19 -19
- package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionExtension.js +15 -15
- package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,87 +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 {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import V from "../../../assets/icons/delete.svg.js";
|
|
3
|
+
import K from "../../../assets/icons/plus.svg.js";
|
|
4
|
+
import { useState as s, useRef as $ } from "react";
|
|
5
|
+
import R from "styled-components";
|
|
6
|
+
import { TitleSmall as u } from "../../TypographyStyle.js";
|
|
7
|
+
import { COLORS as l } from "../../../constants/Theme.js";
|
|
8
|
+
import { FieldBlock as p } from "../AgentBuilder.styled.js";
|
|
9
|
+
import { AGENT_CHAR_LIMITS as Q } from "../constants/charLimits.js";
|
|
10
|
+
import { DRAWER_BODY_STYLE as X, DRAWER_HEADER_STYLE as Z, DrawerHeaderText as ee } from "./DrawerHeaderText.js";
|
|
11
|
+
import { ToolInstructionsField as te } from "./ToolInstructionsField.js";
|
|
12
|
+
import { VariableTriggerArea as h } from "./VariableTriggerArea.js";
|
|
13
|
+
import { SideModal as re } from "../../side-modal/SideModal.js";
|
|
14
|
+
import { Input as f } from "../../input/Input.js";
|
|
15
|
+
import { Dropdown as oe } from "../../dropdown/Dropdown.js";
|
|
16
|
+
import { unwrapDropdownValue as ne } from "../../dropdown/utils.js";
|
|
17
|
+
import { Button as ae } from "../../button/Button.js";
|
|
18
|
+
import { BikEditor as D } from "../../../editor/BikEditor.js";
|
|
19
|
+
const se = ["GET", "POST", "PUT", "PATCH", "DELETE"], le = se.map((d) => ({
|
|
20
|
+
label: d,
|
|
21
|
+
value: d
|
|
22
|
+
})), ke = ({
|
|
23
|
+
onClose: d,
|
|
24
|
+
onSave: _,
|
|
24
25
|
initial: a,
|
|
25
|
-
onImprove:
|
|
26
|
-
charLimits:
|
|
27
|
-
zIndex:
|
|
28
|
-
existingNames:
|
|
26
|
+
onImprove: q,
|
|
27
|
+
charLimits: b = Q,
|
|
28
|
+
zIndex: N,
|
|
29
|
+
existingNames: j = [],
|
|
30
|
+
variablesData: c
|
|
29
31
|
}) => {
|
|
30
|
-
const [
|
|
32
|
+
const [y, z] = s(a?.name ?? ""), I = $(null), E = $(null), [H, F] = s(a?.instructions ?? ""), [x, w] = s(a?.url ?? "https://"), [v, G] = s(
|
|
31
33
|
a?.method ?? "POST"
|
|
32
|
-
), [
|
|
34
|
+
), [A, g] = s(
|
|
33
35
|
a?.headers ?? [{ key: "", value: "" }]
|
|
34
|
-
), [
|
|
36
|
+
), [k, J] = s(a?.requestBody ?? ""), [P, U] = s(
|
|
35
37
|
a?.responseSample ?? ""
|
|
36
|
-
), [
|
|
37
|
-
(o) => o.map((
|
|
38
|
-
),
|
|
39
|
-
(e) => e.trim().toLowerCase() ===
|
|
40
|
-
),
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
|
|
38
|
+
), [B, L] = s(!1), T = (e, r) => g(
|
|
39
|
+
(o) => o.map((n, m) => m === e ? { ...n, ...r } : n)
|
|
40
|
+
), W = () => g((e) => [...e, { key: "", value: "" }]), Y = (e) => g((r) => r.filter((o, n) => n !== e)), S = y.trim(), C = S.length > 0 && j.some(
|
|
41
|
+
(e) => e.trim().toLowerCase() === S.toLowerCase()
|
|
42
|
+
), O = S.length > 0 && x.trim().length > 0 && !C;
|
|
43
|
+
return /* @__PURE__ */ i(
|
|
44
|
+
re,
|
|
43
45
|
{
|
|
44
46
|
header: "Rest API",
|
|
45
47
|
closeOnEscapeKey: !1,
|
|
46
|
-
zIndex:
|
|
48
|
+
zIndex: N,
|
|
47
49
|
headerCustomComponent: /* @__PURE__ */ t(
|
|
48
|
-
|
|
50
|
+
ee,
|
|
49
51
|
{
|
|
50
52
|
title: "Rest API",
|
|
51
53
|
subtitle: "Connect to any API endpoint. Define the request and a sample response for the agent to reference."
|
|
52
54
|
}
|
|
53
55
|
),
|
|
54
56
|
width: "431px",
|
|
55
|
-
headerStyle:
|
|
56
|
-
bodyStyle:
|
|
57
|
-
onClose:
|
|
57
|
+
headerStyle: Z,
|
|
58
|
+
bodyStyle: X,
|
|
59
|
+
onClose: d,
|
|
58
60
|
saveButtonProps: {
|
|
59
61
|
"data-test": "restapi-save",
|
|
60
62
|
buttonText: "Save",
|
|
61
63
|
buttonType: "primary",
|
|
62
64
|
size: "small",
|
|
63
|
-
disabled: !
|
|
64
|
-
isLoading:
|
|
65
|
+
disabled: !O,
|
|
66
|
+
isLoading: B,
|
|
65
67
|
onClick: async () => {
|
|
66
|
-
if (!
|
|
68
|
+
if (!O || B)
|
|
67
69
|
return;
|
|
68
70
|
const e = {
|
|
69
71
|
id: a?.id ?? `restapi_${Date.now().toString(36)}`,
|
|
70
|
-
name:
|
|
71
|
-
instructions:
|
|
72
|
-
url:
|
|
73
|
-
method:
|
|
72
|
+
name: y.trim(),
|
|
73
|
+
instructions: H,
|
|
74
|
+
url: x.trim(),
|
|
75
|
+
method: v,
|
|
74
76
|
// Drop fully-empty header rows.
|
|
75
|
-
headers:
|
|
76
|
-
requestBody:
|
|
77
|
-
responseSample:
|
|
78
|
-
}, r =
|
|
77
|
+
headers: A.filter((o) => o.key.trim() || o.value.trim()),
|
|
78
|
+
requestBody: k,
|
|
79
|
+
responseSample: P
|
|
80
|
+
}, r = _(e);
|
|
79
81
|
if (r && typeof r.then == "function") {
|
|
80
|
-
|
|
82
|
+
L(!0);
|
|
81
83
|
try {
|
|
82
84
|
await r;
|
|
83
85
|
} finally {
|
|
84
|
-
|
|
86
|
+
L(!1);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -91,183 +93,222 @@ const te = ["GET", "POST", "PUT", "PATCH", "DELETE"], re = te.map((i) => ({
|
|
|
91
93
|
buttonText: "Cancel",
|
|
92
94
|
buttonType: "tertiaryGray",
|
|
93
95
|
size: "small",
|
|
94
|
-
onClick:
|
|
96
|
+
onClick: d
|
|
95
97
|
},
|
|
96
98
|
children: [
|
|
97
99
|
/* @__PURE__ */ t(
|
|
98
|
-
|
|
100
|
+
f,
|
|
99
101
|
{
|
|
100
102
|
"data-test": "restapi-name",
|
|
101
103
|
variant: "small",
|
|
102
104
|
labelText: "Name",
|
|
103
105
|
labelTextBold: !0,
|
|
104
106
|
placeholder: "Enter action name",
|
|
105
|
-
value:
|
|
106
|
-
maxCharLimit:
|
|
107
|
-
state:
|
|
108
|
-
errorMessage:
|
|
109
|
-
onChangeText:
|
|
107
|
+
value: y,
|
|
108
|
+
maxCharLimit: b.name,
|
|
109
|
+
state: C ? "invalid" : void 0,
|
|
110
|
+
errorMessage: C ? "A tool with this name already exists" : void 0,
|
|
111
|
+
onChangeText: z
|
|
110
112
|
}
|
|
111
113
|
),
|
|
112
114
|
/* @__PURE__ */ t(
|
|
113
|
-
|
|
115
|
+
te,
|
|
114
116
|
{
|
|
115
117
|
"data-test": "restapi-instructions",
|
|
116
118
|
label: "Instructions",
|
|
117
|
-
value:
|
|
118
|
-
onChange:
|
|
119
|
-
maxLength:
|
|
119
|
+
value: H,
|
|
120
|
+
onChange: F,
|
|
121
|
+
maxLength: b.instructions,
|
|
120
122
|
placeholder: "Describe how should the LLM generate the rest API",
|
|
121
|
-
onImprove:
|
|
123
|
+
onImprove: q,
|
|
124
|
+
variablesData: c
|
|
122
125
|
}
|
|
123
126
|
),
|
|
124
|
-
/* @__PURE__ */ t(
|
|
125
|
-
|
|
127
|
+
/* @__PURE__ */ t(p, { children: /* @__PURE__ */ t(
|
|
128
|
+
h,
|
|
126
129
|
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
variablesData: c,
|
|
131
|
+
onInsert: (e, r) => w((o) => {
|
|
132
|
+
const n = r ?? o.length;
|
|
133
|
+
return `${o.slice(0, n)}${e}${o.slice(n)}`;
|
|
134
|
+
}),
|
|
135
|
+
children: /* @__PURE__ */ t(
|
|
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: x,
|
|
145
|
+
onChangeText: w
|
|
146
|
+
}
|
|
147
|
+
)
|
|
135
148
|
}
|
|
136
149
|
) }),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ t(
|
|
150
|
+
/* @__PURE__ */ i(p, { children: [
|
|
151
|
+
/* @__PURE__ */ t(u, { color: l.content.primary, children: "HTTP method" }),
|
|
139
152
|
/* @__PURE__ */ t(
|
|
140
|
-
|
|
153
|
+
oe,
|
|
141
154
|
{
|
|
142
155
|
"data-test": "restapi-method",
|
|
143
156
|
size: "small",
|
|
144
157
|
width: "100%",
|
|
145
158
|
dropdownWidth: "399px",
|
|
146
|
-
options:
|
|
147
|
-
defaultOptions: [{ label:
|
|
159
|
+
options: le,
|
|
160
|
+
defaultOptions: [{ label: v, value: v }],
|
|
148
161
|
onSelect: (e) => {
|
|
149
|
-
const r =
|
|
150
|
-
r &&
|
|
162
|
+
const r = ne(e);
|
|
163
|
+
r && G(r);
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
)
|
|
154
167
|
] }),
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */ t(
|
|
157
|
-
|
|
168
|
+
/* @__PURE__ */ i(p, { children: [
|
|
169
|
+
/* @__PURE__ */ t(u, { color: l.content.primary, children: "Headers" }),
|
|
170
|
+
A.map((e, r) => (
|
|
158
171
|
// eslint-disable-next-line react/no-array-index-key
|
|
159
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ i(ie, { "data-test": `restapi-header-${r}`, children: [
|
|
160
173
|
/* @__PURE__ */ t(
|
|
161
|
-
|
|
174
|
+
f,
|
|
162
175
|
{
|
|
163
176
|
variant: "small",
|
|
164
177
|
hideInputHeader: !0,
|
|
165
178
|
placeholder: "Enter name",
|
|
166
179
|
value: e.key,
|
|
167
|
-
onChangeText: (o) =>
|
|
180
|
+
onChangeText: (o) => T(r, { key: o })
|
|
168
181
|
}
|
|
169
182
|
),
|
|
170
183
|
/* @__PURE__ */ t(
|
|
171
|
-
|
|
184
|
+
h,
|
|
172
185
|
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
186
|
+
variablesData: c,
|
|
187
|
+
onInsert: (o, n) => {
|
|
188
|
+
const m = n ?? e.value.length;
|
|
189
|
+
T(r, {
|
|
190
|
+
value: `${e.value.slice(0, m)}${o}${e.value.slice(m)}`
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
children: /* @__PURE__ */ t(
|
|
194
|
+
f,
|
|
195
|
+
{
|
|
196
|
+
variant: "small",
|
|
197
|
+
hideInputHeader: !0,
|
|
198
|
+
placeholder: "Enter value",
|
|
199
|
+
value: e.value,
|
|
200
|
+
onChangeText: (o) => T(r, { value: o })
|
|
201
|
+
}
|
|
202
|
+
)
|
|
178
203
|
}
|
|
179
204
|
),
|
|
180
205
|
/* @__PURE__ */ t(
|
|
181
|
-
|
|
206
|
+
ce,
|
|
182
207
|
{
|
|
183
208
|
type: "button",
|
|
184
209
|
"aria-label": "Remove header",
|
|
185
210
|
"data-test": `restapi-header-remove-${r}`,
|
|
186
|
-
onClick: () =>
|
|
211
|
+
onClick: () => Y(r),
|
|
187
212
|
children: /* @__PURE__ */ t(
|
|
188
|
-
|
|
213
|
+
V,
|
|
189
214
|
{
|
|
190
215
|
width: 16,
|
|
191
216
|
height: 16,
|
|
192
|
-
color:
|
|
217
|
+
color: l.content.secondary
|
|
193
218
|
}
|
|
194
219
|
)
|
|
195
220
|
}
|
|
196
221
|
)
|
|
197
222
|
] }, r)
|
|
198
223
|
)),
|
|
199
|
-
/* @__PURE__ */ t(
|
|
200
|
-
|
|
224
|
+
/* @__PURE__ */ t(de, { children: /* @__PURE__ */ t(
|
|
225
|
+
ae,
|
|
201
226
|
{
|
|
202
227
|
"data-test": "restapi-add-header",
|
|
203
228
|
buttonType: "dashRegular",
|
|
204
229
|
size: "small",
|
|
205
|
-
LeadingIcon:
|
|
230
|
+
LeadingIcon: K,
|
|
206
231
|
buttonText: "Add header",
|
|
207
|
-
onClick:
|
|
232
|
+
onClick: W
|
|
208
233
|
}
|
|
209
234
|
) })
|
|
210
235
|
] }),
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */ t(
|
|
236
|
+
/* @__PURE__ */ i(p, { children: [
|
|
237
|
+
/* @__PURE__ */ t(u, { color: l.content.primary, children: "Request " }),
|
|
213
238
|
/* @__PURE__ */ t(
|
|
214
|
-
|
|
239
|
+
h,
|
|
215
240
|
{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
241
|
+
variablesData: c,
|
|
242
|
+
onInsert: (e) => I.current?.insertInlineContent(e),
|
|
243
|
+
children: /* @__PURE__ */ t(
|
|
244
|
+
D,
|
|
245
|
+
{
|
|
246
|
+
ref: I,
|
|
247
|
+
features: { jsonMode: !0 },
|
|
248
|
+
initialContent: k,
|
|
249
|
+
style: M,
|
|
250
|
+
placeholder: "Type or paste JSON here",
|
|
251
|
+
onChange: (e) => J(e.text),
|
|
252
|
+
minHeight: "120px",
|
|
253
|
+
maxHeight: "240px"
|
|
254
|
+
}
|
|
255
|
+
)
|
|
223
256
|
}
|
|
224
257
|
)
|
|
225
258
|
] }),
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
/* @__PURE__ */ t(
|
|
259
|
+
/* @__PURE__ */ i(p, { children: [
|
|
260
|
+
/* @__PURE__ */ t(u, { color: l.content.primary, children: "Response " }),
|
|
228
261
|
/* @__PURE__ */ t(
|
|
229
|
-
|
|
262
|
+
h,
|
|
230
263
|
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
264
|
+
variablesData: c,
|
|
265
|
+
onInsert: (e) => E.current?.insertInlineContent(e),
|
|
266
|
+
children: /* @__PURE__ */ t(
|
|
267
|
+
D,
|
|
268
|
+
{
|
|
269
|
+
ref: E,
|
|
270
|
+
features: { jsonMode: !0 },
|
|
271
|
+
style: M,
|
|
272
|
+
initialContent: P,
|
|
273
|
+
placeholder: "Type or paste JSON here",
|
|
274
|
+
onChange: (e) => U(e.text),
|
|
275
|
+
minHeight: "120px",
|
|
276
|
+
maxHeight: "240px"
|
|
277
|
+
}
|
|
278
|
+
)
|
|
238
279
|
}
|
|
239
280
|
)
|
|
240
281
|
] })
|
|
241
282
|
]
|
|
242
283
|
}
|
|
243
284
|
);
|
|
244
|
-
},
|
|
285
|
+
}, ie = R.div`
|
|
245
286
|
display: flex;
|
|
246
287
|
align-items: center;
|
|
247
288
|
gap: 8px;
|
|
248
|
-
`,
|
|
289
|
+
`, de = R.div`
|
|
249
290
|
display: flex;
|
|
250
|
-
`,
|
|
291
|
+
`, ce = R.button`
|
|
251
292
|
display: inline-flex;
|
|
252
293
|
align-items: center;
|
|
253
294
|
justify-content: center;
|
|
254
295
|
flex-shrink: 0;
|
|
255
296
|
width: 32px;
|
|
256
297
|
height: 32px;
|
|
257
|
-
border: 1px solid ${
|
|
298
|
+
border: 1px solid ${l.stroke.primary};
|
|
258
299
|
border-radius: 4px;
|
|
259
|
-
background: ${
|
|
300
|
+
background: ${l.surface.standard};
|
|
260
301
|
cursor: pointer;
|
|
261
302
|
|
|
262
303
|
&:hover {
|
|
263
|
-
border-color: ${
|
|
304
|
+
border-color: ${l.content.secondary};
|
|
264
305
|
}
|
|
265
|
-
`,
|
|
306
|
+
`, M = {
|
|
266
307
|
borderRadius: "4px",
|
|
267
308
|
overflow: "hidden"
|
|
268
309
|
};
|
|
269
310
|
export {
|
|
270
|
-
|
|
271
|
-
|
|
311
|
+
M as JsonFieldBox,
|
|
312
|
+
ke as RestApiToolPanel
|
|
272
313
|
};
|
|
273
314
|
//# 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 } 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 {\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';\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}\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 * 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}) => {\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/>\n\n\t\t\t<FieldBlock>\n\t\t\t\t<Input\n\t\t\t\t\tdata-test=\"restapi-url\"\n\t\t\t\t\tvariant=\"small\"\n\t\t\t\t\tlabelText=\"Request URL\"\n\t\t\t\t\tlabelTextBold\n\t\t\t\t\tplaceholder=\"https://\"\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tvalue={url}\n\t\t\t\t\tonChangeText={setUrl}\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// 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<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 value\"\n\t\t\t\t\t\t\tvalue={h.value}\n\t\t\t\t\t\t\tonChangeText={(v) => patchHeader(i, { value: v })}\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<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\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","RestApiToolPanel","onClose","onSave","initial","onImprove","charLimits","AGENT_CHAR_LIMITS","zIndex","existingNames","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","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","HeaderRow","IconBtn","DeleteIcon","AddHeaderRow","Button","PlusIcon","BikEditor","JsonFieldBox","c","styled"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAMA,KAA2B,CAAC,OAAO,QAAQ,OAAO,SAAS,QAAQ,GACnEC,KAAiCD,GAAQ,IAAI,CAACE,OAAO;AAAA,EAC1D,OAAOA;AAAA,EACP,OAAOA;AACR,EAAE,GAQWC,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;AACjB,MAAM;AACL,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAASR,GAAS,QAAQ,EAAE,GAC9C,CAACS,GAAcC,CAAe,IAAIF,EAASR,GAAS,gBAAgB,EAAE,GAEtE,CAACW,GAAKC,CAAM,IAAIJ,EAASR,GAAS,OAAO,UAAU,GACnD,CAACa,GAAQC,CAAS,IAAIN;AAAA,IAC3BR,GAAS,UAAU;AAAA,EAAA,GAEd,CAACe,GAASC,CAAU,IAAIR;AAAA,IAC7BR,GAAS,WAAW,CAAC,EAAE,KAAK,IAAI,OAAO,IAAI;AAAA,EAAA,GAEtC,CAACiB,GAAaC,CAAc,IAAIV,EAASR,GAAS,eAAe,EAAE,GACnE,CAACmB,GAAgBC,CAAiB,IAAIZ;AAAA,IAC3CR,GAAS,kBAAkB;AAAA,EAAA,GAEtB,CAACqB,GAAQC,CAAS,IAAId,EAAS,EAAK,GAEpCe,IAAc,CAACC,GAAWC,MAC/BT;AAAA,IAAW,CAACU,MACXA,EAAK,IAAI,CAACC,GAAGC,MAASA,MAAQJ,IAAI,EAAE,GAAGG,GAAG,GAAGF,EAAA,IAAUE,CAAE;AAAA,EAAA,GAErDE,IAAY,MACjBb,EAAW,CAACU,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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOFd,EAAO,OAAO,OAAO;AAAA;AAAA,eAE3BA,EAAO,QAAQ,QAAQ;AAAA;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, 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 * 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\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\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","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","token","caret","u","at","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","HeaderRow","IconBtn","DeleteIcon","AddHeaderRow","Button","PlusIcon","BikEditor","JsonFieldBox","c","styled"],"mappings":";;;;;;;;;;;;;;;;;;AAkDA,MAAMA,KAA2B,CAAC,OAAO,QAAQ,OAAO,SAAS,QAAQ,GACnEC,KAAiCD,GAAQ,IAAI,CAACE,OAAO;AAAA,EAC1D,OAAOA;AAAA,EACP,OAAOA;AACR,EAAE,GAQWC,KAAoD,CAAC;AAAA,EACjE,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC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ACD,GACD;AAAA,0BAECpB,GAAA,EACA,UAAA;AAAA,UAAA,gBAAAR,EAACc,GAAA,EAAW,OAAOC,EAAO,QAAQ,SAAS,UAAA,aAAS;AAAA,UACpD,gBAAAf;AAAA,YAACS;AAAA,YAAA;AAAA,cACA,eAAA7C;AAAA,cACA,UAAU,CAAC8C,MACVxC,EAAkB,SAAS,oBAAoBwC,CAAK;AAAA,cAGrD,UAAA,gBAAAV;AAAA,gBAAC0B;AAAA,gBAAA;AAAA,kBACA,KAAKxD;AAAA,kBACL,UAAU,EAAE,UAAU,GAAA;AAAA,kBACtB,OAAOyD;AAAA,kBACP,gBAAgB9C;AAAA,kBAChB,aAAY;AAAA,kBACZ,UAAU,CAAC+C,MAAM9C,EAAkB8C,EAAE,IAAI;AAAA,kBACzC,WAAU;AAAA,kBACV,WAAU;AAAA,gBAAA;AAAA,cAAA;AAAA,YACX;AAAA,UAAA;AAAA,QACD,EAAA,CACD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGH,GAEMR,KAAYS,EAAO;AAAA;AAAA;AAAA;AAAA,GAMnBN,KAAeM,EAAO;AAAA;AAAA,GAItBR,KAAUQ,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOFd,EAAO,OAAO,OAAO;AAAA;AAAA,eAE3BA,EAAO,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA,kBAIpBA,EAAO,QAAQ,SAAS;AAAA;AAAA,GAI7BY,IAAe;AAAA,EAC3B,cAAc;AAAA,EACd,UAAU;AACX;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { VariableListInterfaceV3 } from '../../variable-picker-v3/model';
|
|
2
3
|
interface ToolInstructionsFieldProps {
|
|
3
4
|
label: string;
|
|
4
5
|
value: string;
|
|
@@ -8,6 +9,14 @@ interface ToolInstructionsFieldProps {
|
|
|
8
9
|
minHeight?: string;
|
|
9
10
|
/** "Improve with AI" — resolves with rewritten text. Omit to hide the button. */
|
|
10
11
|
onImprove?: (text: string) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Variable catalog. When non-empty the field upgrades from a plain textarea
|
|
14
|
+
* to a variables-only `@` mention editor: typing `@` opens the variable
|
|
15
|
+
* categories directly (Variables is the sole category, so the picker skips
|
|
16
|
+
* the Tools / Sub-agent root), and picks render as chips persisted as
|
|
17
|
+
* `{{variable:<name>}}` tokens.
|
|
18
|
+
*/
|
|
19
|
+
variablesData?: VariableListInterfaceV3[];
|
|
11
20
|
'data-test'?: string;
|
|
12
21
|
}
|
|
13
22
|
/**
|