@bikdotai/bik-component-library 0.0.853 → 0.0.855

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 (110) hide show
  1. package/dist/cjs/components/add-variableV2/AddDataPill.js +10 -0
  2. package/dist/cjs/components/add-variableV2/AddDataPill.js.map +1 -0
  3. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  4. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +11 -11
  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/MentionEditor.js +7 -1
  10. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/MentionPicker.js +41 -14
  14. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +6 -5
  16. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
  18. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  19. package/dist/cjs/components/agent-builder/components/VariableInlineField.js +65 -0
  20. package/dist/cjs/components/agent-builder/components/VariableInlineField.js.map +1 -0
  21. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js +10 -0
  22. package/dist/cjs/components/agent-builder/components/VariableTriggerArea.js.map +1 -0
  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 +4 -4
  30. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  31. package/dist/cjs/components/toaster/Toaster.js +1 -1
  32. package/dist/cjs/components/toaster/Toaster.js.map +1 -1
  33. package/dist/cjs/components/toaster/Toaster.styled.js +7 -7
  34. package/dist/cjs/components/toaster/Toaster.styled.js.map +1 -1
  35. package/dist/cjs/components/variable-picker-v3/Content.js +1 -1
  36. package/dist/cjs/components/variable-picker-v3/Content.js.map +1 -1
  37. package/dist/cjs/editor/BikEditor.js +1 -1
  38. package/dist/cjs/editor/BikEditor.js.map +1 -1
  39. package/dist/cjs/editor/BikEditor.styles.js +8 -0
  40. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  41. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  42. package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
  43. package/dist/cjs/editor/extensions/mention/MentionDropdown.js.map +1 -1
  44. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  45. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  46. package/dist/cjs/index.js +1 -1
  47. package/dist/esm/components/add-variableV2/AddDataPill.d.ts +24 -0
  48. package/dist/esm/components/add-variableV2/AddDataPill.js +33 -0
  49. package/dist/esm/components/add-variableV2/AddDataPill.js.map +1 -0
  50. package/dist/esm/components/add-variableV2/index.d.ts +1 -0
  51. package/dist/esm/components/agent-builder/AgentBuilder.js +76 -74
  52. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  53. package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +8 -0
  54. package/dist/esm/components/agent-builder/components/ConfigToolPanel.d.ts +8 -0
  55. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +182 -136
  56. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  57. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +3 -0
  58. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +195 -188
  59. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  60. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +12 -0
  61. package/dist/esm/components/agent-builder/components/MentionEditor.js +144 -103
  62. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  63. package/dist/esm/components/agent-builder/components/MentionField.js +48 -45
  64. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  65. package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +14 -1
  66. package/dist/esm/components/agent-builder/components/MentionPicker.js +286 -218
  67. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  68. package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +8 -0
  69. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +192 -176
  70. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
  71. package/dist/esm/components/agent-builder/components/ToolInstructionsField.d.ts +9 -0
  72. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +67 -48
  73. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  74. package/dist/esm/components/agent-builder/components/VariableInlineField.d.ts +26 -0
  75. package/dist/esm/components/agent-builder/components/VariableInlineField.js +149 -0
  76. package/dist/esm/components/agent-builder/components/VariableInlineField.js.map +1 -0
  77. package/dist/esm/components/agent-builder/components/VariableTriggerArea.d.ts +46 -0
  78. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js +118 -0
  79. package/dist/esm/components/agent-builder/components/VariableTriggerArea.js.map +1 -0
  80. package/dist/esm/components/agent-builder/constants/tools.d.ts +1 -1
  81. package/dist/esm/components/agent-builder/constants/tools.js +14 -13
  82. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  83. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +7 -0
  84. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +99 -96
  85. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  86. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +164 -160
  87. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  88. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +14 -4
  89. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +54 -36
  90. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  91. package/dist/esm/components/toaster/Toaster.js +30 -25
  92. package/dist/esm/components/toaster/Toaster.js.map +1 -1
  93. package/dist/esm/components/toaster/Toaster.styled.js +5 -5
  94. package/dist/esm/components/toaster/Toaster.styled.js.map +1 -1
  95. package/dist/esm/components/variable-picker-v3/Content.js +16 -15
  96. package/dist/esm/components/variable-picker-v3/Content.js.map +1 -1
  97. package/dist/esm/editor/BikEditor.js +40 -34
  98. package/dist/esm/editor/BikEditor.js.map +1 -1
  99. package/dist/esm/editor/BikEditor.styles.js +20 -12
  100. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  101. package/dist/esm/editor/BikEditor.types.d.ts +9 -0
  102. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  103. package/dist/esm/editor/extensions/mention/MentionDropdown.js +28 -28
  104. package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
  105. package/dist/esm/editor/extensions/mention/MentionExtension.js +23 -19
  106. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  107. package/dist/esm/icons/index.d.ts +25 -25
  108. package/dist/esm/index.js +543 -541
  109. package/dist/esm/index.js.map +1 -1
  110. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { ToolSource as ModelToolSource } from '@bikdotai/bik-models/ai-agents/models/agent-tool';\nimport type { FunctionComponent, SVGAttributes } from 'react';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n *\n * This is the RUNTIME mirror of the canonical `@bikdotai/bik-models` `ToolSource`\n * union (the shape the backend persists as `AgentToolDoc.source`). We keep an\n * enum — not a re-export of the type — because the members are needed at runtime\n * for labels, ranks, icons and `===` comparisons; a type-only union can't do\n * that. The two are kept in lock-step by {@link ToolSourceMatchesBikModels}\n * below, which fails to compile if they ever drift.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tBigcommerce = 'bigcommerce',\n\tShipstation = 'shipstation',\n\tSkio = 'skio',\n\tGorgias = 'gorgias',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Compile-time guard that {@link ToolSource} stays a faithful mirror of the\n * canonical `@bikdotai/bik-models` `ToolSource` union. If a source is added to\n * (or removed from) either side without the other, `AssertTrue` receives `false`\n * and this type stops compiling — so the runtime enum can never silently diverge\n * from what the backend persists as `AgentToolDoc.source`. The tuple wrappers\n * (`[…]`) stop the conditionals from distributing over the unions, so it checks\n * set-equality in both directions.\n *\n * Type-only (erased at build): a drift shows up as a compile error on\n * `ToolSourceMatchesBikModels` telling you to reconcile this enum with\n * `@bikdotai/bik-models` (bump the dep and/or the enum).\n */\ntype AssertTrue<T extends true> = T;\ntype ToolSourceMatchesBikModels = AssertTrue<\n\t[`${ToolSource}`] extends [ModelToolSource]\n\t\t? [ModelToolSource] extends [`${ToolSource}`]\n\t\t\t? true\n\t\t\t: false\n\t\t: false\n>;\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Bigcommerce]: 'BigCommerce',\n\t[ToolSource.Shipstation]: 'ShipStation',\n\t[ToolSource.Skio]: 'Skio',\n\t[ToolSource.Gorgias]: 'Gorgias',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Send email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n\t/**\n\t * Integration connection state for this source. `undefined` = no connection\n\t * gating (default). `false` = the store hasn't connected this integration →\n\t * the `@` picker shows a \"Connect\" row that calls {@link onConnect} instead of\n\t * drilling in / offering \"Create new\". `true` = connected (renders normally).\n\t * Set by the consumer via `config.integrationStatus` (today: Slack only).\n\t */\n\tconnected?: boolean;\n\t/** Open the parent's connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Fixed display rank for the `@`-picker's tool-source groups (lower = higher). The\n * picker sorts its source rows by this so adding/updating a tool never reshuffles\n * them. Manifest (the native tools) leads; any source not listed here\n * (dynamic/unknown, e.g. Integration) sorts AFTER Slack, keeping its discovery\n * order among the rest (Array.sort is stable).\n */\nexport const TOOL_SOURCE_RANK: Partial<Record<ToolSource, number>> = {\n\t[ToolSource.Manifest]: 0,\n\t[ToolSource.Shopify]: 1,\n\t// BigCommerce / Skio / Gorgias are their OWN top-level rows; rank orders them\n\t// so adding/updating a tool never reshuffles them.\n\t[ToolSource.Bigcommerce]: 2,\n\t[ToolSource.Skio]: 3,\n\t[ToolSource.Gorgias]: 4,\n\t// ShipStation lives under the \"More Integrations\" umbrella; its rank only\n\t// orders it inside that drill-in view (never shown at the root).\n\t[ToolSource.Shipstation]: 5,\n\t[ToolSource.Slack]: 6,\n\t// Send Email then REST API sit after the integration sources at the top level.\n\t[ToolSource.EmailHandover]: 7,\n\t[ToolSource.RestApi]: 8,\n};\n\n/**\n * External integration / vendor sources. Each renders as its OWN top-level\n * drill-in group in the picker — even when it has a single tool — so the vendor\n * reads as its own discoverable, connectable unit (never collapsed to a lone\n * leaf; see the single-leaf flatten in `MentionPicker`). Deliberately excludes\n * `Manifest` (the built-in natives) and the config/rest action sources (Rest API\n * / Email / Slack), whose single capability is surfaced flat.\n */\nexport const INTEGRATION_SOURCES: ToolSource[] = [\n\tToolSource.Shopify,\n\tToolSource.Bigcommerce,\n\tToolSource.Shipstation,\n\tToolSource.Skio,\n\tToolSource.Gorgias,\n\tToolSource.Integration,\n];\n\nconst INTEGRATION_SOURCE_SET = new Set<string>(INTEGRATION_SOURCES);\n\n/** True for an external integration/vendor source (never collapsed to a single leaf). */\nexport const isIntegrationSource = (source: string): boolean =>\n\tINTEGRATION_SOURCE_SET.has(source);\n\n/**\n * Vendor integrations that live UNDER the \"More Integrations\" umbrella in the `@`\n * picker (a single top-level row → their list), instead of each being its own\n * root row. Shopify, BigCommerce, Skio and Gorgias stay top-level sources of\n * their own; only the less-common vendors (ShipStation) and the generic\n * catch-all Integration are tucked away here.\n */\nexport const MORE_INTEGRATION_SOURCES: ToolSource[] = [\n\tToolSource.Shipstation,\n\tToolSource.Integration,\n];\n\nconst MORE_INTEGRATION_SOURCE_SET = new Set<string>(MORE_INTEGRATION_SOURCES);\n\n/** True for a source shown under the \"More Integrations\" umbrella. */\nexport const isMoreIntegrationSource = (source: string): boolean =>\n\tMORE_INTEGRATION_SOURCE_SET.has(source);\n\n/**\n * Synthetic picker key / label / rank for the \"More Integrations\" umbrella row.\n * The rank lives here (not in {@link TOOL_SOURCE_RANK}) because that map is keyed\n * by the drift-guarded {@link ToolSource} enum — the backend's canonical wire\n * strings — and `more_integrations` is a picker-only key, not a real source.\n */\nexport const MORE_INTEGRATIONS_KEY = 'more_integrations';\nexport const MORE_INTEGRATIONS_LABEL = 'More Integrations';\n/** Always last — sits after every named top-level source (REST API, rank 8). */\nexport const MORE_INTEGRATIONS_RANK = 9;\n\nconst UNRANKED_SOURCE_RANK = Object.keys(TOOL_SOURCE_RANK).length;\n\n/** Sort rank for a source string; unknown sources rank after all known ones. */\nexport const toolSourceRank = (source: string): number =>\n\tTOOL_SOURCE_RANK[source as ToolSource] ?? UNRANKED_SOURCE_RANK;\n\n/**\n * `tool_key` of a configurable shared-drawer tool (email / Slack). Lives here (not\n * in AgentBuilder.model) so this leaf constants file has no back-edge to the model\n * — the dependency stays one-way (model → constants), avoiding a circular import.\n */\nexport type ConfigToolKey = 'send_email' | 'send_slack_message';\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","TOOL_SOURCE_RANK","INTEGRATION_SOURCES","INTEGRATION_SOURCE_SET","isIntegrationSource","source","MORE_INTEGRATION_SOURCES","MORE_INTEGRATION_SOURCE_SET","isMoreIntegrationSource","MORE_INTEGRATIONS_KEY","MORE_INTEGRATIONS_LABEL","MORE_INTEGRATIONS_RANK","UNRANKED_SOURCE_RANK","toolSourceRank","CONFIG_TOOL_SOURCES"],"mappings":"AAcO,MAAMA,IAAiD;AAAA,EAC7D,EAAE,KAAK,QAAQ,OAAO,QAAA;AAAA,EACtB,EAAE,KAAK,YAAY,OAAO,YAAA;AAC3B;AAmBO,IAAKC,sBAAAA,OACXA,EAAA,WAAW,YACXA,EAAA,UAAU,WACV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E,IAAkE;AAAA,EAC7E,gBAA2B;AAAA,EAC3B,OAAmB;AACrB;"}
1
+ {"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { ToolSource as ModelToolSource } from '@bikdotai/bik-models/ai-agents/models/agent-tool';\nimport type { FunctionComponent, SVGAttributes } from 'react';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent' | 'variable';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n\t{ key: 'variable', label: 'Variables' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n *\n * This is the RUNTIME mirror of the canonical `@bikdotai/bik-models` `ToolSource`\n * union (the shape the backend persists as `AgentToolDoc.source`). We keep an\n * enum — not a re-export of the type — because the members are needed at runtime\n * for labels, ranks, icons and `===` comparisons; a type-only union can't do\n * that. The two are kept in lock-step by {@link ToolSourceMatchesBikModels}\n * below, which fails to compile if they ever drift.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tBigcommerce = 'bigcommerce',\n\tShipstation = 'shipstation',\n\tSkio = 'skio',\n\tGorgias = 'gorgias',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Compile-time guard that {@link ToolSource} stays a faithful mirror of the\n * canonical `@bikdotai/bik-models` `ToolSource` union. If a source is added to\n * (or removed from) either side without the other, `AssertTrue` receives `false`\n * and this type stops compiling — so the runtime enum can never silently diverge\n * from what the backend persists as `AgentToolDoc.source`. The tuple wrappers\n * (`[…]`) stop the conditionals from distributing over the unions, so it checks\n * set-equality in both directions.\n *\n * Type-only (erased at build): a drift shows up as a compile error on\n * `ToolSourceMatchesBikModels` telling you to reconcile this enum with\n * `@bikdotai/bik-models` (bump the dep and/or the enum).\n */\ntype AssertTrue<T extends true> = T;\ntype ToolSourceMatchesBikModels = AssertTrue<\n\t[`${ToolSource}`] extends [ModelToolSource]\n\t\t? [ModelToolSource] extends [`${ToolSource}`]\n\t\t\t? true\n\t\t\t: false\n\t\t: false\n>;\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Bigcommerce]: 'BigCommerce',\n\t[ToolSource.Shipstation]: 'ShipStation',\n\t[ToolSource.Skio]: 'Skio',\n\t[ToolSource.Gorgias]: 'Gorgias',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Send email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n\t/**\n\t * Integration connection state for this source. `undefined` = no connection\n\t * gating (default). `false` = the store hasn't connected this integration →\n\t * the `@` picker shows a \"Connect\" row that calls {@link onConnect} instead of\n\t * drilling in / offering \"Create new\". `true` = connected (renders normally).\n\t * Set by the consumer via `config.integrationStatus` (today: Slack only).\n\t */\n\tconnected?: boolean;\n\t/** Open the parent's connect flow for this source (used when `connected === false`). */\n\tonConnect?: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Fixed display rank for the `@`-picker's tool-source groups (lower = higher). The\n * picker sorts its source rows by this so adding/updating a tool never reshuffles\n * them. Manifest (the native tools) leads; any source not listed here\n * (dynamic/unknown, e.g. Integration) sorts AFTER Slack, keeping its discovery\n * order among the rest (Array.sort is stable).\n */\nexport const TOOL_SOURCE_RANK: Partial<Record<ToolSource, number>> = {\n\t[ToolSource.Manifest]: 0,\n\t[ToolSource.Shopify]: 1,\n\t// BigCommerce / Skio / Gorgias are their OWN top-level rows; rank orders them\n\t// so adding/updating a tool never reshuffles them.\n\t[ToolSource.Bigcommerce]: 2,\n\t[ToolSource.Skio]: 3,\n\t[ToolSource.Gorgias]: 4,\n\t// ShipStation lives under the \"More Integrations\" umbrella; its rank only\n\t// orders it inside that drill-in view (never shown at the root).\n\t[ToolSource.Shipstation]: 5,\n\t[ToolSource.Slack]: 6,\n\t// Send Email then REST API sit after the integration sources at the top level.\n\t[ToolSource.EmailHandover]: 7,\n\t[ToolSource.RestApi]: 8,\n};\n\n/**\n * External integration / vendor sources. Each renders as its OWN top-level\n * drill-in group in the picker — even when it has a single tool — so the vendor\n * reads as its own discoverable, connectable unit (never collapsed to a lone\n * leaf; see the single-leaf flatten in `MentionPicker`). Deliberately excludes\n * `Manifest` (the built-in natives) and the config/rest action sources (Rest API\n * / Email / Slack), whose single capability is surfaced flat.\n */\nexport const INTEGRATION_SOURCES: ToolSource[] = [\n\tToolSource.Shopify,\n\tToolSource.Bigcommerce,\n\tToolSource.Shipstation,\n\tToolSource.Skio,\n\tToolSource.Gorgias,\n\tToolSource.Integration,\n];\n\nconst INTEGRATION_SOURCE_SET = new Set<string>(INTEGRATION_SOURCES);\n\n/** True for an external integration/vendor source (never collapsed to a single leaf). */\nexport const isIntegrationSource = (source: string): boolean =>\n\tINTEGRATION_SOURCE_SET.has(source);\n\n/**\n * Vendor integrations that live UNDER the \"More Integrations\" umbrella in the `@`\n * picker (a single top-level row → their list), instead of each being its own\n * root row. Shopify, BigCommerce, Skio and Gorgias stay top-level sources of\n * their own; only the less-common vendors (ShipStation) and the generic\n * catch-all Integration are tucked away here.\n */\nexport const MORE_INTEGRATION_SOURCES: ToolSource[] = [\n\tToolSource.Shipstation,\n\tToolSource.Integration,\n];\n\nconst MORE_INTEGRATION_SOURCE_SET = new Set<string>(MORE_INTEGRATION_SOURCES);\n\n/** True for a source shown under the \"More Integrations\" umbrella. */\nexport const isMoreIntegrationSource = (source: string): boolean =>\n\tMORE_INTEGRATION_SOURCE_SET.has(source);\n\n/**\n * Synthetic picker key / label / rank for the \"More Integrations\" umbrella row.\n * The rank lives here (not in {@link TOOL_SOURCE_RANK}) because that map is keyed\n * by the drift-guarded {@link ToolSource} enum — the backend's canonical wire\n * strings — and `more_integrations` is a picker-only key, not a real source.\n */\nexport const MORE_INTEGRATIONS_KEY = 'more_integrations';\nexport const MORE_INTEGRATIONS_LABEL = 'More Integrations';\n/** Always last — sits after every named top-level source (REST API, rank 8). */\nexport const MORE_INTEGRATIONS_RANK = 9;\n\nconst UNRANKED_SOURCE_RANK = Object.keys(TOOL_SOURCE_RANK).length;\n\n/** Sort rank for a source string; unknown sources rank after all known ones. */\nexport const toolSourceRank = (source: string): number =>\n\tTOOL_SOURCE_RANK[source as ToolSource] ?? UNRANKED_SOURCE_RANK;\n\n/**\n * `tool_key` of a configurable shared-drawer tool (email / Slack). Lives here (not\n * in AgentBuilder.model) so this leaf constants file has no back-edge to the model\n * — the dependency stays one-way (model → constants), avoiding a circular import.\n */\nexport type ConfigToolKey = 'send_email' | 'send_slack_message';\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","TOOL_SOURCE_RANK","INTEGRATION_SOURCES","INTEGRATION_SOURCE_SET","isIntegrationSource","source","MORE_INTEGRATION_SOURCES","MORE_INTEGRATION_SOURCE_SET","isMoreIntegrationSource","MORE_INTEGRATIONS_KEY","MORE_INTEGRATIONS_LABEL","MORE_INTEGRATIONS_RANK","UNRANKED_SOURCE_RANK","toolSourceRank","CONFIG_TOOL_SOURCES"],"mappings":"AAcO,MAAMA,IAAiD;AAAA,EAC7D,EAA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ACH,MACvCE,EAA4B,IAAIF,CAAM,GAQ1BI,IAAwB,qBACxBC,IAA0B,qBAE1BC,IAAyB,GAEhCC,IAAuB,OAAO,KAAKX,CAAgB,EAAE,QAG9CY,IAAiB,CAACR,MAC9BJ,EAAiBI,CAAoB,KAAKO,GAa9BE,IAAkE;AAAA,EAC7E,gBAA2B;AAAA,EAC3B,OAAmB;AACrB;"}
@@ -1,5 +1,6 @@
1
1
  import { ApplicationType } from '@bikdotai/bik-models/growth';
2
2
  import { default as React } from 'react';
3
+ import { VariableListInterfaceV3 } from '../../variable-picker-v3/model';
3
4
  import { AgentTool, AgentValue, ConfigToolKey, IntentOption, ModelOption, ParamsBlob, StepKey, StepValidation, SubAgentDraft, SubAgentRef } from '../AgentBuilder.model';
4
5
  import { AgentCharLimits } from '../constants/charLimits';
5
6
  import { ToolSource } from '../constants/tools';
@@ -81,6 +82,11 @@ export interface AgentBuilderContextShape {
81
82
  integrationStatus?: Partial<Record<ToolSource, boolean>>;
82
83
  /** Open the consumer's connect flow for an unconnected integration source. */
83
84
  onConnectIntegration?: (source: ToolSource) => void;
85
+ /**
86
+ * Variable catalog for the `@` picker's "Variables" view. Absent / empty →
87
+ * the category is hidden. Fed by the consumer via `variablesData`.
88
+ */
89
+ variablesData?: VariableListInterfaceV3[];
84
90
  /** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */
85
91
  applicationType?: ApplicationType;
86
92
  /** Resolved per-field character limits (consumer overrides merged over defaults). */
@@ -126,6 +132,7 @@ interface ProviderProps {
126
132
  configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
127
133
  integrationStatus?: Partial<Record<ToolSource, boolean>>;
128
134
  onConnectIntegration?: (source: ToolSource) => void;
135
+ variablesData?: VariableListInterfaceV3[];
129
136
  validation?: Partial<StepValidation>;
130
137
  applicationType?: ApplicationType;
131
138
  charLimits?: Partial<AgentCharLimits>;
@@ -1,15 +1,15 @@
1
- import { jsx as pt } from "react/jsx-runtime";
2
- import xt, { useState as h, useRef as l, useCallback as e, useMemo as B, useContext as Rt } from "react";
3
- import { AGENT_CHAR_LIMITS as Tt } from "../constants/charLimits.js";
4
- import { getStepIndex as At, STEP_KEYS as g } from "../constants/steps.js";
5
- const lt = xt.createContext(null), Ft = () => {
6
- const s = Rt(lt);
1
+ import { jsx as xt } from "react/jsx-runtime";
2
+ import Rt, { useState as h, useRef as l, useCallback as e, useMemo as B, useContext as Tt } from "react";
3
+ import { AGENT_CHAR_LIMITS as At } from "../constants/charLimits.js";
4
+ import { getStepIndex as _t, STEP_KEYS as g } from "../constants/steps.js";
5
+ const dt = Rt.createContext(null), Pt = () => {
6
+ const s = Tt(dt);
7
7
  if (!s)
8
8
  throw new Error(
9
9
  "useAgentBuilderContext must be used within an AgentBuilderProvider"
10
10
  );
11
11
  return s;
12
- }, _t = (s, r) => {
12
+ }, Mt = (s, r) => {
13
13
  const f = s.trigger.mode === "custom_intent" ? (s.trigger.custom_intent ?? "").trim().length > 0 : s.trigger.intents.length > 0;
14
14
  return {
15
15
  about: s.name.trim().length > 0 && s.name.length <= r.name && s.description.length <= r.description,
@@ -19,7 +19,7 @@ const lt = xt.createContext(null), Ft = () => {
19
19
  // Optional until specced further — never blocks go-live.
20
20
  handover: !0
21
21
  };
22
- }, Pt = ({
22
+ }, Et = ({
23
23
  value: s,
24
24
  onChange: r,
25
25
  activeStep: f,
@@ -31,76 +31,77 @@ const lt = xt.createContext(null), Ft = () => {
31
31
  configToolTemplates: $,
32
32
  integrationStatus: w,
33
33
  onConnectIntegration: H,
34
- validation: I,
35
- applicationType: L,
36
- charLimits: V,
37
- disableStepNavigation: b = !0,
38
- onCreateSubAgent: j,
39
- onFetchSubAgent: q,
40
- onUpdateSubAgent: y,
41
- onImproveSubAgent: K,
42
- onImproveToolInstructions: a,
43
- children: dt
34
+ variablesData: I,
35
+ validation: L,
36
+ applicationType: V,
37
+ charLimits: j,
38
+ disableStepNavigation: q = !0,
39
+ onCreateSubAgent: y,
40
+ onFetchSubAgent: K,
41
+ onUpdateSubAgent: b,
42
+ onImproveSubAgent: G,
43
+ onImproveToolInstructions: N,
44
+ children: gt
44
45
  }) => {
45
- const [gt, ft] = h("about"), T = f ?? gt, i = At(T), G = l(s);
46
- G.current = s;
47
- const [N, U] = h(0), M = l({}), Y = l("instructions"), z = e(
46
+ const [ft, mt] = h("about"), T = f ?? ft, i = _t(T), U = l(s);
47
+ U.current = s;
48
+ const [Y, z] = h(0), M = l({}), J = l("instructions"), Q = e(
48
49
  (t, o) => {
49
50
  o ? M.current[t] = o : delete M.current[t];
50
51
  },
51
52
  []
52
- ), D = e((t) => {
53
- Y.current = t;
54
- }, []), J = l(null), Q = e((t) => {
53
+ ), W = e((t) => {
55
54
  J.current = t;
56
- }, []), W = e(() => {
57
- J.current?.();
58
- }, []), X = l(
55
+ }, []), X = l(null), Z = e((t) => {
56
+ X.current = t;
57
+ }, []), k = e(() => {
58
+ X.current?.();
59
+ }, []), C = l(
59
60
  null
60
- ), Z = e(
61
+ ), D = e(
61
62
  (t) => {
62
- X.current = t;
63
+ C.current = t;
63
64
  },
64
65
  []
65
- ), k = e((t) => {
66
- X.current?.(t);
67
- }, []), C = e(
66
+ ), O = e((t) => {
67
+ C.current?.(t);
68
+ }, []), a = e(
68
69
  (t, o, c, p) => {
69
70
  const u = M.current;
70
- (u[Y.current] ?? u.instructions)?.(t, o, c, p);
71
+ (u[J.current] ?? u.instructions)?.(t, o, c, p);
71
72
  },
72
73
  []
73
- ), [O, S] = h(null), A = l(null), v = l(0), _ = B(
74
- () => ({ ...Tt, ...V }),
75
- [V]
74
+ ), [v, S] = h(null), A = l(null), tt = l(0), _ = B(
75
+ () => ({ ...At, ...j }),
76
+ [j]
76
77
  ), m = B(
77
- () => ({ ..._t(s, _), ...I }),
78
- [s, _, I]
78
+ () => ({ ...Mt(s, _), ...L }),
79
+ [s, _, L]
79
80
  ), d = e(
80
81
  (t) => {
81
82
  const o = g.indexOf(t);
82
- o > i && g.slice(0, o).some((c) => !m[c]) || (f === void 0 && ft(t), F?.(t));
83
+ o > i && g.slice(0, o).some((c) => !m[c]) || (f === void 0 && mt(t), F?.(t));
83
84
  },
84
85
  [f, F, i, m]
85
- ), tt = e(() => {
86
+ ), st = e(() => {
86
87
  const t = g[Math.min(i + 1, g.length - 1)];
87
88
  d(t);
88
- }, [i, d]), st = e(() => {
89
+ }, [i, d]), ot = e(() => {
89
90
  const t = g[Math.max(i - 1, 0)];
90
91
  d(t);
91
- }, [i, d]), ot = e(
92
+ }, [i, d]), nt = e(
92
93
  (t) => r(t),
93
94
  [r]
94
- ), nt = e(
95
+ ), et = e(
95
96
  (t, o) => r({ [t]: o }),
96
97
  [r]
97
- ), et = e(
98
+ ), rt = e(
98
99
  (t, o) => {
99
- const c = G.current;
100
+ const c = U.current;
100
101
  t === "tool" ? !((c.configTools ?? []).some((u) => u.id === o) || (c.restApiTools ?? []).some((u) => u.id === o)) && !c.tools.includes(o) && r({ tools: [...c.tools, o] }) : c.subagents.includes(o) || r({ subagents: [...c.subagents, o] });
101
102
  },
102
103
  [r]
103
- ), rt = e(
104
+ ), ct = e(
104
105
  (t, o) => {
105
106
  const c = t === "tool" ? `{{tool:${o}}}` : `{{subagent:${o}}}`, p = (n) => n.split(c).join("");
106
107
  A.current = {
@@ -124,35 +125,35 @@ const lt = xt.createContext(null), Ft = () => {
124
125
  )
125
126
  } : { subagents: s.subagents.filter((n) => n !== o) }
126
127
  };
127
- r(u), U((n) => n + 1);
128
- const ut = t === "tool" ? x.find((n) => n.tool_id === o)?.display_name ?? (s.restApiTools ?? []).find((n) => n.id === o)?.name ?? "Tool" : R.find((n) => n.id === o)?.name ?? "Sub-agent";
129
- v.current += 1, S({
130
- id: v.current,
131
- message: `${t === "tool" ? "Tool" : "Sub-agent"} "${ut}" removed`
128
+ r(u), z((n) => n + 1);
129
+ const lt = t === "tool" ? x.find((n) => n.tool_id === o)?.display_name ?? (s.restApiTools ?? []).find((n) => n.id === o)?.name ?? "Tool" : R.find((n) => n.id === o)?.name ?? "Sub-agent";
130
+ tt.current += 1, S({
131
+ id: tt.current,
132
+ message: `${t === "tool" ? "Tool" : "Sub-agent"} "${lt}" removed`
132
133
  });
133
134
  },
134
135
  [x, R, s, r]
135
- ), ct = e(() => {
136
- A.current && (r(A.current), A.current = null, U((t) => t + 1)), S(null);
137
- }, [r]), it = e(() => S(null), []), mt = B(
136
+ ), it = e(() => {
137
+ A.current && (r(A.current), A.current = null, z((t) => t + 1)), S(null);
138
+ }, [r]), ut = e(() => S(null), []), pt = B(
138
139
  () => ({
139
140
  value: s,
140
- patch: ot,
141
- updateField: nt,
142
- addReference: et,
143
- removeReference: rt,
144
- mentionResetKey: N,
145
- insertMention: C,
146
- registerMentionField: z,
147
- notifyMentionFocus: D,
148
- undoToast: O,
149
- undoRemoval: ct,
150
- dismissUndo: it,
141
+ patch: nt,
142
+ updateField: et,
143
+ addReference: rt,
144
+ removeReference: ct,
145
+ mentionResetKey: Y,
146
+ insertMention: a,
147
+ registerMentionField: Q,
148
+ notifyMentionFocus: W,
149
+ undoToast: v,
150
+ undoRemoval: it,
151
+ dismissUndo: ut,
151
152
  activeStep: T,
152
153
  activeIndex: i,
153
154
  goToStep: d,
154
- goNext: tt,
155
- goPrev: st,
155
+ goNext: st,
156
+ goPrev: ot,
156
157
  isFirstStep: i === 0,
157
158
  isLastStep: i === g.length - 1,
158
159
  validation: m,
@@ -164,37 +165,38 @@ const lt = xt.createContext(null), Ft = () => {
164
165
  configToolTemplates: $,
165
166
  integrationStatus: w,
166
167
  onConnectIntegration: H,
167
- applicationType: L,
168
+ variablesData: I,
169
+ applicationType: V,
168
170
  charLimits: _,
169
- disableStepNavigation: b,
170
- onCreateSubAgent: j,
171
- registerSubAgentCreator: Q,
172
- requestCreateSubAgent: W,
173
- registerToolActionHandler: Z,
174
- requestToolAction: k,
175
- onFetchSubAgent: q,
176
- onUpdateSubAgent: y,
177
- onImproveSubAgent: K,
178
- onImproveToolInstructions: a
171
+ disableStepNavigation: q,
172
+ onCreateSubAgent: y,
173
+ registerSubAgentCreator: Z,
174
+ requestCreateSubAgent: k,
175
+ registerToolActionHandler: D,
176
+ requestToolAction: O,
177
+ onFetchSubAgent: K,
178
+ onUpdateSubAgent: b,
179
+ onImproveSubAgent: G,
180
+ onImproveToolInstructions: N
179
181
  }),
180
182
  [
181
183
  s,
182
- ot,
183
184
  nt,
184
185
  et,
185
186
  rt,
186
- N,
187
- C,
188
- z,
189
- D,
190
- O,
191
187
  ct,
188
+ Y,
189
+ a,
190
+ Q,
191
+ W,
192
+ v,
192
193
  it,
194
+ ut,
193
195
  T,
194
196
  i,
195
197
  d,
196
- tt,
197
198
  st,
199
+ ot,
198
200
  m,
199
201
  x,
200
202
  R,
@@ -203,24 +205,25 @@ const lt = xt.createContext(null), Ft = () => {
203
205
  $,
204
206
  w,
205
207
  H,
206
- L,
208
+ I,
209
+ V,
207
210
  _,
208
- b,
209
- j,
210
- Q,
211
- W,
212
- Z,
213
- k,
214
211
  q,
215
212
  y,
213
+ Z,
214
+ k,
215
+ D,
216
+ O,
216
217
  K,
217
- a
218
+ b,
219
+ G,
220
+ N
218
221
  ]
219
222
  );
220
- return /* @__PURE__ */ pt(lt.Provider, { value: mt, children: dt });
223
+ return /* @__PURE__ */ xt(dt.Provider, { value: pt, children: gt });
221
224
  };
222
225
  export {
223
- Pt as AgentBuilderProvider,
224
- Ft as useAgentBuilderContext
226
+ Et as AgentBuilderProvider,
227
+ Pt as useAgentBuilderContext
225
228
  };
226
229
  //# sourceMappingURL=AgentBuilderContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tConfigToolKey,\n\tIntentOption,\n\tModelOption,\n\tParamsBlob,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\nimport type { ToolSource } from '../constants/tools';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n\t/** Tool source, for the chip's leading icon. Pass it for a JUST-created custom\n\t * tool that isn't in the editor's mention list yet (else the chip has no icon\n\t * until reload); existing tools resolve it from the list. */\n\tsource?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: MentionInsertFn;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/**\n\t * Backend templates for the shared-drawer tools (email / Slack), keyed by\n\t * `tool_key`. A present key drives its dynamic form + enables its tool action.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/**\n\t * Per-source integration connection state (today: Slack). A source mapped to\n\t * `false` renders a \"Connect\" row in the `@` picker instead of drilling in;\n\t * `true`/absent renders normally. Fed by the consumer via `integrationStatus`.\n\t */\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\t/** Open the consumer's connect flow for an unconnected integration source. */\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/**\n\t * Step 3 registers its \"open the drawer for this built-in tool action\"\n\t * (Rest API / email handover / Slack) handler here so the `@` reference picker\n\t * can trigger it. Pass `null` to unregister.\n\t */\n\tregisterToolActionHandler: (\n\t\tfn: ((source: ToolSource) => void) | null,\n\t) => void;\n\t/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */\n\trequestToolAction: (source: ToolSource) => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / email-handover tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tconfigToolTemplates,\n\tintegrationStatus,\n\tonConnectIntegration,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tonImproveToolInstructions,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\n\t// Step 3 registers a dispatcher that opens a built-in tool action's drawer.\n\tconst toolActionHandlerRef = useRef<((source: ToolSource) => void) | null>(\n\t\tnull,\n\t);\n\tconst registerToolActionHandler = useCallback(\n\t\t(fn: ((source: ToolSource) => void) | null) => {\n\t\t\ttoolActionHandlerRef.current = fn;\n\t\t},\n\t\t[],\n\t);\n\tconst requestToolAction = useCallback((source: ToolSource) => {\n\t\ttoolActionHandlerRef.current?.(source);\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>(\n\t\t(kind, id, label, source) => {\n\t\t\tconst inserters = mentionInsertersRef.current;\n\t\t\tconst target =\n\t\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\t\ttarget?.(kind, id, label, source);\n\t\t},\n\t\t[],\n\t);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\t// Forward jumps (side rail) must not skip past an incomplete step —\n\t\t\t// otherwise an agent with an empty step 3 could reach step 4 and be\n\t\t\t// published. Going back is always allowed.\n\t\t\tconst targetIndex = STEP_KEYS.indexOf(step);\n\t\t\tif (\n\t\t\t\ttargetIndex > activeIndex &&\n\t\t\t\tSTEP_KEYS.slice(0, targetIndex).some((k) => !validation[k])\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange, activeIndex, validation],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\t// Custom tools (Rest API / email / Slack) track themselves on their own\n\t\t\t\t// lists; only catalog/native ids belong in `tools`. Picking an EXISTING\n\t\t\t\t// custom tool from the `@` picker must not leak its id in here — on save\n\t\t\t\t// it becomes a bogus native ref and create-agent validation rejects it.\n\t\t\t\tconst isCustom =\n\t\t\t\t\t(v.configTools ?? []).some((t) => t.id === id) ||\n\t\t\t\t\t(v.restApiTools ?? []).some((t) => t.id === id);\n\t\t\t\tif (!isCustom && !v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot every field a removal touches, for undo. Custom tools (Rest\n\t\t\t// API / email / Slack) live on their own lists, so include them too.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tconfigTools: value.configTools,\n\t\t\t\trestApiTools: value.restApiTools,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t// A tool id may be a catalog tool OR an inline custom tool — drop\n\t\t\t\t\t\t\t// it from whichever list holds it (the others are no-op filters).\n\t\t\t\t\t\t\ttools: value.tools.filter((t) => t !== id),\n\t\t\t\t\t\t\tconfigTools: (value.configTools ?? []).filter((t) => t.id !== id),\n\t\t\t\t\t\t\trestApiTools: (value.restApiTools ?? []).filter(\n\t\t\t\t\t\t\t\t(t) => t.id !== id,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\t\t\t (value.restApiTools ?? []).find((t) => t.id === id)?.name ??\n\t\t\t\t\t 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","onConnectIntegration","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","toolActionHandlerRef","registerToolActionHandler","requestToolAction","source","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","charLimits","useMemo","AGENT_CHAR_LIMITS","validation","goToStep","step","targetIndex","STEP_KEYS","k","goNext","next","goPrev","prev","patch","partial","updateField","key","val","addReference","v","t","removeReference","token","strip","text","s","undoRemoval","dismissUndo"],"mappings":";;;;AAgKA,MAAMA,KACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,EAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CACxBC,GACAC,MACoB;AACpB,QAAMC,IACLF,EAAM,QAAQ,SAAS,mBACnBA,EAAM,QAAQ,iBAAiB,IAAI,KAAA,EAAO,SAAS,IACpDA,EAAM,QAAQ,QAAQ,SAAS;AAEnC,SAAO;AAAA,IACN,OACCA,EAAM,KAAK,KAAA,EAAO,SAAS,KAC3BA,EAAM,KAAK,UAAUC,EAAO,QAC5BD,EAAM,YAAY,UAAUC,EAAO;AAAA,IACpC,SAASC;AAAA;AAAA,IAET,UACCF,EAAM,aAAa,KAAA,EAAO,SAAS,MAClCA,EAAM,aAAa,IAAI,KAAA,EAAO,SAAS;AAAA;AAAA,IAEzC,UAAU;AAAA,EAAA;AAEZ,GA6BaG,KAAgD,CAAC;AAAA,EAC7D,OAAAH;AAAA,EACA,UAAAI;AAAA,EACA,YAAYC;AAAA,EACZ,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,iBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,uBAAAC,IAAwB;AAAA,EACxB,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAA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js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport type { VariableListInterfaceV3 } from '../../variable-picker-v3/model';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tConfigToolKey,\n\tIntentOption,\n\tModelOption,\n\tParamsBlob,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\nimport type { ToolSource } from '../constants/tools';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n\t/** Tool source, for the chip's leading icon. Pass it for a JUST-created custom\n\t * tool that isn't in the editor's mention list yet (else the chip has no icon\n\t * until reload); existing tools resolve it from the list. */\n\tsource?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: MentionInsertFn;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/**\n\t * Backend templates for the shared-drawer tools (email / Slack), keyed by\n\t * `tool_key`. A present key drives its dynamic form + enables its tool action.\n\t */\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\t/**\n\t * Per-source integration connection state (today: Slack). A source mapped to\n\t * `false` renders a \"Connect\" row in the `@` picker instead of drilling in;\n\t * `true`/absent renders normally. Fed by the consumer via `integrationStatus`.\n\t */\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\t/** Open the consumer's connect flow for an unconnected integration source. */\n\tonConnectIntegration?: (source: ToolSource) => void;\n\t/**\n\t * Variable catalog for the `@` picker's \"Variables\" view. Absent / empty →\n\t * the category is hidden. Fed by the consumer via `variablesData`.\n\t */\n\tvariablesData?: VariableListInterfaceV3[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/**\n\t * Step 3 registers its \"open the drawer for this built-in tool action\"\n\t * (Rest API / email handover / Slack) handler here so the `@` reference picker\n\t * can trigger it. Pass `null` to unregister.\n\t */\n\tregisterToolActionHandler: (\n\t\tfn: ((source: ToolSource) => void) | null,\n\t) => void;\n\t/** Open a built-in tool action's drawer (no-op until Step 3 registers it). */\n\trequestToolAction: (source: ToolSource) => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Optional \"Improve with AI\" for the Rest API / email-handover tool drawers. */\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tconfigToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;\n\tintegrationStatus?: Partial<Record<ToolSource, boolean>>;\n\tonConnectIntegration?: (source: ToolSource) => void;\n\tvariablesData?: VariableListInterfaceV3[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tonImproveToolInstructions?: (text: string) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tconfigToolTemplates,\n\tintegrationStatus,\n\tonConnectIntegration,\n\tvariablesData,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tonImproveToolInstructions,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\n\t// Step 3 registers a dispatcher that opens a built-in tool action's drawer.\n\tconst toolActionHandlerRef = useRef<((source: ToolSource) => void) | null>(\n\t\tnull,\n\t);\n\tconst registerToolActionHandler = useCallback(\n\t\t(fn: ((source: ToolSource) => void) | null) => {\n\t\t\ttoolActionHandlerRef.current = fn;\n\t\t},\n\t\t[],\n\t);\n\tconst requestToolAction = useCallback((source: ToolSource) => {\n\t\ttoolActionHandlerRef.current?.(source);\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>(\n\t\t(kind, id, label, source) => {\n\t\t\tconst inserters = mentionInsertersRef.current;\n\t\t\tconst target =\n\t\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\t\ttarget?.(kind, id, label, source);\n\t\t},\n\t\t[],\n\t);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\t// Forward jumps (side rail) must not skip past an incomplete step —\n\t\t\t// otherwise an agent with an empty step 3 could reach step 4 and be\n\t\t\t// published. Going back is always allowed.\n\t\t\tconst targetIndex = STEP_KEYS.indexOf(step);\n\t\t\tif (\n\t\t\t\ttargetIndex > activeIndex &&\n\t\t\t\tSTEP_KEYS.slice(0, targetIndex).some((k) => !validation[k])\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange, activeIndex, validation],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\t// Custom tools (Rest API / email / Slack) track themselves on their own\n\t\t\t\t// lists; only catalog/native ids belong in `tools`. Picking an EXISTING\n\t\t\t\t// custom tool from the `@` picker must not leak its id in here — on save\n\t\t\t\t// it becomes a bogus native ref and create-agent validation rejects it.\n\t\t\t\tconst isCustom =\n\t\t\t\t\t(v.configTools ?? []).some((t) => t.id === id) ||\n\t\t\t\t\t(v.restApiTools ?? []).some((t) => t.id === id);\n\t\t\t\tif (!isCustom && !v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot every field a removal touches, for undo. Custom tools (Rest\n\t\t\t// API / email / Slack) live on their own lists, so include them too.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tconfigTools: value.configTools,\n\t\t\t\trestApiTools: value.restApiTools,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t// A tool id may be a catalog tool OR an inline custom tool — drop\n\t\t\t\t\t\t\t// it from whichever list holds it (the others are no-op filters).\n\t\t\t\t\t\t\ttools: value.tools.filter((t) => t !== id),\n\t\t\t\t\t\t\tconfigTools: (value.configTools ?? []).filter((t) => t.id !== id),\n\t\t\t\t\t\t\trestApiTools: (value.restApiTools ?? []).filter(\n\t\t\t\t\t\t\t\t(t) => t.id !== id,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ??\n\t\t\t\t\t (value.restApiTools ?? []).find((t) => t.id === id)?.name ??\n\t\t\t\t\t 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tvariablesData,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tconfigToolTemplates,\n\t\t\tintegrationStatus,\n\t\t\tonConnectIntegration,\n\t\t\tvariablesData,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tregisterToolActionHandler,\n\t\t\trequestToolAction,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t\tonImproveToolInstructions,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","configToolTemplates","integrationStatus","onConnectIntegration","variablesData","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","onImproveToolInstructions","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","toolActionHandlerRef","registerToolActionHandler","requestToolAction","source","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","charLimits","useMemo","AGENT_CHAR_LIMITS","validation","goToStep","step","targetIndex","STEP_KEYS","k","goNext","next","goPrev","prev","patch","partial","updateField","key","val","addReference","v","t","removeReference","token","strip","text","s","undoRemoval","dismissUndo"],"mappings":";;;;AAsKA,MAAMA,KACLC,GAAM,cAA+C,IAAI,GAE7CC,KAAyB,MAAgC;AACrE,QAAMC,IAAMC,GAAWJ,EAAmB;AAC1C,MAAI,CAACG;AACJ,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAGF,SAAOA;AACR,GAGME,KAAmB,CACxBC,GACAC,MACoB;AACpB,QAAMC,IACLF,EAAM,QAAQ,SAAS,mBACnBA,EAAM,QAAQ,iBAAiB,IAAI,KAAA,EAAO,SAAS,IACpDA,EAAM,QAAQ,QAAQ,SAAS;AAEnC,SAAO;AAAA,IACN,OACCA,EAAM,KAAK,KAAA,EAAO,SAAS,KAC3BA,EAAM,KAAK,UAAUC,EAAO,QAC5BD,EAAM,YAAY,UAAUC,EAAO;AAAA,IACpC,SAASC;AAAA;AAAA,IAET,UACCF,EAAM,aAAa,KAAA,EAAO,SAAS,MACl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