@bikdotai/bik-component-library 0.0.865-beta.4 → 0.0.865-beta.6

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 (127) hide show
  1. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  2. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +29 -151
  4. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +5 -5
  6. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/MentionEditor.js +2 -2
  8. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  10. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/MentionPicker.js +13 -13
  12. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +3 -3
  14. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/constants/steps.js +1 -1
  16. package/dist/cjs/components/agent-builder/constants/steps.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  18. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/steps/Step1About.js +1 -1
  20. package/dist/cjs/components/agent-builder/steps/Step1About.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +2 -2
  22. package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  23. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  24. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  25. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
  26. package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  27. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +4 -4
  28. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  29. package/dist/cjs/components/button/Button.js +1 -1
  30. package/dist/cjs/components/button/Button.js.map +1 -1
  31. package/dist/cjs/components/button/Button.styled.js +2 -2
  32. package/dist/cjs/components/button/Button.styled.js.map +1 -1
  33. package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
  34. package/dist/cjs/components/dropdown-button/DropdownButton.js.map +1 -1
  35. package/dist/cjs/components/tag/Tag.js +1 -1
  36. package/dist/cjs/components/tag/Tag.js.map +1 -1
  37. package/dist/cjs/components/tag/Tag.styled.js +4 -4
  38. package/dist/cjs/components/tag/Tag.styled.js.map +1 -1
  39. package/dist/cjs/components/tag/model.js.map +1 -1
  40. package/dist/cjs/icons/BIK AI specific/WandSparkles.js +1 -1
  41. package/dist/cjs/icons/BIK AI specific/WandSparkles.js.map +1 -1
  42. package/dist/cjs/icons/Informational/General/MessageSource.js +2 -0
  43. package/dist/cjs/icons/Informational/General/MessageSource.js.map +1 -0
  44. package/dist/cjs/icons/index.js +1 -1
  45. package/dist/cjs/index.js +1 -1
  46. package/dist/esm/components/agent-builder/AgentBuilder.js +97 -103
  47. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  48. package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +0 -76
  49. package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -68
  50. package/dist/esm/components/agent-builder/AgentBuilder.styled.js +59 -224
  51. package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  52. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +132 -135
  53. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  54. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +0 -2
  55. package/dist/esm/components/agent-builder/components/MentionEditor.js +45 -47
  56. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  57. package/dist/esm/components/agent-builder/components/MentionField.js +51 -52
  58. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  59. package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +0 -5
  60. package/dist/esm/components/agent-builder/components/MentionPicker.js +132 -134
  61. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  62. package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +0 -2
  63. package/dist/esm/components/agent-builder/components/SelectableListSection.js +46 -48
  64. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  65. package/dist/esm/components/agent-builder/constants/steps.d.ts +1 -31
  66. package/dist/esm/components/agent-builder/constants/steps.js +6 -15
  67. package/dist/esm/components/agent-builder/constants/steps.js.map +1 -1
  68. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +1 -13
  69. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +148 -157
  70. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  71. package/dist/esm/components/agent-builder/index.d.ts +2 -5
  72. package/dist/esm/components/agent-builder/steps/Step1About.js +13 -15
  73. package/dist/esm/components/agent-builder/steps/Step1About.js.map +1 -1
  74. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +48 -55
  75. package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
  76. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +157 -158
  77. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  78. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.d.ts +0 -11
  79. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +23 -127
  80. package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
  81. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +2 -7
  82. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +2 -2
  83. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  84. package/dist/esm/components/button/Button.js +21 -19
  85. package/dist/esm/components/button/Button.js.map +1 -1
  86. package/dist/esm/components/button/Button.styled.d.ts +1 -0
  87. package/dist/esm/components/button/Button.styled.js +5 -5
  88. package/dist/esm/components/button/Button.styled.js.map +1 -1
  89. package/dist/esm/components/button/model.d.ts +5 -0
  90. package/dist/esm/components/dropdown-button/DropdownButton.d.ts +5 -0
  91. package/dist/esm/components/dropdown-button/DropdownButton.js +4 -3
  92. package/dist/esm/components/dropdown-button/DropdownButton.js.map +1 -1
  93. package/dist/esm/components/tag/Tag.d.ts +1 -1
  94. package/dist/esm/components/tag/Tag.js +48 -41
  95. package/dist/esm/components/tag/Tag.js.map +1 -1
  96. package/dist/esm/components/tag/Tag.styled.d.ts +3 -0
  97. package/dist/esm/components/tag/Tag.styled.js +6 -9
  98. package/dist/esm/components/tag/Tag.styled.js.map +1 -1
  99. package/dist/esm/components/tag/model.d.ts +11 -0
  100. package/dist/esm/components/tag/model.js.map +1 -1
  101. package/dist/esm/icons/BIK AI specific/WandSparkles.js +1 -1
  102. package/dist/esm/icons/BIK AI specific/WandSparkles.js.map +1 -1
  103. package/dist/esm/icons/Informational/General/MessageSource.d.ts +7 -0
  104. package/dist/esm/icons/Informational/General/MessageSource.js +46 -0
  105. package/dist/esm/icons/Informational/General/MessageSource.js.map +1 -0
  106. package/dist/esm/icons/Informational/General/index.d.ts +1 -0
  107. package/dist/esm/icons/index.d.ts +25 -25
  108. package/dist/esm/icons/index.js +294 -292
  109. package/dist/esm/icons/index.js.map +1 -1
  110. package/dist/esm/index.js +636 -644
  111. package/dist/esm/index.js.map +1 -1
  112. package/package.json +1 -1
  113. package/dist/cjs/components/agent-builder/components/ChannelSelectModal.js +0 -2
  114. package/dist/cjs/components/agent-builder/components/ChannelSelectModal.js.map +0 -1
  115. package/dist/cjs/components/agent-builder/components/ChannelsSection.js +0 -2
  116. package/dist/cjs/components/agent-builder/components/ChannelsSection.js.map +0 -1
  117. package/dist/cjs/components/agent-builder/constants/channels.js +0 -2
  118. package/dist/cjs/components/agent-builder/constants/channels.js.map +0 -1
  119. package/dist/esm/components/agent-builder/components/ChannelSelectModal.d.ts +0 -26
  120. package/dist/esm/components/agent-builder/components/ChannelSelectModal.js +0 -121
  121. package/dist/esm/components/agent-builder/components/ChannelSelectModal.js.map +0 -1
  122. package/dist/esm/components/agent-builder/components/ChannelsSection.d.ts +0 -10
  123. package/dist/esm/components/agent-builder/components/ChannelsSection.js +0 -183
  124. package/dist/esm/components/agent-builder/components/ChannelsSection.js.map +0 -1
  125. package/dist/esm/components/agent-builder/constants/channels.d.ts +0 -56
  126. package/dist/esm/components/agent-builder/constants/channels.js +0 -41
  127. package/dist/esm/components/agent-builder/constants/channels.js.map +0 -1
@@ -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 type { VariableListInterfaceV3 } from '../../variable-picker-v3/model';\nimport {\n\tAgentChannel,\n\tAgentChannelType,\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\t/** Tool source, for the chip's leading icon. Pass it for a JUST-created custom\n\t * tool that isn't in the editor's mention list yet (else the chip has no icon\n\t * until reload); existing tools resolve it from the list. */\n\tsource?: 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: MentionInsertFn;\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/**\n\t * Variable catalog for the `@` picker's \"Variables\" view. Absent / empty →\n\t * the category is hidden. Fed by the consumer via `variablesData`.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/**\n\t * The store's connected channels + accounts. Absent / empty hides Step 1's\n\t * \"Channels to activate it on\" section entirely.\n\t */\n\tavailableChannels?: AgentChannel[];\n\t/** Open the consumer's channel-management screen. Omit to hide the link. */\n\tonManageChannels?: (type: AgentChannelType) => void;\n\t/** Open the consumer's smart-agent-handover settings (Step 4, BIK only). */\n\tonSmartAgentHandover?: () => void;\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\n/**\n * Step 2's two trigger modes are mutually exclusive, so the unselected one's data\n * is dropped — but only when the merchant LEAVES step 2, never the instant they\n * toggle the radio. Toggling to compare the two options and finding your intents\n * (or the sentence you typed) gone reads as the builder eating your work.\n */\nconst triggerForSelectedMode = (\n\ttrigger: AgentValue['trigger'],\n): AgentValue['trigger'] =>\n\ttrigger.mode === 'custom_intent'\n\t\t? { ...trigger, intents: [] }\n\t\t: { ...trigger, custom_intent: '' };\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\tvariablesData?: VariableListInterfaceV3[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tavailableChannels?: AgentChannel[];\n\tonManageChannels?: (type: AgentChannelType) => void;\n\tonSmartAgentHandover?: () => void;\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\tvariablesData,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tavailableChannels,\n\tonManageChannels,\n\tonSmartAgentHandover,\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>(\n\t\t(kind, id, label, source) => {\n\t\t\tconst inserters = mentionInsertersRef.current;\n\t\t\tconst target =\n\t\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\t\ttarget?.(kind, id, label, source);\n\t\t},\n\t\t[],\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\t// Leaving step 2 is the point the mode choice becomes final (Next, or a\n\t\t\t// rail jump). Done here rather than in Step 2's radio so switching back and\n\t\t\t// forth keeps both — see `triggerForSelectedMode`.\n\t\t\tif (activeStep === 'trigger' && step !== 'trigger') {\n\t\t\t\tonChange({ trigger: triggerForSelectedMode(value.trigger) });\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[\n\t\t\tcontrolledStep,\n\t\t\tonStepChange,\n\t\t\tactiveIndex,\n\t\t\tvalidation,\n\t\t\tactiveStep,\n\t\t\tonChange,\n\t\t\tvalue.trigger,\n\t\t],\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\tvariablesData,\n\t\t\tapplicationType,\n\t\t\tavailableChannels,\n\t\t\tonManageChannels,\n\t\t\tonSmartAgentHandover,\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\tvariablesData,\n\t\t\tapplicationType,\n\t\t\tavailableChannels,\n\t\t\tonManageChannels,\n\t\t\tonSmartAgentHandover,\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","triggerForSelectedMode","trigger","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","onConnectIntegration","variablesData","validationOverride","applicationType","availableChannels","onManageChannels","onSmartAgentHandover","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":"uRAiLMA,GACLC,GAA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EACAa,EACA8B,GACAC,GACAzD,EACAC,EACAiC,EACAK,GACAE,GACAR,EACAzD,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAE,EACAC,EACAC,EACAC,EACA0C,EACAxC,EACAC,EACAwB,EACAC,EACAE,EACAC,EACA3B,EACAC,EACAC,EACAC,CAAA,CACD,EAGD,cACElC,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAAgC,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 type { VariableListInterfaceV3 } from '../../variable-picker-v3/model';\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\t/** Tool source, for the chip's leading icon. Pass it for a JUST-created custom\n\t * tool that isn't in the editor's mention list yet (else the chip has no icon\n\t * until reload); existing tools resolve it from the list. */\n\tsource?: 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: MentionInsertFn;\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/**\n\t * Variable catalog for the `@` picker's \"Variables\" view. Absent / empty →\n\t * the category is hidden. Fed by the consumer via `variablesData`.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\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\n/**\n * Step 2's two trigger modes are mutually exclusive, so the unselected one's data\n * is dropped — but only when the merchant LEAVES step 2, never the instant they\n * toggle the radio. Toggling to compare the two options and finding your intents\n * (or the sentence you typed) gone reads as the builder eating your work.\n */\nconst triggerForSelectedMode = (\n\ttrigger: AgentValue['trigger'],\n): AgentValue['trigger'] =>\n\ttrigger.mode === 'custom_intent'\n\t\t? { ...trigger, intents: [] }\n\t\t: { ...trigger, custom_intent: '' };\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\tvariablesData?: VariableListInterfaceV3[];\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\tvariablesData,\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>(\n\t\t(kind, id, label, source) => {\n\t\t\tconst inserters = mentionInsertersRef.current;\n\t\t\tconst target =\n\t\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\t\ttarget?.(kind, id, label, source);\n\t\t},\n\t\t[],\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\t// Leaving step 2 is the point the mode choice becomes final (Next, or a\n\t\t\t// rail jump). Done here rather than in Step 2's radio so switching back and\n\t\t\t// forth keeps both — see `triggerForSelectedMode`.\n\t\t\tif (activeStep === 'trigger' && step !== 'trigger') {\n\t\t\t\tonChange({ trigger: triggerForSelectedMode(value.trigger) });\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[\n\t\t\tcontrolledStep,\n\t\t\tonStepChange,\n\t\t\tactiveIndex,\n\t\t\tvalidation,\n\t\t\tactiveStep,\n\t\t\tonChange,\n\t\t\tvalue.trigger,\n\t\t],\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\tvariablesData,\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\tvariablesData,\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","triggerForSelectedMode","trigger","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","onConnectIntegration","variablesData","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":"uRAsKMA,GACLC,GAAAA,QAAM,cAA+C,IAAI,EAE7CC,GAAyB,IAAgC,CACrE,MAAMC,EAAMC,EAAAA,WAAWJ,EAAmB,EAC1C,GAAI,CAACG,EACJ,MAAM,IAAI,MACT,oEAAA,EAGF,OAAOA,CACR,EAGME,GAAmB,CACxBC,EACAC,IACoB,CACpB,MAAMC,EACLF,EAAM,QAAQ,OAAS,iBACnBA,EAAM,QAAQ,eAAiB,IAAI,KAAA,EAAO,OAAS,EACpDA,EAAM,QAAQ,QAAQ,OAAS,EAEnC,MAAO,CACN,MACCA,EAAM,KAAK,KAAA,EAAO,OAAS,GAC3BA,EAAM,KAAK,QAAUC,EAAO,MAC5BD,EAAM,YAAY,QAAUC,EAAO,YACpC,QAASC,EAET,SACCF,EAAM,aAAa,KAAA,EAAO,OAAS,IAClCA,EAAM,WAAa,IAAI,KAAA,EAAO,OAAS,EAEzC,SAAU,EAAA,CAEZ,EAQMG,GACLC,GAEAA,EAAQ,OAAS,gBACd,CAAE,GAAGA,EAAS,QAAS,CAAA,CAAC,EACxB,CAAE,GAAGA,EAAS,cAAe,EAAA,EA8BpBC,GAAgD,CAAC,CAC7D,MAAAL,EACA,SAAAM,EACA,WAAYC,EACZ,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,kBAAAC,EAC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EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,cAAAC,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,CACCzB,EACAyE,GACAE,GACAG,GACAG,GACA9C,EACAgB,EACAZ,EACAI,EACAa,EACA8B,GACAC,GACAzD,EACAC,EACAiC,EACAK,EACAE,EACAR,EACAtD,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAE,EACA0C,EACAxC,EACAC,EACAwB,EACAC,EACAE,EACAC,EACA3B,EACAC,EACAC,EACAC,CAAA,CACD,EAGD,cACE/B,GAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAA6B,GACF,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../AgentBuilder.styled.js"),o=require("../components/AiTextArea.js"),l=require("../components/ChannelsSection.js"),c=require("../components/StepSectionHeader.js"),d=require("../constants/steps.js"),u=require("../context/AgentBuilderContext.js"),p=require("../../input/Input.js"),a=d.STEP_DEFINITIONS[0],x=()=>{const{value:n,updateField:i,charLimits:r}=u.useAgentBuilderContext();return e.jsxs("div",{className:"bik-agent-step bik-agent-step--about",children:[e.jsx(c.StepSectionHeader,{title:a.title,helper:a.helper}),e.jsxs(s.SectionBodyWrap,{children:[e.jsx("div",{children:e.jsx(p.Input,{"data-test":"agent-name",labelText:"Agent name",labelTextBold:!0,placeholder:"Enter agent name",value:n.name,maxCharLimit:r.name,maxCharLimitPosition:"TOP",maxCharStyle:{fontSize:12,lineHeight:"16px"},onChangeText:t=>i("name",t)})}),e.jsx(o.AiTextArea,{"data-test":"agent-description",label:"What it does",value:n.description,onChange:t=>i("description",t),maxLength:r.description,placeholder:"Enter description",minHeight:"200px"}),e.jsx(l.ChannelsSection,{})]})]})};exports.Step1About=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../AgentBuilder.styled.js"),o=require("../components/AiTextArea.js"),l=require("../components/StepSectionHeader.js"),c=require("../constants/steps.js"),d=require("../context/AgentBuilderContext.js"),u=require("../../input/Input.js"),a=c.STEP_DEFINITIONS[0],p=()=>{const{value:n,updateField:i,charLimits:r}=d.useAgentBuilderContext();return e.jsxs("div",{className:"bik-agent-step bik-agent-step--about",children:[e.jsx(l.StepSectionHeader,{title:a.title,helper:a.helper}),e.jsxs(s.SectionBodyWrap,{children:[e.jsx("div",{children:e.jsx(u.Input,{"data-test":"agent-name",labelText:"Agent name",labelTextBold:!0,placeholder:"Enter agent name",value:n.name,maxCharLimit:r.name,maxCharLimitPosition:"TOP",maxCharStyle:{fontSize:12,lineHeight:"16px"},onChangeText:t=>i("name",t)})}),e.jsx(o.AiTextArea,{"data-test":"agent-description",label:"What it does",value:n.description,onChange:t=>i("description",t),maxLength:r.description,placeholder:"Enter description",minHeight:"200px"})]})]})};exports.Step1About=p;
2
2
  //# sourceMappingURL=Step1About.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step1About.js","sources":["../../../../../src/components/agent-builder/steps/Step1About.tsx"],"sourcesContent":["import React from 'react';\nimport { Input } from '@src/components/input';\nimport { SectionBodyWrap } from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { ChannelsSection } from '../components/ChannelsSection';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { STEP_DEFINITIONS } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\n\nconst STEP = STEP_DEFINITIONS[0];\n\nexport const Step1About: React.FC = () => {\n\tconst { value, updateField, charLimits } = useAgentBuilderContext();\n\n\treturn (\n\t\t<div className=\"bik-agent-step bik-agent-step--about\">\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<div>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"agent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={value.name}\n\t\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={(text) => updateField('name', text)}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"agent-description\"\n\t\t\t\t\tlabel=\"What it does\"\n\t\t\t\t\tvalue={value.description}\n\t\t\t\t\tonChange={(text) => updateField('description', text)}\n\t\t\t\t\tmaxLength={charLimits.description}\n\t\t\t\t\tplaceholder=\"Enter description\"\n\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t/>\n\n\t\t\t\t<ChannelsSection />\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step1About","value","updateField","charLimits","useAgentBuilderContext","jsxs","jsx","StepSectionHeader","SectionBodyWrap","Input","text","AiTextArea","ChannelsSection"],"mappings":"uZASMA,EAAOC,EAAAA,iBAAiB,CAAC,EAElBC,EAAuB,IAAM,CACzC,KAAM,CAAE,MAAAC,EAAO,YAAAC,EAAa,WAAAC,CAAA,EAAeC,EAAAA,uBAAA,EAE3C,OACCC,EAAAA,KAAC,MAAA,CAAI,UAAU,uCACd,SAAA,CAAAC,MAACC,EAAAA,mBAAkB,MAAOT,EAAK,MAAO,OAAQA,EAAK,OAAQ,SAE1DU,EAAAA,gBAAA,CACA,SAAA,CAAAF,MAAC,MAAA,CACA,SAAAA,EAAAA,IAACG,EAAAA,MAAA,CACA,YAAU,aACV,UAAU,aACV,cAAa,GACb,YAAY,mBACZ,MAAOR,EAAM,KACb,aAAcE,EAAW,KACzB,qBAAqB,MACrB,aAAc,CAAE,SAAU,GAAI,WAAY,MAAA,EAC1C,aAAeO,GAASR,EAAY,OAAQQ,CAAI,CAAA,CAAA,EAElD,EAEAJ,EAAAA,IAACK,EAAAA,WAAA,CACA,YAAU,oBACV,MAAM,eACN,MAAOV,EAAM,YACb,SAAWS,GAASR,EAAY,cAAeQ,CAAI,EACnD,UAAWP,EAAW,YACtB,YAAY,oBACZ,UAAU,OAAA,CAAA,QAGVS,EAAAA,gBAAA,CAAA,CAAgB,CAAA,CAAA,CAClB,CAAA,EACD,CAEF"}
1
+ {"version":3,"file":"Step1About.js","sources":["../../../../../src/components/agent-builder/steps/Step1About.tsx"],"sourcesContent":["import React from 'react';\nimport { Input } from '@src/components/input';\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[0];\n\nexport const Step1About: React.FC = () => {\n\tconst { value, updateField, charLimits } = useAgentBuilderContext();\n\n\treturn (\n\t\t<div className=\"bik-agent-step bik-agent-step--about\">\n\t\t\t<StepSectionHeader title={STEP.title} helper={STEP.helper} />\n\n\t\t\t<SectionBodyWrap>\n\t\t\t\t<div>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"agent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={value.name}\n\t\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={(text) => updateField('name', text)}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<AiTextArea\n\t\t\t\t\tdata-test=\"agent-description\"\n\t\t\t\t\tlabel=\"What it does\"\n\t\t\t\t\tvalue={value.description}\n\t\t\t\t\tonChange={(text) => updateField('description', text)}\n\t\t\t\t\tmaxLength={charLimits.description}\n\t\t\t\t\tplaceholder=\"Enter description\"\n\t\t\t\t\tminHeight=\"200px\"\n\t\t\t\t/>\n\t\t\t</SectionBodyWrap>\n\t\t</div>\n\t);\n};\n"],"names":["STEP","STEP_DEFINITIONS","Step1About","value","updateField","charLimits","useAgentBuilderContext","jsxs","jsx","StepSectionHeader","SectionBodyWrap","Input","text","AiTextArea"],"mappings":"yWAQMA,EAAOC,EAAAA,iBAAiB,CAAC,EAElBC,EAAuB,IAAM,CACzC,KAAM,CAAE,MAAAC,EAAO,YAAAC,EAAa,WAAAC,CAAA,EAAeC,EAAAA,uBAAA,EAE3C,OACCC,EAAAA,KAAC,MAAA,CAAI,UAAU,uCACd,SAAA,CAAAC,MAACC,EAAAA,mBAAkB,MAAOT,EAAK,MAAO,OAAQA,EAAK,OAAQ,SAE1DU,EAAAA,gBAAA,CACA,SAAA,CAAAF,MAAC,MAAA,CACA,SAAAA,EAAAA,IAACG,EAAAA,MAAA,CACA,YAAU,aACV,UAAU,aACV,cAAa,GACb,YAAY,mBACZ,MAAOR,EAAM,KACb,aAAcE,EAAW,KACzB,qBAAqB,MACrB,aAAc,CAAE,SAAU,GAAI,WAAY,MAAA,EAC1C,aAAeO,GAASR,EAAY,OAAQQ,CAAI,CAAA,CAAA,EAElD,EAEAJ,EAAAA,IAACK,EAAAA,WAAA,CACA,YAAU,oBACV,MAAM,eACN,MAAOV,EAAM,YACb,SAAWS,GAASR,EAAY,cAAeQ,CAAI,EACnD,UAAWP,EAAW,YACtB,YAAY,oBACZ,UAAU,OAAA,CAAA,CACX,CAAA,CACD,CAAA,EACD,CAEF"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),T=require("../../../assets/icons/cross.svg.js"),b=require("../../../assets/icons/plus.svg.js"),v=require("styled-components"),O=require("../../dropdown/DropdownPopover/index.js"),h=require("../../radioButton/RadioButton.js"),a=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),o=require("../AgentBuilder.styled.js"),_=require("../components/AiTextArea.js"),R=require("../components/StepSectionHeader.js"),S=require("../constants/steps.js"),B=require("../context/AgentBuilderContext.js"),q=require("../utils/mentionSerialization.js"),g=require("../../button/Button.js"),I=require("../../dropdown/utils.js"),A=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},L=A(v),x=S.STEP_DEFINITION_TEMPLATES[1],w=()=>{const{value:s,patch:c,availableIntents:u,charLimits:y,applicationType:f}=B.useAgentBuilderContext(),{trigger:n}=s,d=q.appTypeLabel(f),l=e=>c({trigger:{...n,mode:e}}),C=e=>{n.intents.includes(e)||c({trigger:{...n,intents:[...n.intents,e]}})},j=e=>c({trigger:{...n,intents:n.intents.filter(r=>r!==e)}}),p=e=>u.find(r=>r.value===e)?.label??e,m=u.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:x.title,helper:S.resolveAppToken(x.helper,d)}),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(h.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(a.TitleSmall,{color:i.COLORS.content.primary,children:`${d} intent`}),t.jsx(a.BodyCaption,{color:i.COLORS.content.secondary,children:`${d}'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(h.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(a.TitleSmall,{color:i.COLORS.content.primary,children:"Custom intent"}),t.jsx(a.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(a.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.jsx(g.Button,{"data-test":`intent-chip-${e}`,size:"chip",buttonType:"tertiaryGray",buttonText:p(e),TrailingIcon:T.default,"aria-label":`Remove ${p(e)}`,onClick:()=>j(e)},e))}),m.length>0&&t.jsx(k,{children:t.jsx(O.DropdownPopover,{"data-test":"intent-add-dropdown",isSearchable:!0,width:"200px",placement:"bottom-start",options:m,onSelect:e=>{const r=I.unwrapDropdownValue(e);r&&C(r)},children:t.jsx(g.Button,{"data-test":"intent-add-button",buttonType:"dashBold",size:"medium",LeadingIcon:b.default,buttonText:"Intent"})})}),t.jsx(a.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(_.AiTextArea,{"data-test":"custom-intent",label:"Describe the trigger",value:n.custom_intent??"",onChange:e=>c({trigger:{...n,custom_intent:e}}),maxLength:y.custom_intent,placeholder:"e.g. The customer wants to cancel an order they placed.",minHeight:"120px"})]})]})},k=L.default.div`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),y=require("../../../assets/icons/cross.svg.js"),C=require("../../../assets/icons/plus.svg.js"),j=require("styled-components"),b=require("../../dropdown/DropdownPopover/index.js"),h=require("../../radioButton/RadioButton.js"),a=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),o=require("../AgentBuilder.styled.js"),v=require("../components/AiTextArea.js"),O=require("../components/StepSectionHeader.js"),T=require("../constants/steps.js"),R=require("../context/AgentBuilderContext.js"),p=require("../../button/Button.js"),_=require("../../dropdown/utils.js"),B=s=>s&&typeof s=="object"&&"default"in s?s:{default:s},I=B(j),g=T.STEP_DEFINITIONS[1],q=()=>{const{value:s,patch:c,availableIntents:d,charLimits:x}=R.useAgentBuilderContext(),{trigger:n}=s,l=e=>c({trigger:{...n,mode:e}}),S=e=>{n.intents.includes(e)||c({trigger:{...n,intents:[...n.intents,e]}})},f=e=>c({trigger:{...n,intents:n.intents.filter(r=>r!==e)}}),u=e=>d.find(r=>r.value===e)?.label??e,m=d.filter(e=>!n.intents.includes(e.value)).map(e=>({label:e.label,value:e.value}));return t.jsxs("div",{children:[t.jsx(O.StepSectionHeader,{title:g.title,helper:g.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(h.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(a.TitleSmall,{color:i.COLORS.content.primary,children:"Manifest intent"}),t.jsx(a.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(h.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(a.TitleSmall,{color:i.COLORS.content.primary,children:"Custom intent"}),t.jsx(a.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(a.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.jsx(p.Button,{"data-test":`intent-chip-${e}`,size:"chip",buttonType:"tertiaryGray",buttonText:u(e),TrailingIcon:y.default,"aria-label":`Remove ${u(e)}`,onClick:()=>f(e)},e))}),m.length>0&&t.jsx(A,{children:t.jsx(b.DropdownPopover,{"data-test":"intent-add-dropdown",isSearchable:!0,width:"200px",placement:"bottom-start",options:m,onSelect:e=>{const r=_.unwrapDropdownValue(e);r&&S(r)},children:t.jsx(p.Button,{"data-test":"intent-add-button",buttonType:"dashBold",size:"medium",LeadingIcon:C.default,buttonText:"Intent"})})}),t.jsx(a.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(v.AiTextArea,{"data-test":"custom-intent",label:"Describe the trigger",value:n.custom_intent??"",onChange:e=>c({trigger:{...n,custom_intent:e}}),maxLength:x.custom_intent,placeholder:"e.g. The customer wants to cancel an order they placed.",minHeight:"120px"})]})]})},A=I.default.div`
2
2
  display: flex;
3
- `;exports.Step2WhenItStepsIn=w;
3
+ `;exports.Step2WhenItStepsIn=q;
4
4
  //# 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 { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { BASE_COLORS, COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tCardRow,\n\tChipWrap,\n\tFieldBlock,\n\tRadioCard,\n\tRadioCardText,\n\tSectionBodyWrap,\n} from '../AgentBuilder.styled';\nimport { AiTextArea } from '../components/AiTextArea';\nimport { StepSectionHeader } from '../components/StepSectionHeader';\nimport { resolveAppToken, STEP_DEFINITION_TEMPLATES } from '../constants/steps';\nimport { useAgentBuilderContext } from '../context/AgentBuilderContext';\nimport { appTypeLabel } from '../utils/mentionSerialization';\n\nconst STEP = STEP_DEFINITION_TEMPLATES[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents, charLimits, applicationType } =\n\t\tuseAgentBuilderContext();\n\tconst { trigger } = value;\n\n\t// The first trigger mode is the host product's own intent classifier, so it's\n\t// named after whichever product the merchant is in — \"Manifest intent\" in\n\t// Manifest, \"BIK intent\" in BIK. `trigger.mode` stays `'manifest_intent'`:\n\t// it's a bik-models TriggerMode the backend keys off, not a label.\n\tconst appLabel = appTypeLabel(applicationType);\n\n\t// Only the mode changes here. The modes are mutually exclusive on save, but the\n\t// unselected one's data is kept until the merchant leaves this step (see\n\t// `triggerForSelectedMode` in AgentBuilderContext) — so toggling the radio to\n\t// compare the two options doesn't delete what they already picked or typed.\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\n\t\t\t\ttitle={STEP.title}\n\t\t\t\thelper={resolveAppToken(STEP.helper, appLabel)}\n\t\t\t/>\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\t{`${appLabel} 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\t{`${appLabel}'s AI classifier routes conversations automatically — 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<Button\n\t\t\t\t\t\t\t\t\t\tkey={intent}\n\t\t\t\t\t\t\t\t\t\tdata-test={`intent-chip-${intent}`}\n\t\t\t\t\t\t\t\t\t\tsize=\"chip\"\n\t\t\t\t\t\t\t\t\t\tbuttonType=\"tertiaryGray\"\n\t\t\t\t\t\t\t\t\t\tbuttonText={labelFor(intent)}\n\t\t\t\t\t\t\t\t\t\tTrailingIcon={CrossIcon}\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\tonClick={() => removeIntent(intent)}\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</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=\"dashBold\"\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_DEFINITION_TEMPLATES","Step2WhenItStepsIn","value","patch","availableIntents","charLimits","applicationType","useAgentBuilderContext","trigger","appLabel","appTypeLabel","setMode","mode","addIntent","intentValue","removeIntent","i","labelFor","v","o","remainingOptions","jsx","StepSectionHeader","resolveAppToken","SectionBodyWrap","jsxs","CardRow","RadioCard","RadioButton","BASE_COLORS","RadioCardText","TitleSmall","COLORS","BodyCaption","FieldBlock","ChipWrap","intent","Button","CrossIcon","AddIntentRow","DropdownPopover","opt","unwrapDropdownValue","PlusIcon","AiTextArea","text","styled"],"mappings":"6yBA0BMA,EAAOC,EAAAA,0BAA0B,CAAC,EAE3BC,EAA+B,IAAM,CACjD,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,iBAAAC,EAAkB,WAAAC,EAAY,gBAAAC,CAAA,EACnDC,yBAAA,EACK,CAAE,QAAAC,GAAYN,EAMdO,EAAWC,EAAAA,aAAaJ,CAAe,EAMvCK,EAAWC,GAChBT,EAAM,CAAE,QAAS,CAAE,GAAGK,EAAS,KAAAI,CAAA,EAAQ,EAElCC,EAAaC,GAAwB,CACrCN,EAAQ,QAAQ,SAASM,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SAAAG,EAAAA,IAACgB,EAAAA,OAAA,CACA,YAAU,oBACV,WAAW,WACX,KAAK,SACL,YAAaM,EAAAA,QACb,WAAW,QAAA,CAAA,CACZ,CAAA,EAEF,QAEAV,EAAAA,YAAA,CAAY,MAAOD,EAAAA,OAAO,QAAQ,UAAW,SAAA,4HAAA,CAG9C,CAAA,CAAA,CACD,EAEAX,EAAAA,IAACuB,EAAAA,WAAA,CACA,YAAU,gBACV,MAAM,uBACN,MAAOpC,EAAQ,eAAiB,GAChC,SAAWqC,GACV1C,EAAM,CAAE,QAAS,CAAE,GAAGK,EAAS,cAAeqC,CAAA,EAAQ,EAEvD,UAAWxC,EAAW,cACtB,YAAY,0DACZ,UAAU,OAAA,CAAA,CACX,CAAA,CAEF,CAAA,EACD,CAEF,EAGMkC,EAAeO,EAAAA,QAAO;AAAA;AAAA"}
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 { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { BASE_COLORS, COLORS } from '@src/constants/Theme';\nimport { TriggerMode } from '../AgentBuilder.model';\nimport {\n\tCardRow,\n\tChipWrap,\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[1];\n\nexport const Step2WhenItStepsIn: React.FC = () => {\n\tconst { value, patch, availableIntents, charLimits } =\n\t\tuseAgentBuilderContext();\n\tconst { trigger } = value;\n\n\t// Only the mode changes here. The modes are mutually exclusive on save, but the\n\t// unselected one's data is kept until the merchant leaves this step (see\n\t// `triggerForSelectedMode` in AgentBuilderContext) — so toggling the radio to\n\t// compare the two options doesn't delete what they already picked or typed.\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={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<Button\n\t\t\t\t\t\t\t\t\t\tkey={intent}\n\t\t\t\t\t\t\t\t\t\tdata-test={`intent-chip-${intent}`}\n\t\t\t\t\t\t\t\t\t\tsize=\"chip\"\n\t\t\t\t\t\t\t\t\t\tbuttonType=\"tertiaryGray\"\n\t\t\t\t\t\t\t\t\t\tbuttonText={labelFor(intent)}\n\t\t\t\t\t\t\t\t\t\tTrailingIcon={CrossIcon}\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\tonClick={() => removeIntent(intent)}\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</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=\"dashBold\"\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","Button","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QAAS,IAAMpB,EAAaoB,CAAM,CAAA,EAP7BA,CAAA,CASN,EACF,EAGAf,EAAiB,OAAS,SAIzBkB,EAAA,CACA,SAAAjB,EAAAA,IAACkB,EAAAA,gBAAA,CACA,YAAU,sBACV,aAAY,GACZ,MAAM,QACN,UAAU,eACV,QAASnB,EACT,SAAWoB,GAAQ,CAClB,MAAMtB,EAAIuB,EAAAA,oBAAoBD,CAAG,EAC7BtB,GACHL,EAAUK,CAAC,CAEb,EAEA,SAAAG,EAAAA,IAACe,EAAAA,OAAA,CACA,YAAU,oBACV,WAAW,WACX,KAAK,SACL,YAAaM,EAAAA,QACb,WAAW,QAAA,CAAA,CACZ,CAAA,EAEF,QAEAV,EAAAA,YAAA,CAAY,MAAOD,EAAAA,OAAO,QAAQ,UAAW,SAAA,4HAAA,CAG9C,CAAA,CAAA,CACD,EAEAV,EAAAA,IAACsB,EAAAA,WAAA,CACA,YAAU,gBACV,MAAM,uBACN,MAAOjC,EAAQ,eAAiB,GAChC,SAAWkC,GACVtC,EAAM,CAAE,QAAS,CAAE,GAAGI,EAAS,cAAekC,CAAA,EAAQ,EAEvD,UAAWpC,EAAW,cACtB,YAAY,0DACZ,UAAU,OAAA,CAAA,CACX,CAAA,CAEF,CAAA,EACD,CAEF,EAGM8B,EAAeO,EAAAA,QAAO;AAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),l=require("react"),q=require("../../TypographyStyle.js"),w=require("../../../constants/Theme.js"),h=require("../AgentBuilder.styled.js"),De=require("../components/ConfigToolPanel.js"),Ne=require("../components/CreateSubAgentPanel.js"),ie=require("../components/MentionField.js"),He=require("../components/RequireVerificationModal.js"),Be=require("../components/RestApiToolPanel.js"),le=require("../components/SelectableListSection.js"),Ke=require("../components/StepSectionHeader.js"),Fe=require("../constants/steps.js"),d=require("../constants/tools.js"),Ue=require("../context/AgentBuilderContext.js"),u=require("../utils/mentionSerialization.js"),O=require("../utils/sourceIcons.js"),Ge=require("../utils/toolActions.js"),Ve=require("../../../icons/Informational/Common UI/Shield.js"),se=require("../../dropdown/Dropdown.js"),ae=require("../../dropdown/utils.js"),We=require("../../tooltips/Tooltip.js"),ze=require("../../switch/Switch.js"),$e=i=>O.renderSourceIcon(O.sourceIcon(i))??void 0,re=i=>({label:i.display_name,value:i.tool_id,leadingIcon:$e(i.source??d.ToolSource.Manifest)}),ce=Fe.STEP_DEFINITIONS[2],X=[{label:"OTP to phone",value:"phone_otp"},{label:"OTP to email",value:"email_otp"}],ue=(i,s)=>{const A=i??[];return A.some(g=>g.id===s.id)?A.map(g=>g.id===s.id?s:g):[...A,s]},Je=()=>{const{value:i,patch:s,updateField:A,addReference:g,removeReference:Y,availableTools:r,availableSubAgents:de,availableModels:L,configToolTemplates:P,applicationType:Z,charLimits:v,insertMention:p,onCreateSubAgent:b,onFetchSubAgent:j,onUpdateSubAgent:D,onImproveSubAgent:pe,onImproveToolInstructions:N,registerSubAgentCreator:H,registerToolActionHandler:B,integrationStatus:K,onConnectIntegration:F,variablesData:U}=Ue.useAgentBuilderContext(),[m,k]=l.useState(null),_=l.useRef(0),[a,f]=l.useState(null),M=l.useRef(0),G=l.useCallback(e=>{M.current+=1,f({key:M.current,kind:"restapi",initialRest:e})},[]),V=l.useCallback((e,t)=>{M.current+=1,f({key:M.current,kind:"config",toolKey:e,initialConfig:t})},[]),ge=l.useCallback(e=>{const t=!(i.restApiTools??[]).some(o=>o.id===e.id);s({restApiTools:ue(i.restApiTools,e)}),t&&p("tool",e.id,u.restApiMentionItem(e).label,d.ToolSource.RestApi),f(null)},[s,i.restApiTools,p]),me=l.useCallback(e=>{const t=!(i.configTools??[]).some(o=>o.id===e.id);if(s({configTools:ue(i.configTools,e)}),t){const o=e.tool_key==="send_slack_message"?d.ToolSource.Slack:d.ToolSource.EmailHandover;p("tool",e.id,u.configToolMentionItem(e).label,o)}f(null)},[s,i.configTools,p]),W=l.useCallback(e=>{const t=d.CONFIG_TOOL_SOURCES[e];t?V(t):G()},[V,G]);l.useEffect(()=>(B(W),()=>B(null)),[B,W]);const[he,ee]=l.useState([]),[Se,be]=l.useState(()=>new Set),C=new Map;de.forEach(e=>C.set(e.id,e)),he.forEach(e=>C.set(e.id,e));const te=Array.from(C.values()),z=l.useCallback(()=>{_.current+=1,k({key:_.current,title:"Create sub-agent"})},[]);l.useEffect(()=>{if(b)return H(z),()=>H(null)},[H,z,b]);const fe=l.useCallback(async e=>{if(!j)return;const t=await j(e);_.current+=1,k({key:_.current,title:"Edit sub-agent",editingId:e,initial:t})},[j]),Te=i.tools.some(e=>r.find(t=>t.tool_id===e)?.auth_required),ye=i.subagents.some(e=>Se.has(e)),S=Te||ye,T=i.authentication?.enabled??!1,y=i.authentication?.type??"email_otp",Ae=u.appTypeLabel(Z)!=="BIK",ve=l.useCallback(async e=>{let t;if(m?.editingId){if(D){const o=await D(m.editingId,e);t=o.id,ee(c=>[...c.filter(I=>I.id!==o.id),o])}}else if(b){const o=await b(e);t=o.id,ee(c=>[...c,o]),s({subagents:[...i.subagents,o.id]}),p("subagent",o.id,`sub-agent: ${o.name}`)}if(t){const o=t,c=e.tools.some(I=>r.find(R=>R.tool_id===I)?.auth_required);be(I=>{const R=new Set(I);return c?R.add(o):R.delete(o),R})}k(null)},[m,D,b,s,i.subagents,p,r]);l.useEffect(()=>{S&&!T&&s({authentication:{enabled:!0,type:y}})},[S,T,y,s]);const[E,$]=l.useState(null),J=l.useCallback(e=>{p("tool",e),g("tool",e)},[p,g]),Ce=l.useCallback(e=>{if(r.find(o=>o.tool_id===e)?.auth_required&&!T){$(e);return}J(e)},[r,T,J]),xe=i.tools.map(e=>{const t=r.find(o=>o.tool_id===e);return t?{id:e,label:t.display_name,icon:O.sourceIcon(t.source??d.ToolSource.Manifest),authRequired:t.auth_required}:null}).filter(e=>e!==null),Ie=(i.restApiTools??[]).map(e=>({id:e.id,label:u.restApiToolName(e),icon:O.SOURCE_ICONS[d.ToolSource.RestApi],onConfigure:()=>G(e)})),Re=(i.configTools??[]).map(e=>({id:e.id,label:u.configToolName(e),icon:O.SOURCE_ICONS[e.tool_key==="send_slack_message"?d.ToolSource.Slack:d.ToolSource.EmailHandover],onConfigure:()=>V(e.tool_key,e)})),qe=[...xe,...Ie,...Re],we=Ge.buildToolActions(P,W,K,F),Oe=r.map(re),x=u.appTypeLabel(Z),je=(()=>{const e=[],t=new Map;return r.forEach(o=>{const c=o.source??d.ToolSource.Manifest;t.has(c)||(t.set(c,[]),e.push(c)),t.get(c)?.push(re(o))}),e.map(o=>({source:o,label:u.toolSourceLabel(o,x),options:t.get(o)??[],connected:K?.[o],onConnect:()=>F?.(o)}))})(),ke=i.subagents.map(e=>{const t=C.get(e);return t?{id:e,label:t.name}:null}).filter(e=>e!==null),_e=te.map(e=>({label:e.name,value:e.id})),Me=[...u.buildAgentMentionItems(r,[],x),...u.buildCustomToolMentionItems(i.configTools,i.restApiTools)],Ee=u.buildAgentMentionItems([],te,x),Le=L.map(e=>({label:e.label,value:e.value,selected:e.value===i.model})),Q=L.find(e=>e.value===i.model),oe=a?.kind==="config"&&a.toolKey?P?.[a.toolKey]:void 0,ne=n.jsx(ze.Switch,{"data-test":"agent-auth-toggle",value:T||S,disabled:S,onValueChange:async e=>{s({authentication:{enabled:e,type:y}})}}),Pe=S?n.jsx(We.Tooltip,{body:"Remove tools that requires customer verification to change this setting.",placement:"bottom",children:n.jsx("span",{style:{display:"flex"},children:ne})}):ne;return n.jsxs(h.Step3Root,{children:[n.jsx(Ke.StepSectionHeader,{title:ce.title,helper:ce.helper}),n.jsxs(h.Step3Grid,{$grow:!0,children:[n.jsxs(h.SectionBodyWrap,{children:[n.jsx(ie.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:v.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(ie.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:v.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(h.Step3Divider,{}),n.jsxs(h.SectionBodyWrap,{children:[n.jsx(le.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:qe,addableOptions:Oe,sourceGroups:je,mentionItems:Me,actionSources:we,emptyText:"No tools added yet.",appLabel:x,onAdd:Ce,onRemove:e=>Y("tool",e),confirmDelete:{noun:"tool"}}),n.jsx(le.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:ke,addableOptions:_e,mentionItems:Ee,emptyText:"No sub-agents added yet.",onAdd:e=>{p("subagent",e),g("subagent",e)},onRemove:e=>Y("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:j?fe:void 0,createOption:b?{label:"Create new",onSelect:z}:void 0}),n.jsxs(h.SideSection,{children:[n.jsxs(h.SideSectionHeader,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(Ve.default,{size:20}),n.jsx(q.TitleSmall,{color:w.COLORS.content.primary,children:"Require customer verification"})]}),Pe]}),n.jsx(q.BodyCaption,{color:w.COLORS.content.secondary,children:S?"Required — this agent uses a tool that accesses customer order details.":"Customers must verify their identity before this agent responds."}),Ae&&(T||S)&&n.jsxs(n.Fragment,{children:[n.jsx(q.BodySecondary,{color:w.COLORS.content.primary,children:"Select verification method"}),n.jsx(se.Dropdown,{"data-test":"agent-auth-method",size:"small",width:"100%",dropdownWidth:"328px",placeHolder:"Select verification method",options:X.map(e=>({...e,selected:e.value===y})),defaultOptions:[X.find(e=>e.value===y)??X[0]],onSelect:e=>{const t=ae.unwrapDropdownValue(e);t&&s({authentication:{enabled:!0,type:t}})}})]})]}),L.length>0&&n.jsxs(h.SideSection,{children:[n.jsx(q.TitleSmall,{color:w.COLORS.content.primary,children:"Advanced settings"}),n.jsx(q.BodySecondary,{color:w.COLORS.content.primary,children:"Select AI model"}),n.jsx(se.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",dropdownWidth:"328px",placeHolder:"Select model",options:Le,defaultOptions:Q?[{label:Q.label,value:Q.value}]:void 0,onSelect:e=>{const t=ae.unwrapDropdownValue(e);t&&A("model",t)}})]})]})]}),m&&n.jsx(Ne.CreateSubAgentPanel,{title:m.title,initial:m.initial,existingNames:i.subagents.filter(e=>e!==m.editingId).map(e=>C.get(e)?.name).filter(e=>!!e),availableTools:r,configToolTemplates:P,variablesData:U,integrationStatus:K,onConnectIntegration:F,appLabel:x,charLimits:v,onImprove:pe,onImproveToolInstructions:N,onClose:()=>k(null),onSave:ve},m.key),a?.kind==="restapi"&&n.jsx(Be.RestApiToolPanel,{initial:a.initialRest,charLimits:v,variablesData:U,existingNames:(i.restApiTools??[]).filter(e=>e.id!==a.initialRest?.id).map(e=>e.name),onImprove:N,onClose:()=>f(null),onSave:ge},a.key),a?.kind==="config"&&a.toolKey&&oe&&n.jsx(De.ConfigToolPanel,{toolKey:a.toolKey,template:oe,initial:a.initialConfig,charLimits:v,variablesData:U,onImprove:N,onClose:()=>f(null),onSave:me},a.key),n.jsx(He.RequireVerificationModal,{open:E!==null,toolLabel:r.find(e=>e.tool_id===E)?.display_name??"This tool",onCancel:()=>$(null),onConfirm:()=>{s({authentication:{enabled:!0,type:y}}),E&&J(E),$(null)}})]})};exports.Step3HowItResponds=Je;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),l=require("react"),R=require("../../TypographyStyle.js"),q=require("../../../constants/Theme.js"),h=require("../AgentBuilder.styled.js"),Pe=require("../components/ConfigToolPanel.js"),De=require("../components/CreateSubAgentPanel.js"),ie=require("../components/MentionField.js"),Ne=require("../components/RequireVerificationModal.js"),He=require("../components/RestApiToolPanel.js"),le=require("../components/SelectableListSection.js"),Be=require("../components/StepSectionHeader.js"),Ke=require("../constants/steps.js"),d=require("../constants/tools.js"),Fe=require("../context/AgentBuilderContext.js"),u=require("../utils/mentionSerialization.js"),w=require("../utils/sourceIcons.js"),Ue=require("../utils/toolActions.js"),Ge=require("../../../icons/Informational/Common UI/Shield.js"),se=require("../../dropdown/Dropdown.js"),ae=require("../../dropdown/utils.js"),Ve=require("../../tooltips/Tooltip.js"),We=require("../../switch/Switch.js"),ze=i=>w.renderSourceIcon(w.sourceIcon(i))??void 0,re=i=>({label:i.display_name,value:i.tool_id,leadingIcon:ze(i.source??d.ToolSource.Manifest)}),ce=Ke.STEP_DEFINITIONS[2],Q=[{label:"OTP to phone",value:"phone_otp"},{label:"OTP to email",value:"email_otp"}],ue=(i,s)=>{const A=i??[];return A.some(g=>g.id===s.id)?A.map(g=>g.id===s.id?s:g):[...A,s]},$e=()=>{const{value:i,patch:s,updateField:A,addReference:g,removeReference:X,availableTools:r,availableSubAgents:de,availableModels:E,configToolTemplates:L,applicationType:Y,charLimits:v,insertMention:p,onCreateSubAgent:b,onFetchSubAgent:O,onUpdateSubAgent:P,onImproveSubAgent:pe,onImproveToolInstructions:D,registerSubAgentCreator:N,registerToolActionHandler:H,integrationStatus:B,onConnectIntegration:K,variablesData:F}=Fe.useAgentBuilderContext(),[m,j]=l.useState(null),k=l.useRef(0),[a,f]=l.useState(null),_=l.useRef(0),U=l.useCallback(e=>{_.current+=1,f({key:_.current,kind:"restapi",initialRest:e})},[]),G=l.useCallback((e,t)=>{_.current+=1,f({key:_.current,kind:"config",toolKey:e,initialConfig:t})},[]),ge=l.useCallback(e=>{const t=!(i.restApiTools??[]).some(o=>o.id===e.id);s({restApiTools:ue(i.restApiTools,e)}),t&&p("tool",e.id,u.restApiMentionItem(e).label,d.ToolSource.RestApi),f(null)},[s,i.restApiTools,p]),me=l.useCallback(e=>{const t=!(i.configTools??[]).some(o=>o.id===e.id);if(s({configTools:ue(i.configTools,e)}),t){const o=e.tool_key==="send_slack_message"?d.ToolSource.Slack:d.ToolSource.EmailHandover;p("tool",e.id,u.configToolMentionItem(e).label,o)}f(null)},[s,i.configTools,p]),V=l.useCallback(e=>{const t=d.CONFIG_TOOL_SOURCES[e];t?G(t):U()},[G,U]);l.useEffect(()=>(H(V),()=>H(null)),[H,V]);const[he,Z]=l.useState([]),[Se,be]=l.useState(()=>new Set),C=new Map;de.forEach(e=>C.set(e.id,e)),he.forEach(e=>C.set(e.id,e));const ee=Array.from(C.values()),W=l.useCallback(()=>{k.current+=1,j({key:k.current,title:"Create sub-agent"})},[]);l.useEffect(()=>{if(b)return N(W),()=>N(null)},[N,W,b]);const fe=l.useCallback(async e=>{if(!O)return;const t=await O(e);k.current+=1,j({key:k.current,title:"Edit sub-agent",editingId:e,initial:t})},[O]),Te=i.tools.some(e=>r.find(t=>t.tool_id===e)?.auth_required),ye=i.subagents.some(e=>Se.has(e)),S=Te||ye,T=i.authentication?.enabled??!1,y=i.authentication?.type??"email_otp",Ae=l.useCallback(async e=>{let t;if(m?.editingId){if(P){const o=await P(m.editingId,e);t=o.id,Z(c=>[...c.filter(x=>x.id!==o.id),o])}}else if(b){const o=await b(e);t=o.id,Z(c=>[...c,o]),s({subagents:[...i.subagents,o.id]}),p("subagent",o.id,`sub-agent: ${o.name}`)}if(t){const o=t,c=e.tools.some(x=>r.find(I=>I.tool_id===x)?.auth_required);be(x=>{const I=new Set(x);return c?I.add(o):I.delete(o),I})}j(null)},[m,P,b,s,i.subagents,p,r]);l.useEffect(()=>{S&&!T&&s({authentication:{enabled:!0,type:y}})},[S,T,y,s]);const[M,z]=l.useState(null),$=l.useCallback(e=>{p("tool",e),g("tool",e)},[p,g]),ve=l.useCallback(e=>{if(r.find(o=>o.tool_id===e)?.auth_required&&!T){z(e);return}$(e)},[r,T,$]),Ce=i.tools.map(e=>{const t=r.find(o=>o.tool_id===e);return t?{id:e,label:t.display_name,icon:w.sourceIcon(t.source??d.ToolSource.Manifest),authRequired:t.auth_required}:null}).filter(e=>e!==null),xe=(i.restApiTools??[]).map(e=>({id:e.id,label:u.restApiToolName(e),icon:w.SOURCE_ICONS[d.ToolSource.RestApi],onConfigure:()=>U(e)})),Ie=(i.configTools??[]).map(e=>({id:e.id,label:u.configToolName(e),icon:w.SOURCE_ICONS[e.tool_key==="send_slack_message"?d.ToolSource.Slack:d.ToolSource.EmailHandover],onConfigure:()=>G(e.tool_key,e)})),Re=[...Ce,...xe,...Ie],qe=Ue.buildToolActions(L,V,B,K),we=r.map(re),Oe=(()=>{const e=[],t=new Map;return r.forEach(o=>{const c=o.source??d.ToolSource.Manifest;t.has(c)||(t.set(c,[]),e.push(c)),t.get(c)?.push(re(o))}),e.map(o=>({source:o,label:u.toolSourceLabel(o),options:t.get(o)??[],connected:B?.[o],onConnect:()=>K?.(o)}))})(),je=i.subagents.map(e=>{const t=C.get(e);return t?{id:e,label:t.name}:null}).filter(e=>e!==null),ke=ee.map(e=>({label:e.name,value:e.id})),te=u.appTypeLabel(Y),_e=[...u.buildAgentMentionItems(r,[],te),...u.buildCustomToolMentionItems(i.configTools,i.restApiTools)],Me=u.buildAgentMentionItems([],ee,te),Ee=E.map(e=>({label:e.label,value:e.value,selected:e.value===i.model})),J=E.find(e=>e.value===i.model),oe=a?.kind==="config"&&a.toolKey?L?.[a.toolKey]:void 0,ne=n.jsx(We.Switch,{"data-test":"agent-auth-toggle",value:T||S,disabled:S,onValueChange:async e=>{s({authentication:{enabled:e,type:y}})}}),Le=S?n.jsx(Ve.Tooltip,{body:"Remove tools that requires customer verification to change this setting.",placement:"bottom",children:n.jsx("span",{style:{display:"flex"},children:ne})}):ne;return n.jsxs(h.Step3Root,{children:[n.jsx(Be.StepSectionHeader,{title:ce.title,helper:ce.helper}),n.jsxs(h.Step3Grid,{$grow:!0,children:[n.jsxs(h.SectionBodyWrap,{children:[n.jsx(ie.MentionField,{fieldKey:"instructions","data-test":"agent-instructions",label:"Instructions",maxLength:v.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(ie.MentionField,{fieldKey:"guardrail","data-test":"agent-guardrail",label:"Guardrails",maxLength:v.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(h.Step3Divider,{}),n.jsxs(h.SectionBodyWrap,{children:[n.jsx(le.SelectableListSection,{title:"Tools",helper:"Actions this agent can take while responding.",dataTestPrefix:"agent-tools",items:Re,addableOptions:we,sourceGroups:Oe,mentionItems:_e,actionSources:qe,emptyText:"No tools added yet.",onAdd:ve,onRemove:e=>X("tool",e),confirmDelete:{noun:"tool"}}),n.jsx(le.SelectableListSection,{title:"Sub-agents",helper:"Other agents this agent can hand off the conversation to.",dataTestPrefix:"agent-subagents",items:je,addableOptions:ke,mentionItems:Me,emptyText:"No sub-agents added yet.",onAdd:e=>{p("subagent",e),g("subagent",e)},onRemove:e=>X("subagent",e),confirmDelete:{noun:"sub-agent"},onConfigure:O?fe:void 0,createOption:b?{label:"Create new",onSelect:W}:void 0}),n.jsxs(h.SideSection,{children:[n.jsxs(h.SideSectionHeader,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(Ge.default,{size:20}),n.jsx(R.TitleSmall,{color:q.COLORS.content.primary,children:"Require customer verification"})]}),Le]}),n.jsx(R.BodyCaption,{color:q.COLORS.content.secondary,children:S?"Required — this agent uses a tool that accesses customer order details.":"Customers must verify their identity before this agent responds."}),(T||S)&&n.jsxs(n.Fragment,{children:[n.jsx(R.BodySecondary,{color:q.COLORS.content.primary,children:"Select verification method"}),n.jsx(se.Dropdown,{"data-test":"agent-auth-method",size:"small",width:"100%",dropdownWidth:"328px",placeHolder:"Select verification method",options:Q.map(e=>({...e,selected:e.value===y})),defaultOptions:[Q.find(e=>e.value===y)??Q[0]],onSelect:e=>{const t=ae.unwrapDropdownValue(e);t&&s({authentication:{enabled:!0,type:t}})}})]})]}),E.length>0&&n.jsxs(h.SideSection,{children:[n.jsx(R.TitleSmall,{color:q.COLORS.content.primary,children:"Advanced settings"}),n.jsx(R.BodySecondary,{color:q.COLORS.content.primary,children:"Select AI model"}),n.jsx(se.Dropdown,{"data-test":"agent-model",size:"small",width:"100%",dropdownWidth:"328px",placeHolder:"Select model",options:Ee,defaultOptions:J?[{label:J.label,value:J.value}]:void 0,onSelect:e=>{const t=ae.unwrapDropdownValue(e);t&&A("model",t)}})]})]})]}),m&&n.jsx(De.CreateSubAgentPanel,{title:m.title,initial:m.initial,existingNames:i.subagents.filter(e=>e!==m.editingId).map(e=>C.get(e)?.name).filter(e=>!!e),availableTools:r,configToolTemplates:L,variablesData:F,integrationStatus:B,onConnectIntegration:K,appLabel:u.appTypeLabel(Y),charLimits:v,onImprove:pe,onImproveToolInstructions:D,onClose:()=>j(null),onSave:Ae},m.key),a?.kind==="restapi"&&n.jsx(He.RestApiToolPanel,{initial:a.initialRest,charLimits:v,variablesData:F,existingNames:(i.restApiTools??[]).filter(e=>e.id!==a.initialRest?.id).map(e=>e.name),onImprove:D,onClose:()=>f(null),onSave:ge},a.key),a?.kind==="config"&&a.toolKey&&oe&&n.jsx(Pe.ConfigToolPanel,{toolKey:a.toolKey,template:oe,initial:a.initialConfig,charLimits:v,variablesData:F,onImprove:D,onClose:()=>f(null),onSave:me},a.key),n.jsx(Ne.RequireVerificationModal,{open:M!==null,toolLabel:r.find(e=>e.tool_id===M)?.display_name??"This tool",onCancel:()=>z(null),onConfirm:()=>{s({authentication:{enabled:!0,type:y}}),M&&$(M),z(null)}})]})};exports.Step3HowItResponds=$e;
2
2
  //# sourceMappingURL=Step3HowItResponds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import { Shield } from '@src/icons';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Switch } from '@src/components/switch';\nimport { Tooltip } from '@src/components/tooltips';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tAuthentication,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tSideSectionHeader,\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 { RequireVerificationModal } from '../components/RequireVerificationModal';\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/** Customer-verification OTP methods, in the dropdown's display order. */\nconst AUTH_METHOD_OPTIONS: SingleOption[] = [\n\t{ label: 'OTP to phone', value: 'phone_otp' },\n\t{ label: 'OTP to email', value: 'email_otp' },\n];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t\tvariablesData,\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\t// Pass the source so the fresh chip gets its icon (it isn't in the\n\t\t\t// editor's mention list yet).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention(\n\t\t\t\t\t'tool',\n\t\t\t\t\tconfig.id,\n\t\t\t\t\trestApiMentionItem(config).label,\n\t\t\t\t\tToolSource.RestApi,\n\t\t\t\t);\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\tconst source =\n\t\t\t\t\tconfig.tool_key === 'send_slack_message'\n\t\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t\t: ToolSource.EmailHandover;\n\t\t\t\tinsertMention(\n\t\t\t\t\t'tool',\n\t\t\t\t\tconfig.id,\n\t\t\t\t\tconfigToolMentionItem(config).label,\n\t\t\t\t\tsource,\n\t\t\t\t);\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// Ids of sub-agents saved this session that use an auth_required tool — they\n\t// make customer verification mandatory on the parent, just like a direct\n\t// auth_required tool. (A persisted sub-agent's tools aren't hydrated into\n\t// `value`, so it only joins this set once opened/edited in the panel.)\n\tconst [authRequiringSubAgents, setAuthRequiringSubAgents] = useState<\n\t\tSet<string>\n\t>(() => new Set());\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\t// ── Customer verification (auth) ──────────────────────────────────────────\n\t// Order tools (auth_required) can't run unless the customer is verified first,\n\t// so verification is MANDATORY whenever such a tool is attached (directly or\n\t// via a sub-agent). Derived before the handlers that read it.\n\tconst hasDirectAuthTool = value.tools.some(\n\t\t(id) => availableTools.find((t) => t.tool_id === id)?.auth_required,\n\t);\n\tconst hasAuthRequiredSubAgent = value.subagents.some((id) =>\n\t\tauthRequiringSubAgents.has(id),\n\t);\n\tconst hasAuthRequiredTool = hasDirectAuthTool || hasAuthRequiredSubAgent;\n\tconst authEnabled = value.authentication?.enabled ?? false;\n\tconst authType: Authentication['type'] =\n\t\tvalue.authentication?.type ?? 'email_otp';\n\t// BIK picks the OTP channel itself, so the merchant only gets the on/off\n\t// toggle there; Manifest still chooses the method.\n\tconst showAuthMethod = appTypeLabel(applicationType) !== 'BIK';\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tlet savedId: string | undefined;\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\tsavedId = ref.id;\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\tsavedId = ref.id;\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\t// A sub-agent that uses an auth_required tool forces customer\n\t\t\t// verification on the parent agent — the tool can't run otherwise. Record\n\t\t\t// it so verification stays mandatory (the reconcile effect turns it on and\n\t\t\t// the toggle locks), mirroring the direct-tool invariant.\n\t\t\tif (savedId) {\n\t\t\t\tconst targetId = savedId;\n\t\t\t\tconst subUsesAuthTool = draft.tools.some(\n\t\t\t\t\t(id) => availableTools.find((t) => t.tool_id === id)?.auth_required,\n\t\t\t\t);\n\t\t\t\tsetAuthRequiringSubAgents((prev) => {\n\t\t\t\t\tconst next = new Set(prev);\n\t\t\t\t\tif (subUsesAuthTool) {\n\t\t\t\t\t\tnext.add(targetId);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnext.delete(targetId);\n\t\t\t\t\t}\n\t\t\t\t\treturn next;\n\t\t\t\t});\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\tavailableTools,\n\t\t],\n\t);\n\n\t// Reconcile the invariant: a loaded agent that already holds an auth_required\n\t// tool must have verification on (a fail-closed tool otherwise runs silently).\n\tuseEffect(() => {\n\t\tif (hasAuthRequiredTool && !authEnabled) {\n\t\t\tpatch({ authentication: { enabled: true, type: authType } });\n\t\t}\n\t}, [hasAuthRequiredTool, authEnabled, authType, patch]);\n\n\t// A tool add awaiting the mandatory-verification confirm (null = no prompt).\n\tconst [pendingAuthTool, setPendingAuthTool] = useState<string | null>(null);\n\tconst addTool = useCallback(\n\t\t(id: string) => {\n\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads the\n\t\t\t// latest value.\n\t\t\tinsertMention('tool', id);\n\t\t\taddReference('tool', id);\n\t\t},\n\t\t[insertMention, addReference],\n\t);\n\t// Adding an auth_required tool while verification is off prompts first; confirm\n\t// turns verification on and adds, cancel skips the add.\n\tconst handleAddTool = useCallback(\n\t\t(id: string) => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\tif (tool?.auth_required && !authEnabled) {\n\t\t\t\tsetPendingAuthTool(id);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\taddTool(id);\n\t\t},\n\t\t[availableTools, authEnabled, addTool],\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\t\tauthRequired: tool.auth_required,\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// The native tool group is named after the host product — \"Manifest\" in\n\t// Manifest, \"BIK\" in BIK — so every surface that renders a source name needs it.\n\tconst appLabel = appTypeLabel(applicationType);\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, appLabel),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t\t// Not connected → the source button opens the connect flow instead of\n\t\t\t// its tool list (see SelectableListSection / onConnectIntegration).\n\t\t\tconnected: integrationStatus?.[src as ToolSource],\n\t\t\tonConnect: () => onConnectIntegration?.(src as ToolSource),\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst 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\tconst verificationToggle = (\n\t\t<Switch\n\t\t\tdata-test=\"agent-auth-toggle\"\n\t\t\tvalue={authEnabled || hasAuthRequiredTool}\n\t\t\t// Mandatory (can't turn off) while an auth_required tool is attached.\n\t\t\tdisabled={hasAuthRequiredTool}\n\t\t\tonValueChange={async (enabled) => {\n\t\t\t\tpatch({ authentication: { enabled, type: authType } });\n\t\t\t}}\n\t\t/>\n\t);\n\t// While locked, a tooltip explains why the toggle can't be changed.\n\tconst verificationToggleNode = hasAuthRequiredTool ? (\n\t\t<Tooltip\n\t\t\tbody=\"Remove tools that requires customer verification to change this setting.\"\n\t\t\tplacement=\"bottom\"\n\t\t>\n\t\t\t<span style={{ display: 'flex' }}>{verificationToggle}</span>\n\t\t</Tooltip>\n\t) : (\n\t\tverificationToggle\n\t);\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\tappLabel={appLabel}\n\t\t\t\t\t\tonAdd={handleAddTool}\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<SideSection>\n\t\t\t\t\t\t<SideSectionHeader>\n\t\t\t\t\t\t\t<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n\t\t\t\t\t\t\t\t<Shield size={20} />\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tRequire customer verification\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{verificationToggleNode}\n\t\t\t\t\t\t</SideSectionHeader>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t{hasAuthRequiredTool\n\t\t\t\t\t\t\t\t? 'Required — this agent uses a tool that accesses customer order details.'\n\t\t\t\t\t\t\t\t: 'Customers must verify their identity before this agent responds.'}\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t{showAuthMethod && (authEnabled || hasAuthRequiredTool) && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tSelect verification method\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-auth-method\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\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\t// match the input: 360px side column − 2×16px padding.\n\t\t\t\t\t\t\t\t\tdropdownWidth=\"328px\"\n\t\t\t\t\t\t\t\t\tplaceHolder=\"Select verification method\"\n\t\t\t\t\t\t\t\t\t// Flag the active method so the open list highlights that row\n\t\t\t\t\t\t\t\t\t// green (list-item 'selected' theme handles the styling).\n\t\t\t\t\t\t\t\t\toptions={AUTH_METHOD_OPTIONS.map((o) => ({\n\t\t\t\t\t\t\t\t\t\t...o,\n\t\t\t\t\t\t\t\t\t\tselected: o.value === authType,\n\t\t\t\t\t\t\t\t\t}))}\n\t\t\t\t\t\t\t\t\tdefaultOptions={[\n\t\t\t\t\t\t\t\t\t\tAUTH_METHOD_OPTIONS.find((o) => o.value === authType) ??\n\t\t\t\t\t\t\t\t\t\t\tAUTH_METHOD_OPTIONS[0],\n\t\t\t\t\t\t\t\t\t]}\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\tpatch({\n\t\t\t\t\t\t\t\t\t\t\t\tauthentication: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: v as Authentication['type'],\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});\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</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</SideSection>\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\t// Block reusing another sub-agent's name (exclude the one being edited).\n\t\t\t\t\texistingNames={value.subagents\n\t\t\t\t\t\t.filter((id) => id !== panel.editingId)\n\t\t\t\t\t\t.map((id) => subAgentById.get(id)?.name)\n\t\t\t\t\t\t.filter((n): n is string => !!n)}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\tappLabel={appLabel}\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\tvariablesData={variablesData}\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\tvariablesData={variablesData}\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\n\t\t\t<RequireVerificationModal\n\t\t\t\topen={pendingAuthTool !== null}\n\t\t\t\ttoolLabel={\n\t\t\t\t\tavailableTools.find((t) => t.tool_id === pendingAuthTool)\n\t\t\t\t\t\t?.display_name ?? 'This tool'\n\t\t\t\t}\n\t\t\t\tonCancel={() => setPendingAuthTool(null)}\n\t\t\t\tonConfirm={() => {\n\t\t\t\t\tpatch({ authentication: { enabled: true, type: authType } });\n\t\t\t\t\tif (pendingAuthTool) {\n\t\t\t\t\t\taddTool(pendingAuthTool);\n\t\t\t\t\t}\n\t\t\t\t\tsetPendingAuthTool(null);\n\t\t\t\t}}\n\t\t\t/>\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","t","ToolSource","STEP","STEP_DEFINITIONS","AUTH_METHOD_OPTIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","integrationStatus","onConnectIntegration","variablesData","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","authRequiringSubAgents","setAuthRequiringSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","hasDirectAuthTool","hasAuthRequiredSubAgent","hasAuthRequiredTool","authEnabled","authType","showAuthMethod","appTypeLabel","handlePanelSave","draft","savedId","ref","prev","targetId","subUsesAuthTool","next","pendingAuthTool","setPendingAuthTool","addTool","handleAddTool","toolItems","tool","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","toolOptions","appLabel","toolSourceGroups","order","bySource","src","toolSourceLabel","subAgentItems","sub","subAgentOptions","toolMentionItems","buildAgentMentionItems","buildCustomToolMentionItems","subAgentMentionItems","modelOptions","m","selectedModel","openConfigTemplate","verificationToggle","jsx","Switch","enabled","verificationToggleNode","Tooltip","Step3Root","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","SideSectionHeader","Shield","TitleSmall","COLORS","BodyCaption","Fragment","BodySecondary","Dropdown","o","opt","v","unwrapDropdownValue","CreateSubAgentPanel","n","RestApiToolPanel","ConfigToolPanel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gB,CAAA,GACpC,OAAQX,GAAMA,EAAE,KAAOuC,EAAW,aAAa,EAAE,EACjD,IAAKvC,GAAMA,EAAE,IAAI,EACnB,UAAW2B,EACX,QAAS,IAAMa,EAAc,IAAI,EACjC,OAAQO,EAAA,EAVHR,EAAW,GAAA,EAcjBA,GAAY,OAAS,UACrBA,EAAW,SACX0E,IACCE,EAAAA,IAAC6B,GAAAA,gBAAA,CAEA,QAASzG,EAAW,QACpB,SAAU0E,GACV,QAAS1E,EAAW,cACpB,WAAAlB,EACA,cAAAW,EACA,UAAWL,EACX,QAAS,IAAMa,EAAc,IAAI,EACjC,OAAQW,EAAA,EARHZ,EAAW,GAAA,EAYnB4E,EAAAA,IAAC8B,GAAAA,yBAAA,CACA,KAAM/D,IAAoB,KAC1B,UACClE,EAAe,KAAMhB,GAAMA,EAAE,UAAYkF,CAAe,GACrD,cAAgB,YAEpB,SAAU,IAAMC,EAAmB,IAAI,EACvC,UAAW,IAAM,CAChBvE,EAAM,CAAE,eAAgB,CAAE,QAAS,GAAM,KAAM2D,CAAA,EAAY,EACvDW,GACHE,EAAQF,CAAe,EAExBC,EAAmB,IAAI,CACxB,CAAA,CAAA,CACD,EACD,CAEF"}
1
+ {"version":3,"file":"Step3HowItResponds.js","sources":["../../../../../src/components/agent-builder/steps/Step3HowItResponds.tsx"],"sourcesContent":["import { Shield } from '@src/icons';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { Dropdown, unwrapDropdownValue } from '@src/components/dropdown';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Switch } from '@src/components/switch';\nimport { Tooltip } from '@src/components/tooltips';\nimport {\n\tBodyCaption,\n\tBodySecondary,\n\tTitleSmall,\n} from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tAuthentication,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport {\n\tSectionBodyWrap,\n\tSideSection,\n\tSideSectionHeader,\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 { RequireVerificationModal } from '../components/RequireVerificationModal';\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/** Customer-verification OTP methods, in the dropdown's display order. */\nconst AUTH_METHOD_OPTIONS: SingleOption[] = [\n\t{ label: 'OTP to phone', value: 'phone_otp' },\n\t{ label: 'OTP to email', value: 'email_otp' },\n];\n\n/** Drawer state — null when closed; `key` remounts it fresh per open. */\ninterface SubAgentPanelState {\n\tkey: number;\n\ttitle: string;\n\teditingId?: string;\n\tinitial?: SubAgentDraft;\n}\n\n/**\n * Config-tool drawer state; `key` remounts fresh. `restapi` is the bespoke Rest\n * API panel; `config` is the shared dynamic panel (email / Slack), tagged with\n * its `toolKey`.\n */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Upsert an item by id (replace when present, append otherwise). */\nconst upsertById = <T extends { id: string }>(\n\tlist: T[] | undefined,\n\titem: T,\n): T[] => {\n\tconst arr = list ?? [];\n\treturn arr.some((x) => x.id === item.id)\n\t\t? arr.map((x) => (x.id === item.id ? item : x))\n\t\t: [...arr, item];\n};\n\nexport const Step3HowItResponds: React.FC = () => {\n\tconst {\n\t\tvalue,\n\t\tpatch,\n\t\tupdateField,\n\t\taddReference,\n\t\tremoveReference,\n\t\tavailableTools,\n\t\tavailableSubAgents,\n\t\tavailableModels,\n\t\tconfigToolTemplates,\n\t\tapplicationType,\n\t\tcharLimits,\n\t\tinsertMention,\n\t\tonCreateSubAgent,\n\t\tonFetchSubAgent,\n\t\tonUpdateSubAgent,\n\t\tonImproveSubAgent,\n\t\tonImproveToolInstructions,\n\t\tregisterSubAgentCreator,\n\t\tregisterToolActionHandler,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t\tvariablesData,\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\t// Pass the source so the fresh chip gets its icon (it isn't in the\n\t\t\t// editor's mention list yet).\n\t\t\tif (isNew) {\n\t\t\t\tinsertMention(\n\t\t\t\t\t'tool',\n\t\t\t\t\tconfig.id,\n\t\t\t\t\trestApiMentionItem(config).label,\n\t\t\t\t\tToolSource.RestApi,\n\t\t\t\t);\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\tconst source =\n\t\t\t\t\tconfig.tool_key === 'send_slack_message'\n\t\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t\t: ToolSource.EmailHandover;\n\t\t\t\tinsertMention(\n\t\t\t\t\t'tool',\n\t\t\t\t\tconfig.id,\n\t\t\t\t\tconfigToolMentionItem(config).label,\n\t\t\t\t\tsource,\n\t\t\t\t);\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// Ids of sub-agents saved this session that use an auth_required tool — they\n\t// make customer verification mandatory on the parent, just like a direct\n\t// auth_required tool. (A persisted sub-agent's tools aren't hydrated into\n\t// `value`, so it only joins this set once opened/edited in the panel.)\n\tconst [authRequiringSubAgents, setAuthRequiringSubAgents] = useState<\n\t\tSet<string>\n\t>(() => new Set());\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\t// ── Customer verification (auth) ──────────────────────────────────────────\n\t// Order tools (auth_required) can't run unless the customer is verified first,\n\t// so verification is MANDATORY whenever such a tool is attached (directly or\n\t// via a sub-agent). Derived before the handlers that read it.\n\tconst hasDirectAuthTool = value.tools.some(\n\t\t(id) => availableTools.find((t) => t.tool_id === id)?.auth_required,\n\t);\n\tconst hasAuthRequiredSubAgent = value.subagents.some((id) =>\n\t\tauthRequiringSubAgents.has(id),\n\t);\n\tconst hasAuthRequiredTool = hasDirectAuthTool || hasAuthRequiredSubAgent;\n\tconst authEnabled = value.authentication?.enabled ?? false;\n\tconst authType: Authentication['type'] =\n\t\tvalue.authentication?.type ?? 'email_otp';\n\n\tconst handlePanelSave = useCallback(\n\t\tasync (draft: SubAgentDraft) => {\n\t\t\tlet savedId: string | undefined;\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\tsavedId = ref.id;\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\tsavedId = ref.id;\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\t// A sub-agent that uses an auth_required tool forces customer\n\t\t\t// verification on the parent agent — the tool can't run otherwise. Record\n\t\t\t// it so verification stays mandatory (the reconcile effect turns it on and\n\t\t\t// the toggle locks), mirroring the direct-tool invariant.\n\t\t\tif (savedId) {\n\t\t\t\tconst targetId = savedId;\n\t\t\t\tconst subUsesAuthTool = draft.tools.some(\n\t\t\t\t\t(id) => availableTools.find((t) => t.tool_id === id)?.auth_required,\n\t\t\t\t);\n\t\t\t\tsetAuthRequiringSubAgents((prev) => {\n\t\t\t\t\tconst next = new Set(prev);\n\t\t\t\t\tif (subUsesAuthTool) {\n\t\t\t\t\t\tnext.add(targetId);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnext.delete(targetId);\n\t\t\t\t\t}\n\t\t\t\t\treturn next;\n\t\t\t\t});\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\tavailableTools,\n\t\t],\n\t);\n\n\t// Reconcile the invariant: a loaded agent that already holds an auth_required\n\t// tool must have verification on (a fail-closed tool otherwise runs silently).\n\tuseEffect(() => {\n\t\tif (hasAuthRequiredTool && !authEnabled) {\n\t\t\tpatch({ authentication: { enabled: true, type: authType } });\n\t\t}\n\t}, [hasAuthRequiredTool, authEnabled, authType, patch]);\n\n\t// A tool add awaiting the mandatory-verification confirm (null = no prompt).\n\tconst [pendingAuthTool, setPendingAuthTool] = useState<string | null>(null);\n\tconst addTool = useCallback(\n\t\t(id: string) => {\n\t\t\t// Always drop a chip at the cursor; addReference dedupes and reads the\n\t\t\t// latest value.\n\t\t\tinsertMention('tool', id);\n\t\t\taddReference('tool', id);\n\t\t},\n\t\t[insertMention, addReference],\n\t);\n\t// Adding an auth_required tool while verification is off prompts first; confirm\n\t// turns verification on and adds, cancel skips the add.\n\tconst handleAddTool = useCallback(\n\t\t(id: string) => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\tif (tool?.auth_required && !authEnabled) {\n\t\t\t\tsetPendingAuthTool(id);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\taddTool(id);\n\t\t},\n\t\t[availableTools, authEnabled, addTool],\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\t\tauthRequired: tool.auth_required,\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + the shared email / Slack tools) live on\n\t// the value, not in `tools`. They render as rows in the same Tools list, each\n\t// with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = (value.restApiTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: restApiToolName(t),\n\t\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\t\tonConfigure: () => openRestApi(t),\n\t\t}),\n\t);\n\tconst configToolItems: SelectableItem[] = (value.configTools ?? []).map(\n\t\t(t) => ({\n\t\t\tid: t.id,\n\t\t\tlabel: configToolName(t),\n\t\t\ticon: SOURCE_ICONS[\n\t\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t\t? ToolSource.Slack\n\t\t\t\t\t: ToolSource.EmailHandover\n\t\t\t],\n\t\t\tonConfigure: () => openConfigTool(t.tool_key, t),\n\t\t}),\n\t);\n\tconst allToolItems: SelectableItem[] = [\n\t\t...toolItems,\n\t\t...restApiItems,\n\t\t...configToolItems,\n\t];\n\n\t// Built-in tools that open a config drawer instead of inserting a mention.\n\t// Shown as empty-state buttons AND in the `@` picker's Tools view. The shared\n\t// email / Slack forms are backend-driven, so each is offered only when its\n\t// template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t\tintegrationStatus,\n\t\tonConnectIntegration,\n\t);\n\n\t// All tools are offered (even already-added ones) so a tool can be referenced\n\t// again in the text; the chip list below still shows each only once.\n\tconst toolOptions: SingleOption[] = availableTools.map(toolOption);\n\n\t// Group tools by source (Manifest / Shopify / …) for the empty-state buttons.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? ToolSource.Manifest;\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push(toolOption(t));\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t\t// Not connected → the source button opens the connect flow instead of\n\t\t\t// its tool list (see SelectableListSection / onConnectIntegration).\n\t\t\tconnected: integrationStatus?.[src as ToolSource],\n\t\t\tonConnect: () => onConnectIntegration?.(src as ToolSource),\n\t\t}));\n\t})();\n\n\tconst subAgentItems: SelectableItem[] = value.subagents\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst sub = subAgentById.get(id);\n\t\t\treturn sub ? { id, label: sub.name } : null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\tconst subAgentOptions: SingleOption[] = knownSubAgents.map((s) => ({\n\t\tlabel: s.name,\n\t\tvalue: s.id,\n\t}));\n\n\t// Per-section `@`-picker items so the header \"+\" opens the same reference\n\t// picker as the Instructions editor, drilled straight into this section's\n\t// category (tools OR sub-agents).\n\tconst appLabel = appTypeLabel(applicationType);\n\tconst toolMentionItems = [\n\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t...buildCustomToolMentionItems(value.configTools, value.restApiTools),\n\t];\n\tconst subAgentMentionItems = buildAgentMentionItems(\n\t\t[],\n\t\tknownSubAgents,\n\t\tappLabel,\n\t);\n\n\tconst modelOptions: SingleOption[] = availableModels.map((m) => ({\n\t\tlabel: m.label,\n\t\tvalue: m.value,\n\t\tselected: m.value === value.model,\n\t}));\n\tconst selectedModel = availableModels.find((m) => m.value === value.model);\n\n\t// The template for the open shared-drawer tool (undefined unless a config\n\t// drawer is open and its template was provided).\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\tconst verificationToggle = (\n\t\t<Switch\n\t\t\tdata-test=\"agent-auth-toggle\"\n\t\t\tvalue={authEnabled || hasAuthRequiredTool}\n\t\t\t// Mandatory (can't turn off) while an auth_required tool is attached.\n\t\t\tdisabled={hasAuthRequiredTool}\n\t\t\tonValueChange={async (enabled) => {\n\t\t\t\tpatch({ authentication: { enabled, type: authType } });\n\t\t\t}}\n\t\t/>\n\t);\n\t// While locked, a tooltip explains why the toggle can't be changed.\n\tconst verificationToggleNode = hasAuthRequiredTool ? (\n\t\t<Tooltip\n\t\t\tbody=\"Remove tools that requires customer verification to change this setting.\"\n\t\t\tplacement=\"bottom\"\n\t\t>\n\t\t\t<span style={{ display: 'flex' }}>{verificationToggle}</span>\n\t\t</Tooltip>\n\t) : (\n\t\tverificationToggle\n\t);\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={handleAddTool}\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<SideSection>\n\t\t\t\t\t\t<SideSectionHeader>\n\t\t\t\t\t\t\t<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n\t\t\t\t\t\t\t\t<Shield size={20} />\n\t\t\t\t\t\t\t\t<TitleSmall color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tRequire customer verification\n\t\t\t\t\t\t\t\t</TitleSmall>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{verificationToggleNode}\n\t\t\t\t\t\t</SideSectionHeader>\n\t\t\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t{hasAuthRequiredTool\n\t\t\t\t\t\t\t\t? 'Required — this agent uses a tool that accesses customer order details.'\n\t\t\t\t\t\t\t\t: 'Customers must verify their identity before this agent responds.'}\n\t\t\t\t\t\t</BodyCaption>\n\t\t\t\t\t\t{(authEnabled || hasAuthRequiredTool) && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BodySecondary color={COLORS.content.primary}>\n\t\t\t\t\t\t\t\t\tSelect verification method\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-auth-method\"\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\twidth=\"100%\"\n\t\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\t// match the input: 360px side column − 2×16px padding.\n\t\t\t\t\t\t\t\t\tdropdownWidth=\"328px\"\n\t\t\t\t\t\t\t\t\tplaceHolder=\"Select verification method\"\n\t\t\t\t\t\t\t\t\t// Flag the active method so the open list highlights that row\n\t\t\t\t\t\t\t\t\t// green (list-item 'selected' theme handles the styling).\n\t\t\t\t\t\t\t\t\toptions={AUTH_METHOD_OPTIONS.map((o) => ({\n\t\t\t\t\t\t\t\t\t\t...o,\n\t\t\t\t\t\t\t\t\t\tselected: o.value === authType,\n\t\t\t\t\t\t\t\t\t}))}\n\t\t\t\t\t\t\t\t\tdefaultOptions={[\n\t\t\t\t\t\t\t\t\t\tAUTH_METHOD_OPTIONS.find((o) => o.value === authType) ??\n\t\t\t\t\t\t\t\t\t\t\tAUTH_METHOD_OPTIONS[0],\n\t\t\t\t\t\t\t\t\t]}\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\tpatch({\n\t\t\t\t\t\t\t\t\t\t\t\tauthentication: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype: v as Authentication['type'],\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});\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</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</SideSection>\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\t// Block reusing another sub-agent's name (exclude the one being edited).\n\t\t\t\t\texistingNames={value.subagents\n\t\t\t\t\t\t.filter((id) => id !== panel.editingId)\n\t\t\t\t\t\t.map((id) => subAgentById.get(id)?.name)\n\t\t\t\t\t\t.filter((n): n is string => !!n)}\n\t\t\t\t\tavailableTools={availableTools}\n\t\t\t\t\tconfigToolTemplates={configToolTemplates}\n\t\t\t\t\tvariablesData={variablesData}\n\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\tonConnectIntegration={onConnectIntegration}\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\tvariablesData={variablesData}\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\tvariablesData={variablesData}\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\n\t\t\t<RequireVerificationModal\n\t\t\t\topen={pendingAuthTool !== null}\n\t\t\t\ttoolLabel={\n\t\t\t\t\tavailableTools.find((t) => t.tool_id === pendingAuthTool)\n\t\t\t\t\t\t?.display_name ?? 'This tool'\n\t\t\t\t}\n\t\t\t\tonCancel={() => setPendingAuthTool(null)}\n\t\t\t\tonConfirm={() => {\n\t\t\t\t\tpatch({ authentication: { enabled: true, type: authType } });\n\t\t\t\t\tif (pendingAuthTool) {\n\t\t\t\t\t\taddTool(pendingAuthTool);\n\t\t\t\t\t}\n\t\t\t\t\tsetPendingAuthTool(null);\n\t\t\t\t}}\n\t\t\t/>\n\t\t</Step3Root>\n\t);\n};\n"],"names":["toolIconEl","source","renderSourceIcon","sourceIcon","toolOption","t","ToolSource","STEP","STEP_DEFINITIONS","AUTH_METHOD_OPTIONS","upsertById","list","item","arr","x","Step3HowItResponds","value","patch","updateField","addReference","removeReference","availableTools","availableSubAgents","availableModels","configToolTemplates","applicationType","charLimits","insertMention","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","registerSubAgentCreator","registerToolActionHandler","integrationStatus","onConnectIntegration","variablesData","useAgentBuilderContext","panel","setPanel","useState","panelKeyRef","useRef","toolDrawer","setToolDrawer","toolDrawerKeyRef","openRestApi","useCallback","initial","openConfigTool","toolKey","handleSaveRestApi","config","isNew","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","openToolAction","CONFIG_TOOL_SOURCES","useEffect","createdSubAgents","setCreatedSubAgents","authRequiringSubAgents","setAuthRequiringSubAgents","subAgentById","s","knownSubAgents","openCreate","openConfigure","id","data","hasDirectAuthTool","hasAuthRequiredSubAgent","hasAuthRequiredTool","authEnabled","authType","handlePanelSave","draft","savedId","ref","prev","targetId","subUsesAuthTool","next","pendingAuthTool","setPendingAuthTool","addTool","handleAddTool","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","verificationToggle","jsx","Switch","enabled","verificationToggleNode","Tooltip","Step3Root","StepSectionHeader","jsxs","Step3Grid","SectionBodyWrap","MentionField","Step3Divider","SelectableListSection","SideSection","SideSectionHeader","Shield","TitleSmall","COLORS","BodyCaption","Fragment","BodySecondary","Dropdown","o","opt","v","unwrapDropdownValue","CreateSubAgentPanel","n","RestApiToolPanel","ConfigToolPanel","RequireVerificationModal"],"mappings":"qiCA6DMA,GAAcC,GACnBC,EAAAA,iBAAiBC,EAAAA,WAAWF,CAAM,CAAC,GAAK,OAGnCG,GAAcC,IAAgC,CACnD,MAAOA,EAAE,aACT,MAAOA,EAAE,QACT,YAAaL,GAAWK,EAAE,QAAUC,EAAAA,WAAW,QAAQ,CACxD,GAEMC,GAAOC,GAAAA,iBAAiB,CAAC,EAGzBC,EAAsC,CAC3C,CAAE,MAAO,eAAgB,MAAO,WAAA,EAChC,CAAE,MAAO,eAAgB,MAAO,WAAA,CACjC,EAwBMC,GAAa,CAClBC,EACAC,IACS,CACT,MAAMC,EAAMF,GAAQ,CAAA,EACpB,OAAOE,EAAI,KAAMC,GAAMA,EAAE,KAAOF,EAAK,EAAE,EAC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,cAAgB,YAEpB,SAAU,IAAMC,EAAmB,IAAI,EACvC,UAAW,IAAM,CAChBrE,EAAM,CAAE,eAAgB,CAAE,QAAS,GAAM,KAAM2D,CAAA,EAAY,EACvDS,GACHE,EAAQF,CAAe,EAExBC,EAAmB,IAAI,CACxB,CAAA,CAAA,CACD,EACD,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("../../../assets/icons/RedirectToNew.svg.js"),u=require("../../radioButton/RadioButton.js"),s=require("../../TypographyStyle.js"),n=require("../../../constants/Theme.js"),t=require("../AgentBuilder.styled.js"),j=require("../components/AiTextArea.js"),p=require("../components/StepSectionHeader.js"),C=require("../constants/steps.js"),v=require("../context/AgentBuilderContext.js"),y=require("../utils/mentionSerialization.js"),T=require("../../tooltips/Tooltip.js"),d=C.STEP_DEFINITIONS[3],h="default",f=()=>{const{value:l,patch:a,applicationType:c,onSmartAgentHandover:o}=v.useAgentBuilderContext(),{handover:r}=l,m=y.appTypeLabel(c)==="BIK",i=r.method!==h;return m?e.jsxs("div",{className:"bik-agent-step bik-agent-step--handover",children:[e.jsx(p.StepSectionHeader,{title:d.title,helper:d.helper}),e.jsxs(t.SectionBodyWrap,{children:[e.jsxs(t.FieldBlock,{children:[e.jsx(s.TitleSmall,{color:n.COLORS.content.primary,children:"Handover method"}),e.jsxs(t.CardRow,{children:[e.jsxs(t.RadioCard,{"data-test":"handover-method-default",type:"button",selected:!i,onClick:()=>a({handover:{...r,method:h}}),children:[e.jsx(u.RadioButton,{isActive:!i,onValueChange:()=>a({handover:{...r,method:h}}),skipSelectingOff:!0,activeColor:n.BASE_COLORS.brand[800]}),e.jsxs(t.RadioCardText,{children:[e.jsx(s.TitleSmall,{color:n.COLORS.content.primary,children:"Use default settings"}),e.jsxs(s.BodyCaption,{color:n.COLORS.content.secondary,children:["As defined in"," ",o?e.jsxs(t.ChannelsLink,{"data-test":"handover-smart-agent-link",type:"button",onClick:S=>{S.stopPropagation(),o()},style:{display:"inline-flex"},children:["Smart agent handover",e.jsx(g.default,{width:12,height:12})]}):"Smart agent handover"]})]})]}),e.jsx(T.Tooltip,{body:"Custom handover rules are coming soon. For now this agent follows your smart agent handover settings.",placement:"top",children:e.jsx("span",{style:{flex:1,display:"flex",cursor:"not-allowed"},children:e.jsxs(t.RadioCard,{"data-test":"handover-method-custom",type:"button",disabled:!0,selected:i,children:[e.jsx(u.RadioButton,{isActive:i,isDisabled:!0,onValueChange:()=>{},skipSelectingOff:!0,activeColor:n.BASE_COLORS.brand[800]}),e.jsxs(t.RadioCardText,{children:[e.jsx(s.TitleSmall,{color:n.COLORS.content.inactive,children:"Custom instructions"}),e.jsx(s.BodyCaption,{color:n.COLORS.content.inactive,children:"Write custom handover rules for this agent."})]})]})})})]})]}),i&&e.jsx(x,{})]})]}):e.jsxs("div",{className:"bik-agent-step bik-agent-step--handover",children:[e.jsx(p.StepSectionHeader,{title:d.title,helper:d.helper}),e.jsx(t.SectionBodyWrap,{children:e.jsx(x,{})})]})},x=()=>{const{value:l,patch:a,charLimits:c}=v.useAgentBuilderContext(),{handover:o}=l;return e.jsx(j.AiTextArea,{"data-test":"handover-when",label:"Handover when",value:o.when,onChange:r=>a({handover:{...o,when:r}}),maxLength:c.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=f;
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;
2
2
  //# sourceMappingURL=Step4HandoverRules.js.map