@agent-native/core 0.7.81 → 0.7.83

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 (257) hide show
  1. package/dist/action.d.ts +8 -0
  2. package/dist/action.d.ts.map +1 -1
  3. package/dist/action.js +4 -0
  4. package/dist/action.js.map +1 -1
  5. package/dist/agent/production-agent.d.ts +12 -2
  6. package/dist/agent/production-agent.d.ts.map +1 -1
  7. package/dist/agent/production-agent.js +58 -20
  8. package/dist/agent/production-agent.js.map +1 -1
  9. package/dist/agent/run-manager.d.ts +8 -1
  10. package/dist/agent/run-manager.d.ts.map +1 -1
  11. package/dist/agent/run-manager.js +11 -12
  12. package/dist/agent/run-manager.js.map +1 -1
  13. package/dist/agent/thread-data-builder.d.ts.map +1 -1
  14. package/dist/agent/thread-data-builder.js +13 -17
  15. package/dist/agent/thread-data-builder.js.map +1 -1
  16. package/dist/agent/types.d.ts +4 -0
  17. package/dist/agent/types.d.ts.map +1 -1
  18. package/dist/agent/types.js.map +1 -1
  19. package/dist/application-state/handlers.d.ts.map +1 -1
  20. package/dist/application-state/handlers.js +3 -8
  21. package/dist/application-state/handlers.js.map +1 -1
  22. package/dist/application-state/script-helpers.d.ts +2 -4
  23. package/dist/application-state/script-helpers.d.ts.map +1 -1
  24. package/dist/application-state/script-helpers.js +10 -47
  25. package/dist/application-state/script-helpers.js.map +1 -1
  26. package/dist/cli/create.d.ts +1 -1
  27. package/dist/cli/create.d.ts.map +1 -1
  28. package/dist/cli/create.js +35 -10
  29. package/dist/cli/create.js.map +1 -1
  30. package/dist/cli/workspace-dev.js +78 -15
  31. package/dist/cli/workspace-dev.js.map +1 -1
  32. package/dist/client/AgentPanel.d.ts.map +1 -1
  33. package/dist/client/AgentPanel.js +6 -2
  34. package/dist/client/AgentPanel.js.map +1 -1
  35. package/dist/client/AssistantChat.d.ts +0 -15
  36. package/dist/client/AssistantChat.d.ts.map +1 -1
  37. package/dist/client/AssistantChat.js +69 -57
  38. package/dist/client/AssistantChat.js.map +1 -1
  39. package/dist/client/ConnectBuilderCard.d.ts +7 -1
  40. package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
  41. package/dist/client/ConnectBuilderCard.js +46 -5
  42. package/dist/client/ConnectBuilderCard.js.map +1 -1
  43. package/dist/client/ErrorBoundary.d.ts.map +1 -1
  44. package/dist/client/ErrorBoundary.js +20 -5
  45. package/dist/client/ErrorBoundary.js.map +1 -1
  46. package/dist/client/FeedbackButton.d.ts +3 -2
  47. package/dist/client/FeedbackButton.d.ts.map +1 -1
  48. package/dist/client/FeedbackButton.js +23 -15
  49. package/dist/client/FeedbackButton.js.map +1 -1
  50. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  51. package/dist/client/agent-chat-adapter.js +303 -169
  52. package/dist/client/agent-chat-adapter.js.map +1 -1
  53. package/dist/client/builder-frame.d.ts +36 -0
  54. package/dist/client/builder-frame.d.ts.map +1 -1
  55. package/dist/client/builder-frame.js +80 -9
  56. package/dist/client/builder-frame.js.map +1 -1
  57. package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
  58. package/dist/client/composer/ComposerPlusMenu.js +7 -2
  59. package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
  60. package/dist/client/composer/PastedTextChip.d.ts +9 -0
  61. package/dist/client/composer/PastedTextChip.d.ts.map +1 -0
  62. package/dist/client/composer/PastedTextChip.js +47 -0
  63. package/dist/client/composer/PastedTextChip.js.map +1 -0
  64. package/dist/client/composer/PromptComposer.d.ts +4 -2
  65. package/dist/client/composer/PromptComposer.d.ts.map +1 -1
  66. package/dist/client/composer/PromptComposer.js +33 -5
  67. package/dist/client/composer/PromptComposer.js.map +1 -1
  68. package/dist/client/composer/TiptapComposer.d.ts +13 -1
  69. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  70. package/dist/client/composer/TiptapComposer.js +61 -16
  71. package/dist/client/composer/TiptapComposer.js.map +1 -1
  72. package/dist/client/composer/VoiceButton.d.ts.map +1 -1
  73. package/dist/client/composer/VoiceButton.js +5 -1
  74. package/dist/client/composer/VoiceButton.js.map +1 -1
  75. package/dist/client/composer/pasted-text.d.ts +6 -0
  76. package/dist/client/composer/pasted-text.d.ts.map +1 -0
  77. package/dist/client/composer/pasted-text.js +49 -0
  78. package/dist/client/composer/pasted-text.js.map +1 -0
  79. package/dist/client/composer/useVoiceDictation.d.ts +1 -0
  80. package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
  81. package/dist/client/composer/useVoiceDictation.js +18 -0
  82. package/dist/client/composer/useVoiceDictation.js.map +1 -1
  83. package/dist/client/index.d.ts +0 -1
  84. package/dist/client/index.d.ts.map +1 -1
  85. package/dist/client/index.js +0 -1
  86. package/dist/client/index.js.map +1 -1
  87. package/dist/client/integrations/IntegrationCard.d.ts.map +1 -1
  88. package/dist/client/integrations/IntegrationCard.js +14 -2
  89. package/dist/client/integrations/IntegrationCard.js.map +1 -1
  90. package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
  91. package/dist/client/integrations/IntegrationsPanel.js +23 -4
  92. package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
  93. package/dist/client/notifications/NotificationsBell.d.ts.map +1 -1
  94. package/dist/client/notifications/NotificationsBell.js +4 -42
  95. package/dist/client/notifications/NotificationsBell.js.map +1 -1
  96. package/dist/client/org/OrgSwitcher.d.ts +4 -6
  97. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  98. package/dist/client/org/OrgSwitcher.js +84 -74
  99. package/dist/client/org/OrgSwitcher.js.map +1 -1
  100. package/dist/client/org/TeamPage.d.ts.map +1 -1
  101. package/dist/client/org/TeamPage.js +3 -154
  102. package/dist/client/org/TeamPage.js.map +1 -1
  103. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  104. package/dist/client/resources/ResourcesPanel.js +13 -35
  105. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  106. package/dist/client/settings/SettingsPanel.js +1 -1
  107. package/dist/client/settings/SettingsPanel.js.map +1 -1
  108. package/dist/client/settings/useBuilderStatus.d.ts +6 -0
  109. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
  110. package/dist/client/settings/useBuilderStatus.js +3 -0
  111. package/dist/client/settings/useBuilderStatus.js.map +1 -1
  112. package/dist/client/sse-event-processor.d.ts +15 -1
  113. package/dist/client/sse-event-processor.d.ts.map +1 -1
  114. package/dist/client/sse-event-processor.js +58 -54
  115. package/dist/client/sse-event-processor.js.map +1 -1
  116. package/dist/client/tools/ToolEditor.d.ts.map +1 -1
  117. package/dist/client/tools/ToolEditor.js +34 -4
  118. package/dist/client/tools/ToolEditor.js.map +1 -1
  119. package/dist/client/tools/ToolViewer.d.ts.map +1 -1
  120. package/dist/client/tools/ToolViewer.js +20 -1
  121. package/dist/client/tools/ToolViewer.js.map +1 -1
  122. package/dist/client/tools/ToolsListPage.d.ts.map +1 -1
  123. package/dist/client/tools/ToolsListPage.js +2 -1
  124. package/dist/client/tools/ToolsListPage.js.map +1 -1
  125. package/dist/client/tools/ToolsSidebarSection.js +1 -1
  126. package/dist/client/tools/ToolsSidebarSection.js.map +1 -1
  127. package/dist/client/transcription/BuilderTranscriptionCta.js +1 -1
  128. package/dist/client/transcription/BuilderTranscriptionCta.js.map +1 -1
  129. package/dist/client/use-chat-threads.d.ts.map +1 -1
  130. package/dist/client/use-chat-threads.js +7 -2
  131. package/dist/client/use-chat-threads.js.map +1 -1
  132. package/dist/collab/client.d.ts.map +1 -1
  133. package/dist/collab/client.js +26 -7
  134. package/dist/collab/client.js.map +1 -1
  135. package/dist/jobs/scheduler.js +0 -4
  136. package/dist/jobs/scheduler.js.map +1 -1
  137. package/dist/oauth-tokens/store.d.ts +0 -4
  138. package/dist/oauth-tokens/store.d.ts.map +1 -1
  139. package/dist/oauth-tokens/store.js +3 -24
  140. package/dist/oauth-tokens/store.js.map +1 -1
  141. package/dist/observability/routes.d.ts.map +1 -1
  142. package/dist/observability/routes.js +1 -9
  143. package/dist/observability/routes.js.map +1 -1
  144. package/dist/onboarding/default-steps.js +1 -1
  145. package/dist/onboarding/default-steps.js.map +1 -1
  146. package/dist/onboarding/plugin.d.ts.map +1 -1
  147. package/dist/onboarding/plugin.js +1 -8
  148. package/dist/onboarding/plugin.js.map +1 -1
  149. package/dist/org/accept-pending.d.ts.map +1 -1
  150. package/dist/org/accept-pending.js +1 -2
  151. package/dist/org/accept-pending.js.map +1 -1
  152. package/dist/org/context.d.ts +0 -2
  153. package/dist/org/context.d.ts.map +1 -1
  154. package/dist/org/context.js +0 -5
  155. package/dist/org/context.js.map +1 -1
  156. package/dist/resources/script-helpers.d.ts +3 -4
  157. package/dist/resources/script-helpers.d.ts.map +1 -1
  158. package/dist/resources/script-helpers.js +8 -15
  159. package/dist/resources/script-helpers.js.map +1 -1
  160. package/dist/scripts/chat/search-chats.d.ts.map +1 -1
  161. package/dist/scripts/chat/search-chats.js +4 -4
  162. package/dist/scripts/chat/search-chats.js.map +1 -1
  163. package/dist/scripts/manage-agent-loop-settings.js +2 -2
  164. package/dist/scripts/manage-agent-loop-settings.js.map +1 -1
  165. package/dist/scripts/resources/delete-memory.d.ts.map +1 -1
  166. package/dist/scripts/resources/delete-memory.js +4 -2
  167. package/dist/scripts/resources/delete-memory.js.map +1 -1
  168. package/dist/scripts/resources/delete.d.ts.map +1 -1
  169. package/dist/scripts/resources/delete.js +11 -4
  170. package/dist/scripts/resources/delete.js.map +1 -1
  171. package/dist/scripts/resources/list.d.ts.map +1 -1
  172. package/dist/scripts/resources/list.js +5 -3
  173. package/dist/scripts/resources/list.js.map +1 -1
  174. package/dist/scripts/resources/migrate-learnings.d.ts.map +1 -1
  175. package/dist/scripts/resources/migrate-learnings.js +5 -2
  176. package/dist/scripts/resources/migrate-learnings.js.map +1 -1
  177. package/dist/scripts/resources/read.d.ts.map +1 -1
  178. package/dist/scripts/resources/read.js +4 -2
  179. package/dist/scripts/resources/read.js.map +1 -1
  180. package/dist/scripts/resources/save-memory.d.ts.map +1 -1
  181. package/dist/scripts/resources/save-memory.js +4 -2
  182. package/dist/scripts/resources/save-memory.js.map +1 -1
  183. package/dist/scripts/resources/write.d.ts.map +1 -1
  184. package/dist/scripts/resources/write.js +11 -4
  185. package/dist/scripts/resources/write.js.map +1 -1
  186. package/dist/secrets/onboarding.d.ts.map +1 -1
  187. package/dist/secrets/onboarding.js +1 -9
  188. package/dist/secrets/onboarding.js.map +1 -1
  189. package/dist/secrets/routes.d.ts.map +1 -1
  190. package/dist/secrets/routes.js +2 -7
  191. package/dist/secrets/routes.js.map +1 -1
  192. package/dist/server/action-discovery.d.ts +15 -0
  193. package/dist/server/action-discovery.d.ts.map +1 -1
  194. package/dist/server/action-discovery.js +49 -0
  195. package/dist/server/action-discovery.js.map +1 -1
  196. package/dist/server/agent-chat-plugin.d.ts +5 -0
  197. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  198. package/dist/server/agent-chat-plugin.js +81 -20
  199. package/dist/server/agent-chat-plugin.js.map +1 -1
  200. package/dist/server/agent-discovery.d.ts.map +1 -1
  201. package/dist/server/agent-discovery.js +5 -7
  202. package/dist/server/agent-discovery.js.map +1 -1
  203. package/dist/server/auth.d.ts +16 -20
  204. package/dist/server/auth.d.ts.map +1 -1
  205. package/dist/server/auth.js +115 -333
  206. package/dist/server/auth.js.map +1 -1
  207. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  208. package/dist/server/core-routes-plugin.js +23 -16
  209. package/dist/server/core-routes-plugin.js.map +1 -1
  210. package/dist/server/credential-provider.d.ts.map +1 -1
  211. package/dist/server/credential-provider.js +1 -2
  212. package/dist/server/credential-provider.js.map +1 -1
  213. package/dist/server/google-oauth.d.ts +14 -2
  214. package/dist/server/google-oauth.d.ts.map +1 -1
  215. package/dist/server/google-oauth.js +32 -10
  216. package/dist/server/google-oauth.js.map +1 -1
  217. package/dist/server/index.d.ts +3 -3
  218. package/dist/server/index.d.ts.map +1 -1
  219. package/dist/server/index.js +2 -2
  220. package/dist/server/index.js.map +1 -1
  221. package/dist/server/oauth-helpers.d.ts +2 -4
  222. package/dist/server/oauth-helpers.d.ts.map +1 -1
  223. package/dist/server/oauth-helpers.js +2 -4
  224. package/dist/server/oauth-helpers.js.map +1 -1
  225. package/dist/server/transcribe-voice.d.ts.map +1 -1
  226. package/dist/server/transcribe-voice.js +2 -4
  227. package/dist/server/transcribe-voice.js.map +1 -1
  228. package/dist/triggers/dispatcher.d.ts.map +1 -1
  229. package/dist/triggers/dispatcher.js +0 -3
  230. package/dist/triggers/dispatcher.js.map +1 -1
  231. package/dist/vite/client.d.ts.map +1 -1
  232. package/dist/vite/client.js +13 -0
  233. package/dist/vite/client.js.map +1 -1
  234. package/docs/content/actions.md +1 -0
  235. package/docs/content/authentication.md +3 -20
  236. package/docs/content/creating-templates.md +1 -1
  237. package/docs/content/deployment.md +0 -1
  238. package/docs/content/security.md +0 -1
  239. package/docs/content/template-analytics.md +10 -0
  240. package/docs/content/template-calendar.md +10 -0
  241. package/docs/content/template-clips.md +10 -0
  242. package/docs/content/template-content.md +11 -1
  243. package/docs/content/template-dispatch.md +10 -0
  244. package/docs/content/template-forms.md +10 -0
  245. package/docs/content/template-mail.md +10 -0
  246. package/docs/content/template-slides.md +11 -1
  247. package/docs/content/template-starter.md +11 -1
  248. package/docs/content/template-video.md +10 -0
  249. package/package.json +1 -1
  250. package/dist/client/dev-mode.d.ts +0 -14
  251. package/dist/client/dev-mode.d.ts.map +0 -1
  252. package/dist/client/dev-mode.js +0 -14
  253. package/dist/client/dev-mode.js.map +0 -1
  254. package/dist/server/local-migration.d.ts +0 -41
  255. package/dist/server/local-migration.d.ts.map +0 -1
  256. package/dist/server/local-migration.js +0 -235
  257. package/dist/server/local-migration.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PastedTextChip.js","sourceRoot":"","sources":["../../../src/client/composer/PastedTextChip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,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AAS,EAAC,0HAA0H,YACtI,IAAI,GACD,IACmB,GACH,IACJ,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport { IconClipboardText, IconX } from \"@tabler/icons-react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport type { Attachment } from \"@assistant-ui/react\";\nimport { cn } from \"../utils.js\";\nimport { countLines, unwrapAttachmentEnvelope } from \"./pasted-text.js\";\n\nfunction readAttachmentText(attachment: Attachment): Promise<string> | string {\n if (\"file\" in attachment && attachment.file instanceof File) {\n return attachment.file.text();\n }\n const textPart = attachment.content?.find(\n (p): p is { type: \"text\"; text: string } =>\n p.type === \"text\" && \"text\" in p && typeof p.text === \"string\",\n );\n return textPart ? unwrapAttachmentEnvelope(textPart.text) : \"\";\n}\n\nfunction usePastedAttachmentText(attachment: Attachment): {\n text: string;\n lines: number;\n chars: number;\n} {\n const [text, setText] = useState(\"\");\n\n useEffect(() => {\n let cancelled = false;\n const result = readAttachmentText(attachment);\n if (typeof result === \"string\") {\n setText(result);\n return;\n }\n result\n .then((value) => {\n if (!cancelled) setText(value);\n })\n .catch(() => {});\n return () => {\n cancelled = true;\n };\n }, [attachment]);\n\n return { text, lines: countLines(text), chars: text.length };\n}\n\nexport interface PastedTextChipProps {\n attachment: Attachment;\n onRemove?: (id: string) => void;\n /** Compact variant rendered inside sent user messages. */\n compact?: boolean;\n}\n\nexport function PastedTextChip({\n attachment,\n onRemove,\n compact = false,\n}: PastedTextChipProps) {\n const [open, setOpen] = useState(false);\n const { text, lines, chars } = usePastedAttachmentText(attachment);\n\n const handleRemove = useCallback(\n (event: React.MouseEvent) => {\n event.stopPropagation();\n onRemove?.(attachment.id);\n },\n [attachment.id, onRemove],\n );\n\n const summary = lines > 0 ? `${lines} lines` : `${chars} chars`;\n\n return (\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger asChild>\n <button\n type=\"button\"\n className={cn(\n \"group relative inline-flex items-center gap-2 rounded-md border border-border/70 bg-muted/50 text-left text-foreground hover:bg-muted/70 cursor-pointer\",\n compact\n ? \"max-w-[220px] px-2 py-1.5 text-xs\"\n : \"max-w-[260px] px-2.5 py-2 text-xs\",\n onRemove && !compact && \"pr-7\",\n )}\n aria-label=\"Preview pasted text\"\n >\n <span\n className={cn(\n \"flex shrink-0 items-center justify-center rounded bg-background text-muted-foreground\",\n compact ? \"h-6 w-6\" : \"h-8 w-8\",\n )}\n >\n <IconClipboardText\n className={compact ? \"h-3.5 w-3.5\" : \"h-4 w-4\"}\n />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate font-medium\">Pasted text</span>\n <span className=\"block text-[11px] text-muted-foreground\">\n {summary}\n </span>\n </span>\n {onRemove && (\n <span\n role=\"button\"\n tabIndex={-1}\n onClick={handleRemove}\n aria-label=\"Remove pasted text\"\n className={cn(\n \"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\",\n compact ? \"\" : \"absolute right-1.5 top-1.5\",\n )}\n >\n <IconX className=\"h-3 w-3\" />\n </span>\n )}\n </button>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side=\"top\"\n align=\"start\"\n sideOffset={6}\n collisionPadding={12}\n className=\"z-50 w-[min(560px,calc(100vw-32px))] rounded-lg border border-border bg-popover text-popover-foreground shadow-lg animate-in fade-in-0 zoom-in-95\"\n >\n <div className=\"flex items-center justify-between gap-2 border-b border-border px-3 py-2\">\n <div className=\"flex items-center gap-2 min-w-0\">\n <IconClipboardText className=\"h-4 w-4 shrink-0 text-muted-foreground\" />\n <span className=\"text-sm font-medium truncate\">Pasted text</span>\n <span className=\"text-[11px] text-muted-foreground shrink-0\">\n {lines} lines · {chars} chars\n </span>\n </div>\n <button\n type=\"button\"\n onClick={() => setOpen(false)}\n aria-label=\"Close preview\"\n className=\"flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3.5 w-3.5\" />\n </button>\n </div>\n <pre className=\"max-h-[60vh] overflow-auto px-3 py-2 text-[12px] leading-[1.5] whitespace-pre-wrap break-words font-mono text-foreground\">\n {text}\n </pre>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n"]}
@@ -16,12 +16,14 @@ export interface PromptComposerProps {
16
16
  className?: string;
17
17
  /** Forwarded to TiptapComposer for draft persistence. */
18
18
  draftScope?: string;
19
- /** Show the model selector (default: false). */
19
+ /** Show the model selector (default: true). */
20
20
  showModelSelector?: boolean;
21
21
  /** Show the voice dictation button (default: true). */
22
22
  voiceEnabled?: boolean;
23
- /** Show file upload controls and pass submitted files to onSubmit. */
23
+ /** Show file upload controls and pass submitted files to onSubmit (default: true). */
24
24
  attachmentsEnabled?: boolean;
25
+ /** Called whenever the plain editor text changes. */
26
+ onTextChange?: (text: string) => void;
25
27
  /** Imperative handle for focusing the composer. */
26
28
  composerRef?: Ref<TiptapComposerHandle>;
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PromptComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAuB1E,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,EAAE,EAC3B,UAAU,EAAE,SAAS,EAAE,KACpB,IAAI,CAAC;IACV,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OA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C;IACvB,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,mDAAmD;IACnD,WAAW,CAAC,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC;CACzC;AA4OD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAqBxD"}
@@ -6,6 +6,8 @@ import { IconX } from "@tabler/icons-react";
6
6
  import { cn } from "../utils.js";
7
7
  import { TiptapComposer } from "./TiptapComposer.js";
8
8
  import { useChatModels } from "../use-chat-models.js";
9
+ import { isPastedTextAttachmentName } from "./pasted-text.js";
10
+ import { PastedTextChip } from "./PastedTextChip.js";
9
11
  // Minimal pass-through adapter. PromptComposer always submits through
10
12
  // onSubmitOverride, so the runtime never actually calls this — but
11
13
  // `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.
@@ -57,6 +59,9 @@ function AttachmentChip({ attachment, onRemove, }) {
57
59
  if (src?.startsWith("blob:"))
58
60
  URL.revokeObjectURL(src);
59
61
  }, [src]);
62
+ if (isPastedTextAttachmentName(attachment.name)) {
63
+ return _jsx(PastedTextChip, { attachment: attachment, onRemove: onRemove });
64
+ }
60
65
  if (src) {
61
66
  return (_jsxs("div", { className: "group relative h-16 w-16 overflow-hidden rounded-lg border border-border/70 bg-muted/50", children: [_jsx("img", { src: src, alt: attachment.name, className: "h-full w-full object-cover" }), _jsx("button", { type: "button", onClick: () => onRemove(attachment.id), "aria-label": `Remove ${attachment.name}`, className: "absolute right-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground", children: _jsx(IconX, { className: "h-3 w-3" }) })] }));
62
67
  }
@@ -72,7 +77,7 @@ function PromptAttachmentStrip() {
72
77
  return null;
73
78
  return (_jsx("div", { className: "flex flex-wrap gap-2 px-2 pt-2", children: attachments.map((attachment) => (_jsx(AttachmentChip, { attachment: attachment, onRemove: handleRemove }, attachment.id))) }));
74
79
  }
75
- function PromptComposerInner({ onSubmit, placeholder, disabled, autoFocus, className, draftScope, showModelSelector, voiceEnabled = true, attachmentsEnabled = false, composerRef, }) {
80
+ function PromptComposerInner({ onSubmit, placeholder, disabled, autoFocus, className, draftScope, showModelSelector = true, voiceEnabled = true, attachmentsEnabled = true, onTextChange, composerRef, }) {
76
81
  const localRef = useRef(null);
77
82
  const handleRef = composerRef ?? localRef;
78
83
  const models = useChatModels();
@@ -87,17 +92,40 @@ function PromptComposerInner({ onSubmit, placeholder, disabled, autoFocus, class
87
92
  }, 50);
88
93
  return () => window.clearTimeout(id);
89
94
  }, [autoFocus, handleRef]);
90
- const handleSubmit = useCallback((text, references, attachments) => {
95
+ const handleSubmit = useCallback(async (text, references, attachments) => {
96
+ // PromptComposer hosts (NewWorkspaceAppFlow, create-tool, create-deck,
97
+ // …) submit a single string prompt — they don't run the assistant-ui
98
+ // attachment send pipeline. TiptapComposer auto-converts large pastes
99
+ // into a "Pasted text" chip, which would otherwise disappear into an
100
+ // unprocessed File. Inline the chip body back into the prompt text so
101
+ // newlines and full content survive the round-trip.
91
102
  const files = [];
103
+ const pastedTextBlocks = [];
92
104
  for (const att of attachments ?? []) {
93
105
  const a = att;
94
106
  if ("file" in a && a.file instanceof File) {
95
- files.push(a.file);
107
+ const file = a.file;
108
+ if (isPastedTextAttachmentName(file.name)) {
109
+ try {
110
+ pastedTextBlocks.push(await file.text());
111
+ }
112
+ catch {
113
+ // If we can't read it, fall back to surfacing it as a regular
114
+ // attachment file rather than silently losing it.
115
+ files.push(file);
116
+ }
117
+ }
118
+ else {
119
+ files.push(file);
120
+ }
96
121
  }
97
122
  }
98
- onSubmit(text, files, references);
123
+ const finalText = pastedTextBlocks.length
124
+ ? [text.trim(), ...pastedTextBlocks].filter(Boolean).join("\n\n")
125
+ : text;
126
+ onSubmit(finalText, files, references);
99
127
  }, [onSubmit]);
100
- return (_jsx("div", { className: cn("agent-composer-area flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring", className), children: _jsxs(ComposerPrimitive.Root, { className: "flex flex-col", children: [_jsx(PromptAttachmentStrip, {}), _jsx(TiptapComposer, { focusRef: handleRef, disabled: disabled, placeholder: placeholder, onSubmit: handleSubmit, plusMenuMode: attachmentsEnabled ? "upload-only" : "hidden", voiceEnabled: voiceEnabled, draftScope: draftScope, selectedModel: showModelSelector ? models.selectedModel : undefined, selectedEffort: showModelSelector ? models.selectedEffort : undefined, availableModels: showModelSelector ? models.availableModels : undefined, onModelChange: showModelSelector ? models.onModelChange : undefined, onEffortChange: showModelSelector ? models.onEffortChange : undefined })] }) }));
128
+ return (_jsx("div", { className: cn("agent-composer-area flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring", className), children: _jsxs(ComposerPrimitive.Root, { className: "flex flex-col", children: [_jsx(PromptAttachmentStrip, {}), _jsx(TiptapComposer, { focusRef: handleRef, disabled: disabled, placeholder: placeholder, onSubmit: handleSubmit, plusMenuMode: attachmentsEnabled ? "upload-only" : "hidden", voiceEnabled: voiceEnabled, onTextChange: onTextChange, draftScope: draftScope, selectedModel: showModelSelector ? models.selectedModel : undefined, selectedEffort: showModelSelector ? models.selectedEffort : undefined, availableModels: showModelSelector ? models.availableModels : undefined, onModelChange: showModelSelector ? models.onModelChange : undefined, onEffortChange: showModelSelector ? models.onEffortChange : undefined })] }) }));
101
129
  }
102
130
  /**
103
131
  * Standalone composer that mirrors the agent sidebar's input experience —
@@ -1 +1 @@
1
- {"version":3,"file":"PromptComposer.js","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAY,MAAM,OAAO,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,MAAM,EACN,WAAW,EACX,e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AI,IAAC,SAAS,EAAC,UAAU,YACxC,KAAC,mBAAmB,OAAK,KAAK,GAAI,GACb,GACE,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, type Ref } from \"react\";\nimport {\n AssistantRuntimeProvider,\n ComposerPrimitive,\n ThreadPrimitive,\n useAui,\n useComposer,\n useLocalRuntime,\n} from \"@assistant-ui/react\";\nimport type {\n Attachment,\n AttachmentAdapter,\n ChatModelAdapter,\n CompleteAttachment,\n PendingAttachment,\n} from \"@assistant-ui/react\";\nimport {\n CompositeAttachmentAdapter,\n SimpleImageAttachmentAdapter,\n SimpleTextAttachmentAdapter,\n} from \"@assistant-ui/react\";\nimport { IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../utils.js\";\nimport { TiptapComposer, type TiptapComposerHandle } from \"./TiptapComposer.js\";\nimport type { Reference } from \"./types.js\";\nimport { useChatModels } from \"../use-chat-models.js\";\n\n/**\n * Files the user attached via the \"+\" button in PromptComposer. The host owns\n * what to do with them — typically POST to a per-app upload endpoint and pass\n * the resulting URLs/paths into the prompt that gets sent to the agent.\n */\nexport type PromptComposerFile = File;\n\nexport interface PromptComposerProps {\n /** Called when the user submits the composer. */\n onSubmit: (\n text: string,\n files: PromptComposerFile[],\n references: Reference[],\n ) => void;\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n /** Forwarded to TiptapComposer for draft persistence. */\n draftScope?: string;\n /** Show the model selector (default: false). */\n showModelSelector?: boolean;\n /** Show the voice dictation button (default: true). */\n voiceEnabled?: boolean;\n /** Show file upload controls and pass submitted files to onSubmit. */\n attachmentsEnabled?: boolean;\n /** Imperative handle for focusing the composer. */\n composerRef?: Ref<TiptapComposerHandle>;\n}\n\n// Minimal pass-through adapter. PromptComposer always submits through\n// onSubmitOverride, so the runtime never actually calls this — but\n// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.\nconst NOOP_ADAPTER: ChatModelAdapter = {\n async *run() {\n return;\n },\n};\n\n/**\n * Local clone of AssistantChat's BinaryDocumentAttachmentAdapter so PDFs and\n * PPTX files can be attached without dragging the whole assistant chat module\n * into bundles that just want a prompt popover.\n */\nclass BinaryDocumentAttachmentAdapter implements AttachmentAdapter {\n public accept =\n \"application/pdf,application/vnd.openxmlformats-officedocument.presentationml.presentation,.pdf,.pptx\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: state.file.name,\n type: \"document\",\n name: state.file.name,\n contentType: state.file.type || \"application/octet-stream\",\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [],\n };\n }\n\n public async remove() {\n /* noop */\n }\n}\n\nfunction getImageSrc(attachment: Attachment): string | null {\n if (attachment.type !== \"image\") return null;\n if (\"file\" in attachment && attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n const imagePart = attachment.content?.find((part) => part.type === \"image\");\n return imagePart && \"image\" in imagePart ? imagePart.image : null;\n}\n\nfunction AttachmentChip({\n attachment,\n onRemove,\n}: {\n attachment: Attachment;\n onRemove: (id: string) => void;\n}) {\n const src = useMemo(() => getImageSrc(attachment), [attachment]);\n useEffect(\n () => () => {\n if (src?.startsWith(\"blob:\")) URL.revokeObjectURL(src);\n },\n [src],\n );\n\n if (src) {\n return (\n <div className=\"group relative h-16 w-16 overflow-hidden rounded-lg border border-border/70 bg-muted/50\">\n <img\n src={src}\n alt={attachment.name}\n className=\"h-full w-full object-cover\"\n />\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"absolute right-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"group relative inline-flex max-w-[200px] items-center gap-2 rounded-md border border-border/70 bg-muted/50 px-2 py-1.5 text-xs\">\n <div className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded bg-background text-[9px] font-semibold uppercase text-muted-foreground\">\n {attachment.name.split(\".\").pop() || \"file\"}\n </div>\n <span className=\"min-w-0 truncate font-medium\">{attachment.name}</span>\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n}\n\nfunction PromptAttachmentStrip() {\n const attachments = useComposer((state) => state.attachments);\n const aui = useAui();\n\n const handleRemove = useCallback(\n (id: string) => {\n void aui.composer().attachment({ id }).remove();\n },\n [aui],\n );\n\n if (attachments.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-2 px-2 pt-2\">\n {attachments.map((attachment) => (\n <AttachmentChip\n key={attachment.id}\n attachment={attachment}\n onRemove={handleRemove}\n />\n ))}\n </div>\n );\n}\n\nfunction PromptComposerInner({\n onSubmit,\n placeholder,\n disabled,\n autoFocus,\n className,\n draftScope,\n showModelSelector,\n voiceEnabled = true,\n attachmentsEnabled = false,\n composerRef,\n}: PromptComposerProps) {\n const localRef = useRef<TiptapComposerHandle>(null);\n const handleRef = composerRef ?? localRef;\n const models = useChatModels();\n\n useEffect(() => {\n if (!autoFocus) return;\n const id = window.setTimeout(() => {\n const target =\n typeof handleRef === \"object\" && handleRef && \"current\" in handleRef\n ? handleRef.current\n : null;\n target?.focus();\n }, 50);\n return () => window.clearTimeout(id);\n }, [autoFocus, handleRef]);\n\n const handleSubmit = useCallback(\n (\n text: string,\n references: Reference[],\n attachments?: ReadonlyArray<unknown>,\n ) => {\n const files: File[] = [];\n for (const att of attachments ?? []) {\n const a = att as Attachment;\n if (\"file\" in a && a.file instanceof File) {\n files.push(a.file);\n }\n }\n onSubmit(text, files, references);\n },\n [onSubmit],\n );\n\n return (\n <div\n className={cn(\n \"agent-composer-area flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring\",\n className,\n )}\n >\n <ComposerPrimitive.Root className=\"flex flex-col\">\n <PromptAttachmentStrip />\n <TiptapComposer\n focusRef={handleRef}\n disabled={disabled}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n plusMenuMode={attachmentsEnabled ? \"upload-only\" : \"hidden\"}\n voiceEnabled={voiceEnabled}\n draftScope={draftScope}\n selectedModel={showModelSelector ? models.selectedModel : undefined}\n selectedEffort={showModelSelector ? models.selectedEffort : undefined}\n availableModels={\n showModelSelector ? models.availableModels : undefined\n }\n onModelChange={showModelSelector ? models.onModelChange : undefined}\n onEffortChange={showModelSelector ? models.onEffortChange : undefined}\n />\n </ComposerPrimitive.Root>\n </div>\n );\n}\n\n/**\n * Standalone composer that mirrors the agent sidebar's input experience —\n * voice dictation, file upload, model selector, submit-on-Enter — for use in\n * popovers and inline prompt forms (create tool, create deck, create dashboard,\n * the Dispatch new-app flow, etc.).\n *\n * The host owns submission: when the user presses Enter or clicks submit,\n * `onSubmit(text, files, references)` is called. PromptComposer runs its own\n * minimal assistant-ui runtime so it can be dropped into any subtree without\n * needing the outer chat to be mounted.\n */\nexport function PromptComposer(props: PromptComposerProps) {\n const attachmentAdapter = useMemo(\n () =>\n new CompositeAttachmentAdapter([\n new SimpleImageAttachmentAdapter(),\n new BinaryDocumentAttachmentAdapter(),\n new SimpleTextAttachmentAdapter(),\n ]),\n [],\n );\n const runtime = useLocalRuntime(NOOP_ADAPTER, {\n adapters: { attachments: attachmentAdapter },\n });\n\n return (\n <AssistantRuntimeProvider runtime={runtime}>\n <ThreadPrimitive.Root className=\"contents\">\n <PromptComposerInner {...props} />\n </ThreadPrimitive.Root>\n </AssistantRuntimeProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"PromptComposer.js","sourceRoot":"","sources":["../../../src/client/composer/PromptComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,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E,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, type Ref } from \"react\";\nimport {\n AssistantRuntimeProvider,\n ComposerPrimitive,\n ThreadPrimitive,\n useAui,\n useComposer,\n useLocalRuntime,\n} from \"@assistant-ui/react\";\nimport type {\n Attachment,\n AttachmentAdapter,\n ChatModelAdapter,\n CompleteAttachment,\n PendingAttachment,\n} from \"@assistant-ui/react\";\nimport {\n CompositeAttachmentAdapter,\n SimpleImageAttachmentAdapter,\n SimpleTextAttachmentAdapter,\n} from \"@assistant-ui/react\";\nimport { IconX } from \"@tabler/icons-react\";\nimport { cn } from \"../utils.js\";\nimport { TiptapComposer, type TiptapComposerHandle } from \"./TiptapComposer.js\";\nimport type { Reference } from \"./types.js\";\nimport { useChatModels } from \"../use-chat-models.js\";\nimport { isPastedTextAttachmentName } from \"./pasted-text.js\";\nimport { PastedTextChip } from \"./PastedTextChip.js\";\n\n/**\n * Files the user attached via the \"+\" button in PromptComposer. The host owns\n * what to do with them — typically POST to a per-app upload endpoint and pass\n * the resulting URLs/paths into the prompt that gets sent to the agent.\n */\nexport type PromptComposerFile = File;\n\nexport interface PromptComposerProps {\n /** Called when the user submits the composer. */\n onSubmit: (\n text: string,\n files: PromptComposerFile[],\n references: Reference[],\n ) => void;\n placeholder?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n /** Forwarded to TiptapComposer for draft persistence. */\n draftScope?: string;\n /** Show the model selector (default: true). */\n showModelSelector?: boolean;\n /** Show the voice dictation button (default: true). */\n voiceEnabled?: boolean;\n /** Show file upload controls and pass submitted files to onSubmit (default: true). */\n attachmentsEnabled?: boolean;\n /** Called whenever the plain editor text changes. */\n onTextChange?: (text: string) => void;\n /** Imperative handle for focusing the composer. */\n composerRef?: Ref<TiptapComposerHandle>;\n}\n\n// Minimal pass-through adapter. PromptComposer always submits through\n// onSubmitOverride, so the runtime never actually calls this — but\n// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.\nconst NOOP_ADAPTER: ChatModelAdapter = {\n async *run() {\n return;\n },\n};\n\n/**\n * Local clone of AssistantChat's BinaryDocumentAttachmentAdapter so PDFs and\n * PPTX files can be attached without dragging the whole assistant chat module\n * into bundles that just want a prompt popover.\n */\nclass BinaryDocumentAttachmentAdapter implements AttachmentAdapter {\n public accept =\n \"application/pdf,application/vnd.openxmlformats-officedocument.presentationml.presentation,.pdf,.pptx\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: state.file.name,\n type: \"document\",\n name: state.file.name,\n contentType: state.file.type || \"application/octet-stream\",\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [],\n };\n }\n\n public async remove() {\n /* noop */\n }\n}\n\nfunction getImageSrc(attachment: Attachment): string | null {\n if (attachment.type !== \"image\") return null;\n if (\"file\" in attachment && attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n const imagePart = attachment.content?.find((part) => part.type === \"image\");\n return imagePart && \"image\" in imagePart ? imagePart.image : null;\n}\n\nfunction AttachmentChip({\n attachment,\n onRemove,\n}: {\n attachment: Attachment;\n onRemove: (id: string) => void;\n}) {\n const src = useMemo(() => getImageSrc(attachment), [attachment]);\n useEffect(\n () => () => {\n if (src?.startsWith(\"blob:\")) URL.revokeObjectURL(src);\n },\n [src],\n );\n\n if (isPastedTextAttachmentName(attachment.name)) {\n return <PastedTextChip attachment={attachment} onRemove={onRemove} />;\n }\n\n if (src) {\n return (\n <div className=\"group relative h-16 w-16 overflow-hidden rounded-lg border border-border/70 bg-muted/50\">\n <img\n src={src}\n alt={attachment.name}\n className=\"h-full w-full object-cover\"\n />\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"absolute right-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"group relative inline-flex max-w-[200px] items-center gap-2 rounded-md border border-border/70 bg-muted/50 px-2 py-1.5 text-xs\">\n <div className=\"flex h-6 w-6 shrink-0 items-center justify-center rounded bg-background text-[9px] font-semibold uppercase text-muted-foreground\">\n {attachment.name.split(\".\").pop() || \"file\"}\n </div>\n <span className=\"min-w-0 truncate font-medium\">{attachment.name}</span>\n <button\n type=\"button\"\n onClick={() => onRemove(attachment.id)}\n aria-label={`Remove ${attachment.name}`}\n className=\"flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground\"\n >\n <IconX className=\"h-3 w-3\" />\n </button>\n </div>\n );\n}\n\nfunction PromptAttachmentStrip() {\n const attachments = useComposer((state) => state.attachments);\n const aui = useAui();\n\n const handleRemove = useCallback(\n (id: string) => {\n void aui.composer().attachment({ id }).remove();\n },\n [aui],\n );\n\n if (attachments.length === 0) return null;\n return (\n <div className=\"flex flex-wrap gap-2 px-2 pt-2\">\n {attachments.map((attachment) => (\n <AttachmentChip\n key={attachment.id}\n attachment={attachment}\n onRemove={handleRemove}\n />\n ))}\n </div>\n );\n}\n\nfunction PromptComposerInner({\n onSubmit,\n placeholder,\n disabled,\n autoFocus,\n className,\n draftScope,\n showModelSelector = true,\n voiceEnabled = true,\n attachmentsEnabled = true,\n onTextChange,\n composerRef,\n}: PromptComposerProps) {\n const localRef = useRef<TiptapComposerHandle>(null);\n const handleRef = composerRef ?? localRef;\n const models = useChatModels();\n\n useEffect(() => {\n if (!autoFocus) return;\n const id = window.setTimeout(() => {\n const target =\n typeof handleRef === \"object\" && handleRef && \"current\" in handleRef\n ? handleRef.current\n : null;\n target?.focus();\n }, 50);\n return () => window.clearTimeout(id);\n }, [autoFocus, handleRef]);\n\n const handleSubmit = useCallback(\n async (\n text: string,\n references: Reference[],\n attachments?: ReadonlyArray<unknown>,\n ) => {\n // PromptComposer hosts (NewWorkspaceAppFlow, create-tool, create-deck,\n // …) submit a single string prompt — they don't run the assistant-ui\n // attachment send pipeline. TiptapComposer auto-converts large pastes\n // into a \"Pasted text\" chip, which would otherwise disappear into an\n // unprocessed File. Inline the chip body back into the prompt text so\n // newlines and full content survive the round-trip.\n const files: File[] = [];\n const pastedTextBlocks: string[] = [];\n for (const att of attachments ?? []) {\n const a = att as Attachment;\n if (\"file\" in a && a.file instanceof File) {\n const file = a.file;\n if (isPastedTextAttachmentName(file.name)) {\n try {\n pastedTextBlocks.push(await file.text());\n } catch {\n // If we can't read it, fall back to surfacing it as a regular\n // attachment file rather than silently losing it.\n files.push(file);\n }\n } else {\n files.push(file);\n }\n }\n }\n const finalText = pastedTextBlocks.length\n ? [text.trim(), ...pastedTextBlocks].filter(Boolean).join(\"\\n\\n\")\n : text;\n onSubmit(finalText, files, references);\n },\n [onSubmit],\n );\n\n return (\n <div\n className={cn(\n \"agent-composer-area flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring\",\n className,\n )}\n >\n <ComposerPrimitive.Root className=\"flex flex-col\">\n <PromptAttachmentStrip />\n <TiptapComposer\n focusRef={handleRef}\n disabled={disabled}\n placeholder={placeholder}\n onSubmit={handleSubmit}\n plusMenuMode={attachmentsEnabled ? \"upload-only\" : \"hidden\"}\n voiceEnabled={voiceEnabled}\n onTextChange={onTextChange}\n draftScope={draftScope}\n selectedModel={showModelSelector ? models.selectedModel : undefined}\n selectedEffort={showModelSelector ? models.selectedEffort : undefined}\n availableModels={\n showModelSelector ? models.availableModels : undefined\n }\n onModelChange={showModelSelector ? models.onModelChange : undefined}\n onEffortChange={showModelSelector ? models.onEffortChange : undefined}\n />\n </ComposerPrimitive.Root>\n </div>\n );\n}\n\n/**\n * Standalone composer that mirrors the agent sidebar's input experience —\n * voice dictation, file upload, model selector, submit-on-Enter — for use in\n * popovers and inline prompt forms (create tool, create deck, create dashboard,\n * the Dispatch new-app flow, etc.).\n *\n * The host owns submission: when the user presses Enter or clicks submit,\n * `onSubmit(text, files, references)` is called. PromptComposer runs its own\n * minimal assistant-ui runtime so it can be dropped into any subtree without\n * needing the outer chat to be mounted.\n */\nexport function PromptComposer(props: PromptComposerProps) {\n const attachmentAdapter = useMemo(\n () =>\n new CompositeAttachmentAdapter([\n new SimpleImageAttachmentAdapter(),\n new BinaryDocumentAttachmentAdapter(),\n new SimpleTextAttachmentAdapter(),\n ]),\n [],\n );\n const runtime = useLocalRuntime(NOOP_ADAPTER, {\n adapters: { attachments: attachmentAdapter },\n });\n\n return (\n <AssistantRuntimeProvider runtime={runtime}>\n <ThreadPrimitive.Root className=\"contents\">\n <PromptComposerInner {...props} />\n </ThreadPrimitive.Root>\n </AssistantRuntimeProvider>\n );\n}\n"]}
@@ -15,6 +15,8 @@ interface TiptapComposerProps {
15
15
  * attachments so callers (e.g. PromptComposer) can surface uploaded files.
16
16
  */
17
17
  onSubmit?: (text: string, references: Reference[], attachments?: ReadonlyArray<unknown>) => void;
18
+ /** Called whenever the plain editor text changes. */
19
+ onTextChange?: (text: string) => void;
18
20
  /** Custom action button (e.g. stop button) to render instead of the default send button. */
19
21
  actionButton?: React.ReactNode;
20
22
  /** Extra button to render alongside the default send button (e.g. stop while running). */
@@ -53,7 +55,17 @@ interface TiptapComposerProps {
53
55
  * `"hidden"` hides attachment controls for text-only prompt surfaces.
54
56
  */
55
57
  plusMenuMode?: "full" | "upload-only" | "hidden";
58
+ /**
59
+ * When true and the composer is running inside the Builder.io webview/iframe,
60
+ * intercept "build me an app/agent" prompts and forward them to the parent
61
+ * Builder chat via `builder.submitChat` instead of sending to the local
62
+ * agent. Off by default — the chat sidebar opts in; standalone prompt
63
+ * forms (NewWorkspaceAppFlow, etc.) handle delegation themselves with
64
+ * extra context (vault keys, computed app ids) that the raw composer
65
+ * text lacks.
66
+ */
67
+ interceptBuildRequestsForBuilder?: boolean;
56
68
  }
57
- export declare function TiptapComposer({ placeholder, disabled, focusRef, onSubmit, actionButton, extraActionButton, attachButton, onSlashCommand, execMode, onExecModeChange, voiceEnabled, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, draftScope, plusMenuMode, }: TiptapComposerProps): import("react/jsx-runtime").JSX.Element;
69
+ export declare function TiptapComposer({ placeholder, disabled, focusRef, onSubmit, onTextChange, actionButton, extraActionButton, attachButton, onSlashCommand, execMode, onExecModeChange, voiceEnabled, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, draftScope, plusMenuMode, interceptBuildRequestsForBuilder, }: TiptapComposerProps): import("react/jsx-runtime").JSX.Element;
58
70
  export {};
59
71
  //# sourceMappingURL=TiptapComposer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TiptapComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/TiptapComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAgCf,OAAO,KAAK,EAGV,SAAS,EAGV,MAAM,YAAY,CAAC;AAMpB,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAwHD,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjC,UAAU,mBAAmB;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,EAAE,EACvB,WAAW,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,KACjC,IAAI,CAAC;IACV,4FAA4F;IAC5F,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,0FAA0F;IAC1F,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC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ACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,2CAA2C;IAC3C,eAAe,CAAC,EAAE,KAAK,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;IACH,uCAAuC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,kDAAkD;IAClD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC;IACjD;;;;;;;;OAQG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AA8YD,wBAAgB,cAAc,CAAC,EAC7B,WAAgC,EAChC,QAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,YAAmB,EACnB,aAAa,EACb,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAqB,EACrB,gCAAwC,GACzC,EAAE,mBAAmB,2CAi6BrB"}
@@ -17,7 +17,9 @@ import { useVoiceDictation } from "./useVoiceDictation.js";
17
17
  import { VoiceButton, VoiceRecordingOverlay } from "./VoiceButton.js";
18
18
  import { ComposerPlusMenu } from "./ComposerPlusMenu.js";
19
19
  import { sendToAgentChat } from "../agent-chat.js";
20
+ import { tryDelegateBuildRequestToBuilder } from "../builder-frame.js";
20
21
  import { getComposerDraftKey } from "./draft-key.js";
22
+ import { createPastedTextFile, shouldConvertPasteToAttachment, } from "./pasted-text.js";
21
23
  import { getReasoningEffortOptionsForModel, reasoningEffortLabel, } from "../../shared/reasoning-effort.js";
22
24
  const BUILT_IN_COMMANDS = [
23
25
  { name: "clear", description: "Start a new chat", icon: "clear" },
@@ -234,7 +236,7 @@ function ModelSelector({ model, effort = "auto", engines, onChange, onEffortChan
234
236
  builderFlow.start();
235
237
  }, disabled: builderFlow.connecting, className: "flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-accent/50 disabled:opacity-60", children: [_jsx(IconPlugConnected, { className: "h-4 w-4 shrink-0 mt-0.5 text-blue-500" }), _jsxs("span", { className: "flex-1 min-w-0", children: [_jsx("span", { className: "block text-[12px] font-medium text-foreground", children: builderFlow.connecting
236
238
  ? "Connecting Builder.io…"
237
- : "Connect Builder.io" }), _jsx("span", { className: "block text-[11px] text-muted-foreground", children: "Free access to Claude, OpenAI & Gemini" })] })] }), _jsx("div", { className: "my-1 border-t border-border" })] })), engines.map((group) => {
239
+ : "Connect Builder.io" }), _jsx("span", { className: "block text-[11px] text-muted-foreground", children: "Free credits for Claude, OpenAI & Gemini" })] })] }), _jsx("div", { className: "my-1 border-t border-border" })] })), engines.map((group) => {
238
240
  const models = latestModelsOnly(group.models);
239
241
  const groupKey = `${group.engine}:${group.label}`;
240
242
  const isExpanded = expandedGroups.has(groupKey);
@@ -261,7 +263,7 @@ function ModelSelector({ model, effort = "auto", engines, onChange, onEffortChan
261
263
  : "opacity-40 cursor-default"}`, children: [_jsx("span", { className: "flex-1 min-w-0 text-[13px] text-foreground truncate", children: friendlyModelName(m) }), m === model && group.configured && (_jsx(IconCheck, { className: "h-3.5 w-3.5 shrink-0 text-blue-500" }))] }, m)))] }, groupKey));
262
264
  }), effortOptions.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 border-t border-border" }), _jsx("div", { className: "px-3 py-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wide", children: "Effort" }), effortOptions.map((option) => (_jsxs("button", { type: "button", onClick: () => onEffortChange?.(option), className: "flex w-full items-center gap-3 px-3 py-1.5 text-left hover:bg-accent/50", children: [_jsx("span", { className: "flex-1 min-w-0 text-[13px] text-foreground truncate", children: reasoningEffortLabel(option) }), option === effort && (_jsx(IconCheck, { className: "h-3.5 w-3.5 shrink-0 text-blue-500" }))] }, option)))] }))] }) })] }));
263
265
  }
264
- export function TiptapComposer({ placeholder = "Message agent...", disabled = false, focusRef, onSubmit, actionButton, extraActionButton, attachButton, onSlashCommand, execMode, onExecModeChange, voiceEnabled = true, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, draftScope, plusMenuMode = "full", }) {
266
+ export function TiptapComposer({ placeholder = "Message agent...", disabled = false, focusRef, onSubmit, onTextChange, actionButton, extraActionButton, attachButton, onSlashCommand, execMode, onExecModeChange, voiceEnabled = true, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, draftScope, plusMenuMode = "full", interceptBuildRequestsForBuilder = false, }) {
265
267
  const [popover, setPopover] = useState(null);
266
268
  const popoverRef = useRef(null);
267
269
  const composerRuntime = useComposerRuntime();
@@ -307,6 +309,8 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
307
309
  filteredSkillsRef.current = filteredSkills;
308
310
  const onSlashCommandRef = useRef(onSlashCommand);
309
311
  onSlashCommandRef.current = onSlashCommand;
312
+ const onTextChangeRef = useRef(onTextChange);
313
+ onTextChangeRef.current = onTextChange;
310
314
  const closePopover = useCallback(() => {
311
315
  setPopover(null);
312
316
  popoverStateRef.current = null;
@@ -356,6 +360,7 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
356
360
  ed.commands.focus("end");
357
361
  setEditorHasText(ed.state.doc.textContent.trim().length > 0);
358
362
  }
363
+ onTextChangeRef.current?.(ed.state.doc.textContent.trim());
359
364
  }
360
365
  catch { }
361
366
  },
@@ -375,6 +380,7 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
375
380
  });
376
381
  }
377
382
  setEditorHasText(hasContent);
383
+ onTextChangeRef.current?.(ed.state.doc.textContent.trim());
378
384
  // Debounce-save draft to localStorage
379
385
  clearTimeout(draftTimerRef.current);
380
386
  draftTimerRef.current = setTimeout(() => {
@@ -396,21 +402,42 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
396
402
  class: "flex-1 resize-none bg-transparent text-sm text-foreground outline-none leading-[1.625rem] min-h-[3.25rem] max-h-[10rem] overflow-y-auto",
397
403
  },
398
404
  handlePaste: (_view, event) => {
405
+ const pastedText = event.clipboardData?.getData("text/plain") ?? "";
399
406
  const files = Array.from(event.clipboardData?.files ?? []).filter((file) => file.type.startsWith("image/"));
400
- if (files.length === 0)
401
- return false;
402
- event.preventDefault();
403
- void Promise.all(files.map((file) => {
404
- // SimpleImageAttachmentAdapter uses file.name as the attachment id.
405
- // Clipboard images (e.g. screenshots) are typically all named
406
- // "image.png", so a second paste would replace the first instead of
407
- // appending. Prepend a unique token so each paste gets a distinct id.
408
- const uniqueName = `${Date.now()}-${Math.random().toString(36).slice(2)}-${file.name}`;
409
- return composerRuntime.addAttachment(new File([file], uniqueName, { type: file.type }));
410
- })).catch((error) => {
411
- console.error("Error adding pasted attachment:", error);
412
- });
413
- return true;
407
+ if (files.length > 0) {
408
+ event.preventDefault();
409
+ const attachments = files.map((file) => {
410
+ // SimpleImageAttachmentAdapter uses file.name as the attachment id.
411
+ // Clipboard images (e.g. screenshots) are typically all named
412
+ // "image.png", so a second paste would replace the first instead of
413
+ // appending. Prepend a unique token so each paste gets a distinct id.
414
+ const uniqueName = `${Date.now()}-${Math.random().toString(36).slice(2)}-${file.name}`;
415
+ return new File([file], uniqueName, { type: file.type });
416
+ });
417
+ // Google Docs rich clipboard payloads can contain both embedded
418
+ // image files and the document text. Since handling files means we
419
+ // prevent Tiptap's default paste, preserve any text as its own chip
420
+ // instead of silently dropping the source material.
421
+ if (pastedText.trim()) {
422
+ attachments.push(createPastedTextFile(pastedText));
423
+ }
424
+ void Promise.all(attachments.map((file) => composerRuntime.addAttachment(file))).catch((error) => {
425
+ console.error("Error adding pasted attachment:", error);
426
+ });
427
+ return true;
428
+ }
429
+ // Large text pastes turn into a `Pasted text` attachment chip so the
430
+ // prompt stays readable. Matches Claude.ai / Claude Code's UX.
431
+ if (shouldConvertPasteToAttachment(pastedText)) {
432
+ event.preventDefault();
433
+ void composerRuntime
434
+ .addAttachment(createPastedTextFile(pastedText))
435
+ .catch((error) => {
436
+ console.error("Error adding pasted-text attachment:", error);
437
+ });
438
+ return true;
439
+ }
440
+ return false;
414
441
  },
415
442
  handleKeyDown: (view, event) => {
416
443
  const pop = popoverStateRef.current;
@@ -773,6 +800,23 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
773
800
  closePopover();
774
801
  return;
775
802
  }
803
+ // Builder iframe delegation: when this app is mounted inside the
804
+ // Builder.io webview and the user typed a "build me an app/agent"
805
+ // prompt, hand it up to the parent Builder chat instead of sending
806
+ // it to this app's domain agent. Builder is the code-writing agent;
807
+ // the local agent (dispatch, mail, etc.) cannot scaffold workspace
808
+ // apps from inside its own iframe.
809
+ if (interceptBuildRequestsForBuilder &&
810
+ tryDelegateBuildRequestToBuilder(trimmed)) {
811
+ ed.commands.clearContent();
812
+ setEditorHasText(false);
813
+ try {
814
+ localStorage.removeItem(draftKey);
815
+ }
816
+ catch { }
817
+ closePopover();
818
+ return;
819
+ }
776
820
  if (onSubmit) {
777
821
  onSubmit(text, references, attachments);
778
822
  // Clear any pending attachments now that the host has them.
@@ -793,6 +837,7 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
793
837
  composerMode,
794
838
  composerRuntime,
795
839
  editor,
840
+ interceptBuildRequestsForBuilder,
796
841
  onSubmit,
797
842
  syncComposerState,
798
843
  ]);