@bikdotai/bik-component-library 0.0.821-beta.8 → 0.0.821
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/assets/icons/Shopify.svg.js +2 -0
- package/dist/cjs/assets/icons/Shopify.svg.js.map +1 -0
- 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 +57 -23
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
- package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +37 -6
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/cjs/components/agent-builder/constants/charLimits.js +1 -1
- package/dist/cjs/components/agent-builder/constants/charLimits.js.map +1 -1
- 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/Step2WhenItStepsIn.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.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 +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js +2 -0
- package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -0
- package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentListingFilters.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListingFilters.js.map +1 -1
- package/dist/cjs/editor/BikEditor.types.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/assets/icons/Shopify.svg.js +6 -0
- package/dist/esm/assets/icons/Shopify.svg.js.map +1 -0
- package/dist/esm/components/agent-builder/AgentBuilder.js +47 -47
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +6 -0
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +82 -42
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +84 -76
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +6 -0
- package/dist/esm/components/agent-builder/components/MentionEditor.js +31 -30
- package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionField.js +40 -37
- package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +6 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +202 -101
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +18 -2
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +159 -91
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.d.ts +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.js +1 -1
- package/dist/esm/components/agent-builder/constants/charLimits.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +7 -0
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +107 -99
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +7 -7
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +131 -106
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +2 -2
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +10 -0
- package/dist/esm/components/agent-builder/utils/sourceIcons.js +10 -0
- package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -0
- package/dist/esm/components/agent-listing/AgentListing.js +108 -101
- package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentListing.model.d.ts +8 -0
- package/dist/esm/components/agent-listing/AgentListingFilters.d.ts +2 -0
- package/dist/esm/components/agent-listing/AgentListingFilters.js +37 -33
- package/dist/esm/components/agent-listing/AgentListingFilters.js.map +1 -1
- package/dist/esm/editor/BikEditor.types.d.ts +7 -0
- package/dist/esm/editor/BikEditor.types.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionDropdown.d.ts +2 -0
- package/dist/esm/editor/extensions/mention/MentionDropdown.js +21 -20
- package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
- package/dist/esm/editor/extensions/mention/MentionExtension.js +66 -55
- package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,113 +1,117 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { AGENT_CHAR_LIMITS as
|
|
4
|
-
import { getStepIndex as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
if (!
|
|
1
|
+
import { jsx as st } from "react/jsx-runtime";
|
|
2
|
+
import it, { useState as S, useRef as g, useCallback as o, useMemo as Z, useContext as ct } from "react";
|
|
3
|
+
import { AGENT_CHAR_LIMITS as O } from "../constants/charLimits.js";
|
|
4
|
+
import { getStepIndex as ut, STEP_KEYS as x } from "../constants/steps.js";
|
|
5
|
+
const b = it.createContext(null), pt = () => {
|
|
6
|
+
const n = ct(b);
|
|
7
|
+
if (!n)
|
|
8
8
|
throw new Error(
|
|
9
9
|
"useAgentBuilderContext must be used within an AgentBuilderProvider"
|
|
10
10
|
);
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const s =
|
|
11
|
+
return n;
|
|
12
|
+
}, dt = (n) => {
|
|
13
|
+
const s = n.trigger.mode === "custom_intent" ? (n.trigger.custom_intent ?? "").trim().length > 0 : n.trigger.intents.length > 0;
|
|
14
14
|
return {
|
|
15
|
-
about:
|
|
15
|
+
about: n.name.trim().length > 0 && n.name.length <= O.name && n.description.length <= O.description,
|
|
16
16
|
trigger: s,
|
|
17
17
|
// At least one of Instructions / Guardrails must be filled.
|
|
18
|
-
response:
|
|
18
|
+
response: n.instructions.trim().length > 0 || (n.guardrail ?? "").trim().length > 0,
|
|
19
19
|
// Optional until specced further — never blocks go-live.
|
|
20
20
|
handover: !0
|
|
21
21
|
};
|
|
22
|
-
},
|
|
23
|
-
value:
|
|
22
|
+
}, xt = ({
|
|
23
|
+
value: n,
|
|
24
24
|
onChange: s,
|
|
25
25
|
activeStep: R,
|
|
26
26
|
onStepChange: B,
|
|
27
27
|
availableTools: u,
|
|
28
28
|
availableSubAgents: m,
|
|
29
29
|
availableIntents: F,
|
|
30
|
-
availableModels:
|
|
31
|
-
validation:
|
|
32
|
-
applicationType:
|
|
33
|
-
disableStepNavigation:
|
|
34
|
-
onCreateSubAgent:
|
|
35
|
-
onFetchSubAgent:
|
|
36
|
-
onUpdateSubAgent:
|
|
37
|
-
onImproveSubAgent:
|
|
38
|
-
children:
|
|
30
|
+
availableModels: I,
|
|
31
|
+
validation: P,
|
|
32
|
+
applicationType: A,
|
|
33
|
+
disableStepNavigation: E = !0,
|
|
34
|
+
onCreateSubAgent: $,
|
|
35
|
+
onFetchSubAgent: w,
|
|
36
|
+
onUpdateSubAgent: y,
|
|
37
|
+
onImproveSubAgent: T,
|
|
38
|
+
children: v
|
|
39
39
|
}) => {
|
|
40
|
-
const [
|
|
41
|
-
(
|
|
42
|
-
e ? _.current[
|
|
40
|
+
const [tt, nt] = S("about"), l = R ?? tt, i = ut(l), [V, a] = S(0), _ = g({}), j = g("instructions"), K = o(
|
|
41
|
+
(t, e) => {
|
|
42
|
+
e ? _.current[t] = e : delete _.current[t];
|
|
43
43
|
},
|
|
44
44
|
[]
|
|
45
|
-
),
|
|
46
|
-
|
|
47
|
-
}, []),
|
|
45
|
+
), L = o((t) => {
|
|
46
|
+
j.current = t;
|
|
47
|
+
}, []), q = g(null), C = o((t) => {
|
|
48
|
+
q.current = t;
|
|
49
|
+
}, []), G = o(() => {
|
|
50
|
+
q.current?.();
|
|
51
|
+
}, []), H = o((t, e, p) => {
|
|
48
52
|
const d = _.current;
|
|
49
|
-
(d[
|
|
50
|
-
}, []), [
|
|
51
|
-
(
|
|
52
|
-
R === void 0 &&
|
|
53
|
+
(d[j.current] ?? d.instructions)?.(t, e, p);
|
|
54
|
+
}, []), [N, h] = S(null), f = g(null), U = g(0), c = o(
|
|
55
|
+
(t) => {
|
|
56
|
+
R === void 0 && nt(t), B?.(t);
|
|
53
57
|
},
|
|
54
58
|
[R, B]
|
|
55
59
|
), Y = o(() => {
|
|
56
|
-
const
|
|
57
|
-
c(
|
|
60
|
+
const t = x[Math.min(i + 1, x.length - 1)];
|
|
61
|
+
c(t);
|
|
58
62
|
}, [i, c]), k = o(() => {
|
|
59
|
-
const
|
|
60
|
-
c(
|
|
61
|
-
}, [i, c]),
|
|
62
|
-
(
|
|
63
|
-
[s]
|
|
64
|
-
), z = o(
|
|
65
|
-
(n, e) => s({ [n]: e }),
|
|
63
|
+
const t = x[Math.max(i - 1, 0)];
|
|
64
|
+
c(t);
|
|
65
|
+
}, [i, c]), z = o(
|
|
66
|
+
(t) => s(t),
|
|
66
67
|
[s]
|
|
67
68
|
), D = o(
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
(t, e) => s({ [t]: e }),
|
|
70
|
+
[s]
|
|
71
|
+
), J = o(
|
|
72
|
+
(t, e) => {
|
|
73
|
+
const p = t === "tool" ? (() => {
|
|
74
|
+
const r = u.find((ot) => ot.tool_id === e);
|
|
71
75
|
return r ? `{{tool:${r.function_key}}}` : null;
|
|
72
|
-
})() : `{{subagent:${e}}}`, d = (r) =>
|
|
73
|
-
|
|
74
|
-
tools:
|
|
75
|
-
subagents:
|
|
76
|
-
instructions:
|
|
77
|
-
guardrail:
|
|
76
|
+
})() : `{{subagent:${e}}}`, d = (r) => p ? r.split(p).join("") : r;
|
|
77
|
+
f.current = {
|
|
78
|
+
tools: n.tools,
|
|
79
|
+
subagents: n.subagents,
|
|
80
|
+
instructions: n.instructions,
|
|
81
|
+
guardrail: n.guardrail
|
|
78
82
|
};
|
|
79
|
-
const
|
|
80
|
-
instructions: d(
|
|
81
|
-
guardrail: d(
|
|
82
|
-
...
|
|
83
|
+
const X = {
|
|
84
|
+
instructions: d(n.instructions),
|
|
85
|
+
guardrail: d(n.guardrail ?? ""),
|
|
86
|
+
...t === "tool" ? { tools: n.tools.filter((r) => r !== e) } : { subagents: n.subagents.filter((r) => r !== e) }
|
|
83
87
|
};
|
|
84
|
-
s(
|
|
85
|
-
const
|
|
88
|
+
s(X), a((r) => r + 1);
|
|
89
|
+
const et = t === "tool" ? u.find((r) => r.tool_id === e)?.display_name ?? "Tool" : m.find((r) => r.id === e)?.name ?? "Sub-agent";
|
|
86
90
|
U.current += 1, h({
|
|
87
91
|
id: U.current,
|
|
88
|
-
message: `${
|
|
92
|
+
message: `${t === "tool" ? "Tool" : "Sub-agent"} "${et}" removed`
|
|
89
93
|
});
|
|
90
94
|
},
|
|
91
|
-
[u, m,
|
|
92
|
-
),
|
|
93
|
-
|
|
94
|
-
}, [s]),
|
|
95
|
-
() => ({ ...
|
|
96
|
-
[
|
|
97
|
-
),
|
|
95
|
+
[u, m, n, s]
|
|
96
|
+
), Q = o(() => {
|
|
97
|
+
f.current && (s(f.current), f.current = null, a((t) => t + 1)), h(null);
|
|
98
|
+
}, [s]), W = o(() => h(null), []), M = Z(
|
|
99
|
+
() => ({ ...dt(n), ...P }),
|
|
100
|
+
[n, P]
|
|
101
|
+
), rt = Z(
|
|
98
102
|
() => ({
|
|
99
|
-
value:
|
|
100
|
-
patch:
|
|
101
|
-
updateField:
|
|
102
|
-
removeReference:
|
|
103
|
-
mentionResetKey:
|
|
104
|
-
insertMention:
|
|
105
|
-
registerMentionField:
|
|
106
|
-
notifyMentionFocus:
|
|
107
|
-
undoToast:
|
|
108
|
-
undoRemoval:
|
|
109
|
-
dismissUndo:
|
|
110
|
-
activeStep:
|
|
103
|
+
value: n,
|
|
104
|
+
patch: z,
|
|
105
|
+
updateField: D,
|
|
106
|
+
removeReference: J,
|
|
107
|
+
mentionResetKey: V,
|
|
108
|
+
insertMention: H,
|
|
109
|
+
registerMentionField: K,
|
|
110
|
+
notifyMentionFocus: L,
|
|
111
|
+
undoToast: N,
|
|
112
|
+
undoRemoval: Q,
|
|
113
|
+
dismissUndo: W,
|
|
114
|
+
activeStep: l,
|
|
111
115
|
activeIndex: i,
|
|
112
116
|
goToStep: c,
|
|
113
117
|
goNext: Y,
|
|
@@ -115,31 +119,33 @@ const a = et.createContext(null), gt = () => {
|
|
|
115
119
|
isFirstStep: i === 0,
|
|
116
120
|
isLastStep: i === x.length - 1,
|
|
117
121
|
validation: M,
|
|
118
|
-
isActiveStepValid: M[
|
|
122
|
+
isActiveStepValid: M[l],
|
|
119
123
|
availableTools: u,
|
|
120
124
|
availableSubAgents: m,
|
|
121
125
|
availableIntents: F,
|
|
122
|
-
availableModels:
|
|
123
|
-
applicationType:
|
|
124
|
-
disableStepNavigation:
|
|
125
|
-
onCreateSubAgent:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
availableModels: I,
|
|
127
|
+
applicationType: A,
|
|
128
|
+
disableStepNavigation: E,
|
|
129
|
+
onCreateSubAgent: $,
|
|
130
|
+
registerSubAgentCreator: C,
|
|
131
|
+
requestCreateSubAgent: G,
|
|
132
|
+
onFetchSubAgent: w,
|
|
133
|
+
onUpdateSubAgent: y,
|
|
134
|
+
onImproveSubAgent: T
|
|
129
135
|
}),
|
|
130
136
|
[
|
|
131
|
-
|
|
132
|
-
q,
|
|
137
|
+
n,
|
|
133
138
|
z,
|
|
134
139
|
D,
|
|
135
|
-
j,
|
|
136
|
-
G,
|
|
137
|
-
N,
|
|
138
|
-
A,
|
|
139
|
-
H,
|
|
140
140
|
J,
|
|
141
|
+
V,
|
|
142
|
+
H,
|
|
143
|
+
K,
|
|
144
|
+
L,
|
|
145
|
+
N,
|
|
141
146
|
Q,
|
|
142
|
-
|
|
147
|
+
W,
|
|
148
|
+
l,
|
|
143
149
|
i,
|
|
144
150
|
c,
|
|
145
151
|
Y,
|
|
@@ -148,19 +154,21 @@ const a = et.createContext(null), gt = () => {
|
|
|
148
154
|
u,
|
|
149
155
|
m,
|
|
150
156
|
F,
|
|
151
|
-
|
|
157
|
+
I,
|
|
158
|
+
A,
|
|
152
159
|
E,
|
|
153
160
|
$,
|
|
161
|
+
C,
|
|
162
|
+
G,
|
|
154
163
|
w,
|
|
155
164
|
y,
|
|
156
|
-
T
|
|
157
|
-
V
|
|
165
|
+
T
|
|
158
166
|
]
|
|
159
167
|
);
|
|
160
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ st(b.Provider, { value: rt, children: v });
|
|
161
169
|
};
|
|
162
170
|
export {
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
xt as AgentBuilderProvider,
|
|
172
|
+
pt as useAgentBuilderContext
|
|
165
173
|
};
|
|
166
174
|
//# sourceMappingURL=AgentBuilderContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tIntentOption,\n\tModelOption,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (value: AgentValue): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.customIntent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= AGENT_CHAR_LIMITS.name &&\n\t\t\tvalue.description.length <= AGENT_CHAR_LIMITS.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst token =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? (() => {\n\t\t\t\t\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\t\t\t\t\treturn tool ? `{{tool:${tool.function_key}}}` : null;\n\t\t\t\t\t })()\n\t\t\t\t\t: `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) =>\n\t\t\t\ttoken ? text.split(token).join('') : text;\n\n\t\t\t// Snapshot the four fields a removal touches, for undo.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? { tools: value.tools.filter((t) => t !== id) }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.displayName ?? 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value), ...validationOverride }),\n\t\t[value, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","triggerValid","AGENT_CHAR_LIMITS","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","validationOverride","applicationType","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","mentionResetKey","setMentionResetKey","mentionInsertersRef","useRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","removeReference","token","tool","t","strip","text","s","k","undoRemoval","dismissUndo","validation","useMemo"],"mappings":";;;;AAmHA,MAAMA,IACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,CAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CAACC,MAAsC;AAC/D,QAAMC,IACLD,EAAM,QAAQ,SAAS,mBACnBA,EAAM,QAAQ,gBAAgB,IAAI,KAAA,EAAO,SAAS,IACnDA,EAAM,QAAQ,QAAQ,SAAS;AAEnC,SAAO;AAAA,IACN,OACCA,EAAM,KAAK,KAAA,EAAO,SAAS,KAC3BA,EAAM,KAAK,UAAUE,EAAkB,QACvCF,EAAM,YAAY,UAAUE,EAAkB;AAAA,IAC/C,SAASD;AAAA;AAAA,IAET,UACCD,EAAM,aAAa,KAAA,EAAO,SAAS,MAClCA,EAAM,aAAa,IAAI,KAAA,EAAO,SAAS;AAAA;AAAA,IAEzC,UAAU;AAAA,EAAA;AAEZ,GAwBaG,KAAgD,CAAC;AAAA,EAC7D,OAAAH;AAAA,EACA,UAAAI;AAAA,EACA,YAAYC;AAAA,EACZ,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAA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AAA,MAC/C,YAAAkB;AAAA,MACA,mBAAmBA,EAAW5C,CAAU;AAAA,MACxC,gBAAAf;AAAA,MACA,oBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,iBAAAC;AAAA,MACA,iBAAAE;AAAA,MACA,uBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,iBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,mBAAAC;AAAA,IAAA;AAAA,IAED;AAAA,MACCjB;AAAA,MACAmD;AAAA,MACAE;AAAA,MACAG;AAAA,MACA/B;AAAA,MACAU;AAAA,MACAL;AAAA,MACAI;AAAA,MACAM;AAAA,MACAwB;AAAA,MACAC;AAAA,MACA3C;AAAA,MACAC;AAAA,MACAqB;AAAA,MACAE;AAAA,MACAG;AAAA,MACAiB;AAAA,MACA3D;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,MACAE;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,IAAA;AAAA,EACD;AAGD,4BACEvB,EAAoB,UAApB,EAA6B,OAAOG,GACnC,UAAAqB,GACF;AAEF;"}
|
|
1
|
+
{"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tIntentOption,\n\tModelOption,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (value: AgentValue): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= AGENT_CHAR_LIMITS.name &&\n\t\t\tvalue.description.length <= AGENT_CHAR_LIMITS.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst token =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? (() => {\n\t\t\t\t\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\t\t\t\t\treturn tool ? `{{tool:${tool.function_key}}}` : null;\n\t\t\t\t\t })()\n\t\t\t\t\t: `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) =>\n\t\t\t\ttoken ? text.split(token).join('') : text;\n\n\t\t\t// Snapshot the four fields a removal touches, for undo.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? { tools: value.tools.filter((t) => t !== id) }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ?? 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value), ...validationOverride }),\n\t\t[value, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","triggerValid","AGENT_CHAR_LIMITS","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","validationOverride","applicationType","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","mentionResetKey","setMentionResetKey","mentionInsertersRef","useRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","removeReference","token","tool","t","strip","text","s","k","undoRemoval","dismissUndo","validation","useMemo"],"mappings":";;;;AA0HA,MAAMA,IACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,CAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CAACC,MAAsC;AAC/D,QAAMC,IACLD,EAAM,QAAQ,SAAS,mBACnBA,EAAM,QAAQ,iBAAiB,IAAI,KAAA,EAAO,SAAS,IACpDA,EAAM,QAAQ,QAAQ,SAAS;AAEnC,SAAO;AAAA,IACN,OACCA,EAAM,KAAK,KAAA,EAAO,SAAS,KAC3BA,EAAM,KAAK,UAAUE,EAAkB,QACvCF,EAAM,YAAY,UAAUE,EAAkB;AAAA,IAC/C,SAASD;AAAA;AAAA,IAET,UACCD,EAAM,aAAa,KAAA,EAAO,SAAS,MAClCA,EAAM,aAAa,IAAI,KAAA,EAAO,SAAS;AAAA;AAAA,IAEzC,UAAU;AAAA,EAAA;AAEZ,GAwBaG,KAAgD,CAAC;AAAA,EAC7D,OAAAH;AAAA,EACA,UAAAI;AAAA,EACA,YAAYC;AAAA,EACZ,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,iBAAAC;AAAA,EACA,uBAAAC,IAAwB;AAAA,EACxB,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,UAAAC;AACD,MAAM;AACL,QAAM,CAACC,IAAcC,EAAe,IAAIC,EAAkB,OAAO,GAC3DC,IAAajB,KAAkBc,IAC/BI,IAAcC,GAAaF,CAAU,GAIrC,CAACG,GAAiBC,CAAkB,IAAIL,EAAS,CAAC,GAIlDM,IAAsBC,EAE1B,EAAE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AA,MACA,uBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,yBAAAsB;AAAA,MACA,uBAAAC;AAAA,MACA,iBAAAtB;AAAA,MACA,kBAAAC;AAAA,MACA,mBAAAC;AAAA,IAAA;AAAA,IAED;AAAA,MACCjB;AAAA,MACAsD;AAAA,MACAE;AAAA,MACAG;AAAA,MACAlC;AAAA,MACAa;AAAA,MACAR;AAAA,MACAI;AAAA,MACAS;AAAA,MACAwB;AAAA,MACAC;AAAA,MACA9C;AAAA,MACAC;AAAA,MACAwB;AAAA,MACAE;AAAA,MACAG;AAAA,MACAiB;AAAA,MACA9D;AAAA,MACAC;AAAA,MACAC;AAAA,MACAC;AAAA,MACAE;AAAA,MACAC;AAAA,MACAC;AAAA,MACAsB;AAAA,MACAC;AAAA,MACAtB;AAAA,MACAC;AAAA,MACAC;AAAA,IAAA;AAAA,EACD;AAGD,4BACEvB,EAAoB,UAApB,EAA6B,OAAOG,IACnC,UAAAqB,GACF;AAEF;"}
|
|
@@ -13,11 +13,11 @@ import { STEP_DEFINITIONS as F } from "../constants/steps.js";
|
|
|
13
13
|
import { useAgentBuilderContext as L } from "../context/AgentBuilderContext.js";
|
|
14
14
|
import { Dropdown as N } from "../../dropdown/Dropdown.js";
|
|
15
15
|
const y = F[1], Z = () => {
|
|
16
|
-
const { value: S, patch: r, availableIntents: m } = L(), { trigger: n } = S, [
|
|
16
|
+
const { value: S, patch: r, availableIntents: m } = L(), { trigger: n } = S, [_, h] = T.useState(!1), a = (e) => r({ trigger: { ...n, mode: e } }), b = (e) => {
|
|
17
17
|
n.intents.includes(e) || r({
|
|
18
18
|
trigger: { ...n, intents: [...n.intents, e] }
|
|
19
19
|
}), h(!1);
|
|
20
|
-
},
|
|
20
|
+
}, I = (e) => r({
|
|
21
21
|
trigger: {
|
|
22
22
|
...n,
|
|
23
23
|
intents: n.intents.filter((c) => c !== e)
|
|
@@ -81,7 +81,7 @@ const y = F[1], Z = () => {
|
|
|
81
81
|
/* @__PURE__ */ t(
|
|
82
82
|
O,
|
|
83
83
|
{
|
|
84
|
-
onClick: () =>
|
|
84
|
+
onClick: () => I(e),
|
|
85
85
|
"aria-label": `Remove ${u(e)}`,
|
|
86
86
|
children: /* @__PURE__ */ t(
|
|
87
87
|
A,
|
|
@@ -94,7 +94,7 @@ const y = F[1], Z = () => {
|
|
|
94
94
|
}
|
|
95
95
|
)
|
|
96
96
|
] }, e)),
|
|
97
|
-
|
|
97
|
+
_ && s.length > 0 ? /* @__PURE__ */ t(
|
|
98
98
|
N,
|
|
99
99
|
{
|
|
100
100
|
"data-test": "intent-add-dropdown",
|
|
@@ -133,9 +133,9 @@ const y = F[1], Z = () => {
|
|
|
133
133
|
{
|
|
134
134
|
"data-test": "custom-intent",
|
|
135
135
|
label: "Describe the trigger",
|
|
136
|
-
value: n.
|
|
137
|
-
onChange: (e) => r({ trigger: { ...n,
|
|
138
|
-
maxLength: M.
|
|
136
|
+
value: n.custom_intent ?? "",
|
|
137
|
+
onChange: (e) => r({ trigger: { ...n, custom_intent: e } }),
|
|
138
|
+
maxLength: M.custom_intent,
|
|
139
139
|
placeholder: "e.g. The customer wants to cancel an order they placed.",
|
|
140
140
|
minHeight: "120px"
|
|
141
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Step2WhenItStepsIn.js","sources":["../../../../../src/components/agent-builder/steps/Step2WhenItStepsIn.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport { Dropdown } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tAddChipButton,\n\tCardRow,\n\tChipCloseButton,\n\tChipWrap,\n\tFieldBlock,\n\tIntentChip,\n\tRadioCard,\n\tRadioCardText,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents } = useAgentBuilderContext();\n\tconst { trigger } = value;\n\tconst [adding, setAdding] = React.useState(false);\n\n\tconst setMode = (mode: TriggerMode) =>\n\t\tpatch({ trigger: { ...trigger, mode } });\n\n\tconst addIntent = (intentValue: string) => {\n\t\tif (!trigger.intents.includes(intentValue)) {\n\t\t\tpatch({\n\t\t\t\ttrigger: { ...trigger, intents: [...trigger.intents, intentValue] },\n\t\t\t});\n\t\t}\n\t\tsetAdding(false);\n\t};\n\n\tconst removeIntent = (intentValue: string) =>\n\t\tpatch({\n\t\t\ttrigger: {\n\t\t\t\t...trigger,\n\t\t\t\tintents: trigger.intents.filter((i) => i !== intentValue),\n\t\t\t},\n\t\t});\n\n\tconst labelFor = (v: string) =>\n\t\tavailableIntents.find((o) => o.value === v)?.label ?? v;\n\n\tconst remainingOptions: SingleOption[] = availableIntents\n\t\t.filter((o) => !trigger.intents.includes(o.value))\n\t\t.map((o) => ({ label: o.label, value: o.value }));\n\n\treturn (\n\t\t<div>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<CardRow>\n\t\t\t\t<RadioCard\n\t\t\t\t\tdata-test=\"trigger-mode-manifest\"\n\t\t\t\t\tselected={trigger.mode === 'manifest_intent'}\n\t\t\t\t\tonClick={() => setMode('manifest_intent')}\n\t\t\t\t>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\tonValueChange={() => setMode('manifest_intent')}\n\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t/>\n\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tManifest intent\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tManifest's AI classifier routes conversations automatically —\n\t\t\t\t\t\t\tno keywords needed.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</RadioCardText>\n\t\t\t\t</RadioCard>\n\n\t\t\t\t<RadioCard\n\t\t\t\t\tdata-test=\"trigger-mode-custom\"\n\t\t\t\t\tselected={trigger.mode === 'custom_intent'}\n\t\t\t\t\tonClick={() => setMode('custom_intent')}\n\t\t\t\t>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\tonValueChange={() => setMode('custom_intent')}\n\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t/>\n\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tCustom intent\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tDefine your own trigger — use exact phrases or describe the\n\t\t\t\t\t\t\tcustomer's intent.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</RadioCardText>\n\t\t\t\t</RadioCard>\n\t\t\t</CardRow>\n\n\t\t\t{trigger.mode === 'manifest_intent' ? (\n\t\t\t\t<FieldBlock>\n\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\tIf customer talks about\n\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t<ChipWrap>\n\t\t\t\t\t\t{trigger.intents.map((intent) => (\n\t\t\t\t\t\t\t<IntentChip key={intent} data-test={`intent-chip-${intent}`}>\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{labelFor(intent)}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<ChipCloseButton\n\t\t\t\t\t\t\t\t\tonClick={() => removeIntent(intent)}\n\t\t\t\t\t\t\t\t\taria-label={`Remove ${labelFor(intent)}`}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\t\t\t\twidth={14}\n\t\t\t\t\t\t\t\t\t\theight={14}\n\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ChipCloseButton>\n\t\t\t\t\t\t\t</IntentChip>\n\t\t\t\t\t\t))}\n\n\t\t\t\t\t\t{adding && remainingOptions.length > 0 ? (\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"intent-add-dropdown\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"200px\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select intent\"\n\t\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\t\toptions={remainingOptions}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst single = Array.isArray(opt) ? opt[0] : opt;\n\t\t\t\t\t\t\t\t\tconst v = (single as SingleOption)?.value;\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\taddIntent(v);\n\t\t\t\t\t\t\t\t\t}\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\tremainingOptions.length > 0 && (\n\t\t\t\t\t\t\t\t<AddChipButton\n\t\t\t\t\t\t\t\t\tdata-test=\"intent-add-button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setAdding(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlusIcon\n\t\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\t\tIntent\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t</AddChipButton>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)}\n\t\t\t\t\t</ChipWrap>\n\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\tThis agent takes over from your main assistant when this intent is\n\t\t\t\t\t\tdetected. The changeover is automatic when you go live.\n\t\t\t\t\t</BodyCaption>\n\t\t\t\t</FieldBlock>\n\t\t\t) : (\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"custom-intent\"\n\t\t\t\t\tlabel=\"Describe the trigger\"\n\t\t\t\t\tvalue={trigger.customIntent ?? ''}\n\t\t\t\t\tonChange={(text) =>\n\t\t\t\t\t\tpatch({ trigger: { ...trigger, customIntent: text } })\n\t\t\t\t\t}\n\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.customIntent}\n\t\t\t\t\tplaceholder=\"e.g. The customer wants to cancel an order they placed.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step2WhenItStepsIn","value","patch","availableIntents","useAgentBuilderContext","trigger","adding","setAdding","React","setMode","mode","addIntent","intentValue","removeIntent","i","labelFor","v","o","remainingOptions","jsx","StepSectionHeader","CardRow","jsxs","RadioCard","RadioButton","COLORS","RadioCardText","TitleSmall","BodyCaption","FieldBlock","ChipWrap","intent","IntentCh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A,cAAA;AAAA,gCAEtBQ,GAAA,EAAc,OAAOR,EAAO,QAAQ,WAAW,UAAA,SAAA,CAEhD;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACD,GAGH;AAAA,wBACCG,GAAA,EAAY,OAAOH,EAAO,QAAQ,WAAW,UAAA,6HAAA,CAG9C;AAAA,IAAA,EAAA,CACD,IAEA,gBAAAN;AAAA,MAACqB;AAAA,MAAA;AAAA,QACA,aAAU;AAAA,QACV,OAAM;AAAA,QACN,OAAOnC,EAAQ,gBAAgB;AAAA,QAC/B,UAAU,CAACoC,MACVvC,EAAM,EAAE,SAAS,EAAE,GAAGG,GAAS,cAAcoC,EAAA,GAAQ;AAAA,QAEtD,WAAWC,EAAkB;AAAA,QAC7B,aAAY;AAAA,QACZ,WAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EACX,GAEF;AAEF;"}
|
|
1
|
+
{"version":3,"file":"Step2WhenItStepsIn.js","sources":["../../../../../src/components/agent-builder/steps/Step2WhenItStepsIn.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport { Dropdown } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tAddChipButton,\n\tCardRow,\n\tChipCloseButton,\n\tChipWrap,\n\tFieldBlock,\n\tIntentChip,\n\tRadioCard,\n\tRadioCardText,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents } = useAgentBuilderContext();\n\tconst { trigger } = value;\n\tconst [adding, setAdding] = React.useState(false);\n\n\tconst setMode = (mode: TriggerMode) =>\n\t\tpatch({ trigger: { ...trigger, mode } });\n\n\tconst addIntent = (intentValue: string) => {\n\t\tif (!trigger.intents.includes(intentValue)) {\n\t\t\tpatch({\n\t\t\t\ttrigger: { ...trigger, intents: [...trigger.intents, intentValue] },\n\t\t\t});\n\t\t}\n\t\tsetAdding(false);\n\t};\n\n\tconst removeIntent = (intentValue: string) =>\n\t\tpatch({\n\t\t\ttrigger: {\n\t\t\t\t...trigger,\n\t\t\t\tintents: trigger.intents.filter((i) => i !== intentValue),\n\t\t\t},\n\t\t});\n\n\tconst labelFor = (v: string) =>\n\t\tavailableIntents.find((o) => o.value === v)?.label ?? v;\n\n\tconst remainingOptions: SingleOption[] = availableIntents\n\t\t.filter((o) => !trigger.intents.includes(o.value))\n\t\t.map((o) => ({ label: o.label, value: o.value }));\n\n\treturn (\n\t\t<div>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<CardRow>\n\t\t\t\t<RadioCard\n\t\t\t\t\tdata-test=\"trigger-mode-manifest\"\n\t\t\t\t\tselected={trigger.mode === 'manifest_intent'}\n\t\t\t\t\tonClick={() => setMode('manifest_intent')}\n\t\t\t\t>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\tonValueChange={() => setMode('manifest_intent')}\n\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t/>\n\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tManifest intent\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tManifest's AI classifier routes conversations automatically —\n\t\t\t\t\t\t\tno keywords needed.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</RadioCardText>\n\t\t\t\t</RadioCard>\n\n\t\t\t\t<RadioCard\n\t\t\t\t\tdata-test=\"trigger-mode-custom\"\n\t\t\t\t\tselected={trigger.mode === 'custom_intent'}\n\t\t\t\t\tonClick={() => setMode('custom_intent')}\n\t\t\t\t>\n\t\t\t\t\t<RadioButton\n\t\t\t\t\t\tisActive={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\tonValueChange={() => setMode('custom_intent')}\n\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t/>\n\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tCustom intent\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tDefine your own trigger — use exact phrases or describe the\n\t\t\t\t\t\t\tcustomer's intent.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</RadioCardText>\n\t\t\t\t</RadioCard>\n\t\t\t</CardRow>\n\n\t\t\t{trigger.mode === 'manifest_intent' ? (\n\t\t\t\t<FieldBlock>\n\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\tIf customer talks about\n\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t<ChipWrap>\n\t\t\t\t\t\t{trigger.intents.map((intent) => (\n\t\t\t\t\t\t\t<IntentChip key={intent} data-test={`intent-chip-${intent}`}>\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{labelFor(intent)}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<ChipCloseButton\n\t\t\t\t\t\t\t\t\tonClick={() => removeIntent(intent)}\n\t\t\t\t\t\t\t\t\taria-label={`Remove ${labelFor(intent)}`}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\t\t\t\twidth={14}\n\t\t\t\t\t\t\t\t\t\theight={14}\n\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ChipCloseButton>\n\t\t\t\t\t\t\t</IntentChip>\n\t\t\t\t\t\t))}\n\n\t\t\t\t\t\t{adding && remainingOptions.length > 0 ? (\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"intent-add-dropdown\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"200px\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select intent\"\n\t\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\t\toptions={remainingOptions}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst single = Array.isArray(opt) ? opt[0] : opt;\n\t\t\t\t\t\t\t\t\tconst v = (single as SingleOption)?.value;\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\taddIntent(v);\n\t\t\t\t\t\t\t\t\t}\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\tremainingOptions.length > 0 && (\n\t\t\t\t\t\t\t\t<AddChipButton\n\t\t\t\t\t\t\t\t\tdata-test=\"intent-add-button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setAdding(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlusIcon\n\t\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\t\tIntent\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t</AddChipButton>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)}\n\t\t\t\t\t</ChipWrap>\n\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\tThis agent takes over from your main assistant when this intent is\n\t\t\t\t\t\tdetected. The changeover is automatic when you go live.\n\t\t\t\t\t</BodyCaption>\n\t\t\t\t</FieldBlock>\n\t\t\t) : (\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"custom-intent\"\n\t\t\t\t\tlabel=\"Describe the trigger\"\n\t\t\t\t\tvalue={trigger.custom_intent ?? ''}\n\t\t\t\t\tonChange={(text) =>\n\t\t\t\t\t\tpatch({ trigger: { ...trigger, custom_intent: text } })\n\t\t\t\t\t}\n\t\t\t\t\tmaxLength={AGENT_CHAR_LIMITS.custom_intent}\n\t\t\t\t\tplaceholder=\"e.g. The customer wants to cancel an order they placed.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step2WhenItStepsIn","value","patch","availableIntents","useAgentBuilderContext","trigger","adding","setAdding","React","setMode","mode","addIntent","intentValue","removeIntent","i","labelFor","v","o","remainingOptions","jsx","StepSectionHeader","CardRow","jsxs","RadioCard","RadioButton","COLORS","RadioCardText","TitleSmall","BodyCaption","FieldBlock","ChipWrap","intent","IntentChip","BodySecondary","ChipCloseButton","CrossIcon","Dropdown","opt","AddChipButton","PlusIcon","AiTextArea","text","AGENT_CHAR_LIMITS"],"mappings":";;;;;;;;;;;;;;AA6BA,MAAMA,IAAOC,EAAiB,CAAC,GAElBC,IAA+B,MAAM;AACjD,QAAM,EAAE,OAAAC,GAAO,OAAAC,GAAO,kBAAAC,EAAA,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