@ai-matrx/chat 0.6.6 → 0.7.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 (249) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -1
  3. package/dist/agents/components/agent-widgets/AgentChatHistorySidebar.js +16 -55
  4. package/dist/agents/components/chat/chat-door.d.ts +67 -0
  5. package/dist/agents/components/chat/chat-door.js +100 -0
  6. package/dist/agents/components/conversation-history/AgentConversationList.d.ts +83 -0
  7. package/dist/agents/components/conversation-history/AgentConversationList.js +252 -0
  8. package/dist/agents/components/conversation-history/ConversationArchiveSection.d.ts +5 -1
  9. package/dist/agents/components/conversation-history/ConversationArchiveSection.js +22 -4
  10. package/dist/agents/components/conversation-history/ConversationHistorySidebar.js +20 -65
  11. package/dist/agents/components/inputs/input-components/TextareaInput.js +2 -0
  12. package/dist/agents/components/inputs/input-components/VariableInputComponent.js +7 -6
  13. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.d.ts +3 -0
  14. package/dist/agents/components/inputs/smart-input/ConversationCompanionPills.js +40 -0
  15. package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +6 -29
  16. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.d.ts +3 -0
  17. package/dist/agents/components/inputs/smart-input/DeviceToolsModeRow.js +35 -0
  18. package/dist/agents/components/inputs/smart-input/InboxQueueStrip.js +0 -8
  19. package/dist/agents/components/inputs/smart-input/RunToolPicker.js +15 -11
  20. package/dist/agents/components/inputs/smart-input/composer/ComposerPlusMenu.js +22 -0
  21. package/dist/agents/components/inputs/smart-input/rail-pill.d.ts +35 -0
  22. package/dist/agents/components/inputs/smart-input/rail-pill.js +30 -0
  23. package/dist/agents/components/inputs/variable-input-variations/AgentVariableForm.js +52 -48
  24. package/dist/agents/components/run-controls/panels/shared.d.ts +1 -1
  25. package/dist/agents/components/shared/AgentModeController.js +3 -2
  26. package/dist/agents/components/shell/AgentRunSidebarMenu.js +15 -54
  27. package/dist/agents/components/working-document/documents-workspace/DocumentsListRail.js +1 -2
  28. package/dist/agents/engine.d.ts +15 -0
  29. package/dist/agents/engine.js +17 -0
  30. package/dist/agents/hooks/useModelControls.js +3 -175
  31. package/dist/agents/redux/agent-definition/selectors.d.ts +237 -237
  32. package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +50 -50
  33. package/dist/agents/redux/agent-shortcuts/selectors.d.ts +147 -147
  34. package/dist/agents/redux/conversation-history/thunks.js +6 -18
  35. package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +1 -73
  36. package/dist/agents/redux/conversation-list/conversation-list.selectors.js +2 -36
  37. package/dist/agents/redux/conversation-list/conversation-list.slice.d.ts +7 -22
  38. package/dist/agents/redux/conversation-list/conversation-list.slice.js +7 -62
  39. package/dist/agents/redux/conversation-list/conversation-list.thunks.d.ts +0 -25
  40. package/dist/agents/redux/conversation-list/conversation-list.thunks.js +2 -58
  41. package/dist/agents/redux/conversation-list/conversation-list.types.d.ts +0 -5
  42. package/dist/agents/redux/conversation-list/conversation-rows.d.ts +16 -0
  43. package/dist/agents/redux/conversation-list/conversation-rows.js +24 -0
  44. package/dist/agents/redux/conversation-list/conversation-trash.thunks.d.ts +1 -0
  45. package/dist/agents/redux/conversation-list/conversation-trash.thunks.js +13 -18
  46. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +54 -54
  47. package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +14 -14
  48. package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +5 -5
  49. package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +3 -3
  50. package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +8 -8
  51. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +5 -5
  52. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +7 -7
  53. package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +1 -1
  54. package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +7 -7
  55. package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +1 -1
  56. package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +14 -14
  57. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.d.ts +10 -1
  58. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.js +114 -265
  59. package/dist/agents/redux/execution-system/thunks/dispatch-matrx-extend-tool.thunk.js +18 -2
  60. package/dist/agents/redux/execution-system/thunks/dispatch-surface-client-tool.thunk.js +10 -28
  61. package/dist/agents/redux/execution-system/thunks/dispatch-surface-write.thunk.js +10 -25
  62. package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +20 -0
  63. package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +6 -1
  64. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.d.ts +58 -0
  65. package/dist/agents/redux/execution-system/thunks/notify-and-play-dispatcher.js +62 -0
  66. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.d.ts +23 -0
  67. package/dist/agents/redux/execution-system/thunks/post-delegated-tool-outcome.js +37 -0
  68. package/dist/agents/redux/execution-system/thunks/resume-instance.thunk.js +10 -2
  69. package/dist/agents/redux/execution-system/utils/build-tool-injection.d.ts +7 -0
  70. package/dist/agents/redux/execution-system/utils/build-tool-injection.js +18 -6
  71. package/dist/agents/redux/execution-system/utils/host-turn.d.ts +45 -0
  72. package/dist/agents/redux/execution-system/utils/host-turn.js +119 -0
  73. package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +1 -1
  74. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.d.ts +50 -20
  75. package/dist/agents/scribe-tools/dispatcher/dispatch-scribe-tool.thunk.js +9 -101
  76. package/dist/agents/types/tool-injection.types.d.ts +18 -2
  77. package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +2 -2
  78. package/dist/agents/ui-first-tools/redux/pending-asks.slice.d.ts +2 -1
  79. package/dist/agents/ui-first-tools/redux/resolve-asks-with-input.thunk.js +1 -1
  80. package/dist/agents/ui-first-tools/tools/ask-response.d.ts +29 -0
  81. package/dist/agents/ui-first-tools/tools/ask-response.js +15 -0
  82. package/dist/agents/ui-first-tools/tools/schemas.d.ts +3 -25
  83. package/dist/agents/ui-first-tools/tools/schemas.js +1 -12
  84. package/dist/agents/ui-first-tools/ui/ApprovalCard.js +1 -1
  85. package/dist/agents/ui-first-tools/ui/AskWizard.d.ts +1 -1
  86. package/dist/agents/ui-first-tools/ui/AskWizard.js +1 -1
  87. package/dist/cx-chat/_legacy-stubs.d.ts +5 -5
  88. package/dist/cx-chat/components/SsrSidebarChats.js +13 -15
  89. package/dist/cx-chat/components/messages/UserMessage.d.ts +2 -2
  90. package/dist/cx-chat/types/conversation.d.ts +6 -6
  91. package/dist/cx-chat/utils/buildContentBlocksForSave.d.ts +1 -1
  92. package/dist/cx-chat/utils/cx-content-converter.d.ts +1 -1
  93. package/dist/host/bare-host-chrome.js +9 -3
  94. package/dist/host/composer-extensions.d.ts +75 -0
  95. package/dist/host/composer-extensions.js +92 -0
  96. package/dist/host/configure.js +1 -0
  97. package/dist/host/contract.d.ts +105 -13
  98. package/dist/host/defaults/confirm.d.ts +15 -0
  99. package/dist/host/defaults/confirm.js +25 -0
  100. package/dist/host/defaults/files-ui.d.ts +85 -0
  101. package/dist/host/defaults/files-ui.js +158 -0
  102. package/dist/host/defaults/gates.d.ts +27 -0
  103. package/dist/host/defaults/gates.js +72 -0
  104. package/dist/host/defaults/media-client.d.ts +15 -0
  105. package/dist/host/defaults/media-client.js +40 -0
  106. package/dist/host/defaults/voice.d.ts +81 -0
  107. package/dist/host/defaults/voice.js +239 -0
  108. package/dist/host/device-tool-handoff.d.ts +26 -0
  109. package/dist/host/device-tool-handoff.js +45 -0
  110. package/dist/host/index.d.ts +1 -0
  111. package/dist/host/index.js +4 -1
  112. package/dist/host/microphone.d.ts +11 -0
  113. package/dist/host/microphone.js +17 -0
  114. package/dist/host/ui-slots.d.ts +29 -74
  115. package/dist/host/ui-slots.js +40 -42
  116. package/dist/store/create-chat-store.d.ts +2 -2
  117. package/dist/store/middlewares.d.ts +5 -5
  118. package/dist/store/slices.d.ts +1 -1
  119. package/dist/surfaces/redux/selectors.d.ts +2 -2
  120. package/dist/tool-call-visualization/components/ToolCallVisualization.js +3 -2
  121. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.d.ts +15 -0
  122. package/dist/tool-call-visualization/configured-rows/ConfiguredRowRenderer.js +36 -0
  123. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.d.ts +40 -0
  124. package/dist/tool-call-visualization/configured-rows/ConfiguredToolRow.js +296 -0
  125. package/dist/tool-call-visualization/configured-rows/CopyToolButton.d.ts +23 -0
  126. package/dist/tool-call-visualization/configured-rows/CopyToolButton.js +62 -0
  127. package/dist/tool-call-visualization/configured-rows/ToolProgressView.d.ts +23 -0
  128. package/dist/tool-call-visualization/configured-rows/ToolProgressView.js +147 -0
  129. package/dist/tool-call-visualization/configured-rows/field-components.d.ts +15 -0
  130. package/dist/tool-call-visualization/configured-rows/field-components.js +244 -0
  131. package/dist/tool-call-visualization/configured-rows/helpers.d.ts +39 -0
  132. package/dist/tool-call-visualization/configured-rows/helpers.js +110 -0
  133. package/dist/tool-call-visualization/configured-rows/register.d.ts +25 -0
  134. package/dist/tool-call-visualization/configured-rows/register.js +51 -0
  135. package/dist/tool-call-visualization/configured-rows/registries.d.ts +27 -0
  136. package/dist/tool-call-visualization/configured-rows/registries.js +14 -0
  137. package/dist/tool-call-visualization/configured-rows/to-row-entry.d.ts +8 -0
  138. package/dist/tool-call-visualization/configured-rows/to-row-entry.js +38 -0
  139. package/dist/tool-call-visualization/configured-rows/transforms.d.ts +14 -0
  140. package/dist/tool-call-visualization/configured-rows/transforms.js +30 -0
  141. package/dist/tool-call-visualization/configured-rows/types.d.ts +140 -0
  142. package/dist/tool-call-visualization/redux/selectors.d.ts +1 -1
  143. package/dist/tool-call-visualization/registry/registry.d.ts +1 -1
  144. package/dist/tool-call-visualization/registry/registry.js +8 -1
  145. package/dist/tool-call-visualization/types.d.ts +1 -1
  146. package/dist/ui/chat-protocol-types.d.ts +0 -1
  147. package/dist/ui/ownership.d.ts +25 -0
  148. package/dist/ui/ownership.js +18 -0
  149. package/dist/voice-agent/audio/audioCapture.js +11 -6
  150. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.d.ts +1 -2
  151. package/dist/window-panels/windows/agents/AgentRunHistoryWindow.js +21 -181
  152. package/dist/window-panels/windows/agents/AgentRunWindow.js +26 -13
  153. package/package.json +4627 -125
  154. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.d.ts +0 -7
  155. package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.js +0 -33
  156. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.d.ts +0 -6
  157. package/dist/agents/components/agent-widgets/chat-assistant/StatusCard.js +0 -21
  158. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.d.ts +0 -6
  159. package/dist/agents/components/agent-widgets/chat-assistant/UserMessageCard.js +0 -11
  160. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.d.ts +0 -12
  161. package/dist/agents/components/agent-widgets/chat-assistant/VariableInputCard.js +0 -7
  162. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.d.ts +0 -4
  163. package/dist/agents/components/agent-widgets/execution-gates/PreExecutionCard.js +0 -81
  164. package/dist/agents/components/run/run-sidebar/SidebarHeader.d.ts +0 -21
  165. package/dist/agents/components/run/run-sidebar/SidebarHeader.js +0 -50
  166. package/dist/agents/components/run-controls/AdvancedRunSettings/index.d.ts +0 -6
  167. package/dist/agents/components/run-controls/AdvancedRunSettings/index.js +0 -32
  168. package/dist/agents/components/run-controls/RunSettingsModal.d.ts +0 -5
  169. package/dist/agents/components/run-controls/RunSettingsModal.js +0 -22
  170. package/dist/agents/components/shell/AgentBuildSidebarExtras.d.ts +0 -6
  171. package/dist/agents/components/shell/AgentBuildSidebarExtras.js +0 -30
  172. package/dist/agents/constants/agent-system-competitors.d.ts +0 -9
  173. package/dist/agents/constants/agent-system-competitors.js +0 -125
  174. package/dist/agents/hooks/message-crud/useMessageActions.d.ts +0 -29
  175. package/dist/agents/hooks/message-crud/useMessageActions.js +0 -119
  176. package/dist/agents/hooks/useConversationPendingCalls.d.ts +0 -30
  177. package/dist/agents/hooks/useConversationPendingCalls.js +0 -42
  178. package/dist/agents/model-registry/model-classes.d.ts +0 -1
  179. package/dist/agents/model-registry/model-classes.js +0 -1
  180. package/dist/agents/redux/conversation-history/index.d.ts +0 -18
  181. package/dist/agents/redux/conversation-history/index.js +0 -4
  182. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.d.ts +0 -38
  183. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.thunks.js +0 -42
  184. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.d.ts +0 -58
  185. package/dist/agents/redux/execution-system/message-crud/server/compact-turns.thunk.js +0 -50
  186. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.d.ts +0 -76
  187. package/dist/agents/redux/execution-system/message-crud/server/fork-and-run-server.thunk.js +0 -101
  188. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.d.ts +0 -38
  189. package/dist/agents/redux/execution-system/thunks/attach-workflow-run.js +0 -25
  190. package/dist/agents/redux/execution-system/utils/source-slice-helpers.d.ts +0 -45
  191. package/dist/agents/redux/execution-system/utils/source-slice-helpers.js +0 -50
  192. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.d.ts +0 -25
  193. package/dist/agents/runtime/realtime/launchRealtimeSession.thunk.js +0 -15
  194. package/dist/agents/services/agentService.d.ts +0 -12
  195. package/dist/agents/services/agentService.js +0 -92
  196. package/dist/agents/utils/escape-code-fences.d.ts +0 -15
  197. package/dist/agents/utils/escape-code-fences.js +0 -9
  198. package/dist/agents/utils/normalize-managed-options.d.ts +0 -30
  199. package/dist/agents/utils/normalize-managed-options.js +0 -29
  200. package/dist/agents/utils/processedDocumentContext.d.ts +0 -51
  201. package/dist/agents/utils/processedDocumentContext.js +0 -51
  202. package/dist/agents/utils/variable-validation.d.ts +0 -28
  203. package/dist/agents/utils/variable-validation.js +0 -54
  204. package/dist/cx-chat/components/ChatConversationSkeleton.d.ts +0 -9
  205. package/dist/cx-chat/components/ChatConversationSkeleton.js +0 -45
  206. package/dist/cx-chat/components/ChatPanelBackButton.d.ts +0 -1
  207. package/dist/cx-chat/components/ChatPanelBackButton.js +0 -26
  208. package/dist/cx-chat/components/messages/MessageErrorBoundary.d.ts +0 -20
  209. package/dist/cx-chat/components/messages/MessageErrorBoundary.js +0 -40
  210. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.d.ts +0 -14
  211. package/dist/cx-chat/components/variable-inputs/CheckboxGroupInput.js +0 -160
  212. package/dist/cx-chat/components/variable-inputs/NumberInput.d.ts +0 -15
  213. package/dist/cx-chat/components/variable-inputs/NumberInput.js +0 -79
  214. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.d.ts +0 -14
  215. package/dist/cx-chat/components/variable-inputs/RadioGroupInput.js +0 -125
  216. package/dist/cx-chat/components/variable-inputs/SelectInput.d.ts +0 -14
  217. package/dist/cx-chat/components/variable-inputs/SelectInput.js +0 -92
  218. package/dist/cx-chat/components/variable-inputs/TextareaInput.d.ts +0 -14
  219. package/dist/cx-chat/components/variable-inputs/TextareaInput.js +0 -46
  220. package/dist/cx-chat/components/variable-inputs/ToggleInput.d.ts +0 -14
  221. package/dist/cx-chat/components/variable-inputs/ToggleInput.js +0 -46
  222. package/dist/cx-chat/hooks/useChatPersistence.d.ts +0 -28
  223. package/dist/cx-chat/hooks/useChatPersistence.js +0 -180
  224. package/dist/cx-chat/hooks/useInstanceBootstrap.d.ts +0 -1
  225. package/dist/cx-chat/hooks/useInstanceBootstrap.js +0 -115
  226. package/dist/cx-chat/types/content.d.ts +0 -184
  227. package/dist/cx-chat/types/content.js +0 -91
  228. package/dist/cx-chat/types/cx-tables.d.ts +0 -176
  229. package/dist/cx-chat/utils/settings-diff.d.ts +0 -13
  230. package/dist/cx-chat/utils/settings-diff.js +0 -25
  231. package/dist/public-chat/components/AgentSelector.d.ts +0 -22
  232. package/dist/public-chat/components/AgentSelector.js +0 -80
  233. package/dist/public-chat/components/GuidedVariableInputs.d.ts +0 -25
  234. package/dist/public-chat/components/GuidedVariableInputs.js +0 -623
  235. package/dist/public-chat/components/PublicVariableInputs.d.ts +0 -29
  236. package/dist/public-chat/components/PublicVariableInputs.js +0 -172
  237. package/dist/public-chat/types/content.d.ts +0 -184
  238. package/dist/public-chat/types/content.js +0 -91
  239. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.d.ts +0 -15
  240. package/dist/tool-call-visualization/renderers/_shared-entity/EntityOpenActions.js +0 -31
  241. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.d.ts +0 -24
  242. package/dist/tool-call-visualization/utils/toolCallBlockToLifecycleEntry.js +0 -26
  243. package/dist/ui/AudioOutputBlockSkeleton.d.ts +0 -17
  244. package/dist/ui/AudioOutputBlockSkeleton.js +0 -78
  245. package/dist/ui/lazy/PublicChatVariableInputs.d.ts +0 -2
  246. package/dist/ui/lazy/PublicChatVariableInputs.js +0 -16
  247. package/dist/utils/xml/readXmlTag.d.ts +0 -12
  248. package/dist/utils/xml/readXmlTag.js +0 -66
  249. /package/dist/{cx-chat/types/cx-tables.js → tool-call-visualization/configured-rows/types.js} +0 -0
@@ -1,623 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useState, useCallback, useRef, useEffect } from "react";
4
- import { ChevronLeft, ChevronRight, ChevronDown, Check } from "lucide-react";
5
- import { Textarea } from "@ai-matrx/design-system";
6
- import { Input } from "@ai-matrx/design-system";
7
- import { Button } from "@ai-matrx/design-system/controls";
8
- import { Checkbox } from "../../ui/checkbox.js";
9
- import { Minus, Plus } from "lucide-react";
10
- import { variableRunLabel } from "@ai-matrx/agents";
11
- import { enterSendsHere } from "@ai-matrx/kit/composer-keys";
12
- function InlineCustomInput({
13
- value,
14
- onChange,
15
- placeholder = "Or type your own answer..."
16
- }) {
17
- return /* @__PURE__ */ jsx("div", { className: "mt-2 pt-2 border-t border-border/40", children: /* @__PURE__ */ jsx(
18
- "input",
19
- {
20
- type: "text",
21
- value,
22
- onChange: (e) => onChange(e.target.value),
23
- placeholder,
24
- className: "w-full text-base md:text-sm bg-textured border-none outline-none text-foreground placeholder:text-muted-foreground py-1 px-2 rounded"
25
- }
26
- ) });
27
- }
28
- function GuidedSelect({
29
- value,
30
- onChange,
31
- options,
32
- allowOther,
33
- onAutoAdvance
34
- }) {
35
- const isOther = value.startsWith("Other: ");
36
- const [otherText, setOtherText] = useState(isOther ? value.slice(7) : "");
37
- const [showOther, setShowOther] = useState(isOther);
38
- const isCustom = !options.includes(value) && !isOther && value !== "";
39
- const handleSelect = (option) => {
40
- onChange(option);
41
- setShowOther(false);
42
- setTimeout(onAutoAdvance, 200);
43
- };
44
- const handleOtherClick = () => {
45
- setShowOther(true);
46
- onChange(`Other: ${otherText}`);
47
- };
48
- const handleCustomChange = (v) => {
49
- if (v === "") {
50
- onChange("");
51
- } else {
52
- onChange(v);
53
- }
54
- setShowOther(false);
55
- };
56
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
57
- /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
58
- options.map((option) => {
59
- const isActive = value === option;
60
- return /* @__PURE__ */ jsx(
61
- "div",
62
- {
63
- role: "button",
64
- tabIndex: 0,
65
- onClick: () => handleSelect(option),
66
- onKeyDown: (e) => {
67
- if (e.key === "Enter" || e.key === " ") {
68
- e.preventDefault();
69
- handleSelect(option);
70
- }
71
- },
72
- className: `w-full text-left px-3 py-2.5 rounded-lg text-sm transition-all border cursor-pointer ${isActive ? "bg-primary/10 border-primary text-foreground ring-1 ring-primary/30" : "bg-textured border-border hover:bg-accent hover:border-foreground/20 text-foreground"}`,
73
- children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
74
- isActive && /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-primary flex-shrink-0" }),
75
- /* @__PURE__ */ jsx("span", { className: isActive ? "font-medium" : "", children: option || "(empty)" })
76
- ] })
77
- },
78
- option
79
- );
80
- }),
81
- allowOther && /* @__PURE__ */ jsx(
82
- "div",
83
- {
84
- role: "button",
85
- tabIndex: 0,
86
- onClick: handleOtherClick,
87
- onKeyDown: (e) => {
88
- if (e.key === "Enter" || e.key === " ") {
89
- e.preventDefault();
90
- handleOtherClick();
91
- }
92
- },
93
- className: `w-full text-left px-3 py-2.5 rounded-lg text-sm transition-all border cursor-pointer ${showOther ? "bg-primary/10 border-primary text-foreground ring-1 ring-primary/30" : "bg-textured border-border hover:bg-accent hover:border-foreground/20 text-foreground"}`,
94
- children: "Other..."
95
- }
96
- )
97
- ] }),
98
- showOther && /* @__PURE__ */ jsx(
99
- Textarea,
100
- {
101
- value: otherText,
102
- onChange: (e) => {
103
- setOtherText(e.target.value);
104
- onChange(`Other: ${e.target.value}`);
105
- },
106
- placeholder: "Type your answer...",
107
- className: "min-h-[60px] text-base md:text-sm mt-1",
108
- autoFocus: true
109
- }
110
- ),
111
- !showOther && /* @__PURE__ */ jsx(
112
- InlineCustomInput,
113
- {
114
- value: isCustom ? value : "",
115
- onChange: handleCustomChange
116
- }
117
- )
118
- ] });
119
- }
120
- function GuidedCheckbox({
121
- value,
122
- onChange,
123
- options,
124
- allowOther
125
- }) {
126
- const selected = value ? value.split("\n").filter(Boolean) : [];
127
- const otherItem = selected.find((s) => s.startsWith("Other: "));
128
- const [otherText, setOtherText] = useState(
129
- otherItem ? otherItem.slice(7) : ""
130
- );
131
- const [showOther, setShowOther] = useState(!!otherItem);
132
- const toggle = (option) => {
133
- const regular = selected.filter((s) => !s.startsWith("Other: "));
134
- const has = regular.includes(option);
135
- const next = has ? regular.filter((s) => s !== option) : [...regular, option];
136
- const all = showOther && otherText ? [...next, `Other: ${otherText}`] : next;
137
- onChange(all.join("\n"));
138
- };
139
- const handleOtherToggle = () => {
140
- const regular = selected.filter((s) => !s.startsWith("Other: "));
141
- if (showOther) {
142
- setShowOther(false);
143
- onChange(regular.join("\n"));
144
- } else {
145
- setShowOther(true);
146
- onChange([...regular, `Other: ${otherText}`].join("\n"));
147
- }
148
- };
149
- const handleCustomChange = (v) => {
150
- if (v === "") return;
151
- onChange(v);
152
- };
153
- return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
154
- /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
155
- options.map((option) => {
156
- const isActive = selected.includes(option);
157
- return /* @__PURE__ */ jsxs(
158
- "label",
159
- {
160
- className: `flex w-full items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-all border cursor-pointer text-left ${isActive ? "bg-primary/10 border-primary text-foreground ring-1 ring-primary/30" : "bg-textured border-border hover:bg-accent hover:border-foreground/20 text-foreground"}`,
161
- children: [
162
- /* @__PURE__ */ jsx(
163
- Checkbox,
164
- {
165
- checked: isActive,
166
- onCheckedChange: () => toggle(option),
167
- "aria-label": option || "(empty)",
168
- className: "flex-shrink-0"
169
- }
170
- ),
171
- /* @__PURE__ */ jsx("span", { className: isActive ? "font-medium" : "", children: option || "(empty)" })
172
- ]
173
- },
174
- option
175
- );
176
- }),
177
- allowOther && /* @__PURE__ */ jsxs(
178
- "label",
179
- {
180
- className: `flex w-full items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-all border cursor-pointer text-left ${showOther ? "bg-primary/10 border-primary text-foreground ring-1 ring-primary/30" : "bg-textured border-border hover:bg-accent hover:border-foreground/20 text-foreground"}`,
181
- children: [
182
- /* @__PURE__ */ jsx(
183
- Checkbox,
184
- {
185
- checked: showOther,
186
- onCheckedChange: handleOtherToggle,
187
- "aria-label": "Other",
188
- className: "flex-shrink-0"
189
- }
190
- ),
191
- /* @__PURE__ */ jsx("span", { children: "Other..." })
192
- ]
193
- }
194
- )
195
- ] }),
196
- showOther && /* @__PURE__ */ jsx(
197
- Textarea,
198
- {
199
- value: otherText,
200
- onChange: (e) => {
201
- setOtherText(e.target.value);
202
- const regular = selected.filter((s) => !s.startsWith("Other: "));
203
- onChange([...regular, `Other: ${e.target.value}`].join("\n"));
204
- },
205
- placeholder: "Type your answer...",
206
- className: "min-h-[60px] text-base md:text-sm mt-1",
207
- autoFocus: true
208
- }
209
- ),
210
- selected.length > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
211
- selected.length,
212
- " selected"
213
- ] }),
214
- !showOther && /* @__PURE__ */ jsx(InlineCustomInput, { value: "", onChange: handleCustomChange })
215
- ] });
216
- }
217
- function GuidedToggle({
218
- value,
219
- onChange,
220
- toggleValues,
221
- onAutoAdvance
222
- }) {
223
- const [offLabel, onLabel] = toggleValues || ["No", "Yes"];
224
- const handleSelect = (val) => {
225
- onChange(val);
226
- setTimeout(onAutoAdvance, 200);
227
- };
228
- const handleCustomChange = (v) => {
229
- onChange(v || offLabel);
230
- };
231
- return /* @__PURE__ */ jsxs("div", { children: [
232
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: [offLabel, onLabel].map((label) => {
233
- const isActive = value === label;
234
- return /* @__PURE__ */ jsx(
235
- "div",
236
- {
237
- role: "button",
238
- tabIndex: 0,
239
- onClick: () => handleSelect(label),
240
- onKeyDown: (e) => {
241
- if (e.key === "Enter" || e.key === " ") {
242
- e.preventDefault();
243
- handleSelect(label);
244
- }
245
- },
246
- className: `px-4 py-3 rounded-lg text-sm font-medium text-center transition-all border cursor-pointer ${isActive ? "bg-primary/10 border-primary text-foreground ring-1 ring-primary/30" : "bg-textured border-border hover:bg-accent hover:border-foreground/20 text-foreground"}`,
247
- children: label
248
- },
249
- label
250
- );
251
- }) }),
252
- /* @__PURE__ */ jsx(
253
- InlineCustomInput,
254
- {
255
- value: value !== offLabel && value !== onLabel ? value : "",
256
- onChange: handleCustomChange
257
- }
258
- )
259
- ] });
260
- }
261
- function GuidedNumber({
262
- value,
263
- onChange,
264
- min,
265
- max,
266
- step = 1
267
- }) {
268
- const num = parseFloat(value) || 0;
269
- const canDec = min === void 0 || num > min;
270
- const canInc = max === void 0 || num < max;
271
- return /* @__PURE__ */ jsxs("div", { children: [
272
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-3", children: [
273
- /* @__PURE__ */ jsx(
274
- Button,
275
- {
276
- type: "button",
277
- variant: "outline",
278
- onClick: () => canDec && onChange((num - step).toString()),
279
- disabled: !canDec,
280
- children: /* @__PURE__ */ jsx(Minus, { className: "w-5 h-5" })
281
- }
282
- ),
283
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-w-[120px]", children: /* @__PURE__ */ jsx(
284
- Input,
285
- {
286
- type: "text",
287
- value,
288
- onChange: (e) => {
289
- const v = e.target.value;
290
- if (v === "" || v === "-" || !isNaN(parseFloat(v))) onChange(v);
291
- },
292
- className: "w-full text-center text-2xl font-semibold h-12",
293
- placeholder: "0"
294
- }
295
- ) }),
296
- /* @__PURE__ */ jsx(
297
- Button,
298
- {
299
- type: "button",
300
- variant: "outline",
301
- onClick: () => canInc && onChange((num + step).toString()),
302
- disabled: !canInc,
303
- children: /* @__PURE__ */ jsx(Plus, { className: "w-5 h-5" })
304
- }
305
- )
306
- ] }),
307
- /* @__PURE__ */ jsx(
308
- InlineCustomInput,
309
- {
310
- value: "",
311
- onChange: (v) => onChange(v),
312
- placeholder: "Or type a number..."
313
- }
314
- )
315
- ] });
316
- }
317
- function GuidedTextarea({
318
- value,
319
- onChange,
320
- variableName
321
- }) {
322
- return /* @__PURE__ */ jsx(
323
- Textarea,
324
- {
325
- value,
326
- onChange: (e) => onChange(e.target.value),
327
- placeholder: `Type your ${variableName.toLowerCase()}...`,
328
- className: "min-h-[100px] text-base md:text-sm resize-none bg-textured",
329
- autoFocus: true
330
- }
331
- );
332
- }
333
- function GuidedVariableContent({
334
- variable,
335
- value,
336
- onChange,
337
- onAutoAdvance
338
- }) {
339
- const cc = variable.customComponent;
340
- if (!cc || cc.type === "textarea") {
341
- return /* @__PURE__ */ jsx(
342
- GuidedTextarea,
343
- {
344
- value,
345
- onChange,
346
- variableName: variableRunLabel(variable)
347
- }
348
- );
349
- }
350
- switch (cc.type) {
351
- case "select":
352
- case "radio":
353
- if (!cc.options?.length) {
354
- return /* @__PURE__ */ jsx(
355
- GuidedTextarea,
356
- {
357
- value,
358
- onChange,
359
- variableName: variableRunLabel(variable)
360
- }
361
- );
362
- }
363
- return /* @__PURE__ */ jsx(
364
- GuidedSelect,
365
- {
366
- value,
367
- onChange,
368
- options: cc.options,
369
- allowOther: cc.allowOther,
370
- onAutoAdvance
371
- }
372
- );
373
- case "checkbox":
374
- if (!cc.options?.length) {
375
- return /* @__PURE__ */ jsx(
376
- GuidedTextarea,
377
- {
378
- value,
379
- onChange,
380
- variableName: variableRunLabel(variable)
381
- }
382
- );
383
- }
384
- return /* @__PURE__ */ jsx(
385
- GuidedCheckbox,
386
- {
387
- value,
388
- onChange,
389
- options: cc.options,
390
- allowOther: cc.allowOther
391
- }
392
- );
393
- case "toggle":
394
- return /* @__PURE__ */ jsx(
395
- GuidedToggle,
396
- {
397
- value,
398
- onChange,
399
- toggleValues: cc.toggleValues,
400
- onAutoAdvance
401
- }
402
- );
403
- case "number":
404
- return /* @__PURE__ */ jsx(
405
- GuidedNumber,
406
- {
407
- value,
408
- onChange,
409
- min: cc.min,
410
- max: cc.max,
411
- step: cc.step
412
- }
413
- );
414
- default:
415
- return /* @__PURE__ */ jsx(
416
- GuidedTextarea,
417
- {
418
- value,
419
- onChange,
420
- variableName: variableRunLabel(variable)
421
- }
422
- );
423
- }
424
- }
425
- function GuidedVariableInputs(props) {
426
- if (props.variableDefaults.length === 0) return null;
427
- return /* @__PURE__ */ jsx(GuidedVariableInputsBody, { ...props });
428
- }
429
- function GuidedVariableInputsBody({
430
- variableDefaults,
431
- values,
432
- onChange,
433
- disabled = false,
434
- onSubmit,
435
- submitOnEnter = false,
436
- textInputRef,
437
- seamless = false
438
- }) {
439
- const [activeIndex, setActiveIndex] = useState(0);
440
- const [isCollapsed, setIsCollapsed] = useState(false);
441
- const [isScrollable, setIsScrollable] = useState(false);
442
- const scrollRef = useRef(null);
443
- const total = variableDefaults.length;
444
- useEffect(() => {
445
- const el = scrollRef.current;
446
- if (!el) return void 0;
447
- const check = () => setIsScrollable(el.scrollHeight > el.clientHeight);
448
- check();
449
- const ro = new ResizeObserver(check);
450
- ro.observe(el);
451
- return () => ro.disconnect();
452
- }, [activeIndex, isCollapsed]);
453
- const variable = variableDefaults[activeIndex];
454
- const value = String(values[variable.name] ?? variable.defaultValue ?? "");
455
- const formattedName = variableRunLabel(variable);
456
- const helpText = variable.helpText;
457
- const answeredCount = variableDefaults.filter((v) => {
458
- const val = String(values[v.name] ?? v.defaultValue ?? "");
459
- return val.trim() !== "";
460
- }).length;
461
- const goNext = useCallback(() => {
462
- if (activeIndex < total - 1) {
463
- setActiveIndex((i) => i + 1);
464
- }
465
- }, [activeIndex, total]);
466
- const goPrev = useCallback(() => {
467
- if (activeIndex > 0) {
468
- setActiveIndex((i) => i - 1);
469
- }
470
- }, [activeIndex]);
471
- const handleSkipAll = useCallback(() => {
472
- setIsCollapsed(true);
473
- textInputRef?.current?.focus();
474
- }, [textInputRef]);
475
- const handleToggleCollapse = useCallback(() => {
476
- setIsCollapsed((c) => !c);
477
- }, []);
478
- const handleChange = useCallback(
479
- (v) => {
480
- onChange(variable.name, v);
481
- },
482
- [onChange, variable.name]
483
- );
484
- const handleKeyDown = useCallback(
485
- (e) => {
486
- if (e.key === "Enter" && !e.shiftKey) {
487
- const cc = variable.customComponent;
488
- if (!cc || cc.type === "textarea") {
489
- e.preventDefault();
490
- if (activeIndex < total - 1) {
491
- goNext();
492
- } else if (enterSendsHere(submitOnEnter) && onSubmit) {
493
- onSubmit("", void 0);
494
- } else {
495
- textInputRef?.current?.focus();
496
- }
497
- }
498
- }
499
- },
500
- [
501
- variable,
502
- activeIndex,
503
- total,
504
- goNext,
505
- submitOnEnter,
506
- onSubmit,
507
- textInputRef
508
- ]
509
- );
510
- const outerRadius = seamless ? "rounded-t-xl rounded-b-none" : "rounded-xl";
511
- const collapsedRadius = seamless ? "rounded-t-xl rounded-b-none" : "rounded-xl";
512
- const progressDots = /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: variableDefaults.map((v, i) => {
513
- const filled = String(values[v.name] ?? v.defaultValue ?? "").trim() !== "";
514
- const isCurrent = i === activeIndex;
515
- return /* @__PURE__ */ jsx(
516
- "span",
517
- {
518
- role: "button",
519
- tabIndex: 0,
520
- onClick: (e) => {
521
- e.stopPropagation();
522
- setActiveIndex(i);
523
- if (isCollapsed) setIsCollapsed(false);
524
- },
525
- onKeyDown: (e) => {
526
- if (e.key === "Enter" || e.key === " ") {
527
- e.preventDefault();
528
- setActiveIndex(i);
529
- if (isCollapsed) setIsCollapsed(false);
530
- }
531
- },
532
- className: `rounded-full transition-all cursor-pointer ${isCurrent ? "w-5 h-2 bg-primary" : filled ? "w-2 h-2 bg-primary/40" : "w-2 h-2 bg-muted-foreground/20"}`,
533
- title: variableRunLabel(v)
534
- },
535
- v.name
536
- );
537
- }) });
538
- if (isCollapsed) {
539
- return /* @__PURE__ */ jsx(
540
- "div",
541
- {
542
- className: `bg-card border border-border ${collapsedRadius} ${seamless ? "border-b-0" : ""}`,
543
- children: /* @__PURE__ */ jsxs(
544
- "div",
545
- {
546
- role: "button",
547
- tabIndex: 0,
548
- onClick: handleToggleCollapse,
549
- onKeyDown: (e) => {
550
- if (e.key === "Enter" || e.key === " ") {
551
- e.preventDefault();
552
- handleToggleCollapse();
553
- }
554
- },
555
- className: `w-full flex items-center justify-between px-3 py-2 hover:bg-accent/50 transition-colors cursor-pointer ${collapsedRadius}`,
556
- children: [
557
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
558
- progressDots,
559
- /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground truncate", children: [
560
- answeredCount,
561
- "/",
562
- total,
563
- " answered"
564
- ] })
565
- ] }),
566
- /* @__PURE__ */ jsx(ChevronDown, { className: "w-3.5 h-3.5 text-muted-foreground flex-shrink-0" })
567
- ]
568
- }
569
- )
570
- }
571
- );
572
- }
573
- return /* @__PURE__ */ jsxs(
574
- "div",
575
- {
576
- className: `bg-muted border border-border ${outerRadius} ${seamless ? "border-b-0" : ""}`,
577
- onKeyDown: handleKeyDown,
578
- children: [
579
- /* @__PURE__ */ jsxs("div", { className: "px-3 pt-2.5 pb-2 border-b border-border/40", children: [
580
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
581
- progressDots,
582
- /* @__PURE__ */ jsx("h3", { className: "flex-1 text-sm font-medium text-foreground truncate min-w-0", children: formattedName }),
583
- /* @__PURE__ */ jsx(Button, { variant: "quiet", onClick: handleSkipAll, children: "Skip questions" })
584
- ] }),
585
- helpText && /* @__PURE__ */ jsx("p", { className: "ml-2 mt-1.5 text-xs text-muted-foreground leading-snug", children: helpText })
586
- ] }),
587
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
588
- /* @__PURE__ */ jsx(
589
- "div",
590
- {
591
- ref: scrollRef,
592
- className: "max-h-[28dvh] md:max-h-[35dvh] overflow-y-auto overscroll-contain px-3 py-2",
593
- children: /* @__PURE__ */ jsx(
594
- GuidedVariableContent,
595
- {
596
- variable,
597
- value,
598
- onChange: handleChange,
599
- onAutoAdvance: goNext
600
- }
601
- )
602
- }
603
- ),
604
- isScrollable && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute bottom-0 inset-x-0 h-8 z-10 bg-gradient-to-t from-muted to-transparent" })
605
- ] }),
606
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2 border-t border-border/50", children: [
607
- /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(ChevronLeft, {}), onClick: goPrev, disabled: activeIndex === 0, children: "Prev" }),
608
- /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
609
- activeIndex + 1,
610
- " of ",
611
- total
612
- ] }),
613
- activeIndex < total - 1 ? /* @__PURE__ */ jsx(Button, { variant: "quiet", tone: "primary", iconEnd: /* @__PURE__ */ jsx(ChevronRight, {}), onClick: goNext, children: "Next" }) : /* @__PURE__ */ jsx(Button, { variant: "quiet", tone: "primary", icon: /* @__PURE__ */ jsx(Check, {}), iconEnd: /* @__PURE__ */ jsx(ChevronRight, {}), onClick: handleSkipAll, children: "Done" })
614
- ] })
615
- ]
616
- }
617
- );
618
- }
619
- var GuidedVariableInputs_default = GuidedVariableInputs;
620
- export {
621
- GuidedVariableInputs,
622
- GuidedVariableInputs_default as default
623
- };
@@ -1,29 +0,0 @@
1
- import React from "react";
2
- import type { VariableDefinition as PromptVariable } from "../../agents/types/agent-definition.types.js";
3
- export interface PublicVariableInputsProps {
4
- variableDefaults: PromptVariable[];
5
- values: Record<string, string>;
6
- onChange: (name: string, value: string) => void;
7
- disabled?: boolean;
8
- compact?: boolean;
9
- /** Hide the outer wrapper (for embedding in custom layouts) */
10
- minimal?: boolean;
11
- /** Called when Enter is pressed on the last variable (if submitOnEnter) */
12
- onSubmit?: (content: string, resources?: any[]) => Promise<boolean>;
13
- /** Whether Enter on the last variable should trigger submit */
14
- submitOnEnter?: boolean;
15
- /** Ref to the text input/textarea to focus after the last variable (if not submitting) */
16
- textInputRef?: React.RefObject<HTMLTextAreaElement | HTMLInputElement | null>;
17
- }
18
- /**
19
- * PublicVariableInputs - Reusable variable input component for public chat
20
- *
21
- * Features:
22
- * - Uses PromptVariable[] structure matching database schema
23
- * - Reuses VariableInputComponent for all input types
24
- * - Clean, compact UI similar to SmartPromptInput
25
- * - Expandable popovers for complex inputs
26
- * - No Redux dependency (Context API compatible)
27
- */
28
- export declare function PublicVariableInputs({ variableDefaults, values, onChange, disabled, compact, minimal, onSubmit, submitOnEnter, textInputRef, }: PublicVariableInputsProps): React.JSX.Element | null;
29
- export default PublicVariableInputs;