@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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { FunctionComponent, SVGAttributes } from 'react';
|
|
2
|
+
import { ConfigToolKey } from '../AgentBuilder.model';
|
|
3
|
+
/**
|
|
4
|
+
* Static tool-related constants for the builder's Step 3 (tools & sub-agents):
|
|
5
|
+
* the reference-picker category tabs and the per-source display labels. Kept here
|
|
6
|
+
* (rather than inline in the picker / serialization utils) so the labels a user
|
|
7
|
+
* sees are all in one obvious place.
|
|
8
|
+
*/
|
|
9
|
+
/** A reference-picker category tab. */
|
|
10
|
+
export type Category = 'tool' | 'subagent';
|
|
11
|
+
/** Category tabs shown at the root of the `@` reference picker. */
|
|
12
|
+
export declare const CATEGORIES: {
|
|
13
|
+
key: Category;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
/**
|
|
17
|
+
* Every tool "source" the builder renders an icon / label / picker entry for.
|
|
18
|
+
* Supersets the persisted bik-models tool source (`manifest` / `shopify` /
|
|
19
|
+
* `integration`) with the built-in config-drawer tools (Rest API / email
|
|
20
|
+
* handover / Slack). Enum VALUES are the source strings used as keys and ids, so
|
|
21
|
+
* they must stay stable. Dynamic/unknown sources (e.g. a raw integration key)
|
|
22
|
+
* are looked up leniently — see `toolSourceLabel` and `sourceIcon`.
|
|
23
|
+
*/
|
|
24
|
+
export declare enum ToolSource {
|
|
25
|
+
Manifest = "manifest",
|
|
26
|
+
Shopify = "shopify",
|
|
27
|
+
Integration = "integration",
|
|
28
|
+
RestApi = "restapi",
|
|
29
|
+
EmailHandover = "email_handover",
|
|
30
|
+
Slack = "slack"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Display labels for the known tool sources — drives the picker's source headers,
|
|
34
|
+
* the empty-state source buttons and the mention-chip prefix. Unknown sources
|
|
35
|
+
* fall back to the raw key (see `toolSourceLabel`).
|
|
36
|
+
*/
|
|
37
|
+
export declare const TOOL_SOURCE_LABELS: Record<ToolSource, string>;
|
|
38
|
+
/** A tool source's brand-glyph component. */
|
|
39
|
+
export type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;
|
|
40
|
+
/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */
|
|
41
|
+
export interface SourceIcon {
|
|
42
|
+
Icon: IconComp;
|
|
43
|
+
w: number;
|
|
44
|
+
h: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A built-in "tool" that opens a config drawer (Rest API / email handover /
|
|
48
|
+
* Slack) rather than inserting a mention. Surfaced as an empty-state source
|
|
49
|
+
* button in the Tools section and as a row in the `@`-picker Tools view; picking
|
|
50
|
+
* it opens the drawer and never writes into the instructions text.
|
|
51
|
+
*/
|
|
52
|
+
export interface ToolAction {
|
|
53
|
+
source: ToolSource;
|
|
54
|
+
label: string;
|
|
55
|
+
icon?: SourceIcon;
|
|
56
|
+
/** Open this tool's config drawer. */
|
|
57
|
+
onSelect: () => void;
|
|
58
|
+
}
|
|
59
|
+
/** Sources of the built-in drawer tools, in display order. */
|
|
60
|
+
export declare const TOOL_ACTION_SOURCES: ToolSource[];
|
|
61
|
+
/**
|
|
62
|
+
* Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each
|
|
63
|
+
* mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.
|
|
64
|
+
*/
|
|
65
|
+
export declare const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const n = [
|
|
2
|
+
{ key: "tool", label: "Tools" },
|
|
3
|
+
{ key: "subagent", label: "Sub-agent" }
|
|
4
|
+
];
|
|
5
|
+
var e = /* @__PURE__ */ ((a) => (a.Manifest = "manifest", a.Shopify = "shopify", a.Integration = "integration", a.RestApi = "restapi", a.EmailHandover = "email_handover", a.Slack = "slack", a))(e || {});
|
|
6
|
+
const s = {
|
|
7
|
+
manifest: "Manifest",
|
|
8
|
+
shopify: "Shopify",
|
|
9
|
+
integration: "Integration",
|
|
10
|
+
restapi: "Rest API",
|
|
11
|
+
email_handover: "Handover to email",
|
|
12
|
+
slack: "Send Slack message"
|
|
13
|
+
}, t = [
|
|
14
|
+
"restapi",
|
|
15
|
+
"email_handover",
|
|
16
|
+
"slack"
|
|
17
|
+
/* Slack */
|
|
18
|
+
], i = {
|
|
19
|
+
email_handover: "send_email",
|
|
20
|
+
slack: "send_slack_message"
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
n as CATEGORIES,
|
|
24
|
+
i as CONFIG_TOOL_SOURCES,
|
|
25
|
+
t as TOOL_ACTION_SOURCES,
|
|
26
|
+
s as TOOL_SOURCE_LABELS,
|
|
27
|
+
e as ToolSource
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { FunctionComponent, SVGAttributes } from 'react';\nimport type { ConfigToolKey } from '../AgentBuilder.model';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Supersets the persisted bik-models tool source (`manifest` / `shopify` /\n * `integration`) with the built-in config-drawer tools (Rest API / email\n * handover / Slack). Enum VALUES are the source strings used as keys and ids, so\n * they must stay stable. Dynamic/unknown sources (e.g. a raw integration key)\n * are looked up leniently — see `toolSourceLabel` and `sourceIcon`.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tIntegration = 'integration',\n\tRestApi = 'restapi',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Display labels for the known tool sources — drives the picker's source headers,\n * the empty-state source buttons and the mention-chip prefix. Unknown sources\n * fall back to the raw key (see `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Handover to email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_SOURCES","CONFIG_TOOL_SOURCES"],"mappings":"AAcO,MAAMA,IAAiD;AAAA,EAC7D,EAAE,KAAK,QAAQ,OAAO,QAAA;AAAA,EACtB,EAAE,KAAK,YAAY,OAAO,YAAA;AAC3B;AAUO,IAAKC,sBAAAA,OACXA,EAAA,WAAW,YACXA,EAAA,UAAU,WACVA,EAAA,cAAc,eACdA,EAAA,UAAU,WACVA,EAAA,gBAAgB,kBAChBA,EAAA,QAAQ,SANGA,IAAAA,KAAA,CAAA,CAAA;AAcL,MAAMC,IAAiD;AAAA,EAC5D,UAAsB;AAAA,EACtB,SAAqB;AAAA,EACrB,aAAyB;AAAA,EACzB,SAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AACrB,GA2BaC,IAAoC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA;AACD,GAMaC,IAAkE;AAAA,EAC7E,gBAA2B;AAAA,EAC3B,OAAmB;AACrB;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { AgentTool, AgentValue, IntentOption, ModelOption, StepKey, StepValidation, SubAgentDraft, SubAgentRef } from '../AgentBuilder.model';
|
|
3
|
+
import { AgentTool, AgentValue, ConfigToolKey, IntentOption, ModelOption, ParamsBlob, StepKey, StepValidation, SubAgentDraft, SubAgentRef } from '../AgentBuilder.model';
|
|
4
4
|
import { AgentCharLimits } from '../constants/charLimits';
|
|
5
|
+
import { ToolSource } from '../constants/tools';
|
|
5
6
|
/** Mention-capable text fields in Step 3 (both store firebase token text). */
|
|
6
7
|
export type MentionFieldKey = 'instructions' | 'guardrail';
|
|
7
8
|
type MentionInsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;
|
|
@@ -63,6 +64,11 @@ export interface AgentBuilderContextShape {
|
|
|
63
64
|
availableSubAgents: SubAgentRef[];
|
|
64
65
|
availableIntents: IntentOption[];
|
|
65
66
|
availableModels: ModelOption[];
|
|
67
|
+
/**
|
|
68
|
+
* Backend templates for the shared-drawer tools (email / Slack), keyed by
|
|
69
|
+
* `tool_key`. A present key drives its dynamic form + enables its tool action.
|
|
70
|
+
*/
|
|
71
|
+
configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
|
|
66
72
|
/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */
|
|
67
73
|
applicationType?: ApplicationType;
|
|
68
74
|
/** Resolved per-field character limits (consumer overrides merged over defaults). */
|
|
@@ -78,12 +84,22 @@ export interface AgentBuilderContextShape {
|
|
|
78
84
|
registerSubAgentCreator: (fn: (() => void) | null) => void;
|
|
79
85
|
/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */
|
|
80
86
|
requestCreateSubAgent: () => void;
|
|
87
|
+
/**
|
|
88
|
+
* Step 3 registers its "open the drawer for this built-in tool action"
|
|
89
|
+
* (Rest API / email handover / Slack) handler here so the `@` reference picker
|
|
90
|
+
* can trigger it. Pass `null` to unregister.
|
|
91
|
+
*/
|
|
92
|
+
registerToolActionHandler: (fn: ((source: ToolSource) => void) | null) => void;
|
|
93
|
+
/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */
|
|
94
|
+
requestToolAction: (source: ToolSource) => void;
|
|
81
95
|
/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */
|
|
82
96
|
onFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;
|
|
83
97
|
/** Persist edits to an existing sub-agent. */
|
|
84
98
|
onUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;
|
|
85
99
|
/** Optional "Improve with AI" for the drawer's instructions / guardrails. */
|
|
86
100
|
onImproveSubAgent?: (kind: 'instructions' | 'guardrail', text: string) => Promise<string>;
|
|
101
|
+
/** Optional "Improve with AI" for the Rest API / email-handover tool drawers. */
|
|
102
|
+
onImproveToolInstructions?: (text: string) => Promise<string>;
|
|
87
103
|
}
|
|
88
104
|
export declare const useAgentBuilderContext: () => AgentBuilderContextShape;
|
|
89
105
|
interface ProviderProps {
|
|
@@ -95,6 +111,7 @@ interface ProviderProps {
|
|
|
95
111
|
availableSubAgents: SubAgentRef[];
|
|
96
112
|
availableIntents: IntentOption[];
|
|
97
113
|
availableModels: ModelOption[];
|
|
114
|
+
configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
|
|
98
115
|
validation?: Partial<StepValidation>;
|
|
99
116
|
applicationType?: ApplicationType;
|
|
100
117
|
charLimits?: Partial<AgentCharLimits>;
|
|
@@ -103,6 +120,7 @@ interface ProviderProps {
|
|
|
103
120
|
onFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;
|
|
104
121
|
onUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;
|
|
105
122
|
onImproveSubAgent?: (kind: 'instructions' | 'guardrail', text: string) => Promise<string>;
|
|
123
|
+
onImproveToolInstructions?: (text: string) => Promise<string>;
|
|
106
124
|
children: React.ReactNode;
|
|
107
125
|
}
|
|
108
126
|
export declare const AgentBuilderProvider: React.FC<ProviderProps>;
|
|
@@ -1,187 +1,216 @@
|
|
|
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 ft } from "react/jsx-runtime";
|
|
2
|
+
import mt, { useState as S, useRef as u, useCallback as e, useMemo as h, useContext as pt } from "react";
|
|
3
|
+
import { AGENT_CHAR_LIMITS as xt } from "../constants/charLimits.js";
|
|
4
|
+
import { getStepIndex as Rt, STEP_KEYS as A } from "../constants/steps.js";
|
|
5
|
+
const ct = mt.createContext(null), ht = () => {
|
|
6
|
+
const t = pt(ct);
|
|
7
|
+
if (!t)
|
|
8
8
|
throw new Error(
|
|
9
9
|
"useAgentBuilderContext must be used within an AgentBuilderProvider"
|
|
10
10
|
);
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const
|
|
11
|
+
return t;
|
|
12
|
+
}, At = (t, r) => {
|
|
13
|
+
const d = t.trigger.mode === "custom_intent" ? (t.trigger.custom_intent ?? "").trim().length > 0 : t.trigger.intents.length > 0;
|
|
14
14
|
return {
|
|
15
|
-
about:
|
|
16
|
-
trigger:
|
|
15
|
+
about: t.name.trim().length > 0 && t.name.length <= r.name && t.description.length <= r.description,
|
|
16
|
+
trigger: d,
|
|
17
17
|
// At least one of Instructions / Guardrails must be filled.
|
|
18
|
-
response:
|
|
18
|
+
response: t.instructions.trim().length > 0 || (t.guardrail ?? "").trim().length > 0,
|
|
19
19
|
// Optional until specced further — never blocks go-live.
|
|
20
20
|
handover: !0
|
|
21
21
|
};
|
|
22
|
-
},
|
|
23
|
-
value:
|
|
24
|
-
onChange:
|
|
25
|
-
activeStep:
|
|
26
|
-
onStepChange:
|
|
27
|
-
availableTools:
|
|
28
|
-
availableSubAgents:
|
|
29
|
-
availableIntents:
|
|
22
|
+
}, Bt = ({
|
|
23
|
+
value: t,
|
|
24
|
+
onChange: r,
|
|
25
|
+
activeStep: d,
|
|
26
|
+
onStepChange: B,
|
|
27
|
+
availableTools: f,
|
|
28
|
+
availableSubAgents: m,
|
|
29
|
+
availableIntents: F,
|
|
30
30
|
availableModels: P,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
configToolTemplates: E,
|
|
32
|
+
validation: $,
|
|
33
|
+
applicationType: a,
|
|
34
|
+
charLimits: w,
|
|
35
|
+
disableStepNavigation: H = !0,
|
|
36
|
+
onCreateSubAgent: I,
|
|
36
37
|
onFetchSubAgent: L,
|
|
37
38
|
onUpdateSubAgent: V,
|
|
38
39
|
onImproveSubAgent: b,
|
|
39
|
-
|
|
40
|
+
onImproveToolInstructions: j,
|
|
41
|
+
children: it
|
|
40
42
|
}) => {
|
|
41
|
-
const [
|
|
42
|
-
|
|
43
|
-
const [y, K] =
|
|
44
|
-
(
|
|
45
|
-
|
|
43
|
+
const [ut, lt] = S("about"), p = d ?? ut, c = Rt(p), q = u(t);
|
|
44
|
+
q.current = t;
|
|
45
|
+
const [y, K] = S(0), T = u({}), G = u("instructions"), N = e(
|
|
46
|
+
(n, o) => {
|
|
47
|
+
o ? T.current[n] = o : delete T.current[n];
|
|
46
48
|
},
|
|
47
49
|
[]
|
|
48
|
-
),
|
|
49
|
-
|
|
50
|
-
}, []),
|
|
51
|
-
|
|
52
|
-
}, []),
|
|
53
|
-
|
|
54
|
-
}, []),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
g === void 0 && rt(t), F?.(t);
|
|
50
|
+
), U = e((n) => {
|
|
51
|
+
G.current = n;
|
|
52
|
+
}, []), Y = u(null), z = e((n) => {
|
|
53
|
+
Y.current = n;
|
|
54
|
+
}, []), D = e(() => {
|
|
55
|
+
Y.current?.();
|
|
56
|
+
}, []), J = u(
|
|
57
|
+
null
|
|
58
|
+
), Q = e(
|
|
59
|
+
(n) => {
|
|
60
|
+
J.current = n;
|
|
60
61
|
},
|
|
61
|
-
[
|
|
62
|
-
),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
[
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
[]
|
|
63
|
+
), W = e((n) => {
|
|
64
|
+
J.current?.(n);
|
|
65
|
+
}, []), X = e((n, o, i) => {
|
|
66
|
+
const g = T.current;
|
|
67
|
+
(g[G.current] ?? g.instructions)?.(n, o, i);
|
|
68
|
+
}, []), [Z, _] = S(null), x = u(null), k = u(0), l = e(
|
|
69
|
+
(n) => {
|
|
70
|
+
d === void 0 && lt(n), B?.(n);
|
|
71
|
+
},
|
|
72
|
+
[d, B]
|
|
73
|
+
), C = e(() => {
|
|
74
|
+
const n = A[Math.min(c + 1, A.length - 1)];
|
|
75
|
+
l(n);
|
|
76
|
+
}, [c, l]), O = e(() => {
|
|
77
|
+
const n = A[Math.max(c - 1, 0)];
|
|
78
|
+
l(n);
|
|
79
|
+
}, [c, l]), v = e(
|
|
80
|
+
(n) => r(n),
|
|
81
|
+
[r]
|
|
82
|
+
), tt = e(
|
|
83
|
+
(n, o) => r({ [n]: o }),
|
|
84
|
+
[r]
|
|
85
|
+
), nt = e(
|
|
86
|
+
(n, o) => {
|
|
87
|
+
const i = q.current;
|
|
88
|
+
n === "tool" ? i.tools.includes(o) || r({ tools: [...i.tools, o] }) : i.subagents.includes(o) || r({ subagents: [...i.subagents, o] });
|
|
78
89
|
},
|
|
79
|
-
[
|
|
80
|
-
),
|
|
81
|
-
(
|
|
82
|
-
const i =
|
|
83
|
-
|
|
84
|
-
tools:
|
|
85
|
-
subagents:
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
[r]
|
|
91
|
+
), ot = e(
|
|
92
|
+
(n, o) => {
|
|
93
|
+
const i = n === "tool" ? `{{tool:${o}}}` : `{{subagent:${o}}}`, g = (s) => s.split(i).join("");
|
|
94
|
+
x.current = {
|
|
95
|
+
tools: t.tools,
|
|
96
|
+
subagents: t.subagents,
|
|
97
|
+
configTools: t.configTools,
|
|
98
|
+
restApiTools: t.restApiTools,
|
|
99
|
+
instructions: t.instructions,
|
|
100
|
+
guardrail: t.guardrail
|
|
88
101
|
};
|
|
89
|
-
const
|
|
90
|
-
instructions:
|
|
91
|
-
guardrail:
|
|
92
|
-
...
|
|
102
|
+
const rt = {
|
|
103
|
+
instructions: g(t.instructions),
|
|
104
|
+
guardrail: g(t.guardrail ?? ""),
|
|
105
|
+
...n === "tool" ? {
|
|
106
|
+
// A tool id may be a catalog tool OR an inline custom tool — drop
|
|
107
|
+
// it from whichever list holds it (the others are no-op filters).
|
|
108
|
+
tools: t.tools.filter((s) => s !== o),
|
|
109
|
+
configTools: (t.configTools ?? []).filter((s) => s.id !== o),
|
|
110
|
+
restApiTools: (t.restApiTools ?? []).filter(
|
|
111
|
+
(s) => s.id !== o
|
|
112
|
+
)
|
|
113
|
+
} : { subagents: t.subagents.filter((s) => s !== o) }
|
|
93
114
|
};
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
id:
|
|
98
|
-
message: `${
|
|
115
|
+
r(rt), K((s) => s + 1);
|
|
116
|
+
const gt = n === "tool" ? f.find((s) => s.tool_id === o)?.display_name ?? (t.restApiTools ?? []).find((s) => s.id === o)?.name ?? "Tool" : m.find((s) => s.id === o)?.name ?? "Sub-agent";
|
|
117
|
+
k.current += 1, _({
|
|
118
|
+
id: k.current,
|
|
119
|
+
message: `${n === "tool" ? "Tool" : "Sub-agent"} "${gt}" removed`
|
|
99
120
|
});
|
|
100
121
|
},
|
|
101
|
-
[
|
|
102
|
-
),
|
|
103
|
-
|
|
104
|
-
}, [
|
|
105
|
-
() => ({ ...
|
|
106
|
-
[
|
|
107
|
-
),
|
|
108
|
-
() => ({ ...
|
|
109
|
-
[
|
|
110
|
-
),
|
|
122
|
+
[f, m, t, r]
|
|
123
|
+
), st = e(() => {
|
|
124
|
+
x.current && (r(x.current), x.current = null, K((n) => n + 1)), _(null);
|
|
125
|
+
}, [r]), et = e(() => _(null), []), R = h(
|
|
126
|
+
() => ({ ...xt, ...w }),
|
|
127
|
+
[w]
|
|
128
|
+
), M = h(
|
|
129
|
+
() => ({ ...At(t, R), ...$ }),
|
|
130
|
+
[t, R, $]
|
|
131
|
+
), dt = h(
|
|
111
132
|
() => ({
|
|
112
|
-
value:
|
|
113
|
-
patch:
|
|
114
|
-
updateField:
|
|
115
|
-
addReference:
|
|
116
|
-
removeReference:
|
|
133
|
+
value: t,
|
|
134
|
+
patch: v,
|
|
135
|
+
updateField: tt,
|
|
136
|
+
addReference: nt,
|
|
137
|
+
removeReference: ot,
|
|
117
138
|
mentionResetKey: y,
|
|
118
|
-
insertMention:
|
|
119
|
-
registerMentionField:
|
|
120
|
-
notifyMentionFocus:
|
|
121
|
-
undoToast:
|
|
122
|
-
undoRemoval:
|
|
123
|
-
dismissUndo:
|
|
124
|
-
activeStep:
|
|
139
|
+
insertMention: X,
|
|
140
|
+
registerMentionField: N,
|
|
141
|
+
notifyMentionFocus: U,
|
|
142
|
+
undoToast: Z,
|
|
143
|
+
undoRemoval: st,
|
|
144
|
+
dismissUndo: et,
|
|
145
|
+
activeStep: p,
|
|
125
146
|
activeIndex: c,
|
|
126
|
-
goToStep:
|
|
127
|
-
goNext:
|
|
128
|
-
goPrev:
|
|
147
|
+
goToStep: l,
|
|
148
|
+
goNext: C,
|
|
149
|
+
goPrev: O,
|
|
129
150
|
isFirstStep: c === 0,
|
|
130
|
-
isLastStep: c ===
|
|
131
|
-
validation:
|
|
132
|
-
isActiveStepValid:
|
|
133
|
-
availableTools:
|
|
134
|
-
availableSubAgents:
|
|
135
|
-
availableIntents:
|
|
151
|
+
isLastStep: c === A.length - 1,
|
|
152
|
+
validation: M,
|
|
153
|
+
isActiveStepValid: M[p],
|
|
154
|
+
availableTools: f,
|
|
155
|
+
availableSubAgents: m,
|
|
156
|
+
availableIntents: F,
|
|
136
157
|
availableModels: P,
|
|
137
|
-
|
|
158
|
+
configToolTemplates: E,
|
|
159
|
+
applicationType: a,
|
|
138
160
|
charLimits: R,
|
|
139
|
-
disableStepNavigation:
|
|
140
|
-
onCreateSubAgent:
|
|
141
|
-
registerSubAgentCreator:
|
|
142
|
-
requestCreateSubAgent:
|
|
161
|
+
disableStepNavigation: H,
|
|
162
|
+
onCreateSubAgent: I,
|
|
163
|
+
registerSubAgentCreator: z,
|
|
164
|
+
requestCreateSubAgent: D,
|
|
165
|
+
registerToolActionHandler: Q,
|
|
166
|
+
requestToolAction: W,
|
|
143
167
|
onFetchSubAgent: L,
|
|
144
168
|
onUpdateSubAgent: V,
|
|
145
|
-
onImproveSubAgent: b
|
|
169
|
+
onImproveSubAgent: b,
|
|
170
|
+
onImproveToolInstructions: j
|
|
146
171
|
}),
|
|
147
172
|
[
|
|
148
|
-
|
|
173
|
+
t,
|
|
174
|
+
v,
|
|
175
|
+
tt,
|
|
176
|
+
nt,
|
|
177
|
+
ot,
|
|
178
|
+
y,
|
|
149
179
|
X,
|
|
180
|
+
N,
|
|
181
|
+
U,
|
|
150
182
|
Z,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
z,
|
|
155
|
-
G,
|
|
156
|
-
H,
|
|
157
|
-
D,
|
|
158
|
-
O,
|
|
159
|
-
v,
|
|
160
|
-
x,
|
|
183
|
+
st,
|
|
184
|
+
et,
|
|
185
|
+
p,
|
|
161
186
|
c,
|
|
162
|
-
u,
|
|
163
|
-
Q,
|
|
164
|
-
W,
|
|
165
|
-
a,
|
|
166
187
|
l,
|
|
188
|
+
C,
|
|
189
|
+
O,
|
|
190
|
+
M,
|
|
167
191
|
f,
|
|
168
|
-
|
|
192
|
+
m,
|
|
193
|
+
F,
|
|
169
194
|
P,
|
|
170
195
|
E,
|
|
196
|
+
a,
|
|
171
197
|
R,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
198
|
+
H,
|
|
199
|
+
I,
|
|
200
|
+
z,
|
|
201
|
+
D,
|
|
202
|
+
Q,
|
|
203
|
+
W,
|
|
176
204
|
L,
|
|
177
205
|
V,
|
|
178
|
-
b
|
|
206
|
+
b,
|
|
207
|
+
j
|
|
179
208
|
]
|
|
180
209
|
);
|
|
181
|
-
return /* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ ft(ct.Provider, { value: dt, children: it });
|
|
182
211
|
};
|
|
183
212
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
213
|
+
Bt as AgentBuilderProvider,
|
|
214
|
+
ht as useAgentBuilderContext
|
|
186
215
|
};
|
|
187
216
|
//# 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 type { AgentCharLimits } 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/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (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/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\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 = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): 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 <= limits.name &&\n\t\t\tvalue.description.length <= 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\tcharLimits?: Partial<AgentCharLimits>;\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\tcharLimits: charLimitsOverride,\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// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\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 addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\tif (!v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\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\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, 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\taddReference,\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\tcharLimits,\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\taddReference,\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\tcharLimits,\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","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","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","addReference","v","removeReference","token","strip","text","t","s","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":";;;;AAoIA,MAAMA,KACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,EAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CACxBC,GACAC,MACoB;AACpB,QAAMC,IACLF,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,UAAUC,EAAO,QAC5BD,EAAM,YAAY,UAAUC,EAAO;AAAA,IACpC,SAASC;AAAA;AAAA,IAET,UACCF,EAAM,aAAa,KAAA,EAAO,SAAS,MAClCA,EAAM,aAAa,IAAI,KAAA,EAAO,SAAS;AAAA;AAAA,IAEzC,UAAU;AAAA,EAAA;AAEZ,GAyBaG,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,YAAYC;AAAA,EACZ,uBAAAC,IAAwB;AAAA,EACxB,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,UAAAC;AACD,MAAM;AACL,QAAM,CAACC,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EF;"}
|
|
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\tConfigToolKey,\n\tIntentOption,\n\tModelOption,\n\tParamsBlob,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\nimport type { ToolSource } from '../constants/tools';\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/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (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/**\n\t * Backend templates for the shared-drawer tools (email / Slack), keyed by\n\t * `tool_key`. A present key drives its dynamic form + enables its tool action.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\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/**\n\t * Step 3 registers its \"open the drawer for this built-in tool action\"\n\t * (Rest API / email handover / Slack) handler here so the `@` reference picker\n\t * can trigger it. Pass `null` to unregister.\n\t */\n\tregisterToolActionHandler: (\n\t\tfn: ((source: ToolSource) => void) | null,\n\t) => void;\n\t/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */\n\trequestToolAction: (source: ToolSource) => 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\t/** Optional \"Improve with AI\" for the Rest API / email-handover tool drawers. */\n\tonImproveToolInstructions?: (text: string) => 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 = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): 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 <= limits.name &&\n\t\t\tvalue.description.length <= 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\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\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\tonImproveToolInstructions?: (text: string) => 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\tconfigToolTemplates,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tonImproveToolInstructions,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\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\n\t// Step 3 registers a dispatcher that opens a built-in tool action's drawer.\n\tconst toolActionHandlerRef = useRef<((source: ToolSource) => void) | null>(\n\t\tnull,\n\t);\n\tconst registerToolActionHandler = useCallback(\n\t\t(fn: ((source: ToolSource) => void) | null) => {\n\t\t\ttoolActionHandlerRef.current = fn;\n\t\t},\n\t\t[],\n\t);\n\tconst requestToolAction = useCallback((source: ToolSource) => {\n\t\ttoolActionHandlerRef.current?.(source);\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 addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\tif (!v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot every field a removal touches, for undo. Custom tools (Rest\n\t\t\t// API / email / Slack) live on their own lists, so include them too.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tconfigTools: value.configTools,\n\t\t\t\trestApiTools: value.restApiTools,\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? {\n\t\t\t\t\t\t\t// A tool id may be a catalog tool OR an inline custom tool — drop\n\t\t\t\t\t\t\t// it from whichever list holds it (the others are no-op filters).\n\t\t\t\t\t\t\ttools: value.tools.filter((t) => t !== id),\n\t\t\t\t\t\t\tconfigTools: (value.configTools ?? []).filter((t) => t.id !== id),\n\t\t\t\t\t\t\trestApiTools: (value.restApiTools ?? []).filter(\n\t\t\t\t\t\t\t\t(t) => t.id !== id,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\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 ??\n\t\t\t\t\t (value.restApiTools ?? []).find((t) => t.id === id)?.name ??\n\t\t\t\t\t '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\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, 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\taddReference,\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\tconfigToolTemplates,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\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\tconfigToolTemplates,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\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","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","toolActionHandlerRef","registerToolActionHandler","requestToolAction","source","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","addReference","v","removeReference","token","strip","text","t","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":";;;;AAwJA,MAAMA,KACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,EAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CACxBC,GACAC,MACoB;AACpB,QAAMC,IACLF,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,UAAUC,EAAO,QAC5BD,EAAM,YAAY,UAAUC,EAAO;AAAA,IACpC,SAASC;AAAA;AAAA,IAET,UACCF,EAAM,aAAa,KAAA,EAAO,SAAS,MAClCA,EAAM,aAAa,IAAI,KAAA,EAAO,SAAS;AAAA;AAAA,IAEzC,UAAU;AAA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