@bikdotai/bik-component-library 0.0.849-beta.2 → 0.0.849-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.
- 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 +16 -0
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +182 -138
- 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 +36 -0
- package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +94 -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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import K from "../../../assets/icons/delete.svg.js";
|
|
3
|
+
import Q from "../../../assets/icons/plus.svg.js";
|
|
4
|
+
import { useState as l, useRef as D } from "react";
|
|
5
|
+
import b from "styled-components";
|
|
6
|
+
import { TitleSmall as u } from "../../TypographyStyle.js";
|
|
7
|
+
import { COLORS as i } from "../../../constants/Theme.js";
|
|
8
|
+
import { FieldBlock as p } from "../AgentBuilder.styled.js";
|
|
9
|
+
import { AGENT_CHAR_LIMITS as X } from "../constants/charLimits.js";
|
|
10
|
+
import { DRAWER_BODY_STYLE as Z, DRAWER_HEADER_STYLE as ee, DrawerHeaderText as te } from "./DrawerHeaderText.js";
|
|
11
|
+
import { ToolInstructionsField as re } from "./ToolInstructionsField.js";
|
|
12
|
+
import { VariableTriggerArea as h } from "./VariableTriggerArea.js";
|
|
13
|
+
import { SideModal as oe } from "../../side-modal/SideModal.js";
|
|
14
|
+
import { Input as f } from "../../input/Input.js";
|
|
15
|
+
import { Dropdown as ne } from "../../dropdown/Dropdown.js";
|
|
16
|
+
import { unwrapDropdownValue as ae } from "../../dropdown/utils.js";
|
|
17
|
+
import { Button as se } from "../../button/Button.js";
|
|
18
|
+
import { BikEditor as q } from "../../../editor/BikEditor.js";
|
|
19
|
+
const le = ["GET", "POST", "PUT", "PATCH", "DELETE"], ie = le.map((s) => ({
|
|
20
|
+
label: s,
|
|
21
|
+
value: s
|
|
22
|
+
})), M = (s, y) => (y.textBefore.match(new RegExp('(?<!\\\\)"', "g"))?.length ?? 0) % 2 === 1 ? s : `"${s}"`, Be = ({
|
|
23
|
+
onClose: s,
|
|
24
|
+
onSave: y,
|
|
25
|
+
initial: n,
|
|
26
|
+
onImprove: N,
|
|
27
|
+
charLimits: I = X,
|
|
28
|
+
zIndex: j,
|
|
29
|
+
existingNames: z = [],
|
|
30
|
+
variablesData: c
|
|
29
31
|
}) => {
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
), [
|
|
33
|
-
|
|
34
|
-
), [
|
|
35
|
-
|
|
36
|
-
), [
|
|
37
|
-
(o) => o.map((
|
|
38
|
-
),
|
|
39
|
-
(e) => e.trim().toLowerCase() ===
|
|
40
|
-
),
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
|
|
32
|
+
const [x, F] = l(n?.name ?? ""), E = D(null), H = D(null), [w, G] = l(n?.instructions ?? ""), [T, k] = l(n?.url ?? "https://"), [g, J] = l(
|
|
33
|
+
n?.method ?? "POST"
|
|
34
|
+
), [A, v] = l(
|
|
35
|
+
n?.headers ?? [{ key: "", value: "" }]
|
|
36
|
+
), [B, U] = l(n?.requestBody ?? ""), [P, W] = l(
|
|
37
|
+
n?.responseSample ?? ""
|
|
38
|
+
), [L, O] = l(!1), S = (e, r) => v(
|
|
39
|
+
(o) => o.map((a, m) => m === e ? { ...a, ...r } : a)
|
|
40
|
+
), Y = () => v((e) => [...e, { key: "", value: "" }]), V = (e) => v((r) => r.filter((o, a) => a !== e)), C = x.trim(), R = C.length > 0 && z.some(
|
|
41
|
+
(e) => e.trim().toLowerCase() === C.toLowerCase()
|
|
42
|
+
), $ = C.length > 0 && T.trim().length > 0 && !R;
|
|
43
|
+
return /* @__PURE__ */ d(
|
|
44
|
+
oe,
|
|
43
45
|
{
|
|
44
46
|
header: "Rest API",
|
|
45
47
|
closeOnEscapeKey: !1,
|
|
46
|
-
zIndex:
|
|
48
|
+
zIndex: j,
|
|
47
49
|
headerCustomComponent: /* @__PURE__ */ t(
|
|
48
|
-
|
|
50
|
+
te,
|
|
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: ee,
|
|
58
|
+
bodyStyle: Z,
|
|
59
|
+
onClose: s,
|
|
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: !$,
|
|
66
|
+
isLoading: L,
|
|
65
67
|
onClick: async () => {
|
|
66
|
-
if (
|
|
68
|
+
if (!$ || L)
|
|
67
69
|
return;
|
|
68
70
|
const e = {
|
|
69
|
-
id:
|
|
70
|
-
name:
|
|
71
|
-
instructions:
|
|
72
|
-
url:
|
|
73
|
-
method:
|
|
71
|
+
id: n?.id ?? `restapi_${Date.now().toString(36)}`,
|
|
72
|
+
name: x.trim(),
|
|
73
|
+
instructions: w,
|
|
74
|
+
url: T.trim(),
|
|
75
|
+
method: g,
|
|
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: B,
|
|
79
|
+
responseSample: P
|
|
80
|
+
}, r = y(e);
|
|
79
81
|
if (r && typeof r.then == "function") {
|
|
80
|
-
|
|
82
|
+
O(!0);
|
|
81
83
|
try {
|
|
82
84
|
await r;
|
|
83
85
|
} finally {
|
|
84
|
-
|
|
86
|
+
O(!1);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -91,183 +93,225 @@ 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: s
|
|
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: x,
|
|
108
|
+
maxCharLimit: I.name,
|
|
109
|
+
state: R ? "invalid" : void 0,
|
|
110
|
+
errorMessage: R ? "A tool with this name already exists" : void 0,
|
|
111
|
+
onChangeText: F
|
|
110
112
|
}
|
|
111
113
|
),
|
|
112
114
|
/* @__PURE__ */ t(
|
|
113
|
-
|
|
115
|
+
re,
|
|
114
116
|
{
|
|
115
117
|
"data-test": "restapi-instructions",
|
|
116
118
|
label: "Instructions",
|
|
117
|
-
value:
|
|
118
|
-
onChange:
|
|
119
|
-
maxLength:
|
|
119
|
+
value: w,
|
|
120
|
+
onChange: G,
|
|
121
|
+
maxLength: I.instructions,
|
|
120
122
|
placeholder: "Describe how should the LLM generate the rest API",
|
|
121
|
-
onImprove:
|
|
123
|
+
onImprove: N,
|
|
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) => k((o) => {
|
|
132
|
+
const a = r ?? o.length;
|
|
133
|
+
return `${o.slice(0, a)}${e}${o.slice(a)}`;
|
|
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: T,
|
|
145
|
+
onChangeText: k
|
|
146
|
+
}
|
|
147
|
+
)
|
|
135
148
|
}
|
|
136
149
|
) }),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ t(
|
|
150
|
+
/* @__PURE__ */ d(p, { children: [
|
|
151
|
+
/* @__PURE__ */ t(u, { color: i.content.primary, children: "HTTP method" }),
|
|
139
152
|
/* @__PURE__ */ t(
|
|
140
|
-
|
|
153
|
+
ne,
|
|
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: ie,
|
|
160
|
+
defaultOptions: [{ label: g, value: g }],
|
|
148
161
|
onSelect: (e) => {
|
|
149
|
-
const r =
|
|
150
|
-
r &&
|
|
162
|
+
const r = ae(e);
|
|
163
|
+
r && J(r);
|
|
151
164
|
}
|
|
152
165
|
}
|
|
153
166
|
)
|
|
154
167
|
] }),
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */ t(
|
|
157
|
-
|
|
168
|
+
/* @__PURE__ */ d(p, { children: [
|
|
169
|
+
/* @__PURE__ */ t(u, { color: i.content.primary, children: "Headers" }),
|
|
170
|
+
A.map((e, r) => (
|
|
158
171
|
// eslint-disable-next-line react/no-array-index-key
|
|
159
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ d(de, { "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) => S(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, 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,
|
|
195
|
+
{
|
|
196
|
+
variant: "small",
|
|
197
|
+
hideInputHeader: !0,
|
|
198
|
+
placeholder: "Enter value",
|
|
199
|
+
value: e.value,
|
|
200
|
+
onChangeText: (o) => S(r, { value: o })
|
|
201
|
+
}
|
|
202
|
+
)
|
|
178
203
|
}
|
|
179
204
|
),
|
|
180
205
|
/* @__PURE__ */ t(
|
|
181
|
-
|
|
206
|
+
pe,
|
|
182
207
|
{
|
|
183
208
|
type: "button",
|
|
184
209
|
"aria-label": "Remove header",
|
|
185
210
|
"data-test": `restapi-header-remove-${r}`,
|
|
186
|
-
onClick: () =>
|
|
211
|
+
onClick: () => V(r),
|
|
187
212
|
children: /* @__PURE__ */ t(
|
|
188
|
-
|
|
213
|
+
K,
|
|
189
214
|
{
|
|
190
215
|
width: 16,
|
|
191
216
|
height: 16,
|
|
192
|
-
color:
|
|
217
|
+
color: i.content.secondary
|
|
193
218
|
}
|
|
194
219
|
)
|
|
195
220
|
}
|
|
196
221
|
)
|
|
197
222
|
] }, r)
|
|
198
223
|
)),
|
|
199
|
-
/* @__PURE__ */ t(
|
|
200
|
-
|
|
224
|
+
/* @__PURE__ */ t(ce, { children: /* @__PURE__ */ t(
|
|
225
|
+
se,
|
|
201
226
|
{
|
|
202
227
|
"data-test": "restapi-add-header",
|
|
203
228
|
buttonType: "dashRegular",
|
|
204
229
|
size: "small",
|
|
205
|
-
LeadingIcon:
|
|
230
|
+
LeadingIcon: Q,
|
|
206
231
|
buttonText: "Add header",
|
|
207
|
-
onClick:
|
|
232
|
+
onClick: Y
|
|
208
233
|
}
|
|
209
234
|
) })
|
|
210
235
|
] }),
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */ t(
|
|
236
|
+
/* @__PURE__ */ d(p, { children: [
|
|
237
|
+
/* @__PURE__ */ t(u, { color: i.content.primary, children: "Request " }),
|
|
213
238
|
/* @__PURE__ */ t(
|
|
214
|
-
|
|
239
|
+
h,
|
|
215
240
|
{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
241
|
+
variablesData: c,
|
|
242
|
+
transformToken: M,
|
|
243
|
+
onInsert: (e) => E.current?.insertInlineContent(e),
|
|
244
|
+
children: /* @__PURE__ */ t(
|
|
245
|
+
q,
|
|
246
|
+
{
|
|
247
|
+
ref: E,
|
|
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
|
+
)
|
|
223
257
|
}
|
|
224
258
|
)
|
|
225
259
|
] }),
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
/* @__PURE__ */ t(
|
|
260
|
+
/* @__PURE__ */ d(p, { children: [
|
|
261
|
+
/* @__PURE__ */ t(u, { color: i.content.primary, children: "Response " }),
|
|
228
262
|
/* @__PURE__ */ t(
|
|
229
|
-
|
|
263
|
+
h,
|
|
230
264
|
{
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
265
|
+
variablesData: c,
|
|
266
|
+
transformToken: M,
|
|
267
|
+
onInsert: (e) => H.current?.insertInlineContent(e),
|
|
268
|
+
children: /* @__PURE__ */ t(
|
|
269
|
+
q,
|
|
270
|
+
{
|
|
271
|
+
ref: H,
|
|
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
|
+
)
|
|
238
281
|
}
|
|
239
282
|
)
|
|
240
283
|
] })
|
|
241
284
|
]
|
|
242
285
|
}
|
|
243
286
|
);
|
|
244
|
-
},
|
|
287
|
+
}, de = b.div`
|
|
245
288
|
display: flex;
|
|
246
289
|
align-items: center;
|
|
247
290
|
gap: 8px;
|
|
248
|
-
`,
|
|
291
|
+
`, ce = b.div`
|
|
249
292
|
display: flex;
|
|
250
|
-
`,
|
|
293
|
+
`, pe = b.button`
|
|
251
294
|
display: inline-flex;
|
|
252
295
|
align-items: center;
|
|
253
296
|
justify-content: center;
|
|
254
297
|
flex-shrink: 0;
|
|
255
298
|
width: 32px;
|
|
256
299
|
height: 32px;
|
|
257
|
-
border: 1px solid ${
|
|
300
|
+
border: 1px solid ${i.stroke.primary};
|
|
258
301
|
border-radius: 4px;
|
|
259
|
-
background: ${
|
|
302
|
+
background: ${i.surface.standard};
|
|
260
303
|
cursor: pointer;
|
|
261
304
|
|
|
262
305
|
&:hover {
|
|
263
|
-
border-color: ${
|
|
306
|
+
border-color: ${i.content.secondary};
|
|
264
307
|
}
|
|
265
|
-
`,
|
|
308
|
+
`, _ = {
|
|
266
309
|
borderRadius: "4px",
|
|
267
310
|
overflow: "hidden"
|
|
268
311
|
};
|
|
269
312
|
export {
|
|
270
|
-
|
|
271
|
-
|
|
313
|
+
_ as JsonFieldBox,
|
|
314
|
+
Be as RestApiToolPanel,
|
|
315
|
+
M as jsonQuoteToken
|
|
272
316
|
};
|
|
273
317
|
//# 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,GAEp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AAAA,YAAA;AAAA,UAAA;AAAA,QACX,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
|
+
{"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,OAAO,QAAQ,OAAO,SAAS,QAAQ,GACnEC,KAAiCD,GAAQ,IAAI,CAACE,OAAO;AAAA,EAC1D,OAAOA;AAAA,EACP,OAAOA;AACR,EAAE,GAQWC,IAAiB,CAC7BC,GACAC,OAEeA,EAAI,WAAW,MAAM,WAAA,cAAA,GAAW,IAAG,UAAU,KAC5C,MAAM,IAAID,IAAQ,IAAIA,CAAK,KAS/BE,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,GAE9CU,IAAmBC,EAAqB,IAAI,GAC5CC,IAAoBD,EAAqB,IAAI,GAC7C,CAACE,GAAcC,CAAe,IAAIL,EAAST,GAAS,gBAAgB,EAAE,GAEtE,CAACe,GAAKC,CAAM,IAAIP,EAAST,GAAS,OAAO,UAAU,GACnD,CAACiB,GAAQC,CAAS,IAAIT;AAAA,IAC3BT,GAAS,UAAU;AAAA,EAAA,GAEd,CAACmB,GAASC,CAAU,IAAIX;AAAA,IAC7BT,GAAS,WAAW,CAAC,EAAE,KAAK,IAAI,OAAO,IAAI;AAAA,EAAA,GAEtC,C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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
|
/**
|