@bikdotai/bik-component-library 0.0.829 → 0.0.830-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +17 -65
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +41 -0
- package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -0
- 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/DrawerHeaderText.js +9 -0
- package/dist/cjs/components/agent-builder/components/DrawerHeaderText.js.map +1 -0
- 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 +20 -20
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +23 -0
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -0
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +5 -5
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +5 -0
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -0
- package/dist/cjs/components/agent-builder/constants/tools.js +2 -0
- package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -0
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- 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/components/agent-builder/utils/mentionSerialization.js +3 -3
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js +1 -1
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -1
- package/dist/cjs/components/side-modal/SideModal.style.js +11 -10
- package/dist/cjs/components/side-modal/SideModal.style.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +100 -96
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +144 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -21
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +42 -111
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.d.ts +33 -0
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +242 -0
- package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -0
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +9 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +318 -219
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/DrawerHeaderText.d.ts +25 -0
- package/dist/esm/components/agent-builder/components/DrawerHeaderText.js +32 -0
- package/dist/esm/components/agent-builder/components/DrawerHeaderText.js.map +1 -0
- package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +6 -0
- package/dist/esm/components/agent-builder/components/MentionEditor.js +38 -30
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +77 -52
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +7 -0
- package/dist/esm/components/agent-builder/components/MentionPicker.js +139 -129
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +27 -0
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +267 -0
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -0
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +14 -0
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +166 -140
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.d.ts +19 -0
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +66 -0
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -0
- package/dist/esm/components/agent-builder/constants/tools.d.ts +65 -0
- package/dist/esm/components/agent-builder/constants/tools.js +29 -0
- package/dist/esm/components/agent-builder/constants/tools.js.map +1 -0
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +19 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +169 -140
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/index.d.ts +2 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +241 -141
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +18 -3
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +81 -62
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +15 -9
- package/dist/esm/components/agent-builder/utils/sourceIcons.js +16 -8
- package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
- package/dist/esm/components/side-modal/SideModal.style.js +1 -0
- package/dist/esm/components/side-modal/SideModal.style.js.map +1 -1
- package/dist/esm/index.js +97 -95
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import { useState as l, useCallback as t } from "react";
|
|
3
|
-
import { COLORS as
|
|
4
|
-
import { BuilderRoot as
|
|
5
|
-
import { AgentBuilderFooter as
|
|
6
|
-
import { AgentBuilderTopBar as
|
|
7
|
-
import { DiscardModal as
|
|
8
|
-
import { GoLiveModal as
|
|
9
|
-
import { StepRail as
|
|
10
|
-
import { UndoToast as
|
|
11
|
-
import { AgentBuilderProvider as
|
|
12
|
-
import { Step1About as
|
|
13
|
-
import { Step2WhenItStepsIn as
|
|
14
|
-
import { Step3HowItResponds as
|
|
15
|
-
import { Step4HandoverRules as
|
|
16
|
-
import { Spinner as
|
|
17
|
-
const
|
|
18
|
-
const { activeStep: d } =
|
|
3
|
+
import { COLORS as ae } from "../../constants/Theme.js";
|
|
4
|
+
import { BuilderRoot as re, Main as ie, Rail as se, Content as le, ContentCard as de, StepScroll as ce } from "./AgentBuilder.styled.js";
|
|
5
|
+
import { AgentBuilderFooter as ue } from "./components/AgentBuilderFooter.js";
|
|
6
|
+
import { AgentBuilderTopBar as ge } from "./components/AgentBuilderTopBar.js";
|
|
7
|
+
import { DiscardModal as fe } from "./components/DiscardModal.js";
|
|
8
|
+
import { GoLiveModal as he } from "./components/GoLiveModal.js";
|
|
9
|
+
import { StepRail as me } from "./components/StepRail.js";
|
|
10
|
+
import { UndoToast as pe } from "./components/UndoToast.js";
|
|
11
|
+
import { AgentBuilderProvider as ve, useAgentBuilderContext as Se } from "./context/AgentBuilderContext.js";
|
|
12
|
+
import { Step1About as be } from "./steps/Step1About.js";
|
|
13
|
+
import { Step2WhenItStepsIn as Ce } from "./steps/Step2WhenItStepsIn.js";
|
|
14
|
+
import { Step3HowItResponds as Ae } from "./steps/Step3HowItResponds.js";
|
|
15
|
+
import { Step4HandoverRules as Le } from "./steps/Step4HandoverRules.js";
|
|
16
|
+
import { Spinner as De } from "../spinner/Spinner.js";
|
|
17
|
+
const Te = () => {
|
|
18
|
+
const { activeStep: d } = Se();
|
|
19
19
|
switch (d) {
|
|
20
20
|
case "about":
|
|
21
|
-
return /* @__PURE__ */ o(
|
|
21
|
+
return /* @__PURE__ */ o(be, {});
|
|
22
22
|
case "trigger":
|
|
23
|
-
return /* @__PURE__ */ o(
|
|
23
|
+
return /* @__PURE__ */ o(Ce, {});
|
|
24
24
|
case "response":
|
|
25
|
-
return /* @__PURE__ */ o(
|
|
25
|
+
return /* @__PURE__ */ o(Ae, {});
|
|
26
26
|
case "handover":
|
|
27
|
-
return /* @__PURE__ */ o(
|
|
27
|
+
return /* @__PURE__ */ o(Le, {});
|
|
28
28
|
default:
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
31
|
+
}, ye = (d) => {
|
|
32
32
|
const {
|
|
33
33
|
config: G,
|
|
34
|
-
onChange:
|
|
34
|
+
onChange: p,
|
|
35
35
|
onStepChange: c,
|
|
36
|
-
onDiscard:
|
|
36
|
+
onDiscard: v,
|
|
37
37
|
onSaveDraft: r,
|
|
38
38
|
onPublish: S,
|
|
39
39
|
onBack: u,
|
|
@@ -41,66 +41,68 @@ const Le = () => {
|
|
|
41
41
|
onGoToDashboard: f,
|
|
42
42
|
onCreateSubAgent: i,
|
|
43
43
|
onFetchSubAgent: P,
|
|
44
|
-
onUpdateSubAgent:
|
|
45
|
-
onImproveSubAgent:
|
|
44
|
+
onUpdateSubAgent: I,
|
|
45
|
+
onImproveSubAgent: w,
|
|
46
|
+
onImproveToolInstructions: M,
|
|
46
47
|
...k
|
|
47
48
|
} = d, {
|
|
48
49
|
value: h,
|
|
49
|
-
activeStep:
|
|
50
|
-
availableTools:
|
|
51
|
-
availableSubAgents:
|
|
52
|
-
availableIntents:
|
|
53
|
-
availableModels:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
activeStep: R,
|
|
51
|
+
availableTools: x,
|
|
52
|
+
availableSubAgents: j,
|
|
53
|
+
availableIntents: H = [],
|
|
54
|
+
availableModels: F = [],
|
|
55
|
+
configToolTemplates: N,
|
|
56
|
+
validation: O,
|
|
57
|
+
applicationType: U,
|
|
58
|
+
charLimits: z,
|
|
57
59
|
isSaving: b,
|
|
58
60
|
isPublishing: C,
|
|
59
|
-
isLoading:
|
|
60
|
-
footerHint:
|
|
61
|
-
disableStepNavigation:
|
|
61
|
+
isLoading: E,
|
|
62
|
+
footerHint: W = "Changes don’t affect customers until you go live",
|
|
63
|
+
disableStepNavigation: $,
|
|
62
64
|
debugLog: A
|
|
63
|
-
} = G, [
|
|
64
|
-
(n, ...
|
|
65
|
-
A && console.log(`[AgentBuilder] ${n}`, ...
|
|
65
|
+
} = G, [q, a] = l(null), [L, D] = l(!1), [J, s] = l(!1), [T, y] = l(!1), e = t(
|
|
66
|
+
(n, ...te) => {
|
|
67
|
+
A && console.log(`[AgentBuilder] ${n}`, ...te);
|
|
66
68
|
},
|
|
67
69
|
[A]
|
|
68
|
-
),
|
|
70
|
+
), K = t(
|
|
69
71
|
(n) => {
|
|
70
|
-
e("onChange", n),
|
|
72
|
+
e("onChange", n), p(n);
|
|
71
73
|
},
|
|
72
|
-
[e,
|
|
73
|
-
),
|
|
74
|
+
[e, p]
|
|
75
|
+
), Q = t(
|
|
74
76
|
(n) => {
|
|
75
77
|
e("onStepChange", n), c?.(n);
|
|
76
78
|
},
|
|
77
79
|
[e, c]
|
|
78
|
-
),
|
|
80
|
+
), V = t(() => (e("onSaveDraft"), r()), [e, r]), X = t(() => (e("onPublish"), S()), [e, S]), Y = t(() => {
|
|
79
81
|
e("onBack"), s(!0);
|
|
80
|
-
}, [e]),
|
|
81
|
-
e("onDiscardAndLeave"), s(!1),
|
|
82
|
-
}, [e,
|
|
82
|
+
}, [e]), Z = t(() => {
|
|
83
|
+
e("onDiscardAndLeave"), s(!1), v();
|
|
84
|
+
}, [e, v]), B = t(async () => {
|
|
83
85
|
e("onSaveDraftAndLeave");
|
|
84
86
|
const n = r();
|
|
85
87
|
if (n && typeof n.then == "function") {
|
|
86
|
-
|
|
88
|
+
y(!0);
|
|
87
89
|
try {
|
|
88
90
|
await n;
|
|
89
91
|
} finally {
|
|
90
|
-
|
|
92
|
+
y(!1);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
s(!1), u?.();
|
|
94
|
-
}, [e, r, u]),
|
|
96
|
+
}, [e, r, u]), _ = t(() => {
|
|
95
97
|
e("onTestAgent"), g?.();
|
|
96
|
-
}, [e, g]),
|
|
98
|
+
}, [e, g]), ee = t(() => {
|
|
97
99
|
e("onGoToDashboard"), f?.();
|
|
98
|
-
}, [e, f]),
|
|
100
|
+
}, [e, f]), ne = t(
|
|
99
101
|
(n) => (e("onCreateSubAgent", n), i ? i(n) : Promise.reject(new Error("onCreateSubAgent not provided"))),
|
|
100
102
|
[e, i]
|
|
101
|
-
),
|
|
103
|
+
), oe = async () => {
|
|
102
104
|
e("onGoLiveConfirm");
|
|
103
|
-
const n =
|
|
105
|
+
const n = X();
|
|
104
106
|
if (n && typeof n.then == "function") {
|
|
105
107
|
D(!0);
|
|
106
108
|
try {
|
|
@@ -112,38 +114,40 @@ const Le = () => {
|
|
|
112
114
|
a("success");
|
|
113
115
|
};
|
|
114
116
|
return /* @__PURE__ */ o(
|
|
115
|
-
|
|
117
|
+
ve,
|
|
116
118
|
{
|
|
117
119
|
value: h,
|
|
118
|
-
onChange:
|
|
119
|
-
activeStep:
|
|
120
|
-
onStepChange: c ?
|
|
121
|
-
availableTools:
|
|
122
|
-
availableSubAgents:
|
|
123
|
-
availableIntents:
|
|
124
|
-
availableModels:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
onChange: K,
|
|
121
|
+
activeStep: R,
|
|
122
|
+
onStepChange: c ? Q : void 0,
|
|
123
|
+
availableTools: x,
|
|
124
|
+
availableSubAgents: j,
|
|
125
|
+
availableIntents: H,
|
|
126
|
+
availableModels: F,
|
|
127
|
+
configToolTemplates: N,
|
|
128
|
+
validation: O,
|
|
129
|
+
applicationType: U,
|
|
130
|
+
charLimits: z,
|
|
131
|
+
disableStepNavigation: $,
|
|
132
|
+
onCreateSubAgent: i ? ne : void 0,
|
|
130
133
|
onFetchSubAgent: P,
|
|
131
|
-
onUpdateSubAgent:
|
|
132
|
-
onImproveSubAgent:
|
|
133
|
-
|
|
134
|
+
onUpdateSubAgent: I,
|
|
135
|
+
onImproveSubAgent: w,
|
|
136
|
+
onImproveToolInstructions: M,
|
|
137
|
+
children: /* @__PURE__ */ m(re, { "data-test": k["data-test"] ?? "agent-builder", children: [
|
|
134
138
|
/* @__PURE__ */ o(
|
|
135
|
-
|
|
139
|
+
ge,
|
|
136
140
|
{
|
|
137
141
|
name: h.name,
|
|
138
142
|
status: h.status,
|
|
139
|
-
onBack: u ?
|
|
140
|
-
onSaveDraft:
|
|
141
|
-
isSaving: b ||
|
|
143
|
+
onBack: u ? Y : void 0,
|
|
144
|
+
onSaveDraft: B,
|
|
145
|
+
isSaving: b || T
|
|
142
146
|
}
|
|
143
147
|
),
|
|
144
|
-
/* @__PURE__ */ m(
|
|
145
|
-
/* @__PURE__ */ o(
|
|
146
|
-
/* @__PURE__ */ o(
|
|
148
|
+
/* @__PURE__ */ m(ie, { children: [
|
|
149
|
+
/* @__PURE__ */ o(se, { children: /* @__PURE__ */ o(me, {}) }),
|
|
150
|
+
/* @__PURE__ */ o(le, { children: E ? /* @__PURE__ */ o(
|
|
147
151
|
"div",
|
|
148
152
|
{
|
|
149
153
|
style: {
|
|
@@ -152,15 +156,15 @@ const Le = () => {
|
|
|
152
156
|
justifyContent: "center",
|
|
153
157
|
height: "100%"
|
|
154
158
|
},
|
|
155
|
-
children: /* @__PURE__ */ o(
|
|
159
|
+
children: /* @__PURE__ */ o(De, { size: "large", color: ae.stroke.brand })
|
|
156
160
|
}
|
|
157
|
-
) : /* @__PURE__ */ m(
|
|
158
|
-
/* @__PURE__ */ o(
|
|
161
|
+
) : /* @__PURE__ */ m(de, { children: [
|
|
162
|
+
/* @__PURE__ */ o(ce, { children: /* @__PURE__ */ o(Te, {}) }),
|
|
159
163
|
/* @__PURE__ */ o(
|
|
160
|
-
|
|
164
|
+
ue,
|
|
161
165
|
{
|
|
162
|
-
footerHint:
|
|
163
|
-
onTestAgent: g ?
|
|
166
|
+
footerHint: W,
|
|
167
|
+
onTestAgent: g ? _ : void 0,
|
|
164
168
|
onGoLive: () => {
|
|
165
169
|
e("onGoLive"), a("confirm");
|
|
166
170
|
},
|
|
@@ -170,35 +174,35 @@ const Le = () => {
|
|
|
170
174
|
] }) })
|
|
171
175
|
] }),
|
|
172
176
|
/* @__PURE__ */ o(
|
|
173
|
-
|
|
177
|
+
he,
|
|
174
178
|
{
|
|
175
|
-
mode:
|
|
179
|
+
mode: q,
|
|
176
180
|
onClose: () => a(null),
|
|
177
|
-
onConfirm:
|
|
181
|
+
onConfirm: oe,
|
|
178
182
|
onSaveDraft: () => {
|
|
179
|
-
a(null),
|
|
183
|
+
a(null), V();
|
|
180
184
|
},
|
|
181
|
-
onGoToDashboard: f ?
|
|
185
|
+
onGoToDashboard: f ? ee : void 0,
|
|
182
186
|
isPublishing: C || L
|
|
183
187
|
}
|
|
184
188
|
),
|
|
185
189
|
/* @__PURE__ */ o(
|
|
186
|
-
|
|
190
|
+
fe,
|
|
187
191
|
{
|
|
188
|
-
open:
|
|
192
|
+
open: J,
|
|
189
193
|
onClose: () => s(!1),
|
|
190
|
-
onDiscard:
|
|
191
|
-
onSaveDraft:
|
|
192
|
-
isSaving: b ||
|
|
194
|
+
onDiscard: Z,
|
|
195
|
+
onSaveDraft: B,
|
|
196
|
+
isSaving: b || T
|
|
193
197
|
}
|
|
194
198
|
),
|
|
195
|
-
/* @__PURE__ */ o(
|
|
199
|
+
/* @__PURE__ */ o(pe, {})
|
|
196
200
|
] })
|
|
197
201
|
}
|
|
198
202
|
);
|
|
199
203
|
};
|
|
200
|
-
|
|
204
|
+
ye.displayName = "AgentBuilder";
|
|
201
205
|
export {
|
|
202
|
-
|
|
206
|
+
ye as AgentBuilder
|
|
203
207
|
};
|
|
204
208
|
//# sourceMappingURL=AgentBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentBuilder.js","sources":["../../../../src/components/agent-builder/AgentBuilder.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { Spinner } from '@src/components/spinner';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentBuilderProps,\n\tAgentValue,\n\tSubAgentDraft,\n} from './AgentBuilder.model';\nimport {\n\tBuilderRoot,\n\tContent,\n\tContentCard,\n\tMain,\n\tRail,\n\tStepScroll,\n} from './AgentBuilder.styled';\nimport { AgentBuilderFooter } from './components/AgentBuilderFooter';\nimport { AgentBuilderTopBar } from './components/AgentBuilderTopBar';\nimport { DiscardModal } from './components/DiscardModal';\nimport { GoLiveModal, GoLiveModalMode } from './components/GoLiveModal';\nimport { StepRail } from './components/StepRail';\nimport { UndoToast } from './components/UndoToast';\nimport {\n\tAgentBuilderProvider,\n\tuseAgentBuilderContext,\n} from './context/AgentBuilderContext';\nimport { Step1About } from './steps/Step1About';\nimport { Step2WhenItStepsIn } from './steps/Step2WhenItStepsIn';\nimport { Step3HowItResponds } from './steps/Step3HowItResponds';\nimport { Step4HandoverRules } from './steps/Step4HandoverRules';\n\nconst StepContent: React.FC = () => {\n\tconst { activeStep } = useAgentBuilderContext();\n\tswitch (activeStep) {\n\t\tcase 'about':\n\t\t\treturn <Step1About />;\n\t\tcase 'trigger':\n\t\t\treturn <Step2WhenItStepsIn />;\n\t\tcase 'response':\n\t\t\treturn <Step3HowItResponds />;\n\t\tcase 'handover':\n\t\t\treturn <Step4HandoverRules />;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * 4-step creation/edit wizard body for an AI agent. Presentational and\n * controlled — the consumer owns the `value`, persistence and routing.\n *\n * @example\n * <AgentBuilder\n * value={agent}\n * onChange={(patch) => setAgent({ ...agent, ...patch })}\n * availableTools={tools}\n * availableSubAgents={subAgents}\n * onDiscard={() => router.back()}\n * onSaveDraft={saveDraft}\n * onPublish={publish}\n * />\n */\nexport const AgentBuilder: React.FC<AgentBuilderProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonChange,\n\t\tonStepChange,\n\t\tonDiscard,\n\t\tonSaveDraft,\n\t\tonPublish,\n\t\tonBack,\n\t\tonTestAgent,\n\t\tonGoToDashboard,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\t...rest\n\t} = props;\n\tconst {\n\t\tvalue,\n\t\tactiveStep,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableIntents = [],\n\t\tavailableModels = [],\n\t\tvalidation,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tisSaving,\n\t\tisPublishing,\n\t\tisLoading,\n\t\tfooterHint = 'Changes don’t affect customers until you go live',\n\t\tdisableStepNavigation,\n\t\tdebugLog,\n\t} = config;\n\n\tconst [modalMode, setModalMode] = useState<GoLiveModalMode>(null);\n\tconst [publishingLocal, setPublishingLocal] = useState(false);\n\t// Back was pressed → confirm leaving (save draft / discard) before navigating.\n\tconst [showLeaveConfirm, setShowLeaveConfirm] = useState(false);\n\tconst [savingAndLeaving, setSavingAndLeaving] = useState(false);\n\n\t// Gated debug logging: each handler logs at its start only when `debugLog`.\n\tconst logAction = useCallback(\n\t\t(action: string, ...args: unknown[]) => {\n\t\t\tif (debugLog) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`[AgentBuilder] ${action}`, ...args);\n\t\t\t}\n\t\t},\n\t\t[debugLog],\n\t);\n\n\tconst handleChange = useCallback(\n\t\t(patch: Partial<AgentValue>) => {\n\t\t\tlogAction('onChange', patch);\n\t\t\tonChange(patch);\n\t\t},\n\t\t[logAction, onChange],\n\t);\n\tconst handleStepChange = useCallback(\n\t\t(step: Parameters<NonNullable<typeof onStepChange>>[0]) => {\n\t\t\tlogAction('onStepChange', step);\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[logAction, onStepChange],\n\t);\n\tconst handleSaveDraft = useCallback(() => {\n\t\tlogAction('onSaveDraft');\n\t\treturn onSaveDraft();\n\t}, [logAction, onSaveDraft]);\n\tconst handlePublish = useCallback(() => {\n\t\tlogAction('onPublish');\n\t\treturn onPublish();\n\t}, [logAction, onPublish]);\n\t// Back opens the \"Save as draft?\" confirmation rather than leaving directly.\n\tconst handleBack = useCallback(() => {\n\t\tlogAction('onBack');\n\t\tsetShowLeaveConfirm(true);\n\t}, [logAction]);\n\n\t// Modal \"Discard\" defers to the parent's discard handler (same as the top bar).\n\tconst handleDiscardAndLeave = useCallback(() => {\n\t\tlogAction('onDiscardAndLeave');\n\t\tsetShowLeaveConfirm(false);\n\t\tonDiscard();\n\t}, [logAction, onDiscard]);\n\n\tconst handleSaveDraftAndLeave = useCallback(async () => {\n\t\tlogAction('onSaveDraftAndLeave');\n\t\tconst result = onSaveDraft();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSavingAndLeaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSavingAndLeaving(false);\n\t\t\t}\n\t\t}\n\t\tsetShowLeaveConfirm(false);\n\t\tonBack?.();\n\t}, [logAction, onSaveDraft, onBack]);\n\tconst handleTestAgent = useCallback(() => {\n\t\tlogAction('onTestAgent');\n\t\tonTestAgent?.();\n\t}, [logAction, onTestAgent]);\n\tconst handleGoToDashboard = useCallback(() => {\n\t\tlogAction('onGoToDashboard');\n\t\tonGoToDashboard?.();\n\t}, [logAction, onGoToDashboard]);\n\tconst handleCreateSubAgent = useCallback(\n\t\t(draft: SubAgentDraft) => {\n\t\t\tlogAction('onCreateSubAgent', draft);\n\t\t\treturn onCreateSubAgent\n\t\t\t\t? onCreateSubAgent(draft)\n\t\t\t\t: Promise.reject(new Error('onCreateSubAgent not provided'));\n\t\t},\n\t\t[logAction, onCreateSubAgent],\n\t);\n\n\tconst handleConfirmGoLive = async () => {\n\t\tlogAction('onGoLiveConfirm');\n\t\tconst result = handlePublish();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetPublishingLocal(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t\tsetModalMode('success');\n\t\t\t} finally {\n\t\t\t\tsetPublishingLocal(false);\n\t\t\t}\n\t\t} else {\n\t\t\tsetModalMode('success');\n\t\t}\n\t};\n\n\treturn (\n\t\t<AgentBuilderProvider\n\t\t\tvalue={value}\n\t\t\tonChange={handleChange}\n\t\t\tactiveStep={activeStep}\n\t\t\tonStepChange={onStepChange ? handleStepChange : undefined}\n\t\t\tavailableTools={availableTools}\n\t\t\tavailableSubAgents={availableSubAgents}\n\t\t\tavailableIntents={availableIntents}\n\t\t\tavailableModels={availableModels}\n\t\t\tvalidation={validation}\n\t\t\tapplicationType={applicationType}\n\t\t\tcharLimits={charLimits}\n\t\t\tdisableStepNavigation={disableStepNavigation}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? handleCreateSubAgent : undefined}\n\t\t\tonFetchSubAgent={onFetchSubAgent}\n\t\t\tonUpdateSubAgent={onUpdateSubAgent}\n\t\t\tonImproveSubAgent={onImproveSubAgent}\n\t\t>\n\t\t\t<BuilderRoot data-test={rest['data-test'] ?? 'agent-builder'}>\n\t\t\t\t<AgentBuilderTopBar\n\t\t\t\t\tname={value.name}\n\t\t\t\t\tstatus={value.status}\n\t\t\t\t\tonBack={onBack ? handleBack : undefined}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<Main>\n\t\t\t\t\t<Rail>\n\t\t\t\t\t\t<StepRail />\n\t\t\t\t\t</Rail>\n\t\t\t\t\t<Content>\n\t\t\t\t\t\t{isLoading ? (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Spinner size=\"large\" color={COLORS.stroke.brand} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ContentCard>\n\t\t\t\t\t\t\t\t<StepScroll>\n\t\t\t\t\t\t\t\t\t<StepContent />\n\t\t\t\t\t\t\t\t</StepScroll>\n\t\t\t\t\t\t\t\t<AgentBuilderFooter\n\t\t\t\t\t\t\t\t\tfooterHint={footerHint}\n\t\t\t\t\t\t\t\t\tonTestAgent={onTestAgent ? handleTestAgent : undefined}\n\t\t\t\t\t\t\t\t\tonGoLive={() => {\n\t\t\t\t\t\t\t\t\t\tlogAction('onGoLive');\n\t\t\t\t\t\t\t\t\t\tsetModalMode('confirm');\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ContentCard>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Content>\n\t\t\t\t</Main>\n\n\t\t\t\t<GoLiveModal\n\t\t\t\t\tmode={modalMode}\n\t\t\t\t\tonClose={() => setModalMode(null)}\n\t\t\t\t\tonConfirm={handleConfirmGoLive}\n\t\t\t\t\tonSaveDraft={() => {\n\t\t\t\t\t\tsetModalMode(null);\n\t\t\t\t\t\thandleSaveDraft();\n\t\t\t\t\t}}\n\t\t\t\t\tonGoToDashboard={onGoToDashboard ? handleGoToDashboard : undefined}\n\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t/>\n\n\t\t\t\t<DiscardModal\n\t\t\t\t\topen={showLeaveConfirm}\n\t\t\t\t\tonClose={() => setShowLeaveConfirm(false)}\n\t\t\t\t\tonDiscard={handleDiscardAndLeave}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<UndoToast />\n\t\t\t</BuilderRoot>\n\t\t</AgentBuilderProvider>\n\t);\n};\n\nAgentBuilder.displayName = 'AgentBuilder';\n"],"names":["StepContent","activeStep","useAgentBuilderContext","Step1About","Step2WhenItStepsIn","Step3HowItResponds","Step4HandoverRules","AgentBuilder","props","config","onChange","onStepChange","onDiscard","onSaveDraft","onPublish","onBack","onTestAgent","onGoToDashboard","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","rest","value","availableTools","availableSubAgents","availableIntents","availableModels","validation","applicationType","charLimits","isSaving","isPublishing","isLoading","footerHint","disableStepNavigation","debugLog","modalMode","setModalMode","useState","publishingLocal","setPublishingLocal","showLeaveConfirm","setShowLeaveConfirm","savingAndLeaving","setSavingAndLeaving","logAction","useCallback","action","args","handleChange","patch","handleStepChange","step","handleSaveDraft","handlePublish","handleBack","handleDiscardAndLeave","handleSaveDraftAndLeave","result","handleTestAgent","handleGoToDashboard","handleCreateSubAgent","draft","handleConfirmGoLive","jsx","AgentBuilderProvider","BuilderRoot","AgentBuilderTopBar","Main","Rail","StepRail","Content","Spinner","COLORS","ContentCard","StepScroll","AgentBuilderFooter","GoLiveModal","DiscardModal","UndoToast"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,KAAwB,MAAM;AACnC,QAAM,EAAE,YAAAC,EAAA,IAAeC,GAAA;AACvB,UAAQD,GAAA;AAAA,IACP,KAAK;AACJ,+BAAQE,IAAA,EAAW;AAAA,IACpB,KAAK;AACJ,+BAAQC,IAAA,EAAmB;AAAA,IAC5B,KAAK;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CACZ;AAAA,IAAA;AAAA,EAAA;AAGH;AAEAzE,GAAa,cAAc;"}
|
|
1
|
+
{"version":3,"file":"AgentBuilder.js","sources":["../../../../src/components/agent-builder/AgentBuilder.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { Spinner } from '@src/components/spinner';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentBuilderProps,\n\tAgentValue,\n\tSubAgentDraft,\n} from './AgentBuilder.model';\nimport {\n\tBuilderRoot,\n\tContent,\n\tContentCard,\n\tMain,\n\tRail,\n\tStepScroll,\n} from './AgentBuilder.styled';\nimport { AgentBuilderFooter } from './components/AgentBuilderFooter';\nimport { AgentBuilderTopBar } from './components/AgentBuilderTopBar';\nimport { DiscardModal } from './components/DiscardModal';\nimport { GoLiveModal, GoLiveModalMode } from './components/GoLiveModal';\nimport { StepRail } from './components/StepRail';\nimport { UndoToast } from './components/UndoToast';\nimport {\n\tAgentBuilderProvider,\n\tuseAgentBuilderContext,\n} from './context/AgentBuilderContext';\nimport { Step1About } from './steps/Step1About';\nimport { Step2WhenItStepsIn } from './steps/Step2WhenItStepsIn';\nimport { Step3HowItResponds } from './steps/Step3HowItResponds';\nimport { Step4HandoverRules } from './steps/Step4HandoverRules';\n\nconst StepContent: React.FC = () => {\n\tconst { activeStep } = useAgentBuilderContext();\n\tswitch (activeStep) {\n\t\tcase 'about':\n\t\t\treturn <Step1About />;\n\t\tcase 'trigger':\n\t\t\treturn <Step2WhenItStepsIn />;\n\t\tcase 'response':\n\t\t\treturn <Step3HowItResponds />;\n\t\tcase 'handover':\n\t\t\treturn <Step4HandoverRules />;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * 4-step creation/edit wizard body for an AI agent. Presentational and\n * controlled — the consumer owns the `value`, persistence and routing.\n *\n * @example\n * <AgentBuilder\n * value={agent}\n * onChange={(patch) => setAgent({ ...agent, ...patch })}\n * availableTools={tools}\n * availableSubAgents={subAgents}\n * onDiscard={() => router.back()}\n * onSaveDraft={saveDraft}\n * onPublish={publish}\n * />\n */\nexport const AgentBuilder: React.FC<AgentBuilderProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonChange,\n\t\tonStepChange,\n\t\tonDiscard,\n\t\tonSaveDraft,\n\t\tonPublish,\n\t\tonBack,\n\t\tonTestAgent,\n\t\tonGoToDashboard,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\t...rest\n\t} = props;\n\tconst {\n\t\tvalue,\n\t\tactiveStep,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableIntents = [],\n\t\tavailableModels = [],\n\t\tconfigToolTemplates,\n\t\tvalidation,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tisSaving,\n\t\tisPublishing,\n\t\tisLoading,\n\t\tfooterHint = 'Changes don’t affect customers until you go live',\n\t\tdisableStepNavigation,\n\t\tdebugLog,\n\t} = config;\n\n\tconst [modalMode, setModalMode] = useState<GoLiveModalMode>(null);\n\tconst [publishingLocal, setPublishingLocal] = useState(false);\n\t// Back was pressed → confirm leaving (save draft / discard) before navigating.\n\tconst [showLeaveConfirm, setShowLeaveConfirm] = useState(false);\n\tconst [savingAndLeaving, setSavingAndLeaving] = useState(false);\n\n\t// Gated debug logging: each handler logs at its start only when `debugLog`.\n\tconst logAction = useCallback(\n\t\t(action: string, ...args: unknown[]) => {\n\t\t\tif (debugLog) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`[AgentBuilder] ${action}`, ...args);\n\t\t\t}\n\t\t},\n\t\t[debugLog],\n\t);\n\n\tconst handleChange = useCallback(\n\t\t(patch: Partial<AgentValue>) => {\n\t\t\tlogAction('onChange', patch);\n\t\t\tonChange(patch);\n\t\t},\n\t\t[logAction, onChange],\n\t);\n\tconst handleStepChange = useCallback(\n\t\t(step: Parameters<NonNullable<typeof onStepChange>>[0]) => {\n\t\t\tlogAction('onStepChange', step);\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[logAction, onStepChange],\n\t);\n\tconst handleSaveDraft = useCallback(() => {\n\t\tlogAction('onSaveDraft');\n\t\treturn onSaveDraft();\n\t}, [logAction, onSaveDraft]);\n\tconst handlePublish = useCallback(() => {\n\t\tlogAction('onPublish');\n\t\treturn onPublish();\n\t}, [logAction, onPublish]);\n\t// Back opens the \"Save as draft?\" confirmation rather than leaving directly.\n\tconst handleBack = useCallback(() => {\n\t\tlogAction('onBack');\n\t\tsetShowLeaveConfirm(true);\n\t}, [logAction]);\n\n\t// Modal \"Discard\" defers to the parent's discard handler (same as the top bar).\n\tconst handleDiscardAndLeave = useCallback(() => {\n\t\tlogAction('onDiscardAndLeave');\n\t\tsetShowLeaveConfirm(false);\n\t\tonDiscard();\n\t}, [logAction, onDiscard]);\n\n\tconst handleSaveDraftAndLeave = useCallback(async () => {\n\t\tlogAction('onSaveDraftAndLeave');\n\t\tconst result = onSaveDraft();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSavingAndLeaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSavingAndLeaving(false);\n\t\t\t}\n\t\t}\n\t\tsetShowLeaveConfirm(false);\n\t\tonBack?.();\n\t}, [logAction, onSaveDraft, onBack]);\n\tconst handleTestAgent = useCallback(() => {\n\t\tlogAction('onTestAgent');\n\t\tonTestAgent?.();\n\t}, [logAction, onTestAgent]);\n\tconst handleGoToDashboard = useCallback(() => {\n\t\tlogAction('onGoToDashboard');\n\t\tonGoToDashboard?.();\n\t}, [logAction, onGoToDashboard]);\n\tconst handleCreateSubAgent = useCallback(\n\t\t(draft: SubAgentDraft) => {\n\t\t\tlogAction('onCreateSubAgent', draft);\n\t\t\treturn onCreateSubAgent\n\t\t\t\t? onCreateSubAgent(draft)\n\t\t\t\t: Promise.reject(new Error('onCreateSubAgent not provided'));\n\t\t},\n\t\t[logAction, onCreateSubAgent],\n\t);\n\n\tconst handleConfirmGoLive = async () => {\n\t\tlogAction('onGoLiveConfirm');\n\t\tconst result = handlePublish();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetPublishingLocal(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t\tsetModalMode('success');\n\t\t\t} finally {\n\t\t\t\tsetPublishingLocal(false);\n\t\t\t}\n\t\t} else {\n\t\t\tsetModalMode('success');\n\t\t}\n\t};\n\n\treturn (\n\t\t<AgentBuilderProvider\n\t\t\tvalue={value}\n\t\t\tonChange={handleChange}\n\t\t\tactiveStep={activeStep}\n\t\t\tonStepChange={onStepChange ? handleStepChange : undefined}\n\t\t\tavailableTools={availableTools}\n\t\t\tavailableSubAgents={availableSubAgents}\n\t\t\tavailableIntents={availableIntents}\n\t\t\tavailableModels={availableModels}\n\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\tvalidation={validation}\n\t\t\tapplicationType={applicationType}\n\t\t\tcharLimits={charLimits}\n\t\t\tdisableStepNavigation={disableStepNavigation}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? handleCreateSubAgent : undefined}\n\t\t\tonFetchSubAgent={onFetchSubAgent}\n\t\t\tonUpdateSubAgent={onUpdateSubAgent}\n\t\t\tonImproveSubAgent={onImproveSubAgent}\n\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t>\n\t\t\t<BuilderRoot data-test={rest['data-test'] ?? 'agent-builder'}>\n\t\t\t\t<AgentBuilderTopBar\n\t\t\t\t\tname={value.name}\n\t\t\t\t\tstatus={value.status}\n\t\t\t\t\tonBack={onBack ? handleBack : undefined}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<Main>\n\t\t\t\t\t<Rail>\n\t\t\t\t\t\t<StepRail />\n\t\t\t\t\t</Rail>\n\t\t\t\t\t<Content>\n\t\t\t\t\t\t{isLoading ? (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Spinner size=\"large\" color={COLORS.stroke.brand} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ContentCard>\n\t\t\t\t\t\t\t\t<StepScroll>\n\t\t\t\t\t\t\t\t\t<StepContent />\n\t\t\t\t\t\t\t\t</StepScroll>\n\t\t\t\t\t\t\t\t<AgentBuilderFooter\n\t\t\t\t\t\t\t\t\tfooterHint={footerHint}\n\t\t\t\t\t\t\t\t\tonTestAgent={onTestAgent ? handleTestAgent : undefined}\n\t\t\t\t\t\t\t\t\tonGoLive={() => {\n\t\t\t\t\t\t\t\t\t\tlogAction('onGoLive');\n\t\t\t\t\t\t\t\t\t\tsetModalMode('confirm');\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ContentCard>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Content>\n\t\t\t\t</Main>\n\n\t\t\t\t<GoLiveModal\n\t\t\t\t\tmode={modalMode}\n\t\t\t\t\tonClose={() => setModalMode(null)}\n\t\t\t\t\tonConfirm={handleConfirmGoLive}\n\t\t\t\t\tonSaveDraft={() => {\n\t\t\t\t\t\tsetModalMode(null);\n\t\t\t\t\t\thandleSaveDraft();\n\t\t\t\t\t}}\n\t\t\t\t\tonGoToDashboard={onGoToDashboard ? handleGoToDashboard : undefined}\n\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t/>\n\n\t\t\t\t<DiscardModal\n\t\t\t\t\topen={showLeaveConfirm}\n\t\t\t\t\tonClose={() => setShowLeaveConfirm(false)}\n\t\t\t\t\tonDiscard={handleDiscardAndLeave}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<UndoToast />\n\t\t\t</BuilderRoot>\n\t\t</AgentBuilderProvider>\n\t);\n};\n\nAgentBuilder.displayName = 'AgentBuilder';\n"],"names":["StepContent","activeStep","useAgentBuilderContext","Step1About","Step2WhenItStepsIn","Step3HowItResponds","Step4HandoverRules","AgentBuilder","props","config","onChange","onStepChange","onDiscard","onSaveDraft","onPublish","onBack","onTestAgent","onGoToDashboard","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","rest","value","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","validation","applicationType","charLimits","isSaving","isPublishing","isLoading","footerHint","disableStepNavigation","debugLog","modalMode","setModalMode","useState","publishingLocal","setPublishingLocal","showLeaveConfirm","setShowLeaveConfirm","savingAndLeaving","setSavingAndLeaving","logAction","useCallback","action","args","handleChange","patch","handleStepChange","step","handleSaveDraft","handlePublish","handleBack","handleDiscardAndLeave","handleSaveDraftAndLeave","result","handleTestAgent","handleGoToDashboard","handleCreateSubAgent","draft","handleConfirmGoLive","jsx","AgentBuilderProvider","BuilderRoot","AgentBuilderTopBar","Main","Rail","StepRail","Content","Spinner","COLORS","ContentCard","StepScroll","AgentBuilderFooter","GoLiveModal","DiscardModal","UndoToast"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,KAAwB,MAAM;AACnC,QAAM,EAAE,YAAAC,EAAA,IAAeC,GAAA;AACvB,UAAQD,GAAA;AAAA,IACP,KAAK;AACJ,+BAAQE,IAAA,EAAW;AAAA,IACpB,KAAK;AACJ,+BAAQC,IAAA,EAAmB;AAAA,IAC5B,KAAK;AACJ,+BAAQC,IAAA,EAAmB;AAAA,I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tBoC,IAAA,CAAA,CAAU;AAAA,MAAA,EAAA,CACZ;AAAA,IAAA;AAAA,EAAA;AAGH;AAEA3E,GAAa,cAAc;"}
|
|
@@ -12,9 +12,131 @@ import { AgentCharLimits } from './constants/charLimits';
|
|
|
12
12
|
export type AgentValue = AgentConfig & {
|
|
13
13
|
trigger: Trigger;
|
|
14
14
|
handover: AgentHandoverConfig;
|
|
15
|
+
/**
|
|
16
|
+
* "Rest API" tools configured inline via the Step-3 tools drawer. These are a
|
|
17
|
+
* UI-only refinement (the bik-models tool schema carries no parameters), so
|
|
18
|
+
* they live on the builder's working value rather than in `tools`.
|
|
19
|
+
*/
|
|
20
|
+
restApiTools?: RestApiToolConfig[];
|
|
21
|
+
/**
|
|
22
|
+
* Shared-drawer configurable tools (email / Slack) configured inline via the
|
|
23
|
+
* Step-3 tools drawer. All render through the one dynamic `ConfigToolPanel`.
|
|
24
|
+
*/
|
|
25
|
+
configTools?: ConfigToolConfig[];
|
|
15
26
|
};
|
|
16
27
|
export type AgentTool = AgentToolDoc;
|
|
17
28
|
export type AgentTriggerValue = Trigger;
|
|
29
|
+
/** HTTP verb for a {@link RestApiToolConfig}. */
|
|
30
|
+
export type RestApiMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
31
|
+
/** A single request header (key / value) for a {@link RestApiToolConfig}. */
|
|
32
|
+
export interface RestApiHeader {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A "Rest API" tool the agent can call. The AI fills any `{{ }}` placeholders in
|
|
38
|
+
* the URL / request body at run time; the sample response is used to infer the
|
|
39
|
+
* shape the agent should expect back.
|
|
40
|
+
*/
|
|
41
|
+
export interface RestApiToolConfig {
|
|
42
|
+
/** Stable id (generated by the builder). */
|
|
43
|
+
id: string;
|
|
44
|
+
/** Display name shown in the tools list. */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Natural-language guidance for how the LLM should call this endpoint. */
|
|
47
|
+
instructions: string;
|
|
48
|
+
/** Endpoint URL; may contain `{{ }}` placeholders the AI fills. */
|
|
49
|
+
url: string;
|
|
50
|
+
method: RestApiMethod;
|
|
51
|
+
headers: RestApiHeader[];
|
|
52
|
+
/** Raw JSON request-body template (may contain `{{ }}` placeholders). */
|
|
53
|
+
requestBody: string;
|
|
54
|
+
/** Raw JSON sample response, for schema inference. */
|
|
55
|
+
responseSample: string;
|
|
56
|
+
}
|
|
57
|
+
/** One form field of a configurable tool, as described by the backend. */
|
|
58
|
+
export interface ParamField {
|
|
59
|
+
/** FE label. */
|
|
60
|
+
title: string;
|
|
61
|
+
/** Same as the map key. */
|
|
62
|
+
key: string;
|
|
63
|
+
/**
|
|
64
|
+
* OPTIONAL — the backend infers it from `component` when omitted
|
|
65
|
+
* (KeyValueInput/JsonInput → object, Switch → boolean, else string).
|
|
66
|
+
*/
|
|
67
|
+
type?: 'string' | 'boolean' | 'number' | 'object';
|
|
68
|
+
/**
|
|
69
|
+
* FE widget: "KeywordInput" | "MultilineInput" | "Select" | "Switch"
|
|
70
|
+
* | "KeyValueInput" | "JsonInput" | ...
|
|
71
|
+
*/
|
|
72
|
+
component: string;
|
|
73
|
+
hint?: string;
|
|
74
|
+
/** Must be filled before save; default false. */
|
|
75
|
+
required?: boolean;
|
|
76
|
+
/** Configured value (a literal, a prompt, a switch state, or a key/value object). */
|
|
77
|
+
value: string | boolean | number | object;
|
|
78
|
+
}
|
|
79
|
+
/** A configurable tool's form: field descriptors keyed by field, in order. */
|
|
80
|
+
export type ParamsBlob = Record<string, ParamField>;
|
|
81
|
+
/** How an agent references a tool (`agent.tools` entries). */
|
|
82
|
+
export interface ToolRef {
|
|
83
|
+
/** Catalog `tool_key` (native) or created custom `tool_id`. */
|
|
84
|
+
tool_id: string;
|
|
85
|
+
type: 'native' | 'custom';
|
|
86
|
+
}
|
|
87
|
+
/** A shared catalog entry from `GET /ai-agent/list-catalog`. */
|
|
88
|
+
export interface CatalogTool {
|
|
89
|
+
tool_key: string;
|
|
90
|
+
display_name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
/** false = native (attach as-is); true = template to instantiate. */
|
|
94
|
+
configurable: boolean;
|
|
95
|
+
/** Blank template form; present only when configurable. */
|
|
96
|
+
params?: ParamsBlob;
|
|
97
|
+
}
|
|
98
|
+
/** A per-store configured tool instance (`list-agent-tools` / `create-tool`). */
|
|
99
|
+
export interface CustomTool {
|
|
100
|
+
/** Server-generated. */
|
|
101
|
+
tool_id: string;
|
|
102
|
+
/** Which template it was created from: "send_email" | "rest_api" | "send_slack_message". */
|
|
103
|
+
tool_key: string;
|
|
104
|
+
display_name: string;
|
|
105
|
+
description: string;
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
/** The template's params with values filled in. */
|
|
108
|
+
params: ParamsBlob;
|
|
109
|
+
store_id: string;
|
|
110
|
+
/** The entry-agent tree root that owns it (FE-minted id). */
|
|
111
|
+
main_agent_id: string;
|
|
112
|
+
/** Set only when created while editing a sub-agent. */
|
|
113
|
+
sub_agent_id: string | null;
|
|
114
|
+
created_at?: number;
|
|
115
|
+
updated_at?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Configurable tools rendered by the shared dynamic drawer (`ConfigToolPanel`).
|
|
119
|
+
* These share ONE form contract — a backend `params` template with values
|
|
120
|
+
* filled in — and differ only by `tool_key` (which picks the header/labels and
|
|
121
|
+
* how the consumer persists it). Rest API is deliberately NOT here: it keeps its
|
|
122
|
+
* own bespoke drawer.
|
|
123
|
+
*/
|
|
124
|
+
export type ConfigToolKey = 'send_email' | 'send_slack_message';
|
|
125
|
+
/**
|
|
126
|
+
* A configured instance of a shared-drawer tool (email / Slack). The form is
|
|
127
|
+
* DYNAMIC — its fields are the backend template (`CatalogTool.params`) for
|
|
128
|
+
* `tool_key`, with values filled in; the builder never hardcodes them. `id` is
|
|
129
|
+
* builder-minted for a new tool and replaced by the server `tool_id` once the
|
|
130
|
+
* consumer persists it via create-tool.
|
|
131
|
+
*/
|
|
132
|
+
export interface ConfigToolConfig {
|
|
133
|
+
/** Builder-minted id, or the server `tool_id` once persisted. */
|
|
134
|
+
id: string;
|
|
135
|
+
/** Which template drives the form + how the consumer persists it. */
|
|
136
|
+
tool_key: ConfigToolKey;
|
|
137
|
+
/** The template for `tool_key` with values filled in. */
|
|
138
|
+
params: ParamsBlob;
|
|
139
|
+
}
|
|
18
140
|
/**
|
|
19
141
|
* The data captured by the "Create sub-agent" drawer. The consumer persists it
|
|
20
142
|
* (as an `is_entry: false` agent) and returns the created {@link SubAgentRef}.
|
|
@@ -23,8 +145,16 @@ export interface SubAgentDraft {
|
|
|
23
145
|
name: string;
|
|
24
146
|
instructions: string;
|
|
25
147
|
guardrail: string;
|
|
26
|
-
/**
|
|
148
|
+
/** Native tool ids (catalog `tool_key`s) the sub-agent can use. */
|
|
27
149
|
tools: string[];
|
|
150
|
+
/**
|
|
151
|
+
* Shared-drawer configurable tools (email / Slack) owned by this sub-agent.
|
|
152
|
+
* The consumer persists each with `sub_agent_id = <this sub-agent>` (they flow
|
|
153
|
+
* up to the parent). Same shape/drawer as the main agent's {@link configTools}.
|
|
154
|
+
*/
|
|
155
|
+
configTools?: ConfigToolConfig[];
|
|
156
|
+
/** "Rest API" tools configured for this sub-agent (bespoke drawer). */
|
|
157
|
+
restApiTools?: RestApiToolConfig[];
|
|
28
158
|
}
|
|
29
159
|
export type { AgentConfig, AgentToolDoc, AgentStatus, StepKey, StepValidation, TriggerMode, Trigger, HandoverMethod, AgentHandoverConfig, SubAgentRef, IntentOption, ModelOption, } from '@bikdotai/bik-models/ai-agents';
|
|
30
160
|
/**
|
|
@@ -41,6 +171,13 @@ export interface AgentBuilderConfig {
|
|
|
41
171
|
availableSubAgents: SubAgentRef[];
|
|
42
172
|
availableIntents?: IntentOption[];
|
|
43
173
|
availableModels?: ModelOption[];
|
|
174
|
+
/**
|
|
175
|
+
* Backend templates (`list-catalog` → params) for the shared-drawer tools,
|
|
176
|
+
* keyed by `tool_key`. Each present key drives its DYNAMIC form and enables
|
|
177
|
+
* its Step-3 tool action; an absent key hides that action. The form's fields
|
|
178
|
+
* only ever come from the backend.
|
|
179
|
+
*/
|
|
180
|
+
configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
|
|
44
181
|
/** Host application context the merchant runs in (e.g. ApplicationType.MANIFEST). */
|
|
45
182
|
applicationType?: ApplicationType;
|
|
46
183
|
/** Optional consumer-supplied validity; merged over the builder's derived validity. */
|
|
@@ -114,6 +251,12 @@ export interface AgentBuilderProps {
|
|
|
114
251
|
* guardrails. Resolves with the rewritten text. Omit to hide the buttons.
|
|
115
252
|
*/
|
|
116
253
|
onImproveSubAgent?: (kind: 'instructions' | 'guardrail', text: string) => Promise<string>;
|
|
254
|
+
/**
|
|
255
|
+
* Optional "Improve with AI" for the instructions field of the Rest API and
|
|
256
|
+
* Handover-to-email tool drawers. Resolves with the rewritten text. Omit to
|
|
257
|
+
* hide the button in both drawers.
|
|
258
|
+
*/
|
|
259
|
+
onImproveToolInstructions?: (text: string) => Promise<string>;
|
|
117
260
|
/** Test id applied to the builder root for e2e/component tests. */
|
|
118
261
|
'data-test'?: string;
|
|
119
262
|
}
|
|
@@ -142,27 +142,6 @@ export declare const ModalIcon: import('styled-components').StyledComponent<"div
|
|
|
142
142
|
export declare const ModalActions: import('styled-components').StyledComponent<"div", any, {
|
|
143
143
|
className: "bik-modal-actions";
|
|
144
144
|
}, "className">;
|
|
145
|
-
export declare const SubAgentScrim: import('styled-components').StyledComponent<"div", any, {
|
|
146
|
-
className: "bik-subagent-scrim";
|
|
147
|
-
}, "className">;
|
|
148
|
-
export declare const SubAgentPanel: import('styled-components').StyledComponent<"div", any, {
|
|
149
|
-
className: "bik-subagent-panel";
|
|
150
|
-
}, "className">;
|
|
151
|
-
export declare const SubAgentPanelHeader: import('styled-components').StyledComponent<"div", any, {
|
|
152
|
-
className: "bik-subagent-panel-header";
|
|
153
|
-
}, "className">;
|
|
154
|
-
export declare const SubAgentPanelHeaderText: import('styled-components').StyledComponent<"div", any, {
|
|
155
|
-
className: "bik-subagent-panel-header-text";
|
|
156
|
-
}, "className">;
|
|
157
|
-
export declare const SubAgentPanelBody: import('styled-components').StyledComponent<"div", any, {
|
|
158
|
-
className: "bik-subagent-panel-body";
|
|
159
|
-
}, "className">;
|
|
160
|
-
export declare const SubAgentPanelFooter: import('styled-components').StyledComponent<"div", any, {
|
|
161
|
-
className: "bik-subagent-panel-footer";
|
|
162
|
-
}, "className">;
|
|
163
|
-
export declare const SubAgentCloseButton: import('styled-components').StyledComponent<"button", any, {
|
|
164
|
-
className: "bik-subagent-close";
|
|
165
|
-
}, "className">;
|
|
166
145
|
/** Inline action row inside a rich field (e.g. "Improve with AI"). */
|
|
167
146
|
export declare const FieldActionRow: import('styled-components').StyledComponent<"div", any, {
|
|
168
147
|
className: "bik-field-action-row";
|