@bikdotai/bik-component-library 0.0.850-tools-beta.0 → 0.0.850

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 (133) hide show
  1. package/dist/cjs/assets/icons/ShipStation.svg.js +1 -1
  2. package/dist/cjs/assets/icons/ShipStation.svg.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +40 -22
  4. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +1 -1
  6. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +5 -5
  8. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/components/DiscardModal.js +1 -1
  10. package/dist/cjs/components/agent-builder/components/DiscardModal.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
  14. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/MentionPicker.js +32 -24
  16. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js +1 -1
  18. package/dist/cjs/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +4 -4
  20. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +2 -2
  22. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  23. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  24. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  25. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  26. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  27. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  28. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  29. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +2 -2
  30. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  31. package/dist/cjs/components/agent-builder/utils/sourceIcons.js +1 -1
  32. package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -1
  33. package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
  34. package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
  35. package/dist/cjs/components/agent-listing/AgentTable.js +1 -1
  36. package/dist/cjs/components/agent-listing/AgentTable.js.map +1 -1
  37. package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
  38. package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
  39. package/dist/cjs/components/agent-listing/AiAgentsEmptyState.js +2 -0
  40. package/dist/cjs/components/agent-listing/AiAgentsEmptyState.js.map +1 -0
  41. package/dist/cjs/editor/BikEditor.js +1 -1
  42. package/dist/cjs/editor/BikEditor.js.map +1 -1
  43. package/dist/cjs/editor/BikEditor.styles.js +21 -16
  44. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  45. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  46. package/dist/cjs/editor/extensions/buildExtensions.js +2 -2
  47. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  48. package/dist/cjs/editor/extensions/characterLimit/CharacterLimitExtension.js +3 -3
  49. package/dist/cjs/editor/extensions/characterLimit/CharacterLimitExtension.js.map +1 -1
  50. package/dist/cjs/editor/extensions/mention/MentionChipNodeView.js +2 -0
  51. package/dist/cjs/editor/extensions/mention/MentionChipNodeView.js.map +1 -0
  52. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  53. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  54. package/dist/cjs/icons/Informational/Common UI/ShieldOutline.js +2 -0
  55. package/dist/cjs/icons/Informational/Common UI/ShieldOutline.js.map +1 -0
  56. package/dist/cjs/icons/index.js +1 -1
  57. package/dist/esm/assets/icons/ShipStation.svg.js +2 -2
  58. package/dist/esm/assets/icons/ShipStation.svg.js.map +1 -1
  59. package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +3 -0
  60. package/dist/esm/components/agent-builder/AgentBuilder.styled.js +61 -42
  61. package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  62. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +1 -1
  63. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  64. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +5 -0
  65. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +243 -227
  66. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  67. package/dist/esm/components/agent-builder/components/DiscardModal.js +57 -49
  68. package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
  69. package/dist/esm/components/agent-builder/components/GoLiveModal.js +26 -22
  70. package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
  71. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +1 -1
  72. package/dist/esm/components/agent-builder/components/MentionEditor.js +93 -77
  73. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  74. package/dist/esm/components/agent-builder/components/MentionPicker.js +194 -168
  75. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  76. package/dist/esm/components/agent-builder/components/RequireVerificationModal.js +5 -5
  77. package/dist/esm/components/agent-builder/components/RequireVerificationModal.js.map +1 -1
  78. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +118 -109
  79. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  80. package/dist/esm/components/agent-builder/components/SelectableListSection.js +149 -133
  81. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  82. package/dist/esm/components/agent-builder/constants/tools.d.ts +9 -11
  83. package/dist/esm/components/agent-builder/constants/tools.js +24 -21
  84. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  85. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +6 -2
  86. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +46 -43
  87. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  88. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +209 -183
  89. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  90. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +3 -2
  91. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +24 -19
  92. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  93. package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +9 -1
  94. package/dist/esm/components/agent-builder/utils/sourceIcons.js +15 -9
  95. package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
  96. package/dist/esm/components/agent-listing/AgentListing.js +79 -83
  97. package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
  98. package/dist/esm/components/agent-listing/AgentListing.model.d.ts +6 -0
  99. package/dist/esm/components/agent-listing/AgentTable.d.ts +2 -0
  100. package/dist/esm/components/agent-listing/AgentTable.js +29 -27
  101. package/dist/esm/components/agent-listing/AgentTable.js.map +1 -1
  102. package/dist/esm/components/agent-listing/AgentTableRow.d.ts +2 -0
  103. package/dist/esm/components/agent-listing/AgentTableRow.js +51 -37
  104. package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
  105. package/dist/esm/components/agent-listing/AiAgentsEmptyState.d.ts +22 -0
  106. package/dist/esm/components/agent-listing/AiAgentsEmptyState.js +22 -0
  107. package/dist/esm/components/agent-listing/AiAgentsEmptyState.js.map +1 -0
  108. package/dist/esm/editor/BikEditor.js +129 -126
  109. package/dist/esm/editor/BikEditor.js.map +1 -1
  110. package/dist/esm/editor/BikEditor.styles.js +24 -19
  111. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  112. package/dist/esm/editor/BikEditor.types.d.ts +17 -0
  113. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  114. package/dist/esm/editor/extensions/buildExtensions.d.ts +7 -0
  115. package/dist/esm/editor/extensions/buildExtensions.js +30 -24
  116. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  117. package/dist/esm/editor/extensions/characterLimit/CharacterLimitExtension.d.ts +20 -3
  118. package/dist/esm/editor/extensions/characterLimit/CharacterLimitExtension.js +40 -25
  119. package/dist/esm/editor/extensions/characterLimit/CharacterLimitExtension.js.map +1 -1
  120. package/dist/esm/editor/extensions/mention/MentionChipNodeView.d.ts +17 -0
  121. package/dist/esm/editor/extensions/mention/MentionChipNodeView.js +39 -0
  122. package/dist/esm/editor/extensions/mention/MentionChipNodeView.js.map +1 -0
  123. package/dist/esm/editor/extensions/mention/MentionExtension.d.ts +1 -1
  124. package/dist/esm/editor/extensions/mention/MentionExtension.js +67 -45
  125. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  126. package/dist/esm/icons/Informational/Common UI/ShieldOutline.d.ts +7 -0
  127. package/dist/esm/icons/Informational/Common UI/ShieldOutline.js +35 -0
  128. package/dist/esm/icons/Informational/Common UI/ShieldOutline.js.map +1 -0
  129. package/dist/esm/icons/Informational/Common UI/index.d.ts +1 -0
  130. package/dist/esm/icons/index.d.ts +25 -25
  131. package/dist/esm/icons/index.js +172 -170
  132. package/dist/esm/icons/index.js.map +1 -1
  133. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { Toaster } from '@src/components/toaster';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tParamsBlob,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport {\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';\nimport { ConfigToolPanel } from './ConfigToolPanel';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { MentionEditor } from './MentionEditor';\nimport { RestApiToolPanel } from './RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\n/**\n * The sub-agent drawer sits above the main builder; its own tool drawers\n * (Rest API / email / Slack) stack one level higher so they open ON TOP of it\n * rather than behind (SideModal defaults to z-index 10).\n */\nconst SUBAGENT_ZINDEX = 1000;\nconst TOOL_DRAWER_ZINDEX = 1002;\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\n/** Config-tool / Rest API drawer state; `key` remounts fresh per open. */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Inline \"Improve with AI\" action rendered below a mention editor. */\nconst ImproveButton = styled.button`\n\talign-self: flex-start;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tcolor: ${COLORS.content.primary};\n\tbackground: ${COLORS.surface.standard};\n\tborder-radius: 8px;\n\tpadding: 6px 12px;\n\tfont-size: 13px;\n\tline-height: 1.1;\n\tfont-weight: 600;\n\tcursor: pointer;\n\n\t&:disabled {\n\t\tcursor: default;\n\t\topacity: 0.6;\n\t}\n`;\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / config-tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\t/**\n\t * Backend templates (email / Slack) that drive the shared config-tool drawer.\n\t * Each present key enables its tool action in this drawer; absent → hidden.\n\t * Same prop the main builder gets — sub-agents can add the same tools.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\tonImproveToolInstructions,\n\tconfigToolTemplates,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\t// Inline-configured tools owned by this sub-agent (same drawers as the main\n\t// agent). Local to the drawer; flow to the consumer via the saved draft.\n\tconst [configTools, setConfigTools] = useState<ConfigToolConfig[]>(\n\t\tinitial?.configTools ?? [],\n\t);\n\tconst [restApiTools, setRestApiTools] = useState<RestApiToolConfig[]>(\n\t\tinitial?.restApiTools ?? [],\n\t);\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents), PLUS\n\t// this drawer's inline custom tools so their `{{tool:<id>}}` tokens rehydrate\n\t// as chips on remount (they aren't in `availableTools`).\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t\t...buildCustomToolMentionItems(configTools, restApiTools),\n\t\t],\n\t\t[availableTools, appLabel, configTools, restApiTools],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\t// Latest custom-tool ids, readable from the mount-captured `@` onSelect handler\n\t// (BikEditor captures it once) — mirrors the context's valueRef trick.\n\tconst customToolIdsRef = useRef<Set<string>>(new Set());\n\tcustomToolIdsRef.current = new Set(\n\t\t[...configTools, ...restApiTools].map((t) => t.id),\n\t);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Only catalog tool ids belong in `tools`; custom tools (Rest API / email /\n\t\t\t// Slack) track themselves on their own lists. Picking an existing custom\n\t\t\t// tool from `@` must not leak its id in as a bogus native ref.\n\t\t\tif (kind === 'tool' && !customToolIdsRef.current.has(id)) {\n\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string, label?: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id, label);\n\t}, []);\n\n\t// Rest API (bespoke) + shared config-tool (email / Slack) drawers, same as the\n\t// main builder's Step 3 — here backed by the drawer's local state.\n\t// ponytail: mirrors Step3HowItResponds; kept local rather than sharing a hook\n\t// because Step3 is context-backed and this drawer is local-state.\n\tconst openRestApi = useCallback((tool?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: tool,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, tool?: 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: tool,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\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\tconst handleSaveRestApi = useCallback(\n\t\t(tool: RestApiToolConfig) => {\n\t\t\tconst isNew = !restApiTools.some((t) => t.id === tool.id);\n\t\t\tsetRestApiTools((prev) => upsertById(prev, tool));\n\t\t\t// Drop a reference chip at the cursor on creation (edits keep the chip).\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, restApiMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[restApiTools, insertToolAtCursor],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(tool: ConfigToolConfig) => {\n\t\t\tconst isNew = !configTools.some((t) => t.id === tool.id);\n\t\t\tsetConfigTools((prev) => upsertById(prev, tool));\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(tool.id, configToolMentionItem(tool).label);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[configTools, insertToolAtCursor],\n\t);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t\tconfigTools: ConfigToolConfig[];\n\t\trestApiTools: RestApiToolConfig[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Remove ANY tool by id: strip its `{{tool:<id>}}` tokens, remount the fields,\n\t// and drop it from whichever list holds it (catalog `tools` or an inline\n\t// custom-tool list). One undo restores all of it.\n\tconst removeTool = (id: string) => {\n\t\tconst label =\n\t\t\tavailableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\trestApiTools.find((t) => t.id === id)?.name ??\n\t\t\t'Tool';\n\t\t// The token stores the tool id (a tool's id is its tool_id).\n\t\tconst token = `{{tool:${id}}}`;\n\t\tconst strip = (text: string) => text.split(token).join('');\n\t\tundoSnapshotRef.current = {\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t};\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetConfigTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetRestApiTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({ id: undoIdRef.current, message: `Tool \"${label}\" removed` });\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetConfigTools(snap.configTools);\n\t\t\tsetRestApiTools(snap.restApiTools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst canSave =\n\t\tname.trim().length > 0 &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + email / Slack) render as rows in the same\n\t// list, each with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = restApiTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: restApiToolName(t),\n\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\tonConfigure: () => openRestApi(t),\n\t}));\n\tconst configToolItems: SelectableItem[] = configTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: configToolName(t),\n\t\ticon: SOURCE_ICONS[\n\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t? ToolSource.Slack\n\t\t\t\t: ToolSource.EmailHandover\n\t\t],\n\t\tonConfigure: () => openConfigTool(t.tool_key, 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 tool actions (Rest API / email / Slack); the shared email / Slack\n\t// forms appear only when their backend template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped. Icon left of\n\t// the name, no description.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => ({\n\t\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\tundefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\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({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\t\t\tundefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SideModal\n\t\t\t\theader={title}\n\t\t\t\tcloseOnEscapeKey={false}\n\t\t\t\tzIndex={SUBAGENT_ZINDEX}\n\t\t\t\theaderCustomComponent={\n\t\t\t\t\t<DrawerHeaderText\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tsubtitle=\"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them.\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\twidth=\"421px\"\n\t\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\t\tonClose={onClose}\n\t\t\t\tsaveButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-save',\n\t\t\t\t\tbuttonText: 'Save',\n\t\t\t\t\tbuttonType: 'primary',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tdisabled: !canSave,\n\t\t\t\t\tisLoading: saving,\n\t\t\t\t\tonClick: handleSave,\n\t\t\t\t}}\n\t\t\t\tcancelButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-cancel',\n\t\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tonClick: onClose,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Input\n\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\tlabelTextBold\n\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\tvalue={name}\n\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\tonChangeText={setName}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\tvalue={instructions}\n\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-instructions\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('instructions')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'instructions'\n\t\t\t\t\t\t\t\t\t? 'Improving…'\n\t\t\t\t\t\t\t\t\t: 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-guardrail\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('guardrail')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'guardrail' ? 'Improving…' : 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<SelectableListSection\n\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\titems={allToolItems}\n\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\tpickerOpensUp\n\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t}}\n\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\tconfirmDelete={{ noun: 'tool', zIndex: TOOL_DRAWER_ZINDEX + 1 }}\n\t\t\t\t/>\n\t\t\t</SideModal>\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["SUBAGENT_ZINDEX","TOOL_DRAWER_ZINDEX","upsertById","list","item","arr","x","ImproveButton","styled","COLORS","CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","onImproveToolInstructions","configToolTemplates","title","initial","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","configTools","setConfigTools","restApiTools","setRestApiTools","toolDrawer","setToolDrawer","toolDrawerKeyRef","useRef","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","buildCustomToolMentionItems","insertersRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","customToolIdsRef","t","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","label","openRestApi","tool","openConfigTool","toolKey","openToolAction","source","CONFIG_TOOL_SOURCES","handleSaveRestApi","isNew","restApiMentionItem","handleSaveConfigTool","configToolMentionItem","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","token","strip","text","k","undoRemove","snap","canSave","toolItems","sourceIcon","ToolSource","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","openConfigTemplate","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","handleImprove","improved","jsxs","Fragment","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","Input","MentionEditor","SelectableListSection","RestApiToolPanel","ConfigToolPanel","Toaster"],"mappings":"8yBAqDMA,GAAkB,IAClBC,EAAqB,KAGrBC,GAAa,CAClBC,EACAC,IACS,CACT,MAAMC,EAAMF,GAAQ,CAAA,EACpB,OAAOE,EAAI,KAAMC,GAAMA,EAAE,KAAOF,EAAK,EAAE,EACpCC,EAAI,IAAKC,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,EACf,UAAU,sBACV,cAAa,GACb,MAAQtC,GAAO,CACdG,EAAmBH,CAAE,EACrBjC,EAAUkC,GAASC,GAAAA,UAAUD,EAAMD,CAAE,CAAC,CACvC,EACA,SAAUqB,GACV,cAAe,CAAE,KAAM,OAAQ,OAAQnF,EAAqB,CAAA,CAAE,CAAA,CAC/D,CAAA,CAAA,EAGAkC,GAAY,OAAS,WACrBmF,EAAAA,IAACO,GAAAA,iBAAA,CAEA,QAAS1F,EAAW,YAAA,WACpBf,EACA,UAAWL,EACX,QAAS,IAAMqB,EAAc,IAAI,EACjC,OAAQuC,GACR,OAAQ1E,CAAA,EANHkC,EAAW,GAAA,EAUjBA,GAAY,OAAS,UACrBA,EAAW,SACXoE,IACCe,EAAAA,IAACQ,GAAAA,gBAAA,CAEA,QAAS3F,EAAW,QACpB,SAAUoE,GACV,QAASpE,EAAW,cAAA,WACpBf,EACA,UAAWL,EACX,QAAS,IAAMqB,EAAc,IAAI,EACjC,OAAQ0C,GACR,OAAQ7E,CAAA,EARHkC,EAAW,GAAA,EAYlB6C,GACAsC,EAAAA,IAACS,GAAAA,QAAA,CAEA,KAAM/C,EAAK,QACX,KAAK,OACL,SAAS,YACT,UAAW,IACX,gBAAe,GACf,YAAa,CACZ,WAAY,OACZ,WAAY,GACZ,cAAe,KACdS,GAAA,EACO,CAAA,EACR,EAED,aAAc,IAAMR,EAAQ,IAAI,CAAA,EAd3BD,EAAK,EAAA,CAeX,EAEF,CAEF"}
1
+ {"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { SideModal } from '@src/components/side-modal';\nimport { Toaster } from '@src/components/toaster';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAgentTool,\n\tConfigToolConfig,\n\tConfigToolKey,\n\tParamsBlob,\n\tRestApiToolConfig,\n\tSubAgentDraft,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { CONFIG_TOOL_SOURCES, ToolSource } from '../constants/tools';\nimport {\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';\nimport { ConfigToolPanel } from './ConfigToolPanel';\nimport {\n\tDRAWER_BODY_STYLE,\n\tDRAWER_HEADER_STYLE,\n\tDrawerHeaderText,\n} from './DrawerHeaderText';\nimport { MentionEditor } from './MentionEditor';\nimport { RestApiToolPanel } from './RestApiToolPanel';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\n/**\n * The sub-agent drawer sits above the main builder; its own tool drawers\n * (Rest API / email / Slack) stack one level higher so they open ON TOP of it\n * rather than behind (SideModal defaults to z-index 10).\n */\nconst SUBAGENT_ZINDEX = 1000;\nconst TOOL_DRAWER_ZINDEX = 1002;\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\n/** Config-tool / Rest API drawer state; `key` remounts fresh per open. */\ninterface ToolDrawerState {\n\tkey: number;\n\tkind: 'restapi' | 'config';\n\ttoolKey?: ConfigToolKey;\n\tinitialRest?: RestApiToolConfig;\n\tinitialConfig?: ConfigToolConfig;\n}\n\n/** Inline \"Improve with AI\" action rendered below a mention editor. */\nconst ImproveButton = styled.button`\n\talign-self: flex-start;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tcolor: ${COLORS.content.primary};\n\tbackground: ${COLORS.surface.standard};\n\tborder-radius: 8px;\n\tpadding: 6px 12px;\n\tfont-size: 13px;\n\tline-height: 1.1;\n\tfont-weight: 600;\n\tcursor: pointer;\n\n\t&:disabled {\n\t\tcursor: default;\n\t\topacity: 0.6;\n\t}\n`;\n\ntype InsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n\tsource?: string,\n) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / config-tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\t/**\n\t * Backend templates (email / Slack) that drive the shared config-tool drawer.\n\t * Each present key enables its tool action in this drawer; absent → hidden.\n\t * Same prop the main builder gets — sub-agents can add the same tools.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/**\n\t * Names of the other sub-agents already on this agent (exclude the one being\n\t * edited). Blocks saving a duplicate name — the LLM references sub-agents by it.\n\t */\n\texistingNames?: string[];\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\tonImproveToolInstructions,\n\tconfigToolTemplates,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\texistingNames = [],\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\t// Inline-configured tools owned by this sub-agent (same drawers as the main\n\t// agent). Local to the drawer; flow to the consumer via the saved draft.\n\tconst [configTools, setConfigTools] = useState<ConfigToolConfig[]>(\n\t\tinitial?.configTools ?? [],\n\t);\n\tconst [restApiTools, setRestApiTools] = useState<RestApiToolConfig[]>(\n\t\tinitial?.restApiTools ?? [],\n\t);\n\tconst [toolDrawer, setToolDrawer] = useState<ToolDrawerState | null>(null);\n\tconst toolDrawerKeyRef = useRef(0);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents), PLUS\n\t// this drawer's inline custom tools so their `{{tool:<id>}}` tokens rehydrate\n\t// as chips on remount (they aren't in `availableTools`).\n\tconst mentionItems = useMemo(\n\t\t() => [\n\t\t\t...buildAgentMentionItems(availableTools, [], appLabel),\n\t\t\t...buildCustomToolMentionItems(configTools, restApiTools),\n\t\t],\n\t\t[availableTools, appLabel, configTools, restApiTools],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\t// Latest custom-tool ids, readable from the mount-captured `@` onSelect handler\n\t// (BikEditor captures it once) — mirrors the context's valueRef trick.\n\tconst customToolIdsRef = useRef<Set<string>>(new Set());\n\tcustomToolIdsRef.current = new Set(\n\t\t[...configTools, ...restApiTools].map((t) => t.id),\n\t);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Only catalog tool ids belong in `tools`; custom tools (Rest API / email /\n\t\t\t// Slack) track themselves on their own lists. Picking an existing custom\n\t\t\t// tool from `@` must not leak its id in as a bogus native ref.\n\t\t\tif (kind === 'tool' && !customToolIdsRef.current.has(id)) {\n\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback(\n\t\t(id: string, label?: string, source?: string) => {\n\t\t\tconst target =\n\t\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\t\tinsertersRef.current.instructions;\n\t\t\ttarget?.('tool', id, label, source);\n\t\t},\n\t\t[],\n\t);\n\n\t// Rest API (bespoke) + shared config-tool (email / Slack) drawers, same as the\n\t// main builder's Step 3 — here backed by the drawer's local state.\n\t// ponytail: mirrors Step3HowItResponds; kept local rather than sharing a hook\n\t// because Step3 is context-backed and this drawer is local-state.\n\tconst openRestApi = useCallback((tool?: RestApiToolConfig) => {\n\t\ttoolDrawerKeyRef.current += 1;\n\t\tsetToolDrawer({\n\t\t\tkey: toolDrawerKeyRef.current,\n\t\t\tkind: 'restapi',\n\t\t\tinitialRest: tool,\n\t\t});\n\t}, []);\n\tconst openConfigTool = useCallback(\n\t\t(toolKey: ConfigToolKey, tool?: 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: tool,\n\t\t\t});\n\t\t},\n\t\t[],\n\t);\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\tconst handleSaveRestApi = useCallback(\n\t\t(tool: RestApiToolConfig) => {\n\t\t\tconst isNew = !restApiTools.some((t) => t.id === tool.id);\n\t\t\tsetRestApiTools((prev) => upsertById(prev, tool));\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 shows its icon (not yet in the list).\n\t\t\tif (isNew) {\n\t\t\t\tinsertToolAtCursor(\n\t\t\t\t\ttool.id,\n\t\t\t\t\trestApiMentionItem(tool).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[restApiTools, insertToolAtCursor],\n\t);\n\tconst handleSaveConfigTool = useCallback(\n\t\t(tool: ConfigToolConfig) => {\n\t\t\tconst isNew = !configTools.some((t) => t.id === tool.id);\n\t\t\tsetConfigTools((prev) => upsertById(prev, tool));\n\t\t\tif (isNew) {\n\t\t\t\tconst source =\n\t\t\t\t\ttool.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\tinsertToolAtCursor(tool.id, configToolMentionItem(tool).label, source);\n\t\t\t}\n\t\t\tsetToolDrawer(null);\n\t\t},\n\t\t[configTools, insertToolAtCursor],\n\t);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t\tconfigTools: ConfigToolConfig[];\n\t\trestApiTools: RestApiToolConfig[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Remove ANY tool by id: strip its `{{tool:<id>}}` tokens, remount the fields,\n\t// and drop it from whichever list holds it (catalog `tools` or an inline\n\t// custom-tool list). One undo restores all of it.\n\tconst removeTool = (id: string) => {\n\t\tconst label =\n\t\t\tavailableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\trestApiTools.find((t) => t.id === id)?.name ??\n\t\t\t'Tool';\n\t\t// The token stores the tool id (a tool's id is its tool_id).\n\t\tconst token = `{{tool:${id}}}`;\n\t\tconst strip = (text: string) => text.split(token).join('');\n\t\tundoSnapshotRef.current = {\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t};\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetConfigTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetRestApiTools((prev) => prev.filter((t) => t.id !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({ id: undoIdRef.current, message: `Tool \"${label}\" removed` });\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetConfigTools(snap.configTools);\n\t\t\tsetRestApiTools(snap.restApiTools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst nameTrimmed = name.trim();\n\t// Case-insensitive: two sub-agents on the same agent can't share a name (the\n\t// LLM references them by it) — mirrors the Rest API tool-name check.\n\tconst isDuplicateName =\n\t\tnameTrimmed.length > 0 &&\n\t\texistingNames.some(\n\t\t\t(n) => n.trim().toLowerCase() === nameTrimmed.toLowerCase(),\n\t\t);\n\tconst canSave =\n\t\tnameTrimmed.length > 0 &&\n\t\t!isDuplicateName &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: sourceIcon(tool.source ?? ToolSource.Manifest),\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Inline-configured tools (Rest API + email / Slack) render as rows in the same\n\t// list, each with its own Configure (edit) action that reopens its drawer.\n\tconst restApiItems: SelectableItem[] = restApiTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: restApiToolName(t),\n\t\ticon: SOURCE_ICONS[ToolSource.RestApi],\n\t\tonConfigure: () => openRestApi(t),\n\t}));\n\tconst configToolItems: SelectableItem[] = configTools.map((t) => ({\n\t\tid: t.id,\n\t\tlabel: configToolName(t),\n\t\ticon: SOURCE_ICONS[\n\t\t\tt.tool_key === 'send_slack_message'\n\t\t\t\t? ToolSource.Slack\n\t\t\t\t: ToolSource.EmailHandover\n\t\t],\n\t\tonConfigure: () => openConfigTool(t.tool_key, 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 tool actions (Rest API / email / Slack); the shared email / Slack\n\t// forms appear only when their backend template was provided.\n\tconst toolActionSources = buildToolActions(\n\t\tconfigToolTemplates,\n\t\topenToolAction,\n\t);\n\n\tconst openConfigTemplate =\n\t\ttoolDrawer?.kind === 'config' && toolDrawer.toolKey\n\t\t\t? configToolTemplates?.[toolDrawer.toolKey]\n\t\t\t: undefined;\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped. Icon left of\n\t// the name, no description.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => ({\n\t\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\tundefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\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({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(sourceIcon(t.source ?? ToolSource.Manifest)) ??\n\t\t\t\t\tundefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t\tconfigTools,\n\t\t\trestApiTools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SideModal\n\t\t\t\theader={title}\n\t\t\t\tcloseOnEscapeKey={false}\n\t\t\t\tzIndex={SUBAGENT_ZINDEX}\n\t\t\t\theaderCustomComponent={\n\t\t\t\t\t<DrawerHeaderText\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\tsubtitle=\"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them.\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\twidth=\"421px\"\n\t\t\t\theaderStyle={DRAWER_HEADER_STYLE}\n\t\t\t\tbodyStyle={DRAWER_BODY_STYLE}\n\t\t\t\tonClose={onClose}\n\t\t\t\tsaveButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-save',\n\t\t\t\t\tbuttonText: 'Save',\n\t\t\t\t\tbuttonType: 'primary',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tdisabled: !canSave,\n\t\t\t\t\tisLoading: saving,\n\t\t\t\t\tonClick: handleSave,\n\t\t\t\t}}\n\t\t\t\tcancelButtonProps={{\n\t\t\t\t\t'data-test': 'subagent-cancel',\n\t\t\t\t\tbuttonText: 'Cancel',\n\t\t\t\t\tbuttonType: 'tertiaryGray',\n\t\t\t\t\tsize: 'small',\n\t\t\t\t\tonClick: onClose,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<Input\n\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\tlabelTextBold\n\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\tvalue={name}\n\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\tstate={isDuplicateName ? 'invalid' : undefined}\n\t\t\t\t\terrorMessage={\n\t\t\t\t\t\tisDuplicateName\n\t\t\t\t\t\t\t? 'A sub-agent with this name already exists'\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t\tonChangeText={setName}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\tvalue={instructions}\n\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\tmaxLength={charLimits.instructions}\n\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\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-instructions\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('instructions')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'instructions'\n\t\t\t\t\t\t\t\t\t? 'Improving…'\n\t\t\t\t\t\t\t\t\t: 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<MentionEditor\n\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\tmaxLength={charLimits.guardrail}\n\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\tminHeight=\"160px\"\n\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\ttools={availableTools}\n\t\t\t\t\ttoolActions={toolActionSources}\n\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\taction={\n\t\t\t\t\t\tonImprove ? (\n\t\t\t\t\t\t\t<ImproveButton\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tdata-test=\"subagent-improve-guardrail\"\n\t\t\t\t\t\t\t\tdisabled={improving !== null}\n\t\t\t\t\t\t\t\tonClick={() => handleImprove('guardrail')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{improving === 'guardrail' ? 'Improving…' : 'Improve with AI'}\n\t\t\t\t\t\t\t</ImproveButton>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<SelectableListSection\n\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\titems={allToolItems}\n\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\tactionSources={toolActionSources}\n\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\tpickerOpensUp\n\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t}}\n\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\tconfirmDelete={{ noun: 'tool', zIndex: TOOL_DRAWER_ZINDEX + 1 }}\n\t\t\t\t/>\n\t\t\t</SideModal>\n\n\t\t\t{toolDrawer?.kind === 'restapi' && (\n\t\t\t\t<RestApiToolPanel\n\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\tinitial={toolDrawer.initialRest}\n\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\tonSave={handleSaveRestApi}\n\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{toolDrawer?.kind === 'config' &&\n\t\t\t\ttoolDrawer.toolKey &&\n\t\t\t\topenConfigTemplate && (\n\t\t\t\t\t<ConfigToolPanel\n\t\t\t\t\t\tkey={toolDrawer.key}\n\t\t\t\t\t\ttoolKey={toolDrawer.toolKey}\n\t\t\t\t\t\ttemplate={openConfigTemplate}\n\t\t\t\t\t\tinitial={toolDrawer.initialConfig}\n\t\t\t\t\t\tcharLimits={charLimits}\n\t\t\t\t\t\tonImprove={onImproveToolInstructions}\n\t\t\t\t\t\tonClose={() => setToolDrawer(null)}\n\t\t\t\t\t\tonSave={handleSaveConfigTool}\n\t\t\t\t\t\tzIndex={TOOL_DRAWER_ZINDEX}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["SUBAGENT_ZINDEX","TOOL_DRAWER_ZINDEX","upsertById","list","item","arr","x","ImproveButton","styled","COLORS","CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","onImproveToolInstructions","configToolTemplates","title","initial","existingNames","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","configTools","setConfigTools","restApiTools","setRestApiTools","toolDrawer","setToolDrawer","toolDrawerKeyRef","useRef","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","buildCustomToolMentionItems","insertersRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","customToolIdsRef","t","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","label","source","openRestApi","tool","openConfigTool","toolKey","openToolAction","CONFIG_TOOL_SOURCES","handleSaveRestApi","isNew","restApiMentionItem","ToolSource","handleSaveConfigTool","configToolMentionItem","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","token","strip","text","k","undoRemove","snap","nameTrimmed","isDuplicateName","n","canSave","toolItems","sourceIcon","restApiItems","restApiToolName","SOURCE_ICONS","configToolItems","configToolName","allToolItems","toolActionSources","buildToolActions","openConfigTemplate","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","handleImprove","improved","jsxs","Fragment","SideModal","jsx","DrawerHeaderText","DRAWER_HEADER_STYLE","DRAWER_BODY_STYLE","Input","MentionEditor","SelectableListSection","RestApiToolPanel","ConfigToolPanel","Toaster"],"mappings":"8yBAqDMA,GAAkB,IAClBC,EAAqB,KAGrBC,GAAa,CAClBC,EACAC,IACS,CACT,MAAMC,EAAMF,GAAQ,CAAA,EACpB,OAAOE,EAAI,KAAMC,GAAMA,EAAE,KAAOF,EAAK,EAAE,EACpCC,EAAI,IAAKC,GAAOA,EAAE,KAAOF,EAAK,GAAKA,EAAOE,CAAE,EAC5C,CAAC,GAAGD,EAAKD,CAAI,CACjB,EAYMG,GAAgBC,GAAAA,QAAO;AAAA;AAAA,qBAERC,EAAAA,OAAO,OAAO,OAAO;AAAA,UAChCA,EAAAA,OAAO,QAAQ,OAAO;AAAA,eACjBA,EAAAA,OAAO,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6DzBC,GAA0D,CAAC,CACvE,QAAAC,EACA,OAAAC,EACA,eAAAC,EACA,UAAAC,EACA,0BAAAC,EACA,oBAAAC,EACA,MAAAC,EAAQ,mBACR,QAAAC,EACA,cAAAC,GAAgB,CAAA,EAChB,SAAAC,EAAW,WAAA,WACXC,EAAaC,GAAAA,iBACd,IA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AAE,CAAA,CAC/D,CAAA,CAAA,EAGAmC,GAAY,OAAS,WACrBsF,EAAAA,IAACO,GAAAA,iBAAA,CAEA,QAAS7F,EAAW,YAAA,WACpBf,EACA,UAAWN,EACX,QAAS,IAAMsB,EAAc,IAAI,EACjC,OAAQuC,GACR,OAAQ3E,CAAA,EANHmC,EAAW,GAAA,EAUjBA,GAAY,OAAS,UACrBA,EAAW,SACXuE,IACCe,EAAAA,IAACQ,GAAAA,gBAAA,CAEA,QAAS9F,EAAW,QACpB,SAAUuE,GACV,QAASvE,EAAW,cAAA,WACpBf,EACA,UAAWN,EACX,QAAS,IAAMsB,EAAc,IAAI,EACjC,OAAQ2C,GACR,OAAQ/E,CAAA,EARHmC,EAAW,GAAA,EAYlB8C,GACAwC,EAAAA,IAACS,GAAAA,QAAA,CAEA,KAAMjD,EAAK,QACX,KAAK,OACL,SAAS,YACT,UAAW,IACX,gBAAe,GACf,YAAa,CACZ,WAAY,OACZ,WAAY,GACZ,cAAe,KACdS,GAAA,EACO,CAAA,EACR,EAED,aAAc,IAAMR,EAAQ,IAAI,CAAA,EAd3BD,EAAK,EAAA,CAeX,EAEF,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../TypographyStyle.js"),r=require("../../../constants/Theme.js"),a=require("../AgentBuilder.styled.js"),u=require("../../modals/styledModal.js"),s=require("../../button/Button.js"),y=({open:d,onClose:i,onDiscard:n,onSaveDraft:l,isSaving:o,disableSaveDraft:c})=>d?e.jsx(u.StyledModal,{"data-test":"agent-discard-modal",open:!0,onClose:i,width:"530px",children:e.jsxs(a.ModalBody,{style:{alignItems:"flex-start",textAlign:"left"},children:[e.jsx(t.TitleMedium,{color:r.COLORS.content.primary,children:"You have unsaved changes"}),e.jsx(t.BodyPrimary,{color:r.COLORS.content.secondary,style:{lineHeight:"24px"},children:"Your progress will be lost if you leave. You can save as draft and come back to this later."}),e.jsxs(a.ModalActions,{children:[e.jsx("div",{style:{display:"flex"},children:e.jsx(s.Button,{"data-test":"agent-discard-leave",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Discard",onClick:n})}),e.jsx("div",{style:{display:"flex"},children:e.jsx(s.Button,{"data-test":"agent-discard-save-draft",buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Save as draft",disabled:c,isLoading:o,onClick:l})})]})]})}):null;exports.DiscardModal=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../TypographyStyle.js"),a=require("../../../constants/Theme.js"),i=require("../AgentBuilder.styled.js"),u=require("../../modals/styledModal.js"),r=require("../../button/Button.js"),y=({open:s,onClose:d,onDiscard:n,onSaveDraft:l,isSaving:o,disableSaveDraft:c})=>s?e.jsx(u.StyledModal,{"data-test":"agent-discard-modal",open:!0,onClose:d,width:"530px",children:e.jsxs(i.ModalBody,{style:{alignItems:"flex-start",textAlign:"left",gap:"32px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(t.TitleMedium,{color:a.COLORS.content.primary,children:"You have unsaved changes"}),e.jsx(t.BodyPrimary,{color:a.COLORS.content.secondary,style:{lineHeight:"24px"},children:"Leaving now will discard your recent changes. You can save them and come back to this later."})]}),e.jsxs(i.ModalActions,{children:[e.jsx("div",{style:{display:"flex"},children:e.jsx(r.Button,{"data-test":"agent-discard-leave",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Discard",onClick:n})}),e.jsx("div",{style:{display:"flex"},children:e.jsx(r.Button,{"data-test":"agent-discard-save-draft",buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Save as draft",disabled:c,isLoading:o,onClick:l})})]})]})}):null;exports.DiscardModal=y;
2
2
  //# sourceMappingURL=DiscardModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiscardModal.js","sources":["../../../../../src/components/agent-builder/components/DiscardModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodyPrimary, TitleMedium } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { ModalActions, ModalBody } from '../AgentBuilder.styled';\n\ninterface DiscardModalProps {\n\topen: boolean;\n\t/** Dismiss the dialog and stay on the builder (X / outside click). */\n\tonClose: () => void;\n\t/** Leave without saving. */\n\tonDiscard: () => void;\n\t/** Save the draft, then leave. */\n\tonSaveDraft: () => void;\n\tisSaving?: boolean;\n\t/** Block \"Save as draft\" (e.g. the agent has no name yet). */\n\tdisableSaveDraft?: boolean;\n}\n\n/**\n * \"You have unsaved changes\" confirmation shown when the user tries to leave the\n * builder (Back). Actions live inside the body (see GoLiveModal for why we avoid\n * StyledModal's footer). Content is left-aligned per design.\n */\nexport const DiscardModal: React.FC<DiscardModalProps> = ({\n\topen,\n\tonClose,\n\tonDiscard,\n\tonSaveDraft,\n\tisSaving,\n\tdisableSaveDraft,\n}) => {\n\tif (!open) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-discard-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth=\"530px\"\n\t\t>\n\t\t\t<ModalBody style={{ alignItems: 'flex-start', textAlign: 'left' }}>\n\t\t\t\t<TitleMedium color={COLORS.content.primary}>\n\t\t\t\t\tYou have unsaved changes\n\t\t\t\t</TitleMedium>\n\t\t\t\t<BodyPrimary\n\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\tstyle={{ lineHeight: '24px' }}\n\t\t\t\t>\n\t\t\t\t\tYour progress will be lost if you leave. You can save as draft and\n\t\t\t\t\tcome back to this later.\n\t\t\t\t</BodyPrimary>\n\n\t\t\t\t<ModalActions>\n\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test=\"agent-discard-leave\"\n\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\tbuttonText=\"Discard\"\n\t\t\t\t\t\t\tonClick={onDiscard}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test=\"agent-discard-save-draft\"\n\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\tbuttonText=\"Save as draft\"\n\t\t\t\t\t\t\tdisabled={disableSaveDraft}\n\t\t\t\t\t\t\tisLoading={isSaving}\n\t\t\t\t\t\t\tonClick={onSaveDraft}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</ModalActions>\n\t\t\t</ModalBody>\n\t\t</StyledModal>\n\t);\n};\n"],"names":["DiscardModal","open","onClose","onDiscard","onSaveDraft","isSaving","disableSaveDraft","jsx","StyledModal","jsxs","ModalBody","TitleMedium","COLORS","BodyPrimary","ModalActions","Button"],"mappings":"wTAyBaA,EAA4C,CAAC,CACzD,KAAAC,EACA,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,SAAAC,EACA,iBAAAC,CACD,IACML,EAKJM,EAAAA,IAACC,EAAAA,YAAA,CACA,YAAU,sBACV,KAAI,GACJ,QAAAN,EACA,MAAM,QAEN,SAAAO,EAAAA,KAACC,aAAU,MAAO,CAAE,WAAY,aAAc,UAAW,QACxD,SAAA,CAAAH,MAACI,EAAAA,YAAA,CAAY,MAAOC,EAAAA,OAAO,QAAQ,QAAS,SAAA,2BAE5C,EACAL,EAAAA,IAACM,EAAAA,YAAA,CACA,MAAOD,EAAAA,OAAO,QAAQ,UACtB,MAAO,CAAE,WAAY,MAAA,EACrB,SAAA,6FAAA,CAAA,SAKAE,EAAAA,aAAA,CACA,SAAA,CAAAP,EAAAA,IAAC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAA,EAAAA,IAACQ,EAAAA,OAAA,CACA,YAAU,sBACV,WAAW,YACX,KAAK,SACL,iBAAgB,GAChB,WAAW,UACX,QAASZ,CAAA,CAAA,EAEX,QACC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAI,EAAAA,IAACQ,EAAAA,OAAA,CACA,YAAU,2BACV,WAAW,UACX,KAAK,SACL,iBAAgB,GAChB,WAAW,gBACX,SAAUT,EACV,UAAWD,EACX,QAASD,CAAA,CAAA,CACV,CACD,CAAA,CAAA,CACD,CAAA,CAAA,CACD,CAAA,CAAA,EA9CM"}
1
+ {"version":3,"file":"DiscardModal.js","sources":["../../../../../src/components/agent-builder/components/DiscardModal.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodyPrimary, TitleMedium } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { ModalActions, ModalBody } from '../AgentBuilder.styled';\n\ninterface DiscardModalProps {\n\topen: boolean;\n\t/** Dismiss the dialog and stay on the builder (X / outside click). */\n\tonClose: () => void;\n\t/** Leave without saving. */\n\tonDiscard: () => void;\n\t/** Save the draft, then leave. */\n\tonSaveDraft: () => void;\n\tisSaving?: boolean;\n\t/** Block \"Save as draft\" (e.g. the agent has no name yet). */\n\tdisableSaveDraft?: boolean;\n}\n\n/**\n * \"You have unsaved changes\" confirmation shown when the user tries to leave the\n * builder (Back). Actions live inside the body (see GoLiveModal for why we avoid\n * StyledModal's footer). Content is left-aligned per design.\n */\nexport const DiscardModal: React.FC<DiscardModalProps> = ({\n\topen,\n\tonClose,\n\tonDiscard,\n\tonSaveDraft,\n\tisSaving,\n\tdisableSaveDraft,\n}) => {\n\tif (!open) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-discard-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth=\"530px\"\n\t\t>\n\t\t\t<ModalBody\n\t\t\t\tstyle={{ alignItems: 'flex-start', textAlign: 'left', gap: '32px' }}\n\t\t\t>\n\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>\n\t\t\t\t\t<TitleMedium color={COLORS.content.primary}>\n\t\t\t\t\t\tYou have unsaved changes\n\t\t\t\t\t</TitleMedium>\n\t\t\t\t\t<BodyPrimary\n\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\tstyle={{ lineHeight: '24px' }}\n\t\t\t\t\t>\n\t\t\t\t\t\tLeaving now will discard your recent changes. You can save them and\n\t\t\t\t\t\tcome back to this later.\n\t\t\t\t\t</BodyPrimary>\n\t\t\t\t</div>\n\n\t\t\t\t<ModalActions>\n\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test=\"agent-discard-leave\"\n\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\tbuttonText=\"Discard\"\n\t\t\t\t\t\t\tonClick={onDiscard}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test=\"agent-discard-save-draft\"\n\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\tbuttonText=\"Save as draft\"\n\t\t\t\t\t\t\tdisabled={disableSaveDraft}\n\t\t\t\t\t\t\tisLoading={isSaving}\n\t\t\t\t\t\t\tonClick={onSaveDraft}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</ModalActions>\n\t\t\t</ModalBody>\n\t\t</StyledModal>\n\t);\n};\n"],"names":["DiscardModal","open","onClose","onDiscard","onSaveDraft","isSaving","disableSaveDraft","jsx","StyledModal","jsxs","ModalBody","TitleMedium","COLORS","BodyPrimary","ModalActions","Button"],"mappings":"wTAyBaA,EAA4C,CAAC,CACzD,KAAAC,EACA,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,SAAAC,EACA,iBAAAC,CACD,IACML,EAKJM,EAAAA,IAACC,EAAAA,YAAA,CACA,YAAU,sBACV,KAAI,GACJ,QAAAN,EACA,MAAM,QAEN,SAAAO,EAAAA,KAACC,EAAAA,UAAA,CACA,MAAO,CAAE,WAAY,aAAc,UAAW,OAAQ,IAAK,MAAA,EAE3D,SAAA,CAAAD,EAAAA,KAAC,MAAA,CAAI,MAAO,CAAE,QAAS,OAAQ,cAAe,SAAU,IAAK,KAAA,EAC5D,SAAA,CAAAF,MAACI,EAAAA,YAAA,CAAY,MAAOC,EAAAA,OAAO,QAAQ,QAAS,SAAA,2BAE5C,EACAL,EAAAA,IAACM,EAAAA,YAAA,CACA,MAAOD,EAAAA,OAAO,QAAQ,UACtB,MAAO,CAAE,WAAY,MAAA,EACrB,SAAA,8FAAA,CAAA,CAGD,EACD,SAECE,EAAAA,aAAA,CACA,SAAA,CAAAP,EAAAA,IAAC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAA,EAAAA,IAACQ,EAAAA,OAAA,CACA,YAAU,sBACV,WAAW,YACX,KAAK,SACL,iBAAgB,GAChB,WAAW,UACX,QAASZ,CAAA,CAAA,EAEX,QACC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAI,EAAAA,IAACQ,EAAAA,OAAA,CACA,YAAU,2BACV,WAAW,UACX,KAAK,SACL,iBAAgB,GAChB,WAAW,gBACX,SAAUT,EACV,UAAWD,EACX,QAASD,CAAA,CAAA,CACV,CACD,CAAA,CAAA,CACD,CAAA,CAAA,CAAA,CACD,CAAA,EAlDM"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("../../../assets/icons/ManifestGlass.svg.js"),y=require("../../../assets/icons/successIcon.svg.js"),a=require("../../TypographyStyle.js"),s=require("../../../constants/Theme.js"),n=require("../AgentBuilder.styled.js"),g=require("../../modals/styledModal.js"),o=require("../../button/Button.js"),m=require("../../../icons/Arrows/Normal arrows/ArrowRight.js"),x=({mode:i,onClose:r,onConfirm:d,onSaveDraft:c,onGoToDashboard:l,isPublishing:u})=>{if(!i)return null;const t=i==="success";return e.jsx(g.StyledModal,{"data-test":"agent-go-live-modal",open:!0,onClose:r,width:t?"400px":"520px",children:e.jsxs(n.ModalBody,{children:[e.jsx(n.ModalIcon,{children:t?e.jsx(y.default,{width:64,height:64}):e.jsx(h.default,{width:64,height:64})}),e.jsx(a.TitleMedium,{color:s.COLORS.content.primary,children:t?"Your agent is live!":"Ready to go live?"}),e.jsx(a.BodyPrimary,{color:s.COLORS.content.secondary,children:t?"You can manage your agents from the AI agent dashboard.":"This agent will start handling customer conversations immediately. You can pause it at any time."}),e.jsx(n.ModalActions,{children:t?e.jsx("div",{style:{display:"flex"},children:e.jsx(o.Button,{"data-test":"agent-go-dashboard",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Go to Agent dashboard",TrailingIcon:m.default,onClick:l??r})}):e.jsxs(e.Fragment,{children:[e.jsx(n.DraftButtonScope,{children:e.jsx(o.Button,{"data-test":"agent-confirm-save-draft",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Save as draft",onClick:c})}),e.jsx("div",{style:{display:"flex"},children:e.jsx(o.Button,{"data-test":"agent-confirm-go-live",buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Go live now",isLoading:u,onClick:d})})]})})]})})};exports.GoLiveModal=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("../../../assets/icons/ManifestGlass.svg.js"),x=require("../../../assets/icons/successIcon.svg.js"),a=require("../../TypographyStyle.js"),r=require("../../../constants/Theme.js"),i=require("../AgentBuilder.styled.js"),y=require("../../modals/styledModal.js"),n=require("../../button/Button.js"),g=require("../../../icons/Arrows/Normal arrows/ArrowRight.js"),m=({mode:o,onClose:s,onConfirm:d,onSaveDraft:l,onGoToDashboard:c,isPublishing:u})=>{if(!o)return null;const t=o==="success";return e.jsx(y.StyledModal,{"data-test":"agent-go-live-modal",open:!0,onClose:s,width:t?"400px":"520px",children:e.jsxs(i.ModalBody,{style:{gap:"24px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(i.ModalIcon,{children:t?e.jsx(x.default,{width:64,height:64}):e.jsx(h.default,{width:64,height:64})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(a.TitleMedium,{color:r.COLORS.content.primary,children:t?"Your agent is live!":"Ready to go live?"}),e.jsx(a.BodyPrimary,{color:r.COLORS.content.secondary,children:t?"You can manage your agents from the AI agent dashboard.":"This agent will start handling customer conversations immediately. You can pause it at any time."})]})]}),e.jsx(i.ModalActions,{children:t?e.jsx("div",{style:{display:"flex"},children:e.jsx(n.Button,{"data-test":"agent-go-dashboard",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Go to Agent dashboard",TrailingIcon:g.default,onClick:c??s})}):e.jsxs(e.Fragment,{children:[e.jsx(i.DraftButtonScope,{children:e.jsx(n.Button,{"data-test":"agent-confirm-save-draft",buttonType:"secondary",size:"medium",matchParentWidth:!0,buttonText:"Save as draft",onClick:l})}),e.jsx("div",{style:{display:"flex"},children:e.jsx(n.Button,{"data-test":"agent-confirm-go-live",buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Go live now",isLoading:u,onClick:d})})]})})]})})};exports.GoLiveModal=m;
2
2
  //# sourceMappingURL=GoLiveModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoLiveModal.js","sources":["../../../../../src/components/agent-builder/components/GoLiveModal.tsx"],"sourcesContent":["import ManifestGlass from '@src/assets/icons/ManifestGlass.svg';\nimport SuccessIcon from '@src/assets/icons/successIcon.svg';\nimport { ArrowRight } from '@src/icons';\nimport React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodyPrimary, TitleMedium } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tDraftButtonScope,\n\tModalActions,\n\tModalBody,\n\tModalIcon,\n} from '../AgentBuilder.styled';\n\nexport type GoLiveModalMode = 'confirm' | 'success' | null;\n\ninterface GoLiveModalProps {\n\tmode: GoLiveModalMode;\n\tonClose: () => void;\n\tonConfirm: () => void;\n\tonSaveDraft: () => void;\n\tonGoToDashboard?: () => void;\n\tisPublishing?: boolean;\n}\n\n/**\n * Confirm / success dialog for going live. Uses `StyledModal` as the shell but\n * renders the actions INSIDE the body (not StyledModal's footer) — the footer's\n * `margin-top:auto` detaches from this short, centered hero layout and spills\n * out of the card. Body-level actions stay anchored under the content.\n */\nexport const GoLiveModal: React.FC<GoLiveModalProps> = ({\n\tmode,\n\tonClose,\n\tonConfirm,\n\tonSaveDraft,\n\tonGoToDashboard,\n\tisPublishing,\n}) => {\n\tif (!mode) {\n\t\treturn null;\n\t}\n\n\tconst isSuccess = mode === 'success';\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-go-live-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth={isSuccess ? '400px' : '520px'}\n\t\t>\n\t\t\t<ModalBody>\n\t\t\t\t<ModalIcon>\n\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t<SuccessIcon width={64} height={64} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<ManifestGlass width={64} height={64} />\n\t\t\t\t\t)}\n\t\t\t\t</ModalIcon>\n\n\t\t\t\t<TitleMedium color={COLORS.content.primary}>\n\t\t\t\t\t{isSuccess ? 'Your agent is live!' : 'Ready to go live?'}\n\t\t\t\t</TitleMedium>\n\t\t\t\t<BodyPrimary color={COLORS.content.secondary}>\n\t\t\t\t\t{isSuccess\n\t\t\t\t\t\t? 'You can manage your agents from the AI agent dashboard.'\n\t\t\t\t\t\t: 'This agent will start handling customer conversations immediately. You can pause it at any time.'}\n\t\t\t\t</BodyPrimary>\n\n\t\t\t\t<ModalActions>\n\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tdata-test=\"agent-go-dashboard\"\n\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\tbuttonText=\"Go to Agent dashboard\"\n\t\t\t\t\t\t\t\tTrailingIcon={ArrowRight}\n\t\t\t\t\t\t\t\tonClick={onGoToDashboard ?? onClose}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DraftButtonScope>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-save-draft\"\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tbuttonText=\"Save as draft\"\n\t\t\t\t\t\t\t\t\tonClick={onSaveDraft}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</DraftButtonScope>\n\t\t\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-go-live\"\n\t\t\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tbuttonText=\"Go live now\"\n\t\t\t\t\t\t\t\t\tisLoading={isPublishing}\n\t\t\t\t\t\t\t\t\tonClick={onConfirm}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</ModalActions>\n\t\t\t</ModalBody>\n\t\t</StyledModal>\n\t);\n};\n"],"names":["GoLiveModal","mode","onClose","onConfirm","onSaveDraft","onGoToDashboard","isPublishing","isSuccess","jsx","StyledModal","ModalBody","ModalIcon","SuccessIcon","ManifestGlass","TitleMedium","COLORS","BodyPrimary","ModalActions","Button","ArrowRight","jsxs","Fragment","DraftButtonScope"],"mappings":"qeAgCaA,EAA0C,CAAC,CACvD,KAAAC,EACA,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,aAAAC,CACD,IAAM,CACL,GAAI,CAACL,EACJ,OAAO,KAGR,MAAMM,EAAYN,IAAS,UAE3B,OACCO,EAAAA,IAACC,EAAAA,YAAA,CACA,YAAU,sBACV,KAAI,GACJ,QAAAP,EACA,MAAOK,EAAY,QAAU,QAE7B,gBAACG,YAAA,CACA,SAAA,CAAAF,MAACG,EAAAA,UAAA,CACC,SAAAJ,EACAC,EAAAA,IAACI,EAAAA,QAAA,CAAY,MAAO,GAAI,OAAQ,GAAI,QAEnCC,EAAAA,QAAA,CAAc,MAAO,GAAI,OAAQ,GAAI,EAExC,EAEAL,EAAAA,IAACM,EAAAA,aAAY,MAAOC,SAAO,QAAQ,QACjC,SAAAR,EAAY,sBAAwB,mBAAA,CACtC,EACAC,EAAAA,IAACQ,EAAAA,aAAY,MAAOD,SAAO,QAAQ,UACjC,SAAAR,EACE,0DACA,kGAAA,CACJ,EAEAC,EAAAA,IAACS,EAAAA,cACC,SAAAV,EACAC,EAAAA,IAAC,OAAI,MAAO,CAAE,QAAS,MAAA,EACtB,SAAAA,EAAAA,IAACU,EAAAA,OAAA,CACA,YAAU,qBACV,WAAW,YACX,KAAK,SACL,iBAAgB,GAChB,WAAW,wBACX,aAAcC,EAAAA,QACd,QAASd,GAAmBH,CAAA,CAAA,CAC7B,CACD,EAEAkB,EAAAA,KAAAC,EAAAA,SAAA,CACC,SAAA,CAAAb,MAACc,EAAAA,iBAAA,CACA,SAAAd,EAAAA,IAACU,EAAAA,OAAA,CACA,YAAU,2BACV,WAAW,YACX,KAAK,SACL,iBAAgB,GAChB,WAAW,gBACX,QAASd,CAAA,CAAA,EAEX,QACC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAI,EAAAA,IAACU,EAAAA,OAAA,CACA,YAAU,wBACV,WAAW,UACX,KAAK,SACL,iBAAgB,GAChB,WAAW,cACX,UAAWZ,EACX,QAASH,CAAA,CAAA,CACV,CACD,CAAA,CAAA,CACD,CAAA,CAEF,CAAA,CAAA,CACD,CAAA,CAAA,CAGH"}
1
+ {"version":3,"file":"GoLiveModal.js","sources":["../../../../../src/components/agent-builder/components/GoLiveModal.tsx"],"sourcesContent":["import ManifestGlass from '@src/assets/icons/ManifestGlass.svg';\nimport SuccessIcon from '@src/assets/icons/successIcon.svg';\nimport { ArrowRight } from '@src/icons';\nimport React from 'react';\nimport { Button } from '@src/components/button';\nimport { StyledModal } from '@src/components/modals';\nimport { BodyPrimary, TitleMedium } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tDraftButtonScope,\n\tModalActions,\n\tModalBody,\n\tModalIcon,\n} from '../AgentBuilder.styled';\n\nexport type GoLiveModalMode = 'confirm' | 'success' | null;\n\ninterface GoLiveModalProps {\n\tmode: GoLiveModalMode;\n\tonClose: () => void;\n\tonConfirm: () => void;\n\tonSaveDraft: () => void;\n\tonGoToDashboard?: () => void;\n\tisPublishing?: boolean;\n}\n\n/**\n * Confirm / success dialog for going live. Uses `StyledModal` as the shell but\n * renders the actions INSIDE the body (not StyledModal's footer) — the footer's\n * `margin-top:auto` detaches from this short, centered hero layout and spills\n * out of the card. Body-level actions stay anchored under the content.\n */\nexport const GoLiveModal: React.FC<GoLiveModalProps> = ({\n\tmode,\n\tonClose,\n\tonConfirm,\n\tonSaveDraft,\n\tonGoToDashboard,\n\tisPublishing,\n}) => {\n\tif (!mode) {\n\t\treturn null;\n\t}\n\n\tconst isSuccess = mode === 'success';\n\n\treturn (\n\t\t<StyledModal\n\t\t\tdata-test=\"agent-go-live-modal\"\n\t\t\topen\n\t\t\tonClose={onClose}\n\t\t\twidth={isSuccess ? '400px' : '520px'}\n\t\t>\n\t\t\t<ModalBody style={{ gap: '24px' }}>\n\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>\n\t\t\t\t\t<ModalIcon>\n\t\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t\t<SuccessIcon width={64} height={64} />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ManifestGlass width={64} height={64} />\n\t\t\t\t\t\t)}\n\t\t\t\t\t</ModalIcon>\n\n\t\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>\n\t\t\t\t\t\t<TitleMedium color={COLORS.content.primary}>\n\t\t\t\t\t\t\t{isSuccess ? 'Your agent is live!' : 'Ready to go live?'}\n\t\t\t\t\t\t</TitleMedium>\n\t\t\t\t\t\t<BodyPrimary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\t{isSuccess\n\t\t\t\t\t\t\t\t? 'You can manage your agents from the AI agent dashboard.'\n\t\t\t\t\t\t\t\t: 'This agent will start handling customer conversations immediately. You can pause it at any time.'}\n\t\t\t\t\t\t</BodyPrimary>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\n\t\t\t\t<ModalActions>\n\t\t\t\t\t{isSuccess ? (\n\t\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tdata-test=\"agent-go-dashboard\"\n\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\tbuttonText=\"Go to Agent dashboard\"\n\t\t\t\t\t\t\t\tTrailingIcon={ArrowRight}\n\t\t\t\t\t\t\t\tonClick={onGoToDashboard ?? onClose}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DraftButtonScope>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-save-draft\"\n\t\t\t\t\t\t\t\t\tbuttonType=\"secondary\"\n\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tbuttonText=\"Save as draft\"\n\t\t\t\t\t\t\t\t\tonClick={onSaveDraft}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</DraftButtonScope>\n\t\t\t\t\t\t\t<div style={{ display: 'flex' }}>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tdata-test=\"agent-confirm-go-live\"\n\t\t\t\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\tmatchParentWidth\n\t\t\t\t\t\t\t\t\tbuttonText=\"Go live now\"\n\t\t\t\t\t\t\t\t\tisLoading={isPublishing}\n\t\t\t\t\t\t\t\t\tonClick={onConfirm}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</ModalActions>\n\t\t\t</ModalBody>\n\t\t</StyledModal>\n\t);\n};\n"],"names":["GoLiveModal","mode","onClose","onConfirm","onSaveDraft","onGoToDashboard","isPublishing","isSuccess","jsx","StyledModal","ModalBody","jsxs","ModalIcon","SuccessIcon","ManifestGlass","TitleMedium","COLORS","BodyPrimary","ModalActions","Button","ArrowRight","Fragment","DraftBut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ACA,SAAAd,EAAAA,IAACW,EAAAA,OAAA,CACA,YAAU,2BACV,WAAW,YACX,KAAK,SACL,iBAAgB,GAChB,WAAW,gBACX,QAASf,CAAA,CAAA,EAEX,QACC,MAAA,CAAI,MAAO,CAAE,QAAS,QACtB,SAAAI,EAAAA,IAACW,EAAAA,OAAA,CACA,YAAU,wBACV,WAAW,UACX,KAAK,SACL,iBAAgB,GAChB,WAAW,cACX,UAAWb,EACX,QAASH,CAAA,CAAA,CACV,CACD,CAAA,CAAA,CACD,CAAA,CAEF,CAAA,CAAA,CACD,CAAA,CAAA,CAGH"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),x=require("../../TypographyStyle.js"),T=require("../../../constants/Theme.js"),u=require("../AgentBuilder.styled.js"),_=require("../constants/editorStyle.js"),d=require("../utils/mentionSerialization.js"),w=require("./MentionPicker.js"),F=require("../../../editor/BikEditor.js"),N=({label:m,value:c,onChange:p,maxLength:a,placeholder:y,minHeight:E="200px",resetKey:l,mentionItems:r,tools:b,onMentionSelect:j,onFocus:q,registerInsert:o,onCreateSubAgent:C,toolActions:k,integrationStatus:O,onConnectIntegration:R,action:M,...B})=>{const s=i.useRef(null),[H,S]=i.useState(c.length),h=i.useCallback((t,e,A)=>{const f=s.current;if(!f)return;const D=r.find(g=>String(g.id)===String(e)&&g.meta?.kind===t),P=A??D?.label??e;f.insertInlineContent(`${d.buildMentionHtml(String(e),P,t)}&nbsp;`)},[r]);i.useEffect(()=>{if(o)return o(h),()=>o(null)},[o,h]);const L=i.useMemo(()=>d.instructionsToEditorHtml(c,r),[l]);return i.useEffect(()=>S(c.length),[l]),n.jsxs(u.FieldBlock,{children:[n.jsxs(u.FieldLabelRow,{children:[n.jsx(x.TitleSmall,{color:T.COLORS.content.primary,children:m}),n.jsxs(x.BodyCaption,{color:T.COLORS.content.secondary,children:[H,"/",a]})]}),n.jsxs(u.AiTextAreaShell,{minHeight:E,"data-test":B["data-test"],children:[n.jsx(F.BikEditor,{ref:s,initialContent:L,placeholder:y,characterLimit:a,minHeight:"120px",maxHeight:"320px",style:{border:"none"},editorStyle:_.AGENT_EDITOR_STYLE,onFocus:q,mentions:{agents:r,removeTriggerOnDismiss:!0,renderDropdown:t=>n.jsx(w.MentionPicker,{...t,onCreateSubAgent:C,toolActions:k,integrationStatus:O,onConnectIntegration:R}),onSelect:t=>{const e=t.meta?.kind;e&&j?.(e,String(t.id))}},onChange:t=>{S(t.characterCount);const e=s.current?.getJSON()??null;p(d.editorDocToInstructions(e,b))}},l),M]})]})};exports.MentionEditor=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),q=require("../../TypographyStyle.js"),x=require("../../../constants/Theme.js"),h=require("../AgentBuilder.styled.js"),G=require("../constants/editorStyle.js"),S=require("../utils/mentionSerialization.js"),y=require("../utils/sourceIcons.js"),I=require("./MentionPicker.js"),J=require("../../../editor/BikEditor.js"),Y=a=>a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r?\n/g,"<br>"),$=({label:a,value:o,onChange:E,maxLength:c,placeholder:R,minHeight:j="200px",resetKey:d,mentionItems:s,tools:k,onMentionSelect:O,onFocus:H,registerInsert:l,onCreateSubAgent:M,toolActions:B,integrationStatus:L,onConnectIntegration:P,action:A,...D})=>{const u=n.useRef(null),[_,p]=n.useState(o.length),g=n.useRef(o.length),w=n.useCallback(({text:e})=>{if(!e)return!1;const t=u.current,f=t?.getSelectedText().length??0,i=c-(g.current-f);return e.length<=i?!1:(i<=0||t?.insertContent(Y(e.slice(0,i))),!0)},[c]),T=n.useCallback((e,t,f,i)=>{const m=u.current;if(!m)return;const C=s.find(b=>String(b.id)===String(t)&&b.meta?.kind===e),N=f??C?.label??t,z=i??C?.meta?.source;m.insertInlineContent(`${S.buildMentionHtml(String(t),N,e,z)}&nbsp;`)},[s]);n.useEffect(()=>{if(l)return l(T),()=>l(null)},[l,T]);const F=n.useMemo(()=>S.instructionsToEditorHtml(o,s),[d]);return n.useEffect(()=>{p(o.length),g.current=o.length},[d]),r.jsxs(h.FieldBlock,{children:[r.jsxs(h.FieldLabelRow,{children:[r.jsx(q.TitleSmall,{color:x.COLORS.content.primary,children:a}),r.jsxs(q.BodyCaption,{color:x.COLORS.content.secondary,children:[_,"/",c]})]}),r.jsxs(h.AiTextAreaShell,{minHeight:j,"data-test":D["data-test"],children:[r.jsx(J.BikEditor,{ref:u,initialContent:F,placeholder:R,characterLimit:c,characterLimitHard:!0,onPaste:w,minHeight:"120px",maxHeight:"320px",style:{border:"none"},editorStyle:G.AGENT_EDITOR_STYLE,onFocus:H,mentions:{agents:s,removeTriggerOnDismiss:!0,renderChipIcon:e=>y.renderSourceIcon(y.sourceIcon(e??void 0),-6),renderDropdown:e=>r.jsx(I.MentionPicker,{...e,onCreateSubAgent:M,toolActions:B,integrationStatus:L,onConnectIntegration:P}),onSelect:e=>{const t=e.meta?.kind;t&&O?.(t,String(e.id))}},onChange:e=>{p(e.characterCount),g.current=e.characterCount;const t=u.current?.getJSON()??null;E(S.editorDocToInstructions(t,k))}},d),A]})]})};exports.MentionEditor=$;
2
2
  //# sourceMappingURL=MentionEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n} from '../utils/mentionSerialization';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => setCount(value.length),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell minHeight={minHeight} data-test={rest['data-test']}>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t// Soft limit: blocks typing past the cap but lets a paste through\n\t\t\t\t\t// (overflow rendered grey) instead of rejecting the whole paste.\n\t\t\t\t\tcharacterLimit={maxLength}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\tif (kind) {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","action","rest","editorRef","useRef","count","setCount","useState","insert","useCallback","kind","id","overrideLabel","editor","item","m","finalLabel","buildMentionHtml","useEffect","initialHtml","useMemo","instructionsToEditorHtml","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","props","MentionPicker","snapshot","doc","editorDocToInstructions"],"mappings":"+ZAqEaA,EAA8C,CAAC,CAC3D,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EAAY,QACZ,SAAAC,EACA,aAAAC,EACA,MAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,OAAAC,EACA,GAAGC,CACJ,IAAM,CACL,MAAMC,EAAYC,EAAAA,OAAqB,IAAI,EACrC,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAASrB,EAAM,MAAM,EAEzCsB,EAASC,EAAAA,YACd,CAACC,EAAMC,EAAIC,IAAkB,CAC5B,MAAMC,EAASV,EAAU,QACzB,GAAI,CAACU,EACJ,OAED,MAAMC,EAAOtB,EAAa,KACxBuB,GACA,OAAOA,EAAE,EAAE,IAAM,OAAOJ,CAAE,GACzBI,EAAE,MAAiD,OAASL,CAAA,EAEzDM,EAAaJ,GAAiBE,GAAM,OAASH,EACnDE,EAAO,oBACN,GAAGI,EAAAA,iBAAiB,OAAON,CAAE,EAAGK,EAAYN,CAAI,CAAC,QAAA,CAEnD,EACA,CAAClB,CAAY,CAAA,EAGd0B,EAAAA,UAAU,IAAM,CACf,GAAKtB,EAGL,OAAAA,EAAeY,CAAM,EAC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,EAsCLU,CAAA,CAAA,CACF,CAAA,EACD,CAEF"}
1
+ {"version":3,"file":"MentionEditor.js","sources":["../../../../../src/components/agent-builder/components/MentionEditor.tsx"],"sourcesContent":["import { BikEditor, BikEditorRef, MentionItem, PasteData } from '@src/editor';\nimport React, {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool } from '../AgentBuilder.model';\nimport {\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\nimport { AGENT_EDITOR_STYLE } from '../constants/editorStyle';\nimport type { ToolAction, ToolSource } from '../constants/tools';\nimport {\n\tbuildMentionHtml,\n\teditorDocToInstructions,\n\tinstructionsToEditorHtml,\n\tMentionKindMeta,\n} from '../utils/mentionSerialization';\nimport { renderSourceIcon, sourceIcon } from '../utils/sourceIcons';\nimport { MentionPicker } from './MentionPicker';\n\ntype InsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n\tsource?: string,\n) => void;\n\n// Insert-safe HTML for a plain-text run: escape entities so pasted text is never\n// interpreted as markup, and keep line breaks (mirrors the plain-paste pipeline).\nconst plainTextToHtml = (text: string): string =>\n\ttext\n\t\t.replace(/&/g, '&amp;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\\r?\\n/g, '<br>');\n\ninterface MentionEditorProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (text: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** Changing this remounts the editor with fresh content. */\n\tresetKey?: string | number;\n\t/** Items shown in the `@` picker (tools, and sub-agents where allowed). */\n\tmentionItems: MentionItem[];\n\t/** Tools used to serialise mention nodes back to `{{tool:KEY}}`. */\n\ttools: AgentTool[];\n\t/** Called when an item is picked from the `@` menu (to attach it upstream). */\n\tonMentionSelect?: (kind: 'tool' | 'subagent', id: string) => void;\n\tonFocus?: () => void;\n\t/** Receives an insert-at-cursor fn (and null on unmount) for side-panel adds. */\n\tregisterInsert?: (fn: InsertFn | null) => void;\n\t/**\n\t * When set, the `@` picker's Sub-agent view shows a \"Create new\" row that calls\n\t * this (opens the create-sub-agent drawer). Omit to hide it (e.g. the drawer's\n\t * own editors, which can't nest sub-agents).\n\t */\n\tonCreateSubAgent?: () => void;\n\t/**\n\t * Built-in tool actions (Rest API / Handover to email) shown in the `@` picker's\n\t * Tools view. Picking one opens its drawer instead of inserting a mention.\n\t */\n\ttoolActions?: ToolAction[];\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Optional action(s) rendered inside the shell, below the editor. */\n\taction?: React.ReactNode;\n\t'data-test'?: string;\n}\n\n/**\n * Presentational BikEditor field with `@` mentions. Stores firebase token text\n * (`{{tool:KEY}}` / `{{subagent:ID}}`). Context-free — both the builder's\n * Step-3 fields and the create-sub-agent drawer compose it.\n */\nexport const MentionEditor: React.FC<MentionEditorProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '200px',\n\tresetKey,\n\tmentionItems,\n\ttools,\n\tonMentionSelect,\n\tonFocus,\n\tregisterInsert,\n\tonCreateSubAgent,\n\ttoolActions,\n\tintegrationStatus,\n\tonConnectIntegration,\n\taction,\n\t...rest\n}) => {\n\tconst editorRef = useRef<BikEditorRef>(null);\n\tconst [count, setCount] = useState(value.length);\n\t// Live character count for the paste handler (BikEditor captures onPaste once\n\t// at mount, so it can't read the `count` state without going stale).\n\tconst countRef = useRef(value.length);\n\n\t// On paste, insert only the characters that still fit under the limit instead\n\t// of letting the paste overflow. Pastes that fit fall through to the editor's\n\t// normal (break-preserving) plain-paste pipeline.\n\tconst handlePaste = useCallback(\n\t\t({ text }: PasteData): boolean | void => {\n\t\t\tif (!text) {\n\t\t\t\treturn false; // non-text (e.g. images) → default handling\n\t\t\t}\n\t\t\tconst editor = editorRef.current;\n\t\t\tconst selectionLength = editor?.getSelectedText().length ?? 0;\n\t\t\tconst room = maxLength - (countRef.current - selectionLength);\n\t\t\tif (text.length <= room) {\n\t\t\t\treturn false; // fits → let the default plain-paste pipeline run\n\t\t\t}\n\t\t\tif (room <= 0) {\n\t\t\t\treturn true; // already full → drop the paste\n\t\t\t}\n\t\t\teditor?.insertContent(plainTextToHtml(text.slice(0, room)));\n\t\t\treturn true;\n\t\t},\n\t\t[maxLength],\n\t);\n\n\tconst insert = useCallback<InsertFn>(\n\t\t(kind, id, overrideLabel, overrideSource) => {\n\t\t\tconst editor = editorRef.current;\n\t\t\tif (!editor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst item = mentionItems.find(\n\t\t\t\t(m) =>\n\t\t\t\t\tString(m.id) === String(id) &&\n\t\t\t\t\t(m.meta as unknown as MentionKindMeta | undefined)?.kind === kind,\n\t\t\t);\n\t\t\tconst finalLabel = overrideLabel ?? item?.label ?? id;\n\t\t\t// Prefer the caller-supplied source: a JUST-created custom tool (Rest API /\n\t\t\t// email / Slack) isn't in `mentionItems` yet, so the lookup would miss and\n\t\t\t// the chip would render without its icon until reload.\n\t\t\tconst source =\n\t\t\t\toverrideSource ??\n\t\t\t\t(item?.meta as unknown as MentionKindMeta | undefined)?.source;\n\t\t\teditor.insertInlineContent(\n\t\t\t\t`${buildMentionHtml(String(id), finalLabel, kind, source)}&nbsp;`,\n\t\t\t);\n\t\t},\n\t\t[mentionItems],\n\t);\n\n\tuseEffect(() => {\n\t\tif (!registerInsert) {\n\t\t\treturn;\n\t\t}\n\t\tregisterInsert(insert);\n\t\treturn () => registerInsert(null);\n\t}, [registerInsert, insert]);\n\n\t// Mount-only initial HTML; recomputed (editor remounted via key) on resetKey.\n\tconst initialHtml = useMemo(\n\t\t() => instructionsToEditorHtml(value, mentionItems),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\tuseEffect(\n\t\t() => {\n\t\t\tsetCount(value.length);\n\t\t\tcountRef.current = value.length;\n\t\t},\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[resetKey],\n\t);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{count}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell minHeight={minHeight} data-test={rest['data-test']}>\n\t\t\t\t<BikEditor\n\t\t\t\t\tkey={resetKey}\n\t\t\t\t\tref={editorRef}\n\t\t\t\t\tinitialContent={initialHtml}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t// Hard limit: nothing may push the content past the cap. Typing,\n\t\t\t\t\t// Enter and drop past it are rejected; a paste is truncated to fill\n\t\t\t\t\t// the remaining room (`onPaste` pre-trims; the hard filter trims any\n\t\t\t\t\t// residue). Content loaded over the cap is kept and can only shrink.\n\t\t\t\t\t// Same metric as the shown count.\n\t\t\t\t\tcharacterLimit={maxLength}\n\t\t\t\t\tcharacterLimitHard\n\t\t\t\t\tonPaste={handlePaste}\n\t\t\t\t\tminHeight=\"120px\"\n\t\t\t\t\tmaxHeight=\"320px\"\n\t\t\t\t\tstyle={{ border: 'none' }}\n\t\t\t\t\teditorStyle={AGENT_EDITOR_STYLE}\n\t\t\t\t\tonFocus={onFocus}\n\t\t\t\t\tmentions={{\n\t\t\t\t\t\tagents: mentionItems,\n\t\t\t\t\t\tremoveTriggerOnDismiss: true,\n\t\t\t\t\t\t// Tool chips lead with their source glyph (manifest / shopify / …);\n\t\t\t\t\t\t// sub-agent chips have no source, so no icon.\n\t\t\t\t\t\trenderChipIcon: (source) =>\n\t\t\t\t\t\t\trenderSourceIcon(sourceIcon(source ?? undefined), -6),\n\t\t\t\t\t\trenderDropdown: (props) => (\n\t\t\t\t\t\t\t<MentionPicker\n\t\t\t\t\t\t\t\t{...props}\n\t\t\t\t\t\t\t\tonCreateSubAgent={onCreateSubAgent}\n\t\t\t\t\t\t\t\ttoolActions={toolActions}\n\t\t\t\t\t\t\t\tintegrationStatus={integrationStatus}\n\t\t\t\t\t\t\t\tonConnectIntegration={onConnectIntegration}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonSelect: (item) => {\n\t\t\t\t\t\t\tconst kind = (item.meta as unknown as MentionKindMeta | undefined)\n\t\t\t\t\t\t\t\t?.kind;\n\t\t\t\t\t\t\tif (kind) {\n\t\t\t\t\t\t\t\tonMentionSelect?.(kind, String(item.id));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonChange={(snapshot) => {\n\t\t\t\t\t\tsetCount(snapshot.characterCount);\n\t\t\t\t\t\tcountRef.current = snapshot.characterCount;\n\t\t\t\t\t\tconst doc = editorRef.current?.getJSON() ?? null;\n\t\t\t\t\t\tonChange(editorDocToInstructions(doc, tools));\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{action}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["plainTextToHtml","text","MentionEditor","label","value","onChange","maxLength","placeholder","minHeight","resetKey","mentionItems","tools","onMentionSelect","onFocus","registerInsert","onCreateSubAgent","toolActions","integrationStatus","onConnectIntegration","action","rest","editorRef","useRef","count","setCount","useState","countRef","handlePaste","useCallback","editor","selectionLength","room","insert","kind","id","overrideLabel","overrideSource","item","m","finalLabel","source","buildMentionHtml","useEffect","initialHtml","useMemo","instructionsToEditorHtml","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","BikEditor","AGENT_EDITOR_STYLE","renderSourceIcon","sourceIcon","props","MentionPicker","snapshot","doc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AC,EACA,qBAAAC,CAAA,CAAA,EAGF,SAAWmB,GAAS,CACnB,MAAMJ,EAAQI,EAAK,MAChB,KACCJ,GACHrB,IAAkBqB,EAAM,OAAOI,EAAK,EAAE,CAAC,CAEzC,CAAA,EAED,SAAWuB,GAAa,CACvBpC,EAASoC,EAAS,cAAc,EAChClC,EAAS,QAAUkC,EAAS,eAC5B,MAAMC,EAAMxC,EAAU,SAAS,QAAA,GAAa,KAC5ChB,EAASyD,EAAAA,wBAAwBD,EAAKlD,CAAK,CAAC,CAC7C,CAAA,EA9CKF,CAAA,EAgDLU,CAAA,CAAA,CACF,CAAA,EACD,CAEF"}
@@ -1,20 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),X=require("../../../assets/icons/chevronRight.svg.js"),Y=require("../../../assets/icons/searchIcon.svg.js"),Z=require("../../../icons/Arrows/Normal arrows/ArrowLeft.js"),l=require("react"),K=require("styled-components"),T=require("../../TypographyStyle.js"),c=require("../../../constants/Theme.js"),O=require("../constants/tools.js"),P=require("../utils/mentionSerialization.js"),y=require("../utils/sourceIcons.js"),J=require("../../../icons/Informational/Common UI/Shield.js"),H=a=>a&&typeof a=="object"&&"default"in a?a:{default:a},p=H(K),g=a=>a.meta,R=a=>g(a)?.plainLabel??a.label,ee="__bik_create_subagent__",te=({items:a,onSelect:L,registerKeyHandler:C,onClose:m,onCreateSubAgent:v,initialSource:z,toolActions:k,integrationStatus:D,onConnectIntegration:N})=>{const[Q,A]=l.useState(null),[u,B]=l.useState(z??null),[w,x]=l.useState(-1),[S,U]=l.useState(""),b=l.useMemo(()=>a.filter(e=>g(e)?.kind==="tool"),[a]),I=l.useMemo(()=>a.filter(e=>g(e)?.kind==="subagent"),[a]),E=l.useMemo(()=>{const e=[];return b.forEach(i=>{const h=g(i)?.source??"other";e.includes(h)||e.push(h)}),e},[b]),M=l.useMemo(()=>new Map((k??[]).map(e=>[e.source,e])),[k]),j=l.useMemo(()=>O.CATEGORIES.filter(e=>e.key==="tool"?b.length>0||(k?.length??0)>0:I.length>0||!!v),[b.length,I.length,v,k?.length]),_=j.length===1?j[0].key:null,d=Q??_,f=d?d==="subagent"?{title:"Sub-agent",onBack:_?void 0:()=>A(null)}:u?{title:P.toolSourceLabel(u),onBack:z?void 0:()=>B(null),icon:y.sourceIcon(u)}:{title:"Tools",onBack:_?void 0:()=>A(null)}:null,s=l.useMemo(()=>{if(!d)return j.map(n=>({id:n.key,label:n.label,drillsIn:!0,onActivate:()=>{A(n.key),B(null)}}));if(d==="subagent"){const n=S.trim().toLowerCase(),t=I.filter(o=>!n||R(o).toLowerCase().includes(n)).map(o=>({id:String(o.id),label:R(o),drillsIn:!1,onActivate:()=>L(o)}));return v&&t.push({id:ee,label:"Create new",drillsIn:!1,isCreate:!0,onActivate:()=>{m?.(),v()}}),t}if(!u){const n=(k??[]).map(t=>t.source).filter(t=>!E.includes(t));return[...E,...n].sort((t,o)=>O.toolSourceRank(t)-O.toolSourceRank(o)).map(t=>{const o=M.get(t);if((o!==void 0?o.connected:D?.[t])===!1)return{id:t,label:P.toolSourceLabel(t),drillsIn:!1,icon:y.sourceIcon(t)??o?.icon,rightLabel:"Connect",onActivate:()=>{m?.(),o?.onConnect?o.onConnect():N?.(t)}};const G=b.filter(q=>(g(q)?.source??"other")===t);if(G.length+(o?1:0)===1&&!(o===void 0&&O.isIntegrationSource(t))){const q=y.sourceIcon(t)??o?.icon;if(o)return{id:t,label:o.label,drillsIn:!1,icon:q,onActivate:()=>{m?.(),o.onSelect()}};const $=G[0];return{id:String($.id),label:R($),drillsIn:!1,icon:q,authRequired:g($)?.authRequired,onActivate:()=>L($)}}return{id:t,label:P.toolSourceLabel(t),drillsIn:!0,icon:y.sourceIcon(t)??o?.icon,onActivate:()=>B(t)}})}const e=S.trim().toLowerCase(),i=b.filter(n=>(g(n)?.source??"other")===u).filter(n=>!e||R(n).toLowerCase().includes(e)).map(n=>({id:String(n.id),label:R(n),drillsIn:!1,authRequired:g(n)?.authRequired,onActivate:()=>L(n)})),h=M.get(u);if(h){const n=u in O.CONFIG_TOOL_SOURCES;i.push({id:`create:${u}`,label:h.label,drillsIn:!1,isCreate:!n,onActivate:()=>{m?.(),h.onSelect()}})}return i},[d,j,u,S,b,I,E,L,m,v,k,M,D,N]);l.useEffect(()=>x(-1),[d,u,S,a]),l.useEffect(()=>U(""),[d,u]);const F=l.useRef({rows:s,activeIndex:w,header:f});F.current={rows:s,activeIndex:w,header:f},l.useEffect(()=>{if(C)return C(e=>{const{rows:i,activeIndex:h,header:n}=F.current;switch(e.key){case"ArrowDown":return i.length&&x(t=>(t+1)%i.length),!0;case"ArrowUp":return i.length&&x(t=>(t+i.length-1)%i.length),!0;case"ArrowRight":case"Enter":return(i[h]??i[0])?.onActivate(),!0;case"ArrowLeft":return n?.onBack?(n.onBack(),!0):!1;default:return!1}}),()=>C(null)},[C]);const V=d?s.length&&!s[0].drillsIn?"items":"sources":"categories",W=d==="tool"&&!!u||d==="subagent";return r.jsxs(ne,{className:`bik-mention-picker bik-mention-picker--${V}`,children:[f&&r.jsxs(ue,{type:"button",onClick:f.onBack,disabled:!f.onBack,style:{background:c.COLORS.surface.subdued,cursor:f.onBack?"pointer":"default"},children:[f.onBack&&r.jsx(Z.default,{width:20,height:20,color:c.COLORS.content.primary}),f.icon&&y.renderSourceIcon(f.icon),r.jsxs(T.TitleSmall,{children:[" ",f.title]})]}),W&&r.jsxs(oe,{children:[r.jsx(Y.default,{width:20,height:20,color:c.COLORS.content.placeholder}),r.jsx(re,{autoFocus:!0,value:S,placeholder:"Search","data-test":"mention-picker-search",onChange:e=>U(e.target.value),onKeyDown:e=>{s.length&&(e.key==="ArrowDown"?(e.preventDefault(),x(i=>(i+1)%s.length)):e.key==="ArrowUp"?(e.preventDefault(),x(i=>(i+s.length-1)%s.length)):e.key==="Enter"&&(e.preventDefault(),(s[w]??s[0])?.onActivate()))}})]}),s.length===0?r.jsx(de,{children:d==="subagent"?null:"No tools available"}):s.map((e,i)=>r.jsx(ie,{type:"button",$active:i===w,onMouseEnter:()=>x(i),onMouseLeave:()=>x(-1),onClick:e.onActivate,children:e.isCreate?r.jsx(se,{children:e.label}):r.jsxs(r.Fragment,{children:[r.jsxs(ae,{children:[y.renderSourceIcon(e.icon),r.jsx(T.BodySecondary,{color:c.COLORS.content.primary,children:e.label}),e.authRequired&&r.jsx(J.default,{size:14,"aria-label":"Requires customer verification"})]}),e.rightLabel?r.jsx(le,{children:e.rightLabel}):e.drillsIn&&r.jsx(X.default,{width:12,height:12})]})},e.id)),s.some(e=>e.authRequired)&&r.jsxs(ce,{children:[r.jsx(J.default,{size:14}),r.jsx(T.BodyCaption,{color:c.COLORS.content.secondary,children:"Requires customer verification"})]})]})},ne=p.default.div`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),ee=require("../../../assets/icons/chevronRight.svg.js"),te=require("../../../assets/icons/searchIcon.svg.js"),ne=require("../../../icons/Arrows/Normal arrows/ArrowLeft.js"),s=require("react"),oe=require("styled-components"),N=require("../../TypographyStyle.js"),l=require("../../../constants/Theme.js"),g=require("../constants/tools.js"),G=require("../utils/mentionSerialization.js"),v=require("../utils/sourceIcons.js"),Y=require("../../../icons/Informational/Common UI/Shield.js"),re=i=>i&&typeof i=="object"&&"default"in i?i:{default:i},p=re(oe),k=i=>i.meta,C=i=>k(i)?.plainLabel??i.label,ie="__bik_create_subagent__",le=({items:i,onSelect:L,registerKeyHandler:j,onClose:O,onCreateSubAgent:R,initialSource:U,toolActions:S,integrationStatus:F,onConnectIntegration:J})=>{const[Z,E]=s.useState(null),[u,q]=s.useState(U??null),[w,M]=s.useState(null),[A,m]=s.useState(-1),[I,Q]=s.useState(""),y=s.useMemo(()=>i.filter(e=>k(e)?.kind==="tool"),[i]),_=s.useMemo(()=>i.filter(e=>k(e)?.kind==="subagent"),[i]),P=s.useMemo(()=>{const e=[];return y.forEach(r=>{const x=k(r)?.source??"other";e.includes(x)||e.push(x)}),e},[y]),z=s.useMemo(()=>new Map((S??[]).map(e=>[e.source,e])),[S]),$=s.useMemo(()=>g.CATEGORIES.filter(e=>e.key==="tool"?y.length>0||(S?.length??0)>0:_.length>0||!!R),[y.length,_.length,R,S?.length]),D=$.length===1?$[0].key:null,d=Z??D,f=d?d==="subagent"?{title:"Sub-agent",onBack:D?void 0:()=>E(null)}:u?{title:G.toolSourceLabel(u),onBack:U?void 0:()=>q(null),icon:v.sourceIcon(u)}:w==="integrations"?{title:"Integrations",onBack:()=>M(null)}:{title:"Tools",onBack:D?void 0:()=>E(null)}:null,c=s.useMemo(()=>{if(!d)return $.map(n=>({id:n.key,label:n.label,drillsIn:!0,onActivate:()=>{E(n.key),q(null),M(null)}}));if(d==="subagent"){const n=I.trim().toLowerCase(),h=_.filter(b=>!n||C(b).toLowerCase().includes(n)).map(b=>({id:String(b.id),label:C(b),drillsIn:!1,onActivate:()=>L(b)}));return R&&h.push({id:ie,label:"Create new",drillsIn:!1,isCreate:!0,onActivate:()=>{O?.(),R()}}),h}if(!u){const n=(S??[]).map(t=>t.source).filter(t=>!P.includes(t)),h=[...P,...n],b=t=>{const a=z.get(t);if((a!==void 0?a.connected:F?.[t])===!1)return{id:t,label:G.toolSourceLabel(t),drillsIn:!1,icon:v.sourceIcon(t)??a?.icon,rightLabel:"Connect",onActivate:()=>{O?.(),a?.onConnect?a.onConnect():J?.(t)}};const X=y.filter(T=>(k(T)?.source??"other")===t);if(X.length+(a?1:0)===1){const T=v.sourceIcon(t)??a?.icon;if(a)return{id:t,label:a.label,drillsIn:!1,icon:T,onActivate:()=>{O?.(),a.onSelect()}};const B=X[0];return{id:String(B.id),label:C(B),drillsIn:!1,icon:T,authRequired:k(B)?.authRequired,onActivate:()=>L(B)}}return{id:t,label:G.toolSourceLabel(t),drillsIn:!0,icon:v.sourceIcon(t)??a?.icon,onActivate:()=>q(t)}};if(w==="integrations")return h.filter(g.isIntegrationSource).sort((t,a)=>g.toolSourceRank(t)-g.toolSourceRank(a)).map(b);const W=h.filter(t=>!g.isIntegrationSource(t)).map(t=>({rank:g.toolSourceRank(t),row:b(t)}));return h.some(g.isIntegrationSource)&&W.push({rank:g.INTEGRATIONS_RANK,row:{id:"__integrations__",label:"Integrations",drillsIn:!0,onActivate:()=>{M("integrations"),q(null)}}}),W.sort((t,a)=>t.rank-a.rank).map(t=>t.row)}const e=I.trim().toLowerCase(),r=y.filter(n=>(k(n)?.source??"other")===u).filter(n=>!e||C(n).toLowerCase().includes(e)).map(n=>({id:String(n.id),label:C(n),drillsIn:!1,authRequired:k(n)?.authRequired,onActivate:()=>L(n)})),x=z.get(u);if(x){const n=u in g.CONFIG_TOOL_SOURCES;r.push({id:`create:${u}`,label:x.label,drillsIn:!1,isCreate:!n,onActivate:()=>{O?.(),x.onSelect()}})}return r},[d,$,u,w,I,y,_,P,L,O,R,S,z,F,J]);s.useEffect(()=>m(-1),[d,u,w,I,i]),s.useEffect(()=>Q(""),[d,u,w]);const V=s.useRef({rows:c,activeIndex:A,header:f});V.current={rows:c,activeIndex:A,header:f},s.useEffect(()=>{if(j)return j(e=>{const{rows:r,activeIndex:x,header:n}=V.current;switch(e.key){case"ArrowDown":return r.length&&m(h=>(h+1)%r.length),!0;case"ArrowUp":return r.length&&m(h=>(h+r.length-1)%r.length),!0;case"ArrowRight":case"Enter":return(r[x]??r[0])?.onActivate(),!0;case"ArrowLeft":return n?.onBack?(n.onBack(),!0):!1;default:return!1}}),()=>j(null)},[j]);const K=d?c.length&&!c[0].drillsIn?"items":"sources":"categories",H=d==="tool"&&!!u||d==="subagent";return o.jsxs(ae,{className:`bik-mention-picker bik-mention-picker--${K}`,children:[f&&o.jsxs(ge,{type:"button",onClick:f.onBack,disabled:!f.onBack,style:{background:l.COLORS.surface.subdued,cursor:f.onBack?"pointer":"default"},children:[f.onBack&&o.jsx(ne.default,{width:20,height:20,color:l.COLORS.content.primary}),f.icon&&v.renderSourceIcon(f.icon),o.jsxs(N.TitleSmall,{children:[" ",f.title]})]}),H&&o.jsxs(se,{children:[o.jsx(te.default,{width:20,height:20,color:l.COLORS.content.placeholder}),o.jsx(ce,{autoFocus:!0,value:I,placeholder:"Search","data-test":"mention-picker-search",onChange:e=>Q(e.target.value),onKeyDown:e=>{c.length&&(e.key==="ArrowDown"?(e.preventDefault(),m(r=>(r+1)%c.length)):e.key==="ArrowUp"?(e.preventDefault(),m(r=>(r+c.length-1)%c.length)):e.key==="Enter"&&(e.preventDefault(),(c[A]??c[0])?.onActivate()))}})]}),c.length===0?o.jsx(xe,{children:d==="subagent"?null:"No tools available"}):c.map((e,r)=>o.jsx(ue,{type:"button",$active:r===A,onMouseEnter:()=>m(r),onMouseLeave:()=>m(-1),onClick:e.onActivate,children:e.isCreate?o.jsx(pe,{children:e.label}):o.jsxs(o.Fragment,{children:[o.jsxs(de,{children:[v.renderSourceIcon(e.icon),o.jsx(N.BodySecondary,{color:l.COLORS.content.primary,children:e.label}),e.authRequired&&o.jsx(Y.default,{size:16,"aria-label":"This tool requires customer verification"})]}),e.rightLabel?o.jsx(he,{children:e.rightLabel}):e.drillsIn&&o.jsx(ee.default,{width:12,height:12})]})},e.id)),c.some(e=>e.authRequired)&&o.jsxs(fe,{children:[o.jsx(Y.default,{size:16}),o.jsx(N.BodyCaption,{color:l.COLORS.content.secondary,children:"This tool requires customer verification"})]})]})},ae=p.default.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  min-width: 240px;
5
5
  max-height: 301px;
6
6
  overflow-y: auto;
7
- background: ${c.COLORS.surface.standard};
8
- border: 1px solid ${c.COLORS.stroke.primary};
7
+ background: ${l.COLORS.surface.standard};
8
+ border: 1px solid ${l.COLORS.stroke.primary};
9
9
  border-radius: 4px;
10
10
  box-shadow: 0px -2px 8px 0px #0000001f;
11
- `,oe=p.default.div`
11
+ `,se=p.default.div`
12
12
  display: flex;
13
13
  align-items: center;
14
14
  gap: 8px;
15
15
  padding: 10px 12px;
16
- border-bottom: 1px solid ${c.COLORS.stroke.primary};
17
- `,re=p.default.input`
16
+ flex-shrink: 0;
17
+ border-bottom: 1px solid ${l.COLORS.stroke.primary};
18
+ `,ce=p.default.input`
18
19
  flex: 1;
19
20
  min-width: 0;
20
21
  border: none;
@@ -22,12 +23,12 @@
22
23
  background: transparent;
23
24
  font-family: Inter;
24
25
  font-size: 14px;
25
- color: ${c.COLORS.content.primary};
26
+ color: ${l.COLORS.content.primary};
26
27
 
27
28
  &::placeholder {
28
- color: ${c.COLORS.content.placeholder};
29
+ color: ${l.COLORS.content.placeholder};
29
30
  }
30
- `,ie=p.default.button`
31
+ `,ue=p.default.button`
31
32
  display: flex;
32
33
  justify-content: space-between;
33
34
  align-items: center;
@@ -35,57 +36,64 @@
35
36
  width: 100%;
36
37
  padding: 8px 10px;
37
38
  height: 48px;
39
+ /* The card is a flex column with a max-height; without these a long list
40
+ compresses its rows below 48px (why only the short first step looked right)
41
+ instead of scrolling. Pin the row so the card scrolls instead. */
42
+ box-sizing: border-box;
43
+ flex-shrink: 0;
38
44
  border: none;
39
- border-bottom: 1px solid ${c.COLORS.stroke.primary};
40
- background: ${a=>a.$active?c.COLORS.surface.subdued:"transparent"};
45
+ border-bottom: 1px solid ${l.COLORS.stroke.primary};
46
+ background: ${i=>i.$active?l.COLORS.surface.subdued:"transparent"};
41
47
  cursor: pointer;
42
48
  text-align: left;
43
49
 
44
50
  &:hover {
45
- background: ${c.COLORS.surface.hovered};
51
+ background: ${l.COLORS.surface.hovered};
46
52
  }
47
- `,ae=p.default.div`
53
+ `,de=p.default.div`
48
54
  display: flex;
49
55
  align-items: center;
50
56
  gap: 12px;
51
57
  min-width: 0;
52
- `,ce=p.default.div`
58
+ `,fe=p.default.div`
53
59
  display: flex;
54
60
  align-items: center;
55
61
  gap: 6px;
56
62
  padding: 8px 12px;
57
- border-top: 1px solid ${c.COLORS.stroke.primary};
58
- `,le=p.default.span`
63
+ border-top: 1px solid ${l.COLORS.stroke.primary};
64
+ `,he=p.default.span`
59
65
  flex-shrink: 0;
60
- color: ${c.COLORS.content.brand};
66
+ color: ${l.COLORS.content.brand};
61
67
  font-family: Inter;
62
68
  font-size: 14px;
63
69
  font-weight: 600;
64
70
  white-space: nowrap;
65
- `,se=p.default.div`
71
+ `,pe=p.default.div`
66
72
  width: 100%;
67
73
  text-align: center;
68
- color: ${c.COLORS.content.brand};
74
+ color: ${l.COLORS.content.brand};
69
75
  font-family: Inter;
70
76
  font-size: 14px;
71
77
  font-weight: 600;
72
- `,ue=p.default.button`
78
+ `,ge=p.default.button`
73
79
  display: flex;
74
80
  align-items: center;
75
81
  padding: 12px 16px;
76
82
  border: none;
77
- border-bottom: 1px solid ${c.COLORS.stroke.primary};
83
+ border-bottom: 1px solid ${l.COLORS.stroke.primary};
78
84
  background: transparent;
79
85
  cursor: pointer;
80
86
  font-family: Inter;
81
87
  font-size: 12px;
82
88
  font-weight: 600;
83
89
  height: 48px;
90
+ box-sizing: border-box;
91
+ flex-shrink: 0;
84
92
  gap: 4px;
85
- `,de=p.default.div`
93
+ `,xe=p.default.div`
86
94
  padding: 12px 10px;
87
95
  font-family: Inter;
88
96
  font-size: 13px;
89
- color: ${c.COLORS.content.secondary};
90
- `;exports.MentionPicker=te;
97
+ color: ${l.COLORS.content.secondary};
98
+ `;exports.MentionPicker=le;
91
99
  //# sourceMappingURL=MentionPicker.js.map