@bikdotai/bik-component-library 0.0.839-beta.6 → 0.0.839

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 (153) hide show
  1. package/dist/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js +1 -1
  2. package/dist/cjs/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  4. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +20 -44
  6. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js +1 -1
  8. package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js +1 -1
  10. package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +2 -2
  12. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
  14. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/DiscardModal.js +1 -1
  16. package/dist/cjs/components/agent-builder/components/DiscardModal.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
  18. package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
  20. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/components/MentionPicker.js +13 -13
  22. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  23. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +4 -4
  24. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  25. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +6 -6
  26. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  27. package/dist/cjs/components/agent-builder/components/StepSectionHeader.js +1 -1
  28. package/dist/cjs/components/agent-builder/components/StepSectionHeader.js.map +1 -1
  29. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  30. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  31. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  32. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  33. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +1 -3
  34. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  35. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  36. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  37. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
  38. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  39. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +3 -5
  40. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  41. package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
  42. package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
  43. package/dist/cjs/components/agent-listing/AgentTable.js +1 -1
  44. package/dist/cjs/components/agent-listing/AgentTable.js.map +1 -1
  45. package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
  46. package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
  47. package/dist/cjs/components/agent-listing/DeleteAgentModal.js +1 -1
  48. package/dist/cjs/components/agent-listing/DeleteAgentModal.js.map +1 -1
  49. package/dist/cjs/components/button/Button.styled.js +0 -1
  50. package/dist/cjs/components/button/Button.styled.js.map +1 -1
  51. package/dist/cjs/components/button/themes.js +11 -11
  52. package/dist/cjs/components/button/themes.js.map +1 -1
  53. package/dist/cjs/components/dropdown/Dropdown.js +1 -1
  54. package/dist/cjs/components/dropdown/Dropdown.js.map +1 -1
  55. package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
  56. package/dist/cjs/components/dropdown-button/DropdownButton.js.map +1 -1
  57. package/dist/cjs/editor/BikEditor.js +1 -1
  58. package/dist/cjs/editor/BikEditor.js.map +1 -1
  59. package/dist/cjs/editor/BikEditor.styles.js +54 -97
  60. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  61. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js +3 -3
  62. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  63. package/dist/cjs/icons/Media/Visual/FormkitNeutral.js +2 -0
  64. package/dist/cjs/icons/Media/Visual/FormkitNeutral.js.map +1 -0
  65. package/dist/cjs/icons/Media/Visual/FormkitSad.js +2 -0
  66. package/dist/cjs/icons/Media/Visual/FormkitSad.js.map +1 -0
  67. package/dist/cjs/icons/index.js +1 -1
  68. package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js +66 -61
  69. package/dist/esm/components/BikGiftedChat/GiftedChat/GiftedChat.js.map +1 -1
  70. package/dist/esm/components/agent-builder/AgentBuilder.js +102 -106
  71. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  72. package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -3
  73. package/dist/esm/components/agent-builder/AgentBuilder.styled.js +82 -110
  74. package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  75. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +21 -29
  76. package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
  77. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +26 -27
  78. package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
  79. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +25 -25
  80. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  81. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +23 -24
  82. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  83. package/dist/esm/components/agent-builder/components/DiscardModal.d.ts +1 -3
  84. package/dist/esm/components/agent-builder/components/DiscardModal.js +16 -25
  85. package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
  86. package/dist/esm/components/agent-builder/components/GoLiveModal.js +34 -36
  87. package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
  88. package/dist/esm/components/agent-builder/components/MentionEditor.js +19 -19
  89. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  90. package/dist/esm/components/agent-builder/components/MentionPicker.js +60 -64
  91. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  92. package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +0 -2
  93. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +105 -111
  94. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  95. package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +4 -13
  96. package/dist/esm/components/agent-builder/components/SelectableListSection.js +148 -173
  97. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  98. package/dist/esm/components/agent-builder/components/StepSectionHeader.js +7 -7
  99. package/dist/esm/components/agent-builder/components/StepSectionHeader.js.map +1 -1
  100. package/dist/esm/components/agent-builder/constants/tools.js +1 -1
  101. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  102. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +103 -104
  103. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  104. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +98 -102
  105. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  106. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +142 -144
  107. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  108. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +79 -23
  109. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  110. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +23 -35
  111. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  112. package/dist/esm/components/agent-listing/AgentListing.js +65 -70
  113. package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
  114. package/dist/esm/components/agent-listing/AgentTable.d.ts +0 -2
  115. package/dist/esm/components/agent-listing/AgentTable.js +15 -16
  116. package/dist/esm/components/agent-listing/AgentTable.js.map +1 -1
  117. package/dist/esm/components/agent-listing/AgentTableRow.js +11 -11
  118. package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
  119. package/dist/esm/components/agent-listing/DeleteAgentModal.js +8 -8
  120. package/dist/esm/components/agent-listing/DeleteAgentModal.js.map +1 -1
  121. package/dist/esm/components/button/Button.styled.js +19 -25
  122. package/dist/esm/components/button/Button.styled.js.map +1 -1
  123. package/dist/esm/components/button/themes.d.ts +1 -0
  124. package/dist/esm/components/button/themes.js +61 -51
  125. package/dist/esm/components/button/themes.js.map +1 -1
  126. package/dist/esm/components/dropdown/Dropdown.js +13 -18
  127. package/dist/esm/components/dropdown/Dropdown.js.map +1 -1
  128. package/dist/esm/components/dropdown-button/DropdownButton.js +13 -13
  129. package/dist/esm/components/dropdown-button/DropdownButton.js.map +1 -1
  130. package/dist/esm/editor/BikEditor.js +160 -173
  131. package/dist/esm/editor/BikEditor.js.map +1 -1
  132. package/dist/esm/editor/BikEditor.styles.d.ts +3 -20
  133. package/dist/esm/editor/BikEditor.styles.js +57 -102
  134. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  135. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.d.ts +8 -5
  136. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +68 -87
  137. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -1
  138. package/dist/esm/icons/Media/Visual/FormkitNeutral.js +58 -0
  139. package/dist/esm/icons/Media/Visual/FormkitNeutral.js.map +1 -0
  140. package/dist/esm/icons/Media/Visual/FormkitSad.js +61 -0
  141. package/dist/esm/icons/Media/Visual/FormkitSad.js.map +1 -0
  142. package/dist/esm/icons/Media/Visual/index.d.ts +2 -0
  143. package/dist/esm/icons/index.d.ts +25 -25
  144. package/dist/esm/icons/index.js +420 -416
  145. package/dist/esm/icons/index.js.map +1 -1
  146. package/package.json +1 -1
  147. package/dist/cjs/components/agent-listing/AgentTableShimmer.js +0 -2
  148. package/dist/cjs/components/agent-listing/AgentTableShimmer.js.map +0 -1
  149. package/dist/esm/components/agent-builder/__fixtures__/agentValue.d.ts +0 -11
  150. package/dist/esm/components/agent-listing/AgentTableShimmer.d.ts +0 -12
  151. package/dist/esm/components/agent-listing/AgentTableShimmer.js +0 -20
  152. package/dist/esm/components/agent-listing/AgentTableShimmer.js.map +0 -1
  153. package/dist/esm/components/agent-listing/__fixtures__/agents.d.ts +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"StepSectionHeader.js","sources":["../../../../../src/components/agent-builder/components/StepSectionHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { BodyCaption, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { SectionHeaderWrap } from '../AgentBuilder.styled';\n\ninterface StepSectionHeaderProps {\n\ttitle: string;\n\thelper?: string;\n}\n\nexport const StepSectionHeader: React.FC<StepSectionHeaderProps> = ({\n\ttitle,\n\thelper,\n}) => (\n\t<SectionHeaderWrap>\n\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t{helper && (\n\t\t\t<BodyCaption color={COLORS.content.secondary}>{helper}</BodyCaption>\n\t\t)}\n\t</SectionHeaderWrap>\n);\n"],"names":["StepSectionHeader","title","helper","SectionHeaderWrap","jsx","TitleRegular","COLORS","BodyCaption"],"mappings":"2OAUaA,EAAsD,CAAC,CACnE,MAAAC,EACA,OAAAC,CACD,WACEC,oBAAA,CACA,SAAA,CAAAC,MAACC,EAAAA,aAAA,CAAa,MAAOC,EAAAA,OAAO,QAAQ,QAAU,SAAAL,EAAM,EACnDC,GACAE,EAAAA,IAACG,EAAAA,YAAA,CAAY,MAAOD,EAAAA,OAAO,QAAQ,UAAY,SAAAJ,CAAA,CAAO,CAAA,CAAA,CAExD"}
1
+ {"version":3,"file":"StepSectionHeader.js","sources":["../../../../../src/components/agent-builder/components/StepSectionHeader.tsx"],"sourcesContent":["import React from 'react';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { SectionHeaderWrap } from '../AgentBuilder.styled';\n\ninterface StepSectionHeaderProps {\n\ttitle: string;\n\thelper?: string;\n}\n\nexport const StepSectionHeader: React.FC<StepSectionHeaderProps> = ({\n\ttitle,\n\thelper,\n}) => (\n\t<SectionHeaderWrap>\n\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t{helper && (\n\t\t\t<BodySecondary color={COLORS.content.secondary}>{helper}</BodySecondary>\n\t\t)}\n\t</SectionHeaderWrap>\n);\n"],"names":["StepSectionHeader","title","helper","SectionHeaderWrap","jsx","TitleRegular","COLORS","BodySecondary"],"mappings":"2OAUaA,EAAsD,CAAC,CACnE,MAAAC,EACA,OAAAC,CACD,WACEC,oBAAA,CACA,SAAA,CAAAC,MAACC,EAAAA,aAAA,CAAa,MAAOC,EAAAA,OAAO,QAAQ,QAAU,SAAAL,EAAM,EACnDC,GACAE,EAAAA,IAACG,EAAAA,cAAA,CAAc,MAAOD,EAAAA,OAAO,QAAQ,UAAY,SAAAJ,CAAA,CAAO,CAAA,CAAA,CAE1D"}
@@ -1,2 +1,2 @@
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:"Send 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,S={email_handover:"send_email",slack:"send_slack_message"};exports.CATEGORIES=s;exports.CONFIG_TOOL_SOURCES=S;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;
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';\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]: 'Send 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,aAC3B,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
+ {"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 at=require("react/jsx-runtime"),s=require("react"),ft=require("../constants/charLimits.js"),u=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 f=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:f,response:t.instructions.trim().length>0||(t.guardrail??"").trim().length>0,handover:!0}},St=({value:t,onChange:r,activeStep:f,onStepChange:C,availableTools:m,availableSubAgents:R,availableIntents:A,availableModels:_,configToolTemplates:k,integrationStatus:E,onConnectIntegration:P,validation:M,applicationType:h,charLimits:B,disableStepNavigation:K=!0,onCreateSubAgent:q,onFetchSubAgent:Y,onUpdateSubAgent:j,onImproveSubAgent:y,onImproveToolInstructions:F,children:ct})=>{const[it,ut]=s.useState("about"),b=f??it,i=u.getStepIndex(b),L=s.useRef(t);L.current=t;const[$,w]=s.useState(0),x=s.useRef({}),H=s.useRef("instructions"),I=s.useCallback((e,n)=>{n?x.current[e]=n:delete x.current[e]},[]),V=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)},[]),O=s.useCallback((e,n,c)=>{const d=x.current;(d[H.current]??d.instructions)?.(e,n,c)},[]),[Q,p]=s.useState(null),S=s.useRef(null),W=s.useRef(0),T=s.useMemo(()=>({...ft.AGENT_CHAR_LIMITS,...B}),[B]),g=s.useMemo(()=>({...bt(t,T),...M}),[t,T,M]),l=s.useCallback(e=>{const n=u.STEP_KEYS.indexOf(e);n>i&&u.STEP_KEYS.slice(0,n).some(c=>!g[c])||(f===void 0&&ut(e),C?.(e))},[f,C,i,g]),X=s.useCallback(()=>{const e=u.STEP_KEYS[Math.min(i+1,u.STEP_KEYS.length-1)];l(e)},[i,l]),Z=s.useCallback(()=>{const e=u.STEP_KEYS[Math.max(i-1,0)];l(e)},[i,l]),v=s.useCallback(e=>r(e),[r]),tt=s.useCallback((e,n)=>r({[e]:n}),[r]),et=s.useCallback((e,n)=>{const c=L.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]),st=s.useCallback((e,n)=>{const c=e==="tool"?`{{tool:${n}}}`:`{{subagent:${n}}}`,d=o=>o.split(c).join("");S.current={tools:t.tools,subagents:t.subagents,configTools:t.configTools,restApiTools:t.restApiTools,instructions:t.instructions,guardrail:t.guardrail};const a={instructions:d(t.instructions),guardrail:d(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),w(o=>o+1);const dt=e==="tool"?m.find(o=>o.tool_id===n)?.display_name??(t.restApiTools??[]).find(o=>o.id===n)?.name??"Tool":R.find(o=>o.id===n)?.name??"Sub-agent";W.current+=1,p({id:W.current,message:`${e==="tool"?"Tool":"Sub-agent"} "${dt}" removed`})},[m,R,t,r]),nt=s.useCallback(()=>{S.current&&(r(S.current),S.current=null,w(e=>e+1)),p(null)},[r]),ot=s.useCallback(()=>p(null),[]),lt=s.useMemo(()=>({value:t,patch:v,updateField:tt,addReference:et,removeReference:st,mentionResetKey:$,insertMention:O,registerMentionField:I,notifyMentionFocus:V,undoToast:Q,undoRemoval:nt,dismissUndo:ot,activeStep:b,activeIndex:i,goToStep:l,goNext:X,goPrev:Z,isFirstStep:i===0,isLastStep:i===u.STEP_KEYS.length-1,validation:g,isActiveStepValid:g[b],availableTools:m,availableSubAgents:R,availableIntents:A,availableModels:_,configToolTemplates:k,integrationStatus:E,onConnectIntegration:P,applicationType:h,charLimits:T,disableStepNavigation:K,onCreateSubAgent:q,registerSubAgentCreator:G,requestCreateSubAgent:N,registerToolActionHandler:z,requestToolAction:J,onFetchSubAgent:Y,onUpdateSubAgent:j,onImproveSubAgent:y,onImproveToolInstructions:F}),[t,v,tt,et,st,$,O,I,V,Q,nt,ot,b,i,l,X,Z,g,m,R,A,_,k,E,P,h,T,K,q,G,N,z,J,Y,j,y,F]);return at.jsx(rt.Provider,{value:lt,children:ct})};exports.AgentBuilderProvider=St;exports.useAgentBuilderContext=Rt;
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/**\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\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 goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\t// Forward jumps (side rail) must not skip past an incomplete step —\n\t\t\t// otherwise an agent with an empty step 3 could reach step 4 and be\n\t\t\t// published. Going back is always allowed.\n\t\t\tconst targetIndex = STEP_KEYS.indexOf(step);\n\t\t\tif (\n\t\t\t\ttargetIndex > activeIndex &&\n\t\t\t\tSTEP_KEYS.slice(0, targetIndex).some((k) => !validation[k])\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\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, activeIndex, validation],\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\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","charLimits","useMemo","AGENT_CHAR_LIMITS","validation","goToStep","step","targetIndex","STEP_KEYS","k","goNext","next","goPrev","prev","patch","partial","updateField","key","val","addReference","v","t","removeReference","token","strip","text","s","undoRemoval","dismissUndo"],"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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C,IAAgB,EAC7B,WAAYA,IAAgBoC,YAAU,OAAS,EAC/C,WAAAJ,EACA,kBAAmBA,EAAWjC,CAAU,EACxC,eAAApB,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,gBAAAE,EAAA,WACA0C,EACA,sBAAAxC,EACA,iBAAAC,EACA,wBAAAwB,EACA,sBAAAC,EACA,0BAAAE,EACA,kBAAAC,EACA,gBAAA3B,EACA,iBAAAC,EACA,kBAAAC,EACA,0BAAAC,CAAA,GAED,CACCtB,EACAsE,EACAE,GACAG,GACAG,GACA9C,EACAgB,EACAZ,EACAI,EACAa,EACA8B,GACAC,GACAzD,EACAC,EACAiC,EACAK,EACAE,EACAR,EACArD,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAE,EACA0C,EACAxC,EACAC,EACAwB,EACAC,EACAE,EACAC,EACA3B,EACAC,EACAC,EACAC,CAAA,CACD,EAGD,cACE5B,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAA0B,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,E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C,EACA,gBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,gBAAAE,EAAA,WACAiE,EACA,sBAAA/D,EACA,iBAAAC,EACA,wBAAAwB,EACA,sBAAAC,EACA,0BAAAE,EACA,kBAAAC,EACA,gBAAA3B,EACA,iBAAAC,EACA,kBAAAC,EACA,0BAAAC,CAAA,GAED,CACCtB,EACAgE,EACAE,GACAG,GACAG,GACAxC,EACAgB,EACAZ,EACAI,EACAa,EACAyB,GACAC,GACApD,EACAC,EACA6B,EACAE,EACAG,EACAqB,EACA5E,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAE,EACAiE,EACA/D,EACAC,EACAwB,EACAC,EACAE,EACAC,EACA3B,EACAC,EACAC,EACAC,CAAA,CACD,EAGD,cACE5B,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAA0B,GACF,CAEF"}
@@ -1,4 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("../../../assets/icons/cross.svg.js"),f=require("../../../assets/icons/plus.svg.js"),y=require("styled-components"),j=require("../../dropdown/DropdownPopover/index.js"),m=require("../../radioButton/RadioButton.js"),r=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),o=require("../AgentBuilder.styled.js"),O=require("../components/AiTextArea.js"),R=require("../components/StepSectionHeader.js"),v=require("../constants/steps.js"),_=require("../context/AgentBuilderContext.js"),b=require("../../button/Button.js"),T=require("../../dropdown/utils.js"),B=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},I=B(y),p=v.STEP_DEFINITIONS[1],q=()=>{const{value:s,patch:c,availableIntents:d,charLimits:g}=_.useAgentBuilderContext(),{trigger:n}=s,l=e=>c({trigger:e==="manifest_intent"?{...n,mode:e,custom_intent:""}:{...n,mode:e,intents:[]}}),x=e=>{n.intents.includes(e)||c({trigger:{...n,intents:[...n.intents,e]}})},S=e=>c({trigger:{...n,intents:n.intents.filter(a=>a!==e)}}),u=e=>d.find(a=>a.value===e)?.label??e,h=d.filter(e=>!n.intents.includes(e.value)).map(e=>({label:e.label,value:e.value}));return t.jsxs("div",{children:[t.jsx(R.StepSectionHeader,{title:p.title,helper:p.helper}),t.jsxs(o.SectionBodyWrap,{children:[t.jsxs(o.CardRow,{children:[t.jsxs(o.RadioCard,{"data-test":"trigger-mode-manifest",selected:n.mode==="manifest_intent",onClick:()=>l("manifest_intent"),children:[t.jsx(m.RadioButton,{isActive:n.mode==="manifest_intent",onValueChange:()=>l("manifest_intent"),skipSelectingOff:!0,activeColor:i.BASE_COLORS.brand[800]}),t.jsxs(o.RadioCardText,{children:[t.jsx(r.TitleSmall,{color:i.COLORS.content.primary,children:"Manifest intent"}),t.jsx(r.BodyCaption,{color:i.COLORS.content.secondary,children:"Manifest's AI classifier routes conversations automatically — no keywords needed."})]})]}),t.jsxs(o.RadioCard,{"data-test":"trigger-mode-custom",selected:n.mode==="custom_intent",onClick:()=>l("custom_intent"),children:[t.jsx(m.RadioButton,{isActive:n.mode==="custom_intent",onValueChange:()=>l("custom_intent"),skipSelectingOff:!0,activeColor:i.BASE_COLORS.brand[800]}),t.jsxs(o.RadioCardText,{children:[t.jsx(r.TitleSmall,{color:i.COLORS.content.primary,children:"Custom intent"}),t.jsx(r.BodyCaption,{color:i.COLORS.content.secondary,children:"Define your own trigger — use exact phrases or describe the customer's intent."})]})]})]}),n.mode==="manifest_intent"?t.jsxs(o.FieldBlock,{children:[t.jsx(r.TitleSmall,{color:i.COLORS.content.primary,children:"If customer talks about"}),n.intents.length>0&&t.jsx(o.ChipWrap,{children:n.intents.map(e=>t.jsxs(o.IntentChip,{"data-test":`intent-chip-${e}`,children:[t.jsx(r.BodySecondary,{color:i.COLORS.content.primary,children:u(e)}),t.jsx(o.ChipCloseButton,{onClick:()=>S(e),"aria-label":`Remove ${u(e)}`,children:t.jsx(C.default,{width:14,height:14,color:i.COLORS.content.secondary})})]},e))}),h.length>0&&t.jsx(w,{children:t.jsx(j.DropdownPopover,{"data-test":"intent-add-dropdown",isSearchable:!0,width:"200px",placement:"bottom-start",options:h,onSelect:e=>{const a=T.unwrapDropdownValue(e);a&&x(a)},children:t.jsx(b.Button,{"data-test":"intent-add-button",buttonType:"dashRegular",size:"medium",LeadingIcon:f.default,buttonText:"Intent"})})}),t.jsx(r.BodyCaption,{color:i.COLORS.content.secondary,children:"This agent takes over from your main assistant when this intent is detected. The changeover is automatic when you go live."})]}):t.jsx(O.AiTextArea,{"data-test":"custom-intent",label:"Describe the trigger",value:n.custom_intent??"",onChange:e=>c({trigger:{...n,custom_intent:e}}),maxLength:g.custom_intent,placeholder:"e.g. The customer wants to cancel an order they placed.",minHeight:"120px"})]})]})},w=I.default.div`
2
- display: flex;
3
- `;exports.Step2WhenItStepsIn=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("../../../assets/icons/cross.svg.js"),y=require("../../../assets/icons/plus.svg.js"),j=require("../../dropdown/DropdownPopover/index.js"),h=require("../../radioButton/RadioButton.js"),r=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js"),i=require("../AgentBuilder.styled.js"),O=require("../components/AiTextArea.js"),f=require("../components/StepSectionHeader.js"),R=require("../constants/steps.js"),v=require("../context/AgentBuilderContext.js"),b=require("../../dropdown/utils.js"),m=R.STEP_DEFINITIONS[1],T=()=>{const{value:p,patch:c,availableIntents:l,charLimits:g}=v.useAgentBuilderContext(),{trigger:n}=p,a=t=>c({trigger:{...n,mode:t}}),x=t=>{n.intents.includes(t)||c({trigger:{...n,intents:[...n.intents,t]}})},C=t=>c({trigger:{...n,intents:n.intents.filter(s=>s!==t)}}),d=t=>l.find(s=>s.value===t)?.label??t,u=l.filter(t=>!n.intents.includes(t.value)).map(t=>({label:t.label,value:t.value}));return e.jsxs("div",{children:[e.jsx(f.StepSectionHeader,{title:m.title,helper:m.helper}),e.jsxs(i.SectionBodyWrap,{children:[e.jsxs(i.CardRow,{children:[e.jsxs(i.RadioCard,{"data-test":"trigger-mode-manifest",selected:n.mode==="manifest_intent",onClick:()=>a("manifest_intent"),children:[e.jsx(h.RadioButton,{isActive:n.mode==="manifest_intent",onValueChange:()=>a("manifest_intent"),skipSelectingOff:!0,activeColor:o.COLORS.content.brand}),e.jsxs(i.RadioCardText,{children:[e.jsx(r.TitleSmall,{color:o.COLORS.content.primary,children:"Manifest intent"}),e.jsx(r.BodyCaption,{color:o.COLORS.content.secondary,children:"Manifest's AI classifier routes conversations automatically — no keywords needed."})]})]}),e.jsxs(i.RadioCard,{"data-test":"trigger-mode-custom",selected:n.mode==="custom_intent",onClick:()=>a("custom_intent"),children:[e.jsx(h.RadioButton,{isActive:n.mode==="custom_intent",onValueChange:()=>a("custom_intent"),skipSelectingOff:!0,activeColor:o.COLORS.content.brand}),e.jsxs(i.RadioCardText,{children:[e.jsx(r.TitleSmall,{color:o.COLORS.content.primary,children:"Custom intent"}),e.jsx(r.BodyCaption,{color:o.COLORS.content.secondary,children:"Define your own trigger — use exact phrases or describe the customer's intent."})]})]})]}),n.mode==="manifest_intent"?e.jsxs(i.FieldBlock,{children:[e.jsx(r.TitleSmall,{color:o.COLORS.content.primary,children:"If customer talks about"}),e.jsxs(i.ChipWrap,{children:[n.intents.map(t=>e.jsxs(i.IntentChip,{"data-test":`intent-chip-${t}`,children:[e.jsx(r.BodySecondary,{color:o.COLORS.content.primary,children:d(t)}),e.jsx(i.ChipCloseButton,{onClick:()=>C(t),"aria-label":`Remove ${d(t)}`,children:e.jsx(S.default,{width:14,height:14,color:o.COLORS.content.secondary})})]},t)),u.length>0&&e.jsx(j.DropdownPopover,{"data-test":"intent-add-dropdown",isSearchable:!0,width:"200px",placement:"bottom-start",options:u,onSelect:t=>{const s=b.unwrapDropdownValue(t);s&&x(s)},children:e.jsxs(i.AddChipButton,{"data-test":"intent-add-button",type:"button",children:[e.jsx(y.default,{width:16,height:16,color:o.COLORS.content.secondary}),e.jsx(r.BodySecondary,{color:o.COLORS.content.secondary,children:"Intent"})]})})]}),e.jsx(r.BodyCaption,{color:o.COLORS.content.secondary,children:"This agent takes over from your main assistant when this intent is detected. The changeover is automatic when you go live."})]}):e.jsx(O.AiTextArea,{"data-test":"custom-intent",label:"Describe the trigger",value:n.custom_intent??"",onChange:t=>c({trigger:{...n,custom_intent:t}}),maxLength:g.custom_intent,placeholder:"e.g. The customer wants to cancel an order they placed.",minHeight:"120px"})]})]})};exports.Step2WhenItStepsIn=T;
4
2
  //# sourceMappingURL=Step2WhenItStepsIn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step2WhenItStepsIn.js","sources":["../../../../../src/components/agent-builder/steps/Step2WhenItStepsIn.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { unwrapDropdownValue } from '@src/components/dropdown';\nimport { DropdownPopover } from '@src/components/dropdown/DropdownPopover';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { BASE_COLORS, COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tCardRow,\n\tChipCloseButton,\n\tChipWrap,\n\tFieldBlock,\n\tIntentChip,\n\tRadioCard,\n\tRadioCardText,\n\tSectionBodyWrap,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents, charLimits } =\n\t\tuseAgentBuilderContext();\n\tconst { trigger } = value;\n\n\t// The two modes are mutually exclusive, so switching clears the other mode's\n\t// data — otherwise both manifest intents AND a custom intent get saved.\n\tconst setMode = (mode: TriggerMode) =>\n\t\tpatch({\n\t\t\ttrigger:\n\t\t\t\tmode === 'manifest_intent'\n\t\t\t\t\t? { ...trigger, mode, custom_intent: '' }\n\t\t\t\t\t: { ...trigger, mode, intents: [] },\n\t\t});\n\n\tconst addIntent = (intentValue: string) => {\n\t\tif (!trigger.intents.includes(intentValue)) {\n\t\t\tpatch({\n\t\t\t\ttrigger: { ...trigger, intents: [...trigger.intents, intentValue] },\n\t\t\t});\n\t\t}\n\t};\n\n\tconst removeIntent = (intentValue: string) =>\n\t\tpatch({\n\t\t\ttrigger: {\n\t\t\t\t...trigger,\n\t\t\t\tintents: trigger.intents.filter((i) => i !== intentValue),\n\t\t\t},\n\t\t});\n\n\tconst labelFor = (v: string) =>\n\t\tavailableIntents.find((o) => o.value === v)?.label ?? v;\n\n\tconst remainingOptions: SingleOption[] = availableIntents\n\t\t.filter((o) => !trigger.intents.includes(o.value))\n\t\t.map((o) => ({ label: o.label, value: o.value }));\n\n\treturn (\n\t\t<div>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<CardRow>\n\t\t\t\t\t<RadioCard\n\t\t\t\t\t\tdata-test=\"trigger-mode-manifest\"\n\t\t\t\t\t\tselected={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\tonClick={() => setMode('manifest_intent')}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\tisActive={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\t\tonValueChange={() => setMode('manifest_intent')}\n\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\tactiveColor={BASE_COLORS.brand['800']}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tManifest intent\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tManifest&apos;s AI classifier routes conversations automatically\n\t\t\t\t\t\t\t\t— no keywords needed.\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t</RadioCard>\n\n\t\t\t\t\t<RadioCard\n\t\t\t\t\t\tdata-test=\"trigger-mode-custom\"\n\t\t\t\t\t\tselected={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\tonClick={() => setMode('custom_intent')}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\tisActive={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\t\tonValueChange={() => setMode('custom_intent')}\n\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\tactiveColor={BASE_COLORS.brand['800']}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tCustom intent\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tDefine your own trigger — use exact phrases or describe the\n\t\t\t\t\t\t\t\tcustomer&apos;s intent.\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t</RadioCard>\n\t\t\t\t</CardRow>\n\n\t\t\t\t{trigger.mode === 'manifest_intent' ? (\n\t\t\t\t\t<FieldBlock>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tIf customer talks about\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t{trigger.intents.length > 0 && (\n\t\t\t\t\t\t\t<ChipWrap>\n\t\t\t\t\t\t\t\t{trigger.intents.map((intent) => (\n\t\t\t\t\t\t\t\t\t<IntentChip key={intent} data-test={`intent-chip-${intent}`}>\n\t\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\t{labelFor(intent)}\n\t\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t\t\t<ChipCloseButton\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => removeIntent(intent)}\n\t\t\t\t\t\t\t\t\t\t\taria-label={`Remove ${labelFor(intent)}`}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\t\t\t\t\t\twidth={14}\n\t\t\t\t\t\t\t\t\t\t\t\theight={14}\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ChipCloseButton>\n\t\t\t\t\t\t\t\t\t</IntentChip>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</ChipWrap>\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t{remainingOptions.length > 0 && (\n\t\t\t\t\t\t\t// Dashed \"+ Intent\" button on its own row under the chips;\n\t\t\t\t\t\t\t// clicking it opens the intent list directly — no intermediate\n\t\t\t\t\t\t\t// select input.\n\t\t\t\t\t\t\t<AddIntentRow>\n\t\t\t\t\t\t\t\t<DropdownPopover\n\t\t\t\t\t\t\t\t\tdata-test=\"intent-add-dropdown\"\n\t\t\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\t\t\twidth=\"200px\"\n\t\t\t\t\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\t\t\t\t\toptions={remainingOptions}\n\t\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\t\taddIntent(v);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tdata-test=\"intent-add-button\"\n\t\t\t\t\t\t\t\t\t\tbuttonType=\"dashRegular\"\n\t\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\t\tLeadingIcon={PlusIcon}\n\t\t\t\t\t\t\t\t\t\tbuttonText=\"Intent\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</DropdownPopover>\n\t\t\t\t\t\t\t</AddIntentRow>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tThis agent takes over from your main assistant when this intent is\n\t\t\t\t\t\t\tdetected. The changeover is automatic when you go live.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</FieldBlock>\n\t\t\t\t) : (\n\t\t\t\t\t<AiTextArea\n\t\t\t\t\t\tdata-test=\"custom-intent\"\n\t\t\t\t\t\tlabel=\"Describe the trigger\"\n\t\t\t\t\t\tvalue={trigger.custom_intent ?? ''}\n\t\t\t\t\t\tonChange={(text) =>\n\t\t\t\t\t\t\tpatch({ trigger: { ...trigger, custom_intent: text } })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmaxLength={charLimits.custom_intent}\n\t\t\t\t\t\tplaceholder=\"e.g. The customer wants to cancel an order they placed.\"\n\t\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n\n// Keeps the dashed \"+ Intent\" button at its natural width on its own row.\nconst AddIntentRow = styled.div`\n\tdisplay: flex;\n`;\n"],"names":["STEP","STEP_DEFINITIONS","Step2WhenItStepsIn","value","patch","availableIntents","charLimits","useAgentBuilderContext","trigger","setMode","mode","addIntent","intentValue","removeIntent","i","labelFor","v","o","remainingOptions","jsx","StepSectionHeader","SectionBodyWrap","jsxs","CardRow","RadioCard","RadioButton","BASE_COLORS","RadioCardText","TitleSmall","COLORS","BodyCaption","FieldBlock","ChipWrap","intent","IntentChip","BodySecondary","ChipCloseButton","CrossIcon","AddIntentRow","DropdownPopover","opt","unwrapDropdownValue","Button","PlusIcon","AiTextArea","text","styled"],"mappings":"+vBA+BMA,EAAOC,EAAAA,iBAAiB,CAAC,EAElBC,EAA+B,IAAM,CACjD,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,iBAAAC,EAAkB,WAAAC,CAAA,EACvCC,EAAAA,uBAAA,EACK,CAAE,QAAAC,GAAYL,EAIdM,EAAWC,GAChBN,EAAM,CACL,QACCM,IAAS,kBACN,CAAE,GAAGF,EAAS,KAAAE,EAAM,cAAe,EAAA,EACnC,CAAE,GAAGF,EAAS,KAAAE,EAAM,QAAS,CAAA,CAAC,CAAE,CACpC,EAEIC,EAAaC,GAAwB,CACrCJ,EAAQ,QAAQ,SAASI,CAAW,GACxCR,EAAM,CACL,QAAS,CAAE,GAAGI,EAAS,QAAS,CAAC,GAAGA,EAAQ,QAASI,CAAW,CAAA,CAAE,CAClE,CAEH,EAEMC,EAAgBD,GACrBR,EAAM,CACL,QAAS,CACR,GAAGI,EACH,QAASA,EAAQ,QAAQ,OAAQM,GAAMA,IAAMF,CAAW,CAAA,CACzD,CACA,EAEIG,EAAYC,GACjBX,EAAiB,KAAMY,GAAMA,EAAE,QAAUD,CAAC,GAAG,OAASA,EAEjDE,EAAmCb,EACvC,OAAQY,GAAM,CAACT,EAAQ,QAAQ,SAASS,EAAE,KAAK,CAAC,EAChD,IAAKA,IAAO,CAAE,MAAOA,EAAE,MAAO,MAAOA,EAAE,KAAA,EAAQ,EAEjD,cACE,MAAA,CACA,SAAA,CAAAE,MAACC,EAAAA,mBAAkB,MAAOpB,EAAK,MAAO,OAAQA,EAAK,OAAQ,SAC1DqB,EAAAA,gBAAA,CACA,SAAA,CAAAC,OAACC,EAAAA,QAAA,CACA,SAAA,CA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"Step2WhenItStepsIn.js","sources":["../../../../../src/components/agent-builder/steps/Step2WhenItStepsIn.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport PlusIcon from '@src/assets/icons/plus.svg';\nimport React from 'react';\nimport { unwrapDropdownValue } from '@src/components/dropdown';\nimport { DropdownPopover } from '@src/components/dropdown/DropdownPopover';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tAddChipButton,\n\tCardRow,\n\tChipCloseButton,\n\tChipWrap,\n\tFieldBlock,\n\tIntentChip,\n\tRadioCard,\n\tRadioCardText,\n\tSectionBodyWrap,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents, charLimits } =\n\t\tuseAgentBuilderContext();\n\tconst { trigger } = value;\n\n\tconst setMode = (mode: TriggerMode) =>\n\t\tpatch({ trigger: { ...trigger, mode } });\n\n\tconst addIntent = (intentValue: string) => {\n\t\tif (!trigger.intents.includes(intentValue)) {\n\t\t\tpatch({\n\t\t\t\ttrigger: { ...trigger, intents: [...trigger.intents, intentValue] },\n\t\t\t});\n\t\t}\n\t};\n\n\tconst removeIntent = (intentValue: string) =>\n\t\tpatch({\n\t\t\ttrigger: {\n\t\t\t\t...trigger,\n\t\t\t\tintents: trigger.intents.filter((i) => i !== intentValue),\n\t\t\t},\n\t\t});\n\n\tconst labelFor = (v: string) =>\n\t\tavailableIntents.find((o) => o.value === v)?.label ?? v;\n\n\tconst remainingOptions: SingleOption[] = availableIntents\n\t\t.filter((o) => !trigger.intents.includes(o.value))\n\t\t.map((o) => ({ label: o.label, value: o.value }));\n\n\treturn (\n\t\t<div>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<CardRow>\n\t\t\t\t\t<RadioCard\n\t\t\t\t\t\tdata-test=\"trigger-mode-manifest\"\n\t\t\t\t\t\tselected={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\tonClick={() => setMode('manifest_intent')}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\tisActive={trigger.mode === 'manifest_intent'}\n\t\t\t\t\t\t\tonValueChange={() => setMode('manifest_intent')}\n\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tManifest intent\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tManifest&apos;s AI classifier routes conversations automatically\n\t\t\t\t\t\t\t\t— no keywords needed.\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t</RadioCard>\n\n\t\t\t\t\t<RadioCard\n\t\t\t\t\t\tdata-test=\"trigger-mode-custom\"\n\t\t\t\t\t\tselected={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\tonClick={() => setMode('custom_intent')}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\tisActive={trigger.mode === 'custom_intent'}\n\t\t\t\t\t\t\tonValueChange={() => setMode('custom_intent')}\n\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tCustom intent\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tDefine your own trigger — use exact phrases or describe the\n\t\t\t\t\t\t\t\tcustomer&apos;s intent.\n\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t</RadioCard>\n\t\t\t\t</CardRow>\n\n\t\t\t\t{trigger.mode === 'manifest_intent' ? (\n\t\t\t\t\t<FieldBlock>\n\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\tIf customer talks about\n\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t<ChipWrap>\n\t\t\t\t\t\t\t{trigger.intents.map((intent) => (\n\t\t\t\t\t\t\t\t<IntentChip key={intent} data-test={`intent-chip-${intent}`}>\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{labelFor(intent)}\n\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t\t<ChipCloseButton\n\t\t\t\t\t\t\t\t\t\tonClick={() => removeIntent(intent)}\n\t\t\t\t\t\t\t\t\t\taria-label={`Remove ${labelFor(intent)}`}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\t\t\t\t\twidth={14}\n\t\t\t\t\t\t\t\t\t\t\theight={14}\n\t\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</ChipCloseButton>\n\t\t\t\t\t\t\t\t</IntentChip>\n\t\t\t\t\t\t\t))}\n\n\t\t\t\t\t\t\t{remainingOptions.length > 0 && (\n\t\t\t\t\t\t\t\t// Clicking the button opens the intent list directly — no\n\t\t\t\t\t\t\t\t// intermediate select input.\n\t\t\t\t\t\t\t\t<DropdownPopover\n\t\t\t\t\t\t\t\t\tdata-test=\"intent-add-dropdown\"\n\t\t\t\t\t\t\t\t\tisSearchable\n\t\t\t\t\t\t\t\t\twidth=\"200px\"\n\t\t\t\t\t\t\t\t\tplacement=\"bottom-start\"\n\t\t\t\t\t\t\t\t\toptions={remainingOptions}\n\t\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\t\taddIntent(v);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<AddChipButton data-test=\"intent-add-button\" type=\"button\">\n\t\t\t\t\t\t\t\t\t\t<PlusIcon\n\t\t\t\t\t\t\t\t\t\t\twidth={16}\n\t\t\t\t\t\t\t\t\t\t\theight={16}\n\t\t\t\t\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\t\t\tIntent\n\t\t\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t\t</AddChipButton>\n\t\t\t\t\t\t\t\t</DropdownPopover>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</ChipWrap>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tThis agent takes over from your main assistant when this intent is\n\t\t\t\t\t\t\tdetected. The changeover is automatic when you go live.\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t</FieldBlock>\n\t\t\t\t) : (\n\t\t\t\t\t<AiTextArea\n\t\t\t\t\t\tdata-test=\"custom-intent\"\n\t\t\t\t\t\tlabel=\"Describe the trigger\"\n\t\t\t\t\t\tvalue={trigger.custom_intent ?? ''}\n\t\t\t\t\t\tonChange={(text) =>\n\t\t\t\t\t\t\tpatch({ trigger: { ...trigger, custom_intent: text } })\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmaxLength={charLimits.custom_intent}\n\t\t\t\t\t\tplaceholder=\"e.g. The customer wants to cancel an order they placed.\"\n\t\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step2WhenItStepsIn","value","patch","availableIntents","charLimits","useAgentBuilderContext","trigger","setMode","mode","addIntent","intentValue","removeIntent","i","labelFor","v","o","remainingOptions","jsx","StepSectionHeader","SectionBodyWrap","jsxs","CardRow","RadioCard","RadioButton","COLORS","RadioCardText","TitleSmall","BodyCaption","FieldBlock","ChipWrap","intent","IntentChip","BodySecondary","ChipCloseButton","CrossIcon","DropdownPopover","opt","unwrapDropdownValue","AddChipButton","PlusIcon","AiTextArea","text"],"mappings":"6nBA8BMA,EAAOC,EAAAA,iBAAiB,CAAC,EAElBC,EAA+B,IAAM,CACjD,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,iBAAAC,EAAkB,WAAAC,CAAA,EACvCC,EAAAA,uBAAA,EACK,CAAE,QAAAC,GAAYL,EAEdM,EAAWC,GAChBN,EAAM,CAAE,QAAS,CAAE,GAAGI,EAAS,KAAAE,CAAA,EAAQ,EAElCC,EAAaC,GAAwB,CACrCJ,EAAQ,QAAQ,SAASI,CAAW,GACxCR,EAAM,CACL,QAAS,CAAE,GAAGI,EAAS,QAAS,CAAC,GAAGA,EAAQ,QAASI,CAAW,CAAA,CAAE,CAClE,CAEH,EAEMC,EAAgBD,GACrBR,EAAM,CACL,QAAS,CACR,GAAGI,EACH,QAASA,EAAQ,QAAQ,OAAQM,GAAMA,IAAMF,CAAW,CAAA,CACzD,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AAc,MAAOR,EAAAA,OAAO,QAAQ,UAAW,SAAA,QAAA,CAEhD,CAAA,CAAA,CACD,CAAA,CAAA,CACD,EAEF,QACCG,EAAAA,YAAA,CAAY,MAAOH,EAAAA,OAAO,QAAQ,UAAW,SAAA,4HAAA,CAG9C,CAAA,CAAA,CACD,EAEAP,EAAAA,IAACuB,EAAAA,WAAA,CACA,YAAU,gBACV,MAAM,uBACN,MAAOlC,EAAQ,eAAiB,GAChC,SAAWmC,GACVvC,EAAM,CAAE,QAAS,CAAE,GAAGI,EAAS,cAAemC,CAAA,EAAQ,EAEvD,UAAWrC,EAAW,cACtB,YAAY,0DACZ,UAAU,OAAA,CAAA,CACX,CAAA,CAEF,CAAA,EACD,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),G=require("../../TypographyStyle.js"),U=require("../../../constants/Theme.js"),S=require("../AgentBuilder.styled.js"),be=require("../components/ConfigToolPanel.js"),Se=require("../components/CreateSubAgentPanel.js"),W=require("../components/MentionField.js"),fe=require("../components/RestApiToolPanel.js"),z=require("../components/SelectableListSection.js"),Te=require("../components/StepSectionHeader.js"),ye=require("../constants/steps.js"),p=require("../constants/tools.js"),he=require("../context/AgentBuilderContext.js"),r=require("../utils/mentionSerialization.js"),h=require("../utils/sourceIcons.js"),Ae=require("../utils/toolActions.js"),ve=require("../../dropdown/Dropdown.js"),Ce=require("../../dropdown/utils.js"),Ie=t=>h.renderSourceIcon(h.sourceIcon(t))??void 0,$=t=>({label:t.display_name,value:t.tool_id,leadingIcon:Ie(t.source??p.ToolSource.Manifest)}),V=ye.STEP_DEFINITIONS[2],J=(t,a)=>{const f=t??[];return f.some(u=>u.id===a.id)?f.map(u=>u.id===a.id?a:u):[...f,a]},xe=()=>{const{value:t,patch:a,updateField:f,addReference:u,removeReference:P,availableTools:T,availableSubAgents:Q,availableModels:w,configToolTemplates:k,applicationType:D,charLimits:y,insertMention:c,onCreateSubAgent:g,onFetchSubAgent:A,onUpdateSubAgent:R,onImproveSubAgent:X,onImproveToolInstructions:O,registerSubAgentCreator:j,registerToolActionHandler:q}=he.useAgentBuilderContext(),[d,v]=s.useState(null),C=s.useRef(0),[i,m]=s.useState(null),I=s.useRef(0),M=s.useCallback(e=>{I.current+=1,m({key:I.current,kind:"restapi",initialRest:e})},[]),E=s.useCallback((e,o)=>{I.current+=1,m({key:I.current,kind:"config",toolKey:e,initialConfig:o})},[]),Y=s.useCallback(e=>{const o=!(t.restApiTools??[]).some(l=>l.id===e.id);a({restApiTools:J(t.restApiTools,e)}),o&&c("tool",e.id,r.restApiMentionItem(e).label),m(null)},[a,t.restApiTools,c]),Z=s.useCallback(e=>{const o=!(t.configTools??[]).some(l=>l.id===e.id);a({configTools:J(t.configTools,e)}),o&&c("tool",e.id,r.configToolMentionItem(e).label),m(null)},[a,t.configTools,c]),L=s.useCallback(e=>{const o=p.CONFIG_TOOL_SOURCES[e];o?E(o):M()},[E,M]);s.useEffect(()=>(q(L),()=>q(null)),[q,L]);const[ee,K]=s.useState([]),x=new Map;Q.forEach(e=>x.set(e.id,e)),ee.forEach(e=>x.set(e.id,e));const H=Array.from(x.values()),_=s.useCallback(()=>{C.current+=1,v({key:C.current,title:"Create sub-agent"})},[]);s.useEffect(()=>{if(g)return j(_),()=>j(null)},[j,_,g]);const oe=s.useCallback(async e=>{if(!A)return;const o=await A(e);C.current+=1,v({key:C.current,title:"Edit sub-agent",editingId:e,initial:o})},[A]),te=s.useCallback(async e=>{if(d?.editingId){if(R){const o=await R(d.editingId,e);K(l=>[...l.filter(b=>b.id!==o.id),o])}}else if(g){const o=await g(e);K(l=>[...l,o]),a({subagents:[...t.subagents,o.id]}),c("subagent",o.id,`sub-agent: ${o.name}`)}v(null)},[d,R,g,a,t.subagents,c]),ne=t.tools.map(e=>{const o=T.find(l=>l.tool_id===e);return o?{id:e,label:o.display_name,icon:h.sourceIcon(o.source??p.ToolSource.Manifest)}:null}).filter(e=>e!==null),le=(t.restApiTools??[]).map(e=>({id:e.id,label:r.restApiToolName(e),icon:h.SOURCE_ICONS[p.ToolSource.RestApi],onConfigure:()=>M(e)})),se=(t.configTools??[]).map(e=>({id:e.id,label:r.configToolName(e),icon:h.SOURCE_ICONS[e.tool_key==="send_slack_message"?p.ToolSource.Slack:p.ToolSource.EmailHandover],onConfigure:()=>E(e.tool_key,e)})),ie=[...ne,...le,...se],ae=Ae.buildToolActions(k,L),re=T.map($),ce=(()=>{const e=[],o=new Map;return T.forEach(l=>{const b=l.source??p.ToolSource.Manifest;o.has(b)||(o.set(b,[]),e.push(b)),o.get(b)?.push($(l))}),e.map(l=>({source:l,label:r.toolSourceLabel(l),options:o.get(l)??[]}))})(),ue=t.subagents.map(e=>{const o=x.get(e);return o?{id:e,label:o.name}:null}).filter(e=>e!==null),de=H.map(e=>({label:e.name,value:e.id})),B=r.appTypeLabel(D),pe=[...r.buildAgentMentionItems(T,[],B),...r.buildCustomToolMentionItems(t.configTools,t.restApiTools)],ge=r.buildAgentMentionItems([],H,B),me=w.map(e=>({label:e.label,value:e.value,selected:e.value===t.model})),N=w.find(e=>e.value===t.model),F=i?.kind==="config"&&i.toolKey?k?.[i.toolKey]:void 0;return n.jsxs(S.Step3Root,{children:[n.jsx(Te.StepSectionHeader,{title:V.title,helper:V.helper}),n.jsxs(S.Step3Grid,{$grow:!0,children:[n.jsxs(S.SectionBodyWrap,{children:[n.jsx(W.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:y.instructions,placeholder:"Write the steps in plain English. The agent will follow them exactly. The more specific you are, the better it performs.",minHeight:"200px"}),n.jsx(W.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:y.guardrail,placeholder:"e.g. Never discuss competitor pricing. Always stay within the cancellation policy. Do not process refunds above ₹10,000 without human approval.",minHeight:"140px"})]}),n.jsx(S.Step3Divider,{}),n.jsxs(S.SectionBodyWrap,{children:[n.jsx(z.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:ie,addableOptions:re,sourceGroups:ce,mentionItems:pe,actionSources:ae,emptyText:"No tools added yet.",onAdd:e=>{c("tool",e),u("tool",e)},onRemove:e=>P("tool",e),confirmDelete:{noun:"tool"}}),n.jsx(z.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:ue,addableOptions:de,mentionItems:ge,emptyText:"No sub-agents added yet.",onAdd:e=>{c("subagent",e),u("subagent",e)},onRemove:e=>P("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:A?oe:void 0,createOption:g?{label:"Create new",onSelect:_}:void 0}),w.length>0&&n.jsxs(S.SideSection,{children:[n.jsx(G.TitleSmall,{color:U.COLORS.content.primary,children:"Advanced settings"}),n.jsx(G.BodySecondary,{color:U.COLORS.content.primary,children:"Select AI model"}),n.jsx(ve.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",dropdownWidth:"328px",placeHolder:"Select model",options:me,defaultOptions:N?[{label:N.label,value:N.value}]:void 0,onSelect:e=>{const o=Ce.unwrapDropdownValue(e);o&&f("model",o)}})]})]})]}),d&&n.jsx(Se.CreateSubAgentPanel,{title:d.title,initial:d.initial,availableTools:T,configToolTemplates:k,appLabel:r.appTypeLabel(D),charLimits:y,onImprove:X,onImproveToolInstructions:O,onClose:()=>v(null),onSave:te},d.key),i?.kind==="restapi"&&n.jsx(fe.RestApiToolPanel,{initial:i.initialRest,charLimits:y,existingNames:(t.restApiTools??[]).filter(e=>e.id!==i.initialRest?.id).map(e=>e.name),onImprove:O,onClose:()=>m(null),onSave:Y},i.key),i?.kind==="config"&&i.toolKey&&F&&n.jsx(be.ConfigToolPanel,{toolKey:i.toolKey,template:F,initial:i.initialConfig,charLimits:y,onImprove:O,onClose:()=>m(null),onSave:Z},i.key)]})};exports.Step3HowItResponds=xe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),G=require("../../TypographyStyle.js"),U=require("../../../constants/Theme.js"),m=require("../AgentBuilder.styled.js"),Se=require("../components/ConfigToolPanel.js"),me=require("../components/CreateSubAgentPanel.js"),W=require("../components/MentionField.js"),fe=require("../components/RestApiToolPanel.js"),z=require("../components/SelectableListSection.js"),Te=require("../components/StepSectionHeader.js"),ye=require("../constants/steps.js"),p=require("../constants/tools.js"),Ae=require("../context/AgentBuilderContext.js"),r=require("../utils/mentionSerialization.js"),A=require("../utils/sourceIcons.js"),he=require("../utils/toolActions.js"),Ce=require("../../dropdown/Dropdown.js"),Ie=require("../../dropdown/utils.js"),ve=t=>A.renderSourceIcon(A.sourceIcon(t))??void 0,$=t=>({label:t.display_name,value:t.tool_id,leadingIcon:ve(t.source??p.ToolSource.Manifest)}),V=ye.STEP_DEFINITIONS[2],J=(t,i)=>{const f=t??[];return f.some(u=>u.id===i.id)?f.map(u=>u.id===i.id?i:u):[...f,i]},xe=()=>{const{value:t,patch:i,updateField:f,addReference:u,removeReference:N,availableTools:T,availableSubAgents:Q,availableModels:k,configToolTemplates:R,applicationType:D,charLimits:y,insertMention:c,onCreateSubAgent:g,onFetchSubAgent:h,onUpdateSubAgent:O,onImproveSubAgent:X,onImproveToolInstructions:w,registerSubAgentCreator:j,registerToolActionHandler:q}=Ae.useAgentBuilderContext(),[d,C]=s.useState(null),I=s.useRef(0),[a,b]=s.useState(null),v=s.useRef(0),M=s.useCallback(e=>{v.current+=1,b({key:v.current,kind:"restapi",initialRest:e})},[]),E=s.useCallback((e,o)=>{v.current+=1,b({key:v.current,kind:"config",toolKey:e,initialConfig:o})},[]),Y=s.useCallback(e=>{const o=!(t.restApiTools??[]).some(l=>l.id===e.id);i({restApiTools:J(t.restApiTools,e)}),o&&c("tool",e.id,r.restApiMentionItem(e).label),b(null)},[i,t.restApiTools,c]),Z=s.useCallback(e=>{const o=!(t.configTools??[]).some(l=>l.id===e.id);i({configTools:J(t.configTools,e)}),o&&c("tool",e.id,r.configToolMentionItem(e).label),b(null)},[i,t.configTools,c]),L=s.useCallback(e=>{const o=p.CONFIG_TOOL_SOURCES[e];o?E(o):M()},[E,M]);s.useEffect(()=>(q(L),()=>q(null)),[q,L]);const[ee,K]=s.useState([]),x=new Map;Q.forEach(e=>x.set(e.id,e)),ee.forEach(e=>x.set(e.id,e));const H=Array.from(x.values()),_=s.useCallback(()=>{I.current+=1,C({key:I.current,title:"Create sub-agent"})},[]);s.useEffect(()=>{if(g)return j(_),()=>j(null)},[j,_,g]);const oe=s.useCallback(async e=>{if(!h)return;const o=await h(e);I.current+=1,C({key:I.current,title:"Edit sub-agent",editingId:e,initial:o})},[h]),te=s.useCallback(async e=>{if(d?.editingId){if(O){const o=await O(d.editingId,e);K(l=>[...l.filter(S=>S.id!==o.id),o])}}else if(g){const o=await g(e);K(l=>[...l,o]),i({subagents:[...t.subagents,o.id]}),c("subagent",o.id,`sub-agent: ${o.name}`)}C(null)},[d,O,g,i,t.subagents,c]),ne=t.tools.map(e=>{const o=T.find(l=>l.tool_id===e);return o?{id:e,label:o.display_name,icon:A.sourceIcon(o.source??p.ToolSource.Manifest)}:null}).filter(e=>e!==null),le=(t.restApiTools??[]).map(e=>({id:e.id,label:r.restApiToolName(e),icon:A.SOURCE_ICONS[p.ToolSource.RestApi],onConfigure:()=>M(e)})),se=(t.configTools??[]).map(e=>({id:e.id,label:r.configToolName(e),icon:A.SOURCE_ICONS[e.tool_key==="send_slack_message"?p.ToolSource.Slack:p.ToolSource.EmailHandover],onConfigure:()=>E(e.tool_key,e)})),ie=[...ne,...le,...se],ae=he.buildToolActions(R,L),re=T.map($),ce=(()=>{const e=[],o=new Map;return T.forEach(l=>{const S=l.source??p.ToolSource.Manifest;o.has(S)||(o.set(S,[]),e.push(S)),o.get(S)?.push($(l))}),e.map(l=>({source:l,label:r.toolSourceLabel(l),options:o.get(l)??[]}))})(),ue=t.subagents.map(e=>{const o=x.get(e);return o?{id:e,label:o.name}:null}).filter(e=>e!==null),de=H.map(e=>({label:e.name,value:e.id})),B=r.appTypeLabel(D),pe=[...r.buildAgentMentionItems(T,[],B),...r.buildCustomToolMentionItems(t.configTools,t.restApiTools)],ge=r.buildAgentMentionItems([],H,B),be=k.map(e=>({label:e.label,value:e.value,selected:e.value===t.model})),P=k.find(e=>e.value===t.model),F=a?.kind==="config"&&a.toolKey?R?.[a.toolKey]:void 0;return n.jsxs(m.Step3Root,{children:[n.jsx(Te.StepSectionHeader,{title:V.title,helper:V.helper}),n.jsxs(m.Step3Grid,{$grow:!0,children:[n.jsxs(m.SectionBodyWrap,{children:[n.jsx(W.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:y.instructions,placeholder:"Write what this agent should do. Type @ to reference a tool or sub-agent.",minHeight:"200px"}),n.jsx(W.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:y.guardrail,placeholder:"Things this agent must never do. Type @ to reference a tool or sub-agent.",minHeight:"140px"})]}),n.jsx(m.Step3Divider,{}),n.jsxs(m.SectionBodyWrap,{children:[n.jsx(z.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:ie,addableOptions:re,sourceGroups:ce,mentionItems:pe,actionSources:ae,emptyText:"No tools added yet.",onAdd:e=>{c("tool",e),u("tool",e)},onRemove:e=>N("tool",e),confirmDelete:{noun:"tool"}}),n.jsx(z.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:ue,addableOptions:de,mentionItems:ge,emptyText:"No sub-agents added yet.",onAdd:e=>{c("subagent",e),u("subagent",e)},onRemove:e=>N("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:h?oe:void 0,createOption:g?{label:"Create new",onSelect:_}:void 0}),k.length>0&&n.jsxs(m.SideSection,{children:[n.jsx(G.TitleSmall,{color:U.COLORS.content.primary,children:"Advanced settings"}),n.jsx(G.TitleSmall,{color:U.COLORS.content.secondary,children:"Select AI model"}),n.jsx(Ce.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",placeHolder:"Select model",options:be,defaultOptions:P?[{label:P.label,value:P.value}]:void 0,onSelect:e=>{const o=Ie.unwrapDropdownValue(e);o&&f("model",o)}})]})]})]}),d&&n.jsx(me.CreateSubAgentPanel,{title:d.title,initial:d.initial,availableTools:T,configToolTemplates:R,appLabel:r.appTypeLabel(D),charLimits:y,onImprove:X,onImproveToolInstructions:w,onClose:()=>C(null),onSave:te},d.key),a?.kind==="restapi"&&n.jsx(fe.RestApiToolPanel,{initial:a.initialRest,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:Y},a.key),a?.kind==="config"&&a.toolKey&&F&&n.jsx(Se.ConfigToolPanel,{toolKey:a.toolKey,template:F,initial:a.initialConfig,charLimits:y,onImprove:w,onClose:()=>b(null),onSave:Z},a.key)]})};exports.Step3HowItResponds=xe;
2
2
  //# sourceMappingURL=Step3HowItResponds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { BodySecondary, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write the steps in plain English. The agent will follow them exactly. The more specific you are, the better it performs.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Always stay within the cancellation policy. Do not process refunds above ₹10,000 without human approval.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\t// Popover is portalled, so \"100%\" collapses to content width —\n\t\t\t\t\t\t\t\t// match the input: 360px side column − 2×16px SectionBodyWrap\n\t\t\t\t\t\t\t\t// padding.\n\t\t\t\t\t\t\t\tdropdownWidth=\"328px\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', v);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t// Block reusing another tool's name (exclude the one being edited).\n\t\t\t\t\texistingNames={(value.restApiTools ?? [])\n\t\t\t\t\t\t.filter((t) => t.id !== toolDrawer.initialRest?.id)\n\t\t\t\t\t\t.map((t) => t.name)}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","BodySecondary","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":"+1BAmDMA,GAAcC,GACnBC,EAAAA,iBAAiBC,EAAAA,WAAWF,CAAM,CAAC,GAAK,OAGnCG,EAAc,IAAgC,CACnD,MAAO,EAAE,aACT,MAAO,EAAE,QACT,YAAaJ,GAAW,EAAE,QAAUK,EAAAA,WAAW,QAAQ,CACxD,GAEMC,EAAOC,GAAAA,iBAAiB,CAAC,EAwBzBC,EAAa,CAClBC,EACAC,IACS,CACT,MAAMC,EAAMF,GAAQ,CAAA,EACpB,OAAOE,EAAI,KAAMC,GAAMA,EAAE,KAAOF,EAAK,EAAE,EACpCC,EAAI,IAAKC,GAAOA,EAAE,KAAOF,EAAK,GAAKA,EAAOE,CAAE,EAC5C,CAAC,GAAGD,EAAKD,CAAI,CACjB,EAEaG,GAA+B,IAAM,CACjD,KAAM,CACL,MAAAC,EACA,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,gBAAAC,EACA,o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HR,EAAW,GAAA,EAajBA,GAAY,OAAS,UACrBA,EAAW,SACX2D,GACCE,EAAAA,IAACkB,GAAAA,gBAAA,CAEA,QAAS/E,EAAW,QACpB,SAAU2D,EACV,QAAS3D,EAAW,cACpB,WAAAf,EACA,UAAWM,EACX,QAAS,IAAMU,EAAc,IAAI,EACjC,OAAQY,CAAA,EAPHb,EAAW,GAAA,CAQjB,EAEH,CAEF"}
1
+ {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tStep3Divider,\n\tStep3Grid,\n\tStep3Root,\n} from '../AgentBuilder.styled';\nimport { ConfigToolPanel } from '../components/ConfigToolPanel';\nimport { CreateSubAgentPanel } from '../components/CreateSubAgentPanel';\nimport { MentionField } from '../components/MentionField';\nimport { RestApiToolPanel } from '../components/RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from '../components/SelectableListSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport {\n\tappTypeLabel,\n\tbuildAgentMentionItems,\n\tbuildCustomToolMentionItems,\n\tconfigToolMentionItem,\n\tconfigToolName,\n\trestApiMentionItem,\n\trestApiToolName,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport {\n\trenderSourceIcon,\n\tSOURCE_ICONS,\n\tsourceIcon,\n} from '../utils/sourceIcons';\nimport { buildToolActions } from '../utils/toolActions';\n\n/** Source brand glyph for a tool, as a dropdown leadingIcon element. */\nconst toolIconEl = (source: string): JSX.Element | undefined =>\n\trenderSourceIcon(sourceIcon(source)) ?? undefined;\n\n/** Dropdown option for a tool: icon left of the name, no description. */\nconst toolOption = (t: AgentTool): SingleOption => ({\n\tlabel: t.display_name,\n\tvalue: t.tool_id,\n\tleadingIcon: toolIconEl(t.source ?? ToolSource.Manifest),\n});\n\nconst STEP = STEP_DEFINITIONS[2];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t} = useAgentBuilderContext();\n\n\tconst [panel, setPanel] = useState<SubAgentPanelState | null>(null);\n\tconst panelKeyRef = useRef(0);\n\n\t// Rest API (bespoke) + shared config-tool drawers (separate from the sub-agent one).\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst openRestApi = useCallback((initial?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: initial,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, initial?: ConfigToolConfig) => {\n\t\t\ttoolDrawerKeyRef.current += 1;\n\t\t\tsetToolDrawer({\n\t\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\t\tkind: 'config',\n\t\t\t\ttoolKey,\n\t\t\t\tinitialConfig: initial,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\n\tconst handleSaveRestApi = useCallback(\n\t\t(config: RestApiToolConfig) => {\n\t\t\tconst isNew = !(value.restApiTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ restApiTools: upsertById(value.restApiTools, config) });\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, restApiMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.restApiTools, insertMention],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(config: ConfigToolConfig) => {\n\t\t\tconst isNew = !(value.configTools ?? []).some((t) => t.id === config.id);\n\t\t\tpatch({ configTools: upsertById(value.configTools, config) });\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention('tool', config.id, configToolMentionItem(config).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[patch, value.configTools, insertMention],\n\t);\n\n\t// Open a tool action's drawer by picker source (restapi / email / slack).\n\tconst openToolAction = useCallback(\n\t\t(source: ToolSource) => {\n\t\t\tconst toolKey = CONFIG_TOOL_SOURCES[source];\n\t\t\tif (toolKey) {\n\t\t\t\topenConfigTool(toolKey);\n\t\t\t} else {\n\t\t\t\topenRestApi();\n\t\t\t}\n\t\t},\n\t\t[openConfigTool, openRestApi],\n\t);\n\t// Let the `@` reference picker (Instructions / Guardrails) open these drawers.\n\tuseEffect(() => {\n\t\tregisterToolActionHandler(openToolAction);\n\t\treturn () => registerToolActionHandler(null);\n\t}, [registerToolActionHandler, openToolAction]);\n\t// Sub-agents created / edited in this session, so a chip resolves (and reflects\n\t// a renamed sub-agent) before the consumer refreshes `availableSubAgents`.\n\tconst [createdSubAgents, setCreatedSubAgents] = useState<SubAgentRef[]>([]);\n\t// Created/edited refs take precedence over the consumer-supplied list.\n\tconst subAgentById = new Map<string, SubAgentRef>();\n\tavailableSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tcreatedSubAgents.forEach((s) => subAgentById.set(s.id, s));\n\tconst knownSubAgents = Array.from(subAgentById.values());\n\n\tconst openCreate = useCallback(() => {\n\t\tpanelKeyRef.current += 1;\n\t\tsetPanel({ key: panelKeyRef.current, title: 'Create sub-agent' });\n\t}, []);\n\n\t// Let the `@` picker's \"Create new\" row open this step's drawer.\n\tuseEffect(() => {\n\t\tif (!onCreateSubAgent) {\n\t\t\treturn;\n\t\t}\n\t\tregisterSubAgentCreator(openCreate);\n\t\treturn () => registerSubAgentCreator(null);\n\t}, [registerSubAgentCreator, openCreate, onCreateSubAgent]);\n\n\tconst openConfigure = useCallback(\n\t\tasync (id: string) => {\n\t\t\tif (!onFetchSubAgent) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = await onFetchSubAgent(id);\n\t\t\tpanelKeyRef.current += 1;\n\t\t\tsetPanel({\n\t\t\t\tkey: panelKeyRef.current,\n\t\t\t\ttitle: 'Edit sub-agent',\n\t\t\t\teditingId: id,\n\t\t\t\tinitial: data,\n\t\t\t});\n\t\t},\n\t\t[onFetchSubAgent],\n\t);\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tif (panel?.editingId) {\n\t\t\t\tif (onUpdateSubAgent) {\n\t\t\t\t\tconst ref = await onUpdateSubAgent(panel.editingId, draft);\n\t\t\t\t\tsetCreatedSubAgents((prev) => [\n\t\t\t\t\t\t...prev.filter((s) => s.id !== ref.id),\n\t\t\t\t\t\tref,\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t} else if (onCreateSubAgent) {\n\t\t\t\tconst ref = await onCreateSubAgent(draft);\n\t\t\t\tsetCreatedSubAgents((prev) => [...prev, ref]);\n\t\t\t\tpatch({ subagents: [...value.subagents, ref.id] });\n\t\t\t\tinsertMention('subagent', ref.id, `sub-agent: ${ref.name}`);\n\t\t\t}\n\t\t\tsetPanel(null);\n\t\t},\n\t\t[\n\t\t\tpanel,\n\t\t\tonUpdateSubAgent,\n\t\t\tonCreateSubAgent,\n\t\t\tpatch,\n\t\t\tvalue.subagents,\n\t\t\tinsertMention,\n\t\t],\n\t);\n\n\tconst toolItems: SelectableItem[] = value.tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\treturn (\n\t\t<Step3Root>\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<Step3Grid $grow>\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"instructions\"\n\t\t\t\t\t\tdata-test=\"agent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write what this agent should do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionField\n\t\t\t\t\t\tfieldKey=\"guardrail\"\n\t\t\t\t\t\tdata-test=\"agent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"Things this agent must never do. Type @ to reference a tool or sub-agent.\"\n\t\t\t\t\t\tminHeight=\"140px\"\n\t\t\t\t\t/>\n\t\t\t\t</SectionBodyWrap>\n\n\t\t\t\t<Step3Divider />\n\n\t\t\t\t<SectionBodyWrap>\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools\"\n\t\t\t\t\t\thelper=\"Actions this agent can take while responding.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-tools\"\n\t\t\t\t\t\titems={allToolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={toolMentionItems}\n\t\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads\n\t\t\t\t\t\t\t// the latest value.\n\t\t\t\t\t\t\tinsertMention('tool', id);\n\t\t\t\t\t\t\taddReference('tool', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\t// Strips the tool's tokens AND drops it from whichever list holds it\n\t\t\t\t\t\t// (catalog `tools` or an inline custom-tool list).\n\t\t\t\t\t\tonRemove={(id) => removeReference('tool', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'tool' }}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Sub-agents\"\n\t\t\t\t\t\thelper=\"Other agents this agent can hand off the conversation to.\"\n\t\t\t\t\t\tdataTestPrefix=\"agent-subagents\"\n\t\t\t\t\t\titems={subAgentItems}\n\t\t\t\t\t\taddableOptions={subAgentOptions}\n\t\t\t\t\t\tmentionItems={subAgentMentionItems}\n\t\t\t\t\t\temptyText=\"No sub-agents added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertMention('subagent', id);\n\t\t\t\t\t\t\taddReference('subagent', id);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={(id) => removeReference('subagent', id)}\n\t\t\t\t\t\tconfirmDelete={{ noun: 'sub-agent' }}\n\t\t\t\t\t\tonConfigure={onFetchSubAgent ? openConfigure : undefined}\n\t\t\t\t\t\tcreateOption={\n\t\t\t\t\t\t\tonCreateSubAgent\n\t\t\t\t\t\t\t\t? { label: 'Create new', onSelect: openCreate }\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{availableModels.length > 0 && (\n\t\t\t\t\t\t<SideSection>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\tAdvanced settings\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\tSelect AI model\n\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\tdata-test=\"agent-model\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\t\t\t\t\t\t\tplaceHolder=\"Select model\"\n\t\t\t\t\t\t\t\toptions={modelOptions}\n\t\t\t\t\t\t\t\tdefaultOptions={\n\t\t\t\t\t\t\t\t\tselectedModel\n\t\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: selectedModel.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: selectedModel.value,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonSelect={(opt) => {\n\t\t\t\t\t\t\t\t\tconst v = unwrapDropdownValue(opt);\n\t\t\t\t\t\t\t\t\tif (v) {\n\t\t\t\t\t\t\t\t\t\tupdateField('model', v);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</SideSection>\n\t\t\t\t\t)}\n\t\t\t\t</SectionBodyWrap>\n\t\t\t</Step3Grid>\n\n\t\t\t{panel && (\n\t\t\t\t<CreateSubAgentPanel\n\t\t\t\t\tkey={panel.key}\n\t\t\t\t\ttitle={panel.title}\n\t\t\t\t\tinitial={panel.initial}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tappLabel={appTypeLabel(applicationType)}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveSubAgent}\n\t\t\t\t\tonImproveToolInstructions={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setPanel(null)}\n\t\t\t\t\tonSave={handlePanelSave}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","ToolSource","STEP","STEP_DEFINITIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","t","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","handlePanelSave","draft","ref","prev","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","appLabel","appTypeLabel","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","Step3Root","jsx","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","TitleSmall","COLORS","Dropdown","opt","v","unwrapDropdownValue","CreateSubAgentPanel","RestApiToolPanel","ConfigToolPanel"],"mappings":"+1BAmDMA,GAAcC,GACnBC,EAAAA,iBAAiBC,EAAAA,WAAWF,CAAM,CAAC,GAAK,OAGnCG,EAAc,IAAgC,CACnD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AEA,MAAOjF,EAAM,MACb,QAASA,EAAM,QACf,eAAAf,EACA,oBAAAG,EACA,SAAUoE,EAAAA,aAAanE,CAAe,EACtC,WAAAC,EACA,UAAWK,EACX,0BAAAC,EACA,QAAS,IAAMK,EAAS,IAAI,EAC5B,OAAQ+B,EAAA,EAVHhC,EAAM,GAAA,EAcZK,GAAY,OAAS,WACrB6D,EAAAA,IAACgB,GAAAA,iBAAA,CAEA,QAAS7E,EAAW,YACpB,WAAAf,EACA,UAAWM,EACX,QAAS,IAAMU,EAAc,IAAI,EACjC,OAAQO,CAAA,EALHR,EAAW,GAAA,EASjBA,GAAY,OAAS,UACrBA,EAAW,SACX2D,GACCE,EAAAA,IAACiB,GAAAA,gBAAA,CAEA,QAAS9E,EAAW,QACpB,SAAU2D,EACV,QAAS3D,EAAW,cACpB,WAAAf,EACA,UAAWM,EACX,QAAS,IAAMU,EAAc,IAAI,EACjC,OAAQY,CAAA,EAPHb,EAAW,GAAA,CAQjB,EAEH,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("../AgentBuilder.styled.js"),d=require("../components/AiTextArea.js"),h=require("../components/StepSectionHeader.js"),c=require("../constants/steps.js"),l=require("../context/AgentBuilderContext.js"),r=c.STEP_DEFINITIONS[3],u=()=>{const{value:n,patch:a,charLimits:o}=l.useAgentBuilderContext(),{handover:t}=n;return e.jsxs("div",{className:"bik-agent-step bik-agent-step--handover",children:[e.jsx(h.StepSectionHeader,{title:r.title,helper:r.helper}),e.jsx(i.SectionBodyWrap,{children:e.jsx(d.AiTextArea,{"data-test":"handover-when",label:"Handover when",value:t.when,onChange:s=>a({handover:{...t,when:s}}),maxLength:o.handoverWhen,placeholder:"e.g. Hand over if the customer is angry or asks for a human three times. Hand over if the order value exceeds ₹5,000.",minHeight:"120px"})})]})};exports.Step4HandoverRules=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../radioButton/RadioButton.js"),r=require("../../TypographyStyle.js"),n=require("../../../constants/Theme.js"),o=require("../AgentBuilder.styled.js"),u=require("../components/AiTextArea.js"),p=require("../components/StepSectionHeader.js"),x=require("../constants/steps.js"),C=require("../context/AgentBuilderContext.js"),d=x.STEP_DEFINITIONS[3],S=()=>{const{value:l,patch:a,charLimits:h}=C.useAgentBuilderContext(),{handover:t}=l,s=i=>a({handover:{...t,method:i}});return e.jsxs("div",{className:"bik-agent-step bik-agent-step--handover",children:[e.jsx(p.StepSectionHeader,{title:d.title,helper:d.helper}),e.jsxs(o.SectionBodyWrap,{children:[e.jsx(u.AiTextArea,{"data-test":"handover-when",label:"Handover when",value:t.when,onChange:i=>a({handover:{...t,when:i}}),maxLength:h.handoverWhen,placeholder:"e.g. Hand over if the customer is angry or requests a human agent.",minHeight:"120px"}),e.jsxs(o.FieldBlock,{children:[e.jsx(r.TitleSmall,{color:n.COLORS.content.primary,children:"Handover method"}),e.jsxs(o.CardRow,{children:[e.jsxs(o.RadioCard,{"data-test":"handover-method-default",selected:t.method==="default",onClick:()=>s("default"),children:[e.jsx(c.RadioButton,{isActive:t.method==="default",onValueChange:()=>s("default"),skipSelectingOff:!0,activeColor:n.COLORS.content.brand}),e.jsxs(o.RadioCardText,{children:[e.jsx(r.TitleSmall,{color:n.COLORS.content.primary,children:"Use default settings"}),e.jsx(r.BodyCaption,{color:n.COLORS.content.secondary,children:"Defined in Customize > Agent handover"})]})]}),e.jsxs(o.RadioCard,{"data-test":"handover-method-specific",selected:t.method==="specific_channels",onClick:()=>s("specific_channels"),children:[e.jsx(c.RadioButton,{isActive:t.method==="specific_channels",onValueChange:()=>s("specific_channels"),skipSelectingOff:!0,activeColor:n.COLORS.content.brand}),e.jsxs(o.RadioCardText,{children:[e.jsx(r.TitleSmall,{color:n.COLORS.content.primary,children:"Choose specific channels"}),e.jsx(r.BodyCaption,{color:n.COLORS.content.secondary,children:"Always hands over regardless of business hours."})]})]})]})]})]})]})};exports.Step4HandoverRules=S;
2
2
  //# sourceMappingURL=Step4HandoverRules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step4HandoverRules.js","sources":["../../../../../src/components/agent-builder/steps/Step4HandoverRules.tsx"],"sourcesContent":["import React from 'react';\nimport { SectionBodyWrap } from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[3];\n\n// The \"Handover method\" radio section was removed: the method is UI-only and the\n// consumer always sends the seeded default ('default'); handover.method stays on\n// the value shape untouched.\nexport const Step4HandoverRules: React.FC = () => {\n\tconst { value, patch, charLimits } = useAgentBuilderContext();\n\tconst { handover } = value;\n\n\treturn (\n\t\t<div className=\"bik-agent-step bik-agent-step--handover\">\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"handover-when\"\n\t\t\t\t\tlabel=\"Handover when\"\n\t\t\t\t\tvalue={handover.when}\n\t\t\t\t\tonChange={(text) => patch({ handover: { ...handover, when: text } })}\n\t\t\t\t\tmaxLength={charLimits.handoverWhen}\n\t\t\t\t\tplaceholder=\"e.g. Hand over if the customer is angry or asks for a human three times. Hand over if the order value exceeds ₹5,000.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step4HandoverRules","value","patch","charLimits","useAgentBuilderContext","handover","jsxs","jsx","StepSectionHeader","SectionBodyWrap","AiTextArea","text"],"mappings":"uUAOMA,EAAOC,EAAAA,iBAAiB,CAAC,EAKlBC,EAA+B,IAAM,CACjD,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,CAAA,EAAeC,EAAAA,uBAAA,EAC/B,CAAE,SAAAC,GAAaJ,EAErB,OACCK,EAAAA,KAAC,MAAA,CAAI,UAAU,0CACd,SAAA,CAAAC,MAACC,EAAAA,mBAAkB,MAAOV,EAAK,MAAO,OAAQA,EAAK,OAAQ,QAE1DW,EAAAA,gBAAA,CACA,SAAAF,EAAAA,IAACG,EAAAA,WAAA,CACA,YAAU,gBACV,MAAM,gBACN,MAAOL,EAAS,KAChB,SAAWM,GAAST,EAAM,CAAE,SAAU,CAAE,GAAGG,EAAU,KAAMM,CAAA,EAAQ,EACnE,UAAWR,EAAW,aACtB,YAAY,wHACZ,UAAU,OAAA,CAAA,CACX,CACD,CAAA,EACD,CAEF"}
1
+ {"version":3,"file":"Step4HandoverRules.js","sources":["../../../../../src/components/agent-builder/steps/Step4HandoverRules.tsx"],"sourcesContent":["import React from 'react';\nimport { RadioButton } from '@src/components/radioButton/RadioButton';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { HandoverMethod } from '../AgentBuilder.model';\nimport {\n\tCardRow,\n\tFieldBlock,\n\tRadioCard,\n\tRadioCardText,\n\tSectionBodyWrap,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[3];\n\nexport const Step4HandoverRules: React.FC = () => {\n\tconst { value, patch, charLimits } = useAgentBuilderContext();\n\tconst { handover } = value;\n\n\tconst setMethod = (method: HandoverMethod) =>\n\t\tpatch({ handover: { ...handover, method } });\n\n\treturn (\n\t\t<div className=\"bik-agent-step bik-agent-step--handover\">\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"handover-when\"\n\t\t\t\t\tlabel=\"Handover when\"\n\t\t\t\t\tvalue={handover.when}\n\t\t\t\t\tonChange={(text) => patch({ handover: { ...handover, when: text } })}\n\t\t\t\t\tmaxLength={charLimits.handoverWhen}\n\t\t\t\t\tplaceholder=\"e.g. Hand over if the customer is angry or requests a human agent.\"\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t/>\n\n\t\t\t\t<FieldBlock>\n\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\tHandover method\n\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t<CardRow>\n\t\t\t\t\t\t<RadioCard\n\t\t\t\t\t\t\tdata-test=\"handover-method-default\"\n\t\t\t\t\t\t\tselected={handover.method === 'default'}\n\t\t\t\t\t\t\tonClick={() => setMethod('default')}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\t\tisActive={handover.method === 'default'}\n\t\t\t\t\t\t\t\tonValueChange={() => setMethod('default')}\n\t\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tUse default settings\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\tDefined in Customize &gt; Agent handover\n\t\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t\t</RadioCard>\n\n\t\t\t\t\t\t<RadioCard\n\t\t\t\t\t\t\tdata-test=\"handover-method-specific\"\n\t\t\t\t\t\t\tselected={handover.method === 'specific_channels'}\n\t\t\t\t\t\t\tonClick={() => setMethod('specific_channels')}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<RadioButton\n\t\t\t\t\t\t\t\tisActive={handover.method === 'specific_channels'}\n\t\t\t\t\t\t\t\tonValueChange={() => setMethod('specific_channels')}\n\t\t\t\t\t\t\t\tskipSelectingOff\n\t\t\t\t\t\t\t\tactiveColor={COLORS.content.brand}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<RadioCardText>\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tChoose specific channels\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t\t\tAlways hands over regardless of business hours.\n\t\t\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t\t</RadioCardText>\n\t\t\t\t\t\t</RadioCard>\n\t\t\t\t\t</CardRow>\n\t\t\t\t</FieldBlock>\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step4HandoverRules","value","patch","charLimits","useAgentBuilderContext","handover","setMethod","method","jsxs","jsx","StepSectionHeader","SectionBodyWrap","AiTextArea","text","FieldBlock","TitleSmall","COLORS","CardRow","RadioCard","RadioButton","RadioCardText","BodyCaption"],"mappings":"ocAiBMA,EAAOC,EAAAA,iBAAiB,CAAC,EAElBC,EAA+B,IAAM,CACjD,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,WAAAC,CAAA,EAAeC,EAAAA,uBAAA,EAC/B,CAAE,SAAAC,GAAaJ,EAEfK,EAAaC,GAClBL,EAAM,CAAE,SAAU,CAAE,GAAGG,EAAU,OAAAE,CAAA,EAAU,EAE5C,OACCC,EAAAA,KAAC,MAAA,CAAI,UAAU,0CACd,SAAA,CAAAC,MAACC,EAAAA,mBAAkB,MAAOZ,EAAK,MAAO,OAAQA,EAAK,OAAQ,SAE1Da,EAAAA,gBAAA,CACA,SAAA,CAAAF,EAAAA,IAACG,EAAAA,WAAA,CACA,YAAU,gBACV,MAA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AAW,SAAA,iDAAA,CAE9C,CAAA,CAAA,CACD,CAAA,CAAA,CAAA,CACD,CAAA,CACD,CAAA,CAAA,CACD,CAAA,CAAA,CACD,CAAA,EACD,CAEF"}
@@ -1,6 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../constants/tools.js"),m=(e,t="Manifest")=>e?i.TOOL_SOURCE_LABELS[e]??e:t,L=e=>{const t=e?String(e):"";return t==="BIK"?"BIK":t==="BSP"?"BSP":"Manifest"},k=(e,t,n="Manifest")=>[...e.map(o=>({id:o.tool_id,label:`${m(o.source,n)} : ${o.display_name}`,meta:{kind:"tool",plainLabel:o.display_name,source:o.source}})),...t.map(o=>({id:o.id,label:`sub-agent: ${o.name}`,meta:{kind:"subagent",plainLabel:o.name}}))],d=e=>e.tool_key==="send_slack_message"?String(e.params.channelId?.value??"").trim()||"Send Slack message":String(e.params.sendTo?.value??"").split(",").map(t=>t.trim()).filter(Boolean)[0]||"Send Email",p=e=>e.name||"Rest API",b=e=>{const t=p(e);return{id:e.id,label:`${i.TOOL_SOURCE_LABELS[i.ToolSource.RestApi]} : ${t}`,meta:{kind:"tool",plainLabel:t,source:i.ToolSource.RestApi}}},g=e=>{const t=e.tool_key==="send_slack_message"?i.ToolSource.Slack:i.ToolSource.EmailHandover,n=d(e);return{id:e.id,label:`${i.TOOL_SOURCE_LABELS[t]} : ${n}`,meta:{kind:"tool",plainLabel:n,source:t}}},_=(e=[],t=[])=>[...t.map(b),...e.map(g)],s=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=e=>s(e).replace(/"/g,"&quot;"),S=(e,t,n)=>`<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${r(e)}" data-label="${r(t)}" data-kind="${r(n)}">${s(t)}</span>`,$=(e,t,n)=>S(e,t,n),f=e=>{const t=new Map;for(const n of e){const o=n.meta;o?.kind==="tool"?t.set(`tool:${String(n.id)}`,n):o?.kind==="subagent"&&t.set(`subagent:${String(n.id)}`,n)}return t},c=/\{\{(tool:[^}]+|subagent:[^}]+)\}\}/g,E=(e,t)=>{let n="",o=0;c.lastIndex=0;let a;for(;(a=c.exec(e))!==null;){n+=s(e.slice(o,a.index));const l=t.get(a[1]);if(l){const T=l.meta.kind;n+=S(String(l.id),l.label,T)}else n+=s(a[0]);o=c.lastIndex}return n+=s(e.slice(o)),n.replace(/\n/g,"<br>")},O=(e,t=[])=>{if(!e)return"";const n=f(t);return e.split(/\n{2,}/).map(o=>`<p>${E(o,n)}</p>`).join("")},A=(e,t,n)=>(t??(n.has(e)?"tool":"subagent"))==="tool"?`{{tool:${e}}}`:`{{subagent:${e}}}`,u=(e,t)=>{switch(e.type){case"text":return e.text??"";case"mentionAgent":case"mentionTeam":{const n=e.attrs?.id;if(n==null)return"";const o=e.attrs?.kind;return A(String(n),o==null?null:String(o),t)}case"variable":return`{{${String(e.attrs?.variableName??"")}}}`;case"hardBreak":return`
2
- `;case"orderedList":case"bulletList":{const n=e.type==="orderedList";return(e.content??[]).map((o,a)=>`${n?`${a+1}.`:"-"} ${u(o,t).replace(/\n+$/,"")}`).join(`
3
- `)+`
4
- `}default:{const n=(e.content??[]).map(a=>u(a,t)).join("");return["paragraph","heading","listItem","blockquote"].includes(e.type)?`${n}
5
- `:n}}},I=(e,t)=>{if(!e)return"";const n=new Set(t.map(o=>o.tool_id));return u(e,n).replace(/\n+$/,"")};exports.TOOL_SOURCE_LABELS=i.TOOL_SOURCE_LABELS;exports.appTypeLabel=L;exports.buildAgentMentionItems=k;exports.buildCustomToolMentionItems=_;exports.buildMentionHtml=$;exports.configToolMentionItem=g;exports.configToolName=d;exports.editorDocToInstructions=I;exports.instructionsToEditorHtml=O;exports.restApiMentionItem=b;exports.restApiToolName=p;exports.toolSourceLabel=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../constants/tools.js"),u=(e,t="Manifest")=>e?a.TOOL_SOURCE_LABELS[e]??e:t,k=e=>{const t=e?String(e):"";return t==="BIK"?"BIK":t==="BSP"?"BSP":"Manifest"},L=(e,t,n="Manifest")=>[...e.map(o=>({id:o.tool_id,label:`${u(o.source,n)} : ${o.display_name}`,meta:{kind:"tool",plainLabel:o.display_name,source:o.source}})),...t.map(o=>({id:o.id,label:`sub-agent: ${o.name}`,meta:{kind:"subagent",plainLabel:o.name}}))],m=e=>e.tool_key==="send_slack_message"?String(e.params.channelId?.value??"").trim()||"Send Slack message":String(e.params.sendTo?.value??"").split(",").map(t=>t.trim()).filter(Boolean)[0]||"Handover to email",d=e=>e.name||"Rest API",p=e=>{const t=d(e);return{id:e.id,label:`${a.TOOL_SOURCE_LABELS[a.ToolSource.RestApi]} : ${t}`,meta:{kind:"tool",plainLabel:t,source:a.ToolSource.RestApi}}},g=e=>{const t=e.tool_key==="send_slack_message"?a.ToolSource.Slack:a.ToolSource.EmailHandover,n=m(e);return{id:e.id,label:`${a.TOOL_SOURCE_LABELS[t]} : ${n}`,meta:{kind:"tool",plainLabel:n,source:t}}},_=(e=[],t=[])=>[...t.map(p),...e.map(g)],l=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=e=>l(e).replace(/"/g,"&quot;"),b=(e,t,n)=>`<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${r(e)}" data-label="${r(t)}" data-kind="${r(n)}">${l(t)}</span>`,f=(e,t,n)=>b(e,t,n),O=e=>{const t=new Map;for(const n of e){const o=n.meta;o?.kind==="tool"?t.set(`tool:${String(n.id)}`,n):o?.kind==="subagent"&&t.set(`subagent:${String(n.id)}`,n)}return t},c=/\{\{(tool:[^}]+|subagent:[^}]+)\}\}/g,E=(e,t)=>{let n="",o=0;c.lastIndex=0;let i;for(;(i=c.exec(e))!==null;){n+=l(e.slice(o,i.index));const s=t.get(i[1]);if(s){const T=s.meta.kind;n+=b(String(s.id),s.label,T)}else n+=l(i[0]);o=c.lastIndex}return n+=l(e.slice(o)),n.replace(/\n/g,"<br>")},$=(e,t=[])=>{if(!e)return"";const n=O(t);return e.split(/\n{2,}/).map(o=>`<p>${E(o,n)}</p>`).join("")},I=(e,t,n)=>(t??(n.has(e)?"tool":"subagent"))==="tool"?`{{tool:${e}}}`:`{{subagent:${e}}}`,S=(e,t)=>{switch(e.type){case"text":return e.text??"";case"mentionAgent":case"mentionTeam":{const n=e.attrs?.id;if(n==null)return"";const o=e.attrs?.kind;return I(String(n),o==null?null:String(o),t)}case"variable":return`{{${String(e.attrs?.variableName??"")}}}`;case"hardBreak":return`
2
+ `;default:{const n=(e.content??[]).map(i=>S(i,t)).join("");return["paragraph","heading","listItem","blockquote"].includes(e.type)?`${n}
3
+ `:n}}},A=(e,t)=>{if(!e)return"";const n=new Set(t.map(o=>o.tool_id));return S(e,n).replace(/\n+$/,"")};exports.TOOL_SOURCE_LABELS=a.TOOL_SOURCE_LABELS;exports.appTypeLabel=k;exports.buildAgentMentionItems=L;exports.buildCustomToolMentionItems=_;exports.buildMentionHtml=f;exports.configToolMentionItem=g;exports.configToolName=m;exports.editorDocToInstructions=A;exports.instructionsToEditorHtml=$;exports.restApiMentionItem=p;exports.restApiToolName=d;exports.toolSourceLabel=u;
6
4
  //# sourceMappingURL=mentionSerialization.js.map