@bikdotai/bik-component-library 0.0.830 → 0.0.831-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
  2. package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +17 -65
  4. package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +41 -0
  6. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -0
  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/DrawerHeaderText.js +15 -0
  10. package/dist/cjs/components/agent-builder/components/DrawerHeaderText.js.map +1 -0
  11. package/dist/cjs/components/agent-builder/components/MentionEditor.js +1 -1
  12. package/dist/cjs/components/agent-builder/components/MentionEditor.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/components/MentionField.js +1 -1
  14. package/dist/cjs/components/agent-builder/components/MentionField.js.map +1 -1
  15. package/dist/cjs/components/agent-builder/components/MentionPicker.js +20 -20
  16. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +23 -0
  18. package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -0
  19. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +5 -5
  20. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  21. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +5 -0
  22. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -0
  23. package/dist/cjs/components/agent-builder/constants/tools.js +2 -0
  24. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -0
  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 +3 -3
  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/side-modal/SideModal.style.js +11 -10
  34. package/dist/cjs/components/side-modal/SideModal.style.js.map +1 -1
  35. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  36. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  37. package/dist/cjs/index.js +1 -1
  38. package/dist/esm/components/agent-builder/AgentBuilder.js +100 -96
  39. package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
  40. package/dist/esm/components/agent-builder/AgentBuilder.model.d.ts +144 -1
  41. package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +0 -21
  42. package/dist/esm/components/agent-builder/AgentBuilder.styled.js +42 -111
  43. package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
  44. package/dist/esm/components/agent-builder/components/ConfigToolPanel.d.ts +33 -0
  45. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +251 -0
  46. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -0
  47. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.d.ts +9 -1
  48. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +318 -219
  49. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  50. package/dist/esm/components/agent-builder/components/DrawerHeaderText.d.ts +33 -0
  51. package/dist/esm/components/agent-builder/components/DrawerHeaderText.js +42 -0
  52. package/dist/esm/components/agent-builder/components/DrawerHeaderText.js.map +1 -0
  53. package/dist/esm/components/agent-builder/components/MentionEditor.d.ts +6 -0
  54. package/dist/esm/components/agent-builder/components/MentionEditor.js +38 -30
  55. package/dist/esm/components/agent-builder/components/MentionEditor.js.map +1 -1
  56. package/dist/esm/components/agent-builder/components/MentionField.js +76 -51
  57. package/dist/esm/components/agent-builder/components/MentionField.js.map +1 -1
  58. package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +7 -0
  59. package/dist/esm/components/agent-builder/components/MentionPicker.js +162 -145
  60. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  61. package/dist/esm/components/agent-builder/components/RestApiToolPanel.d.ts +27 -0
  62. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +270 -0
  63. package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -0
  64. package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +14 -0
  65. package/dist/esm/components/agent-builder/components/SelectableListSection.js +166 -140
  66. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  67. package/dist/esm/components/agent-builder/components/ToolInstructionsField.d.ts +19 -0
  68. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +66 -0
  69. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -0
  70. package/dist/esm/components/agent-builder/constants/tools.d.ts +77 -0
  71. package/dist/esm/components/agent-builder/constants/tools.js +34 -0
  72. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -0
  73. package/dist/esm/components/agent-builder/context/AgentBuilderContext.d.ts +19 -1
  74. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +169 -140
  75. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  76. package/dist/esm/components/agent-builder/index.d.ts +2 -1
  77. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +241 -141
  78. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  79. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +18 -3
  80. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +81 -62
  81. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  82. package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +15 -9
  83. package/dist/esm/components/agent-builder/utils/sourceIcons.js +16 -8
  84. package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
  85. package/dist/esm/components/side-modal/SideModal.style.js +1 -0
  86. package/dist/esm/components/side-modal/SideModal.style.js.map +1 -1
  87. package/dist/esm/editor/extensions/mention/MentionExtension.js +60 -57
  88. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  89. package/dist/esm/index.js +97 -95
  90. package/dist/esm/index.js.map +1 -1
  91. package/package.json +1 -1
@@ -0,0 +1,77 @@
1
+ import { FunctionComponent, SVGAttributes } from 'react';
2
+ import { ConfigToolKey } from '../AgentBuilder.model';
3
+ /**
4
+ * Static tool-related constants for the builder's Step 3 (tools & sub-agents):
5
+ * the reference-picker category tabs and the per-source display labels. Kept here
6
+ * (rather than inline in the picker / serialization utils) so the labels a user
7
+ * sees are all in one obvious place.
8
+ */
9
+ /** A reference-picker category tab. */
10
+ export type Category = 'tool' | 'subagent';
11
+ /** Category tabs shown at the root of the `@` reference picker. */
12
+ export declare const CATEGORIES: {
13
+ key: Category;
14
+ label: string;
15
+ }[];
16
+ /**
17
+ * Every tool "source" the builder renders an icon / label / picker entry for.
18
+ * Enum VALUES are the backend's canonical read-only `source` wire strings
19
+ * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the
20
+ * configurable tools are `email_handover` / `rest_api` / `slack`, every native
21
+ * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources
22
+ * kept for back-compat (the backend now collapses natives to `manifest`).
23
+ * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and
24
+ * `sourceIcon`.
25
+ */
26
+ export declare enum ToolSource {
27
+ Manifest = "manifest",
28
+ Shopify = "shopify",
29
+ Integration = "integration",
30
+ RestApi = "rest_api",
31
+ EmailHandover = "email_handover",
32
+ Slack = "slack"
33
+ }
34
+ /**
35
+ * Display labels for the known tool sources — the CATEGORY/integration name, used
36
+ * for the picker's source headers (drill-in groups), the empty-state source
37
+ * buttons and the mention-chip prefix. A source is a category ("Slack") you drill
38
+ * into; the specific addable action inside it ("Send Slack message") is
39
+ * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see
40
+ * `toolSourceLabel`).
41
+ */
42
+ export declare const TOOL_SOURCE_LABELS: Record<ToolSource, string>;
43
+ /**
44
+ * The addable action inside a configurable/rest source — shown as the "add" row
45
+ * in the `@` picker (below any existing instances) and the empty-state button.
46
+ * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in
47
+ * (e.g. category "Slack" → action "Send Slack message").
48
+ */
49
+ export declare const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>>;
50
+ /** A tool source's brand-glyph component. */
51
+ export type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;
52
+ /** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */
53
+ export interface SourceIcon {
54
+ Icon: IconComp;
55
+ w: number;
56
+ h: number;
57
+ }
58
+ /**
59
+ * A built-in "tool" that opens a config drawer (Rest API / email handover /
60
+ * Slack) rather than inserting a mention. Surfaced as an empty-state source
61
+ * button in the Tools section and as a row in the `@`-picker Tools view; picking
62
+ * it opens the drawer and never writes into the instructions text.
63
+ */
64
+ export interface ToolAction {
65
+ source: ToolSource;
66
+ label: string;
67
+ icon?: SourceIcon;
68
+ /** Open this tool's config drawer. */
69
+ onSelect: () => void;
70
+ }
71
+ /** Sources of the built-in drawer tools, in display order. */
72
+ export declare const TOOL_ACTION_SOURCES: ToolSource[];
73
+ /**
74
+ * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each
75
+ * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.
76
+ */
77
+ export declare const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>>;
@@ -0,0 +1,34 @@
1
+ const s = [
2
+ { key: "tool", label: "Tools" },
3
+ { key: "subagent", label: "Sub-agent" }
4
+ ];
5
+ var e = /* @__PURE__ */ ((a) => (a.Manifest = "manifest", a.Shopify = "shopify", a.Integration = "integration", a.RestApi = "rest_api", a.EmailHandover = "email_handover", a.Slack = "slack", a))(e || {});
6
+ const n = {
7
+ manifest: "Manifest",
8
+ shopify: "Shopify",
9
+ integration: "Integration",
10
+ rest_api: "Rest API",
11
+ email_handover: "Email",
12
+ slack: "Slack"
13
+ }, t = {
14
+ rest_api: "REST API",
15
+ email_handover: "Handover to email",
16
+ slack: "Send Slack message"
17
+ }, i = [
18
+ "rest_api",
19
+ "email_handover",
20
+ "slack"
21
+ /* Slack */
22
+ ], _ = {
23
+ email_handover: "send_email",
24
+ slack: "send_slack_message"
25
+ };
26
+ export {
27
+ s as CATEGORIES,
28
+ _ as CONFIG_TOOL_SOURCES,
29
+ t as TOOL_ACTION_LABELS,
30
+ i as TOOL_ACTION_SOURCES,
31
+ n as TOOL_SOURCE_LABELS,
32
+ e as ToolSource
33
+ };
34
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sources":["../../../../../src/components/agent-builder/constants/tools.ts"],"sourcesContent":["import type { FunctionComponent, SVGAttributes } from 'react';\nimport type { ConfigToolKey } from '../AgentBuilder.model';\n\n/**\n * Static tool-related constants for the builder's Step 3 (tools & sub-agents):\n * the reference-picker category tabs and the per-source display labels. Kept here\n * (rather than inline in the picker / serialization utils) so the labels a user\n * sees are all in one obvious place.\n */\n\n/** A reference-picker category tab. */\nexport type Category = 'tool' | 'subagent';\n\n/** Category tabs shown at the root of the `@` reference picker. */\nexport const CATEGORIES: { key: Category; label: string }[] = [\n\t{ key: 'tool', label: 'Tools' },\n\t{ key: 'subagent', label: 'Sub-agent' },\n];\n\n/**\n * Every tool \"source\" the builder renders an icon / label / picker entry for.\n * Enum VALUES are the backend's canonical read-only `source` wire strings\n * (`app/agents/config/schema.py` → `ToolSource`, derived from `tool_key`): the\n * configurable tools are `email_handover` / `rest_api` / `slack`, every native\n * tool is `manifest`. `shopify` / `integration` are legacy bik-models sources\n * kept for back-compat (the backend now collapses natives to `manifest`).\n * Dynamic/unknown sources are looked up leniently — see `toolSourceLabel` and\n * `sourceIcon`.\n */\nexport enum ToolSource {\n\tManifest = 'manifest',\n\tShopify = 'shopify',\n\tIntegration = 'integration',\n\tRestApi = 'rest_api',\n\tEmailHandover = 'email_handover',\n\tSlack = 'slack',\n}\n\n/**\n * Display labels for the known tool sources — the CATEGORY/integration name, used\n * for the picker's source headers (drill-in groups), the empty-state source\n * buttons and the mention-chip prefix. A source is a category (\"Slack\") you drill\n * into; the specific addable action inside it (\"Send Slack message\") is\n * `TOOL_ACTION_LABELS`. Unknown sources fall back to the raw key (see\n * `toolSourceLabel`).\n */\nexport const TOOL_SOURCE_LABELS: Record<ToolSource, string> = {\n\t[ToolSource.Manifest]: 'Manifest',\n\t[ToolSource.Shopify]: 'Shopify',\n\t[ToolSource.Integration]: 'Integration',\n\t[ToolSource.RestApi]: 'Rest API',\n\t[ToolSource.EmailHandover]: 'Email',\n\t[ToolSource.Slack]: 'Slack',\n};\n\n/**\n * The addable action inside a configurable/rest source — shown as the \"add\" row\n * in the `@` picker (below any existing instances) and the empty-state button.\n * Distinct from `TOOL_SOURCE_LABELS`, which names the category the action lives in\n * (e.g. category \"Slack\" → action \"Send Slack message\").\n */\nexport const TOOL_ACTION_LABELS: Partial<Record<ToolSource, string>> = {\n\t[ToolSource.RestApi]: 'REST API',\n\t[ToolSource.EmailHandover]: 'Handover to email',\n\t[ToolSource.Slack]: 'Send Slack message',\n};\n\n/** A tool source's brand-glyph component. */\nexport type IconComp = FunctionComponent<SVGAttributes<SVGElement>>;\n\n/** Brand glyph for a tool source, with its own size so each keeps its aspect ratio. */\nexport interface SourceIcon {\n\tIcon: IconComp;\n\tw: number;\n\th: number;\n}\n\n/**\n * A built-in \"tool\" that opens a config drawer (Rest API / email handover /\n * Slack) rather than inserting a mention. Surfaced as an empty-state source\n * button in the Tools section and as a row in the `@`-picker Tools view; picking\n * it opens the drawer and never writes into the instructions text.\n */\nexport interface ToolAction {\n\tsource: ToolSource;\n\tlabel: string;\n\ticon?: SourceIcon;\n\t/** Open this tool's config drawer. */\n\tonSelect: () => void;\n}\n\n/** Sources of the built-in drawer tools, in display order. */\nexport const TOOL_ACTION_SOURCES: ToolSource[] = [\n\tToolSource.RestApi,\n\tToolSource.EmailHandover,\n\tToolSource.Slack,\n];\n\n/**\n * Drawer sources rendered by the shared dynamic panel (`ConfigToolPanel`), each\n * mapped to its backend `tool_key`. Rest API is absent — it has a bespoke panel.\n */\nexport const CONFIG_TOOL_SOURCES: Partial<Record<ToolSource, ConfigToolKey>> = {\n\t[ToolSource.EmailHandover]: 'send_email',\n\t[ToolSource.Slack]: 'send_slack_message',\n};\n"],"names":["CATEGORIES","ToolSource","TOOL_SOURCE_LABELS","TOOL_ACTION_LABELS","TOOL_ACTION_SOURCES","CONFIG_TOOL_SOURCES"],"mappings":"AAcO,MAAMA,IAAiD;AAAA,EAC7D,EAAE,KAAK,QAAQ,OAAO,QAAA;AAAA,EACtB,EAAE,KAAK,YAAY,OAAO,YAAA;AAC3B;AAYO,IAAKC,sBAAAA,OACXA,EAAA,WAAW,YACXA,EAAA,UAAU,WACVA,EAAA,cAAc,eACdA,EAAA,UAAU,YACVA,EAAA,gBAAgB,kBAChBA,EAAA,QAAQ,SANGA,IAAAA,KAAA,CAAA,CAAA;AAiBL,MAAMC,IAAiD;AAAA,EAC5D,UAAsB;AAAA,EACtB,SAAqB;AAAA,EACrB,aAAyB;AAAA,EACzB,UAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AACrB,GAQaC,IAA0D;AAAA,EACrE,UAAqB;AAAA,EACrB,gBAA2B;AAAA,EAC3B,OAAmB;AACrB,GA2BaC,IAAoC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA;AACD,GAMaC,IAAkE;AAAA,EAC7E,gBAA2B;AAAA,EAC3B,OAAmB;AACrB;"}
@@ -1,7 +1,8 @@
1
1
  import { ApplicationType } from '@bikdotai/bik-models/growth';
2
2
  import { default as React } from 'react';
3
- import { AgentTool, AgentValue, IntentOption, ModelOption, StepKey, StepValidation, SubAgentDraft, SubAgentRef } from '../AgentBuilder.model';
3
+ import { AgentTool, AgentValue, ConfigToolKey, IntentOption, ModelOption, ParamsBlob, StepKey, StepValidation, SubAgentDraft, SubAgentRef } from '../AgentBuilder.model';
4
4
  import { AgentCharLimits } from '../constants/charLimits';
5
+ import { ToolSource } from '../constants/tools';
5
6
  /** Mention-capable text fields in Step 3 (both store firebase token text). */
6
7
  export type MentionFieldKey = 'instructions' | 'guardrail';
7
8
  type MentionInsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;
@@ -63,6 +64,11 @@ export interface AgentBuilderContextShape {
63
64
  availableSubAgents: SubAgentRef[];
64
65
  availableIntents: IntentOption[];
65
66
  availableModels: ModelOption[];
67
+ /**
68
+ * Backend templates for the shared-drawer tools (email / Slack), keyed by
69
+ * `tool_key`. A present key drives its dynamic form + enables its tool action.
70
+ */
71
+ configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
66
72
  /** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */
67
73
  applicationType?: ApplicationType;
68
74
  /** Resolved per-field character limits (consumer overrides merged over defaults). */
@@ -78,12 +84,22 @@ export interface AgentBuilderContextShape {
78
84
  registerSubAgentCreator: (fn: (() => void) | null) => void;
79
85
  /** Open the create-sub-agent drawer (no-op until Step 3 registers it). */
80
86
  requestCreateSubAgent: () => void;
87
+ /**
88
+ * Step 3 registers its "open the drawer for this built-in tool action"
89
+ * (Rest API / email handover / Slack) handler here so the `@` reference picker
90
+ * can trigger it. Pass `null` to unregister.
91
+ */
92
+ registerToolActionHandler: (fn: ((source: ToolSource) => void) | null) => void;
93
+ /** Open a built-in tool action's drawer (no-op until Step 3 registers it). */
94
+ requestToolAction: (source: ToolSource) => void;
81
95
  /** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */
82
96
  onFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;
83
97
  /** Persist edits to an existing sub-agent. */
84
98
  onUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;
85
99
  /** Optional "Improve with AI" for the drawer's instructions / guardrails. */
86
100
  onImproveSubAgent?: (kind: 'instructions' | 'guardrail', text: string) => Promise<string>;
101
+ /** Optional "Improve with AI" for the Rest API / email-handover tool drawers. */
102
+ onImproveToolInstructions?: (text: string) => Promise<string>;
87
103
  }
88
104
  export declare const useAgentBuilderContext: () => AgentBuilderContextShape;
89
105
  interface ProviderProps {
@@ -95,6 +111,7 @@ interface ProviderProps {
95
111
  availableSubAgents: SubAgentRef[];
96
112
  availableIntents: IntentOption[];
97
113
  availableModels: ModelOption[];
114
+ configToolTemplates?: Partial<Record<ConfigToolKey, ParamsBlob>>;
98
115
  validation?: Partial<StepValidation>;
99
116
  applicationType?: ApplicationType;
100
117
  charLimits?: Partial<AgentCharLimits>;
@@ -103,6 +120,7 @@ interface ProviderProps {
103
120
  onFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;
104
121
  onUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;
105
122
  onImproveSubAgent?: (kind: 'instructions' | 'guardrail', text: string) => Promise<string>;
123
+ onImproveToolInstructions?: (text: string) => Promise<string>;
106
124
  children: React.ReactNode;
107
125
  }
108
126
  export declare const AgentBuilderProvider: React.FC<ProviderProps>;
@@ -1,187 +1,216 @@
1
- import { jsx as it } from "react/jsx-runtime";
2
- import ut, { useState as h, useRef as d, useCallback as r, useMemo as B, useContext as dt } from "react";
3
- import { AGENT_CHAR_LIMITS as gt } from "../constants/charLimits.js";
4
- import { getStepIndex as mt, STEP_KEYS as _ } from "../constants/steps.js";
5
- const nt = ut.createContext(null), _t = () => {
6
- const n = dt(nt);
7
- if (!n)
1
+ import { jsx as ft } from "react/jsx-runtime";
2
+ import mt, { useState as S, useRef as u, useCallback as e, useMemo as h, useContext as pt } from "react";
3
+ import { AGENT_CHAR_LIMITS as xt } from "../constants/charLimits.js";
4
+ import { getStepIndex as Rt, STEP_KEYS as A } from "../constants/steps.js";
5
+ const ct = mt.createContext(null), ht = () => {
6
+ const t = pt(ct);
7
+ if (!t)
8
8
  throw new Error(
9
9
  "useAgentBuilderContext must be used within an AgentBuilderProvider"
10
10
  );
11
- return n;
12
- }, lt = (n, s) => {
13
- const g = n.trigger.mode === "custom_intent" ? (n.trigger.custom_intent ?? "").trim().length > 0 : n.trigger.intents.length > 0;
11
+ return t;
12
+ }, At = (t, r) => {
13
+ const d = t.trigger.mode === "custom_intent" ? (t.trigger.custom_intent ?? "").trim().length > 0 : t.trigger.intents.length > 0;
14
14
  return {
15
- about: n.name.trim().length > 0 && n.name.length <= s.name && n.description.length <= s.description,
16
- trigger: g,
15
+ about: t.name.trim().length > 0 && t.name.length <= r.name && t.description.length <= r.description,
16
+ trigger: d,
17
17
  // At least one of Instructions / Guardrails must be filled.
18
- response: n.instructions.trim().length > 0 || (n.guardrail ?? "").trim().length > 0,
18
+ response: t.instructions.trim().length > 0 || (t.guardrail ?? "").trim().length > 0,
19
19
  // Optional until specced further — never blocks go-live.
20
20
  handover: !0
21
21
  };
22
- }, Mt = ({
23
- value: n,
24
- onChange: s,
25
- activeStep: g,
26
- onStepChange: F,
27
- availableTools: l,
28
- availableSubAgents: f,
29
- availableIntents: I,
22
+ }, Bt = ({
23
+ value: t,
24
+ onChange: r,
25
+ activeStep: d,
26
+ onStepChange: B,
27
+ availableTools: f,
28
+ availableSubAgents: m,
29
+ availableIntents: F,
30
30
  availableModels: P,
31
- validation: A,
32
- applicationType: E,
33
- charLimits: T,
34
- disableStepNavigation: $ = !0,
35
- onCreateSubAgent: w,
31
+ configToolTemplates: E,
32
+ validation: $,
33
+ applicationType: a,
34
+ charLimits: w,
35
+ disableStepNavigation: H = !0,
36
+ onCreateSubAgent: I,
36
37
  onFetchSubAgent: L,
37
38
  onUpdateSubAgent: V,
38
39
  onImproveSubAgent: b,
39
- children: et
40
+ onImproveToolInstructions: j,
41
+ children: it
40
42
  }) => {
41
- const [st, rt] = h("about"), x = g ?? st, c = mt(x), j = d(n);
42
- j.current = n;
43
- const [y, K] = h(0), M = d({}), q = d("instructions"), G = r(
44
- (t, e) => {
45
- e ? M.current[t] = e : delete M.current[t];
43
+ const [ut, lt] = S("about"), p = d ?? ut, c = Rt(p), q = u(t);
44
+ q.current = t;
45
+ const [y, K] = S(0), T = u({}), G = u("instructions"), N = e(
46
+ (n, o) => {
47
+ o ? T.current[n] = o : delete T.current[n];
46
48
  },
47
49
  []
48
- ), H = r((t) => {
49
- q.current = t;
50
- }, []), N = d(null), U = r((t) => {
51
- N.current = t;
52
- }, []), Y = r(() => {
53
- N.current?.();
54
- }, []), z = r((t, e, i) => {
55
- const m = M.current;
56
- (m[q.current] ?? m.instructions)?.(t, e, i);
57
- }, []), [D, S] = h(null), p = d(null), J = d(0), u = r(
58
- (t) => {
59
- g === void 0 && rt(t), F?.(t);
50
+ ), U = e((n) => {
51
+ G.current = n;
52
+ }, []), Y = u(null), z = e((n) => {
53
+ Y.current = n;
54
+ }, []), D = e(() => {
55
+ Y.current?.();
56
+ }, []), J = u(
57
+ null
58
+ ), Q = e(
59
+ (n) => {
60
+ J.current = n;
60
61
  },
61
- [g, F]
62
- ), Q = r(() => {
63
- const t = _[Math.min(c + 1, _.length - 1)];
64
- u(t);
65
- }, [c, u]), W = r(() => {
66
- const t = _[Math.max(c - 1, 0)];
67
- u(t);
68
- }, [c, u]), X = r(
69
- (t) => s(t),
70
- [s]
71
- ), Z = r(
72
- (t, e) => s({ [t]: e }),
73
- [s]
74
- ), k = r(
75
- (t, e) => {
76
- const i = j.current;
77
- t === "tool" ? i.tools.includes(e) || s({ tools: [...i.tools, e] }) : i.subagents.includes(e) || s({ subagents: [...i.subagents, e] });
62
+ []
63
+ ), W = e((n) => {
64
+ J.current?.(n);
65
+ }, []), X = e((n, o, i) => {
66
+ const g = T.current;
67
+ (g[G.current] ?? g.instructions)?.(n, o, i);
68
+ }, []), [Z, _] = S(null), x = u(null), k = u(0), l = e(
69
+ (n) => {
70
+ d === void 0 && lt(n), B?.(n);
71
+ },
72
+ [d, B]
73
+ ), C = e(() => {
74
+ const n = A[Math.min(c + 1, A.length - 1)];
75
+ l(n);
76
+ }, [c, l]), O = e(() => {
77
+ const n = A[Math.max(c - 1, 0)];
78
+ l(n);
79
+ }, [c, l]), v = e(
80
+ (n) => r(n),
81
+ [r]
82
+ ), tt = e(
83
+ (n, o) => r({ [n]: o }),
84
+ [r]
85
+ ), nt = e(
86
+ (n, o) => {
87
+ const i = q.current;
88
+ n === "tool" ? i.tools.includes(o) || r({ tools: [...i.tools, o] }) : i.subagents.includes(o) || r({ subagents: [...i.subagents, o] });
78
89
  },
79
- [s]
80
- ), C = r(
81
- (t, e) => {
82
- const i = t === "tool" ? `{{tool:${e}}}` : `{{subagent:${e}}}`, m = (o) => o.split(i).join("");
83
- p.current = {
84
- tools: n.tools,
85
- subagents: n.subagents,
86
- instructions: n.instructions,
87
- guardrail: n.guardrail
90
+ [r]
91
+ ), ot = e(
92
+ (n, o) => {
93
+ const i = n === "tool" ? `{{tool:${o}}}` : `{{subagent:${o}}}`, g = (s) => s.split(i).join("");
94
+ x.current = {
95
+ tools: t.tools,
96
+ subagents: t.subagents,
97
+ configTools: t.configTools,
98
+ restApiTools: t.restApiTools,
99
+ instructions: t.instructions,
100
+ guardrail: t.guardrail
88
101
  };
89
- const tt = {
90
- instructions: m(n.instructions),
91
- guardrail: m(n.guardrail ?? ""),
92
- ...t === "tool" ? { tools: n.tools.filter((o) => o !== e) } : { subagents: n.subagents.filter((o) => o !== e) }
102
+ const rt = {
103
+ instructions: g(t.instructions),
104
+ guardrail: g(t.guardrail ?? ""),
105
+ ...n === "tool" ? {
106
+ // A tool id may be a catalog tool OR an inline custom tool — drop
107
+ // it from whichever list holds it (the others are no-op filters).
108
+ tools: t.tools.filter((s) => s !== o),
109
+ configTools: (t.configTools ?? []).filter((s) => s.id !== o),
110
+ restApiTools: (t.restApiTools ?? []).filter(
111
+ (s) => s.id !== o
112
+ )
113
+ } : { subagents: t.subagents.filter((s) => s !== o) }
93
114
  };
94
- s(tt), K((o) => o + 1);
95
- const ct = t === "tool" ? l.find((o) => o.tool_id === e)?.display_name ?? "Tool" : f.find((o) => o.id === e)?.name ?? "Sub-agent";
96
- J.current += 1, S({
97
- id: J.current,
98
- message: `${t === "tool" ? "Tool" : "Sub-agent"} "${ct}" removed`
115
+ r(rt), K((s) => s + 1);
116
+ const gt = n === "tool" ? f.find((s) => s.tool_id === o)?.display_name ?? (t.restApiTools ?? []).find((s) => s.id === o)?.name ?? "Tool" : m.find((s) => s.id === o)?.name ?? "Sub-agent";
117
+ k.current += 1, _({
118
+ id: k.current,
119
+ message: `${n === "tool" ? "Tool" : "Sub-agent"} "${gt}" removed`
99
120
  });
100
121
  },
101
- [l, f, n, s]
102
- ), O = r(() => {
103
- p.current && (s(p.current), p.current = null, K((t) => t + 1)), S(null);
104
- }, [s]), v = r(() => S(null), []), R = B(
105
- () => ({ ...gt, ...T }),
106
- [T]
107
- ), a = B(
108
- () => ({ ...lt(n, R), ...A }),
109
- [n, R, A]
110
- ), ot = B(
122
+ [f, m, t, r]
123
+ ), st = e(() => {
124
+ x.current && (r(x.current), x.current = null, K((n) => n + 1)), _(null);
125
+ }, [r]), et = e(() => _(null), []), R = h(
126
+ () => ({ ...xt, ...w }),
127
+ [w]
128
+ ), M = h(
129
+ () => ({ ...At(t, R), ...$ }),
130
+ [t, R, $]
131
+ ), dt = h(
111
132
  () => ({
112
- value: n,
113
- patch: X,
114
- updateField: Z,
115
- addReference: k,
116
- removeReference: C,
133
+ value: t,
134
+ patch: v,
135
+ updateField: tt,
136
+ addReference: nt,
137
+ removeReference: ot,
117
138
  mentionResetKey: y,
118
- insertMention: z,
119
- registerMentionField: G,
120
- notifyMentionFocus: H,
121
- undoToast: D,
122
- undoRemoval: O,
123
- dismissUndo: v,
124
- activeStep: x,
139
+ insertMention: X,
140
+ registerMentionField: N,
141
+ notifyMentionFocus: U,
142
+ undoToast: Z,
143
+ undoRemoval: st,
144
+ dismissUndo: et,
145
+ activeStep: p,
125
146
  activeIndex: c,
126
- goToStep: u,
127
- goNext: Q,
128
- goPrev: W,
147
+ goToStep: l,
148
+ goNext: C,
149
+ goPrev: O,
129
150
  isFirstStep: c === 0,
130
- isLastStep: c === _.length - 1,
131
- validation: a,
132
- isActiveStepValid: a[x],
133
- availableTools: l,
134
- availableSubAgents: f,
135
- availableIntents: I,
151
+ isLastStep: c === A.length - 1,
152
+ validation: M,
153
+ isActiveStepValid: M[p],
154
+ availableTools: f,
155
+ availableSubAgents: m,
156
+ availableIntents: F,
136
157
  availableModels: P,
137
- applicationType: E,
158
+ configToolTemplates: E,
159
+ applicationType: a,
138
160
  charLimits: R,
139
- disableStepNavigation: $,
140
- onCreateSubAgent: w,
141
- registerSubAgentCreator: U,
142
- requestCreateSubAgent: Y,
161
+ disableStepNavigation: H,
162
+ onCreateSubAgent: I,
163
+ registerSubAgentCreator: z,
164
+ requestCreateSubAgent: D,
165
+ registerToolActionHandler: Q,
166
+ requestToolAction: W,
143
167
  onFetchSubAgent: L,
144
168
  onUpdateSubAgent: V,
145
- onImproveSubAgent: b
169
+ onImproveSubAgent: b,
170
+ onImproveToolInstructions: j
146
171
  }),
147
172
  [
148
- n,
173
+ t,
174
+ v,
175
+ tt,
176
+ nt,
177
+ ot,
178
+ y,
149
179
  X,
180
+ N,
181
+ U,
150
182
  Z,
151
- k,
152
- C,
153
- y,
154
- z,
155
- G,
156
- H,
157
- D,
158
- O,
159
- v,
160
- x,
183
+ st,
184
+ et,
185
+ p,
161
186
  c,
162
- u,
163
- Q,
164
- W,
165
- a,
166
187
  l,
188
+ C,
189
+ O,
190
+ M,
167
191
  f,
168
- I,
192
+ m,
193
+ F,
169
194
  P,
170
195
  E,
196
+ a,
171
197
  R,
172
- $,
173
- w,
174
- U,
175
- Y,
198
+ H,
199
+ I,
200
+ z,
201
+ D,
202
+ Q,
203
+ W,
176
204
  L,
177
205
  V,
178
- b
206
+ b,
207
+ j
179
208
  ]
180
209
  );
181
- return /* @__PURE__ */ it(nt.Provider, { value: ot, children: et });
210
+ return /* @__PURE__ */ ft(ct.Provider, { value: dt, children: it });
182
211
  };
183
212
  export {
184
- Mt as AgentBuilderProvider,
185
- _t as useAgentBuilderContext
213
+ Bt as AgentBuilderProvider,
214
+ ht as useAgentBuilderContext
186
215
  };
187
216
  //# sourceMappingURL=AgentBuilderContext.js.map