@bikdotai/bik-component-library 0.0.832-beta.0 → 0.0.832-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.
Files changed (109) hide show
  1. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  2. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  4. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/MentionPicker.js +11 -4
  6. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  8. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  10. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/utils/toolActions.js +1 -1
  12. package/dist/cjs/components/agent-builder/utils/toolActions.js.map +1 -1
  13. package/dist/cjs/icons/Social/Channels/EmailMarketingV2.js +2 -0
  14. package/dist/cjs/icons/Social/Channels/EmailMarketingV2.js.map +1 -0
  15. package/dist/cjs/icons/Social/Channels/EmailV2.js +2 -0
  16. package/dist/cjs/icons/Social/Channels/EmailV2.js.map +1 -0
  17. package/dist/cjs/icons/Social/Channels/FacebookCommentV2.js +2 -0
  18. package/dist/cjs/icons/Social/Channels/FacebookCommentV2.js.map +1 -0
  19. package/dist/cjs/icons/Social/Channels/FacebookV2.js +2 -0
  20. package/dist/cjs/icons/Social/Channels/FacebookV2.js.map +1 -0
  21. package/dist/cjs/icons/Social/Channels/GmailV2.js +2 -0
  22. package/dist/cjs/icons/Social/Channels/GmailV2.js.map +1 -0
  23. package/dist/cjs/icons/Social/Channels/InstagramCommentV2.js +2 -0
  24. package/dist/cjs/icons/Social/Channels/InstagramCommentV2.js.map +1 -0
  25. package/dist/cjs/icons/Social/Channels/InstagramV2.js +2 -0
  26. package/dist/cjs/icons/Social/Channels/InstagramV2.js.map +1 -0
  27. package/dist/cjs/icons/Social/Channels/MessengerV2.js +2 -0
  28. package/dist/cjs/icons/Social/Channels/MessengerV2.js.map +1 -0
  29. package/dist/cjs/icons/Social/Channels/PhoneV2.js +2 -0
  30. package/dist/cjs/icons/Social/Channels/PhoneV2.js.map +1 -0
  31. package/dist/cjs/icons/Social/Channels/RcsV2.js +2 -0
  32. package/dist/cjs/icons/Social/Channels/RcsV2.js.map +1 -0
  33. package/dist/cjs/icons/Social/Channels/SmsV2.js +2 -0
  34. package/dist/cjs/icons/Social/Channels/SmsV2.js.map +1 -0
  35. package/dist/cjs/icons/Social/Channels/TaskV2.js +2 -0
  36. package/dist/cjs/icons/Social/Channels/TaskV2.js.map +1 -0
  37. package/dist/cjs/icons/Social/Channels/WebpushV2.js +2 -0
  38. package/dist/cjs/icons/Social/Channels/WebpushV2.js.map +1 -0
  39. package/dist/cjs/icons/Social/Channels/WhatsAppCallV2.js +2 -0
  40. package/dist/cjs/icons/Social/Channels/WhatsAppCallV2.js.map +1 -0
  41. package/dist/cjs/icons/Social/Channels/WhatsAppV2.js +2 -0
  42. package/dist/cjs/icons/Social/Channels/WhatsAppV2.js.map +1 -0
  43. package/dist/cjs/icons/index.js +1 -1
  44. package/dist/esm/components/agent-builder/AgentBuilder.js +91 -87
  45. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  46. package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +25 -1
  47. package/dist/esm/components/agent-builder/components/MentionField.js +56 -44
  48. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  49. package/dist/esm/components/agent-builder/components/MentionPicker.js +135 -116
  50. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  51. package/dist/esm/components/agent-builder/constants/tools.d.ts +25 -1
  52. package/dist/esm/components/agent-builder/constants/tools.js +20 -12
  53. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  54. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +10 -0
  55. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +129 -123
  56. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  57. package/dist/esm/components/agent-builder/utils/toolActions.d.ts +1 -1
  58. package/dist/esm/components/agent-builder/utils/toolActions.js +13 -9
  59. package/dist/esm/components/agent-builder/utils/toolActions.js.map +1 -1
  60. package/dist/esm/icons/Social/Channels/EmailMarketingV2.d.ts +6 -0
  61. package/dist/esm/icons/Social/Channels/EmailMarketingV2.js +41 -0
  62. package/dist/esm/icons/Social/Channels/EmailMarketingV2.js.map +1 -0
  63. package/dist/esm/icons/Social/Channels/EmailV2.d.ts +6 -0
  64. package/dist/esm/icons/Social/Channels/EmailV2.js +30 -0
  65. package/dist/esm/icons/Social/Channels/EmailV2.js.map +1 -0
  66. package/dist/esm/icons/Social/Channels/FacebookCommentV2.d.ts +6 -0
  67. package/dist/esm/icons/Social/Channels/FacebookCommentV2.js +53 -0
  68. package/dist/esm/icons/Social/Channels/FacebookCommentV2.js.map +1 -0
  69. package/dist/esm/icons/Social/Channels/FacebookV2.d.ts +6 -0
  70. package/dist/esm/icons/Social/Channels/FacebookV2.js +28 -0
  71. package/dist/esm/icons/Social/Channels/FacebookV2.js.map +1 -0
  72. package/dist/esm/icons/Social/Channels/GmailV2.d.ts +6 -0
  73. package/dist/esm/icons/Social/Channels/GmailV2.js +30 -0
  74. package/dist/esm/icons/Social/Channels/GmailV2.js.map +1 -0
  75. package/dist/esm/icons/Social/Channels/InstagramCommentV2.d.ts +6 -0
  76. package/dist/esm/icons/Social/Channels/InstagramCommentV2.js +53 -0
  77. package/dist/esm/icons/Social/Channels/InstagramCommentV2.js.map +1 -0
  78. package/dist/esm/icons/Social/Channels/InstagramV2.d.ts +6 -0
  79. package/dist/esm/icons/Social/Channels/InstagramV2.js +39 -0
  80. package/dist/esm/icons/Social/Channels/InstagramV2.js.map +1 -0
  81. package/dist/esm/icons/Social/Channels/MessengerV2.d.ts +6 -0
  82. package/dist/esm/icons/Social/Channels/MessengerV2.js +28 -0
  83. package/dist/esm/icons/Social/Channels/MessengerV2.js.map +1 -0
  84. package/dist/esm/icons/Social/Channels/PhoneV2.d.ts +6 -0
  85. package/dist/esm/icons/Social/Channels/PhoneV2.js +30 -0
  86. package/dist/esm/icons/Social/Channels/PhoneV2.js.map +1 -0
  87. package/dist/esm/icons/Social/Channels/RcsV2.d.ts +6 -0
  88. package/dist/esm/icons/Social/Channels/RcsV2.js +30 -0
  89. package/dist/esm/icons/Social/Channels/RcsV2.js.map +1 -0
  90. package/dist/esm/icons/Social/Channels/SmsV2.d.ts +6 -0
  91. package/dist/esm/icons/Social/Channels/SmsV2.js +30 -0
  92. package/dist/esm/icons/Social/Channels/SmsV2.js.map +1 -0
  93. package/dist/esm/icons/Social/Channels/TaskV2.d.ts +6 -0
  94. package/dist/esm/icons/Social/Channels/TaskV2.js +37 -0
  95. package/dist/esm/icons/Social/Channels/TaskV2.js.map +1 -0
  96. package/dist/esm/icons/Social/Channels/WebpushV2.d.ts +6 -0
  97. package/dist/esm/icons/Social/Channels/WebpushV2.js +39 -0
  98. package/dist/esm/icons/Social/Channels/WebpushV2.js.map +1 -0
  99. package/dist/esm/icons/Social/Channels/WhatsAppCallV2.d.ts +6 -0
  100. package/dist/esm/icons/Social/Channels/WhatsAppCallV2.js +46 -0
  101. package/dist/esm/icons/Social/Channels/WhatsAppCallV2.js.map +1 -0
  102. package/dist/esm/icons/Social/Channels/WhatsAppV2.d.ts +6 -0
  103. package/dist/esm/icons/Social/Channels/WhatsAppV2.js +30 -0
  104. package/dist/esm/icons/Social/Channels/WhatsAppV2.js.map +1 -0
  105. package/dist/esm/icons/Social/Channels/index.d.ts +15 -0
  106. package/dist/esm/icons/index.d.ts +25 -25
  107. package/dist/esm/icons/index.js +484 -454
  108. package/dist/esm/icons/index.js.map +1 -1
  109. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("react"),se=require("../../constants/Theme.js"),a=require("./AgentBuilder.styled.js"),re=require("./components/AgentBuilderFooter.js"),ie=require("./components/AgentBuilderTopBar.js"),le=require("./components/DiscardModal.js"),ue=require("./components/GoLiveModal.js"),ce=require("./components/StepRail.js"),de=require("./components/UndoToast.js"),T=require("./context/AgentBuilderContext.js"),ge=require("./steps/Step1About.js"),Se=require("./steps/Step2WhenItStepsIn.js"),he=require("./steps/Step3HowItResponds.js"),ve=require("./steps/Step4HandoverRules.js"),be=require("../spinner/Spinner.js"),pe=()=>{const{activeStep:u}=T.useAgentBuilderContext();switch(u){case"about":return n.jsx(ge.Step1About,{});case"trigger":return n.jsx(Se.Step2WhenItStepsIn,{});case"response":return n.jsx(he.Step3HowItResponds,{});case"handover":return n.jsx(ve.Step4HandoverRules,{});default:return null}},D=u=>{const{config:y,onChange:v,onStepChange:c,onDiscard:b,onSaveDraft:r,onPublish:p,onBack:d,onTestAgent:g,onGoToDashboard:S,onCreateSubAgent:i,onFetchSubAgent:k,onUpdateSubAgent:q,onImproveSubAgent:I,onImproveToolInstructions:R,...G}=u,{value:h,activeStep:M,availableTools:P,availableSubAgents:w,availableIntents:H=[],availableModels:F=[],configToolTemplates:O,validation:U,applicationType:N,charLimits:W,isSaving:C,isPublishing:f,isLoading:z,footerHint:E="Changes don’t affect customers until you go live",disableStepNavigation:_,debugLog:A}=y,[$,s]=o.useState(null),[j,x]=o.useState(!1),[J,l]=o.useState(!1),[m,L]=o.useState(!1),e=o.useCallback((t,...ae)=>{A&&console.log(`[AgentBuilder] ${t}`,...ae)},[A]),K=o.useCallback(t=>{e("onChange",t),v(t)},[e,v]),Q=o.useCallback(t=>{e("onStepChange",t),c?.(t)},[e,c]),V=o.useCallback(()=>(e("onSaveDraft"),r()),[e,r]),X=o.useCallback(()=>(e("onPublish"),p()),[e,p]),Y=o.useCallback(()=>{e("onBack"),l(!0)},[e]),Z=o.useCallback(()=>{e("onDiscardAndLeave"),l(!1),b()},[e,b]),B=o.useCallback(async()=>{e("onSaveDraftAndLeave");const t=r();if(t&&typeof t.then=="function"){L(!0);try{await t}finally{L(!1)}}l(!1),d?.()},[e,r,d]),ee=o.useCallback(()=>{e("onTestAgent"),g?.()},[e,g]),ne=o.useCallback(()=>{e("onGoToDashboard"),S?.()},[e,S]),te=o.useCallback(t=>(e("onCreateSubAgent",t),i?i(t):Promise.reject(new Error("onCreateSubAgent not provided"))),[e,i]),oe=async()=>{e("onGoLiveConfirm");const t=X();if(t&&typeof t.then=="function"){x(!0);try{await t,s("success")}finally{x(!1)}}else s("success")};return n.jsx(T.AgentBuilderProvider,{value:h,onChange:K,activeStep:M,onStepChange:c?Q:void 0,availableTools:P,availableSubAgents:w,availableIntents:H,availableModels:F,configToolTemplates:O,validation:U,applicationType:N,charLimits:W,disableStepNavigation:_,onCreateSubAgent:i?te:void 0,onFetchSubAgent:k,onUpdateSubAgent:q,onImproveSubAgent:I,onImproveToolInstructions:R,children:n.jsxs(a.BuilderRoot,{"data-test":G["data-test"]??"agent-builder",children:[n.jsx(ie.AgentBuilderTopBar,{name:h.name,status:h.status,onBack:d?Y:void 0,onSaveDraft:B,isSaving:C||m}),n.jsxs(a.Main,{children:[n.jsx(a.Rail,{children:n.jsx(ce.StepRail,{})}),n.jsx(a.Content,{children:z?n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:n.jsx(be.Spinner,{size:"large",color:se.COLORS.stroke.brand})}):n.jsxs(a.ContentCard,{children:[n.jsx(a.StepScroll,{children:n.jsx(pe,{})}),n.jsx(re.AgentBuilderFooter,{footerHint:E,onTestAgent:g?ee:void 0,onGoLive:()=>{e("onGoLive"),s("confirm")},isPublishing:f||j})]})})]}),n.jsx(ue.GoLiveModal,{mode:$,onClose:()=>s(null),onConfirm:oe,onSaveDraft:()=>{s(null),V()},onGoToDashboard:S?ne:void 0,isPublishing:f||j}),n.jsx(le.DiscardModal,{open:J,onClose:()=>l(!1),onDiscard:Z,onSaveDraft:B,isSaving:C||m}),n.jsx(de.UndoToast,{})]})})};D.displayName="AgentBuilder";exports.AgentBuilder=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),o=require("react"),ie=require("../../constants/Theme.js"),a=require("./AgentBuilder.styled.js"),le=require("./components/AgentBuilderFooter.js"),ue=require("./components/AgentBuilderTopBar.js"),ce=require("./components/DiscardModal.js"),de=require("./components/GoLiveModal.js"),ge=require("./components/StepRail.js"),Se=require("./components/UndoToast.js"),T=require("./context/AgentBuilderContext.js"),he=require("./steps/Step1About.js"),ve=require("./steps/Step2WhenItStepsIn.js"),be=require("./steps/Step3HowItResponds.js"),pe=require("./steps/Step4HandoverRules.js"),Ce=require("../spinner/Spinner.js"),fe=()=>{const{activeStep:u}=T.useAgentBuilderContext();switch(u){case"about":return n.jsx(he.Step1About,{});case"trigger":return n.jsx(ve.Step2WhenItStepsIn,{});case"response":return n.jsx(be.Step3HowItResponds,{});case"handover":return n.jsx(pe.Step4HandoverRules,{});default:return null}},D=u=>{const{config:y,onChange:v,onStepChange:c,onDiscard:b,onSaveDraft:r,onPublish:p,onBack:d,onTestAgent:g,onGoToDashboard:S,onCreateSubAgent:i,onFetchSubAgent:k,onUpdateSubAgent:q,onImproveSubAgent:I,onImproveToolInstructions:R,onConnectIntegration:G,...M}=u,{value:h,activeStep:P,availableTools:w,availableSubAgents:H,availableIntents:F=[],availableModels:O=[],configToolTemplates:U,integrationStatus:N,validation:W,applicationType:z,charLimits:E,isSaving:C,isPublishing:f,isLoading:_,footerHint:$="Changes don’t affect customers until you go live",disableStepNavigation:J,debugLog:A}=y,[K,s]=o.useState(null),[j,x]=o.useState(!1),[Q,l]=o.useState(!1),[m,L]=o.useState(!1),e=o.useCallback((t,...re)=>{A&&console.log(`[AgentBuilder] ${t}`,...re)},[A]),V=o.useCallback(t=>{e("onChange",t),v(t)},[e,v]),X=o.useCallback(t=>{e("onStepChange",t),c?.(t)},[e,c]),Y=o.useCallback(()=>(e("onSaveDraft"),r()),[e,r]),Z=o.useCallback(()=>(e("onPublish"),p()),[e,p]),ee=o.useCallback(()=>{e("onBack"),l(!0)},[e]),ne=o.useCallback(()=>{e("onDiscardAndLeave"),l(!1),b()},[e,b]),B=o.useCallback(async()=>{e("onSaveDraftAndLeave");const t=r();if(t&&typeof t.then=="function"){L(!0);try{await t}finally{L(!1)}}l(!1),d?.()},[e,r,d]),te=o.useCallback(()=>{e("onTestAgent"),g?.()},[e,g]),oe=o.useCallback(()=>{e("onGoToDashboard"),S?.()},[e,S]),ae=o.useCallback(t=>(e("onCreateSubAgent",t),i?i(t):Promise.reject(new Error("onCreateSubAgent not provided"))),[e,i]),se=async()=>{e("onGoLiveConfirm");const t=Z();if(t&&typeof t.then=="function"){x(!0);try{await t,s("success")}finally{x(!1)}}else s("success")};return n.jsx(T.AgentBuilderProvider,{value:h,onChange:V,activeStep:P,onStepChange:c?X:void 0,availableTools:w,availableSubAgents:H,availableIntents:F,availableModels:O,configToolTemplates:U,integrationStatus:N,onConnectIntegration:G,validation:W,applicationType:z,charLimits:E,disableStepNavigation:J,onCreateSubAgent:i?ae:void 0,onFetchSubAgent:k,onUpdateSubAgent:q,onImproveSubAgent:I,onImproveToolInstructions:R,children:n.jsxs(a.BuilderRoot,{"data-test":M["data-test"]??"agent-builder",children:[n.jsx(ue.AgentBuilderTopBar,{name:h.name,status:h.status,onBack:d?ee:void 0,onSaveDraft:B,isSaving:C||m}),n.jsxs(a.Main,{children:[n.jsx(a.Rail,{children:n.jsx(ge.StepRail,{})}),n.jsx(a.Content,{children:_?n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:n.jsx(Ce.Spinner,{size:"large",color:ie.COLORS.stroke.brand})}):n.jsxs(a.ContentCard,{children:[n.jsx(a.StepScroll,{children:n.jsx(fe,{})}),n.jsx(le.AgentBuilderFooter,{footerHint:$,onTestAgent:g?te:void 0,onGoLive:()=>{e("onGoLive"),s("confirm")},isPublishing:f||j})]})})]}),n.jsx(de.GoLiveModal,{mode:K,onClose:()=>s(null),onConfirm:se,onSaveDraft:()=>{s(null),Y()},onGoToDashboard:S?oe:void 0,isPublishing:f||j}),n.jsx(ce.DiscardModal,{open:Q,onClose:()=>l(!1),onDiscard:ne,onSaveDraft:B,isSaving:C||m}),n.jsx(Se.UndoToast,{})]})})};D.displayName="AgentBuilder";exports.AgentBuilder=D;
2
2
  //# sourceMappingURL=AgentBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilder.js","sources":["../../../../src/components/agent-builder/AgentBuilder.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { Spinner } from '@src/components/spinner';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentBuilderProps,\n\tAgentValue,\n\tSubAgentDraft,\n} from './AgentBuilder.model';\nimport {\n\tBuilderRoot,\n\tContent,\n\tContentCard,\n\tMain,\n\tRail,\n\tStepScroll,\n} from './AgentBuilder.styled';\nimport { AgentBuilderFooter } from './components/AgentBuilderFooter';\nimport { AgentBuilderTopBar } from './components/AgentBuilderTopBar';\nimport { DiscardModal } from './components/DiscardModal';\nimport { GoLiveModal, GoLiveModalMode } from './components/GoLiveModal';\nimport { StepRail } from './components/StepRail';\nimport { UndoToast } from './components/UndoToast';\nimport {\n\tAgentBuilderProvider,\n\tuseAgentBuilderContext,\n} from './context/AgentBuilderContext';\nimport { Step1About } from './steps/Step1About';\nimport { Step2WhenItStepsIn } from './steps/Step2WhenItStepsIn';\nimport { Step3HowItResponds } from './steps/Step3HowItResponds';\nimport { Step4HandoverRules } from './steps/Step4HandoverRules';\n\nconst StepContent: React.FC = () => {\n\tconst { activeStep } = useAgentBuilderContext();\n\tswitch (activeStep) {\n\t\tcase 'about':\n\t\t\treturn <Step1About />;\n\t\tcase 'trigger':\n\t\t\treturn <Step2WhenItStepsIn />;\n\t\tcase 'response':\n\t\t\treturn <Step3HowItResponds />;\n\t\tcase 'handover':\n\t\t\treturn <Step4HandoverRules />;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * 4-step creation/edit wizard body for an AI agent. Presentational and\n * controlled — the consumer owns the `value`, persistence and routing.\n *\n * @example\n * <AgentBuilder\n * value={agent}\n * onChange={(patch) => setAgent({ ...agent, ...patch })}\n * availableTools={tools}\n * availableSubAgents={subAgents}\n * onDiscard={() => router.back()}\n * onSaveDraft={saveDraft}\n * onPublish={publish}\n * />\n */\nexport const AgentBuilder: React.FC<AgentBuilderProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonChange,\n\t\tonStepChange,\n\t\tonDiscard,\n\t\tonSaveDraft,\n\t\tonPublish,\n\t\tonBack,\n\t\tonTestAgent,\n\t\tonGoToDashboard,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\t...rest\n\t} = props;\n\tconst {\n\t\tvalue,\n\t\tactiveStep,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableIntents = [],\n\t\tavailableModels = [],\n\t\tconfigToolTemplates,\n\t\tvalidation,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tisSaving,\n\t\tisPublishing,\n\t\tisLoading,\n\t\tfooterHint = 'Changes don’t affect customers until you go live',\n\t\tdisableStepNavigation,\n\t\tdebugLog,\n\t} = config;\n\n\tconst [modalMode, setModalMode] = useState<GoLiveModalMode>(null);\n\tconst [publishingLocal, setPublishingLocal] = useState(false);\n\t// Back was pressed → confirm leaving (save draft / discard) before navigating.\n\tconst [showLeaveConfirm, setShowLeaveConfirm] = useState(false);\n\tconst [savingAndLeaving, setSavingAndLeaving] = useState(false);\n\n\t// Gated debug logging: each handler logs at its start only when `debugLog`.\n\tconst logAction = useCallback(\n\t\t(action: string, ...args: unknown[]) => {\n\t\t\tif (debugLog) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`[AgentBuilder] ${action}`, ...args);\n\t\t\t}\n\t\t},\n\t\t[debugLog],\n\t);\n\n\tconst handleChange = useCallback(\n\t\t(patch: Partial<AgentValue>) => {\n\t\t\tlogAction('onChange', patch);\n\t\t\tonChange(patch);\n\t\t},\n\t\t[logAction, onChange],\n\t);\n\tconst handleStepChange = useCallback(\n\t\t(step: Parameters<NonNullable<typeof onStepChange>>[0]) => {\n\t\t\tlogAction('onStepChange', step);\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[logAction, onStepChange],\n\t);\n\tconst handleSaveDraft = useCallback(() => {\n\t\tlogAction('onSaveDraft');\n\t\treturn onSaveDraft();\n\t}, [logAction, onSaveDraft]);\n\tconst handlePublish = useCallback(() => {\n\t\tlogAction('onPublish');\n\t\treturn onPublish();\n\t}, [logAction, onPublish]);\n\t// Back opens the \"Save as draft?\" confirmation rather than leaving directly.\n\tconst handleBack = useCallback(() => {\n\t\tlogAction('onBack');\n\t\tsetShowLeaveConfirm(true);\n\t}, [logAction]);\n\n\t// Modal \"Discard\" defers to the parent's discard handler (same as the top bar).\n\tconst handleDiscardAndLeave = useCallback(() => {\n\t\tlogAction('onDiscardAndLeave');\n\t\tsetShowLeaveConfirm(false);\n\t\tonDiscard();\n\t}, [logAction, onDiscard]);\n\n\tconst handleSaveDraftAndLeave = useCallback(async () => {\n\t\tlogAction('onSaveDraftAndLeave');\n\t\tconst result = onSaveDraft();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSavingAndLeaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSavingAndLeaving(false);\n\t\t\t}\n\t\t}\n\t\tsetShowLeaveConfirm(false);\n\t\tonBack?.();\n\t}, [logAction, onSaveDraft, onBack]);\n\tconst handleTestAgent = useCallback(() => {\n\t\tlogAction('onTestAgent');\n\t\tonTestAgent?.();\n\t}, [logAction, onTestAgent]);\n\tconst handleGoToDashboard = useCallback(() => {\n\t\tlogAction('onGoToDashboard');\n\t\tonGoToDashboard?.();\n\t}, [logAction, onGoToDashboard]);\n\tconst handleCreateSubAgent = useCallback(\n\t\t(draft: SubAgentDraft) => {\n\t\t\tlogAction('onCreateSubAgent', draft);\n\t\t\treturn onCreateSubAgent\n\t\t\t\t? onCreateSubAgent(draft)\n\t\t\t\t: Promise.reject(new Error('onCreateSubAgent not provided'));\n\t\t},\n\t\t[logAction, onCreateSubAgent],\n\t);\n\n\tconst handleConfirmGoLive = async () => {\n\t\tlogAction('onGoLiveConfirm');\n\t\tconst result = handlePublish();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetPublishingLocal(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t\tsetModalMode('success');\n\t\t\t} finally {\n\t\t\t\tsetPublishingLocal(false);\n\t\t\t}\n\t\t} else {\n\t\t\tsetModalMode('success');\n\t\t}\n\t};\n\n\treturn (\n\t\t<AgentBuilderProvider\n\t\t\tvalue={value}\n\t\t\tonChange={handleChange}\n\t\t\tactiveStep={activeStep}\n\t\t\tonStepChange={onStepChange ? handleStepChange : undefined}\n\t\t\tavailableTools={availableTools}\n\t\t\tavailableSubAgents={availableSubAgents}\n\t\t\tavailableIntents={availableIntents}\n\t\t\tavailableModels={availableModels}\n\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\tvalidation={validation}\n\t\t\tapplicationType={applicationType}\n\t\t\tcharLimits={charLimits}\n\t\t\tdisableStepNavigation={disableStepNavigation}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? handleCreateSubAgent : undefined}\n\t\t\tonFetchSubAgent={onFetchSubAgent}\n\t\t\tonUpdateSubAgent={onUpdateSubAgent}\n\t\t\tonImproveSubAgent={onImproveSubAgent}\n\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t>\n\t\t\t<BuilderRoot data-test={rest['data-test'] ?? 'agent-builder'}>\n\t\t\t\t<AgentBuilderTopBar\n\t\t\t\t\tname={value.name}\n\t\t\t\t\tstatus={value.status}\n\t\t\t\t\tonBack={onBack ? handleBack : undefined}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<Main>\n\t\t\t\t\t<Rail>\n\t\t\t\t\t\t<StepRail />\n\t\t\t\t\t</Rail>\n\t\t\t\t\t<Content>\n\t\t\t\t\t\t{isLoading ? (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Spinner size=\"large\" color={COLORS.stroke.brand} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ContentCard>\n\t\t\t\t\t\t\t\t<StepScroll>\n\t\t\t\t\t\t\t\t\t<StepContent />\n\t\t\t\t\t\t\t\t</StepScroll>\n\t\t\t\t\t\t\t\t<AgentBuilderFooter\n\t\t\t\t\t\t\t\t\tfooterHint={footerHint}\n\t\t\t\t\t\t\t\t\tonTestAgent={onTestAgent ? handleTestAgent : undefined}\n\t\t\t\t\t\t\t\t\tonGoLive={() => {\n\t\t\t\t\t\t\t\t\t\tlogAction('onGoLive');\n\t\t\t\t\t\t\t\t\t\tsetModalMode('confirm');\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ContentCard>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Content>\n\t\t\t\t</Main>\n\n\t\t\t\t<GoLiveModal\n\t\t\t\t\tmode={modalMode}\n\t\t\t\t\tonClose={() => setModalMode(null)}\n\t\t\t\t\tonConfirm={handleConfirmGoLive}\n\t\t\t\t\tonSaveDraft={() => {\n\t\t\t\t\t\tsetModalMode(null);\n\t\t\t\t\t\thandleSaveDraft();\n\t\t\t\t\t}}\n\t\t\t\t\tonGoToDashboard={onGoToDashboard ? handleGoToDashboard : undefined}\n\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t/>\n\n\t\t\t\t<DiscardModal\n\t\t\t\t\topen={showLeaveConfirm}\n\t\t\t\t\tonClose={() => setShowLeaveConfirm(false)}\n\t\t\t\t\tonDiscard={handleDiscardAndLeave}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<UndoToast />\n\t\t\t</BuilderRoot>\n\t\t</AgentBuilderProvider>\n\t);\n};\n\nAgentBuilder.displayName = 'AgentBuilder';\n"],"names":["StepContent","activeStep","useAgentBuilderContext","Step1About","Step2WhenItStepsIn","Step3HowItResponds","Step4HandoverRules","AgentBuilder","props","config","onChange","onStepChange","onDiscard","onSaveDraft","onPublish","onBack","onTestAgent","onGoToDashboard","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","rest","value","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","validation","applicationType","charLimits","isSaving","isPublishing","isLoading","footerHint","disableStepNavigation","debugLog","modalMode","setModalMode","useState","publishingLocal","setPublishingLocal","showLeaveConfirm","setShowLeaveConfirm","savingAndLeaving","setSavingAndLeaving","logAction","useCallback","action","args","handleChange","patch","handleStepChange","step","handleSaveDraft","handlePublish","handleBack","handleDiscardAndLeave","handleSaveDraftAndLeave","result","handleTestAgent","handleGoToDashboard","handleCreateSubAgent","draft","handleConfirmGoLive","jsx","AgentBuilderProvider","BuilderRoot","AgentBuilderTopBar","Main","Rail","StepRail","Content","Spinner","COLORS","ContentCard","StepScroll","Ag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O,OAAO,KAAA,CAAO,CAAA,CAAA,SAGlDC,cAAA,CACA,SAAA,CAAAV,EAAAA,IAACW,EAAAA,WAAA,CACA,SAAAX,EAAAA,IAACnE,GAAA,CAAA,CAAY,EACd,EACAmE,EAAAA,IAACY,GAAAA,mBAAA,CACA,WAAA3C,EACA,YAAapB,EAAc8C,GAAkB,OAC7C,SAAU,IAAM,CACfd,EAAU,UAAU,EACpBR,EAAa,SAAS,CACvB,EACA,aAAcN,GAAgBQ,CAAA,CAAA,CAC/B,CAAA,CACD,CAAA,CAEF,CAAA,EACD,EAEAyB,EAAAA,IAACa,GAAAA,YAAA,CACA,KAAMzC,EACN,QAAS,IAAMC,EAAa,IAAI,EAChC,UAAW0B,GACX,YAAa,IAAM,CAClB1B,EAAa,IAAI,EACjBgB,EAAA,CACD,EACA,gBAAiBvC,EAAkB8C,GAAsB,OACzD,aAAc7B,GAAgBQ,CAAA,CAAA,EAG/ByB,EAAAA,IAACc,GAAAA,aAAA,CACA,KAAMrC,EACN,QAAS,IAAMC,EAAoB,EAAK,EACxC,UAAWc,EACX,YAAaC,EACb,SAAU3B,GAAYa,CAAA,CAAA,QAGtBoC,GAAAA,UAAA,CAAA,CAAU,CAAA,CAAA,CACZ,CAAA,CAAA,CAGH,EAEA3E,EAAa,YAAc"}
1
+ {"version":3,"file":"AgentBuilder.js","sources":["../../../../src/components/agent-builder/AgentBuilder.tsx"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport { Spinner } from '@src/components/spinner';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentBuilderProps,\n\tAgentValue,\n\tSubAgentDraft,\n} from './AgentBuilder.model';\nimport {\n\tBuilderRoot,\n\tContent,\n\tContentCard,\n\tMain,\n\tRail,\n\tStepScroll,\n} from './AgentBuilder.styled';\nimport { AgentBuilderFooter } from './components/AgentBuilderFooter';\nimport { AgentBuilderTopBar } from './components/AgentBuilderTopBar';\nimport { DiscardModal } from './components/DiscardModal';\nimport { GoLiveModal, GoLiveModalMode } from './components/GoLiveModal';\nimport { StepRail } from './components/StepRail';\nimport { UndoToast } from './components/UndoToast';\nimport {\n\tAgentBuilderProvider,\n\tuseAgentBuilderContext,\n} from './context/AgentBuilderContext';\nimport { Step1About } from './steps/Step1About';\nimport { Step2WhenItStepsIn } from './steps/Step2WhenItStepsIn';\nimport { Step3HowItResponds } from './steps/Step3HowItResponds';\nimport { Step4HandoverRules } from './steps/Step4HandoverRules';\n\nconst StepContent: React.FC = () => {\n\tconst { activeStep } = useAgentBuilderContext();\n\tswitch (activeStep) {\n\t\tcase 'about':\n\t\t\treturn <Step1About />;\n\t\tcase 'trigger':\n\t\t\treturn <Step2WhenItStepsIn />;\n\t\tcase 'response':\n\t\t\treturn <Step3HowItResponds />;\n\t\tcase 'handover':\n\t\t\treturn <Step4HandoverRules />;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\n/**\n * 4-step creation/edit wizard body for an AI agent. Presentational and\n * controlled — the consumer owns the `value`, persistence and routing.\n *\n * @example\n * <AgentBuilder\n * value={agent}\n * onChange={(patch) => setAgent({ ...agent, ...patch })}\n * availableTools={tools}\n * availableSubAgents={subAgents}\n * onDiscard={() => router.back()}\n * onSaveDraft={saveDraft}\n * onPublish={publish}\n * />\n */\nexport const AgentBuilder: React.FC<AgentBuilderProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonChange,\n\t\tonStepChange,\n\t\tonDiscard,\n\t\tonSaveDraft,\n\t\tonPublish,\n\t\tonBack,\n\t\tonTestAgent,\n\t\tonGoToDashboard,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tonConnectIntegration,\n\t\t...rest\n\t} = props;\n\tconst {\n\t\tvalue,\n\t\tactiveStep,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableIntents = [],\n\t\tavailableModels = [],\n\t\tconfigToolTemplates,\n\t\tintegrationStatus,\n\t\tvalidation,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tisSaving,\n\t\tisPublishing,\n\t\tisLoading,\n\t\tfooterHint = 'Changes don’t affect customers until you go live',\n\t\tdisableStepNavigation,\n\t\tdebugLog,\n\t} = config;\n\n\tconst [modalMode, setModalMode] = useState<GoLiveModalMode>(null);\n\tconst [publishingLocal, setPublishingLocal] = useState(false);\n\t// Back was pressed → confirm leaving (save draft / discard) before navigating.\n\tconst [showLeaveConfirm, setShowLeaveConfirm] = useState(false);\n\tconst [savingAndLeaving, setSavingAndLeaving] = useState(false);\n\n\t// Gated debug logging: each handler logs at its start only when `debugLog`.\n\tconst logAction = useCallback(\n\t\t(action: string, ...args: unknown[]) => {\n\t\t\tif (debugLog) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`[AgentBuilder] ${action}`, ...args);\n\t\t\t}\n\t\t},\n\t\t[debugLog],\n\t);\n\n\tconst handleChange = useCallback(\n\t\t(patch: Partial<AgentValue>) => {\n\t\t\tlogAction('onChange', patch);\n\t\t\tonChange(patch);\n\t\t},\n\t\t[logAction, onChange],\n\t);\n\tconst handleStepChange = useCallback(\n\t\t(step: Parameters<NonNullable<typeof onStepChange>>[0]) => {\n\t\t\tlogAction('onStepChange', step);\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[logAction, onStepChange],\n\t);\n\tconst handleSaveDraft = useCallback(() => {\n\t\tlogAction('onSaveDraft');\n\t\treturn onSaveDraft();\n\t}, [logAction, onSaveDraft]);\n\tconst handlePublish = useCallback(() => {\n\t\tlogAction('onPublish');\n\t\treturn onPublish();\n\t}, [logAction, onPublish]);\n\t// Back opens the \"Save as draft?\" confirmation rather than leaving directly.\n\tconst handleBack = useCallback(() => {\n\t\tlogAction('onBack');\n\t\tsetShowLeaveConfirm(true);\n\t}, [logAction]);\n\n\t// Modal \"Discard\" defers to the parent's discard handler (same as the top bar).\n\tconst handleDiscardAndLeave = useCallback(() => {\n\t\tlogAction('onDiscardAndLeave');\n\t\tsetShowLeaveConfirm(false);\n\t\tonDiscard();\n\t}, [logAction, onDiscard]);\n\n\tconst handleSaveDraftAndLeave = useCallback(async () => {\n\t\tlogAction('onSaveDraftAndLeave');\n\t\tconst result = onSaveDraft();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSavingAndLeaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSavingAndLeaving(false);\n\t\t\t}\n\t\t}\n\t\tsetShowLeaveConfirm(false);\n\t\tonBack?.();\n\t}, [logAction, onSaveDraft, onBack]);\n\tconst handleTestAgent = useCallback(() => {\n\t\tlogAction('onTestAgent');\n\t\tonTestAgent?.();\n\t}, [logAction, onTestAgent]);\n\tconst handleGoToDashboard = useCallback(() => {\n\t\tlogAction('onGoToDashboard');\n\t\tonGoToDashboard?.();\n\t}, [logAction, onGoToDashboard]);\n\tconst handleCreateSubAgent = useCallback(\n\t\t(draft: SubAgentDraft) => {\n\t\t\tlogAction('onCreateSubAgent', draft);\n\t\t\treturn onCreateSubAgent\n\t\t\t\t? onCreateSubAgent(draft)\n\t\t\t\t: Promise.reject(new Error('onCreateSubAgent not provided'));\n\t\t},\n\t\t[logAction, onCreateSubAgent],\n\t);\n\n\tconst handleConfirmGoLive = async () => {\n\t\tlogAction('onGoLiveConfirm');\n\t\tconst result = handlePublish();\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetPublishingLocal(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t\tsetModalMode('success');\n\t\t\t} finally {\n\t\t\t\tsetPublishingLocal(false);\n\t\t\t}\n\t\t} else {\n\t\t\tsetModalMode('success');\n\t\t}\n\t};\n\n\treturn (\n\t\t<AgentBuilderProvider\n\t\t\tvalue={value}\n\t\t\tonChange={handleChange}\n\t\t\tactiveStep={activeStep}\n\t\t\tonStepChange={onStepChange ? handleStepChange : undefined}\n\t\t\tavailableTools={availableTools}\n\t\t\tavailableSubAgents={availableSubAgents}\n\t\t\tavailableIntents={availableIntents}\n\t\t\tavailableModels={availableModels}\n\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\tintegrationStatus={integrationStatus}\n\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\tvalidation={validation}\n\t\t\tapplicationType={applicationType}\n\t\t\tcharLimits={charLimits}\n\t\t\tdisableStepNavigation={disableStepNavigation}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? handleCreateSubAgent : undefined}\n\t\t\tonFetchSubAgent={onFetchSubAgent}\n\t\t\tonUpdateSubAgent={onUpdateSubAgent}\n\t\t\tonImproveSubAgent={onImproveSubAgent}\n\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t>\n\t\t\t<BuilderRoot data-test={rest['data-test'] ?? 'agent-builder'}>\n\t\t\t\t<AgentBuilderTopBar\n\t\t\t\t\tname={value.name}\n\t\t\t\t\tstatus={value.status}\n\t\t\t\t\tonBack={onBack ? handleBack : undefined}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<Main>\n\t\t\t\t\t<Rail>\n\t\t\t\t\t\t<StepRail />\n\t\t\t\t\t</Rail>\n\t\t\t\t\t<Content>\n\t\t\t\t\t\t{isLoading ? (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\t\t\theight: '100%',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Spinner size=\"large\" color={COLORS.stroke.brand} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ContentCard>\n\t\t\t\t\t\t\t\t<StepScroll>\n\t\t\t\t\t\t\t\t\t<StepContent />\n\t\t\t\t\t\t\t\t</StepScroll>\n\t\t\t\t\t\t\t\t<AgentBuilderFooter\n\t\t\t\t\t\t\t\t\tfooterHint={footerHint}\n\t\t\t\t\t\t\t\t\tonTestAgent={onTestAgent ? handleTestAgent : undefined}\n\t\t\t\t\t\t\t\t\tonGoLive={() => {\n\t\t\t\t\t\t\t\t\t\tlogAction('onGoLive');\n\t\t\t\t\t\t\t\t\t\tsetModalMode('confirm');\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ContentCard>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Content>\n\t\t\t\t</Main>\n\n\t\t\t\t<GoLiveModal\n\t\t\t\t\tmode={modalMode}\n\t\t\t\t\tonClose={() => setModalMode(null)}\n\t\t\t\t\tonConfirm={handleConfirmGoLive}\n\t\t\t\t\tonSaveDraft={() => {\n\t\t\t\t\t\tsetModalMode(null);\n\t\t\t\t\t\thandleSaveDraft();\n\t\t\t\t\t}}\n\t\t\t\t\tonGoToDashboard={onGoToDashboard ? handleGoToDashboard : undefined}\n\t\t\t\t\tisPublishing={isPublishing || publishingLocal}\n\t\t\t\t/>\n\n\t\t\t\t<DiscardModal\n\t\t\t\t\topen={showLeaveConfirm}\n\t\t\t\t\tonClose={() => setShowLeaveConfirm(false)}\n\t\t\t\t\tonDiscard={handleDiscardAndLeave}\n\t\t\t\t\tonSaveDraft={handleSaveDraftAndLeave}\n\t\t\t\t\tisSaving={isSaving || savingAndLeaving}\n\t\t\t\t/>\n\n\t\t\t\t<UndoToast />\n\t\t\t</BuilderRoot>\n\t\t</AgentBuilderProvider>\n\t);\n};\n\nAgentBuilder.displayName = 'AgentBuilder';\n"],"names":["StepContent","activeStep","useAgentBuilderContext","Step1About","Step2WhenItStepsIn","Step3HowItResponds","Step4HandoverRules","AgentBuilder","props","config","onChange","onStepChange","onDiscard","onSaveDraft","onPublish","onBack","onTestAgent","onGoToDashboard","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","onConnectIntegration","rest","value","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","validation","applicationType","charLimits","isSaving","isPublishing","isLoading","footerHint","disableStepNavigation","debugLog","modalMode","setModalMode","useState","publishingLocal","setPublishingLocal","showLeaveConfirm","setShowLeaveConfirm","savingAndLeaving","setSavingAndLeaving","logAction","useCallback","action","args","handleChange","patch","handleStepChange","step","handleSaveDraft","handlePublish","handleBack","handleDiscardAndLeave","handleSaveDraftAndLeave","result","handleTestAgent","handleGoToDashboard","handleCreateSubAgent","draft","handleConfirmGoLive","jsx","AgentBuilderProvider","BuilderRoot","AgentBuilderTopBar","Main","Rail","StepRail","Content","Spinner","COLORS","ContentCard","StepScroll","AgentBuilderFooter","GoLiveModal","DiscardModal","UndoToast"],"mappings":"qtBA+BMA,GAAwB,IAAM,CACnC,KAAM,CAAE,WAAAC,CAAA,EAAeC,yBAAA,EACvB,OAAQD,EAAA,CACP,IAAK,QACJ,aAAQE,GAAAA,WAAA,EAAW,EACpB,IAAK,UACJ,aAAQC,GAAAA,mBAAA,EAAmB,EAC5B,IAAK,WACJ,aAAQC,GAAAA,mBAAA,EAAmB,EAC5B,IAAK,WACJ,aAAQC,GAAAA,mBAAA,EAAmB,EAC5B,QACC,OAAO,IAAA,CAEV,EAiBaC,EAA6CC,GAAU,CACnE,KAAM,CACL,OAAAC,EACA,SAAAC,EACA,aAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,OAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,qBAAAC,EACA,GAAGC,CAAA,EACAhB,EACE,CACL,MAAAiB,EACA,WAAAxB,EACA,eAAAyB,EACA,mBAAAC,EACA,iBAAAC,EAAmB,CA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,IAAMC,EAAoB,EAAK,EACxC,UAAWc,GACX,YAAaC,EACb,SAAU3B,GAAYa,CAAA,CAAA,QAGtBoC,GAAAA,UAAA,CAAA,CAAU,CAAA,CAAA,CACZ,CAAA,CAAA,CAGH,EAEA7E,EAAa,YAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),n=require("react"),j=require("../context/AgentBuilderContext.js"),i=require("../utils/mentionSerialization.js"),h=require("../utils/toolActions.js"),k=require("./MentionEditor.js"),y=({fieldKey:e,label:b,placeholder:A,maxLength:d,minHeight:T,...m})=>{const{value:t,patch:M,addReference:r,availableTools:s,availableSubAgents:l,applicationType:a,mentionResetKey:p,registerMentionField:u,notifyMentionFocus:C,onCreateSubAgent:q,requestCreateSubAgent:S,requestToolAction:c,configToolTemplates:g}=j.useAgentBuilderContext(),v=n.useMemo(()=>[...i.buildAgentMentionItems(s,l,i.appTypeLabel(a)),...i.buildCustomToolMentionItems(t.configTools,t.restApiTools)],[s,l,a,t.configTools,t.restApiTools]),F=n.useMemo(()=>h.buildToolActions(g,c),[c,g]),x=n.useCallback(o=>u(e,o),[u,e]),I=n.useCallback((o,R)=>r(o,R),[r]);return $.jsx(k.MentionEditor,{label:b,value:t[e]??"",onChange:o=>M({[e]:o}),maxLength:d,placeholder:A,minHeight:T,resetKey:`${t.id}:${e}:${p}`,mentionItems:v,tools:s,onMentionSelect:I,onFocus:()=>C(e),registerInsert:x,onCreateSubAgent:q?S:void 0,toolActions:F,"data-test":m["data-test"]})};exports.MentionField=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),n=require("react"),k=require("../context/AgentBuilderContext.js"),s=require("../utils/mentionSerialization.js"),y=require("../utils/toolActions.js"),B=require("./MentionEditor.js"),E=({fieldKey:e,label:d,placeholder:T,maxLength:m,minHeight:M,...p})=>{const{value:t,patch:C,addReference:r,availableTools:i,availableSubAgents:a,applicationType:l,mentionResetKey:S,registerMentionField:u,notifyMentionFocus:q,onCreateSubAgent:v,requestCreateSubAgent:F,requestToolAction:c,configToolTemplates:g,integrationStatus:b,onConnectIntegration:A}=k.useAgentBuilderContext(),I=n.useMemo(()=>[...s.buildAgentMentionItems(i,a,s.appTypeLabel(l)),...s.buildCustomToolMentionItems(t.configTools,t.restApiTools)],[i,a,l,t.configTools,t.restApiTools]),x=n.useMemo(()=>y.buildToolActions(g,c,b,A),[c,g,b,A]),R=n.useCallback(o=>u(e,o),[u,e]),$=n.useCallback((o,j)=>r(o,j),[r]);return h.jsx(B.MentionEditor,{label:d,value:t[e]??"",onChange:o=>C({[e]:o}),maxLength:m,placeholder:T,minHeight:M,resetKey:`${t.id}:${e}:${S}`,mentionItems:I,tools:i,onMentionSelect:$,onFocus:()=>q(e),registerInsert:R,onCreateSubAgent:v?F:void 0,toolActions:x,"data-test":p["data-test"]})};exports.MentionField=E;
2
2
  //# sourceMappingURL=MentionField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionField.js","sources":["../../../../../src/components/agent-builder/components/MentionField.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { AgentValue } from '../AgentBuilder.model';\nimport { ToolAction } from '../constants/tools';\nimport {\n\tMentionFieldKey,\n\tuseAgentBuilderContext,\n} from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n} from '../utils/mentionSerialization';\nimport { buildToolActions } from '../utils/toolActions';\nimport { MentionEditor } from './MentionEditor';\n\ninterface MentionFieldProps {\n\t/** Which AgentValue field this editor reads / writes. */\n\tfieldKey: MentionFieldKey;\n\tlabel: string;\n\tplaceholder?: string;\n\tmaxLength: number;\n\tminHeight?: string;\n\t'data-test'?: string;\n}\n\n/**\n * Context-bound {@link MentionEditor} for the builder's Step-3 Instructions /\n * Guardrails. Both `@` tools and sub-agents are offered; the field registers its\n * insert + focus with the context so side-panel adds drop a chip into whichever\n * field was last focused, and remounts on `mentionResetKey`.\n */\nexport const MentionField: React.FC<MentionFieldProps> = ({\n\tfieldKey,\n\tlabel,\n\tplaceholder,\n\tmaxLength,\n\tminHeight,\n\t...rest\n}) => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\taddReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tapplicationType,\n\t\tmentionResetKey,\n\t\tregisterMentionField,\n\t\tnotifyMentionFocus,\n\t\tonCreateSubAgent,\n\t\trequestCreateSubAgent,\n\t\trequestToolAction,\n\t\tconfigToolTemplates,\n\t} = useAgentBuilderContext();\n\n\t// Catalog tools + sub-agents, PLUS the inline custom tools (Rest API / email /\n\t// Slack) so their `{{tool:<id>}}` tokens rehydrate as chips on remount — they\n\t// live on the value, not in `availableTools`.\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(\n\t\t\t\tavailableTools,\n\t\t\t\tavailableSubAgents,\n\t\t\t\tappTypeLabel(applicationType),\n\t\t\t),\n\t\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t\t],\n\t\t[\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tapplicationType,\n\t\t\tvalue.configTools,\n\t\t\tvalue.restApiTools,\n\t\t],\n\t);\n\n\t// Built-in tool actions (Rest API / email / Slack) shown in the `@` picker's\n\t// Tools view — picking one opens its drawer (Step 3) instead of inserting text.\n\t// The shared email / Slack forms are backend-driven: each is offered only when\n\t// its template was provided.\n\tconst toolActions = useMemo<ToolAction[]>(\n\t\t() => buildToolActions(configToolTemplates, requestToolAction),\n\t\t[requestToolAction, configToolTemplates],\n\t);\n\n\tconst registerInsert = useCallback(\n\t\t(fn: Parameters<typeof registerMentionField>[1]) =>\n\t\t\tregisterMentionField(fieldKey, fn),\n\t\t[registerMentionField, fieldKey],\n\t);\n\n\t// Route through the context's ref-backed `addReference`: BikEditor captures\n\t// this handler at mount, so reading `value.tools` here would keep only the last\n\t// pick. `addReference` always appends against the latest lists.\n\tconst onMentionSelect = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => addReference(kind, id),\n\t\t[addReference],\n\t);\n\n\treturn (\n\t\t<MentionEditor\n\t\t\tlabel={label}\n\t\t\tvalue={(value[fieldKey] as string | undefined) ?? ''}\n\t\t\tonChange={(text) => patch({ [fieldKey]: text } as Partial<AgentValue>)}\n\t\t\tmaxLength={maxLength}\n\t\t\tplaceholder={placeholder}\n\t\t\tminHeight={minHeight}\n\t\t\tresetKey={`${value.id}:${fieldKey}:${mentionResetKey}`}\n\t\t\tmentionItems={mentionItems}\n\t\t\ttools={availableTools}\n\t\t\tonMentionSelect={onMentionSelect}\n\t\t\tonFocus={() => notifyMentionFocus(fieldKey)}\n\t\t\tregisterInsert={registerInsert}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? requestCreateSubAgent : undefined}\n\t\t\ttoolActions={toolActions}\n\t\t\tdata-test={rest['data-test']}\n\t\t/>\n\t);\n};\n"],"names":["MentionField","fieldKey","label","placeholder","maxLength","minHeight","rest","value","patch","addReference","availableTools","availableSubAgents","applicationType","mentionResetKey","registerMentionField","notifyMentionFocus","onCreateSubAgent","requestCreateSubAgent","requestToolAction","configToolTemplates","useAgentBuilderContext","mentionItems","useMemo","buildAgentMentionItems","appTypeLabel","buildCustomToolMentionItems","toolActions","buildToolActions","registerInsert","useCallback","fn","onMentionSelect","kind","id","jsx","MentionEditor","text"],"mappings":"0SA+BaA,EAA4C,CAAC,CACzD,SAAAC,EACA,MAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,GAAGC,CACJ,IAAM,CACL,KAAM,CACL,MAAAC,EACA,MAAAC,EACA,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,qBAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,oBAAAC,CAAA,EACGC,yBAAA,EAKEC,EAAeC,EAAAA,QACpB,IAAM,CACL,GAAGC,EAAAA,uBACFb,EACAC,EACAa,EAAAA,aAAaZ,CAAe,CAAA,EAE7B,GAAGa,8BAA4BlB,EAAM,YAAaA,EAAM,YAAY,CAAA,EAErE,CACCG,EACAC,EACAC,EACAL,EAAM,YACNA,EAAM,YAAA,CACP,EAOKmB,EAAcJ,EAAAA,QACnB,IAAMK,EAAAA,iBAAiBR,EAAqBD,CAAiB,EAC7D,CAACA,EAAmBC,CAAmB,CAAA,EAGlCS,EAAiBC,EAAAA,YACrBC,GACAhB,EAAqBb,EAAU6B,CAAE,EAClC,CAAChB,EAAsBb,CAAQ,CAAA,EAM1B8B,EAAkBF,EAAAA,YACvB,CAACG,EAA2BC,IAAexB,EAAauB,EAAMC,CAAE,EAChE,CAACxB,CAAY,CAAA,EAGd,OACCyB,EAAAA,IAACC,EAAAA,cAAA,CACA,MAAAjC,EACA,MAAQK,EAAMN,CAAQ,GAA4B,GAClD,SAAWmC,GAAS5B,EAAM,CAAE,CAACP,CAAQ,EAAGmC,EAA6B,EACrE,UAAAhC,EACA,YAAAD,EACA,UAAAE,EACA,SAAU,GAAGE,EAAM,EAAE,IAAIN,CAAQ,IAAIY,CAAe,GACpD,aAAAQ,EACA,MAAOX,EACP,gBAAAqB,EACA,QAAS,IAAMhB,EAAmBd,CAAQ,EAC1C,eAAA2B,EACA,iBAAkBZ,EAAmBC,EAAwB,OAAA,YAC7DS,EACA,YAAWpB,EAAK,WAAW,CAAA,CAAA,CAG9B"}
1
+ {"version":3,"file":"MentionField.js","sources":["../../../../../src/components/agent-builder/components/MentionField.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { AgentValue } from '../AgentBuilder.model';\nimport { ToolAction } from '../constants/tools';\nimport {\n\tMentionFieldKey,\n\tuseAgentBuilderContext,\n} from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n} from '../utils/mentionSerialization';\nimport { buildToolActions } from '../utils/toolActions';\nimport { MentionEditor } from './MentionEditor';\n\ninterface MentionFieldProps {\n\t/** Which AgentValue field this editor reads / writes. */\n\tfieldKey: MentionFieldKey;\n\tlabel: string;\n\tplaceholder?: string;\n\tmaxLength: number;\n\tminHeight?: string;\n\t'data-test'?: string;\n}\n\n/**\n * Context-bound {@link MentionEditor} for the builder's Step-3 Instructions /\n * Guardrails. Both `@` tools and sub-agents are offered; the field registers its\n * insert + focus with the context so side-panel adds drop a chip into whichever\n * field was last focused, and remounts on `mentionResetKey`.\n */\nexport const MentionField: React.FC<MentionFieldProps> = ({\n\tfieldKey,\n\tlabel,\n\tplaceholder,\n\tmaxLength,\n\tminHeight,\n\t...rest\n}) => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\taddReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tapplicationType,\n\t\tmentionResetKey,\n\t\tregisterMentionField,\n\t\tnotifyMentionFocus,\n\t\tonCreateSubAgent,\n\t\trequestCreateSubAgent,\n\t\trequestToolAction,\n\t\tconfigToolTemplates,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t} = useAgentBuilderContext();\n\n\t// Catalog tools + sub-agents, PLUS the inline custom tools (Rest API / email /\n\t// Slack) so their `{{tool:<id>}}` tokens rehydrate as chips on remount — they\n\t// live on the value, not in `availableTools`.\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(\n\t\t\t\tavailableTools,\n\t\t\t\tavailableSubAgents,\n\t\t\t\tappTypeLabel(applicationType),\n\t\t\t),\n\t\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t\t],\n\t\t[\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tapplicationType,\n\t\t\tvalue.configTools,\n\t\t\tvalue.restApiTools,\n\t\t],\n\t);\n\n\t// Built-in tool actions (Rest API / email / Slack) shown in the `@` picker's\n\t// Tools view — picking one opens its drawer (Step 3) instead of inserting text.\n\t// The shared email / Slack forms are backend-driven: each is offered only when\n\t// its template was provided.\n\tconst toolActions = useMemo<ToolAction[]>(\n\t\t() =>\n\t\t\tbuildToolActions(\n\t\t\t\tconfigToolTemplates,\n\t\t\t\trequestToolAction,\n\t\t\t\tintegrationStatus,\n\t\t\t\tonConnectIntegration,\n\t\t\t),\n\t\t[\n\t\t\trequestToolAction,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t],\n\t);\n\n\tconst registerInsert = useCallback(\n\t\t(fn: Parameters<typeof registerMentionField>[1]) =>\n\t\t\tregisterMentionField(fieldKey, fn),\n\t\t[registerMentionField, fieldKey],\n\t);\n\n\t// Route through the context's ref-backed `addReference`: BikEditor captures\n\t// this handler at mount, so reading `value.tools` here would keep only the last\n\t// pick. `addReference` always appends against the latest lists.\n\tconst onMentionSelect = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => addReference(kind, id),\n\t\t[addReference],\n\t);\n\n\treturn (\n\t\t<MentionEditor\n\t\t\tlabel={label}\n\t\t\tvalue={(value[fieldKey] as string | undefined) ?? ''}\n\t\t\tonChange={(text) => patch({ [fieldKey]: text } as Partial<AgentValue>)}\n\t\t\tmaxLength={maxLength}\n\t\t\tplaceholder={placeholder}\n\t\t\tminHeight={minHeight}\n\t\t\tresetKey={`${value.id}:${fieldKey}:${mentionResetKey}`}\n\t\t\tmentionItems={mentionItems}\n\t\t\ttools={availableTools}\n\t\t\tonMentionSelect={onMentionSelect}\n\t\t\tonFocus={() => notifyMentionFocus(fieldKey)}\n\t\t\tregisterInsert={registerInsert}\n\t\t\tonCreateSubAgent={onCreateSubAgent ? requestCreateSubAgent : undefined}\n\t\t\ttoolActions={toolActions}\n\t\t\tdata-test={rest['data-test']}\n\t\t/>\n\t);\n};\n"],"names":["MentionField","fieldKey","label","placeholder","maxLength","minHeight","rest","value","patch","addReference","availableTools","availableSubAgents","applicationType","mentionResetKey","registerMentionField","notifyMentionFocus","onCreateSubAgent","requestCreateSubAgent","requestToolAction","configToolTemplates","integrationStatus","onConnectIntegration","useAgentBuilderContext","mentionItems","useMemo","buildAgentMentionItems","appTypeLabel","buildCustomToolMentionItems","toolActions","buildToolActions","registerInsert","useCallback","fn","onMentionSelect","kind","id","jsx","MentionEditor","text"],"mappings":"0SA+BaA,EAA4C,CAAC,CACzD,SAAAC,EACA,MAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,GAAGC,CACJ,IAAM,CACL,KAAM,CACL,MAAAC,EACA,MAAAC,EACA,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,qBAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,qBAAAC,CAAA,EACGC,yBAAA,EAKEC,EAAeC,EAAAA,QACpB,IAAM,CACL,GAAGC,EAAAA,uBACFf,EACAC,EACAe,EAAAA,aAAad,CAAe,CAAA,EAE7B,GAAGe,8BAA4BpB,EAAM,YAAaA,EAAM,YAAY,CAAA,EAErE,CACCG,EACAC,EACAC,EACAL,EAAM,YACNA,EAAM,YAAA,CACP,EAOKqB,EAAcJ,EAAAA,QACnB,IACCK,EAAAA,iBACCV,EACAD,EACAE,EACAC,CAAA,EAEF,CACCH,EACAC,EACAC,EACAC,CAAA,CACD,EAGKS,EAAiBC,EAAAA,YACrBC,GACAlB,EAAqBb,EAAU+B,CAAE,EAClC,CAAClB,EAAsBb,CAAQ,CAAA,EAM1BgC,EAAkBF,EAAAA,YACvB,CAACG,EAA2BC,IAAe1B,EAAayB,EAAMC,CAAE,EAChE,CAAC1B,CAAY,CAAA,EAGd,OACC2B,EAAAA,IAACC,EAAAA,cAAA,CACA,MAAAnC,EACA,MAAQK,EAAMN,CAAQ,GAA4B,GAClD,SAAWqC,GAAS9B,EAAM,CAAE,CAACP,CAAQ,EAAGqC,EAA6B,EACrE,UAAAlC,EACA,YAAAD,EACA,UAAAE,EACA,SAAU,GAAGE,EAAM,EAAE,IAAIN,CAAQ,IAAIY,CAAe,GACpD,aAAAU,EACA,MAAOb,EACP,gBAAAuB,EACA,QAAS,IAAMlB,EAAmBd,CAAQ,EAC1C,eAAA6B,EACA,iBAAkBd,EAAmBC,EAAwB,OAAA,YAC7DW,EACA,YAAWtB,EAAK,WAAW,CAAA,CAAA,CAG9B"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),F=require("../../../assets/icons/chevronRight.svg.js"),G=require("../../../assets/icons/searchIcon.svg.js"),J=require("../../../icons/Arrows/Normal arrows/ArrowLeft.js"),l=require("react"),Q=require("styled-components"),M=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),T=require("../constants/tools.js"),P=require("../utils/mentionSerialization.js"),C=require("../utils/sourceIcons.js"),V=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},p=V(Q),m=n=>n.meta,R=n=>m(n)?.plainLabel??n.label,W="__bik_create_subagent__",X=({items:n,onSelect:L,registerKeyHandler:v,onClose:I,onCreateSubAgent:b,initialSource:D,toolActions:h})=>{const[z,j]=l.useState(null),[c,$]=l.useState(D??null),[O,g]=l.useState(0),[k,_]=l.useState(""),x=l.useMemo(()=>n.filter(e=>m(e)?.kind==="tool"),[n]),S=l.useMemo(()=>n.filter(e=>m(e)?.kind==="subagent"),[n]),E=l.useMemo(()=>{const e=[];return x.forEach(r=>{const f=m(r)?.source??"other";e.includes(f)||e.push(f)}),e},[x]),q=l.useMemo(()=>new Map((h??[]).map(e=>[e.source,e])),[h]),w=l.useMemo(()=>T.CATEGORIES.filter(e=>e.key==="tool"?x.length>0||(h?.length??0)>0:S.length>0||!!b),[x.length,S.length,b,h?.length]),B=w.length===1?w[0].key:null,s=z??B,d=s?s==="subagent"?{title:"Sub-agent",onBack:B?void 0:()=>j(null)}:c?{title:P.toolSourceLabel(c),onBack:()=>$(null),icon:C.sourceIcon(c)}:{title:"Tools",onBack:B?void 0:()=>j(null)}:null,u=l.useMemo(()=>{if(!s)return w.map(t=>({id:t.key,label:t.label,drillsIn:!0,onActivate:()=>{j(t.key),$(null)}}));if(s==="subagent"){const t=k.trim().toLowerCase(),o=S.filter(y=>!t||R(y).toLowerCase().includes(t)).map(y=>({id:String(y.id),label:R(y),drillsIn:!1,onActivate:()=>L(y)}));return b&&o.push({id:W,label:"Create new",drillsIn:!1,isCreate:!0,onActivate:()=>{I?.(),b()}}),o}if(!c){const t=(h??[]).map(o=>o.source).filter(o=>!E.includes(o));return[...E,...t].map(o=>({id:o,label:P.toolSourceLabel(o),drillsIn:!0,icon:C.sourceIcon(o)??q.get(o)?.icon,onActivate:()=>$(o)}))}const e=k.trim().toLowerCase(),r=x.filter(t=>(m(t)?.source??"other")===c).filter(t=>!e||R(t).toLowerCase().includes(e)).map(t=>({id:String(t.id),label:R(t),drillsIn:!1,onActivate:()=>L(t)})),f=q.get(c);if(f){const t=c in T.CONFIG_TOOL_SOURCES;r.push({id:`create:${c}`,label:f.label,drillsIn:!1,isCreate:!t,onActivate:()=>{I?.(),f.onSelect()}})}return r},[s,w,c,k,x,S,E,L,I,b,h,q]);l.useEffect(()=>g(0),[s,c,k,n]),l.useEffect(()=>_(""),[s,c]);const A=l.useRef({rows:u,activeIndex:O,header:d});A.current={rows:u,activeIndex:O,header:d},l.useEffect(()=>{if(v)return v(e=>{const{rows:r,activeIndex:f,header:t}=A.current;switch(e.key){case"ArrowDown":return r.length&&g(o=>(o+1)%r.length),!0;case"ArrowUp":return r.length&&g(o=>(o+r.length-1)%r.length),!0;case"ArrowRight":case"Enter":return r[f]?.onActivate(),!0;case"ArrowLeft":return t?.onBack?(t.onBack(),!0):!1;default:return!1}}),()=>v(null)},[v]);const N=s?u.length&&!u[0].drillsIn?"items":"sources":"categories",U=s==="tool"&&!!c||s==="subagent";return a.jsxs(Y,{className:`bik-mention-picker bik-mention-picker--${N}`,children:[d&&a.jsxs(ne,{type:"button",onClick:d.onBack,disabled:!d.onBack,style:{background:i.COLORS.surface.subdued,cursor:d.onBack?"pointer":"default"},children:[d.onBack&&a.jsx(J.default,{width:20,height:20,color:i.COLORS.content.primary}),d.icon&&C.renderSourceIcon(d.icon),a.jsxs(M.TitleSmall,{children:[" ",d.title]})]}),U&&a.jsxs(Z,{children:[a.jsx(G.default,{width:20,height:20,color:i.COLORS.content.placeholder}),a.jsx(K,{autoFocus:!0,value:k,placeholder:"Search","data-test":"mention-picker-search",onChange:e=>_(e.target.value),onKeyDown:e=>{u.length&&(e.key==="ArrowDown"?(e.preventDefault(),g(r=>(r+1)%u.length)):e.key==="ArrowUp"?(e.preventDefault(),g(r=>(r+u.length-1)%u.length)):e.key==="Enter"&&(e.preventDefault(),u[O]?.onActivate()))}})]}),u.length===0?a.jsx(re,{children:s==="subagent"?"No sub-agents available":"No tools available"}):u.map((e,r)=>a.jsx(H,{type:"button",$active:r===O,onMouseEnter:()=>g(r),onClick:e.onActivate,children:e.isCreate?a.jsx(te,{children:e.label}):a.jsxs(a.Fragment,{children:[a.jsxs(ee,{children:[C.renderSourceIcon(e.icon),a.jsx(M.BodySecondary,{color:i.COLORS.content.primary,children:e.label})]}),e.drillsIn&&a.jsx(F.default,{width:12,height:12})]})},e.id))]})},Y=p.default.div`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),F=require("../../../assets/icons/chevronRight.svg.js"),G=require("../../../assets/icons/searchIcon.svg.js"),J=require("../../../icons/Arrows/Normal arrows/ArrowLeft.js"),c=require("react"),Q=require("styled-components"),P=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),L=require("../constants/tools.js"),_=require("../utils/mentionSerialization.js"),m=require("../utils/sourceIcons.js"),V=o=>o&&typeof o=="object"&&"default"in o?o:{default:o},p=V(Q),S=o=>o.meta,I=o=>S(o)?.plainLabel??o.label,W="__bik_create_subagent__",X=({items:o,onSelect:j,registerKeyHandler:O,onClose:v,onCreateSubAgent:k,initialSource:D,toolActions:g})=>{const[z,$]=c.useState(null),[l,A]=c.useState(D??null),[C,b]=c.useState(0),[y,M]=c.useState(""),x=c.useMemo(()=>o.filter(e=>S(e)?.kind==="tool"),[o]),w=c.useMemo(()=>o.filter(e=>S(e)?.kind==="subagent"),[o]),E=c.useMemo(()=>{const e=[];return x.forEach(r=>{const h=S(r)?.source??"other";e.includes(h)||e.push(h)}),e},[x]),q=c.useMemo(()=>new Map((g??[]).map(e=>[e.source,e])),[g]),R=c.useMemo(()=>L.CATEGORIES.filter(e=>e.key==="tool"?x.length>0||(g?.length??0)>0:w.length>0||!!k),[x.length,w.length,k,g?.length]),B=R.length===1?R[0].key:null,u=z??B,f=u?u==="subagent"?{title:"Sub-agent",onBack:B?void 0:()=>$(null)}:l?{title:_.toolSourceLabel(l),onBack:()=>A(null),icon:m.sourceIcon(l)}:{title:"Tools",onBack:B?void 0:()=>$(null)}:null,d=c.useMemo(()=>{if(!u)return R.map(t=>({id:t.key,label:t.label,drillsIn:!0,onActivate:()=>{$(t.key),A(null)}}));if(u==="subagent"){const t=y.trim().toLowerCase(),n=w.filter(s=>!t||I(s).toLowerCase().includes(t)).map(s=>({id:String(s.id),label:I(s),drillsIn:!1,onActivate:()=>j(s)}));return k&&n.push({id:W,label:"Create new",drillsIn:!1,isCreate:!0,onActivate:()=>{v?.(),k()}}),n}if(!l){const t=(g??[]).map(n=>n.source).filter(n=>!E.includes(n));return[...E,...t].sort((n,s)=>L.toolSourceRank(n)-L.toolSourceRank(s)).map(n=>{const s=q.get(n);return s?.connected===!1?{id:n,label:_.toolSourceLabel(n),drillsIn:!1,icon:m.sourceIcon(n)??s.icon,rightLabel:"Connect",onActivate:()=>{v?.(),s.onConnect?.()}}:{id:n,label:_.toolSourceLabel(n),drillsIn:!0,icon:m.sourceIcon(n)??s?.icon,onActivate:()=>A(n)}})}const e=y.trim().toLowerCase(),r=x.filter(t=>(S(t)?.source??"other")===l).filter(t=>!e||I(t).toLowerCase().includes(e)).map(t=>({id:String(t.id),label:I(t),drillsIn:!1,onActivate:()=>j(t)})),h=q.get(l);if(h){const t=l in L.CONFIG_TOOL_SOURCES;r.push({id:`create:${l}`,label:h.label,drillsIn:!1,isCreate:!t,onActivate:()=>{v?.(),h.onSelect()}})}return r},[u,R,l,y,x,w,E,j,v,k,g,q]);c.useEffect(()=>b(0),[u,l,y,o]),c.useEffect(()=>M(""),[u,l]);const T=c.useRef({rows:d,activeIndex:C,header:f});T.current={rows:d,activeIndex:C,header:f},c.useEffect(()=>{if(O)return O(e=>{const{rows:r,activeIndex:h,header:t}=T.current;switch(e.key){case"ArrowDown":return r.length&&b(n=>(n+1)%r.length),!0;case"ArrowUp":return r.length&&b(n=>(n+r.length-1)%r.length),!0;case"ArrowRight":case"Enter":return r[h]?.onActivate(),!0;case"ArrowLeft":return t?.onBack?(t.onBack(),!0):!1;default:return!1}}),()=>O(null)},[O]);const N=u?d.length&&!d[0].drillsIn?"items":"sources":"categories",U=u==="tool"&&!!l||u==="subagent";return a.jsxs(Y,{className:`bik-mention-picker bik-mention-picker--${N}`,children:[f&&a.jsxs(oe,{type:"button",onClick:f.onBack,disabled:!f.onBack,style:{background:i.COLORS.surface.subdued,cursor:f.onBack?"pointer":"default"},children:[f.onBack&&a.jsx(J.default,{width:20,height:20,color:i.COLORS.content.primary}),f.icon&&m.renderSourceIcon(f.icon),a.jsxs(P.TitleSmall,{children:[" ",f.title]})]}),U&&a.jsxs(Z,{children:[a.jsx(G.default,{width:20,height:20,color:i.COLORS.content.placeholder}),a.jsx(K,{autoFocus:!0,value:y,placeholder:"Search","data-test":"mention-picker-search",onChange:e=>M(e.target.value),onKeyDown:e=>{d.length&&(e.key==="ArrowDown"?(e.preventDefault(),b(r=>(r+1)%d.length)):e.key==="ArrowUp"?(e.preventDefault(),b(r=>(r+d.length-1)%d.length)):e.key==="Enter"&&(e.preventDefault(),d[C]?.onActivate()))}})]}),d.length===0?a.jsx(re,{children:u==="subagent"?"No sub-agents available":"No tools available"}):d.map((e,r)=>a.jsx(H,{type:"button",$active:r===C,onMouseEnter:()=>b(r),onClick:e.onActivate,children:e.isCreate?a.jsx(ne,{children:e.label}):a.jsxs(a.Fragment,{children:[a.jsxs(ee,{children:[m.renderSourceIcon(e.icon),a.jsx(P.BodySecondary,{color:i.COLORS.content.primary,children:e.label})]}),e.rightLabel?a.jsx(te,{children:e.rightLabel}):e.drillsIn&&a.jsx(F.default,{width:12,height:12})]})},e.id))]})},Y=p.default.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  min-width: 240px;
@@ -37,7 +37,7 @@
37
37
  height: 48px;
38
38
  border: none;
39
39
  border-bottom: 1px solid ${i.COLORS.stroke.primary};
40
- background: ${n=>n.$active?i.COLORS.surface.subdued:"transparent"};
40
+ background: ${o=>o.$active?i.COLORS.surface.subdued:"transparent"};
41
41
  cursor: pointer;
42
42
  text-align: left;
43
43
 
@@ -49,14 +49,21 @@
49
49
  align-items: center;
50
50
  gap: 12px;
51
51
  min-width: 0;
52
- `,te=p.default.div`
52
+ `,te=p.default.span`
53
+ flex-shrink: 0;
54
+ color: ${i.COLORS.content.brand};
55
+ font-family: Inter;
56
+ font-size: 14px;
57
+ font-weight: 600;
58
+ white-space: nowrap;
59
+ `,ne=p.default.div`
53
60
  width: 100%;
54
61
  text-align: center;
55
62
  color: ${i.COLORS.content.brand};
56
63
  font-family: Inter;
57
64
  font-size: 14px;
58
65
  font-weight: 600;
59
- `,ne=p.default.button`
66
+ `,oe=p.default.button`
60
67
  display: flex;
61
68
  align-items: center;
62
69
  padding: 12px 16px;
@@ -1 +1 @@
1
- {"version":3,"file":"MentionPicker.js","sources":["../../../../../src/components/agent-builder/components/MentionPicker.tsx"],"sourcesContent":["// import ChevronLeft from '@src/assets/icons/chevronLeft.svg';\nimport ChevronRight from '@src/assets/icons/chevronRight.svg';\nimport SearchIcon from '@src/assets/icons/searchIcon.svg';\nimport type { MentionDropdownRenderProps, MentionItem } from '@src/editor';\nimport SvgArrowLeft from '@src/icons/Arrows/Normal arrows/ArrowLeft';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { BodySecondary, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { CATEGORIES, CONFIG_TOOL_SOURCES } from '../constants/tools';\nimport type { Category, ToolAction } from '../constants/tools';\nimport {\n\tMentionKindMeta,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport { renderSourceIcon, sourceIcon, SourceIcon } from '../utils/sourceIcons';\n\nconst metaOf = (item: MentionItem): MentionKindMeta | undefined =>\n\titem.meta as unknown as MentionKindMeta | undefined;\n\nconst rowLabel = (item: MentionItem): string =>\n\tmetaOf(item)?.plainLabel ?? item.label;\n\n/** One navigable row in the picker's current view. */\ntype PickerRowModel = {\n\tid: string;\n\tlabel: string;\n\t/** Drill-in rows show a chevron; leaf (selectable) rows do not. */\n\tdrillsIn: boolean;\n\t/** Leading brand glyph (source rows only). */\n\ticon?: SourceIcon;\n\t/** Brand-coloured \"Create new\" action row (not a selectable item). */\n\tisCreate?: boolean;\n\tonActivate: () => void;\n};\n\n/** Sentinel id for the sub-agent \"Create new\" row. */\nconst CREATE_SUBAGENT_ID = '__bik_create_subagent__';\n\ntype MentionPickerProps = MentionDropdownRenderProps & {\n\t/** Opens the create-sub-agent drawer (shows a \"Create new\" row in the Sub-agent view). */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Open already drilled into this tool source (e.g. `'shopify'`) — its tool list\n\t * is shown immediately. */\n\tinitialSource?: string;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the Tools view.\n\t * Picking one opens its config drawer (via `onSelect`) and dismisses the picker\n\t * — it never inserts a mention into the text.\n\t */\n\ttoolActions?: ToolAction[];\n};\n\n/**\n * `@` reference picker. Drills:\n * root → Tools → <source> (Manifest / Shopify / …) → tool\n * → Sub-agent → sub-agent\n * (\"Add condition\" and \"Variables\" are intentionally not shown yet.)\n *\n * Owns keyboard navigation (↑/↓ move, →/Enter activate, ← go back) over the\n * CURRENTLY visible rows — registered with the editor via `registerKeyHandler`.\n */\nexport const MentionPicker: React.FC<MentionPickerProps> = ({\n\titems,\n\tonSelect,\n\tregisterKeyHandler,\n\tonClose,\n\tonCreateSubAgent,\n\tinitialSource,\n\ttoolActions,\n}) => {\n\tconst [category, setCategory] = useState<Category | null>(null);\n\tconst [source, setSource] = useState<string | null>(initialSource ?? null);\n\tconst [activeIndex, setActiveIndex] = useState(0);\n\t// Search box shown inside a source's tool list (Manifest / Shopify); filters\n\t// that source's tools by name.\n\tconst [search, setSearch] = useState('');\n\n\tconst tools = useMemo(\n\t\t() => items.filter((i) => metaOf(i)?.kind === 'tool'),\n\t\t[items],\n\t);\n\tconst subAgents = useMemo(\n\t\t() => items.filter((i) => metaOf(i)?.kind === 'subagent'),\n\t\t[items],\n\t);\n\tconst sources = useMemo(() => {\n\t\tconst acc: string[] = [];\n\t\ttools.forEach((t) => {\n\t\t\tconst s = metaOf(t)?.source ?? 'other';\n\t\t\tif (!acc.includes(s)) {\n\t\t\t\tacc.push(s);\n\t\t\t}\n\t\t});\n\t\treturn acc;\n\t}, [tools]);\n\t// The built-in \"create\" action per source (Rest API / email / Slack). A source\n\t// with an action drills into [its instances + a \"Create new\" row] — like the\n\t// Sub-agent category — instead of showing a duplicate flat \"create\" row.\n\tconst actionBySource = useMemo(\n\t\t() =>\n\t\t\tnew Map<string, ToolAction>(\n\t\t\t\t(toolActions ?? []).map((a) => [a.source, a]),\n\t\t\t),\n\t\t[toolActions],\n\t);\n\n\t// Show a category when it has items — and ALWAYS show Sub-agent when creating\n\t// one is possible, so an agent with no sub-agents yet still gets the root\n\t// \"Tools / Sub-agent\" choice (with a \"Create new\" inside). When only one is\n\t// available (e.g. the sub-agent drawer offers tools only) the selector is skipped.\n\tconst availableCategories = useMemo(\n\t\t() =>\n\t\t\tCATEGORIES.filter((c) =>\n\t\t\t\tc.key === 'tool'\n\t\t\t\t\t? tools.length > 0 || (toolActions?.length ?? 0) > 0\n\t\t\t\t\t: subAgents.length > 0 || !!onCreateSubAgent,\n\t\t\t),\n\t\t[tools.length, subAgents.length, onCreateSubAgent, toolActions?.length],\n\t);\n\tconst soleCategory =\n\t\tavailableCategories.length === 1 ? availableCategories[0].key : null;\n\tconst activeCategory = category ?? soleCategory;\n\n\t// Title shown above the current view. `onBack` is omitted at a root level (a\n\t// sole category has nowhere to go back to) — the header then shows as a plain\n\t// title. When `onBack` is set the header leads with a back arrow, followed by\n\t// the source icon in a source detail view: `[← back][icon][title]`.\n\tconst header: {\n\t\ttitle: string;\n\t\tonBack?: () => void;\n\t\ticon?: SourceIcon;\n\t} | null = !activeCategory\n\t\t? null\n\t\t: activeCategory === 'subagent'\n\t\t? // Always titled — with a back arrow only when the category chooser is above.\n\t\t {\n\t\t\t\ttitle: 'Sub-agent',\n\t\t\t\tonBack: soleCategory ? undefined : () => setCategory(null),\n\t\t }\n\t\t: source\n\t\t? {\n\t\t\t\ttitle: toolSourceLabel(source),\n\t\t\t\tonBack: () => setSource(null),\n\t\t\t\ticon: sourceIcon(source),\n\t\t }\n\t\t: // Always titled — matches the Sub-agent header; back arrow only when the\n\t\t // category chooser is above (i.e. not the sole category).\n\t\t {\n\t\t\t\ttitle: 'Tools',\n\t\t\t\tonBack: soleCategory ? undefined : () => setCategory(null),\n\t\t };\n\n\t// Build the navigable rows for the current view.\n\tconst rows: PickerRowModel[] = useMemo(() => {\n\t\tif (!activeCategory) {\n\t\t\treturn availableCategories.map((c) => ({\n\t\t\t\tid: c.key,\n\t\t\t\tlabel: c.label,\n\t\t\t\tdrillsIn: true,\n\t\t\t\tonActivate: () => {\n\t\t\t\t\tsetCategory(c.key);\n\t\t\t\t\tsetSource(null);\n\t\t\t\t},\n\t\t\t}));\n\t\t}\n\t\tif (activeCategory === 'subagent') {\n\t\t\tconst sq = search.trim().toLowerCase();\n\t\t\tconst leaves: PickerRowModel[] = subAgents\n\t\t\t\t.filter((item) => !sq || rowLabel(item).toLowerCase().includes(sq))\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tid: String(item.id),\n\t\t\t\t\tlabel: rowLabel(item),\n\t\t\t\t\tdrillsIn: false,\n\t\t\t\t\tonActivate: () => onSelect(item),\n\t\t\t\t}));\n\t\t\t// \"Create new\" opens the drawer — first dismiss the menu (strips the \"@\").\n\t\t\tif (onCreateSubAgent) {\n\t\t\t\tleaves.push({\n\t\t\t\t\tid: CREATE_SUBAGENT_ID,\n\t\t\t\t\tlabel: 'Create new',\n\t\t\t\t\tdrillsIn: false,\n\t\t\t\t\tisCreate: true,\n\t\t\t\t\tonActivate: () => {\n\t\t\t\t\t\tonClose?.();\n\t\t\t\t\t\tonCreateSubAgent();\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn leaves;\n\t\t}\n\t\tif (!source) {\n\t\t\t// One drill-in row per source: the real sources (from instances) plus any\n\t\t\t// action source (Rest API / email / Slack) with no instances yet, so it\n\t\t\t// still appears for first-time creation. Deduped — no more twin rows.\n\t\t\tconst actionOnly = (toolActions ?? [])\n\t\t\t\t.map((a) => a.source)\n\t\t\t\t.filter((s) => !sources.includes(s));\n\t\t\treturn [...sources, ...actionOnly].map((s) => ({\n\t\t\t\tid: s,\n\t\t\t\tlabel: toolSourceLabel(s),\n\t\t\t\tdrillsIn: true,\n\t\t\t\ticon: sourceIcon(s) ?? actionBySource.get(s)?.icon,\n\t\t\t\tonActivate: () => setSource(s),\n\t\t\t}));\n\t\t}\n\t\tconst q = search.trim().toLowerCase();\n\t\tconst leaves: PickerRowModel[] = tools\n\t\t\t.filter((t) => (metaOf(t)?.source ?? 'other') === source)\n\t\t\t.filter((t) => !q || rowLabel(t).toLowerCase().includes(q))\n\t\t\t.map((item) => ({\n\t\t\t\tid: String(item.id),\n\t\t\t\tlabel: rowLabel(item),\n\t\t\t\tdrillsIn: false,\n\t\t\t\tonActivate: () => onSelect(item),\n\t\t\t}));\n\t\t// A configurable source's add row, below any existing instances, opening\n\t\t// its drawer. Config tools (Slack / email) are a single fixed capability →\n\t\t// render like a normal tool leaf (label only, no icon — matching the tool\n\t\t// rows). Rest API instances are user-created, so its \"add\" stays a\n\t\t// brand-coloured create row.\n\t\tconst action = actionBySource.get(source);\n\t\tif (action) {\n\t\t\tconst isConfigTool = source in CONFIG_TOOL_SOURCES;\n\t\t\tleaves.push({\n\t\t\t\tid: `create:${source}`,\n\t\t\t\tlabel: action.label,\n\t\t\t\tdrillsIn: false,\n\t\t\t\tisCreate: !isConfigTool,\n\t\t\t\tonActivate: () => {\n\t\t\t\t\tonClose?.();\n\t\t\t\t\taction.onSelect();\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\treturn leaves;\n\t}, [\n\t\tactiveCategory,\n\t\tavailableCategories,\n\t\tsource,\n\t\tsearch,\n\t\ttools,\n\t\tsubAgents,\n\t\tsources,\n\t\tonSelect,\n\t\tonClose,\n\t\tonCreateSubAgent,\n\t\ttoolActions,\n\t\tactionBySource,\n\t]);\n\n\t// Reset highlight whenever the view (or filtered result set) changes.\n\tuseEffect(() => setActiveIndex(0), [activeCategory, source, search, items]);\n\t// Clear the search box when leaving a source view.\n\tuseEffect(() => setSearch(''), [activeCategory, source]);\n\n\t// Keep the latest rows/index reachable from the stable key handler.\n\tconst navRef = useRef({ rows, activeIndex, header });\n\tnavRef.current = { rows, activeIndex, header };\n\n\tuseEffect(() => {\n\t\tif (!registerKeyHandler) {\n\t\t\treturn;\n\t\t}\n\t\tregisterKeyHandler((event) => {\n\t\t\tconst { rows: r, activeIndex: i, header: h } = navRef.current;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tif (r.length) setActiveIndex((p) => (p + 1) % r.length);\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tif (r.length) setActiveIndex((p) => (p + r.length - 1) % r.length);\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'Enter':\n\t\t\t\t\tr[i]?.onActivate();\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (h?.onBack) {\n\t\t\t\t\t\th.onBack();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn () => registerKeyHandler(null);\n\t}, [registerKeyHandler]);\n\n\tconst variant = !activeCategory\n\t\t? 'categories'\n\t\t: rows.length && !rows[0].drillsIn\n\t\t? 'items'\n\t\t: 'sources';\n\n\t// Search lives inside a source's tool list (Manifest / Shopify) and in the\n\t// sub-agent list.\n\tconst showSearch =\n\t\t(activeCategory === 'tool' && !!source) || activeCategory === 'subagent';\n\n\treturn (\n\t\t<PickerCard className={`bik-mention-picker bik-mention-picker--${variant}`}>\n\t\t\t{header && (\n\t\t\t\t<PickerBack\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={header.onBack}\n\t\t\t\t\tdisabled={!header.onBack}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: COLORS.surface.subdued,\n\t\t\t\t\t\tcursor: header.onBack ? 'pointer' : 'default',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{header.onBack && (\n\t\t\t\t\t\t<SvgArrowLeft\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.primary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{header.icon && renderSourceIcon(header.icon)}\n\t\t\t\t\t<TitleSmall> {header.title}</TitleSmall>\n\t\t\t\t</PickerBack>\n\t\t\t)}\n\t\t\t{showSearch && (\n\t\t\t\t<PickerSearchRow>\n\t\t\t\t\t<SearchIcon\n\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\theight={20}\n\t\t\t\t\t\tcolor={COLORS.content.placeholder}\n\t\t\t\t\t/>\n\t\t\t\t\t<PickerSearchInput\n\t\t\t\t\t\t// Focus on open so the user can type immediately (appears only\n\t\t\t\t\t\t// after they drill into a source).\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\tvalue={search}\n\t\t\t\t\t\tplaceholder=\"Search\"\n\t\t\t\t\t\tdata-test=\"mention-picker-search\"\n\t\t\t\t\t\tonChange={(e) => setSearch(e.target.value)}\n\t\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\t\tif (!rows.length) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (e.key === 'ArrowDown') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\tsetActiveIndex((p) => (p + 1) % rows.length);\n\t\t\t\t\t\t\t} else if (e.key === 'ArrowUp') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\tsetActiveIndex((p) => (p + rows.length - 1) % rows.length);\n\t\t\t\t\t\t\t} else if (e.key === 'Enter') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\trows[activeIndex]?.onActivate();\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</PickerSearchRow>\n\t\t\t)}\n\t\t\t{rows.length === 0 ? (\n\t\t\t\t<PickerEmpty>\n\t\t\t\t\t{activeCategory === 'subagent'\n\t\t\t\t\t\t? 'No sub-agents available'\n\t\t\t\t\t\t: 'No tools available'}\n\t\t\t\t</PickerEmpty>\n\t\t\t) : (\n\t\t\t\trows.map((row, i) => (\n\t\t\t\t\t<PickerRow\n\t\t\t\t\t\tkey={row.id}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t$active={i === activeIndex}\n\t\t\t\t\t\tonMouseEnter={() => setActiveIndex(i)}\n\t\t\t\t\t\tonClick={row.onActivate}\n\t\t\t\t\t>\n\t\t\t\t\t\t{row.isCreate ? (\n\t\t\t\t\t\t\t<CreateRowText>{row.label}</CreateRowText>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<PickerRowMain>\n\t\t\t\t\t\t\t\t\t{renderSourceIcon(row.icon)}\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t\t{row.label}\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t</PickerRowMain>\n\t\t\t\t\t\t\t\t{row.drillsIn && <ChevronRight width={12} height={12} />}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</PickerRow>\n\t\t\t\t))\n\t\t\t)}\n\t\t</PickerCard>\n\t);\n};\n\nconst PickerCard = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tmin-width: 240px;\n\tmax-height: 301px;\n\toverflow-y: auto;\n\tbackground: ${COLORS.surface.standard};\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\tbox-shadow: 0px -2px 8px 0px #0000001f;\n`;\n\n// Search box at the top of a source's tool list (Manifest / Shopify).\nconst PickerSearchRow = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tpadding: 10px 12px;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n`;\n\nconst PickerSearchInput = styled.input`\n\tflex: 1;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tbackground: transparent;\n\tfont-family: Inter;\n\tfont-size: 14px;\n\tcolor: ${COLORS.content.primary};\n\n\t&::placeholder {\n\t\tcolor: ${COLORS.content.placeholder};\n\t}\n`;\n\nconst PickerRow = styled.button<{ $active?: boolean }>`\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tgap: 2px;\n\twidth: 100%;\n\tpadding: 8px 10px;\n\theight: 48px;\n\tborder: none;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n\tbackground: ${(p) => (p.$active ? COLORS.surface.subdued : 'transparent')};\n\tcursor: pointer;\n\ttext-align: left;\n\n\t&:hover {\n\t\tbackground: ${COLORS.surface.subdued};\n\t}\n`;\n\n// Left cluster: leading source glyph + label (chevron stays right via PickerRow).\nconst PickerRowMain = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n\tmin-width: 0;\n`;\n\n// \"Create new\" — centered brand text, no icon (matches the side-panel dropdown).\nconst CreateRowText = styled.div`\n\twidth: 100%;\n\ttext-align: center;\n\tcolor: ${COLORS.content.brand};\n\tfont-family: Inter;\n\tfont-size: 14px;\n\tfont-weight: 600;\n`;\n\nconst PickerBack = styled.button`\n\tdisplay: flex;\n\talign-items: center;\n\tpadding: 12px 16px;\n\tborder: none;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n\tbackground: transparent;\n\tcursor: pointer;\n\tfont-family: Inter;\n\tfont-size: 12px;\n\tfont-weight: 600;\n\theight: 48px;\n\tgap: 4px;\n`;\n\nconst PickerEmpty = styled.div`\n\tpadding: 12px 10px;\n\tfont-family: Inter;\n\tfont-size: 13px;\n\tcolor: ${COLORS.content.secondary};\n`;\n"],"names":["metaOf","item","rowLabel","CREATE_SUBAGENT_ID","MentionPicker","items","onSelect","registerKeyHandler","onClose","onCreateSubAgent","initialSource","toolActions","category","setCategory","useState","source","setSource","activeIndex","setActiveIndex","search","setSearch","tools","useMemo","i","subAgents","sources","acc","t","s","actionBySource","a","availableCategories","CATEGORIES","c","soleCategory","activeCategory","header","toolSourceLabel","sourceIcon","rows","sq","leaves","actionOnly","q","action","isConfigTool","CONFIG_TOOL_SOURCES","useEffect","navRef","useRef","event","h","p","variant","showSearch","jsxs","PickerCard","PickerBack","COLORS","jsx","SvgArrowLeft","renderSourceIcon","TitleSmall","PickerSearchRow","SearchIcon","PickerSearchInput","PickerEmpty","row","PickerRow","CreateRowText","Fragment","PickerRowMain","BodySecondary","ChevronRight","styled"],"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sourcesContent":["// import ChevronLeft from '@src/assets/icons/chevronLeft.svg';\nimport ChevronRight from '@src/assets/icons/chevronRight.svg';\nimport SearchIcon from '@src/assets/icons/searchIcon.svg';\nimport type { MentionDropdownRenderProps, MentionItem } from '@src/editor';\nimport SvgArrowLeft from '@src/icons/Arrows/Normal arrows/ArrowLeft';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { BodySecondary, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tCATEGORIES,\n\tCONFIG_TOOL_SOURCES,\n\ttoolSourceRank,\n} from '../constants/tools';\nimport type { Category, ToolAction } from '../constants/tools';\nimport {\n\tMentionKindMeta,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport { renderSourceIcon, sourceIcon, SourceIcon } from '../utils/sourceIcons';\n\nconst metaOf = (item: MentionItem): MentionKindMeta | undefined =>\n\titem.meta as unknown as MentionKindMeta | undefined;\n\nconst rowLabel = (item: MentionItem): string =>\n\tmetaOf(item)?.plainLabel ?? item.label;\n\n/** One navigable row in the picker's current view. */\ntype PickerRowModel = {\n\tid: string;\n\tlabel: string;\n\t/** Drill-in rows show a chevron; leaf (selectable) rows do not. */\n\tdrillsIn: boolean;\n\t/** Leading brand glyph (source rows only). */\n\ticon?: SourceIcon;\n\t/** Brand-coloured \"Create new\" action row (not a selectable item). */\n\tisCreate?: boolean;\n\t/**\n\t * Brand-coloured right-aligned action text (e.g. \"Connect\") shown in place of\n\t * the drill-in chevron — used for an unconnected integration source.\n\t */\n\trightLabel?: string;\n\tonActivate: () => void;\n};\n\n/** Sentinel id for the sub-agent \"Create new\" row. */\nconst CREATE_SUBAGENT_ID = '__bik_create_subagent__';\n\ntype MentionPickerProps = MentionDropdownRenderProps & {\n\t/** Opens the create-sub-agent drawer (shows a \"Create new\" row in the Sub-agent view). */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Open already drilled into this tool source (e.g. `'shopify'`) — its tool list\n\t * is shown immediately. */\n\tinitialSource?: string;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the Tools view.\n\t * Picking one opens its config drawer (via `onSelect`) and dismisses the picker\n\t * — it never inserts a mention into the text.\n\t */\n\ttoolActions?: ToolAction[];\n};\n\n/**\n * `@` reference picker. Drills:\n * root → Tools → <source> (Manifest / Shopify / …) → tool\n * → Sub-agent → sub-agent\n * (\"Add condition\" and \"Variables\" are intentionally not shown yet.)\n *\n * Owns keyboard navigation (↑/↓ move, →/Enter activate, ← go back) over the\n * CURRENTLY visible rows — registered with the editor via `registerKeyHandler`.\n */\nexport const MentionPicker: React.FC<MentionPickerProps> = ({\n\titems,\n\tonSelect,\n\tregisterKeyHandler,\n\tonClose,\n\tonCreateSubAgent,\n\tinitialSource,\n\ttoolActions,\n}) => {\n\tconst [category, setCategory] = useState<Category | null>(null);\n\tconst [source, setSource] = useState<string | null>(initialSource ?? null);\n\tconst [activeIndex, setActiveIndex] = useState(0);\n\t// Search box shown inside a source's tool list (Manifest / Shopify); filters\n\t// that source's tools by name.\n\tconst [search, setSearch] = useState('');\n\n\tconst tools = useMemo(\n\t\t() => items.filter((i) => metaOf(i)?.kind === 'tool'),\n\t\t[items],\n\t);\n\tconst subAgents = useMemo(\n\t\t() => items.filter((i) => metaOf(i)?.kind === 'subagent'),\n\t\t[items],\n\t);\n\tconst sources = useMemo(() => {\n\t\tconst acc: string[] = [];\n\t\ttools.forEach((t) => {\n\t\t\tconst s = metaOf(t)?.source ?? 'other';\n\t\t\tif (!acc.includes(s)) {\n\t\t\t\tacc.push(s);\n\t\t\t}\n\t\t});\n\t\treturn acc;\n\t}, [tools]);\n\t// The built-in \"create\" action per source (Rest API / email / Slack). A source\n\t// with an action drills into [its instances + a \"Create new\" row] — like the\n\t// Sub-agent category — instead of showing a duplicate flat \"create\" row.\n\tconst actionBySource = useMemo(\n\t\t() =>\n\t\t\tnew Map<string, ToolAction>(\n\t\t\t\t(toolActions ?? []).map((a) => [a.source, a]),\n\t\t\t),\n\t\t[toolActions],\n\t);\n\n\t// Show a category when it has items — and ALWAYS show Sub-agent when creating\n\t// one is possible, so an agent with no sub-agents yet still gets the root\n\t// \"Tools / Sub-agent\" choice (with a \"Create new\" inside). When only one is\n\t// available (e.g. the sub-agent drawer offers tools only) the selector is skipped.\n\tconst availableCategories = useMemo(\n\t\t() =>\n\t\t\tCATEGORIES.filter((c) =>\n\t\t\t\tc.key === 'tool'\n\t\t\t\t\t? tools.length > 0 || (toolActions?.length ?? 0) > 0\n\t\t\t\t\t: subAgents.length > 0 || !!onCreateSubAgent,\n\t\t\t),\n\t\t[tools.length, subAgents.length, onCreateSubAgent, toolActions?.length],\n\t);\n\tconst soleCategory =\n\t\tavailableCategories.length === 1 ? availableCategories[0].key : null;\n\tconst activeCategory = category ?? soleCategory;\n\n\t// Title shown above the current view. `onBack` is omitted at a root level (a\n\t// sole category has nowhere to go back to) — the header then shows as a plain\n\t// title. When `onBack` is set the header leads with a back arrow, followed by\n\t// the source icon in a source detail view: `[← back][icon][title]`.\n\tconst header: {\n\t\ttitle: string;\n\t\tonBack?: () => void;\n\t\ticon?: SourceIcon;\n\t} | null = !activeCategory\n\t\t? null\n\t\t: activeCategory === 'subagent'\n\t\t? // Always titled — with a back arrow only when the category chooser is above.\n\t\t {\n\t\t\t\ttitle: 'Sub-agent',\n\t\t\t\tonBack: soleCategory ? undefined : () => setCategory(null),\n\t\t }\n\t\t: source\n\t\t? {\n\t\t\t\ttitle: toolSourceLabel(source),\n\t\t\t\tonBack: () => setSource(null),\n\t\t\t\ticon: sourceIcon(source),\n\t\t }\n\t\t: // Always titled — matches the Sub-agent header; back arrow only when the\n\t\t // category chooser is above (i.e. not the sole category).\n\t\t {\n\t\t\t\ttitle: 'Tools',\n\t\t\t\tonBack: soleCategory ? undefined : () => setCategory(null),\n\t\t };\n\n\t// Build the navigable rows for the current view.\n\tconst rows: PickerRowModel[] = useMemo(() => {\n\t\tif (!activeCategory) {\n\t\t\treturn availableCategories.map((c) => ({\n\t\t\t\tid: c.key,\n\t\t\t\tlabel: c.label,\n\t\t\t\tdrillsIn: true,\n\t\t\t\tonActivate: () => {\n\t\t\t\t\tsetCategory(c.key);\n\t\t\t\t\tsetSource(null);\n\t\t\t\t},\n\t\t\t}));\n\t\t}\n\t\tif (activeCategory === 'subagent') {\n\t\t\tconst sq = search.trim().toLowerCase();\n\t\t\tconst leaves: PickerRowModel[] = subAgents\n\t\t\t\t.filter((item) => !sq || rowLabel(item).toLowerCase().includes(sq))\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tid: String(item.id),\n\t\t\t\t\tlabel: rowLabel(item),\n\t\t\t\t\tdrillsIn: false,\n\t\t\t\t\tonActivate: () => onSelect(item),\n\t\t\t\t}));\n\t\t\t// \"Create new\" opens the drawer — first dismiss the menu (strips the \"@\").\n\t\t\tif (onCreateSubAgent) {\n\t\t\t\tleaves.push({\n\t\t\t\t\tid: CREATE_SUBAGENT_ID,\n\t\t\t\t\tlabel: 'Create new',\n\t\t\t\t\tdrillsIn: false,\n\t\t\t\t\tisCreate: true,\n\t\t\t\t\tonActivate: () => {\n\t\t\t\t\t\tonClose?.();\n\t\t\t\t\t\tonCreateSubAgent();\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn leaves;\n\t\t}\n\t\tif (!source) {\n\t\t\t// One drill-in row per source: the real sources (from instances) plus any\n\t\t\t// action source (Rest API / email / Slack) with no instances yet, so it\n\t\t\t// still appears for first-time creation. Deduped — no more twin rows.\n\t\t\tconst actionOnly = (toolActions ?? [])\n\t\t\t\t.map((a) => a.source)\n\t\t\t\t.filter((s) => !sources.includes(s));\n\t\t\t// Fixed source order (manifest → shopify → rest_api → email → slack →\n\t\t\t// rest) so adding/updating a tool never reshuffles the picker rows.\n\t\t\treturn [...sources, ...actionOnly]\n\t\t\t\t.sort((a, b) => toolSourceRank(a) - toolSourceRank(b))\n\t\t\t\t.map((s) => {\n\t\t\t\t\tconst action = actionBySource.get(s);\n\t\t\t\t\t// Integration not connected → a \"Connect\" row (no drill-in / no\n\t\t\t\t\t// instances / no \"Create new\"); clicking dismisses the picker and\n\t\t\t\t\t// runs the consumer's connect flow.\n\t\t\t\t\tif (action?.connected === false) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: s,\n\t\t\t\t\t\t\tlabel: toolSourceLabel(s),\n\t\t\t\t\t\t\tdrillsIn: false,\n\t\t\t\t\t\t\ticon: sourceIcon(s) ?? action.icon,\n\t\t\t\t\t\t\trightLabel: 'Connect',\n\t\t\t\t\t\t\tonActivate: () => {\n\t\t\t\t\t\t\t\tonClose?.();\n\t\t\t\t\t\t\t\taction.onConnect?.();\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\treturn {\n\t\t\t\t\t\tid: s,\n\t\t\t\t\t\tlabel: toolSourceLabel(s),\n\t\t\t\t\t\tdrillsIn: true,\n\t\t\t\t\t\ticon: sourceIcon(s) ?? action?.icon,\n\t\t\t\t\t\tonActivate: () => setSource(s),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t}\n\t\tconst q = search.trim().toLowerCase();\n\t\tconst leaves: PickerRowModel[] = tools\n\t\t\t.filter((t) => (metaOf(t)?.source ?? 'other') === source)\n\t\t\t.filter((t) => !q || rowLabel(t).toLowerCase().includes(q))\n\t\t\t.map((item) => ({\n\t\t\t\tid: String(item.id),\n\t\t\t\tlabel: rowLabel(item),\n\t\t\t\tdrillsIn: false,\n\t\t\t\tonActivate: () => onSelect(item),\n\t\t\t}));\n\t\t// A configurable source's add row, below any existing instances, opening\n\t\t// its drawer. Config tools (Slack / email) are a single fixed capability →\n\t\t// render like a normal tool leaf (label only, no icon — matching the tool\n\t\t// rows). Rest API instances are user-created, so its \"add\" stays a\n\t\t// brand-coloured create row.\n\t\tconst action = actionBySource.get(source);\n\t\tif (action) {\n\t\t\tconst isConfigTool = source in CONFIG_TOOL_SOURCES;\n\t\t\tleaves.push({\n\t\t\t\tid: `create:${source}`,\n\t\t\t\tlabel: action.label,\n\t\t\t\tdrillsIn: false,\n\t\t\t\tisCreate: !isConfigTool,\n\t\t\t\tonActivate: () => {\n\t\t\t\t\tonClose?.();\n\t\t\t\t\taction.onSelect();\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t\treturn leaves;\n\t}, [\n\t\tactiveCategory,\n\t\tavailableCategories,\n\t\tsource,\n\t\tsearch,\n\t\ttools,\n\t\tsubAgents,\n\t\tsources,\n\t\tonSelect,\n\t\tonClose,\n\t\tonCreateSubAgent,\n\t\ttoolActions,\n\t\tactionBySource,\n\t]);\n\n\t// Reset highlight whenever the view (or filtered result set) changes.\n\tuseEffect(() => setActiveIndex(0), [activeCategory, source, search, items]);\n\t// Clear the search box when leaving a source view.\n\tuseEffect(() => setSearch(''), [activeCategory, source]);\n\n\t// Keep the latest rows/index reachable from the stable key handler.\n\tconst navRef = useRef({ rows, activeIndex, header });\n\tnavRef.current = { rows, activeIndex, header };\n\n\tuseEffect(() => {\n\t\tif (!registerKeyHandler) {\n\t\t\treturn;\n\t\t}\n\t\tregisterKeyHandler((event) => {\n\t\t\tconst { rows: r, activeIndex: i, header: h } = navRef.current;\n\t\t\tswitch (event.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tif (r.length) setActiveIndex((p) => (p + 1) % r.length);\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tif (r.length) setActiveIndex((p) => (p + r.length - 1) % r.length);\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'Enter':\n\t\t\t\t\tr[i]?.onActivate();\n\t\t\t\t\treturn true;\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (h?.onBack) {\n\t\t\t\t\t\th.onBack();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn () => registerKeyHandler(null);\n\t}, [registerKeyHandler]);\n\n\tconst variant = !activeCategory\n\t\t? 'categories'\n\t\t: rows.length && !rows[0].drillsIn\n\t\t? 'items'\n\t\t: 'sources';\n\n\t// Search lives inside a source's tool list (Manifest / Shopify) and in the\n\t// sub-agent list.\n\tconst showSearch =\n\t\t(activeCategory === 'tool' && !!source) || activeCategory === 'subagent';\n\n\treturn (\n\t\t<PickerCard className={`bik-mention-picker bik-mention-picker--${variant}`}>\n\t\t\t{header && (\n\t\t\t\t<PickerBack\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={header.onBack}\n\t\t\t\t\tdisabled={!header.onBack}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: COLORS.surface.subdued,\n\t\t\t\t\t\tcursor: header.onBack ? 'pointer' : 'default',\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{header.onBack && (\n\t\t\t\t\t\t<SvgArrowLeft\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.primary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{header.icon && renderSourceIcon(header.icon)}\n\t\t\t\t\t<TitleSmall> {header.title}</TitleSmall>\n\t\t\t\t</PickerBack>\n\t\t\t)}\n\t\t\t{showSearch && (\n\t\t\t\t<PickerSearchRow>\n\t\t\t\t\t<SearchIcon\n\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\theight={20}\n\t\t\t\t\t\tcolor={COLORS.content.placeholder}\n\t\t\t\t\t/>\n\t\t\t\t\t<PickerSearchInput\n\t\t\t\t\t\t// Focus on open so the user can type immediately (appears only\n\t\t\t\t\t\t// after they drill into a source).\n\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\tvalue={search}\n\t\t\t\t\t\tplaceholder=\"Search\"\n\t\t\t\t\t\tdata-test=\"mention-picker-search\"\n\t\t\t\t\t\tonChange={(e) => setSearch(e.target.value)}\n\t\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\t\tif (!rows.length) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (e.key === 'ArrowDown') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\tsetActiveIndex((p) => (p + 1) % rows.length);\n\t\t\t\t\t\t\t} else if (e.key === 'ArrowUp') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\tsetActiveIndex((p) => (p + rows.length - 1) % rows.length);\n\t\t\t\t\t\t\t} else if (e.key === 'Enter') {\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\trows[activeIndex]?.onActivate();\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</PickerSearchRow>\n\t\t\t)}\n\t\t\t{rows.length === 0 ? (\n\t\t\t\t<PickerEmpty>\n\t\t\t\t\t{activeCategory === 'subagent'\n\t\t\t\t\t\t? 'No sub-agents available'\n\t\t\t\t\t\t: 'No tools available'}\n\t\t\t\t</PickerEmpty>\n\t\t\t) : (\n\t\t\t\trows.map((row, i) => (\n\t\t\t\t\t<PickerRow\n\t\t\t\t\t\tkey={row.id}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t$active={i === activeIndex}\n\t\t\t\t\t\tonMouseEnter={() => setActiveIndex(i)}\n\t\t\t\t\t\tonClick={row.onActivate}\n\t\t\t\t\t>\n\t\t\t\t\t\t{row.isCreate ? (\n\t\t\t\t\t\t\t<CreateRowText>{row.label}</CreateRowText>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<PickerRowMain>\n\t\t\t\t\t\t\t\t\t{renderSourceIcon(row.icon)}\n\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\t\t{row.label}\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t</PickerRowMain>\n\t\t\t\t\t\t\t\t{row.rightLabel ? (\n\t\t\t\t\t\t\t\t\t<RightActionText>{row.rightLabel}</RightActionText>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\trow.drillsIn && <ChevronRight width={12} height={12} />\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</PickerRow>\n\t\t\t\t))\n\t\t\t)}\n\t\t</PickerCard>\n\t);\n};\n\nconst PickerCard = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tmin-width: 240px;\n\tmax-height: 301px;\n\toverflow-y: auto;\n\tbackground: ${COLORS.surface.standard};\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tborder-radius: 4px;\n\tbox-shadow: 0px -2px 8px 0px #0000001f;\n`;\n\n// Search box at the top of a source's tool list (Manifest / Shopify).\nconst PickerSearchRow = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tpadding: 10px 12px;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n`;\n\nconst PickerSearchInput = styled.input`\n\tflex: 1;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tbackground: transparent;\n\tfont-family: Inter;\n\tfont-size: 14px;\n\tcolor: ${COLORS.content.primary};\n\n\t&::placeholder {\n\t\tcolor: ${COLORS.content.placeholder};\n\t}\n`;\n\nconst PickerRow = styled.button<{ $active?: boolean }>`\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tgap: 2px;\n\twidth: 100%;\n\tpadding: 8px 10px;\n\theight: 48px;\n\tborder: none;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n\tbackground: ${(p) => (p.$active ? COLORS.surface.subdued : 'transparent')};\n\tcursor: pointer;\n\ttext-align: left;\n\n\t&:hover {\n\t\tbackground: ${COLORS.surface.subdued};\n\t}\n`;\n\n// Left cluster: leading source glyph + label (chevron stays right via PickerRow).\nconst PickerRowMain = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 12px;\n\tmin-width: 0;\n`;\n\n// Right-aligned brand action text (e.g. \"Connect\") in place of the chevron.\nconst RightActionText = styled.span`\n\tflex-shrink: 0;\n\tcolor: ${COLORS.content.brand};\n\tfont-family: Inter;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\twhite-space: nowrap;\n`;\n\n// \"Create new\" — centered brand text, no icon (matches the side-panel dropdown).\nconst CreateRowText = styled.div`\n\twidth: 100%;\n\ttext-align: center;\n\tcolor: ${COLORS.content.brand};\n\tfont-family: Inter;\n\tfont-size: 14px;\n\tfont-weight: 600;\n`;\n\nconst PickerBack = styled.button`\n\tdisplay: flex;\n\talign-items: center;\n\tpadding: 12px 16px;\n\tborder: none;\n\tborder-bottom: 1px solid ${COLORS.stroke.primary};\n\tbackground: transparent;\n\tcursor: pointer;\n\tfont-family: Inter;\n\tfont-size: 12px;\n\tfont-weight: 600;\n\theight: 48px;\n\tgap: 4px;\n`;\n\nconst PickerEmpty = styled.div`\n\tpadding: 12px 10px;\n\tfont-family: Inter;\n\tfont-size: 13px;\n\tcolor: ${COLORS.content.secondary};\n`;\n"],"names":["metaOf","item","rowLabel","CREATE_SUBAGENT_ID","MentionPicker","items","onSelect","registerKeyHandler","onClose","onCreateSubAgent","initialSource","toolActions","category","setCategory","useState","source","setSource","activeIndex","setActiveIndex","search","setSearch","tools","useMemo","i","subAgents","sources","acc","t","s","actionBySource","a","availableCategories","CATEGORIES","c","soleCategory","activeCategory","header","toolSourceLabel","sourceIcon","rows","sq","leaves","actionOnly","b","toolSourceRank","action","q","isConfigTool","CONFIG_TOOL_SOURCES","useEffect","navRef","useRef","event","h","p","variant","showSearch","jsxs","PickerCard","PickerBack","COLORS","jsx","SvgArrowLeft","renderSourceIcon","TitleSmall","PickerSearchRow","SearchIcon","PickerSearchInput","PickerEmpty","row","PickerRow","CreateRowText","Fragment","PickerRowMain","BodySecondary","RightActionText","ChevronRight","styled"],"mappings":"qlBAqBMA,EAAUC,GACfA,EAAK,KAEAC,EAAYD,GACjBD,EAAOC,CAAI,GAAG,YAAcA,EAAK,MAqB5BE,EAAqB,0BA0BdC,EAA8C,CAAC,CAC3D,MAAAC,EACA,SAAAC,EACA,mBAAAC,EACA,QAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,YAAAC,CACD,IAAM,CACL,KAAM,CAACC,EAAUC,CAAW,EAAIC,EAAAA,SAA0B,IAAI,EACxD,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAwBJ,GAAiB,IAAI,EACnE,CAACO,EAAaC,CAAc,EAAIJ,EAAAA,SAAS,CAAC,EAG1C,CAACK,EAAQC,CAAS,EAAIN,EAAAA,SAAS,EAAE,EAEjCO,EAAQC,EAAAA,QACb,IAAMjB,EAAM,OAAQkB,GAAMvB,EAAOuB,CAAC,GAAG,OAAS,MAAM,EACpD,CAAClB,CAAK,CAAA,EAEDmB,EAAYF,EAAAA,QACjB,IAAMjB,EAAM,OAAQkB,GAAMvB,EAAOuB,CAAC,GAAG,OAAS,UAAU,EACxD,CAAClB,CAAK,CAAA,EAEDoB,EAAUH,EAAAA,QAAQ,IAAM,CAC7B,MAAMI,EAAgB,CAAA,EACtBL,OAAAA,EAAM,QAASM,GAAM,CACpB,MAAMC,EAAI5B,EAAO2B,CAAC,GAAG,QAAU,QAC1BD,EAAI,SAASE,CAAC,GAClBF,EAAI,KAAKE,CAAC,CAEZ,CAAC,EACMF,CACR,EAAG,CAACL,CAAK,CAAC,EAIJQ,EAAiBP,EAAAA,QACtB,IACC,IAAI,KACFX,GAAe,CAAA,GAAI,IAAKmB,GAAM,CAACA,EAAE,OAAQA,CAAC,CAAC,CAAA,EAE9C,CAACnB,CAAW,CAAA,EAOPoB,EAAsBT,EAAAA,QAC3B,IACCU,EAAAA,WAAW,OAAQ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Q,OAAO;AAAA;AAAA,EAKhCa,GAAgBI,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAQvBF,GAAkBE,EAAAA,QAAO;AAAA;AAAA,UAErBjB,EAAAA,OAAO,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxBW,GAAgBM,EAAAA,QAAO;AAAA;AAAA;AAAA,UAGnBjB,EAAAA,OAAO,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,EAMxBD,GAAakB,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,4BAKEjB,EAAAA,OAAO,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU3CQ,GAAcS,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA,UAIjBjB,EAAAA,OAAO,QAAQ,SAAS;AAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=[{key:"tool",label:"Tools"},{key:"subagent",label:"Sub-agent"}];var e=(a=>(a.Manifest="manifest",a.Shopify="shopify",a.Integration="integration",a.RestApi="rest_api",a.EmailHandover="email_handover",a.Slack="slack",a))(e||{});const s={manifest:"Manifest",shopify:"Shopify",integration:"Integration",rest_api:"Rest API",email_handover:"Email",slack:"Slack"},n={rest_api:"REST API",email_handover:"Handover to email",slack:"Send Slack message"},i=["rest_api","email_handover","slack"],O={email_handover:"send_email",slack:"send_slack_message"};exports.CATEGORIES=t;exports.CONFIG_TOOL_SOURCES=O;exports.TOOL_ACTION_LABELS=n;exports.TOOL_ACTION_SOURCES=i;exports.TOOL_SOURCE_LABELS=s;exports.ToolSource=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=[{key:"tool",label:"Tools"},{key:"subagent",label:"Sub-agent"}];var t=(e=>(e.Manifest="manifest",e.Shopify="shopify",e.Integration="integration",e.RestApi="rest_api",e.EmailHandover="email_handover",e.Slack="slack",e))(t||{});const n={manifest:"Manifest",shopify:"Shopify",integration:"Integration",rest_api:"Rest API",email_handover:"Email",slack:"Slack"},O={rest_api:"REST API",email_handover:"Handover to email",slack:"Send Slack message"},_=["rest_api","email_handover","slack"],a={manifest:0,shopify:1,rest_api:2,email_handover:3,slack:4},i=Object.keys(a).length,l=e=>a[e]??i,o={email_handover:"send_email",slack:"send_slack_message"};exports.CATEGORIES=s;exports.CONFIG_TOOL_SOURCES=o;exports.TOOL_ACTION_LABELS=O;exports.TOOL_ACTION_SOURCES=_;exports.TOOL_SOURCE_LABELS=n;exports.TOOL_SOURCE_RANK=a;exports.ToolSource=t;exports.toolSourceRank=l;
2
2
  //# sourceMappingURL=tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { FunctionComponent, SVGAttributes } from 'react';\nimport type { ConfigToolKey } from '../AgentBuilder.model';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Handover to email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","CONFIG_TOOL_SOURCES"],"mappings":"gFAcO,MAAMA,EAAiD,CAC7D,CAAE,IAAK,OAAQ,MAAO,OAAA,EACtB,CAAE,IAAK,WAAY,MAAO,WAAA,CAC3B,EAYO,IAAKC,GAAAA,IACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,cACdA,EAAA,QAAU,WACVA,EAAA,cAAgB,iBAChBA,EAAA,MAAQ,QANGA,IAAAA,GAAA,CAAA,CAAA,EAiBL,MAAMC,EAAiD,CAC5D,SAAsB,WACtB,QAAqB,UACrB,YAAyB,cACzB,SAAqB,WACrB,eAA2B,QAC3B,MAAmB,OACrB,EAQaC,EAA0D,CACrE,SAAqB,WACrB,eAA2B,oBAC3B,MAAmB,oBACrB,EA2BaC,EAAoC,CAChD,WACA,iBACA,OACD,EAMaC,EAAkE,CAC7E,eAA2B,aAC3B,MAAmB,oBACrB"}
1
+ {"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { FunctionComponent, SVGAttributes } from 'react';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Handover to email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n\t/**\n\t * Integration connection state for this source. `undefined` = no connection\n\t * gating (default). `false` = the store hasn't connected this integration →\n\t * the `@` picker shows a \"Connect\" row that calls {@link onConnect} instead of\n\t * drilling in / offering \"Create new\". `true` = connected (renders normally).\n\t * Set by the consumer via `config.integrationStatus` (today: Slack only).\n\t */\n\tconnected?: boolean;\n\t/** Open the parent's connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Fixed display rank for the `@`-picker's tool-source groups (lower = higher). The\n * picker sorts its source rows by this so adding/updating a tool never reshuffles\n * them. Any source not listed here (dynamic/unknown, e.g. Integration) sorts AFTER\n * Slack, keeping its discovery order among the rest (Array.sort is stable).\n */\nexport const TOOL_SOURCE_RANK: Partial<Record<ToolSource, number>> = {\n\t[ToolSource.Manifest]: 0,\n\t[ToolSource.Shopify]: 1,\n\t[ToolSource.RestApi]: 2,\n\t[ToolSource.EmailHandover]: 3,\n\t[ToolSource.Slack]: 4,\n};\n\nconst UNRANKED_SOURCE_RANK = Object.keys(TOOL_SOURCE_RANK).length;\n\n/** Sort rank for a source string; unknown sources rank after all known ones. */\nexport const toolSourceRank = (source: string): number =>\n\tTOOL_SOURCE_RANK[source as ToolSource] ?? UNRANKED_SOURCE_RANK;\n\n/**\n * `tool_key` of a configurable shared-drawer tool (email / Slack). Lives here (not\n * in AgentBuilder.model) so this leaf constants file has no back-edge to the model\n * — the dependency stays one-way (model → constants), avoiding a circular import.\n */\nexport type ConfigToolKey = 'send_email' | 'send_slack_message';\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","TOOL_SOURCE_RANK","UNRANKED_SOURCE_RANK","toolSourceRank","source","CONFIG_TOOL_SOURCES"],"mappings":"gFAaO,MAAMA,EAAiD,CAC7D,CAAE,IAAK,OAAQ,MAAO,OAAA,EACtB,CAAE,IAAK,WAAY,MAAO,WAAA,CAC3B,EAYO,IAAKC,GAAAA,IACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UACVA,EAAA,YAAc,cACdA,EAAA,QAAU,WACVA,EAAA,cAAgB,iBAChBA,EAAA,MAAQ,QANGA,IAAAA,GAAA,CAAA,CAAA,EAiBL,MAAMC,EAAiD,CAC5D,SAAsB,WACtB,QAAqB,UACrB,YAAyB,cACzB,SAAqB,WACrB,eAA2B,QAC3B,MAAmB,OACrB,EAQaC,EAA0D,CACrE,SAAqB,WACrB,eAA2B,oBAC3B,MAAmB,oBACrB,EAqCaC,EAAoC,CAChD,WACA,iBACA,OACD,EAQaC,EAAwD,CACnE,SAAsB,EACtB,QAAqB,EACrB,SAAqB,EACrB,eAA2B,EAC3B,MAAmB,CACrB,EAEMC,EAAuB,OAAO,KAAKD,CAAgB,EAAE,OAG9CE,EAAkBC,GAC9BH,EAAiBG,CAAoB,GAAKF,EAa9BG,EAAkE,CAC7E,eAA2B,aAC3B,MAAmB,oBACrB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lt=require("react/jsx-runtime"),s=require("react"),at=require("../constants/charLimits.js"),g=require("../constants/steps.js"),dt=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},gt=dt(s),nt=gt.default.createContext(null),ft=()=>{const t=s.useContext(nt);if(!t)throw new Error("useAgentBuilderContext must be used within an AgentBuilderProvider");return t},mt=(t,r)=>{const d=t.trigger.mode==="custom_intent"?(t.trigger.custom_intent??"").trim().length>0:t.trigger.intents.length>0;return{about:t.name.trim().length>0&&t.name.length<=r.name&&t.description.length<=r.description,trigger:d,response:t.instructions.trim().length>0||(t.guardrail??"").trim().length>0,handover:!0}},Rt=({value:t,onChange:r,activeStep:d,onStepChange:x,availableTools:f,availableSubAgents:m,availableIntents:A,availableModels:k,configToolTemplates:_,validation:E,applicationType:M,charLimits:P,disableStepNavigation:h=!0,onCreateSubAgent:B,onFetchSubAgent:q,onUpdateSubAgent:j,onImproveSubAgent:y,onImproveToolInstructions:F,children:ot})=>{const[rt,ct]=s.useState("about"),R=d??rt,i=g.getStepIndex(R),K=s.useRef(t);K.current=t;const[L,$]=s.useState(0),T=s.useRef({}),Y=s.useRef("instructions"),w=s.useCallback((e,n)=>{n?T.current[e]=n:delete T.current[e]},[]),H=s.useCallback(e=>{Y.current=e},[]),I=s.useRef(null),V=s.useCallback(e=>{I.current=e},[]),D=s.useCallback(()=>{I.current?.()},[]),G=s.useRef(null),N=s.useCallback(e=>{G.current=e},[]),U=s.useCallback(e=>{G.current?.(e)},[]),z=s.useCallback((e,n,c)=>{const l=T.current;(l[Y.current]??l.instructions)?.(e,n,c)},[]),[J,C]=s.useState(null),b=s.useRef(null),Q=s.useRef(0),u=s.useCallback(e=>{d===void 0&&ct(e),x?.(e)},[d,x]),W=s.useCallback(()=>{const e=g.STEP_KEYS[Math.min(i+1,g.STEP_KEYS.length-1)];u(e)},[i,u]),X=s.useCallback(()=>{const e=g.STEP_KEYS[Math.max(i-1,0)];u(e)},[i,u]),Z=s.useCallback(e=>r(e),[r]),O=s.useCallback((e,n)=>r({[e]:n}),[r]),v=s.useCallback((e,n)=>{const c=K.current;e==="tool"?!((c.configTools??[]).some(a=>a.id===n)||(c.restApiTools??[]).some(a=>a.id===n))&&!c.tools.includes(n)&&r({tools:[...c.tools,n]}):c.subagents.includes(n)||r({subagents:[...c.subagents,n]})},[r]),tt=s.useCallback((e,n)=>{const c=e==="tool"?`{{tool:${n}}}`:`{{subagent:${n}}}`,l=o=>o.split(c).join("");b.current={tools:t.tools,subagents:t.subagents,configTools:t.configTools,restApiTools:t.restApiTools,instructions:t.instructions,guardrail:t.guardrail};const a={instructions:l(t.instructions),guardrail:l(t.guardrail??""),...e==="tool"?{tools:t.tools.filter(o=>o!==n),configTools:(t.configTools??[]).filter(o=>o.id!==n),restApiTools:(t.restApiTools??[]).filter(o=>o.id!==n)}:{subagents:t.subagents.filter(o=>o!==n)}};r(a),$(o=>o+1);const ut=e==="tool"?f.find(o=>o.tool_id===n)?.display_name??(t.restApiTools??[]).find(o=>o.id===n)?.name??"Tool":m.find(o=>o.id===n)?.name??"Sub-agent";Q.current+=1,C({id:Q.current,message:`${e==="tool"?"Tool":"Sub-agent"} "${ut}" removed`})},[f,m,t,r]),et=s.useCallback(()=>{b.current&&(r(b.current),b.current=null,$(e=>e+1)),C(null)},[r]),st=s.useCallback(()=>C(null),[]),p=s.useMemo(()=>({...at.AGENT_CHAR_LIMITS,...P}),[P]),S=s.useMemo(()=>({...mt(t,p),...E}),[t,p,E]),it=s.useMemo(()=>({value:t,patch:Z,updateField:O,addReference:v,removeReference:tt,mentionResetKey:L,insertMention:z,registerMentionField:w,notifyMentionFocus:H,undoToast:J,undoRemoval:et,dismissUndo:st,activeStep:R,activeIndex:i,goToStep:u,goNext:W,goPrev:X,isFirstStep:i===0,isLastStep:i===g.STEP_KEYS.length-1,validation:S,isActiveStepValid:S[R],availableTools:f,availableSubAgents:m,availableIntents:A,availableModels:k,configToolTemplates:_,applicationType:M,charLimits:p,disableStepNavigation:h,onCreateSubAgent:B,registerSubAgentCreator:V,requestCreateSubAgent:D,registerToolActionHandler:N,requestToolAction:U,onFetchSubAgent:q,onUpdateSubAgent:j,onImproveSubAgent:y,onImproveToolInstructions:F}),[t,Z,O,v,tt,L,z,w,H,J,et,st,R,i,u,W,X,S,f,m,A,k,_,M,p,h,B,V,D,N,U,q,j,y,F]);return lt.jsx(nt.Provider,{value:it,children:ot})};exports.AgentBuilderProvider=Rt;exports.useAgentBuilderContext=ft;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const at=require("react/jsx-runtime"),s=require("react"),ft=require("../constants/charLimits.js"),f=require("../constants/steps.js"),gt=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},mt=gt(s),rt=mt.default.createContext(null),Rt=()=>{const t=s.useContext(rt);if(!t)throw new Error("useAgentBuilderContext must be used within an AgentBuilderProvider");return t},bt=(t,r)=>{const a=t.trigger.mode==="custom_intent"?(t.trigger.custom_intent??"").trim().length>0:t.trigger.intents.length>0;return{about:t.name.trim().length>0&&t.name.length<=r.name&&t.description.length<=r.description,trigger:a,response:t.instructions.trim().length>0||(t.guardrail??"").trim().length>0,handover:!0}},pt=({value:t,onChange:r,activeStep:a,onStepChange:S,availableTools:g,availableSubAgents:m,availableIntents:A,availableModels:k,configToolTemplates:_,integrationStatus:E,onConnectIntegration:M,validation:P,applicationType:h,charLimits:B,disableStepNavigation:q=!0,onCreateSubAgent:j,onFetchSubAgent:y,onUpdateSubAgent:F,onImproveSubAgent:K,onImproveToolInstructions:L,children:ct})=>{const[it,ut]=s.useState("about"),R=a??it,i=f.getStepIndex(R),$=s.useRef(t);$.current=t;const[Y,w]=s.useState(0),T=s.useRef({}),H=s.useRef("instructions"),V=s.useCallback((e,o)=>{o?T.current[e]=o:delete T.current[e]},[]),I=s.useCallback(e=>{H.current=e},[]),D=s.useRef(null),G=s.useCallback(e=>{D.current=e},[]),N=s.useCallback(()=>{D.current?.()},[]),U=s.useRef(null),z=s.useCallback(e=>{U.current=e},[]),J=s.useCallback(e=>{U.current?.(e)},[]),Q=s.useCallback((e,o,c)=>{const l=T.current;(l[H.current]??l.instructions)?.(e,o,c)},[]),[W,x]=s.useState(null),b=s.useRef(null),X=s.useRef(0),u=s.useCallback(e=>{a===void 0&&ut(e),S?.(e)},[a,S]),Z=s.useCallback(()=>{const e=f.STEP_KEYS[Math.min(i+1,f.STEP_KEYS.length-1)];u(e)},[i,u]),O=s.useCallback(()=>{const e=f.STEP_KEYS[Math.max(i-1,0)];u(e)},[i,u]),v=s.useCallback(e=>r(e),[r]),tt=s.useCallback((e,o)=>r({[e]:o}),[r]),et=s.useCallback((e,o)=>{const c=$.current;e==="tool"?!((c.configTools??[]).some(d=>d.id===o)||(c.restApiTools??[]).some(d=>d.id===o))&&!c.tools.includes(o)&&r({tools:[...c.tools,o]}):c.subagents.includes(o)||r({subagents:[...c.subagents,o]})},[r]),st=s.useCallback((e,o)=>{const c=e==="tool"?`{{tool:${o}}}`:`{{subagent:${o}}}`,l=n=>n.split(c).join("");b.current={tools:t.tools,subagents:t.subagents,configTools:t.configTools,restApiTools:t.restApiTools,instructions:t.instructions,guardrail:t.guardrail};const d={instructions:l(t.instructions),guardrail:l(t.guardrail??""),...e==="tool"?{tools:t.tools.filter(n=>n!==o),configTools:(t.configTools??[]).filter(n=>n.id!==o),restApiTools:(t.restApiTools??[]).filter(n=>n.id!==o)}:{subagents:t.subagents.filter(n=>n!==o)}};r(d),w(n=>n+1);const dt=e==="tool"?g.find(n=>n.tool_id===o)?.display_name??(t.restApiTools??[]).find(n=>n.id===o)?.name??"Tool":m.find(n=>n.id===o)?.name??"Sub-agent";X.current+=1,x({id:X.current,message:`${e==="tool"?"Tool":"Sub-agent"} "${dt}" removed`})},[g,m,t,r]),ot=s.useCallback(()=>{b.current&&(r(b.current),b.current=null,w(e=>e+1)),x(null)},[r]),nt=s.useCallback(()=>x(null),[]),p=s.useMemo(()=>({...ft.AGENT_CHAR_LIMITS,...B}),[B]),C=s.useMemo(()=>({...bt(t,p),...P}),[t,p,P]),lt=s.useMemo(()=>({value:t,patch:v,updateField:tt,addReference:et,removeReference:st,mentionResetKey:Y,insertMention:Q,registerMentionField:V,notifyMentionFocus:I,undoToast:W,undoRemoval:ot,dismissUndo:nt,activeStep:R,activeIndex:i,goToStep:u,goNext:Z,goPrev:O,isFirstStep:i===0,isLastStep:i===f.STEP_KEYS.length-1,validation:C,isActiveStepValid:C[R],availableTools:g,availableSubAgents:m,availableIntents:A,availableModels:k,configToolTemplates:_,integrationStatus:E,onConnectIntegration:M,applicationType:h,charLimits:p,disableStepNavigation:q,onCreateSubAgent:j,registerSubAgentCreator:G,requestCreateSubAgent:N,registerToolActionHandler:z,requestToolAction:J,onFetchSubAgent:y,onUpdateSubAgent:F,onImproveSubAgent:K,onImproveToolInstructions:L}),[t,v,tt,et,st,Y,Q,V,I,W,ot,nt,R,i,u,Z,O,C,g,m,A,k,_,E,M,h,p,q,j,G,N,z,J,y,F,K,L]);return at.jsx(rt.Provider,{value:lt,children:ct})};exports.AgentBuilderProvider=pt;exports.useAgentBuilderContext=Rt;
2
2
  //# sourceMappingURL=AgentBuilderContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tConfigToolKey,\n\tIntentOption,\n\tModelOption,\n\tParamsBlob,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\nimport type { ToolSource } from '../constants/tools';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/**\n\t * Backend templates for the shared-drawer tools (email / Slack), keyed by\n\t * `tool_key`. A present key drives its dynamic form + enables its tool action.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/**\n\t * Step 3 registers its \"open the drawer for this built-in tool action\"\n\t * (Rest API / email handover / Slack) handler here so the `@` reference picker\n\t * can trigger it. Pass `null` to unregister.\n\t */\n\tregisterToolActionHandler: (\n\t\tfn: ((source: ToolSource) => void) | null,\n\t) => void;\n\t/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */\n\trequestToolAction: (source: ToolSource) => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / email-handover tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tconfigToolTemplates,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tonImproveToolInstructions,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\n\t// Step 3 registers a dispatcher that opens a built-in tool action's drawer.\n\tconst toolActionHandlerRef = useRef<((source: ToolSource) => void) | null>(\n\t\tnull,\n\t);\n\tconst registerToolActionHandler = useCallback(\n\t\t(fn: ((source: ToolSource) => void) | null) => {\n\t\t\ttoolActionHandlerRef.current = fn;\n\t\t},\n\t\t[],\n\t);\n\tconst requestToolAction = useCallback((source: ToolSource) => {\n\t\ttoolActionHandlerRef.current?.(source);\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\t// Custom tools (Rest API / email / Slack) track themselves on their own\n\t\t\t\t// lists; only catalog/native ids belong in `tools`. Picking an EXISTING\n\t\t\t\t// custom tool from the `@` picker must not leak its id in here — on save\n\t\t\t\t// it becomes a bogus native ref and create-agent validation rejects it.\n\t\t\t\tconst isCustom =\n\t\t\t\t\t(v.configTools ?? []).some((t) => t.id === id) ||\n\t\t\t\t\t(v.restApiTools ?? []).some((t) => t.id === id);\n\t\t\t\tif (!isCustom && !v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot every field a removal touches, for undo. Custom tools (Rest\n\t\t\t// API / email / Slack) live on their own lists, so include them too.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tconfigTools: value.configTools,\n\t\t\t\trestApiTools: value.restApiTools,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t// A tool id may be a catalog tool OR an inline custom tool — drop\n\t\t\t\t\t\t\t// it from whichever list holds it (the others are no-op filters).\n\t\t\t\t\t\t\ttools: value.tools.filter((t) => t !== id),\n\t\t\t\t\t\t\tconfigTools: (value.configTools ?? []).filter((t) => t.id !== id),\n\t\t\t\t\t\t\trestApiTools: (value.restApiTools ?? []).filter(\n\t\t\t\t\t\t\t\t(t) => t.id !== id,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\t\t\t (value.restApiTools ?? []).find((t) => t.id === id)?.name ??\n\t\t\t\t\t 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","toolActionHandlerRef","registerToolActionHandler","requestToolAction","source","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","addReference","v","t","removeReference","token","strip","text","s","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":"uRAwJMA,GACLC,GAAAA,QAAM,cAA+C,IAAI,EAE7CC,GAAyB,IAAgC,CACrE,MAAMC,EAAMC,EAAAA,WAAWJ,EAAmB,EAC1C,GAAI,CAACG,EACJ,MAAM,IAAI,MACT,oEAAA,EAGF,OAAOA,CACR,EAGME,GAAmB,CACxBC,EACAC,IACoB,CACpB,MAAMC,EACLF,EAAM,QAAQ,OAAS,iBACnBA,EAAM,QAAQ,eAAiB,IAAI,KAAA,EAAO,OAAS,EACpDA,EAAM,QAAQ,QAAQ,OAAS,EAEnC,MAAO,CACN,MACCA,EAAM,KAAK,KAAA,EAAO,OAAS,GAC3BA,EAAM,KAAK,QAAUC,EAAO,MAC5BD,EAAM,YAAY,QAAUC,EAAO,YACpC,QAASC,EAET,SACCF,EAAM,aAAa,KAAA,EAAO,OAAS,IAClCA,EAAM,WAAa,IAAI,KAAA,EAAO,OAAS,EAEzC,SAAU,EAAA,CAEZ,EA2BaG,GAAgD,CAAC,CAC7D,MAAAH,EACA,SAAAI,EACA,WAAYC,EACZ,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAYC,EACZ,g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ACAC,EACA6B,EACAE,EACAG,EACAqB,EACA1E,EACAC,EACAC,EACAC,EACAC,EACAE,EACAiE,EACA/D,EACAC,EACAwB,EACAC,EACAE,EACAC,EACA3B,EACAC,EACAC,EACAC,CAAA,CACD,EAGD,cACE1B,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAAwB,GACF,CAEF"}
1
+ {"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tConfigToolKey,\n\tIntentOption,\n\tModelOption,\n\tParamsBlob,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\nimport type { ToolSource } from '../constants/tools';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/**\n\t * Backend templates for the shared-drawer tools (email / Slack), keyed by\n\t * `tool_key`. A present key drives its dynamic form + enables its tool action.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/**\n\t * Per-source integration connection state (today: Slack). A source mapped to\n\t * `false` renders a \"Connect\" row in the `@` picker instead of drilling in;\n\t * `true`/absent renders normally. Fed by the consumer via `integrationStatus`.\n\t */\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\t/** Open the consumer's connect flow for an unconnected integration source. */\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/**\n\t * Step 3 registers its \"open the drawer for this built-in tool action\"\n\t * (Rest API / email handover / Slack) handler here so the `@` reference picker\n\t * can trigger it. Pass `null` to unregister.\n\t */\n\tregisterToolActionHandler: (\n\t\tfn: ((source: ToolSource) => void) | null,\n\t) => void;\n\t/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */\n\trequestToolAction: (source: ToolSource) => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / email-handover tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tconfigToolTemplates,\n\tintegrationStatus,\n\tonConnectIntegration,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tonImproveToolInstructions,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\n\t// Step 3 registers a dispatcher that opens a built-in tool action's drawer.\n\tconst toolActionHandlerRef = useRef<((source: ToolSource) => void) | null>(\n\t\tnull,\n\t);\n\tconst registerToolActionHandler = useCallback(\n\t\t(fn: ((source: ToolSource) => void) | null) => {\n\t\t\ttoolActionHandlerRef.current = fn;\n\t\t},\n\t\t[],\n\t);\n\tconst requestToolAction = useCallback((source: ToolSource) => {\n\t\ttoolActionHandlerRef.current?.(source);\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\t// Custom tools (Rest API / email / Slack) track themselves on their own\n\t\t\t\t// lists; only catalog/native ids belong in `tools`. Picking an EXISTING\n\t\t\t\t// custom tool from the `@` picker must not leak its id in here — on save\n\t\t\t\t// it becomes a bogus native ref and create-agent validation rejects it.\n\t\t\t\tconst isCustom =\n\t\t\t\t\t(v.configTools ?? []).some((t) => t.id === id) ||\n\t\t\t\t\t(v.restApiTools ?? []).some((t) => t.id === id);\n\t\t\t\tif (!isCustom && !v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot every field a removal touches, for undo. Custom tools (Rest\n\t\t\t// API / email / Slack) live on their own lists, so include them too.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tconfigTools: value.configTools,\n\t\t\t\trestApiTools: value.restApiTools,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t// A tool id may be a catalog tool OR an inline custom tool — drop\n\t\t\t\t\t\t\t// it from whichever list holds it (the others are no-op filters).\n\t\t\t\t\t\t\ttools: value.tools.filter((t) => t !== id),\n\t\t\t\t\t\t\tconfigTools: (value.configTools ?? []).filter((t) => t.id !== id),\n\t\t\t\t\t\t\trestApiTools: (value.restApiTools ?? []).filter(\n\t\t\t\t\t\t\t\t(t) => t.id !== id,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\t\t\t (value.restApiTools ?? []).find((t) => t.id === id)?.name ??\n\t\t\t\t\t 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","onConnectIntegration","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","toolActionHandlerRef","registerToolActionHandler","requestToolAction","source","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","addReference","v","t","removeReference","token","strip","text","s","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":"uRAgKMA,GACLC,GAAAA,QAAM,cAA+C,IAAI,EAE7CC,GAAyB,IAAgC,CACrE,MAAMC,EAAMC,EAAAA,WAAWJ,EAAmB,EAC1C,GAAI,CAACG,EACJ,MAAM,IAAI,MACT,oEAAA,EAGF,OAAOA,CACR,EAGME,GAAmB,CACxBC,EACAC,IACoB,CACpB,MAAMC,EACLF,EAAM,QAAQ,OAAS,iBACnBA,EAAM,QAAQ,eAAiB,IAAI,KAAA,EAAO,OAAS,EACpDA,EAAM,QAAQ,QAAQ,OAAS,EAEnC,MAAO,CACN,MACCA,EAAM,KAAK,KAAA,EAAO,OAAS,GAC3BA,EAAM,KAAK,QAAUC,EAAO,MAC5BD,EAAM,YAAY,QAAUC,EAAO,YACpC,QAASC,EAET,SACCF,EAAM,aAAa,KAAA,EAAO,OAAS,IAClCA,EAAM,WAAa,IAAI,KAAA,EAAO,OAAS,EAEzC,SAAU,EAAA,CAEZ,EA6BaG,GAAgD,CAAC,CAC7D,MAAAH,EACA,SAAAI,EACA,WAAYC,EACZ,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,WAAYC,EACZ,gBAAAC,EACA,WAAYC,EACZ,sBAAAC,EAAwB,GACxB,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,0BAAAC,EACA,SAAAC,EACD,IAAM,CACL,KAAM,CAACC,GAAcC,EAAe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,EACAC,EACAC,CAAA,CACD,EAGD,cACE5B,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAA0B,GACF,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../constants/tools.js"),n=require("./sourceIcons.js"),S=(e,l)=>t.TOOL_ACTION_SOURCES.filter(o=>{const O=t.CONFIG_TOOL_SOURCES[o];return!O||!!e?.[O]}).map(o=>({source:o,label:t.TOOL_ACTION_LABELS[o]??t.TOOL_SOURCE_LABELS[o],icon:n.SOURCE_ICONS[o],onSelect:()=>l(o)}));exports.buildToolActions=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../constants/tools.js"),i=require("./sourceIcons.js"),c=(O,e,l,S)=>t.TOOL_ACTION_SOURCES.filter(o=>{const n=t.CONFIG_TOOL_SOURCES[o];return!n||!!O?.[n]}).map(o=>({source:o,label:t.TOOL_ACTION_LABELS[o]??t.TOOL_SOURCE_LABELS[o],icon:i.SOURCE_ICONS[o],onSelect:()=>e(o),connected:l?.[o],onConnect:()=>S?.(o)}));exports.buildToolActions=c;
2
2
  //# sourceMappingURL=toolActions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolActions.js","sources":["../../../../../src/components/agent-builder/utils/toolActions.ts"],"sourcesContent":["import { ConfigToolKey, ParamsBlob } from '../AgentBuilder.model';\nimport {\n\tCONFIG_TOOL_SOURCES,\n\tTOOL_ACTION_LABELS,\n\tTOOL_ACTION_SOURCES,\n\tTOOL_SOURCE_LABELS,\n\tToolAction,\n\tToolSource,\n} from '../constants/tools';\nimport { SOURCE_ICONS } from './sourceIcons';\n\n/**\n * Single source of truth for the built-in tool \"action\" list (Rest API / email /\n * Slack) shown in the `@` picker AND the Step-3 / sub-agent Tools panel. A config\n * tool (email / Slack) is offered only when its backend template was provided.\n * The category name comes from `TOOL_SOURCE_LABELS`; the addable-action name from\n * `TOOL_ACTION_LABELS`. Consumers pass only how to open the drawer (`onSelect`) so\n * every surface renders identical actions/labels.\n */\nexport const buildToolActions = (\n\tconfigToolTemplates: Partial<Record<ConfigToolKey, ParamsBlob>> | undefined,\n\tonSelect: (source: ToolSource) => void,\n): ToolAction[] =>\n\tTOOL_ACTION_SOURCES.filter((source) => {\n\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\treturn !toolKey || Boolean(configToolTemplates?.[toolKey]);\n\t}).map((source) => ({\n\t\tsource,\n\t\tlabel: TOOL_ACTION_LABELS[source] ?? TOOL_SOURCE_LABELS[source],\n\t\ticon: SOURCE_ICONS[source],\n\t\tonSelect: () => onSelect(source),\n\t}));\n"],"names":["buildToolActions","configToolTemplates","onSelect","TOOL_ACTION_SOURCES","source","toolKey","CONFIG_TOOL_SOURCES","TOOL_ACTION_LABELS","TOOL_SOURCE_LABELS","SOURCE_ICONS"],"mappings":"uJAmBaA,EAAmB,CAC/BC,EACAC,IAEAC,EAAAA,oBAAoB,OAAQC,GAAW,CACtC,MAAMC,EAAUC,EAAAA,oBAAoBF,CAAM,EAC1C,MAAO,CAACC,GAAW,EAAQJ,IAAsBI,CAAO,CACzD,CAAC,EAAE,IAAKD,IAAY,CACnB,OAAAA,EACA,MAAOG,EAAAA,mBAAmBH,CAAM,GAAKI,EAAAA,mBAAmBJ,CAAM,EAC9D,KAAMK,EAAAA,aAAaL,CAAM,EACzB,SAAU,IAAMF,EAASE,CAAM,CAChC,EAAE"}
1
+ {"version":3,"file":"toolActions.js","sources":["../../../../../src/components/agent-builder/utils/toolActions.ts"],"sourcesContent":["import { ConfigToolKey, ParamsBlob } from '../AgentBuilder.model';\nimport {\n\tCONFIG_TOOL_SOURCES,\n\tTOOL_ACTION_LABELS,\n\tTOOL_ACTION_SOURCES,\n\tTOOL_SOURCE_LABELS,\n\tToolAction,\n\tToolSource,\n} from '../constants/tools';\nimport { SOURCE_ICONS } from './sourceIcons';\n\n/**\n * Single source of truth for the built-in tool \"action\" list (Rest API / email /\n * Slack) shown in the `@` picker AND the Step-3 / sub-agent Tools panel. A config\n * tool (email / Slack) is offered only when its backend template was provided.\n * The category name comes from `TOOL_SOURCE_LABELS`; the addable-action name from\n * `TOOL_ACTION_LABELS`. Consumers pass only how to open the drawer (`onSelect`) so\n * every surface renders identical actions/labels.\n */\nexport const buildToolActions = (\n\tconfigToolTemplates: Partial<Record<ConfigToolKey, ParamsBlob>> | undefined,\n\tonSelect: (source: ToolSource) => void,\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>,\n\tonConnect?: (source: ToolSource) => void,\n): ToolAction[] =>\n\tTOOL_ACTION_SOURCES.filter((source) => {\n\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\treturn !toolKey || Boolean(configToolTemplates?.[toolKey]);\n\t}).map((source) => ({\n\t\tsource,\n\t\tlabel: TOOL_ACTION_LABELS[source] ?? TOOL_SOURCE_LABELS[source],\n\t\ticon: SOURCE_ICONS[source],\n\t\tonSelect: () => onSelect(source),\n\t\t// `undefined` unless the consumer reports this source's connection state,\n\t\t// in which case `false` makes the picker render a \"Connect\" row.\n\t\tconnected: integrationStatus?.[source],\n\t\tonConnect: () => onConnect?.(source),\n\t}));\n"],"names":["buildToolActions","configToolTemplates","onSelect","integrationStatus","onConnect","TOOL_ACTION_SOURCES","source","toolKey","CONFIG_TOOL_SOURCES","TOOL_ACTION_LABELS","TOOL_SOURCE_LABELS","SOURCE_ICONS"],"mappings":"uJAmBaA,EAAmB,CAC/BC,EACAC,EACAC,EACAC,IAEAC,EAAAA,oBAAoB,OAAQC,GAAW,CACtC,MAAMC,EAAUC,EAAAA,oBAAoBF,CAAM,EAC1C,MAAO,CAACC,GAAW,EAAQN,IAAsBM,CAAO,CACzD,CAAC,EAAE,IAAKD,IAAY,CACnB,OAAAA,EACA,MAAOG,EAAAA,mBAAmBH,CAAM,GAAKI,EAAAA,mBAAmBJ,CAAM,EAC9D,KAAMK,EAAAA,aAAaL,CAAM,EACzB,SAAU,IAAMJ,EAASI,CAAM,EAG/B,UAAWH,IAAoBG,CAAM,EACrC,UAAW,IAAMF,IAAYE,CAAM,CACpC,EAAE"}