@bikdotai/bik-component-library 0.0.840-tools-beta.0 → 0.0.840-tools-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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),Z=require("../../../assets/icons/delete.svg.js"),G=require("../../../assets/icons/edit.svg.js"),H=require("../../../assets/icons/plus.svg.js"),u=require("react"),T=require("styled-components"),S=require("../../TypographyStyle.js"),d=require("../../../constants/Theme.js"),s=require("../AgentBuilder.styled.js"),C=require("../utils/sourceIcons.js"),ee=require("./MentionPicker.js"),F=require("../../dropdown/Dropdown.js"),N=require("../../dropdown/utils.js"),ne=require("../../button/Button.js"),oe=require("../../states-modal/DeleteConfirmationModal.js"),te=i=>i&&typeof i=="object"&&"default"in i?i:{default:i},k=te(T),V="__bik_create_new__",le=({title:i,helper:L,items:a,addableOptions:y,onAdd:g,onRemove:m,dataTestPrefix:t,emptyText:K,createOption:o,onConfigure:_,sourceGroups:p,mentionItems:B,actionSources:w,confirmDelete:f})=>{const[h,c]=u.useState(!1),[q,b]=u.useState(null),[U,v]=u.useState(null),j=!!p&&p.length>0,$=p?.find(e=>e.source===U),l=B!==void 0,A=u.useRef(null),D=u.useRef(null),[x,I]=u.useState(null);u.useEffect(()=>{if(!l||!h)return;const e=R=>{const z=R.target;!A.current?.contains(z)&&!D.current?.contains(z)&&c(!1)},r=R=>{R.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",r)}},[l,h]);const P=j?l||a.length>0:l||y.length>0||!!o&&a.length>0,J=a.length===0&&!!o&&!j&&!l,E=!!w&&w.length>0,Q=(j||E)&&a.length===0,X=()=>{if(l){I(null),c(e=>!e);return}if(j){v(null),c(e=>!e);return}if(y.length===0&&o){o.onSelect();return}c(e=>!e)},Y=()=>a.map(e=>{const r=e.onConfigure??(_?()=>_(e.id):void 0);return n.jsxs(s.SelectableRow,{"data-test":`${t}-row-${e.id}`,children:[C.renderSourceIcon(e.icon),n.jsx(s.RowText,{children:n.jsx(S.BodySecondary,{numberOfLines:1,color:d.COLORS.content.primary,children:e.label})}),n.jsxs(s.RowActions,{children:[r&&n.jsx(s.RowMenuButton,{"data-test":`${t}-edit-${e.id}`,"aria-label":`Edit ${e.label}`,onClick:r,children:n.jsx(G.default,{width:16,height:16,color:d.COLORS.content.secondary})}),r&&n.jsx(s.RowActionDivider,{"aria-hidden":!0}),n.jsx(s.RowMenuButton,{"data-test":`${t}-delete-${e.id}`,"aria-label":`Delete ${e.label}`,onClick:()=>f?b(e.id):m(e.id),children:n.jsx(Z.default,{width:16,height:16,color:d.COLORS.content.secondary})})]})]},e.id)}),O=o?[...y,{label:o.label,value:V,searchKey:o.label,customComponent:n.jsx("div",{style:{width:"100%",textAlign:"center",color:d.COLORS.content.brand,fontFamily:"Inter",fontSize:14,fontWeight:600},children:o.label})}]:y,M=l?n.jsx(ee.MentionPicker,{items:B??[],query:"",activeIndex:0,initialSource:x??void 0,onSelect:e=>{c(!1),g(String(e.id))},onClose:()=>c(!1),onCreateSubAgent:o?()=>{c(!1),o.onSelect()}:void 0,toolActions:E?w?.map(e=>({...e,onSelect:()=>{c(!1),e.onSelect()}})):void 0},x??"__root__"):null;return n.jsxs(s.SideSection,{children:[n.jsxs(s.SideSectionHeader,{children:[n.jsx(S.TitleSmall,{color:d.COLORS.content.primary,children:i}),P&&n.jsxs(re,{ref:A,children:[n.jsx(s.AddIconButton,{"data-test":`${t}-add`,onClick:X,"aria-label":`Add ${i}`,children:n.jsx(H.default,{width:20,height:20,color:d.COLORS.content.brand})}),l&&h&&x===null&&n.jsx(W,{"data-test":`${t}-picker`,children:M})]})]}),L&&n.jsx(S.BodyCaption,{color:d.COLORS.content.secondary,children:L}),Q?n.jsxs(ce,{ref:l?D:void 0,children:[n.jsxs(s.SourceButtonRow,{"data-test":`${t}-sources`,children:[p?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-source-${e.source}`,onClick:()=>{if(l){I(e.source),c(!0);return}v(e.source)},children:[C.renderSourceIcon(C.SOURCE_ICONS[e.source],-4),n.jsx(S.BodySecondary,{color:d.COLORS.content.primary,children:e.label})]},e.source)),w?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-action-${e.source}`,onClick:e.onSelect,children:[C.renderSourceIcon(e.icon,-4),n.jsx(S.BodySecondary,{color:d.COLORS.content.primary,children:e.label})]},e.source))]}),l&&h&&x!==null&&n.jsx(W,{$align:"left","data-test":`${t}-picker`,children:M}),!l&&$&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Search ${$.label} tools`,options:$.options,onSelect:e=>{const r=N.unwrapDropdownValue(e);v(null),c(!1),r&&g(r)}})]}):n.jsxs(n.Fragment,{children:[!l&&h&&O.length>0&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Select ${i.toLowerCase()}`,options:O,onSelect:e=>{const r=N.unwrapDropdownValue(e);c(!1),r&&(r===V?o?.onSelect():g(r))}}),a.length===0&&!h?n.jsxs(n.Fragment,{children:[n.jsx(S.BodyCaption,{color:d.COLORS.content.placeholder,children:K}),J&&o&&n.jsx(ne.Button,{"data-test":`${t}-create`,buttonType:"secondary",size:"small",matchParentWidth:!0,LeadingIcon:H.default,buttonText:o.label,onClick:o.onSelect})]}):Y()]}),f&&q&&n.jsx(oe.DeleteConfirmationModal,{"data-test":`${t}-delete-confirm`,header:`Delete this ${f.noun}?`,subHeader:`Deleting this ${f.noun} will also remove it from your instructions, wherever it's referenced.`,confirmationText:"Delete",zIndex:f.zIndex,onDeleteConfirmed:()=>{m(q),b(null)},onCancelClicked:()=>b(null)})]})},re=k.default.div`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),Z=require("../../../assets/icons/delete.svg.js"),G=require("../../../assets/icons/edit.svg.js"),H=require("../../../assets/icons/plus.svg.js"),u=require("react"),T=require("styled-components"),S=require("../../TypographyStyle.js"),d=require("../../../constants/Theme.js"),s=require("../AgentBuilder.styled.js"),C=require("../utils/sourceIcons.js"),ee=require("./MentionPicker.js"),F=require("../../dropdown/Dropdown.js"),N=require("../../dropdown/utils.js"),ne=require("../../button/Button.js"),oe=require("../../states-modal/DeleteConfirmationModal.js"),te=i=>i&&typeof i=="object"&&"default"in i?i:{default:i},k=te(T),V="__bik_create_new__",le=({title:i,helper:L,items:a,addableOptions:y,onAdd:b,onRemove:m,dataTestPrefix:t,emptyText:K,createOption:o,onConfigure:_,sourceGroups:p,mentionItems:B,actionSources:w,confirmDelete:f})=>{const[h,c]=u.useState(!1),[q,g]=u.useState(null),[U,v]=u.useState(null),j=!!p&&p.length>0,$=p?.find(e=>e.source===U),l=B!==void 0,A=u.useRef(null),D=u.useRef(null),[x,I]=u.useState(null);u.useEffect(()=>{if(!l||!h)return;const e=R=>{const z=R.target;!A.current?.contains(z)&&!D.current?.contains(z)&&c(!1)},r=R=>{R.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",r)}},[l,h]);const P=j?l||a.length>0:l||y.length>0||!!o&&a.length>0,J=a.length===0&&!!o&&!j&&!l,E=!!w&&w.length>0,Q=(j||E)&&a.length===0,X=()=>{if(l){I(null),c(e=>!e);return}if(j){v(null),c(e=>!e);return}if(y.length===0&&o){o.onSelect();return}c(e=>!e)},Y=()=>a.map(e=>{const r=e.onConfigure??(_?()=>_(e.id):void 0);return n.jsxs(s.SelectableRow,{"data-test":`${t}-row-${e.id}`,children:[C.renderSourceIcon(e.icon),n.jsx(s.RowText,{children:n.jsx(S.BodySecondary,{numberOfLines:1,color:d.COLORS.content.primary,children:e.label})}),n.jsxs(s.RowActions,{children:[r&&n.jsx(s.RowMenuButton,{"data-test":`${t}-edit-${e.id}`,"aria-label":`Edit ${e.label}`,onClick:r,children:n.jsx(G.default,{width:16,height:16,color:d.COLORS.content.secondary})}),r&&n.jsx(s.RowActionDivider,{"aria-hidden":!0}),n.jsx(s.RowMenuButton,{"data-test":`${t}-delete-${e.id}`,"aria-label":`Delete ${e.label}`,onClick:()=>f?g(e.id):m(e.id),children:n.jsx(Z.default,{width:16,height:16,color:d.COLORS.content.secondary})})]})]},e.id)}),O=o?[...y,{label:o.label,value:V,searchKey:o.label,customComponent:n.jsx("div",{style:{width:"100%",textAlign:"center",color:d.COLORS.content.brand,fontFamily:"Inter",fontSize:14,fontWeight:600},children:o.label})}]:y,M=l?n.jsx(ee.MentionPicker,{items:B??[],query:"",activeIndex:0,initialSource:x??void 0,onSelect:e=>{c(!1),b(String(e.id))},onClose:()=>c(!1),onCreateSubAgent:o?()=>{c(!1),o.onSelect()}:void 0,toolActions:E?w?.map(e=>({...e,onSelect:()=>{c(!1),e.onSelect()}})):void 0},x??"__root__"):null;return n.jsxs(s.SideSection,{children:[n.jsxs(s.SideSectionHeader,{children:[n.jsx(S.TitleSmall,{color:d.COLORS.content.primary,children:i}),P&&n.jsxs(re,{ref:A,children:[n.jsx(s.AddIconButton,{"data-test":`${t}-add`,onClick:X,"aria-label":`Add ${i}`,children:n.jsx(H.default,{width:20,height:20,color:d.COLORS.content.brand})}),l&&h&&x===null&&n.jsx(W,{"data-test":`${t}-picker`,children:M})]})]}),L&&n.jsx(S.BodyCaption,{color:d.COLORS.content.secondary,children:L}),Q?n.jsxs(ce,{ref:l?D:void 0,children:[n.jsxs(s.SourceButtonRow,{"data-test":`${t}-sources`,children:[p?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-source-${e.source}`,onClick:()=>{if(e.connected===!1){e.onConnect?.();return}if(l){I(e.source),c(!0);return}v(e.source)},children:[C.renderSourceIcon(C.SOURCE_ICONS[e.source],-4),n.jsx(S.BodySecondary,{color:d.COLORS.content.primary,children:e.label})]},e.source)),w?.map(e=>n.jsxs(s.SourceButton,{type:"button","data-test":`${t}-action-${e.source}`,onClick:e.onSelect,children:[C.renderSourceIcon(e.icon,-4),n.jsx(S.BodySecondary,{color:d.COLORS.content.primary,children:e.label})]},e.source))]}),l&&h&&x!==null&&n.jsx(W,{$align:"left","data-test":`${t}-picker`,children:M}),!l&&$&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Search ${$.label} tools`,options:$.options,onSelect:e=>{const r=N.unwrapDropdownValue(e);v(null),c(!1),r&&b(r)}})]}):n.jsxs(n.Fragment,{children:[!l&&h&&O.length>0&&n.jsx(F.Dropdown,{"data-test":`${t}-dropdown`,size:"small",width:"100%",isSearchable:!0,placeHolder:`Select ${i.toLowerCase()}`,options:O,onSelect:e=>{const r=N.unwrapDropdownValue(e);c(!1),r&&(r===V?o?.onSelect():b(r))}}),a.length===0&&!h?n.jsxs(n.Fragment,{children:[n.jsx(S.BodyCaption,{color:d.COLORS.content.placeholder,children:K}),J&&o&&n.jsx(ne.Button,{"data-test":`${t}-create`,buttonType:"secondary",size:"small",matchParentWidth:!0,LeadingIcon:H.default,buttonText:o.label,onClick:o.onSelect})]}):Y()]}),f&&q&&n.jsx(oe.DeleteConfirmationModal,{"data-test":`${t}-delete-confirm`,header:`Delete this ${f.noun}?`,subHeader:`Deleting this ${f.noun} will also remove it from your instructions, wherever it's referenced.`,confirmationText:"Delete",zIndex:f.zIndex,onDeleteConfirmed:()=>{m(q),g(null)},onCancelClicked:()=>g(null)})]})},re=k.default.div`
2
2
  position: relative;
3
3
  display: flex;
4
4
  `,ce=k.default.div`
@@ -1 +1 @@
1
- {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\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) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":"iuBAyDMA,EAAsB,qBA0DfC,GAA8D,CAAC,CAC3E,MAAAC,EACA,OA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YAAW,GAAGtE,CAAc,UAC5B,WAAW,YACX,KAAK,QACL,iBAAgB,GAChB,YAAa2D,EAAAA,QACb,WAAYzD,EAAa,MACzB,QAASA,EAAa,QAAA,CAAA,CACvB,CAAA,CAEF,EAEAiC,EAAA,CAAe,EAEjB,EAEA5B,GAAiBI,GACjB8B,EAAAA,IAAC8B,GAAAA,wBAAA,CACA,YAAW,GAAGvE,CAAc,kBAC5B,OAAQ,eAAeO,EAAc,IAAI,IACzC,UAAW,iBAAiBA,EAAc,IAAI,yEAC9C,iBAAiB,SACjB,OAAQA,EAAc,OACtB,kBAAmB,IAAM,CACxBR,EAASY,CAAe,EACxBC,EAAmB,IAAI,CACxB,EACA,gBAAiB,IAAMA,EAAmB,IAAI,CAAA,CAAA,CAC/C,EAEF,CAEF,EAGM6C,GAAgBe,EAAAA,QAAO;AAAA;AAAA;AAAA,EAMvBV,GAAqBU,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5BZ,EAAgBY,EAAAA,QAAO;AAAA;AAAA;AAAA,GAGzBC,GAAOA,EAAE,SAAW,OAAS,WAAa,WAAY;AAAA;AAAA"}
1
+ {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\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) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":"iuBAiEMA,EAAsB,qBA0DfC,GAA8D,CAAC,CAC3E,MAAAC,EACA,OAAAC,EACA,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AAmB5B,GACnBuC,EAAAA,IAAC6B,GAAAA,OAAA,CACA,YAAW,GAAGtE,CAAc,UAC5B,WAAW,YACX,KAAK,QACL,iBAAgB,GAChB,YAAa2D,EAAAA,QACb,WAAYzD,EAAa,MACzB,QAASA,EAAa,QAAA,CAAA,CACvB,CAAA,CAEF,EAEAiC,EAAA,CAAe,EAEjB,EAEA5B,GAAiBI,GACjB8B,EAAAA,IAAC8B,GAAAA,wBAAA,CACA,YAAW,GAAGvE,CAAc,kBAC5B,OAAQ,eAAeO,EAAc,IAAI,IACzC,UAAW,iBAAiBA,EAAc,IAAI,yEAC9C,iBAAiB,SACjB,OAAQA,EAAc,OACtB,kBAAmB,IAAM,CACxBR,EAASY,CAAe,EACxBC,EAAmB,IAAI,CACxB,EACA,gBAAiB,IAAMA,EAAmB,IAAI,CAAA,CAAA,CAC/C,EAEF,CAEF,EAGM6C,GAAgBe,EAAAA,QAAO;AAAA;AAAA;AAAA,EAMvBV,GAAqBU,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5BZ,EAAgBY,EAAAA,QAAO;AAAA;AAAA;AAAA,GAGzBC,GAAOA,EAAE,SAAW,OAAS,WAAa,WAAY;AAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),G=require("../../TypographyStyle.js"),U=require("../../../constants/Theme.js"),m=require("../AgentBuilder.styled.js"),Se=require("../components/ConfigToolPanel.js"),me=require("../components/CreateSubAgentPanel.js"),W=require("../components/MentionField.js"),fe=require("../components/RestApiToolPanel.js"),z=require("../components/SelectableListSection.js"),Te=require("../components/StepSectionHeader.js"),ye=require("../constants/steps.js"),p=require("../constants/tools.js"),Ae=require("../context/AgentBuilderContext.js"),r=require("../utils/mentionSerialization.js"),A=require("../utils/sourceIcons.js"),he=require("../utils/toolActions.js"),Ce=require("../../dropdown/Dropdown.js"),Ie=require("../../dropdown/utils.js"),ve=t=>A.renderSourceIcon(A.sourceIcon(t))??void 0,$=t=>({label:t.display_name,value:t.tool_id,leadingIcon:ve(t.source??p.ToolSource.Manifest)}),V=ye.STEP_DEFINITIONS[2],J=(t,i)=>{const f=t??[];return f.some(u=>u.id===i.id)?f.map(u=>u.id===i.id?i:u):[...f,i]},xe=()=>{const{value:t,patch:i,updateField:f,addReference:u,removeReference:N,availableTools:T,availableSubAgents:Q,availableModels:k,configToolTemplates:R,applicationType:D,charLimits:y,insertMention:c,onCreateSubAgent:g,onFetchSubAgent:h,onUpdateSubAgent:O,onImproveSubAgent:X,onImproveToolInstructions:w,registerSubAgentCreator:j,registerToolActionHandler:q}=Ae.useAgentBuilderContext(),[d,C]=s.useState(null),I=s.useRef(0),[a,b]=s.useState(null),v=s.useRef(0),M=s.useCallback(e=>{v.current+=1,b({key:v.current,kind:"restapi",initialRest:e})},[]),E=s.useCallback((e,o)=>{v.current+=1,b({key:v.current,kind:"config",toolKey:e,initialConfig:o})},[]),Y=s.useCallback(e=>{const o=!(t.restApiTools??[]).some(l=>l.id===e.id);i({restApiTools:J(t.restApiTools,e)}),o&&c("tool",e.id,r.restApiMentionItem(e).label),b(null)},[i,t.restApiTools,c]),Z=s.useCallback(e=>{const o=!(t.configTools??[]).some(l=>l.id===e.id);i({configTools:J(t.configTools,e)}),o&&c("tool",e.id,r.configToolMentionItem(e).label),b(null)},[i,t.configTools,c]),L=s.useCallback(e=>{const o=p.CONFIG_TOOL_SOURCES[e];o?E(o):M()},[E,M]);s.useEffect(()=>(q(L),()=>q(null)),[q,L]);const[ee,K]=s.useState([]),x=new Map;Q.forEach(e=>x.set(e.id,e)),ee.forEach(e=>x.set(e.id,e));const H=Array.from(x.values()),_=s.useCallback(()=>{I.current+=1,C({key:I.current,title:"Create sub-agent"})},[]);s.useEffect(()=>{if(g)return j(_),()=>j(null)},[j,_,g]);const oe=s.useCallback(async e=>{if(!h)return;const o=await h(e);I.current+=1,C({key:I.current,title:"Edit sub-agent",editingId:e,initial:o})},[h]),te=s.useCallback(async e=>{if(d?.editingId){if(O){const o=await O(d.editingId,e);K(l=>[...l.filter(S=>S.id!==o.id),o])}}else if(g){const o=await g(e);K(l=>[...l,o]),i({subagents:[...t.subagents,o.id]}),c("subagent",o.id,`sub-agent: ${o.name}`)}C(null)},[d,O,g,i,t.subagents,c]),ne=t.tools.map(e=>{const o=T.find(l=>l.tool_id===e);return o?{id:e,label:o.display_name,icon:A.sourceIcon(o.source??p.ToolSource.Manifest)}:null}).filter(e=>e!==null),le=(t.restApiTools??[]).map(e=>({id:e.id,label:r.restApiToolName(e),icon:A.SOURCE_ICONS[p.ToolSource.RestApi],onConfigure:()=>M(e)})),se=(t.configTools??[]).map(e=>({id:e.id,label:r.configToolName(e),icon:A.SOURCE_ICONS[e.tool_key==="send_slack_message"?p.ToolSource.Slack:p.ToolSource.EmailHandover],onConfigure:()=>E(e.tool_key,e)})),ie=[...ne,...le,...se],ae=he.buildToolActions(R,L),re=T.map($),ce=(()=>{const e=[],o=new Map;return T.forEach(l=>{const S=l.source??p.ToolSource.Manifest;o.has(S)||(o.set(S,[]),e.push(S)),o.get(S)?.push($(l))}),e.map(l=>({source:l,label:r.toolSourceLabel(l),options:o.get(l)??[]}))})(),ue=t.subagents.map(e=>{const o=x.get(e);return o?{id:e,label:o.name}:null}).filter(e=>e!==null),de=H.map(e=>({label:e.name,value:e.id})),B=r.appTypeLabel(D),pe=[...r.buildAgentMentionItems(T,[],B),...r.buildCustomToolMentionItems(t.configTools,t.restApiTools)],ge=r.buildAgentMentionItems([],H,B),be=k.map(e=>({label:e.label,value:e.value,selected:e.value===t.model})),P=k.find(e=>e.value===t.model),F=a?.kind==="config"&&a.toolKey?R?.[a.toolKey]:void 0;return n.jsxs(m.Step3Root,{children:[n.jsx(Te.StepSectionHeader,{title:V.title,helper:V.helper}),n.jsxs(m.Step3Grid,{$grow:!0,children:[n.jsxs(m.SectionBodyWrap,{children:[n.jsx(W.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:y.instructions,placeholder:"Write what this agent should do. Type @ to reference a tool or sub-agent.",minHeight:"200px"}),n.jsx(W.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:y.guardrail,placeholder:"Things this agent must never do. Type @ to reference a tool or sub-agent.",minHeight:"140px"})]}),n.jsx(m.Step3Divider,{}),n.jsxs(m.SectionBodyWrap,{children:[n.jsx(z.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:ie,addableOptions:re,sourceGroups:ce,mentionItems:pe,actionSources:ae,emptyText:"No tools added yet.",onAdd:e=>{c("tool",e),u("tool",e)},onRemove:e=>N("tool",e),confirmDelete:{noun:"tool"}}),n.jsx(z.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:ue,addableOptions:de,mentionItems:ge,emptyText:"No sub-agents added yet.",onAdd:e=>{c("subagent",e),u("subagent",e)},onRemove:e=>N("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:h?oe:void 0,createOption:g?{label:"Create new",onSelect:_}:void 0}),k.length>0&&n.jsxs(m.SideSection,{children:[n.jsx(G.TitleSmall,{color:U.COLORS.content.primary,children:"Advanced settings"}),n.jsx(G.TitleSmall,{color:U.COLORS.content.secondary,children:"Select AI model"}),n.jsx(Ce.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",placeHolder:"Select model",options:be,defaultOptions:P?[{label:P.label,value:P.value}]:void 0,onSelect:e=>{const o=Ie.unwrapDropdownValue(e);o&&f("model",o)}})]})]})]}),d&&n.jsx(me.CreateSubAgentPanel,{title:d.title,initial:d.initial,availableTools:T,configToolTemplates:R,appLabel:r.appTypeLabel(D),charLimits:y,onImprove:X,onImproveToolInstructions:w,onClose:()=>C(null),onSave:te},d.key),a?.kind==="restapi"&&n.jsx(fe.RestApiToolPanel,{initial:a.initialRest,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:Y},a.key),a?.kind==="config"&&a.toolKey&&F&&n.jsx(Se.ConfigToolPanel,{toolKey:a.toolKey,template:F,initial:a.initialConfig,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:Z},a.key)]})};exports.Step3HowItResponds=xe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),s=require("react"),W=require("../../TypographyStyle.js"),z=require("../../../constants/Theme.js"),m=require("../AgentBuilder.styled.js"),fe=require("../components/ConfigToolPanel.js"),Te=require("../components/CreateSubAgentPanel.js"),$=require("../components/MentionField.js"),ye=require("../components/RestApiToolPanel.js"),V=require("../components/SelectableListSection.js"),Ae=require("../components/StepSectionHeader.js"),he=require("../constants/steps.js"),p=require("../constants/tools.js"),Ce=require("../context/AgentBuilderContext.js"),r=require("../utils/mentionSerialization.js"),A=require("../utils/sourceIcons.js"),Ie=require("../utils/toolActions.js"),ve=require("../../dropdown/Dropdown.js"),xe=require("../../dropdown/utils.js"),ke=t=>A.renderSourceIcon(A.sourceIcon(t))??void 0,J=t=>({label:t.display_name,value:t.tool_id,leadingIcon:ke(t.source??p.ToolSource.Manifest)}),Q=he.STEP_DEFINITIONS[2],X=(t,i)=>{const f=t??[];return f.some(u=>u.id===i.id)?f.map(u=>u.id===i.id?i:u):[...f,i]},Re=()=>{const{value:t,patch:i,updateField:f,addReference:u,removeReference:N,availableTools:T,availableSubAgents:Y,availableModels:k,configToolTemplates:R,applicationType:D,charLimits:y,insertMention:c,onCreateSubAgent:g,onFetchSubAgent:h,onUpdateSubAgent:O,onImproveSubAgent:Z,onImproveToolInstructions:w,registerSubAgentCreator:j,registerToolActionHandler:q,integrationStatus:K,onConnectIntegration:H}=Ce.useAgentBuilderContext(),[d,C]=s.useState(null),I=s.useRef(0),[a,b]=s.useState(null),v=s.useRef(0),M=s.useCallback(e=>{v.current+=1,b({key:v.current,kind:"restapi",initialRest:e})},[]),E=s.useCallback((e,o)=>{v.current+=1,b({key:v.current,kind:"config",toolKey:e,initialConfig:o})},[]),ee=s.useCallback(e=>{const o=!(t.restApiTools??[]).some(n=>n.id===e.id);i({restApiTools:X(t.restApiTools,e)}),o&&c("tool",e.id,r.restApiMentionItem(e).label),b(null)},[i,t.restApiTools,c]),oe=s.useCallback(e=>{const o=!(t.configTools??[]).some(n=>n.id===e.id);i({configTools:X(t.configTools,e)}),o&&c("tool",e.id,r.configToolMentionItem(e).label),b(null)},[i,t.configTools,c]),L=s.useCallback(e=>{const o=p.CONFIG_TOOL_SOURCES[e];o?E(o):M()},[E,M]);s.useEffect(()=>(q(L),()=>q(null)),[q,L]);const[te,B]=s.useState([]),x=new Map;Y.forEach(e=>x.set(e.id,e)),te.forEach(e=>x.set(e.id,e));const F=Array.from(x.values()),_=s.useCallback(()=>{I.current+=1,C({key:I.current,title:"Create sub-agent"})},[]);s.useEffect(()=>{if(g)return j(_),()=>j(null)},[j,_,g]);const ne=s.useCallback(async e=>{if(!h)return;const o=await h(e);I.current+=1,C({key:I.current,title:"Edit sub-agent",editingId:e,initial:o})},[h]),le=s.useCallback(async e=>{if(d?.editingId){if(O){const o=await O(d.editingId,e);B(n=>[...n.filter(S=>S.id!==o.id),o])}}else if(g){const o=await g(e);B(n=>[...n,o]),i({subagents:[...t.subagents,o.id]}),c("subagent",o.id,`sub-agent: ${o.name}`)}C(null)},[d,O,g,i,t.subagents,c]),se=t.tools.map(e=>{const o=T.find(n=>n.tool_id===e);return o?{id:e,label:o.display_name,icon:A.sourceIcon(o.source??p.ToolSource.Manifest)}:null}).filter(e=>e!==null),ie=(t.restApiTools??[]).map(e=>({id:e.id,label:r.restApiToolName(e),icon:A.SOURCE_ICONS[p.ToolSource.RestApi],onConfigure:()=>M(e)})),ae=(t.configTools??[]).map(e=>({id:e.id,label:r.configToolName(e),icon:A.SOURCE_ICONS[e.tool_key==="send_slack_message"?p.ToolSource.Slack:p.ToolSource.EmailHandover],onConfigure:()=>E(e.tool_key,e)})),re=[...se,...ie,...ae],ce=Ie.buildToolActions(R,L,K,H),ue=T.map(J),de=(()=>{const e=[],o=new Map;return T.forEach(n=>{const S=n.source??p.ToolSource.Manifest;o.has(S)||(o.set(S,[]),e.push(S)),o.get(S)?.push(J(n))}),e.map(n=>({source:n,label:r.toolSourceLabel(n),options:o.get(n)??[],connected:K?.[n],onConnect:()=>H?.(n)}))})(),pe=t.subagents.map(e=>{const o=x.get(e);return o?{id:e,label:o.name}:null}).filter(e=>e!==null),ge=F.map(e=>({label:e.name,value:e.id})),G=r.appTypeLabel(D),be=[...r.buildAgentMentionItems(T,[],G),...r.buildCustomToolMentionItems(t.configTools,t.restApiTools)],Se=r.buildAgentMentionItems([],F,G),me=k.map(e=>({label:e.label,value:e.value,selected:e.value===t.model})),P=k.find(e=>e.value===t.model),U=a?.kind==="config"&&a.toolKey?R?.[a.toolKey]:void 0;return l.jsxs(m.Step3Root,{children:[l.jsx(Ae.StepSectionHeader,{title:Q.title,helper:Q.helper}),l.jsxs(m.Step3Grid,{$grow:!0,children:[l.jsxs(m.SectionBodyWrap,{children:[l.jsx($.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:y.instructions,placeholder:"Write what this agent should do. Type @ to reference a tool or sub-agent.",minHeight:"200px"}),l.jsx($.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:y.guardrail,placeholder:"Things this agent must never do. Type @ to reference a tool or sub-agent.",minHeight:"140px"})]}),l.jsx(m.Step3Divider,{}),l.jsxs(m.SectionBodyWrap,{children:[l.jsx(V.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:re,addableOptions:ue,sourceGroups:de,mentionItems:be,actionSources:ce,emptyText:"No tools added yet.",onAdd:e=>{c("tool",e),u("tool",e)},onRemove:e=>N("tool",e),confirmDelete:{noun:"tool"}}),l.jsx(V.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:pe,addableOptions:ge,mentionItems:Se,emptyText:"No sub-agents added yet.",onAdd:e=>{c("subagent",e),u("subagent",e)},onRemove:e=>N("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:h?ne:void 0,createOption:g?{label:"Create new",onSelect:_}:void 0}),k.length>0&&l.jsxs(m.SideSection,{children:[l.jsx(W.TitleSmall,{color:z.COLORS.content.primary,children:"Advanced settings"}),l.jsx(W.TitleSmall,{color:z.COLORS.content.secondary,children:"Select AI model"}),l.jsx(ve.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",placeHolder:"Select model",options:me,defaultOptions:P?[{label:P.label,value:P.value}]:void 0,onSelect:e=>{const o=xe.unwrapDropdownValue(e);o&&f("model",o)}})]})]})]}),d&&l.jsx(Te.CreateSubAgentPanel,{title:d.title,initial:d.initial,availableTools:T,configToolTemplates:R,appLabel:r.appTypeLabel(D),charLimits:y,onImprove:Z,onImproveToolInstructions:w,onClose:()=>C(null),onSave:le},d.key),a?.kind==="restapi"&&l.jsx(ye.RestApiToolPanel,{initial:a.initialRest,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:ee},a.key),a?.kind==="config"&&a.toolKey&&U&&l.jsx(fe.ConfigToolPanel,{toolKey:a.toolKey,template:U,initial:a.initialConfig,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:oe},a.key)]})};exports.Step3HowItResponds=Re;
2
2
  //# sourceMappingURL=Step3HowItResponds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write what this agent should do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"Things this agent must never do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', 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</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":"+1BAmDMA,GAAcC,GACnBC,EAAAA,iBAAiBC,EAAAA,WAAWF,CAAM,CAAC,GAAK,OAGnCG,EAAc,IAAgC,CACnD,MAAO,EAAE,aACT,MAAO,EAAE,QACT,YAAaJ,GAAW,EAAE,QAAUK,EAAAA,WAAW,QAAQ,CACxD,GAEMC,EAAOC,GAAAA,iBAAiB,CAAC,EAwBzBC,EAAa,CAClBC,EACAC,IACS,CACT,MAAMC,EAAMF,GAAQ,CAAA,EACpB,OAAOE,EAAI,KAAMC,GAAMA,EAAE,KAAOF,EAAK,EAAE,EACpCC,EAAI,IAAKC,GAAOA,EAAE,KAAOF,EAAK,GAAKA,EAAOE,CAAE,EAC5C,CAAC,GAAGD,EAAKD,CAAI,CACjB,EAEaG,GAA+B,IAAM,CACjD,KAAM,CACL,MAAAC,EACA,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA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H,CAEF"}
1
+ {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t\t// Not connected → the source button opens the connect flow instead of\n\t\t\t// its tool list (see SelectableListSection / onConnectIntegration).\n\t\t\tconnected: integrationStatus?.[src as ToolSource],\n\t\t\tonConnect: () => onConnectIntegration?.(src as ToolSource),\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write what this agent should do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"Things this agent must never do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', 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</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","integrationStatus","onConnectIntegration","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":"+1BAmDMA,GAAcC,GACnBC,EAAAA,iBAAiBC,EAAAA,WAAWF,CAAM,CAAC,GAAK,OAGnCG,EAAc,IAAgC,CACnD,MAAO,EAAE,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AAA,CAAA,CACD,CAAA,CACD,CAAA,CAAA,CAEF,CAAA,EACD,EAEC/E,GACAkE,EAAAA,IAACe,GAAAA,oBAAA,CAEA,MAAOjF,EAAM,MACb,QAASA,EAAM,QACf,eAAAjB,EACA,oBAAAG,EACA,SAAUsE,EAAAA,aAAarE,CAAe,EACtC,WAAAC,EACA,UAAWK,EACX,0BAAAC,EACA,QAAS,IAAMO,EAAS,IAAI,EAC5B,OAAQ+B,EAAA,EAVHhC,EAAM,GAAA,EAcZK,GAAY,OAAS,WACrB6D,EAAAA,IAACgB,GAAAA,iBAAA,CAEA,QAAS7E,EAAW,YACpB,WAAAjB,EACA,UAAWM,EACX,QAAS,IAAMY,EAAc,IAAI,EACjC,OAAQO,EAAA,EALHR,EAAW,GAAA,EASjBA,GAAY,OAAS,UACrBA,EAAW,SACX2D,GACCE,EAAAA,IAACiB,GAAAA,gBAAA,CAEA,QAAS9E,EAAW,QACpB,SAAU2D,EACV,QAAS3D,EAAW,cACpB,WAAAjB,EACA,UAAWM,EACX,QAAS,IAAMY,EAAc,IAAI,EACjC,OAAQY,EAAA,EAPHb,EAAW,GAAA,CAQjB,EAEH,CAEF"}
@@ -20,6 +20,14 @@ export interface SourceGroup {
20
20
  source: string;
21
21
  label: string;
22
22
  options: SingleOption[];
23
+ /**
24
+ * Integration connection state for this source. `false` = the store hasn't
25
+ * connected it → clicking the source button calls {@link onConnect} instead of
26
+ * opening its tool list. `true`/absent → opens normally.
27
+ */
28
+ connected?: boolean;
29
+ /** Open the connect flow for this source (used when `connected === false`). */
30
+ onConnect?: () => void;
23
31
  }
24
32
  interface SelectableListSectionProps {
25
33
  title: string;
@@ -18,7 +18,7 @@ const Q = "__bik_create_new__", He = ({
18
18
  helper: _,
19
19
  items: s,
20
20
  addableOptions: f,
21
- onAdd: g,
21
+ onAdd: $,
22
22
  onRemove: R,
23
23
  dataTestPrefix: t,
24
24
  emptyText: Y,
@@ -29,7 +29,7 @@ const Q = "__bik_create_new__", He = ({
29
29
  actionSources: m,
30
30
  confirmDelete: h
31
31
  }) => {
32
- const [a, c] = v(!1), [I, $] = v(null), [Z, y] = v(null), S = !!p && p.length > 0, b = p?.find((e) => e.source === Z), l = B !== void 0, L = K(null), z = K(null), [w, x] = v(null);
32
+ const [a, c] = v(!1), [I, g] = v(null), [Z, y] = v(null), S = !!p && p.length > 0, b = p?.find((e) => e.source === Z), l = B !== void 0, L = K(null), z = K(null), [w, x] = v(null);
33
33
  le(() => {
34
34
  if (!l || !a)
35
35
  return;
@@ -91,7 +91,7 @@ const Q = "__bik_create_new__", He = ({
91
91
  {
92
92
  "data-test": `${t}-delete-${e.id}`,
93
93
  "aria-label": `Delete ${e.label}`,
94
- onClick: () => h ? $(e.id) : R(e.id),
94
+ onClick: () => h ? g(e.id) : R(e.id),
95
95
  children: /* @__PURE__ */ o(
96
96
  ne,
97
97
  {
@@ -136,7 +136,7 @@ const Q = "__bik_create_new__", He = ({
136
136
  activeIndex: 0,
137
137
  initialSource: w ?? void 0,
138
138
  onSelect: (e) => {
139
- c(!1), g(String(e.id));
139
+ c(!1), $(String(e.id));
140
140
  },
141
141
  onClose: () => c(!1),
142
142
  onCreateSubAgent: n ? () => {
@@ -168,7 +168,7 @@ const Q = "__bik_create_new__", He = ({
168
168
  ] })
169
169
  ] }),
170
170
  _ && /* @__PURE__ */ o(U, { color: d.content.secondary, children: _ }),
171
- O ? /* @__PURE__ */ i(ge, { ref: l ? z : void 0, children: [
171
+ O ? /* @__PURE__ */ i($e, { ref: l ? z : void 0, children: [
172
172
  /* @__PURE__ */ i(se, { "data-test": `${t}-sources`, children: [
173
173
  p?.map((e) => /* @__PURE__ */ i(
174
174
  V,
@@ -176,6 +176,10 @@ const Q = "__bik_create_new__", He = ({
176
176
  type: "button",
177
177
  "data-test": `${t}-source-${e.source}`,
178
178
  onClick: () => {
179
+ if (e.connected === !1) {
180
+ e.onConnect?.();
181
+ return;
182
+ }
179
183
  if (l) {
180
184
  x(e.source), c(!0);
181
185
  return;
@@ -215,7 +219,7 @@ const Q = "__bik_create_new__", He = ({
215
219
  options: b.options,
216
220
  onSelect: (e) => {
217
221
  const r = P(e);
218
- y(null), c(!1), r && g(r);
222
+ y(null), c(!1), r && $(r);
219
223
  }
220
224
  }
221
225
  )
@@ -231,7 +235,7 @@ const Q = "__bik_create_new__", He = ({
231
235
  options: M,
232
236
  onSelect: (e) => {
233
237
  const r = P(e);
234
- c(!1), r && (r === Q ? n?.onSelect() : g(r));
238
+ c(!1), r && (r === Q ? n?.onSelect() : $(r));
235
239
  }
236
240
  }
237
241
  ),
@@ -260,16 +264,16 @@ const Q = "__bik_create_new__", He = ({
260
264
  confirmationText: "Delete",
261
265
  zIndex: h.zIndex,
262
266
  onDeleteConfirmed: () => {
263
- R(I), $(null);
267
+ R(I), g(null);
264
268
  },
265
- onCancelClicked: () => $(null)
269
+ onCancelClicked: () => g(null)
266
270
  }
267
271
  )
268
272
  ] });
269
273
  }, ve = E.div`
270
274
  position: relative;
271
275
  display: flex;
272
- `, ge = E.div`
276
+ `, $e = E.div`
273
277
  position: relative;
274
278
  display: flex;
275
279
  flex-direction: column;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\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) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":";;;;;;;;;;;;;;;AAyDA,MAAMA,IAAsB,sBA0DfC,KAA8D,CAAC;AAAA,EAC3E,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACD,MAAM;AACL,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpC,CAACC,GAAiBC,CAAkB,IAAIF,EAAwB,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,QACA,iBAAiB,MAAMA,EAAmB,IAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAC/C,GAEF;AAEF,GAGM6C,KAAgBe,EAAO;AAAA;AAAA;AAAA,GAMvBV,KAAqBU,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA,GAS5BZ,IAAgBY,EAAO;AAAA;AAAA;AAAA,GAG1B,CAACC,MAAOA,EAAE,WAAW,SAAS,aAAa,WAAY;AAAA;AAAA;"}
1
+ {"version":3,"file":"SelectableListSection.js","sources":["../../../../../src/components/agent-builder/components/SelectableListSection.tsx"],"sourcesContent":["import DeleteIcon from '@src/assets/icons/delete.svg';\nimport EditIcon from '@src/assets/icons/edit.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport { MentionItem } from '@src/editor';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { DeleteConfirmationModal } from '@src/components/states-modal';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAddIconButton,\n\tRowActionDivider,\n\tRowActions,\n\tRowMenuButton,\n\tRowText,\n\tSelectableRow,\n\tSideSection,\n\tSideSectionHeader,\n\tSourceButton,\n\tSourceButtonRow,\n} from '../AgentBuilder.styled';\nimport { ToolAction } from '../constants/tools';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tSourceIcon,\n} from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\nexport interface SelectableItem {\n\tid: string;\n\tlabel: string;\n\t/** Leading brand glyph (e.g. a tool's source icon). */\n\ticon?: SourceIcon;\n\t/**\n\t * When set, this row shows an edit (Configure) icon that calls this instead of\n\t * the section-level `onConfigure`. Use for rows that open their own drawer\n\t * (e.g. a configured Rest API / email-handover tool).\n\t */\n\tonConfigure?: () => void;\n}\n\n/** A tool source for the empty-state picker (Tools): a button → its searchable list. */\nexport interface SourceGroup {\n\tsource: string;\n\tlabel: string;\n\toptions: SingleOption[];\n\t/**\n\t * Integration connection state for this source. `false` = the store hasn't\n\t * connected it → clicking the source button calls {@link onConnect} instead of\n\t * opening its tool list. `true`/absent → opens normally.\n\t */\n\tconnected?: boolean;\n\t/** Open the connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sentinel value for the \"create new\" entry in the add dropdown. */\nconst CREATE_OPTION_VALUE = '__bik_create_new__';\n\ninterface SelectableListSectionProps {\n\ttitle: string;\n\thelper?: string;\n\titems: SelectableItem[];\n\t/**\n\t * Options shown in the add dropdown. Pass ALL items (not just unselected\n\t * ones) when re-picking an already-added item is allowed (e.g. to insert its\n\t * mention again) — the chip list still shows each item only once.\n\t */\n\taddableOptions: SingleOption[];\n\tonAdd: (id: string) => void;\n\tonRemove: (id: string) => void;\n\tdataTestPrefix: string;\n\temptyText: string;\n\t/**\n\t * Adds a \"create new\" entry at the top of the add dropdown (e.g. \"Create\n\t * sub-agent\"). Selecting it calls `onSelect` instead of `onAdd`.\n\t */\n\tcreateOption?: { label: string; onSelect: () => void };\n\t/**\n\t * When provided, each row shows an edit (Configure) icon next to Delete.\n\t * Omit for tools (Delete only).\n\t */\n\tonConfigure?: (id: string) => void;\n\t/**\n\t * Tool sources (e.g. Manifest / Shopify). When set, the empty state shows a\n\t * button per source; clicking one reveals a searchable dropdown of just that\n\t * source's options. Selecting calls `onAdd`. Takes precedence over the plain\n\t * `addableOptions` dropdown.\n\t */\n\tsourceGroups?: SourceGroup[];\n\t/**\n\t * When provided, the header \"+\" opens the same `@` reference picker used in the\n\t * Instructions editor (a {@link MentionPicker} popover) instead of the inline\n\t * select dropdown. Pass the items for THIS section only (tools OR sub-agents) —\n\t * the picker auto-drills into the single category. Selecting a row calls\n\t * `onAdd(id)`; the picker's \"Create new\" row (sub-agents) calls\n\t * `createOption.onSelect`.\n\t */\n\tmentionItems?: MentionItem[];\n\t/**\n\t * Built-in \"action\" tools (e.g. Rest API / Handover to email) that open a\n\t * config drawer via `onSelect` instead of adding a mention. Shown as\n\t * empty-state source buttons (only while no items exist, alongside\n\t * `sourceGroups`) AND as rows inside the `@` picker's Tools view.\n\t */\n\tactionSources?: ToolAction[];\n\t/**\n\t * When set, the row Delete icon opens a confirmation modal (instead of\n\t * removing immediately); `onRemove` runs only on confirm. `noun` fills the one\n\t * shared message template (\"Delete this <noun>?\" …); `zIndex` raises the modal\n\t * above a parent drawer. Omit to delete directly.\n\t */\n\tconfirmDelete?: { noun: string; zIndex?: number };\n}\n\nexport const SelectableListSection: React.FC<SelectableListSectionProps> = ({\n\ttitle,\n\thelper,\n\titems,\n\taddableOptions,\n\tonAdd,\n\tonRemove,\n\tdataTestPrefix,\n\temptyText,\n\tcreateOption,\n\tonConfigure,\n\tsourceGroups,\n\tmentionItems,\n\tactionSources,\n\tconfirmDelete,\n}) => {\n\tconst [adding, setAdding] = useState(false);\n\t// Row id awaiting delete confirmation (null = modal closed).\n\tconst [pendingDeleteId, setPendingDeleteId] = useState<string | null>(null);\n\t// Tools: which source's searchable list is open (null = just show the buttons).\n\tconst [activeSource, setActiveSource] = useState<string | null>(null);\n\tconst hasSourceGroups = !!sourceGroups && sourceGroups.length > 0;\n\tconst activeGroup = sourceGroups?.find((g) => g.source === activeSource);\n\t// When set, \"+\" opens the `@` MentionPicker popover instead of a select input.\n\tconst usePicker = mentionItems !== undefined;\n\t// Separate anchors for the header \"+\" popover and the empty-state source-button\n\t// popover — when empty both render at once, so a shared ref would misfire the\n\t// outside-click check (closing the header picker when a source row is clicked).\n\tconst headerPickerRef = useRef<HTMLDivElement>(null);\n\tconst sourcePickerRef = useRef<HTMLDivElement>(null);\n\t// Source (Shopify / Manifest) the empty-state button opened the picker into;\n\t// null when \"+\" opened it at the root source list.\n\tconst [pickerSource, setPickerSource] = useState<string | null>(null);\n\n\t// Dismiss the picker popover on outside click / Escape.\n\tuseEffect(() => {\n\t\tif (!usePicker || !adding) {\n\t\t\treturn;\n\t\t}\n\t\tconst onDocMouseDown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (\n\t\t\t\t!headerPickerRef.current?.contains(target) &&\n\t\t\t\t!sourcePickerRef.current?.contains(target)\n\t\t\t) {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tconst onKeyDown = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsetAdding(false);\n\t\t\t}\n\t\t};\n\t\tdocument.addEventListener('mousedown', onDocMouseDown);\n\t\tdocument.addEventListener('keydown', onKeyDown);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('mousedown', onDocMouseDown);\n\t\t\tdocument.removeEventListener('keydown', onKeyDown);\n\t\t};\n\t}, [usePicker, adding]);\n\n\t// Header \"+\" picks an EXISTING item (and, once some exist, re-creates via the\n\t// dropdown's footer row). With an empty list + a createOption the body shows a\n\t// dedicated \"Create new\" button instead, so the header \"+\" would be redundant.\n\t// In picker mode the \"+\" always shows (even empty) — for tools it sits next to\n\t// the empty-state source buttons; the create flow lives inside the picker.\n\tconst showAddButton = hasSourceGroups\n\t\t? usePicker || items.length > 0\n\t\t: usePicker ||\n\t\t addableOptions.length > 0 ||\n\t\t (!!createOption && items.length > 0);\n\t// Empty state offers a one-click \"Create new\" (sub-agents) rather than burying\n\t// it behind a single-item dropdown. In picker mode the \"+\" opens the picker\n\t// (with its own \"Create new\" row) instead, so skip the standalone button.\n\tconst showEmptyCreate =\n\t\titems.length === 0 && !!createOption && !hasSourceGroups && !usePicker;\n\tconst hasActionSources = !!actionSources && actionSources.length > 0;\n\t// Source buttons ONLY while no item is added — the tool sources (Manifest /\n\t// Shopify …) plus the built-in action tools (Rest API / Handover to email).\n\t// Once an item exists, adding more uses the header \"+\" → picker (the buttons\n\t// never come back); the action tools still live inside that picker.\n\tconst showSourceButtons =\n\t\t(hasSourceGroups || hasActionSources) && items.length === 0;\n\t// Nothing existing to pick → skip the 1-item dropdown and create directly.\n\tconst handleAddClick = () => {\n\t\tif (usePicker) {\n\t\t\t// Toggle the `@` reference-picker popover (rendered under the \"+\"), opened\n\t\t\t// at the root source list (no pre-drilled source).\n\t\t\tsetPickerSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (hasSourceGroups) {\n\t\t\tsetActiveSource(null);\n\t\t\tsetAdding((v) => !v);\n\t\t\treturn;\n\t\t}\n\t\tif (addableOptions.length === 0 && createOption) {\n\t\t\tcreateOption.onSelect();\n\t\t\treturn;\n\t\t}\n\t\tsetAdding((v) => !v);\n\t};\n\n\tconst renderChipRows = () =>\n\t\titems.map((item) => {\n\t\t\t// Per-item configure wins; otherwise fall back to the section-level one.\n\t\t\tconst configure =\n\t\t\t\titem.onConfigure ??\n\t\t\t\t(onConfigure ? () => onConfigure(item.id) : undefined);\n\t\t\treturn (\n\t\t\t\t<SelectableRow\n\t\t\t\t\tkey={item.id}\n\t\t\t\t\tdata-test={`${dataTestPrefix}-row-${item.id}`}\n\t\t\t\t>\n\t\t\t\t\t{renderSourceIcon(item.icon)}\n\t\t\t\t\t<RowText>\n\t\t\t\t\t\t<BodySecondary numberOfLines={1} color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{item.label}\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</RowText>\n\t\t\t\t\t<RowActions>\n\t\t\t\t\t\t{configure && (\n\t\t\t\t\t\t\t// Configurable rows (sub-agents, Rest API / email tools) get an\n\t\t\t\t\t\t\t// always-visible edit icon.\n\t\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-edit-${item.id}`}\n\t\t\t\t\t\t\t\taria-label={`Edit ${item.label}`}\n\t\t\t\t\t\t\t\tonClick={configure}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditIcon\n\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{configure && <RowActionDivider aria-hidden />}\n\t\t\t\t\t\t<RowMenuButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-${item.id}`}\n\t\t\t\t\t\t\taria-label={`Delete ${item.label}`}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tconfirmDelete ? setPendingDeleteId(item.id) : onRemove(item.id)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<DeleteIcon\n\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RowMenuButton>\n\t\t\t\t\t</RowActions>\n\t\t\t\t</SelectableRow>\n\t\t\t);\n\t\t});\n\t// \"Create new\" is a brand-coloured footer row at the BOTTOM of the dropdown,\n\t// separated from the selectable items by a divider.\n\tconst dropdownOptions: SingleOption[] = createOption\n\t\t? [\n\t\t\t\t...addableOptions,\n\t\t\t\t{\n\t\t\t\t\tlabel: createOption.label,\n\t\t\t\t\tvalue: CREATE_OPTION_VALUE,\n\t\t\t\t\tsearchKey: createOption.label,\n\t\t\t\t\tcustomComponent: (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\ttextAlign: 'center',\n\t\t\t\t\t\t\t\tcolor: COLORS.content.brand,\n\t\t\t\t\t\t\t\tfontFamily: 'Inter',\n\t\t\t\t\t\t\t\tfontSize: 14,\n\t\t\t\t\t\t\t\tfontWeight: 600,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{createOption.label}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t ]\n\t\t: addableOptions;\n\n\t// One picker instance reused by the header \"+\" and the empty-state source\n\t// buttons. `key` remounts it so a source button re-drills into its own tools\n\t// (the initial drill-in level is read once, on mount).\n\tconst pickerNode = usePicker ? (\n\t\t<MentionPicker\n\t\t\tkey={pickerSource ?? '__root__'}\n\t\t\titems={mentionItems ?? []}\n\t\t\tquery=\"\"\n\t\t\tactiveIndex={0}\n\t\t\tinitialSource={pickerSource ?? undefined}\n\t\t\tonSelect={(item) => {\n\t\t\t\tsetAdding(false);\n\t\t\t\tonAdd(String(item.id));\n\t\t\t}}\n\t\t\tonClose={() => setAdding(false)}\n\t\t\tonCreateSubAgent={\n\t\t\t\tcreateOption\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\tcreateOption.onSelect();\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\ttoolActions={\n\t\t\t\thasActionSources\n\t\t\t\t\t? actionSources?.map((a) => ({\n\t\t\t\t\t\t\t...a,\n\t\t\t\t\t\t\tonSelect: () => {\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\ta.onSelect();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }))\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t) : null;\n\n\treturn (\n\t\t<SideSection>\n\t\t\t<SideSectionHeader>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{title}</TitleSmall>\n\t\t\t\t{showAddButton && (\n\t\t\t\t\t<AddButtonWrap ref={headerPickerRef}>\n\t\t\t\t\t\t<AddIconButton\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-add`}\n\t\t\t\t\t\t\tonClick={handleAddClick}\n\t\t\t\t\t\t\taria-label={`Add ${title}`}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<PlusIcon width={20} height={20} color={COLORS.content.brand} />\n\t\t\t\t\t\t</AddIconButton>\n\t\t\t\t\t\t{usePicker && adding && pickerSource === null && (\n\t\t\t\t\t\t\t<PickerPopover data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</AddButtonWrap>\n\t\t\t\t)}\n\t\t\t</SideSectionHeader>\n\n\t\t\t{helper && (\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t\t)}\n\n\t\t\t{showSourceButtons ? (\n\t\t\t\t<SourcePickerAnchor ref={usePicker ? sourcePickerRef : undefined}>\n\t\t\t\t\t{/* No tools yet: one button per source (never shown once a tool exists). */}\n\t\t\t\t\t<SourceButtonRow data-test={`${dataTestPrefix}-sources`}>\n\t\t\t\t\t\t{sourceGroups?.map((g) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={g.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-source-${g.source}`}\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t// Not connected → open the connect flow instead of the tools.\n\t\t\t\t\t\t\t\t\tif (g.connected === false) {\n\t\t\t\t\t\t\t\t\t\tg.onConnect?.();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (usePicker) {\n\t\t\t\t\t\t\t\t\t\t// Open the `@` picker drilled straight into this source's tools.\n\t\t\t\t\t\t\t\t\t\tsetPickerSource(g.source);\n\t\t\t\t\t\t\t\t\t\tsetAdding(true);\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsetActiveSource(g.source);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(SOURCE_ICONS[g.source], -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{g.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t{/* Built-in action tools (Rest API / Handover to email) open a drawer. */}\n\t\t\t\t\t\t{actionSources?.map((a) => (\n\t\t\t\t\t\t\t<SourceButton\n\t\t\t\t\t\t\t\tkey={a.source}\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-action-${a.source}`}\n\t\t\t\t\t\t\t\tonClick={a.onSelect}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{renderSourceIcon(a.icon, -4)}\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t{a.label}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t</SourceButton>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</SourceButtonRow>\n\n\t\t\t\t\t{/* Picker mode: clicking a source opens its tools in the `@` picker. */}\n\t\t\t\t\t{usePicker && adding && pickerSource !== null && (\n\t\t\t\t\t\t<PickerPopover $align=\"left\" data-test={`${dataTestPrefix}-picker`}>\n\t\t\t\t\t\t\t{pickerNode}\n\t\t\t\t\t\t</PickerPopover>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Legacy (non-picker) mode: chosen source → its searchable tool list. */}\n\t\t\t\t\t{!usePicker && activeGroup && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Search ${activeGroup.label} tools`}\n\t\t\t\t\t\t\toptions={activeGroup.options}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetActiveSource(null);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\t\t\t\t</SourcePickerAnchor>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{!usePicker && adding && dropdownOptions.length > 0 && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-dropdown`}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\tplaceHolder={`Select ${title.toLowerCase()}`}\n\t\t\t\t\t\t\toptions={dropdownOptions}\n\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\tsetAdding(false);\n\t\t\t\t\t\t\t\tif (!v) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v === CREATE_OPTION_VALUE) {\n\t\t\t\t\t\t\t\t\tcreateOption?.onSelect();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonAdd(v);\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)}\n\n\t\t\t\t\t{items.length === 0 && !adding ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.placeholder}>\n\t\t\t\t\t\t\t\t{emptyText}\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t{showEmptyCreate && createOption && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test={`${dataTestPrefix}-create`}\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\tbuttonText={createOption.label}\n\t\t\t\t\t\t\t\t\tonClick={createOption.onSelect}\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) : (\n\t\t\t\t\t\trenderChipRows()\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{confirmDelete && pendingDeleteId && (\n\t\t\t\t<DeleteConfirmationModal\n\t\t\t\t\tdata-test={`${dataTestPrefix}-delete-confirm`}\n\t\t\t\t\theader={`Delete this ${confirmDelete.noun}?`}\n\t\t\t\t\tsubHeader={`Deleting this ${confirmDelete.noun} will also remove it from your instructions, wherever it's referenced.`}\n\t\t\t\t\tconfirmationText=\"Delete\"\n\t\t\t\t\tzIndex={confirmDelete.zIndex}\n\t\t\t\t\tonDeleteConfirmed={() => {\n\t\t\t\t\t\tonRemove(pendingDeleteId);\n\t\t\t\t\t\tsetPendingDeleteId(null);\n\t\t\t\t\t}}\n\t\t\t\t\tonCancelClicked={() => setPendingDeleteId(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</SideSection>\n\t);\n};\n\n// Anchors the `@`-picker popover to the header \"+\" button.\nconst AddButtonWrap = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n`;\n\n// Anchors the `@`-picker popover to the empty-state source buttons.\nconst SourcePickerAnchor = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\n// Floating card under the trigger. Aligns to the \"+\" (right) or the source\n// buttons (left) so it stays inside the side panel.\nconst PickerPopover = styled.div<{ $align?: 'left' | 'right' }>`\n\tposition: absolute;\n\ttop: calc(100% + 4px);\n\t${(p) => (p.$align === 'left' ? 'left: 0;' : 'right: 0;')}\n\tz-index: 30;\n`;\n"],"names":["CREATE_OPTION_VALUE","SelectableListSection","title","helper","items","addableOptions","onAdd","onRemove","dataTestPrefix","emptyText","createOption","onConfigure","sourceGroups","mentionItems","actionSources","confirmDelete","adding","setAdding","useState","pendingDeleteId","setPendingDeleteId","activeSource","setActiveSource","hasSourceGroups","activeGroup","g","usePicker","headerPickerRef","useRef","sourcePickerRef","pickerSource","setPickerSource","useEffect","onDocMouseDown","e","target","onKeyDown","showAddButton","showEmptyCreate","hasActionSources","showSourceButtons","handleAddClick","v","renderChipRows","item","configure","jsxs","SelectableRow","renderSourceIcon","jsx","RowText","BodySecondary","COLORS","RowActions","RowMenuButton","EditIcon","RowActionDivider","DeleteIcon","dropdownOptions","pickerNode","MentionPicker","a","SideSection","SideSectionHeader","TitleSmall","AddButtonWrap","AddIconButton","PlusIcon","PickerPopover","BodyCaption","SourcePickerAnchor","SourceButtonRow","SourceButton","SOURCE_ICONS","Dropdown","opt","unwrapDropdownValue","Fragment","Button","DeleteConfirmationModal","styled","p"],"mappings":";;;;;;;;;;;;;;;AAiEA,MAAMA,IAAsB,sBA0DfC,KAA8D,CAAC;AAAA,EAC3E,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACD,MAAM;AACL,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpC,CAACC,GAAiBC,CAAkB,IAAIF,EAAwB,IAAI,GAEpE,CAACG,GAAcC,CAAe,IAAIJ,EAAwB,IAAI,GAC9DK,IAAkB,CA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AA,QACA,iBAAiB,MAAMA,EAAmB,IAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAC/C,GAEF;AAEF,GAGM6C,KAAgBe,EAAO;AAAA;AAAA;AAAA,GAMvBV,KAAqBU,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA,GAS5BZ,IAAgBY,EAAO;AAAA;AAAA;AAAA,GAG1B,CAACC,MAAOA,EAAE,WAAW,SAAS,aAAa,WAAY;AAAA;AAAA;"}
@@ -1,30 +1,30 @@
1
1
  import { jsxs as T, jsx as l } from "react/jsx-runtime";
2
- import { useState as N, useRef as U, useCallback as r, useEffect as j } from "react";
3
- import { TitleSmall as W } from "../../TypographyStyle.js";
4
- import { COLORS as $ } from "../../../constants/Theme.js";
5
- import { Step3Root as ve, Step3Grid as ye, SectionBodyWrap as z, Step3Divider as Ie, SideSection as Ce } from "../AgentBuilder.styled.js";
6
- import { ConfigToolPanel as we } from "../components/ConfigToolPanel.js";
7
- import { CreateSubAgentPanel as ke } from "../components/CreateSubAgentPanel.js";
8
- import { MentionField as V } from "../components/MentionField.js";
9
- import { RestApiToolPanel as Oe } from "../components/RestApiToolPanel.js";
10
- import { SelectableListSection as q } from "../components/SelectableListSection.js";
11
- import { StepSectionHeader as Re } from "../components/StepSectionHeader.js";
12
- import { STEP_DEFINITIONS as Me } from "../constants/steps.js";
13
- import { CONFIG_TOOL_SOURCES as Ee, ToolSource as g } from "../constants/tools.js";
14
- import { useAgentBuilderContext as _e } from "../context/AgentBuilderContext.js";
15
- import { restApiMentionItem as xe, configToolMentionItem as Ke, restApiToolName as Le, configToolName as Ne, toolSourceLabel as De, buildAgentMentionItems as J, buildCustomToolMentionItems as Pe, appTypeLabel as Q } from "../utils/mentionSerialization.js";
16
- import { sourceIcon as oe, SOURCE_ICONS as X, renderSourceIcon as He } from "../utils/sourceIcons.js";
17
- import { buildToolActions as Fe } from "../utils/toolActions.js";
18
- import { Dropdown as Ge } from "../../dropdown/Dropdown.js";
19
- import { unwrapDropdownValue as Be } from "../../dropdown/utils.js";
20
- const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
2
+ import { useState as N, useRef as W, useCallback as r, useEffect as $ } from "react";
3
+ import { TitleSmall as z } from "../../TypographyStyle.js";
4
+ import { COLORS as V } from "../../../constants/Theme.js";
5
+ import { Step3Root as Ie, Step3Grid as Ce, SectionBodyWrap as q, Step3Divider as we, SideSection as ke } from "../AgentBuilder.styled.js";
6
+ import { ConfigToolPanel as Oe } from "../components/ConfigToolPanel.js";
7
+ import { CreateSubAgentPanel as Re } from "../components/CreateSubAgentPanel.js";
8
+ import { MentionField as J } from "../components/MentionField.js";
9
+ import { RestApiToolPanel as Me } from "../components/RestApiToolPanel.js";
10
+ import { SelectableListSection as Q } from "../components/SelectableListSection.js";
11
+ import { StepSectionHeader as Ee } from "../components/StepSectionHeader.js";
12
+ import { STEP_DEFINITIONS as _e } from "../constants/steps.js";
13
+ import { CONFIG_TOOL_SOURCES as xe, ToolSource as g } from "../constants/tools.js";
14
+ import { useAgentBuilderContext as Ke } from "../context/AgentBuilderContext.js";
15
+ import { restApiMentionItem as Le, configToolMentionItem as Ne, restApiToolName as De, configToolName as Pe, toolSourceLabel as He, buildAgentMentionItems as X, buildCustomToolMentionItems as Fe, appTypeLabel as Y } from "../utils/mentionSerialization.js";
16
+ import { sourceIcon as ne, SOURCE_ICONS as Z, renderSourceIcon as Ge } from "../utils/sourceIcons.js";
17
+ import { buildToolActions as Be } from "../utils/toolActions.js";
18
+ import { Dropdown as Ue } from "../../dropdown/Dropdown.js";
19
+ import { unwrapDropdownValue as je } from "../../dropdown/utils.js";
20
+ const We = (t) => Ge(ne(t)) ?? void 0, ee = (t) => ({
21
21
  label: t.display_name,
22
22
  value: t.tool_id,
23
- leadingIcon: Ue(t.source ?? g.Manifest)
24
- }), Z = Me[2], ee = (t, i) => {
23
+ leadingIcon: We(t.source ?? g.Manifest)
24
+ }), oe = _e[2], te = (t, i) => {
25
25
  const f = t ?? [];
26
26
  return f.some((c) => c.id === i.id) ? f.map((c) => c.id === i.id ? i : c) : [...f, i];
27
- }, ro = () => {
27
+ }, uo = () => {
28
28
  const {
29
29
  value: t,
30
30
  patch: i,
@@ -32,7 +32,7 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
32
32
  addReference: c,
33
33
  removeReference: D,
34
34
  availableTools: b,
35
- availableSubAgents: te,
35
+ availableSubAgents: le,
36
36
  availableModels: C,
37
37
  configToolTemplates: w,
38
38
  applicationType: P,
@@ -41,11 +41,13 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
41
41
  onCreateSubAgent: u,
42
42
  onFetchSubAgent: h,
43
43
  onUpdateSubAgent: k,
44
- onImproveSubAgent: ne,
44
+ onImproveSubAgent: ie,
45
45
  onImproveToolInstructions: O,
46
46
  registerSubAgentCreator: R,
47
- registerToolActionHandler: M
48
- } = _e(), [d, A] = N(null), v = U(0), [s, p] = N(null), y = U(0), E = r((e) => {
47
+ registerToolActionHandler: M,
48
+ integrationStatus: H,
49
+ onConnectIntegration: F
50
+ } = Ke(), [d, A] = N(null), v = W(0), [s, p] = N(null), y = W(0), E = r((e) => {
49
51
  y.current += 1, p({
50
52
  key: y.current,
51
53
  kind: "restapi",
@@ -61,36 +63,36 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
61
63
  });
62
64
  },
63
65
  []
64
- ), le = r(
66
+ ), se = r(
65
67
  (e) => {
66
68
  const o = !(t.restApiTools ?? []).some((n) => n.id === e.id);
67
- i({ restApiTools: ee(t.restApiTools, e) }), o && a("tool", e.id, xe(e).label), p(null);
69
+ i({ restApiTools: te(t.restApiTools, e) }), o && a("tool", e.id, Le(e).label), p(null);
68
70
  },
69
71
  [i, t.restApiTools, a]
70
- ), ie = r(
72
+ ), ae = r(
71
73
  (e) => {
72
74
  const o = !(t.configTools ?? []).some((n) => n.id === e.id);
73
- i({ configTools: ee(t.configTools, e) }), o && a("tool", e.id, Ke(e).label), p(null);
75
+ i({ configTools: te(t.configTools, e) }), o && a("tool", e.id, Ne(e).label), p(null);
74
76
  },
75
77
  [i, t.configTools, a]
76
78
  ), x = r(
77
79
  (e) => {
78
- const o = Ee[e];
80
+ const o = xe[e];
79
81
  o ? _(o) : E();
80
82
  },
81
83
  [_, E]
82
84
  );
83
- j(() => (M(x), () => M(null)), [M, x]);
84
- const [se, H] = N([]), I = /* @__PURE__ */ new Map();
85
- te.forEach((e) => I.set(e.id, e)), se.forEach((e) => I.set(e.id, e));
86
- const F = Array.from(I.values()), K = r(() => {
85
+ $(() => (M(x), () => M(null)), [M, x]);
86
+ const [re, G] = N([]), I = /* @__PURE__ */ new Map();
87
+ le.forEach((e) => I.set(e.id, e)), re.forEach((e) => I.set(e.id, e));
88
+ const B = Array.from(I.values()), K = r(() => {
87
89
  v.current += 1, A({ key: v.current, title: "Create sub-agent" });
88
90
  }, []);
89
- j(() => {
91
+ $(() => {
90
92
  if (u)
91
93
  return R(K), () => R(null);
92
94
  }, [R, K, u]);
93
- const ae = r(
95
+ const ce = r(
94
96
  async (e) => {
95
97
  if (!h)
96
98
  return;
@@ -103,19 +105,19 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
103
105
  });
104
106
  },
105
107
  [h]
106
- ), re = r(
108
+ ), de = r(
107
109
  async (e) => {
108
110
  if (d?.editingId) {
109
111
  if (k) {
110
112
  const o = await k(d.editingId, e);
111
- H((n) => [
113
+ G((n) => [
112
114
  ...n.filter((m) => m.id !== o.id),
113
115
  o
114
116
  ]);
115
117
  }
116
118
  } else if (u) {
117
119
  const o = await u(e);
118
- H((n) => [...n, o]), i({ subagents: [...t.subagents, o.id] }), a("subagent", o.id, `sub-agent: ${o.name}`);
120
+ G((n) => [...n, o]), i({ subagents: [...t.subagents, o.id] }), a("subagent", o.id, `sub-agent: ${o.name}`);
119
121
  }
120
122
  A(null);
121
123
  },
@@ -127,68 +129,74 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
127
129
  t.subagents,
128
130
  a
129
131
  ]
130
- ), ce = t.tools.map((e) => {
132
+ ), ue = t.tools.map((e) => {
131
133
  const o = b.find((n) => n.tool_id === e);
132
134
  return o ? {
133
135
  id: e,
134
136
  label: o.display_name,
135
- icon: oe(o.source ?? g.Manifest)
137
+ icon: ne(o.source ?? g.Manifest)
136
138
  } : null;
137
- }).filter((e) => e !== null), de = (t.restApiTools ?? []).map(
139
+ }).filter((e) => e !== null), pe = (t.restApiTools ?? []).map(
138
140
  (e) => ({
139
141
  id: e.id,
140
- label: Le(e),
141
- icon: X[g.RestApi],
142
+ label: De(e),
143
+ icon: Z[g.RestApi],
142
144
  onConfigure: () => E(e)
143
145
  })
144
- ), ue = (t.configTools ?? []).map(
146
+ ), me = (t.configTools ?? []).map(
145
147
  (e) => ({
146
148
  id: e.id,
147
- label: Ne(e),
148
- icon: X[e.tool_key === "send_slack_message" ? g.Slack : g.EmailHandover],
149
+ label: Pe(e),
150
+ icon: Z[e.tool_key === "send_slack_message" ? g.Slack : g.EmailHandover],
149
151
  onConfigure: () => _(e.tool_key, e)
150
152
  })
151
- ), pe = [
152
- ...ce,
153
- ...de,
154
- ...ue
155
- ], me = Fe(
153
+ ), ge = [
154
+ ...ue,
155
+ ...pe,
156
+ ...me
157
+ ], fe = Be(
156
158
  w,
157
- x
158
- ), ge = b.map(Y), fe = (() => {
159
+ x,
160
+ H,
161
+ F
162
+ ), be = b.map(ee), Se = (() => {
159
163
  const e = [], o = /* @__PURE__ */ new Map();
160
164
  return b.forEach((n) => {
161
165
  const m = n.source ?? g.Manifest;
162
- o.has(m) || (o.set(m, []), e.push(m)), o.get(m)?.push(Y(n));
166
+ o.has(m) || (o.set(m, []), e.push(m)), o.get(m)?.push(ee(n));
163
167
  }), e.map((n) => ({
164
168
  source: n,
165
- label: De(n),
166
- options: o.get(n) ?? []
169
+ label: He(n),
170
+ options: o.get(n) ?? [],
171
+ // Not connected → the source button opens the connect flow instead of
172
+ // its tool list (see SelectableListSection / onConnectIntegration).
173
+ connected: H?.[n],
174
+ onConnect: () => F?.(n)
167
175
  }));
168
- })(), be = t.subagents.map((e) => {
176
+ })(), Te = t.subagents.map((e) => {
169
177
  const o = I.get(e);
170
178
  return o ? { id: e, label: o.name } : null;
171
- }).filter((e) => e !== null), Se = F.map((e) => ({
179
+ }).filter((e) => e !== null), he = B.map((e) => ({
172
180
  label: e.name,
173
181
  value: e.id
174
- })), G = Q(P), Te = [
175
- ...J(b, [], G),
176
- ...Pe(t.configTools, t.restApiTools)
177
- ], he = J(
182
+ })), U = Y(P), Ae = [
183
+ ...X(b, [], U),
184
+ ...Fe(t.configTools, t.restApiTools)
185
+ ], ve = X(
178
186
  [],
179
- F,
180
- G
181
- ), Ae = C.map((e) => ({
187
+ B,
188
+ U
189
+ ), ye = C.map((e) => ({
182
190
  label: e.label,
183
191
  value: e.value,
184
192
  selected: e.value === t.model
185
- })), L = C.find((e) => e.value === t.model), B = s?.kind === "config" && s.toolKey ? w?.[s.toolKey] : void 0;
186
- return /* @__PURE__ */ T(ve, { children: [
187
- /* @__PURE__ */ l(Re, { title: Z.title, helper: Z.helper }),
188
- /* @__PURE__ */ T(ye, { $grow: !0, children: [
189
- /* @__PURE__ */ T(z, { children: [
193
+ })), L = C.find((e) => e.value === t.model), j = s?.kind === "config" && s.toolKey ? w?.[s.toolKey] : void 0;
194
+ return /* @__PURE__ */ T(Ie, { children: [
195
+ /* @__PURE__ */ l(Ee, { title: oe.title, helper: oe.helper }),
196
+ /* @__PURE__ */ T(Ce, { $grow: !0, children: [
197
+ /* @__PURE__ */ T(q, { children: [
190
198
  /* @__PURE__ */ l(
191
- V,
199
+ J,
192
200
  {
193
201
  fieldKey: "instructions",
194
202
  "data-test": "agent-instructions",
@@ -199,7 +207,7 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
199
207
  }
200
208
  ),
201
209
  /* @__PURE__ */ l(
202
- V,
210
+ J,
203
211
  {
204
212
  fieldKey: "guardrail",
205
213
  "data-test": "agent-guardrail",
@@ -210,19 +218,19 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
210
218
  }
211
219
  )
212
220
  ] }),
213
- /* @__PURE__ */ l(Ie, {}),
214
- /* @__PURE__ */ T(z, { children: [
221
+ /* @__PURE__ */ l(we, {}),
222
+ /* @__PURE__ */ T(q, { children: [
215
223
  /* @__PURE__ */ l(
216
- q,
224
+ Q,
217
225
  {
218
226
  title: "Tools",
219
227
  helper: "Actions this agent can take while responding.",
220
228
  dataTestPrefix: "agent-tools",
221
- items: pe,
222
- addableOptions: ge,
223
- sourceGroups: fe,
224
- mentionItems: Te,
225
- actionSources: me,
229
+ items: ge,
230
+ addableOptions: be,
231
+ sourceGroups: Se,
232
+ mentionItems: Ae,
233
+ actionSources: fe,
226
234
  emptyText: "No tools added yet.",
227
235
  onAdd: (e) => {
228
236
  a("tool", e), c("tool", e);
@@ -232,35 +240,35 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
232
240
  }
233
241
  ),
234
242
  /* @__PURE__ */ l(
235
- q,
243
+ Q,
236
244
  {
237
245
  title: "Sub-agents",
238
246
  helper: "Other agents this agent can hand off the conversation to.",
239
247
  dataTestPrefix: "agent-subagents",
240
- items: be,
241
- addableOptions: Se,
242
- mentionItems: he,
248
+ items: Te,
249
+ addableOptions: he,
250
+ mentionItems: ve,
243
251
  emptyText: "No sub-agents added yet.",
244
252
  onAdd: (e) => {
245
253
  a("subagent", e), c("subagent", e);
246
254
  },
247
255
  onRemove: (e) => D("subagent", e),
248
256
  confirmDelete: { noun: "sub-agent" },
249
- onConfigure: h ? ae : void 0,
257
+ onConfigure: h ? ce : void 0,
250
258
  createOption: u ? { label: "Create new", onSelect: K } : void 0
251
259
  }
252
260
  ),
253
- C.length > 0 && /* @__PURE__ */ T(Ce, { children: [
254
- /* @__PURE__ */ l(W, { color: $.content.primary, children: "Advanced settings" }),
255
- /* @__PURE__ */ l(W, { color: $.content.secondary, children: "Select AI model" }),
261
+ C.length > 0 && /* @__PURE__ */ T(ke, { children: [
262
+ /* @__PURE__ */ l(z, { color: V.content.primary, children: "Advanced settings" }),
263
+ /* @__PURE__ */ l(z, { color: V.content.secondary, children: "Select AI model" }),
256
264
  /* @__PURE__ */ l(
257
- Ge,
265
+ Ue,
258
266
  {
259
267
  "data-test": "agent-model",
260
268
  size: "small",
261
269
  width: "100%",
262
270
  placeHolder: "Select model",
263
- options: Ae,
271
+ options: ye,
264
272
  defaultOptions: L ? [
265
273
  {
266
274
  label: L.label,
@@ -268,7 +276,7 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
268
276
  }
269
277
  ] : void 0,
270
278
  onSelect: (e) => {
271
- const o = Be(e);
279
+ const o = je(e);
272
280
  o && f("model", o);
273
281
  }
274
282
  }
@@ -277,48 +285,48 @@ const Ue = (t) => He(oe(t)) ?? void 0, Y = (t) => ({
277
285
  ] })
278
286
  ] }),
279
287
  d && /* @__PURE__ */ l(
280
- ke,
288
+ Re,
281
289
  {
282
290
  title: d.title,
283
291
  initial: d.initial,
284
292
  availableTools: b,
285
293
  configToolTemplates: w,
286
- appLabel: Q(P),
294
+ appLabel: Y(P),
287
295
  charLimits: S,
288
- onImprove: ne,
296
+ onImprove: ie,
289
297
  onImproveToolInstructions: O,
290
298
  onClose: () => A(null),
291
- onSave: re
299
+ onSave: de
292
300
  },
293
301
  d.key
294
302
  ),
295
303
  s?.kind === "restapi" && /* @__PURE__ */ l(
296
- Oe,
304
+ Me,
297
305
  {
298
306
  initial: s.initialRest,
299
307
  charLimits: S,
300
308
  onImprove: O,
301
309
  onClose: () => p(null),
302
- onSave: le
310
+ onSave: se
303
311
  },
304
312
  s.key
305
313
  ),
306
- s?.kind === "config" && s.toolKey && B && /* @__PURE__ */ l(
307
- we,
314
+ s?.kind === "config" && s.toolKey && j && /* @__PURE__ */ l(
315
+ Oe,
308
316
  {
309
317
  toolKey: s.toolKey,
310
- template: B,
318
+ template: j,
311
319
  initial: s.initialConfig,
312
320
  charLimits: S,
313
321
  onImprove: O,
314
322
  onClose: () => p(null),
315
- onSave: ie
323
+ onSave: ae
316
324
  },
317
325
  s.key
318
326
  )
319
327
  ] });
320
328
  };
321
329
  export {
322
- ro as Step3HowItResponds
330
+ uo as Step3HowItResponds
323
331
  };
324
332
  //# sourceMappingURL=Step3HowItResponds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write what this agent should do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"Things this agent must never do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', 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</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":";;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,KAAa,CAACC,MACnBC,GAAiBC,GAAWF,CAAM,CAAC,KAAK,QAGnCG,IAAa,CAAC,OAAgC;AAAA,EACnD,OAAO,EAAE;AAAA,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,SAASA,EAAM;AAAA,QACf,gBAAAf;AAAA,QACA,qBAAAG;AAAA,QACA,UAAUoE,EAAanE,CAAe;AAAA,QACtC,YAAAC;AAAA,QACA,WAAWK;AAAA,QACX,2BAAAC;AAAA,QACA,SAAS,MAAMK,EAAS,IAAI;AAAA,QAC5B,QAAQ+B;AAAA,MAAA;AAAA,MAVHhC,EAAM;AAAA,IAAA;AAAA,IAcZK,GAAY,SAAS,aACrB,gBAAA6D;AAAA,MAACgB;AAAA,MAAA;AAAA,QAEA,SAAS7E,EAAW;AAAA,QACpB,YAAAf;AAAA,QACA,WAAWM;AAAA,QACX,SAAS,MAAMU,EAAc,IAAI;AAAA,QACjC,QAAQO;AAAA,MAAA;AAAA,MALHR,EAAW;AAAA,IAAA;AAAA,IASjBA,GAAY,SAAS,YACrBA,EAAW,WACX2D,KACC,gBAAAE;AAAA,MAACiB;AAAA,MAAA;AAAA,QAEA,SAAS9E,EAAW;AAAA,QACpB,UAAU2D;AAAA,QACV,SAAS3D,EAAW;AAAA,QACpB,YAAAf;AAAA,QACA,WAAWM;AAAA,QACX,SAAS,MAAMU,EAAc,IAAI;AAAA,QACjC,QAAQY;AAAA,MAAA;AAAA,MAPHb,EAAW;AAAA,IAAA;AAAA,EAQjB,GAEH;AAEF;"}
1
+ {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t\t// Not connected → the source button opens the connect flow instead of\n\t\t\t// its tool list (see SelectableListSection / onConnectIntegration).\n\t\t\tconnected: integrationStatus?.[src as ToolSource],\n\t\t\tonConnect: () => onConnectIntegration?.(src as ToolSource),\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write what this agent should do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"Things this agent must never do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', 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</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","integrationStatus","onConnectIntegration","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":";;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,KAAa,CAACC,MACnBC,GAAiBC,GAAWF,CAAM,CAAC,KAAK,QAGnCG,KAAa,CAAC,OAAgC;AAAA,EACnD,OAAO,EAAE;AAAA,EACT,OAAO,EAAE;AAAA,EACT,aAAaJ,GAAW,EAAE,UAAUK,EAAW,QAAQ;AACxD,IAEMC,KAAOC,GAAiB,CAAC,GAwBzBC,KAAa,CAClBC,GACAC,MACS;AACT,QAAMC,IAAMF,KAAQ,CAAA;AACpB,SAAOE,EAAI,KAAK,CAACC,MAAMA,EAAE,OAAOF,EAAK,EAAE,IACpCC,EAAI,IAAI,CAACC,MAAOA,EAAE,OAAOF,EAAK,KAAKA,IAAOE,CAAE,IAC5C,CAAC,GAAGD,GAAKD,CAAI;AACjB,GAEaG,KAA+B,MAAM;AACjD,QAAM;AAAA,IACL,OAAAC;AAAA,IACA,OAAAC;AAAA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,GAAY,SAAS,aACrB,gBAAA6D;AAAA,MAACgB;AAAA,MAAA;AAAA,QAEA,SAAS7E,EAAW;AAAA,QACpB,YAAAjB;AAAA,QACA,WAAWM;AAAA,QACX,SAAS,MAAMY,EAAc,IAAI;AAAA,QACjC,QAAQO;AAAA,MAAA;AAAA,MALHR,EAAW;AAAA,IAAA;AAAA,IASjBA,GAAY,SAAS,YACrBA,EAAW,WACX2D,KACC,gBAAAE;AAAA,MAACiB;AAAA,MAAA;AAAA,QAEA,SAAS9E,EAAW;AAAA,QACpB,UAAU2D;AAAA,QACV,SAAS3D,EAAW;AAAA,QACpB,YAAAjB;AAAA,QACA,WAAWM;AAAA,QACX,SAAS,MAAMY,EAAc,IAAI;AAAA,QACjC,QAAQY;AAAA,MAAA;AAAA,MAPHb,EAAW;AAAA,IAAA;AAAA,EAQjB,GAEH;AAEF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.840-tools-beta.0",
3
+ "version": "0.0.840-tools-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",