@epam/ai-dial-chat-hooks 1.3.0-dev.37 → 1.3.0-dev.372

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 (578) hide show
  1. package/api-error/api-error.d.ts +2 -0
  2. package/api-error/api-error.d.ts.map +1 -1
  3. package/api-error/api-error.js +31 -23
  4. package/api-transport/create-unauthorized-middleware.js +4 -1
  5. package/attachment/attach-constraints.d.ts +31 -0
  6. package/attachment/attach-constraints.d.ts.map +1 -0
  7. package/attachment/attach-constraints.js +18 -0
  8. package/attachment/useAttachmentAction/useAttachmentAction.d.ts +1 -1
  9. package/attachment/useAttachmentAction/useAttachmentAction.d.ts.map +1 -1
  10. package/attachment/useAttachmentAction/useAttachmentAction.js +25 -28
  11. package/attachments.js +2 -1
  12. package/catalog/application-credentials.d.ts +15 -0
  13. package/catalog/application-credentials.d.ts.map +1 -0
  14. package/catalog/application-credentials.js +28 -0
  15. package/catalog/catalog-derivations.d.ts +5 -3
  16. package/catalog/catalog-derivations.d.ts.map +1 -1
  17. package/catalog/catalog-derivations.js +13 -6
  18. package/catalog/catalog-entity-kind.d.ts +31 -0
  19. package/catalog/catalog-entity-kind.d.ts.map +1 -0
  20. package/catalog/catalog-entity-kind.js +21 -0
  21. package/catalog/catalog-preferences.d.ts +8 -0
  22. package/catalog/catalog-preferences.d.ts.map +1 -0
  23. package/catalog/catalog-preferences.js +5 -0
  24. package/catalog/create-publish-api.d.ts +3 -1
  25. package/catalog/create-publish-api.d.ts.map +1 -1
  26. package/catalog/create-publish-api.js +4 -0
  27. package/catalog/deployment-id.d.ts +13 -4
  28. package/catalog/deployment-id.d.ts.map +1 -1
  29. package/catalog/deployment-id.js +17 -3
  30. package/catalog/entity-details.d.ts +2 -0
  31. package/catalog/entity-details.d.ts.map +1 -1
  32. package/catalog/favorite-entity-type.d.ts +5 -0
  33. package/catalog/favorite-entity-type.d.ts.map +1 -0
  34. package/catalog/favorite-entity-type.js +10 -0
  35. package/catalog/map-deployment-limits-to-input.d.ts +4 -3
  36. package/catalog/map-deployment-limits-to-input.d.ts.map +1 -1
  37. package/catalog/map-deployment-limits-to-input.js +3 -4
  38. package/catalog/map-deployment-to-catalog-item.d.ts +12 -1
  39. package/catalog/map-deployment-to-catalog-item.d.ts.map +1 -1
  40. package/catalog/map-deployment-to-catalog-item.js +22 -15
  41. package/catalog/map-entity-details-to-catalog.d.ts.map +1 -1
  42. package/catalog/map-entity-details-to-catalog.js +69 -24
  43. package/catalog/map-skill-to-catalog-item.d.ts +4 -5
  44. package/catalog/map-skill-to-catalog-item.d.ts.map +1 -1
  45. package/catalog/map-skill-to-catalog-item.js +29 -38
  46. package/catalog/publish.d.ts +1 -1
  47. package/catalog/publish.d.ts.map +1 -1
  48. package/catalog/resource-folder.d.ts +8 -0
  49. package/catalog/resource-folder.d.ts.map +1 -0
  50. package/catalog/resource-folder.js +13 -0
  51. package/catalog/resource-name-conflict.d.ts +22 -0
  52. package/catalog/resource-name-conflict.d.ts.map +1 -0
  53. package/catalog/resource-name-conflict.js +32 -0
  54. package/catalog/resource-save-adapter.d.ts +36 -0
  55. package/catalog/resource-save-adapter.d.ts.map +1 -0
  56. package/catalog/resource-save-adapter.js +4 -0
  57. package/catalog/resource-save-adapters.d.ts +93 -0
  58. package/catalog/resource-save-adapters.d.ts.map +1 -0
  59. package/catalog/resource-save-adapters.js +116 -0
  60. package/catalog/resource-save.d.ts +76 -0
  61. package/catalog/resource-save.d.ts.map +1 -0
  62. package/catalog/resource-save.js +52 -0
  63. package/catalog/unpublishable-folders.d.ts +21 -0
  64. package/catalog/unpublishable-folders.d.ts.map +1 -0
  65. package/catalog/unpublishable-folders.js +21 -0
  66. package/catalog/usage-limit-rows.d.ts +14 -0
  67. package/catalog/usage-limit-rows.d.ts.map +1 -0
  68. package/catalog/usage-limit-rows.js +19 -0
  69. package/catalog/use-publish-history.d.ts +19 -0
  70. package/catalog/use-publish-history.d.ts.map +1 -0
  71. package/catalog/use-publish-history.js +25 -0
  72. package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.d.ts +57 -0
  73. package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.d.ts.map +1 -0
  74. package/catalog/useApplicationCredentialActions/useApplicationCredentialActions.js +67 -0
  75. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts +23 -6
  76. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts.map +1 -1
  77. package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +108 -107
  78. package/catalog/useCatalogItemDelete/useCatalogItemDelete.d.ts +41 -0
  79. package/catalog/useCatalogItemDelete/useCatalogItemDelete.d.ts.map +1 -0
  80. package/catalog/useCatalogItemDelete/useCatalogItemDelete.js +37 -0
  81. package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.d.ts.map +1 -1
  82. package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +72 -77
  83. package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +1 -1
  84. package/catalog/usePublishFolders/usePublishFolders.d.ts +8 -0
  85. package/catalog/usePublishFolders/usePublishFolders.d.ts.map +1 -1
  86. package/catalog/usePublishFolders/usePublishFolders.js +32 -29
  87. package/catalog/useResourceFolders/useResourceFolders.d.ts +33 -0
  88. package/catalog/useResourceFolders/useResourceFolders.d.ts.map +1 -0
  89. package/catalog/useResourceFolders/useResourceFolders.js +58 -0
  90. package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts +64 -0
  91. package/catalog/useResourceSavePanel/useResourceSavePanel.d.ts.map +1 -0
  92. package/catalog/useResourceSavePanel/useResourceSavePanel.js +173 -0
  93. package/catalog/useSkillItemDetails.js +3 -3
  94. package/catalog/useUnpublishConfirmation/useUnpublishConfirmation.d.ts +43 -0
  95. package/catalog/useUnpublishConfirmation/useUnpublishConfirmation.d.ts.map +1 -0
  96. package/catalog/useUnpublishConfirmation/useUnpublishConfirmation.js +46 -0
  97. package/catalog/useUnpublishableFolders/useUnpublishableFolders.d.ts +22 -0
  98. package/catalog/useUnpublishableFolders/useUnpublishableFolders.d.ts.map +1 -0
  99. package/catalog/useUnpublishableFolders/useUnpublishableFolders.js +53 -0
  100. package/catalog.js +41 -23
  101. package/conversation/conversation-data-source.d.ts +47 -0
  102. package/conversation/conversation-data-source.d.ts.map +1 -0
  103. package/conversation/conversation-data-source.js +11 -0
  104. package/conversation/conversation-draft/conversation-draft-store.d.ts +21 -0
  105. package/conversation/conversation-draft/conversation-draft-store.d.ts.map +1 -0
  106. package/conversation/conversation-draft/conversation-draft-store.js +84 -0
  107. package/conversation/conversation-draft/conversation-draft.d.ts +48 -0
  108. package/conversation/conversation-draft/conversation-draft.d.ts.map +1 -0
  109. package/conversation/conversation-list.d.ts +6 -0
  110. package/conversation/conversation-list.d.ts.map +1 -0
  111. package/conversation/conversation-list.js +5 -0
  112. package/conversation/conversation-title-stream.d.ts +33 -0
  113. package/conversation/conversation-title-stream.d.ts.map +1 -0
  114. package/conversation/conversation-title-stream.js +103 -0
  115. package/conversation/conversation-transfer/attachment-refs.d.ts +10 -2
  116. package/conversation/conversation-transfer/attachment-refs.d.ts.map +1 -1
  117. package/conversation/conversation-transfer/attachment-refs.js +31 -9
  118. package/conversation/conversation-transfer/export-conversation.d.ts +5 -1
  119. package/conversation/conversation-transfer/export-conversation.d.ts.map +1 -1
  120. package/conversation/conversation-transfer/export-conversation.js +19 -18
  121. package/conversation/conversation-transfer/import-conversation.d.ts +11 -6
  122. package/conversation/conversation-transfer/import-conversation.d.ts.map +1 -1
  123. package/conversation/conversation-transfer/import-conversation.js +65 -69
  124. package/conversation/conversation-transfer/progress.js +1 -1
  125. package/conversation/conversation-transfer/zip-export.js +1 -7
  126. package/conversation/conversation-transfer/zip-import.js +1 -1
  127. package/conversation/create-chat-stream-api.d.ts +24 -3
  128. package/conversation/create-chat-stream-api.d.ts.map +1 -1
  129. package/conversation/create-chat-stream-api.js +67 -56
  130. package/conversation/generation-registry.d.ts +30 -0
  131. package/conversation/generation-registry.d.ts.map +1 -0
  132. package/conversation/generation-registry.js +33 -0
  133. package/conversation/get-model-id-from-conversation-id.d.ts.map +1 -1
  134. package/conversation/get-model-id-from-conversation-id.js +1 -1
  135. package/conversation/message-utils.d.ts +6 -0
  136. package/conversation/message-utils.d.ts.map +1 -1
  137. package/conversation/message-utils.js +14 -10
  138. package/conversation/scheduled-task-grouping.d.ts +53 -0
  139. package/conversation/scheduled-task-grouping.d.ts.map +1 -0
  140. package/conversation/scheduled-task-grouping.js +45 -0
  141. package/conversation/useActiveConversationSync/useActiveConversationSync.d.ts +4 -2
  142. package/conversation/useActiveConversationSync/useActiveConversationSync.d.ts.map +1 -1
  143. package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -12
  144. package/conversation/useAttachmentUpload/useAttachmentUpload.d.ts.map +1 -1
  145. package/conversation/useAttachmentUpload/useAttachmentUpload.js +4 -1
  146. package/conversation/useConversationComposerDraft/useConversationComposerDraft.d.ts +39 -0
  147. package/conversation/useConversationComposerDraft/useConversationComposerDraft.d.ts.map +1 -0
  148. package/conversation/useConversationComposerDraft/useConversationComposerDraft.js +128 -0
  149. package/conversation/useConversationDiscovery/useConversationDiscovery.d.ts +22 -0
  150. package/conversation/useConversationDiscovery/useConversationDiscovery.d.ts.map +1 -0
  151. package/conversation/useConversationDiscovery/useConversationDiscovery.js +60 -0
  152. package/conversation/useConversationExport/useConversationExport.d.ts.map +1 -1
  153. package/conversation/useConversationExport/useConversationExport.js +113 -122
  154. package/conversation/useConversationHandlers/message-utils.js +2 -2
  155. package/conversation/useConversationHandlers/useConversationHandlers.js +41 -41
  156. package/conversation/useConversationImport/useConversationImport.js +24 -24
  157. package/conversation/useConversationPanelItems/useConversationPanelItems.d.ts +18 -5
  158. package/conversation/useConversationPanelItems/useConversationPanelItems.d.ts.map +1 -1
  159. package/conversation/useConversationPanelItems/useConversationPanelItems.js +34 -30
  160. package/conversation/useConversationScroll/useConversationScroll.d.ts.map +1 -1
  161. package/conversation/useConversationScroll/useConversationScroll.js +69 -72
  162. package/conversation/useConversationStream/conversation-path.js +2 -2
  163. package/conversation/useConversationStream/conversation-stream.types.d.ts +142 -0
  164. package/conversation/useConversationStream/conversation-stream.types.d.ts.map +1 -0
  165. package/conversation/useConversationStream/frame-scheduler.js +17 -17
  166. package/conversation/useConversationStream/generation-resume.d.ts +24 -2
  167. package/conversation/useConversationStream/generation-resume.d.ts.map +1 -1
  168. package/conversation/useConversationStream/generation-resume.js +110 -121
  169. package/conversation/useConversationStream/stream-errors.d.ts +10 -0
  170. package/conversation/useConversationStream/stream-errors.d.ts.map +1 -0
  171. package/conversation/useConversationStream/stream-errors.js +10 -0
  172. package/conversation/useConversationStream/stream-session.d.ts +51 -0
  173. package/conversation/useConversationStream/stream-session.d.ts.map +1 -0
  174. package/conversation/useConversationStream/stream-session.js +179 -0
  175. package/conversation/useConversationStream/useConversationReloadErrors.d.ts +25 -0
  176. package/conversation/useConversationStream/useConversationReloadErrors.d.ts.map +1 -0
  177. package/conversation/useConversationStream/useConversationReloadErrors.js +38 -0
  178. package/conversation/useConversationStream/useConversationStream.d.ts +3 -136
  179. package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -1
  180. package/conversation/useConversationStream/useConversationStream.js +141 -325
  181. package/conversation/useConversationStream/useStopGeneration.d.ts +29 -0
  182. package/conversation/useConversationStream/useStopGeneration.d.ts.map +1 -0
  183. package/conversation/useConversationStream/useStopGeneration.js +48 -0
  184. package/conversation/useConversationStream/useStreamPathState.d.ts +39 -0
  185. package/conversation/useConversationStream/useStreamPathState.d.ts.map +1 -0
  186. package/conversation/useConversationStream/useStreamPathState.js +55 -0
  187. package/conversation/useConversationTitleEnrichmentController.d.ts +64 -0
  188. package/conversation/useConversationTitleEnrichmentController.d.ts.map +1 -0
  189. package/conversation/useConversationTitleEnrichmentController.js +155 -0
  190. package/conversation/useDeploymentChangeTracking.d.ts +14 -0
  191. package/conversation/useDeploymentChangeTracking.d.ts.map +1 -0
  192. package/conversation/useDeploymentChangeTracking.js +23 -0
  193. package/conversation/useEntityPreselection/useEntityPreselection.d.ts +108 -0
  194. package/conversation/useEntityPreselection/useEntityPreselection.d.ts.map +1 -0
  195. package/conversation/useEntityPreselection/useEntityPreselection.js +78 -0
  196. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +4 -10
  197. package/conversation/useTranscribeAudio/useTranscribeAudio.d.ts +8 -1
  198. package/conversation/useTranscribeAudio/useTranscribeAudio.d.ts.map +1 -1
  199. package/conversation/useTranscribeAudio/useTranscribeAudio.js +36 -27
  200. package/conversation/useVisibleConversationIdsReporter/useVisibleConversationIdsReporter.d.ts +16 -0
  201. package/conversation/useVisibleConversationIdsReporter/useVisibleConversationIdsReporter.d.ts.map +1 -0
  202. package/conversation/useVisibleConversationIdsReporter/useVisibleConversationIdsReporter.js +17 -0
  203. package/conversation-overlay.js +1 -2
  204. package/conversation-sources/stage-citations.d.ts +9 -0
  205. package/conversation-sources/stage-citations.d.ts.map +1 -0
  206. package/conversation-sources/stage-citations.js +8 -0
  207. package/conversation-sources/useConversationAnnotationPool/useConversationAnnotationPool.d.ts +4 -0
  208. package/conversation-sources/useConversationAnnotationPool/useConversationAnnotationPool.d.ts.map +1 -0
  209. package/conversation-sources/useConversationAnnotationPool/useConversationAnnotationPool.js +5 -0
  210. package/conversation-sources.js +3 -1
  211. package/conversation.js +45 -33
  212. package/entry-points/attachments.d.ts +1 -0
  213. package/entry-points/attachments.d.ts.map +1 -1
  214. package/entry-points/catalog.d.ts +17 -0
  215. package/entry-points/catalog.d.ts.map +1 -1
  216. package/entry-points/conversation-sources.d.ts +2 -0
  217. package/entry-points/conversation-sources.d.ts.map +1 -1
  218. package/entry-points/conversation.d.ts +13 -0
  219. package/entry-points/conversation.d.ts.map +1 -1
  220. package/entry-points/external-services.d.ts +6 -0
  221. package/entry-points/external-services.d.ts.map +1 -0
  222. package/entry-points/file-manager-canvas.d.ts +1 -0
  223. package/entry-points/file-manager-canvas.d.ts.map +1 -1
  224. package/entry-points/file-manager.d.ts +2 -0
  225. package/entry-points/file-manager.d.ts.map +1 -1
  226. package/entry-points/oauth.d.ts +1 -0
  227. package/entry-points/oauth.d.ts.map +1 -1
  228. package/entry-points/offline-credentials.d.ts +7 -0
  229. package/entry-points/offline-credentials.d.ts.map +1 -0
  230. package/entry-points/project.d.ts +20 -0
  231. package/entry-points/project.d.ts.map +1 -0
  232. package/entry-points/scheduled-tasks.d.ts +7 -0
  233. package/entry-points/scheduled-tasks.d.ts.map +1 -1
  234. package/entry-points/sharing.d.ts +4 -0
  235. package/entry-points/sharing.d.ts.map +1 -1
  236. package/entry-points/skill-editor.d.ts +2 -0
  237. package/entry-points/skill-editor.d.ts.map +1 -1
  238. package/entry-points/skills-state.d.ts +1 -0
  239. package/entry-points/skills-state.d.ts.map +1 -1
  240. package/entry-points/usage-limits.d.ts +9 -0
  241. package/entry-points/usage-limits.d.ts.map +1 -0
  242. package/entry-points/utils.d.ts +6 -0
  243. package/entry-points/utils.d.ts.map +1 -1
  244. package/entry-points/viewport-layout.d.ts +1 -0
  245. package/entry-points/viewport-layout.d.ts.map +1 -1
  246. package/external-services/useExternalServiceLogin.d.ts +99 -0
  247. package/external-services/useExternalServiceLogin.d.ts.map +1 -0
  248. package/external-services/useExternalServiceLogin.js +93 -0
  249. package/external-services.d.ts +2 -0
  250. package/external-services.js +5 -0
  251. package/file-manager-canvas.js +3 -2
  252. package/file-manager.js +32 -30
  253. package/files/attachment-canvas.d.ts +12 -0
  254. package/files/attachment-canvas.d.ts.map +1 -1
  255. package/files/attachment-canvas.js +18 -10
  256. package/files/attachment-dto-to-display.d.ts.map +1 -1
  257. package/files/attachment-dto-to-display.js +13 -12
  258. package/files/attachment-types.js +1 -1
  259. package/files/browser-download.d.ts +9 -0
  260. package/files/browser-download.d.ts.map +1 -0
  261. package/files/browser-download.js +23 -0
  262. package/files/create-files-api.d.ts +3 -4
  263. package/files/create-files-api.d.ts.map +1 -1
  264. package/files/create-files-api.js +1 -1
  265. package/files/create-upload-file-with-progress.d.ts +21 -1
  266. package/files/create-upload-file-with-progress.d.ts.map +1 -1
  267. package/files/create-upload-file-with-progress.js +50 -34
  268. package/files/dial-file-manager-copy-move.util.d.ts.map +1 -1
  269. package/files/dial-file-manager-copy-move.util.js +28 -28
  270. package/files/dial-file-manager-mapping.util.d.ts +23 -3
  271. package/files/dial-file-manager-mapping.util.d.ts.map +1 -1
  272. package/files/dial-file-manager-mapping.util.js +97 -69
  273. package/files/dial-file-manager.types.d.ts +15 -5
  274. package/files/dial-file-manager.types.d.ts.map +1 -1
  275. package/files/dial-file-to-attachment.js +3 -3
  276. package/files/dial-file.d.ts +19 -0
  277. package/files/dial-file.d.ts.map +1 -1
  278. package/files/dial-file.js +20 -12
  279. package/files/dial-files-api.d.ts +2 -2
  280. package/files/dial-files-api.d.ts.map +1 -1
  281. package/files/download-progress.d.ts +33 -0
  282. package/files/download-progress.d.ts.map +1 -0
  283. package/files/download-progress.js +28 -0
  284. package/files/source-content.js +1 -1
  285. package/files/useDialFileListing/useDialFileListing.d.ts.map +1 -1
  286. package/files/useDialFileListing/useDialFileListing.js +97 -109
  287. package/files/useDialFileManager/useDialFileManager.d.ts.map +1 -1
  288. package/files/useDialFileManager/useDialFileManager.js +5 -2
  289. package/files/useDialFileManagerSections/useDialFileManagerSections.d.ts.map +1 -1
  290. package/files/useDialFileManagerSections/useDialFileManagerSections.js +59 -68
  291. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +1 -1
  292. package/files/useDialFileMetadata/useDialFileMetadata.js +3 -3
  293. package/files/useDialFileMutations/useDialFileMutations.d.ts +9 -0
  294. package/files/useDialFileMutations/useDialFileMutations.d.ts.map +1 -1
  295. package/files/useDialFileMutations/useDialFileMutations.js +232 -159
  296. package/files/useDialFilePreview/useDialFilePreview.d.ts +33 -0
  297. package/files/useDialFilePreview/useDialFilePreview.d.ts.map +1 -0
  298. package/files/useDialFilePreview/useDialFilePreview.js +45 -0
  299. package/files/useDialFileUploadBatch/useDialFileUploadBatch.d.ts.map +1 -1
  300. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +114 -103
  301. package/files/useFileAttachmentModalState/useFileAttachmentModalState.d.ts +25 -0
  302. package/files/useFileAttachmentModalState/useFileAttachmentModalState.d.ts.map +1 -0
  303. package/files/useFileAttachmentModalState/useFileAttachmentModalState.js +19 -0
  304. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +2 -2
  305. package/files/useUnshareConfirmationState/useUnshareConfirmationState.d.ts +23 -0
  306. package/files/useUnshareConfirmationState/useUnshareConfirmationState.d.ts.map +1 -0
  307. package/files/useUnshareConfirmationState/useUnshareConfirmationState.js +18 -0
  308. package/index.d.ts +96 -0
  309. package/index.d.ts.map +1 -1
  310. package/index.js +244 -149
  311. package/mcp-apps/mcp-apps-api-client.d.ts.map +1 -1
  312. package/mcp-apps/mcp-apps-api-client.js +18 -17
  313. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.d.ts +3 -2
  314. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.d.ts.map +1 -1
  315. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +28 -10
  316. package/mcp-apps/useMcpAppTools/useMcpAppTools.d.ts.map +1 -1
  317. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +45 -45
  318. package/oauth/authorize-url.d.ts +7 -1
  319. package/oauth/authorize-url.d.ts.map +1 -1
  320. package/oauth/authorize-url.js +14 -4
  321. package/oauth/callback-exchange.d.ts +49 -0
  322. package/oauth/callback-exchange.d.ts.map +1 -0
  323. package/oauth/callback-exchange.js +29 -0
  324. package/oauth/handshake.js +3 -10
  325. package/oauth/models.d.ts +25 -0
  326. package/oauth/models.d.ts.map +1 -1
  327. package/oauth/popup.d.ts.map +1 -1
  328. package/oauth/popup.js +19 -17
  329. package/oauth/toolset-id.d.ts +7 -0
  330. package/oauth/toolset-id.d.ts.map +1 -1
  331. package/oauth/toolset-id.js +9 -2
  332. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts.map +1 -1
  333. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +41 -42
  334. package/oauth/useToolsetLogin/useToolsetLogin.d.ts +7 -1
  335. package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +1 -1
  336. package/oauth/useToolsetLogin/useToolsetLogin.js +51 -42
  337. package/oauth.js +9 -8
  338. package/offline-credentials/map-offline-credentials-response.d.ts +20 -0
  339. package/offline-credentials/map-offline-credentials-response.d.ts.map +1 -0
  340. package/offline-credentials/map-offline-credentials-response.js +17 -0
  341. package/offline-credentials/scheduled-tasks-login-banner.d.ts +31 -0
  342. package/offline-credentials/scheduled-tasks-login-banner.d.ts.map +1 -0
  343. package/offline-credentials/scheduled-tasks-login-banner.js +17 -0
  344. package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.d.ts +58 -0
  345. package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.d.ts.map +1 -0
  346. package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.js +37 -0
  347. package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.d.ts +61 -0
  348. package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.d.ts.map +1 -0
  349. package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.js +37 -0
  350. package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.d.ts +28 -0
  351. package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.d.ts.map +1 -0
  352. package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.js +29 -0
  353. package/offline-credentials.d.ts +2 -0
  354. package/offline-credentials.js +7 -0
  355. package/package.json +49 -25
  356. package/project/create-project-chat.d.ts +34 -0
  357. package/project/create-project-chat.d.ts.map +1 -0
  358. package/project/create-project-chat.js +27 -0
  359. package/project/project-conversation-data-source.d.ts +36 -0
  360. package/project/project-conversation-data-source.d.ts.map +1 -0
  361. package/project/project-conversation-data-source.js +67 -0
  362. package/project/project-events.d.ts +14 -0
  363. package/project/project-events.d.ts.map +1 -0
  364. package/project/project-events.js +25 -0
  365. package/project/project-file-preview.d.ts +32 -0
  366. package/project/project-file-preview.d.ts.map +1 -0
  367. package/project/project-file-preview.js +25 -0
  368. package/project/project-form-errors.d.ts +23 -0
  369. package/project/project-form-errors.d.ts.map +1 -0
  370. package/project/project-form-errors.js +46 -0
  371. package/project/project-limits.d.ts +17 -0
  372. package/project/project-limits.d.ts.map +1 -0
  373. package/project/project-limits.js +11 -0
  374. package/project/project-mapping.d.ts +16 -0
  375. package/project/project-mapping.d.ts.map +1 -0
  376. package/project/project-mapping.js +43 -0
  377. package/project/project-refresh.d.ts +12 -0
  378. package/project/project-refresh.d.ts.map +1 -0
  379. package/project/project-refresh.js +6 -0
  380. package/project/project-viewed-marks.d.ts +9 -0
  381. package/project/project-viewed-marks.d.ts.map +1 -0
  382. package/project/project-viewed-marks.js +8 -0
  383. package/project/project-watch-stream.d.ts +26 -0
  384. package/project/project-watch-stream.d.ts.map +1 -0
  385. package/project/project-watch-stream.js +39 -0
  386. package/project/projects-api-client.d.ts +179 -0
  387. package/project/projects-api-client.d.ts.map +1 -0
  388. package/project/projects-api-client.js +90 -0
  389. package/project/use-pinned-project-chats.d.ts +58 -0
  390. package/project/use-pinned-project-chats.d.ts.map +1 -0
  391. package/project/use-pinned-project-chats.js +269 -0
  392. package/project/use-project-actions.d.ts +53 -0
  393. package/project/use-project-actions.d.ts.map +1 -0
  394. package/project/use-project-actions.js +92 -0
  395. package/project/use-project-artifacts.d.ts +24 -0
  396. package/project/use-project-artifacts.d.ts.map +1 -0
  397. package/project/use-project-artifacts.js +78 -0
  398. package/project/use-project-conversations.d.ts +32 -0
  399. package/project/use-project-conversations.d.ts.map +1 -0
  400. package/project/use-project-conversations.js +200 -0
  401. package/project/use-project-draft.d.ts +46 -0
  402. package/project/use-project-draft.d.ts.map +1 -0
  403. package/project/use-project-draft.js +54 -0
  404. package/project/use-project-file-preview.d.ts +47 -0
  405. package/project/use-project-file-preview.d.ts.map +1 -0
  406. package/project/use-project-file-preview.js +50 -0
  407. package/project/use-project-submit.d.ts +49 -0
  408. package/project/use-project-submit.d.ts.map +1 -0
  409. package/project/use-project-submit.js +73 -0
  410. package/project/use-project-watch.d.ts +24 -0
  411. package/project/use-project-watch.d.ts.map +1 -0
  412. package/project/use-project-watch.js +41 -0
  413. package/project/use-project.d.ts +23 -0
  414. package/project/use-project.d.ts.map +1 -0
  415. package/project/use-project.js +73 -0
  416. package/project/use-projects.d.ts +27 -0
  417. package/project/use-projects.d.ts.map +1 -0
  418. package/project/use-projects.js +92 -0
  419. package/project.d.ts +2 -0
  420. package/project.js +20 -0
  421. package/prompt/prompt.d.ts +11 -0
  422. package/prompt/prompt.d.ts.map +1 -1
  423. package/prompt/prompt.js +7 -3
  424. package/scheduled-task/active-scheduled-task.d.ts +58 -0
  425. package/scheduled-task/active-scheduled-task.d.ts.map +1 -0
  426. package/scheduled-task/active-scheduled-task.js +18 -0
  427. package/scheduled-task/check-scheduled-task-auth-session-error.d.ts +27 -0
  428. package/scheduled-task/check-scheduled-task-auth-session-error.d.ts.map +1 -0
  429. package/scheduled-task/check-scheduled-task-auth-session-error.js +17 -0
  430. package/scheduled-task/scheduled-task-description.d.ts +2 -0
  431. package/scheduled-task/scheduled-task-description.d.ts.map +1 -1
  432. package/scheduled-task/scheduled-task-description.js +33 -24
  433. package/scheduled-task/scheduled-task-display.d.ts +106 -0
  434. package/scheduled-task/scheduled-task-display.d.ts.map +1 -0
  435. package/scheduled-task/scheduled-task-display.js +69 -0
  436. package/scheduled-task/scheduled-task-next-occurrence.d.ts +9 -0
  437. package/scheduled-task/scheduled-task-next-occurrence.d.ts.map +1 -0
  438. package/scheduled-task/scheduled-task-next-occurrence.js +20 -0
  439. package/scheduled-task/scheduled-task-preparation.d.ts +1 -1
  440. package/scheduled-task/scheduled-task-trigger.d.ts.map +1 -1
  441. package/scheduled-task/scheduled-task-trigger.js +75 -48
  442. package/scheduled-task/use-scheduled-task-runs.js +19 -31
  443. package/scheduled-task/use-scheduled-tasks.d.ts +2 -2
  444. package/scheduled-task/use-scheduled-tasks.js +1 -1
  445. package/scheduled-task/useActiveScheduledTaskDetails.d.ts +18 -0
  446. package/scheduled-task/useActiveScheduledTaskDetails.d.ts.map +1 -0
  447. package/scheduled-task/useActiveScheduledTaskDetails.js +40 -0
  448. package/scheduled-task/useScheduledTaskSkillDisplayNames/useScheduledTaskSkillDisplayNames.d.ts +17 -0
  449. package/scheduled-task/useScheduledTaskSkillDisplayNames/useScheduledTaskSkillDisplayNames.d.ts.map +1 -0
  450. package/scheduled-task/useScheduledTaskSkillDisplayNames/useScheduledTaskSkillDisplayNames.js +29 -0
  451. package/scheduled-task/useStartScheduledTask.d.ts +41 -0
  452. package/scheduled-task/useStartScheduledTask.d.ts.map +1 -0
  453. package/scheduled-task/useStartScheduledTask.js +169 -0
  454. package/scheduled-tasks.js +13 -6
  455. package/scroll-anchoring.js +1 -2
  456. package/share-invitation/models.d.ts +46 -0
  457. package/share-invitation/models.d.ts.map +1 -0
  458. package/share-invitation/share-invitation-error.d.ts +6 -0
  459. package/share-invitation/share-invitation-error.d.ts.map +1 -0
  460. package/share-invitation/share-invitation-error.js +37 -0
  461. package/share-invitation/types.d.ts +10 -0
  462. package/share-invitation/types.d.ts.map +1 -0
  463. package/share-invitation/types.js +6 -0
  464. package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.d.ts +9 -0
  465. package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.d.ts.map +1 -0
  466. package/share-invitation/useAcceptShareInvitation/useAcceptShareInvitation.js +26 -0
  467. package/shared/application-schema.js +3 -3
  468. package/shared/client-channel.d.ts +53 -0
  469. package/shared/client-channel.d.ts.map +1 -0
  470. package/shared/client-channel.js +6 -0
  471. package/shared/cron-day-of-month.js +10 -10
  472. package/shared/external-services.d.ts +1 -1
  473. package/shared/locale.d.ts +6 -2
  474. package/shared/locale.d.ts.map +1 -1
  475. package/shared/locale.js +4 -4
  476. package/shared/read-sse-events.d.ts +10 -0
  477. package/shared/read-sse-events.d.ts.map +1 -0
  478. package/shared/read-sse-events.js +33 -0
  479. package/shared/serialized-writer.d.ts +12 -0
  480. package/shared/serialized-writer.d.ts.map +1 -0
  481. package/shared/serialized-writer.js +44 -0
  482. package/shared/sleep.d.ts +3 -0
  483. package/shared/sleep.d.ts.map +1 -0
  484. package/shared/sleep.js +13 -0
  485. package/shared/theme-colors.d.ts +16 -0
  486. package/shared/theme-colors.d.ts.map +1 -0
  487. package/shared/theme-colors.js +14 -0
  488. package/shared/url-cleanup.d.ts +18 -0
  489. package/shared/url-cleanup.d.ts.map +1 -0
  490. package/shared/url-cleanup.js +18 -0
  491. package/shared/usage-stat.d.ts +3 -0
  492. package/shared/usage-stat.d.ts.map +1 -0
  493. package/shared/usage-stat.js +4 -0
  494. package/shared/useAppVersionCheck/useAppVersionCheck.d.ts +22 -0
  495. package/shared/useAppVersionCheck/useAppVersionCheck.d.ts.map +1 -0
  496. package/shared/useAppVersionCheck/useAppVersionCheck.js +36 -0
  497. package/shared/usePersistedState/usePersistedState.d.ts +28 -0
  498. package/shared/usePersistedState/usePersistedState.d.ts.map +1 -0
  499. package/shared/usePersistedState/usePersistedState.js +24 -0
  500. package/sharing.js +5 -2
  501. package/signin-interrupt/models.d.ts +48 -0
  502. package/signin-interrupt/models.d.ts.map +1 -0
  503. package/signin-interrupt/signin-row-info.d.ts +10 -0
  504. package/signin-interrupt/signin-row-info.d.ts.map +1 -0
  505. package/signin-interrupt/signin-row-info.js +21 -0
  506. package/signin-interrupt/types.d.ts +28 -0
  507. package/signin-interrupt/types.d.ts.map +1 -0
  508. package/signin-interrupt/types.js +10 -0
  509. package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts +52 -0
  510. package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.d.ts.map +1 -0
  511. package/signin-interrupt/useSigninInterrupt/useSigninInterrupt.js +270 -0
  512. package/skill/skill-file-batch-validation.d.ts +4 -0
  513. package/skill/skill-file-batch-validation.d.ts.map +1 -1
  514. package/skill/skill-file-batch-validation.js +34 -33
  515. package/skill/skill-lookup.d.ts +20 -0
  516. package/skill/skill-lookup.d.ts.map +1 -0
  517. package/skill/skill-lookup.js +12 -0
  518. package/skill/skill-types.js +1 -1
  519. package/skill/skill.d.ts +5 -1
  520. package/skill/skill.d.ts.map +1 -1
  521. package/skill/skill.js +27 -28
  522. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +1 -7
  523. package/skill/useSkillEditorSubmit.d.ts +15 -1
  524. package/skill/useSkillEditorSubmit.d.ts.map +1 -1
  525. package/skill/useSkillEditorSubmit.js +164 -87
  526. package/skill/useSkillFileActions.d.ts +2 -0
  527. package/skill/useSkillFileActions.d.ts.map +1 -1
  528. package/skill/useSkillFileActions.js +36 -21
  529. package/skill-editor/useSkillFilePreviewSyncController.d.ts +41 -0
  530. package/skill-editor/useSkillFilePreviewSyncController.d.ts.map +1 -0
  531. package/skill-editor/useSkillFilePreviewSyncController.js +58 -0
  532. package/skill-editor/useSkillFileSystemPicker/useSkillFileSystemPicker.d.ts +23 -0
  533. package/skill-editor/useSkillFileSystemPicker/useSkillFileSystemPicker.d.ts.map +1 -0
  534. package/skill-editor/useSkillFileSystemPicker/useSkillFileSystemPicker.js +43 -0
  535. package/skill-editor.js +11 -9
  536. package/skills-state.js +3 -2
  537. package/source-content.js +1 -2
  538. package/usage/map-usage-data-to-dashboard.d.ts +1 -16
  539. package/usage/map-usage-data-to-dashboard.d.ts.map +1 -1
  540. package/usage/map-user-usage-to-model-limits.d.ts.map +1 -1
  541. package/usage/map-user-usage-to-model-limits.js +24 -24
  542. package/usage/usage-banner-source.d.ts +24 -0
  543. package/usage/usage-banner-source.d.ts.map +1 -0
  544. package/usage/usage-banner-source.js +61 -0
  545. package/usage/usage-gauge.d.ts +3 -0
  546. package/usage/usage-gauge.d.ts.map +1 -0
  547. package/usage/usage-gauge.js +4 -0
  548. package/usage/usage-period.d.ts +7 -0
  549. package/usage/usage-period.d.ts.map +1 -0
  550. package/usage/usage-period.js +6 -0
  551. package/usage/usage-reset-time.d.ts +78 -0
  552. package/usage/usage-reset-time.d.ts.map +1 -0
  553. package/usage/usage-reset-time.js +82 -0
  554. package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts +56 -0
  555. package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts.map +1 -0
  556. package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.js +34 -0
  557. package/usage/useRefreshUsageAfterGeneration/useRefreshUsageAfterGeneration.d.ts +16 -0
  558. package/usage/useRefreshUsageAfterGeneration/useRefreshUsageAfterGeneration.d.ts.map +1 -0
  559. package/usage/useRefreshUsageAfterGeneration/useRefreshUsageAfterGeneration.js +14 -0
  560. package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts +58 -0
  561. package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts.map +1 -0
  562. package/usage/useUsageLimitBanner/useUsageLimitBanner.js +70 -0
  563. package/usage/useUsageLimitBannerDismissal/useUsageLimitBannerDismissal.d.ts +14 -0
  564. package/usage/useUsageLimitBannerDismissal/useUsageLimitBannerDismissal.d.ts.map +1 -0
  565. package/usage/useUsageLimitBannerDismissal/useUsageLimitBannerDismissal.js +19 -0
  566. package/usage-limits.d.ts +2 -0
  567. package/usage-limits.js +10 -0
  568. package/useChatSettingsFormConfig/useChatSettingsFormConfig.d.ts +2 -0
  569. package/useChatSettingsFormConfig/useChatSettingsFormConfig.d.ts.map +1 -1
  570. package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +25 -21
  571. package/usePageFileDrag/usePageFileDrag.js +3 -3
  572. package/useShareLink/useShareLink.d.ts.map +1 -1
  573. package/useShareLink/useShareLink.js +18 -17
  574. package/utils.js +23 -17
  575. package/viewport-layout/canvas-width.d.ts +39 -0
  576. package/viewport-layout/canvas-width.d.ts.map +1 -0
  577. package/viewport-layout/canvas-width.js +23 -0
  578. package/viewport-layout.js +2 -1
@@ -1,138 +1,5 @@
1
- import { SendCompletionDtoModeEnum } from '@epam/ai-dial-chat-api-client';
2
- import { Conversation, MessageCustomContent, StreamChunk } from '@epam/ai-dial-chat-shared';
3
- import { Dispatch, MutableRefObject, SetStateAction } from 'react';
4
- /** Options accepted by {@link ConversationStreamTransport.streamCompletion}. */
5
- export interface StreamCompletionOptions {
6
- onChunk: (chunk: StreamChunk) => void;
7
- onComplete: () => void | Promise<void>;
8
- onError: (error: Error) => void;
9
- signal: AbortSignal;
10
- }
11
- /**
12
- * Host-owned transport for the DIAL Core completion protocol. Implemented at
13
- * the app edge — never hardcodes an `/api` path, CSRF handling, or a
14
- * `server-api` import; the library only depends on this interface's shape.
15
- */
16
- export interface ConversationStreamTransport {
17
- /** Starts a completion; delivers chunks/completion/error through `options`, aborted via `options.signal`. */
18
- streamCompletion(path: string, message: string | undefined, model: string, options: StreamCompletionOptions, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, messageIndex?: number, clientChannelId?: string): void;
19
- /**
20
- * Requests the backend stop an active generation. `content` is the answer text shown
21
- * so far; the backend saves it for a generation whose text it does not hold.
22
- */
23
- stopCompletion(params: {
24
- generationId: string;
25
- path: string;
26
- content?: string;
27
- }): Promise<void>;
28
- /** Opens a stream of resource-update events for `path`, until aborted via `signal`. */
29
- watchConversation(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
30
- /**
31
- * Attaches to an active generation's live replay: a `snapshot` event
32
- * carrying the assistant message as assembled so far, then a `chunk` event
33
- * per subsequent delta, then exactly one terminal event (`done`/`error`/
34
- * `stopped`), until aborted via `signal`. Rejects when no active
35
- * generation exists for `path` — including one that already finished —
36
- * so the caller can fall back to `watchConversation`.
37
- */
38
- attachToGeneration(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
39
- /** Reloads the persisted conversation by its full (bucket-qualified) id. */
40
- getConversation(conversationId: string, signal?: AbortSignal): Promise<Conversation>;
41
- /**
42
- * Saves `conversation` at the bucket-stripped `path`, resolving with the saved
43
- * conversation. Used only for the single recovery save after the backend's
44
- * terminal save was rejected with `401`; without it that failure shows the
45
- * persistence warning immediately.
46
- */
47
- saveConversation?(path: string, conversation: Conversation): Promise<Conversation>;
48
- }
49
- /** Host-owned generation lifecycle, backing cross-navigation `AbortController` ownership. */
50
- export interface ConversationGenerationLifecycle {
51
- /** Starts (or replaces) tracking for a generation on `path`, returning its `AbortController`. */
52
- startGeneration: (path: string, generationId: string) => AbortController;
53
- /** Marks the generation identified by `path`/`generationId` complete, if it is still the active one. */
54
- completeGeneration: (path: string, generationId: string) => void;
55
- }
56
- /** Optional host-owned client-channel connection, used to nudge tool-signin delivery. */
57
- export interface ConversationStreamChannel {
58
- channelId: string | null;
59
- ensureConnected: () => void;
60
- /** Resolves with a channel id, waiting for an in-flight subscribe if one isn't established yet, so a completion sent immediately after mount can still carry it. */
61
- waitForChannel: (timeoutMs?: number) => Promise<string | null>;
62
- /** Notifies the host that a generation just ended (completed or errored), so it can consider disconnecting an idle channel. */
63
- notifyGenerationSettled?: () => void;
64
- }
65
- /** Optional host-owned overlay generation-lifecycle notifications. Each method is independently optional. */
66
- export interface ConversationStreamOverlayNotifier {
67
- notifyGenerationStart?: () => void;
68
- notifyGenerationEnd?: () => void;
69
- notifyStopGenerating?: () => void;
70
- }
71
- /** Shared mutable channel through which the displayed conversation's state is read/written. */
72
- export interface ConversationStateAccessor {
73
- setConversation: Dispatch<SetStateAction<Conversation | null>>;
74
- conversationRef: MutableRefObject<Conversation | null>;
75
- }
76
- /** Parameters for {@link useConversationStream}. */
77
- export interface UseConversationStreamParams {
78
- conversationId: string | undefined;
79
- state: ConversationStateAccessor;
80
- transport: ConversationStreamTransport;
81
- generation: ConversationGenerationLifecycle;
82
- channel?: ConversationStreamChannel;
83
- overlay?: ConversationStreamOverlayNotifier;
84
- onStopError?: (error: Error) => void;
85
- /**
86
- * Message shown on the message bubble when the backend rejects a completion
87
- * because this conversation is already generating — the case a second
88
- * browser tab of the same session hits. Defaults to
89
- * {@link DEFAULT_GENERATION_CONFLICT_MESSAGE}.
90
- */
91
- generationConflictMessage?: string;
92
- /** Host-translated warning shown when the received answer could not be saved. */
93
- generationPersistenceErrorMessage?: string;
94
- /**
95
- * Receives the original error of every failed stream. The hook shows only
96
- * host-supplied or upstream-supplied text on the message bubble and hides
97
- * transport detail (e.g. `Failed to fetch`), so this is where the host can
98
- * still log or report the raw error.
99
- */
100
- onStreamError?: (error: Error) => void;
101
- /**
102
- * Coalesces the displayed chunk updates into one `setConversation` per
103
- * animation frame. Chunks still reach the per-path buffer immediately, and
104
- * any pending update is flushed before completion, error, stop, or a
105
- * superseding generation. Defaults to `false` (one update per chunk).
106
- */
107
- batchChunksPerFrame?: boolean;
108
- }
109
- /** Per-start options of {@link UseConversationStreamResult.startStream}. */
110
- export interface StartStreamOptions {
111
- /**
112
- * Treats a `GenerationConflictError` as "this turn is already being
113
- * generated" — e.g. a page reloaded before that generation saved its start
114
- * state — and joins the running generation instead of showing the conflict
115
- * message, which remains the fallback. Only for a start that sends no new
116
- * user text; a send the user typed must keep reporting the conflict.
117
- */
118
- resumeOnConflict?: boolean;
119
- }
120
- /** Return value of {@link useConversationStream}. */
121
- export interface UseConversationStreamResult {
122
- startStream: (conversationId: string, userContent: string, messageIndex: number, model: string, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, options?: StartStreamOptions) => void;
123
- handleStop: () => void;
124
- resumeIfAwaitingGeneration: (currentConversationId: string, conversation: Conversation) => void;
125
- /** Restores the accumulated live assistant message when its conversation is loaded again before completion. */
126
- restoreBufferedGeneration: (currentConversationId: string, conversation: Conversation) => Conversation;
127
- isStreaming: boolean;
128
- canStopStreaming: boolean;
129
- /** Whether the displayed conversation's terminal read failed. */
130
- hasConversationReloadError: boolean;
131
- /** Whether a retry of that read is in flight. */
132
- isReloadingConversation: boolean;
133
- /** Retries the failed read without saving or regenerating the answer. */
134
- retryConversationReload: () => Promise<void>;
135
- }
1
+ import { UseConversationStreamParams, UseConversationStreamResult } from './conversation-stream.types';
2
+ export type { ConversationGenerationLifecycle, ConversationStateAccessor, ConversationStreamChannel, ConversationStreamOverlayNotifier, ConversationStreamTransport, StartStreamOptions, StreamCompletionOptions, UseConversationStreamParams, UseConversationStreamResult, } from './conversation-stream.types';
136
3
  /**
137
4
  * Owns completion-streaming state: per-path streaming/stoppable tracking,
138
5
  * stale-chunk rejection, cross-navigation live-message buffering,
@@ -141,5 +8,5 @@ export interface UseConversationStreamResult {
141
8
  * `transport`/`generation`/`channel`/`overlay` capabilities rather than any
142
9
  * app context or `server-api` import.
143
10
  */
144
- export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, generationPersistenceErrorMessage, onStreamError, batchChunksPerFrame, }: UseConversationStreamParams) => UseConversationStreamResult;
11
+ export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, generationPersistenceErrorMessage, generationInterruptedMessage, onStreamError, batchChunksPerFrame, }: UseConversationStreamParams) => UseConversationStreamResult;
145
12
  //# sourceMappingURL=useConversationStream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,6BAA6B,CAAC;AAYrC,YAAY,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,yBAAyB,EACzB,iCAAiC,EACjC,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,iSAanC,2BAA2B,KAAG,2BAwRhC,CAAC"}
@@ -1,336 +1,152 @@
1
- import { safeDecodeURI as e } from "../../shared/string-utils.js";
2
- import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamInterruptedError as a, StreamUpstreamError as o } from "../create-chat-stream-api.js";
3
- import { getConversationPath as s } from "./conversation-path.js";
4
- import { applyChunkToMessages as c } from "./apply-chunk.js";
5
- import { restoreBufferedMessage as l } from "./buffered-generation.js";
6
- import { createResumeIfAwaitingGeneration as ee, fetchConversationForRecovery as te, findPendingBackgroundMessageIndex as u, hasGeneratedPayload as ne, isAwaitingGenerationResume as d } from "./generation-resume.js";
7
- import { createFrameScheduler as re } from "./frame-scheduler.js";
8
- import { MessageRole as ie, generateUUID as ae } from "@epam/ai-dial-chat-shared";
9
- import { useCallback as f, useEffect as p, useMemo as oe, useRef as m, useState as h } from "react";
10
- import { SendCompletionDtoModeEnum as g } from "@epam/ai-dial-chat-api-client";
1
+ import { DEFAULT_GENERATION_CONFLICT_MESSAGE as e, DEFAULT_GENERATION_INTERRUPTED_ERROR_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n } from "../create-chat-stream-api.js";
2
+ import { getConversationPath as r } from "./conversation-path.js";
3
+ import { restoreBufferedMessage as i } from "./buffered-generation.js";
4
+ import { createResumeIfAwaitingGeneration as a, isAwaitingGenerationResume as o } from "./generation-resume.js";
5
+ import { createFrameScheduler as s } from "./frame-scheduler.js";
6
+ import { findResumedBackgroundGenerationId as ee } from "./stream-errors.js";
7
+ import { runStreamSession as c } from "./stream-session.js";
8
+ import { useConversationReloadErrors as l } from "./useConversationReloadErrors.js";
9
+ import { useStopGeneration as te } from "./useStopGeneration.js";
10
+ import { useStreamPathState as ne } from "./useStreamPathState.js";
11
+ import { MessageRole as re } from "@epam/ai-dial-chat-shared";
12
+ import { useCallback as u, useEffect as d, useMemo as ie, useRef as f, useState as ae } from "react";
11
13
  //#region src/conversation/useConversationStream/useConversationStream.ts
12
- var se = 2e4, ce = 401, le = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof o ? e.message : "", _ = (e) => {
13
- if (!e) return;
14
- let t = u(e);
15
- return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
16
- }, v = ({ conversationId: o, state: { setConversation: v, conversationRef: y }, transport: b, generation: { startGeneration: ue, completeGeneration: x }, channel: S, overlay: C, onStopError: w, generationConflictMessage: de = t, generationPersistenceErrorMessage: T = n, onStreamError: E, batchChunksPerFrame: D = !1 }) => {
17
- let O = m(E);
18
- p(() => {
19
- O.current = E;
20
- }, [E]);
21
- let fe = m(D);
22
- p(() => {
23
- fe.current = D;
24
- }, [D]);
25
- let [k] = h(re), [A, j] = h(() => /* @__PURE__ */ new Set()), [M, N] = h(() => /* @__PURE__ */ new Set()), P = m(/* @__PURE__ */ new Map()), F = m(/* @__PURE__ */ new Set()), I = m(/* @__PURE__ */ new Map()), L = m(/* @__PURE__ */ new Set()), pe = m(/* @__PURE__ */ new Map()), R = m(!0), z = m(/* @__PURE__ */ new Map()), [B, V] = h(z.current), H = m(/* @__PURE__ */ new Set()), [me, U] = h(H.current);
26
- p(() => (R.current = !0, () => {
27
- R.current = !1;
14
+ var p = ({ conversationId: p, state: { setConversation: m, conversationRef: h }, transport: g, generation: { startGeneration: _, completeGeneration: v }, channel: y, overlay: b, onStopError: oe, generationConflictMessage: x = e, generationPersistenceErrorMessage: S = n, generationInterruptedMessage: C = t, onStreamError: w, batchChunksPerFrame: T = !1 }) => {
15
+ let E = f(w);
16
+ d(() => {
17
+ E.current = w;
18
+ }, [w]);
19
+ let D = f(T);
20
+ d(() => {
21
+ D.current = T;
22
+ }, [T]);
23
+ let [O] = ae(s), k = f(!0);
24
+ d(() => (k.current = !0, () => {
25
+ k.current = !1;
28
26
  }), []);
29
- let W = f((e) => {
30
- if (!z.current.has(e)) return;
31
- let t = new Map(z.current);
32
- t.delete(e), z.current = t, R.current && V(t);
33
- }, []), G = f((e, t, n) => {
34
- if (!R.current || !n()) return;
35
- let r = new Map(z.current);
36
- r.set(e, {
37
- retry: t,
38
- isCurrent: n
39
- }), z.current = r, V(r);
40
- }, []), he = f(async () => {
41
- if (!o) return;
42
- let e = z.current.get(s(o));
43
- if (!(!e || !e.isCurrent() || H.current.has(e))) {
44
- H.current.add(e), U(new Set(H.current));
45
- try {
46
- await e.retry();
47
- } finally {
48
- H.current.delete(e), R.current && U(new Set(H.current));
49
- }
50
- }
51
- }, [o]), K = m(o);
52
- p(() => (K.current = o, () => k.cancelAll()), [o, k]);
53
- let q = f((e) => R.current && s(K.current ?? "") === e, []), J = f((e) => {
54
- W(e), j((t) => {
55
- if (t.has(e)) return t;
56
- let n = new Set(t);
57
- return n.add(e), n;
58
- });
59
- }, [W]), Y = f((e) => {
60
- j((t) => {
61
- if (!t.has(e)) return t;
62
- let n = new Set(t);
63
- return n.delete(e), n;
64
- });
65
- }, []), X = f((e, t) => {
66
- N((n) => {
67
- if (n.has(e) === t) return n;
68
- let r = new Set(n);
69
- return t ? r.add(e) : r.delete(e), r;
70
- });
71
- }, []), Z = f((e, t) => {
72
- P.current.get(e) === t && (P.current.delete(e), X(e, !1));
73
- }, [X]), Q = oe(() => ee({
74
- transport: b,
75
- setConversation: v,
76
- conversationRef: y,
77
- resumingPathsRef: F,
78
- bufferedGenerationsRef: I,
79
- addStreamingPath: J,
80
- removeStreamingPath: Y,
81
- isPathDisplayed: q,
82
- generationPersistenceErrorMessage: T,
83
- frameScheduler: D ? k : void 0,
84
- stoppedGenerationIdsRef: L,
85
- onReloadError: G,
86
- onReloadSuccess: W
27
+ let { reloadFailuresRef: A, reloadFailures: j, retrying: M, clearReloadError: N, reportReloadError: P, retryConversationReload: se } = l({
28
+ conversationId: p,
29
+ mountedRef: k
30
+ }), { streamingPaths: ce, streamingPathsRef: le, stoppablePaths: ue, activeGenerationIdsRef: F, resumedGenerationIdsRef: I, resumingPathsRef: L, bufferedGenerationsRef: R, stoppedGenerationIdsRef: z, stopRequestedIdsRef: B, latestGenerationIdsRef: V, isPathDisplayed: H, addStreamingPath: U, removeStreamingPath: W, setPathStoppable: G, releaseActiveGeneration: K, rememberResumedGenerationId: q, forgetResumedGenerationId: J } = ne({
31
+ conversationId: p,
32
+ frameScheduler: O,
33
+ mountedRef: k,
34
+ clearReloadError: N
35
+ }), Y = ie(() => a({
36
+ transport: g,
37
+ setConversation: m,
38
+ conversationRef: h,
39
+ resumingPathsRef: L,
40
+ bufferedGenerationsRef: R,
41
+ addStreamingPath: U,
42
+ removeStreamingPath: W,
43
+ isPathDisplayed: H,
44
+ generationPersistenceErrorMessage: S,
45
+ generationInterruptedMessage: C,
46
+ frameScheduler: T ? O : void 0,
47
+ stoppedGenerationIdsRef: z,
48
+ rememberResumedGenerationId: q,
49
+ forgetResumedGenerationId: J,
50
+ onReloadError: P,
51
+ onReloadSuccess: N
87
52
  }), [
88
- J,
89
- Y,
90
- q,
91
- b,
92
- T,
93
- D,
94
- k,
95
- G,
96
- W
97
- ]), ge = f((t, n, o, ee, re, f, p = g.Append, oe = {}) => {
98
- let m = f ?? ae(), h = s(t);
99
- k.flush(h), F.current.delete(h), P.current.set(h, m), pe.current.set(h, m), X(h, !0);
100
- let _;
101
- p === g.Regenerate ? _ = o : p === g.Edit && (_ = o - 1);
102
- let w = () => pe.current.get(h) !== m, E = ue(h, m), D = y.current?.messages[o];
103
- D ? I.current.set(h, {
104
- generationId: m,
105
- messageIndex: o,
106
- message: D
107
- }) : I.current.delete(h), J(h), C?.notifyGenerationStart?.(), S?.ensureConnected();
108
- let A = () => {
109
- w() || Y(h), Z(h, m), x(h, m), S?.notifyGenerationSettled?.();
110
- }, j = () => {
111
- if (w()) return;
112
- let e = I.current.get(h);
113
- !e || e.generationId !== m || (e.message = {
114
- ...e.message,
115
- streamErrorMessage: T
116
- }, O.current?.(new i()), q(h) && v((t) => {
117
- if (!t || w() || !q(h)) return t;
118
- let n = l(t, e);
119
- return y.current = n, n;
120
- }));
121
- }, M = I.current.get(h), N = () => R.current && !w() && I.current.get(h) === M, z = async () => {
122
- if (N()) {
123
- if (!q(h)) {
124
- M && I.current.delete(h);
125
- return;
126
- }
127
- try {
128
- let n = await b.getConversation(e(t));
129
- if (!N()) return;
130
- if (W(h), !q(h)) {
131
- M && I.current.delete(h);
132
- return;
133
- }
134
- if (u(n) !== -1) {
135
- Q(t, n, { seedMessage: M?.message });
136
- return;
137
- }
138
- if (M && M.messageIndex === n.messages.length - 1 && d(n) && ne(M.message)) {
139
- j();
140
- return;
141
- }
142
- M && I.current.delete(h), v(n), y.current = n;
143
- } catch {
144
- N() && G(h, z, N);
145
- }
146
- }
147
- }, B = {
148
- signal: E.signal,
149
- onChunk: (e) => {
150
- if (w()) return;
151
- let t = I.current.get(h);
152
- if (t?.generationId === m) {
153
- let n = c([t.message], 0, e);
154
- n && (t.message = n[0]);
155
- }
156
- if (q(h)) {
157
- if (fe.current && t?.generationId === m) {
158
- k.schedule(h, () => {
159
- let e = I.current.get(h);
160
- if (w() || !q(h) || e?.generationId !== m) return;
161
- let t = { ...e };
162
- v((e) => {
163
- if (!e) return e;
164
- let n = l(e, t);
165
- return y.current = n, n;
166
- });
167
- });
168
- return;
169
- }
170
- v((t) => {
171
- if (!t) return t;
172
- let n = I.current.get(h), r;
173
- if (n?.generationId === m) r = l(t, n);
174
- else {
175
- let n = c(t.messages, o, e);
176
- if (!n) return t;
177
- r = {
178
- ...t,
179
- messages: n
180
- };
181
- }
182
- return y.current = r, r;
183
- });
184
- }
185
- },
186
- onComplete: async () => {
187
- k.flush(h), A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.(), await z();
188
- },
189
- onError: (e) => {
190
- if (k.flush(h), O.current?.(e), e instanceof a && !w()) {
191
- he(e);
192
- return;
193
- }
194
- if (e instanceof r && oe.resumeOnConflict && !w()) {
195
- K(e);
196
- return;
197
- }
198
- V(e);
199
- }
200
- }, V = (e) => {
201
- let t = I.current.get(h), n = t?.generationId === m ? t : void 0;
202
- if (n && !(e instanceof i) && I.current.delete(h), A(), n && b.saveConversation && e instanceof i && e.status === ce) {
203
- me(e, n, b.saveConversation.bind(b));
204
- return;
205
- }
206
- H(e, n);
207
- }, H = (e, t) => {
208
- if (t && e instanceof i && (t.message = {
209
- ...t.message,
210
- streamErrorMessage: T
211
- }), w() || !q(h)) return;
212
- let n = le(e, de, T);
213
- v((e) => {
214
- if (!e || w() || !q(h)) return e;
215
- let r = t?.generationId === m ? l(e, t) : e, i = {
216
- ...r,
217
- messages: r.messages.map((e, t) => t === o ? {
218
- ...e,
219
- streamErrorMessage: n
220
- } : e)
221
- };
222
- return y.current = i, i;
223
- });
224
- }, me = async (n, r, i) => {
225
- let a = () => R.current && !w() && I.current.get(h) === r;
226
- try {
227
- let o = await b.getConversation(e(t));
228
- if (!a()) return;
229
- if (r.messageIndex !== o.messages.length - 1 || !d(o)) {
230
- H(n, r);
231
- return;
232
- }
233
- let s = await i(h, l(o, r));
234
- if (!a() || (I.current.delete(h), !q(h))) return;
235
- v(s), y.current = s;
236
- } catch {
237
- a() && H(n, r);
238
- }
239
- }, U = () => {
240
- A(), L.current.has(m) ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
241
- }, he = async (n) => {
242
- F.current.add(h), ge(await te(() => b.getConversation(e(t)), w), n, !1);
243
- }, K = async (n) => {
244
- P.current.get(h) === m && X(h, !1), F.current.add(h), ge(await te(() => b.getConversation(e(t)), w, (e) => e.messages.length === o && e.messages.at(-1)?.role === ie.User), n, !0);
245
- }, ge = (e, n, r) => {
246
- if (w()) {
247
- A();
248
- return;
249
- }
250
- let i = e?.messages[e.messages.length - 1], a = e != null && e.messages.length - 1 === o && i?.role === ie.Assistant, s = r && e != null && u(e) !== -1;
251
- if (!e || !a && !s) {
252
- F.current.delete(h), V(n);
253
- return;
254
- }
255
- let c = I.current.get(h), l = c?.generationId === m ? c : void 0;
256
- if (d(e)) {
257
- Q(t, e, {
258
- seedMessage: a ? l?.message : void 0,
259
- skipDedupe: !0,
260
- onSettled: U
261
- });
262
- return;
263
- }
264
- F.current.delete(h), l && I.current.delete(h), q(h) && (v(e), y.current = e), U();
265
- };
266
- (async () => {
267
- try {
268
- let e = S?.channelId ?? await S?.waitForChannel(se) ?? void 0, t = L.current.has(m);
269
- if (E.signal.aborted || w() || t) {
270
- I.current.get(h)?.generationId === m && I.current.delete(h), w() || Y(h), Z(h, m), x(h, m), S?.notifyGenerationSettled?.(), t ? L.current.delete(m) : w() || C?.notifyGenerationEnd?.();
271
- return;
272
- }
273
- b.streamCompletion(h, n, ee, B, re, m, p, _, e);
274
- } catch (e) {
275
- B.onError(e instanceof Error ? e : Error(String(e)));
276
- }
277
- })();
278
- }, [
279
- ue,
280
- x,
281
- J,
282
- Y,
283
- X,
284
- Z,
285
- q,
286
- S?.channelId,
287
- S?.ensureConnected,
288
- S?.waitForChannel,
289
- S?.notifyGenerationSettled,
53
+ U,
54
+ W,
55
+ H,
56
+ g,
57
+ S,
290
58
  C,
291
- b,
292
- Q,
293
- de,
294
59
  T,
295
- k,
60
+ O,
61
+ q,
62
+ J,
63
+ P,
64
+ N
65
+ ]), de = u((e, t, n, r, i, a, o, s) => c({
66
+ transport: g,
67
+ channel: y,
68
+ overlay: b,
69
+ startGeneration: _,
70
+ completeGeneration: v,
71
+ setConversation: m,
72
+ conversationRef: h,
73
+ generationConflictMessage: x,
74
+ generationPersistenceErrorMessage: S,
75
+ onStreamErrorRef: E,
76
+ batchChunksPerFrameRef: D,
77
+ mountedRef: k,
78
+ frameScheduler: O,
79
+ resumeGeneration: Y,
80
+ activeGenerationIdsRef: F,
81
+ latestGenerationIdsRef: V,
82
+ resumingPathsRef: L,
83
+ bufferedGenerationsRef: R,
84
+ stoppedGenerationIdsRef: z,
85
+ addStreamingPath: U,
86
+ removeStreamingPath: W,
87
+ setPathStoppable: G,
88
+ releaseActiveGeneration: K,
89
+ isPathDisplayed: H,
90
+ reportReloadError: P,
91
+ clearReloadError: N
92
+ }, e, t, n, r, i, a, o, s), [
93
+ _,
94
+ v,
95
+ U,
96
+ W,
296
97
  G,
297
- W
298
- ]), _e = f((e, t) => {
299
- let n = s(e), r = I.current.get(n);
300
- return z.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === ie.Assistant && !d(t) ? (W(n), I.current.delete(n), t) : r ? l(t, r) : t;
301
- }, [W]), ve = f(() => {
302
- if (!o) return;
303
- let e = s(o), t = P.current.get(e) ?? _(y.current);
304
- if (!t) return;
305
- L.current.add(t), k.flush(e), C?.notifyStopGenerating?.();
306
- let n = I.current.get(e)?.message.content;
307
- b.stopCompletion({
308
- generationId: t,
309
- path: e,
310
- content: n
311
- }).catch((e) => {
312
- let t = e instanceof Error ? e : Error(String(e));
313
- w?.(t);
314
- });
98
+ K,
99
+ H,
100
+ y?.channelId,
101
+ y?.ensureConnected,
102
+ y?.waitForChannel,
103
+ y?.notifyGenerationSettled,
104
+ b,
105
+ g,
106
+ Y,
107
+ x,
108
+ S,
109
+ O,
110
+ P,
111
+ N
112
+ ]), fe = u((e, t) => {
113
+ let n = r(e), a = R.current.get(n);
114
+ return A.current.get(n)?.isCurrent() && a && t.messages.length - 1 >= a.messageIndex && t.messages[a.messageIndex].role === re.Assistant && !o(t) ? (N(n), R.current.delete(n), t) : a ? i(t, a) : t;
315
115
  }, [
316
- o,
317
- y,
318
- k,
319
- w,
320
- C,
321
- b
322
- ]), ye = f((e, t) => Q(e, t), [Q]), be = o != null && A.has(s(o)), $ = o == null ? null : s(o), xe = $ != null && (M.has($) || be && _(y.current) != null), Se = $ ? B.get($) : void 0, Ce = Se?.isCurrent() ?? !1;
116
+ R,
117
+ N,
118
+ A
119
+ ]), pe = te({
120
+ conversationId: p,
121
+ conversationRef: h,
122
+ transport: g,
123
+ overlay: b,
124
+ onStopError: oe,
125
+ frameScheduler: O,
126
+ mountedRef: k,
127
+ activeGenerationIdsRef: F,
128
+ resumedGenerationIdsRef: I,
129
+ bufferedGenerationsRef: R,
130
+ stoppedGenerationIdsRef: z,
131
+ stopRequestedIdsRef: B,
132
+ streamingPathsRef: le
133
+ }), me = u((e, t) => {
134
+ F.current.has(r(e)) || Y(e, t, {
135
+ trackAttachGenerationId: !0,
136
+ shouldMarkOrphanedAsInterrupted: !0
137
+ });
138
+ }, [F, Y]), X = p != null && ce.has(r(p)), Z = p == null ? null : r(p), he = Z != null && (ue.has(Z) || X && ee(h.current) != null), Q = Z ? j.get(Z) : void 0, $ = Q?.isCurrent() ?? !1;
323
139
  return {
324
- hasConversationReloadError: Ce,
325
- isReloadingConversation: !!Se && Ce && me.has(Se),
326
- retryConversationReload: he,
327
- startStream: ge,
328
- handleStop: ve,
329
- resumeIfAwaitingGeneration: ye,
330
- restoreBufferedGeneration: _e,
331
- isStreaming: be,
332
- canStopStreaming: xe
140
+ hasConversationReloadError: $,
141
+ isReloadingConversation: !!Q && $ && M.has(Q),
142
+ retryConversationReload: se,
143
+ startStream: de,
144
+ handleStop: pe,
145
+ resumeIfAwaitingGeneration: me,
146
+ restoreBufferedGeneration: fe,
147
+ isStreaming: X,
148
+ canStopStreaming: he
333
149
  };
334
150
  };
335
151
  //#endregion
336
- export { v as useConversationStream };
152
+ export { p as useConversationStream };
@@ -0,0 +1,29 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { ConversationStateAccessor, ConversationStreamOverlayNotifier, ConversationStreamTransport } from './conversation-stream.types';
3
+ import { FrameScheduler } from './frame-scheduler';
4
+ import { useStreamPathState } from './useStreamPathState';
5
+ type PathState = ReturnType<typeof useStreamPathState>;
6
+ interface UseStopGenerationParams {
7
+ conversationId: string | undefined;
8
+ conversationRef: ConversationStateAccessor['conversationRef'];
9
+ transport: ConversationStreamTransport;
10
+ overlay: ConversationStreamOverlayNotifier | undefined;
11
+ onStopError: ((error: Error) => void) | undefined;
12
+ frameScheduler: FrameScheduler;
13
+ mountedRef: MutableRefObject<boolean>;
14
+ activeGenerationIdsRef: PathState['activeGenerationIdsRef'];
15
+ resumedGenerationIdsRef: PathState['resumedGenerationIdsRef'];
16
+ bufferedGenerationsRef: PathState['bufferedGenerationsRef'];
17
+ stoppedGenerationIdsRef: PathState['stoppedGenerationIdsRef'];
18
+ stopRequestedIdsRef: PathState['stopRequestedIdsRef'];
19
+ streamingPathsRef: PathState['streamingPathsRef'];
20
+ }
21
+ /**
22
+ * Stop for the displayed conversation's generation: resolves its id (local,
23
+ * then a pending background generation, then a resumed one), flushes pending
24
+ * display writes, and asks the backend to stop it. A `404` within a short
25
+ * grace window is the generation ending on its own and is not reported.
26
+ */
27
+ export declare const useStopGeneration: ({ conversationId, conversationRef, transport, overlay, onStopError, frameScheduler, mountedRef, activeGenerationIdsRef, resumedGenerationIdsRef, bufferedGenerationsRef, stoppedGenerationIdsRef, stopRequestedIdsRef, streamingPathsRef, }: UseStopGenerationParams) => () => void;
28
+ export {};
29
+ //# sourceMappingURL=useStopGeneration.d.ts.map