@signalcore/ui 0.1.0 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (611) hide show
  1. package/README.md +896 -513
  2. package/dist/AgentAbout.d.ts +186 -0
  3. package/dist/AgentAbout.js +1020 -0
  4. package/dist/AgentAbout.js.map +1 -0
  5. package/dist/AgentCard.d.ts +49 -0
  6. package/dist/AgentCard.js +77 -0
  7. package/dist/AgentCard.js.map +1 -0
  8. package/dist/AgentChat.d.ts +233 -0
  9. package/dist/AgentChat.js +1127 -0
  10. package/dist/AgentChat.js.map +1 -0
  11. package/dist/AgentSpace.d.ts +112 -0
  12. package/dist/AgentSpace.js +339 -0
  13. package/dist/AgentSpace.js.map +1 -0
  14. package/dist/AgentTasks.d.ts +48 -0
  15. package/dist/AgentTasks.js +120 -0
  16. package/dist/AgentTasks.js.map +1 -0
  17. package/dist/BrowserView.d.ts +52 -0
  18. package/dist/BrowserView.js +328 -0
  19. package/dist/BrowserView.js.map +1 -0
  20. package/dist/FileView.d.ts +63 -0
  21. package/dist/FileView.js +449 -0
  22. package/dist/FileView.js.map +1 -0
  23. package/dist/Modes.d.ts +13 -0
  24. package/dist/Modes.js +75 -0
  25. package/dist/Modes.js.map +1 -0
  26. package/dist/VoiceCall.d.ts +91 -0
  27. package/dist/VoiceCall.js +302 -0
  28. package/dist/VoiceCall.js.map +1 -0
  29. package/dist/about.d.ts +212 -0
  30. package/dist/about.js +136 -0
  31. package/dist/about.js.map +1 -0
  32. package/dist/agentIcons.d.ts +33 -0
  33. package/dist/agentIcons.js +36 -0
  34. package/dist/agentIcons.js.map +1 -0
  35. package/dist/automation/Automation.d.ts +35 -0
  36. package/dist/automation/Automation.js +268 -0
  37. package/dist/automation/Automation.js.map +1 -0
  38. package/dist/automation/RunView.d.ts +25 -0
  39. package/dist/automation/RunView.js +187 -0
  40. package/dist/automation/RunView.js.map +1 -0
  41. package/dist/automation/cron.d.ts +41 -0
  42. package/dist/automation/cron.js +169 -0
  43. package/dist/automation/cron.js.map +1 -0
  44. package/dist/automation/marks.js +121 -0
  45. package/dist/automation/marks.js.map +1 -0
  46. package/dist/automation/messages.d.ts +113 -0
  47. package/dist/automation/messages.js +113 -0
  48. package/dist/automation/messages.js.map +1 -0
  49. package/dist/automation/record.d.ts +47 -0
  50. package/dist/automation/record.js +177 -0
  51. package/dist/automation/record.js.map +1 -0
  52. package/dist/automation/types.d.ts +143 -0
  53. package/dist/automation/when.d.ts +36 -0
  54. package/dist/automation/when.js +168 -0
  55. package/dist/automation/when.js.map +1 -0
  56. package/dist/blocks.d.ts +185 -0
  57. package/dist/browser.js +292 -0
  58. package/dist/browser.js.map +1 -0
  59. package/dist/call.d.ts +89 -0
  60. package/dist/call.js +218 -0
  61. package/dist/call.js.map +1 -0
  62. package/dist/channelParts.js +26 -0
  63. package/dist/channelParts.js.map +1 -0
  64. package/dist/classes.js +8 -3
  65. package/dist/classes.js.map +1 -0
  66. package/dist/client.d.ts +146 -54
  67. package/dist/client.js +204 -1
  68. package/dist/client.js.map +1 -0
  69. package/dist/conversationFiles.js +46 -0
  70. package/dist/conversationFiles.js.map +1 -0
  71. package/dist/credentials.d.ts +45 -0
  72. package/dist/credentials.js +98 -0
  73. package/dist/credentials.js.map +1 -0
  74. package/dist/dev.js +17 -0
  75. package/dist/dev.js.map +1 -0
  76. package/dist/es.d.ts +17 -0
  77. package/dist/es.js +382 -0
  78. package/dist/es.js.map +1 -0
  79. package/dist/files.d.ts +21 -0
  80. package/dist/files.js +214 -0
  81. package/dist/files.js.map +1 -0
  82. package/dist/frames.d.ts +115 -0
  83. package/dist/frames.js +219 -0
  84. package/dist/frames.js.map +1 -0
  85. package/dist/icons.js +29 -0
  86. package/dist/icons.js.map +1 -0
  87. package/dist/index.d.ts +63 -60
  88. package/dist/index.js +59 -45
  89. package/dist/kit/AudioPlayer.d.ts +20 -0
  90. package/dist/kit/AudioPlayer.js +116 -0
  91. package/dist/kit/AudioPlayer.js.map +1 -0
  92. package/dist/kit/Button.d.ts +29 -0
  93. package/dist/kit/Button.js +59 -0
  94. package/dist/kit/Button.js.map +1 -0
  95. package/dist/kit/Card.d.ts +16 -0
  96. package/dist/kit/Card.js +36 -0
  97. package/dist/kit/Card.js.map +1 -0
  98. package/dist/kit/Chart.js +152 -0
  99. package/dist/kit/Chart.js.map +1 -0
  100. package/dist/kit/Choices.d.ts +21 -0
  101. package/dist/kit/Choices.js +99 -0
  102. package/dist/kit/Choices.js.map +1 -0
  103. package/dist/kit/Combobox.d.ts +26 -0
  104. package/dist/kit/Combobox.js +190 -0
  105. package/dist/kit/Combobox.js.map +1 -0
  106. package/dist/kit/DateField.d.ts +17 -0
  107. package/dist/kit/DateField.js +133 -0
  108. package/dist/kit/DateField.js.map +1 -0
  109. package/dist/kit/Field.d.ts +40 -0
  110. package/dist/kit/Field.js +98 -0
  111. package/dist/kit/Field.js.map +1 -0
  112. package/dist/kit/FileField.d.ts +113 -0
  113. package/dist/kit/FileField.js +341 -0
  114. package/dist/kit/FileField.js.map +1 -0
  115. package/dist/kit/FileMark.d.ts +15 -0
  116. package/dist/kit/FileMark.js +39 -0
  117. package/dist/kit/FileMark.js.map +1 -0
  118. package/dist/kit/Inputs.d.ts +59 -0
  119. package/dist/kit/Inputs.js +205 -0
  120. package/dist/kit/Inputs.js.map +1 -0
  121. package/dist/kit/List.d.ts +47 -0
  122. package/dist/kit/List.js +85 -0
  123. package/dist/kit/List.js.map +1 -0
  124. package/dist/kit/Mark.d.ts +30 -0
  125. package/dist/kit/Mark.js +27 -0
  126. package/dist/kit/Mark.js.map +1 -0
  127. package/dist/kit/MarkStack.d.ts +15 -0
  128. package/dist/kit/MarkStack.js +26 -0
  129. package/dist/kit/MarkStack.js.map +1 -0
  130. package/dist/kit/Note.d.ts +11 -0
  131. package/dist/kit/Note.js +31 -0
  132. package/dist/kit/Note.js.map +1 -0
  133. package/dist/kit/Popover.js +90 -0
  134. package/dist/kit/Popover.js.map +1 -0
  135. package/dist/kit/RangeField.d.ts +14 -0
  136. package/dist/kit/RangeField.js +47 -0
  137. package/dist/kit/RangeField.js.map +1 -0
  138. package/dist/kit/RatingField.d.ts +14 -0
  139. package/dist/kit/RatingField.js +50 -0
  140. package/dist/kit/RatingField.js.map +1 -0
  141. package/dist/kit/Stat.d.ts +26 -0
  142. package/dist/kit/Stat.js +46 -0
  143. package/dist/kit/Stat.js.map +1 -0
  144. package/dist/kit/Switch.d.ts +14 -0
  145. package/dist/kit/Switch.js +21 -0
  146. package/dist/kit/Switch.js.map +1 -0
  147. package/dist/kit/Tag.d.ts +16 -0
  148. package/dist/kit/Tag.js +20 -0
  149. package/dist/kit/Tag.js.map +1 -0
  150. package/dist/kit/Tile.d.ts +34 -0
  151. package/dist/kit/Tile.js +52 -0
  152. package/dist/kit/Tile.js.map +1 -0
  153. package/dist/kit/TimeField.d.ts +31 -0
  154. package/dist/kit/TimeField.js +109 -0
  155. package/dist/kit/TimeField.js.map +1 -0
  156. package/dist/kit/context.d.ts +22 -0
  157. package/dist/kit/context.js +46 -0
  158. package/dist/kit/context.js.map +1 -0
  159. package/dist/kit/dates.d.ts +14 -0
  160. package/dist/kit/dates.js +129 -0
  161. package/dist/kit/dates.js.map +1 -0
  162. package/dist/kit/messages.d.ts +99 -0
  163. package/dist/kit/messages.js +66 -0
  164. package/dist/kit/messages.js.map +1 -0
  165. package/dist/kit/numbers.d.ts +12 -0
  166. package/dist/kit/numbers.js +40 -0
  167. package/dist/kit/numbers.js.map +1 -0
  168. package/dist/kit/options.d.ts +10 -0
  169. package/dist/kit/options.js +23 -0
  170. package/dist/kit/options.js.map +1 -0
  171. package/dist/kit/uploads.d.ts +42 -0
  172. package/dist/kit/uploads.js +165 -0
  173. package/dist/kit/uploads.js.map +1 -0
  174. package/dist/kit/waveform.js +76 -0
  175. package/dist/kit/waveform.js.map +1 -0
  176. package/dist/locale.d.ts +1 -0
  177. package/dist/locale.js +1 -0
  178. package/dist/markdown.js +84 -0
  179. package/dist/markdown.js.map +1 -0
  180. package/dist/marks.js +217 -0
  181. package/dist/marks.js.map +1 -0
  182. package/dist/reveal.js +48 -0
  183. package/dist/reveal.js.map +1 -0
  184. package/dist/stepGlyphs.js +62 -0
  185. package/dist/stepGlyphs.js.map +1 -0
  186. package/dist/surface/Form.js +264 -0
  187. package/dist/surface/Form.js.map +1 -0
  188. package/dist/surface/Markdown.js +42 -0
  189. package/dist/surface/Markdown.js.map +1 -0
  190. package/dist/surface/Surface.d.ts +31 -17
  191. package/dist/surface/Surface.js +480 -57
  192. package/dist/surface/Surface.js.map +1 -0
  193. package/dist/surface/scope.d.ts +32 -0
  194. package/dist/surface/scope.js +23 -0
  195. package/dist/surface/scope.js.map +1 -0
  196. package/dist/surface/values.d.ts +44 -0
  197. package/dist/surface/values.js +237 -0
  198. package/dist/surface/values.js.map +1 -0
  199. package/dist/tint.d.ts +10 -0
  200. package/dist/tint.js +19 -0
  201. package/dist/tint.js.map +1 -0
  202. package/dist/types.d.ts +541 -0
  203. package/dist/types.js +16 -0
  204. package/dist/types.js.map +1 -0
  205. package/dist/useAgentFace.d.ts +18 -0
  206. package/dist/useAgentFace.js +45 -0
  207. package/dist/useAgentFace.js.map +1 -0
  208. package/dist/useCall.d.ts +39 -0
  209. package/dist/useCall.js +273 -0
  210. package/dist/useCall.js.map +1 -0
  211. package/dist/useConversation.d.ts +77 -0
  212. package/dist/useConversation.js +523 -0
  213. package/dist/useConversation.js.map +1 -0
  214. package/dist/useDictation.d.ts +17 -0
  215. package/dist/useDictation.js +68 -0
  216. package/dist/useDictation.js.map +1 -0
  217. package/dist/useLive.d.ts +26 -0
  218. package/dist/useLive.js +88 -0
  219. package/dist/useLive.js.map +1 -0
  220. package/dist/usePolled.js +68 -0
  221. package/dist/usePolled.js.map +1 -0
  222. package/dist/voice/Orb.d.ts +10 -9
  223. package/dist/voice/Orb.js +43 -39
  224. package/dist/voice/Orb.js.map +1 -0
  225. package/dist/voice/StillOrb.js +33 -0
  226. package/dist/voice/StillOrb.js.map +1 -0
  227. package/dist/voice/WebGLOrb.js +98 -0
  228. package/dist/voice/WebGLOrb.js.map +1 -0
  229. package/dist/voice/fluidDots.js +161 -0
  230. package/dist/voice/fluidDots.js.map +1 -0
  231. package/dist/voice/motion.js +84 -0
  232. package/dist/voice/motion.js.map +1 -0
  233. package/dist/voice/orbs.d.ts +32 -0
  234. package/dist/voice/orbs.js +16 -0
  235. package/dist/voice/orbs.js.map +1 -0
  236. package/dist/voice/useReducedMotion.js +16 -16
  237. package/dist/voice/useReducedMotion.js.map +1 -0
  238. package/dist/voice/wave.js +116 -0
  239. package/dist/voice/wave.js.map +1 -0
  240. package/dist/voice/webgl.js +177 -0
  241. package/dist/voice/webgl.js.map +1 -0
  242. package/dist/widget.js +284 -8
  243. package/package.json +49 -39
  244. package/src/AgentAbout.tsx +1621 -0
  245. package/src/AgentCard.tsx +123 -0
  246. package/src/AgentChat.tsx +1812 -0
  247. package/src/AgentSpace.tsx +540 -0
  248. package/src/AgentTasks.tsx +163 -0
  249. package/src/BrowserView.tsx +442 -0
  250. package/src/FileView.tsx +620 -0
  251. package/src/Modes.tsx +112 -0
  252. package/src/VoiceCall.tsx +411 -0
  253. package/src/about.ts +355 -0
  254. package/src/agentIcons.ts +56 -0
  255. package/src/automation/Automation.tsx +308 -0
  256. package/src/automation/RunView.tsx +213 -0
  257. package/src/automation/cron.ts +196 -0
  258. package/src/automation/marks.tsx +144 -0
  259. package/src/automation/messages.ts +231 -0
  260. package/src/automation/record.ts +206 -0
  261. package/src/automation/types.ts +146 -0
  262. package/src/automation/when.ts +195 -0
  263. package/src/blocks.ts +249 -0
  264. package/src/browser.ts +334 -0
  265. package/src/call.ts +300 -0
  266. package/src/channelParts.ts +17 -0
  267. package/src/classes.ts +10 -0
  268. package/src/client.ts +397 -0
  269. package/src/conversationFiles.ts +54 -0
  270. package/src/credentials.ts +158 -0
  271. package/src/dev.ts +20 -0
  272. package/src/es.ts +423 -0
  273. package/src/files.ts +238 -0
  274. package/src/frames.ts +291 -0
  275. package/src/icons.tsx +49 -0
  276. package/src/index.ts +271 -0
  277. package/src/kit/AudioPlayer.tsx +129 -0
  278. package/src/kit/Button.tsx +97 -0
  279. package/src/kit/Card.tsx +47 -0
  280. package/src/kit/Chart.tsx +129 -0
  281. package/src/kit/Choices.tsx +131 -0
  282. package/src/kit/Combobox.tsx +247 -0
  283. package/src/kit/DateField.tsx +156 -0
  284. package/src/kit/Field.tsx +137 -0
  285. package/src/kit/FileField.tsx +492 -0
  286. package/src/kit/FileMark.tsx +56 -0
  287. package/src/kit/Inputs.tsx +250 -0
  288. package/src/kit/List.tsx +135 -0
  289. package/src/kit/Mark.tsx +64 -0
  290. package/src/kit/MarkStack.tsx +29 -0
  291. package/src/kit/Note.tsx +42 -0
  292. package/src/kit/Popover.tsx +121 -0
  293. package/src/kit/RangeField.tsx +53 -0
  294. package/src/kit/RatingField.tsx +62 -0
  295. package/src/kit/Stat.tsx +60 -0
  296. package/src/kit/Switch.tsx +28 -0
  297. package/src/kit/Tag.tsx +32 -0
  298. package/src/kit/Tile.tsx +74 -0
  299. package/src/kit/TimeField.tsx +157 -0
  300. package/src/kit/context.tsx +246 -0
  301. package/src/kit/dates.ts +150 -0
  302. package/src/kit/messages.ts +160 -0
  303. package/src/kit/numbers.ts +44 -0
  304. package/src/kit/options.ts +30 -0
  305. package/src/kit/uploads.ts +244 -0
  306. package/src/kit/waveform.ts +84 -0
  307. package/src/locale.ts +6 -0
  308. package/src/markdown.ts +69 -0
  309. package/src/marks.tsx +328 -0
  310. package/src/reveal.ts +52 -0
  311. package/src/stepGlyphs.ts +83 -0
  312. package/src/styles.css +6970 -0
  313. package/src/surface/Form.tsx +299 -0
  314. package/src/surface/Markdown.tsx +55 -0
  315. package/src/surface/Surface.tsx +605 -0
  316. package/src/surface/scope.ts +82 -0
  317. package/src/surface/values.ts +361 -0
  318. package/src/tint.ts +14 -0
  319. package/src/types.ts +604 -0
  320. package/src/useAgentFace.ts +47 -0
  321. package/src/useCall.ts +292 -0
  322. package/src/useConversation.ts +627 -0
  323. package/src/useDictation.ts +83 -0
  324. package/src/useLive.ts +115 -0
  325. package/src/usePolled.ts +60 -0
  326. package/src/voice/Orb.tsx +45 -0
  327. package/src/voice/StillOrb.tsx +29 -0
  328. package/src/voice/WebGLOrb.tsx +98 -0
  329. package/src/voice/fluidDots.tsx +171 -0
  330. package/src/voice/motion.ts +112 -0
  331. package/src/voice/orbs.ts +39 -0
  332. package/src/voice/useReducedMotion.ts +24 -0
  333. package/src/voice/wave.tsx +129 -0
  334. package/src/voice/webgl.ts +209 -0
  335. package/src/widget/css.d.ts +5 -0
  336. package/src/widget/element.tsx +535 -0
  337. package/src/widget/index.ts +10 -0
  338. package/src/widget/mount.ts +27 -0
  339. package/src/widget/widget.css +253 -0
  340. package/dist/SignalcoreProvider.d.ts +0 -113
  341. package/dist/SignalcoreProvider.js +0 -84
  342. package/dist/automations/AppMarks.d.ts +0 -11
  343. package/dist/automations/AppMarks.js +0 -18
  344. package/dist/automations/AutomationCard.d.ts +0 -27
  345. package/dist/automations/AutomationCard.js +0 -53
  346. package/dist/automations/AutomationsWindow.d.ts +0 -38
  347. package/dist/automations/AutomationsWindow.js +0 -57
  348. package/dist/automations/Card.d.ts +0 -46
  349. package/dist/automations/Card.js +0 -45
  350. package/dist/automations/ScheduleMarks.d.ts +0 -13
  351. package/dist/automations/ScheduleMarks.js +0 -24
  352. package/dist/automations/presentationIcons.d.ts +0 -7
  353. package/dist/automations/presentationIcons.js +0 -67
  354. package/dist/automations/schedule.d.ts +0 -25
  355. package/dist/automations/schedule.js +0 -59
  356. package/dist/automations/time.d.ts +0 -3
  357. package/dist/automations/time.js +0 -25
  358. package/dist/browser/BrowserView.d.ts +0 -43
  359. package/dist/browser/BrowserView.js +0 -94
  360. package/dist/browser/room.d.ts +0 -21
  361. package/dist/browser/room.js +0 -33
  362. package/dist/browser/useBrowserSession.d.ts +0 -17
  363. package/dist/browser/useBrowserSession.js +0 -67
  364. package/dist/builder/BuilderChat.d.ts +0 -32
  365. package/dist/builder/BuilderChat.js +0 -41
  366. package/dist/builder/BuilderTranscript.d.ts +0 -49
  367. package/dist/builder/BuilderTranscript.js +0 -62
  368. package/dist/builder/StatusLine.d.ts +0 -8
  369. package/dist/builder/StatusLine.js +0 -17
  370. package/dist/builder/answer.d.ts +0 -7
  371. package/dist/builder/answer.js +0 -8
  372. package/dist/builder/blocks.d.ts +0 -31
  373. package/dist/builder/blocks.js +0 -74
  374. package/dist/builder/items.d.ts +0 -15
  375. package/dist/builder/items.js +0 -21
  376. package/dist/builder/steps.d.ts +0 -20
  377. package/dist/builder/steps.js +0 -120
  378. package/dist/builder/time.d.ts +0 -4
  379. package/dist/builder/time.js +0 -24
  380. package/dist/builder/useBuildSession.d.ts +0 -36
  381. package/dist/builder/useBuildSession.js +0 -130
  382. package/dist/builder/workingOn.d.ts +0 -7
  383. package/dist/builder/workingOn.js +0 -15
  384. package/dist/chat/AgentChat.d.ts +0 -37
  385. package/dist/chat/AgentChat.js +0 -21
  386. package/dist/chat/ChatView.d.ts +0 -25
  387. package/dist/chat/ChatView.js +0 -34
  388. package/dist/chat/Composer.d.ts +0 -20
  389. package/dist/chat/Composer.js +0 -22
  390. package/dist/chat/MessageRow.d.ts +0 -22
  391. package/dist/chat/MessageRow.js +0 -32
  392. package/dist/chat/arrival.d.ts +0 -15
  393. package/dist/chat/arrival.js +0 -25
  394. package/dist/chat/history.d.ts +0 -24
  395. package/dist/chat/history.js +0 -45
  396. package/dist/chat/moments.d.ts +0 -25
  397. package/dist/chat/moments.js +0 -72
  398. package/dist/chat/types.d.ts +0 -12
  399. package/dist/chat/types.js +0 -1
  400. package/dist/chat/useComposer.d.ts +0 -46
  401. package/dist/chat/useComposer.js +0 -62
  402. package/dist/chat/useConversation.d.ts +0 -35
  403. package/dist/chat/useConversation.js +0 -71
  404. package/dist/chat/useStickToBottom.d.ts +0 -9
  405. package/dist/chat/useStickToBottom.js +0 -33
  406. package/dist/chat/useTurns.d.ts +0 -49
  407. package/dist/chat/useTurns.js +0 -111
  408. package/dist/classes.d.ts +0 -2
  409. package/dist/development.d.ts +0 -5
  410. package/dist/development.js +0 -8
  411. package/dist/flow/FlowWindow.d.ts +0 -42
  412. package/dist/flow/FlowWindow.js +0 -126
  413. package/dist/flow/index.d.ts +0 -16
  414. package/dist/flow/index.js +0 -16
  415. package/dist/flow/kinds.d.ts +0 -23
  416. package/dist/flow/kinds.js +0 -48
  417. package/dist/flow/map.d.ts +0 -44
  418. package/dist/flow/map.js +0 -225
  419. package/dist/flow/nodePaths.d.ts +0 -7
  420. package/dist/flow/nodePaths.js +0 -17
  421. package/dist/flow/relations.d.ts +0 -42
  422. package/dist/flow/relations.js +0 -174
  423. package/dist/host.d.ts +0 -124
  424. package/dist/host.js +0 -1
  425. package/dist/live/LiveView.d.ts +0 -28
  426. package/dist/live/LiveView.js +0 -55
  427. package/dist/live/capture.d.ts +0 -20
  428. package/dist/live/capture.js +0 -100
  429. package/dist/live/follow.d.ts +0 -26
  430. package/dist/live/follow.js +0 -72
  431. package/dist/live/paint.d.ts +0 -13
  432. package/dist/live/paint.js +0 -77
  433. package/dist/live/useLiveStream.d.ts +0 -16
  434. package/dist/live/useLiveStream.js +0 -57
  435. package/dist/look.d.ts +0 -33
  436. package/dist/look.js +0 -241
  437. package/dist/messages/en.d.ts +0 -3
  438. package/dist/messages/en.js +0 -251
  439. package/dist/messages/es.d.ts +0 -3
  440. package/dist/messages/es.js +0 -251
  441. package/dist/messages/index.d.ts +0 -16
  442. package/dist/messages/index.js +0 -33
  443. package/dist/messages/types.d.ts +0 -246
  444. package/dist/messages/types.js +0 -1
  445. package/dist/parts/Button.d.ts +0 -18
  446. package/dist/parts/Button.js +0 -17
  447. package/dist/parts/Icon.d.ts +0 -39
  448. package/dist/parts/Icon.js +0 -37
  449. package/dist/parts/Input.d.ts +0 -6
  450. package/dist/parts/Input.js +0 -11
  451. package/dist/parts/Spinner.d.ts +0 -2
  452. package/dist/parts/Spinner.js +0 -7
  453. package/dist/patterns.d.ts +0 -15
  454. package/dist/patterns.js +0 -5
  455. package/dist/presets.d.ts +0 -82
  456. package/dist/presets.js +0 -81
  457. package/dist/primitives.d.ts +0 -22
  458. package/dist/primitives.js +0 -58
  459. package/dist/request/RequestCard.d.ts +0 -34
  460. package/dist/request/RequestCard.js +0 -101
  461. package/dist/request/approval/ApprovalPreview.d.ts +0 -5
  462. package/dist/request/approval/ApprovalPreview.js +0 -27
  463. package/dist/request/approval/shapes.d.ts +0 -32
  464. package/dist/request/approval/shapes.js +0 -68
  465. package/dist/request/apps.d.ts +0 -11
  466. package/dist/request/apps.js +0 -27
  467. package/dist/request/cards.d.ts +0 -12
  468. package/dist/request/cards.js +0 -24
  469. package/dist/request/deliver.d.ts +0 -12
  470. package/dist/request/deliver.js +0 -21
  471. package/dist/request/handOver.d.ts +0 -18
  472. package/dist/request/handOver.js +0 -33
  473. package/dist/request/kinds/Approval.d.ts +0 -3
  474. package/dist/request/kinds/Approval.js +0 -9
  475. package/dist/request/kinds/Choice.d.ts +0 -3
  476. package/dist/request/kinds/Choice.js +0 -8
  477. package/dist/request/kinds/Connect.d.ts +0 -9
  478. package/dist/request/kinds/Connect.js +0 -119
  479. package/dist/request/kinds/FreeText.d.ts +0 -3
  480. package/dist/request/kinds/FreeText.js +0 -20
  481. package/dist/request/kinds/HandOver.d.ts +0 -13
  482. package/dist/request/kinds/HandOver.js +0 -20
  483. package/dist/request/kinds/Secret.d.ts +0 -7
  484. package/dist/request/kinds/Secret.js +0 -49
  485. package/dist/request/kinds/Upload.d.ts +0 -6
  486. package/dist/request/kinds/Upload.js +0 -47
  487. package/dist/request/types.d.ts +0 -83
  488. package/dist/request/types.js +0 -1
  489. package/dist/safeUrl.d.ts +0 -6
  490. package/dist/safeUrl.js +0 -8
  491. package/dist/stream/builder.d.ts +0 -176
  492. package/dist/stream/builder.js +0 -202
  493. package/dist/stream/reduce.d.ts +0 -51
  494. package/dist/stream/reduce.js +0 -58
  495. package/dist/stream/untilAborted.d.ts +0 -7
  496. package/dist/stream/untilAborted.js +0 -32
  497. package/dist/stream/useRunStream.d.ts +0 -26
  498. package/dist/stream/useRunStream.js +0 -137
  499. package/dist/styles.css +0 -2318
  500. package/dist/surface/HostNode.d.ts +0 -14
  501. package/dist/surface/HostNode.js +0 -30
  502. package/dist/surface/Node.d.ts +0 -7
  503. package/dist/surface/Node.js +0 -49
  504. package/dist/surface/SurfaceBoundary.d.ts +0 -26
  505. package/dist/surface/SurfaceBoundary.js +0 -20
  506. package/dist/surface/bindings.d.ts +0 -14
  507. package/dist/surface/bindings.js +0 -37
  508. package/dist/surface/check.d.ts +0 -27
  509. package/dist/surface/check.js +0 -102
  510. package/dist/surface/format.d.ts +0 -10
  511. package/dist/surface/format.js +0 -32
  512. package/dist/surface/hosts.d.ts +0 -6
  513. package/dist/surface/hosts.js +0 -11
  514. package/dist/surface/scene.d.ts +0 -21
  515. package/dist/surface/scene.js +0 -8
  516. package/dist/surface/templates/Browser.d.ts +0 -6
  517. package/dist/surface/templates/Browser.js +0 -11
  518. package/dist/surface/templates/Chart.d.ts +0 -6
  519. package/dist/surface/templates/Chart.js +0 -13
  520. package/dist/surface/templates/Choices.d.ts +0 -3
  521. package/dist/surface/templates/Choices.js +0 -12
  522. package/dist/surface/templates/Form.d.ts +0 -3
  523. package/dist/surface/templates/Form.js +0 -44
  524. package/dist/surface/templates/KeyValue.d.ts +0 -3
  525. package/dist/surface/templates/KeyValue.js +0 -7
  526. package/dist/surface/templates/Layout.d.ts +0 -5
  527. package/dist/surface/templates/Layout.js +0 -16
  528. package/dist/surface/templates/Live.d.ts +0 -6
  529. package/dist/surface/templates/Live.js +0 -9
  530. package/dist/surface/templates/Media.d.ts +0 -5
  531. package/dist/surface/templates/Media.js +0 -13
  532. package/dist/surface/templates/Slots.d.ts +0 -3
  533. package/dist/surface/templates/Slots.js +0 -19
  534. package/dist/surface/templates/Table.d.ts +0 -3
  535. package/dist/surface/templates/Table.js +0 -12
  536. package/dist/surface/templates/Text.d.ts +0 -4
  537. package/dist/surface/templates/Text.js +0 -15
  538. package/dist/surface/templates/index.d.ts +0 -7
  539. package/dist/surface/templates/index.js +0 -32
  540. package/dist/surface/types.d.ts +0 -68
  541. package/dist/surface/types.js +0 -6
  542. package/dist/theme.d.ts +0 -62
  543. package/dist/theme.js +0 -9
  544. package/dist/useTokens.d.ts +0 -7
  545. package/dist/useTokens.js +0 -41
  546. package/dist/voice/VoiceWindow.d.ts +0 -18
  547. package/dist/voice/VoiceWindow.js +0 -35
  548. package/dist/voice/index.d.ts +0 -13
  549. package/dist/voice/index.js +0 -12
  550. package/dist/voice/meter.d.ts +0 -16
  551. package/dist/voice/meter.js +0 -52
  552. package/dist/voice/orbColors.d.ts +0 -16
  553. package/dist/voice/orbColors.js +0 -75
  554. package/dist/voice/pushable.d.ts +0 -16
  555. package/dist/voice/pushable.js +0 -56
  556. package/dist/voice/useDictation.d.ts +0 -24
  557. package/dist/voice/useDictation.js +0 -60
  558. package/dist/voice/useReducedMotion.d.ts +0 -5
  559. package/dist/voice/useVoice.d.ts +0 -70
  560. package/dist/voice/useVoice.js +0 -197
  561. package/dist/voice/useVoicePrimitives.d.ts +0 -7
  562. package/dist/voice/useVoicePrimitives.js +0 -11
  563. package/dist/voice/voice.d.ts +0 -55
  564. package/dist/voice/voice.js +0 -9
  565. package/dist/voice/webSpeech.d.ts +0 -33
  566. package/dist/voice/webSpeech.js +0 -258
  567. package/dist/widget.js.map +0 -1
  568. package/dist/windows/AgentSpace.d.ts +0 -78
  569. package/dist/windows/AgentSpace.js +0 -135
  570. package/dist/windows/Captions.d.ts +0 -13
  571. package/dist/windows/Captions.js +0 -22
  572. package/dist/windows/Dock.d.ts +0 -37
  573. package/dist/windows/Dock.js +0 -22
  574. package/dist/windows/Journal.d.ts +0 -15
  575. package/dist/windows/Journal.js +0 -19
  576. package/dist/windows/KindMark.d.ts +0 -7
  577. package/dist/windows/KindMark.js +0 -31
  578. package/dist/windows/Pending.d.ts +0 -8
  579. package/dist/windows/Pending.js +0 -17
  580. package/dist/windows/Stage.d.ts +0 -18
  581. package/dist/windows/Stage.js +0 -21
  582. package/dist/windows/StatusLabel.d.ts +0 -9
  583. package/dist/windows/StatusLabel.js +0 -7
  584. package/dist/windows/Strip.d.ts +0 -17
  585. package/dist/windows/Strip.js +0 -42
  586. package/dist/windows/SurfaceWindow.d.ts +0 -20
  587. package/dist/windows/SurfaceWindow.js +0 -12
  588. package/dist/windows/WindowFrame.d.ts +0 -23
  589. package/dist/windows/WindowFrame.js +0 -22
  590. package/dist/windows/hearing.d.ts +0 -11
  591. package/dist/windows/hearing.js +0 -26
  592. package/dist/windows/kinds.d.ts +0 -47
  593. package/dist/windows/kinds.js +0 -28
  594. package/dist/windows/reduce.d.ts +0 -98
  595. package/dist/windows/reduce.js +0 -151
  596. package/dist/windows/registry.d.ts +0 -18
  597. package/dist/windows/registry.js +0 -61
  598. package/dist/windows/reveal.d.ts +0 -9
  599. package/dist/windows/reveal.js +0 -6
  600. package/dist/windows/space.d.ts +0 -21
  601. package/dist/windows/space.js +0 -6
  602. package/dist/windows/status.d.ts +0 -11
  603. package/dist/windows/status.js +0 -30
  604. package/dist/windows/types.d.ts +0 -15
  605. package/dist/windows/types.js +0 -1
  606. package/dist/windows/useLoaded.d.ts +0 -44
  607. package/dist/windows/useLoaded.js +0 -58
  608. package/dist/windows/useUnread.d.ts +0 -7
  609. package/dist/windows/useUnread.js +0 -21
  610. package/dist/windows/useWindows.d.ts +0 -70
  611. package/dist/windows/useWindows.js +0 -60
@@ -0,0 +1,26 @@
1
+ //#region src/channelParts.ts
2
+ /**
3
+ * What of an agent's reply on a channel shows now, as the person there gets it: the parts that
4
+ * went, and whether more are on their way (shown as the channel's "typing"). One that failed
5
+ * shows whole, so the business reads what didn't go. Anything that doesn't go out shows whole.
6
+ */
7
+ function channelParts(message, text) {
8
+ if (message.delivery == null) return {
9
+ shown: [text],
10
+ typing: false
11
+ };
12
+ const parts = message.pieces != null && message.pieces.length > 1 ? message.pieces : [text];
13
+ if (message.delivery === "failed") return {
14
+ shown: parts,
15
+ typing: false
16
+ };
17
+ const sent = message.sent_parts ?? (message.delivery === "queued" ? 0 : parts.length);
18
+ return {
19
+ shown: parts.slice(0, sent),
20
+ typing: sent < parts.length
21
+ };
22
+ }
23
+ //#endregion
24
+ export { channelParts };
25
+
26
+ //# sourceMappingURL=channelParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channelParts.js","names":[],"sources":["../src/channelParts.ts"],"sourcesContent":["import type { Message } from \"./types\";\n\n/**\n * What of an agent's reply on a channel shows now, as the person there gets it: the parts that\n * went, and whether more are on their way (shown as the channel's \"typing\"). One that failed\n * shows whole, so the business reads what didn't go. Anything that doesn't go out shows whole.\n */\nexport function channelParts(\n message: Pick<Message, \"delivery\" | \"pieces\" | \"sent_parts\">,\n text: string,\n): { shown: string[]; typing: boolean } {\n if (message.delivery == null) return { shown: [text], typing: false };\n const parts = message.pieces != null && message.pieces.length > 1 ? message.pieces : [text];\n if (message.delivery === \"failed\") return { shown: parts, typing: false };\n const sent = message.sent_parts ?? (message.delivery === \"queued\" ? 0 : parts.length);\n return { shown: parts.slice(0, sent), typing: sent < parts.length };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,aACd,SACA,MACsC;CACtC,IAAI,QAAQ,YAAY,MAAM,OAAO;EAAE,OAAO,CAAC,IAAI;EAAG,QAAQ;CAAM;CACpE,MAAM,QAAQ,QAAQ,UAAU,QAAQ,QAAQ,OAAO,SAAS,IAAI,QAAQ,SAAS,CAAC,IAAI;CAC1F,IAAI,QAAQ,aAAa,UAAU,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAM;CACxE,MAAM,OAAO,QAAQ,eAAe,QAAQ,aAAa,WAAW,IAAI,MAAM;CAC9E,OAAO;EAAE,OAAO,MAAM,MAAM,GAAG,IAAI;EAAG,QAAQ,OAAO,MAAM;CAAO;AACpE"}
package/dist/classes.js CHANGED
@@ -1,4 +1,9 @@
1
- /** A class attribute from the parts that apply: falsy ones are skipped. */
2
- export function classes(...parts) {
3
- return parts.filter(Boolean).join(" ");
1
+ //#region src/classes.ts
2
+ /** The classes of a component's parts: each name, and what the host adds under it. */
3
+ function classes(classNames, ...parts) {
4
+ return parts.flatMap((part) => [part, classNames?.[part]]).filter((name) => name !== void 0).join(" ");
4
5
  }
6
+ //#endregion
7
+ export { classes };
8
+
9
+ //# sourceMappingURL=classes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classes.js","names":[],"sources":["../src/classes.ts"],"sourcesContent":["/** The classes of a component's parts: each name, and what the host adds under it. */\nexport function classes<Part extends string>(\n classNames: Partial<Record<Part, string>> | undefined,\n ...parts: Part[]\n): string {\n return parts\n .flatMap((part) => [part, classNames?.[part]])\n .filter((name) => name !== undefined)\n .join(\" \");\n}\n"],"mappings":";;AACA,SAAgB,QACd,YACA,GAAG,OACK;CACR,OAAO,MACJ,SAAS,SAAS,CAAC,MAAM,aAAa,KAAK,CAAC,CAAC,CAC7C,QAAQ,SAAS,SAAS,KAAA,CAAS,CAAC,CACpC,KAAK,GAAG;AACb"}
package/dist/client.d.ts CHANGED
@@ -1,65 +1,157 @@
1
- import type { BuilderEvent, LiveFrame, LiveStream, Signalcore } from "@signalcore/sdk";
1
+ import { AboutOut, MemoryFact } from "./about.js";
2
+ import { Automation, AutomationView, RunRecord, Task } from "./automation/types.js";
3
+ import { Credentials, Speaker } from "./credentials.js";
4
+ import { AgentFace, CallToken, Channel, Conversation, ConversationDetail, ConversationFile, FileAt, FilePreview, StoredFile, WidgetConfig } from "./types.js";
5
+ //#region src/client.d.ts
2
6
  /**
3
- * What the components ask of the API, and nothing more. `Signalcore` from `@signalcore/sdk` has
4
- * all of it; a host that reaches the API another way (the web app, signed in with a cookie
5
- * instead of a key) supplies the same calls. A group the client lacks is not a failure: the
6
- * component that needs it says so, or hands the answer to the host (`onResolve`).
7
+ * What the API answered when it was not a success: its status, its sentence (`detail`, written
8
+ * to be shown) and its `code`, for a host to word in its own language.
7
9
  */
8
- export interface UiClient {
10
+ export declare class ApiError extends Error {
11
+ readonly status: number;
12
+ readonly detail: string;
13
+ /** What went wrong, by name (`not_found`, `no_calls`); null when the answer named nothing. */
14
+ readonly code: string | null;
15
+ constructor(status: number, detail: string, code?: string | null);
16
+ }
17
+ /**
18
+ * Where the API is, and who calls it (`Credentials`: the cookie, a person's token, a token asked
19
+ * of the host's backend, or a publishable key and its visitor).
20
+ */
21
+ export type ClientOptions = Credentials & {
22
+ /**
23
+ * The API's origin and prefix: `/api` in our own app (the cookie's, on the page's origin), the
24
+ * public `https://…/v1` from a host's page.
25
+ */
26
+ baseUrl: string;
27
+ /** A host's own `fetch`, when the global one is not the right one. */
28
+ fetch?: typeof fetch | undefined;
29
+ };
30
+ /** The files under one owner: the organization's, or an agent's own. */
31
+ export interface Files {
32
+ /** Every file, by path. */
33
+ list: () => Promise<StoredFile[]>;
34
+ /**
35
+ * Stores the bytes under the path (replacing a file of the same name), with the blob's type
36
+ * as the file's; `searchable` makes it knowledge `search_files` reads (text, PDF).
37
+ */
38
+ put: (path: string, blob: Blob, searchable: boolean) => Promise<StoredFile>;
39
+ delete: (path: string) => Promise<void>;
40
+ }
41
+ /** How an upload goes: how much of it has gone, and how to let it go. */
42
+ export interface UploadOptions {
43
+ /** Hears the share sent so far, from 0 to 1, as it goes. */
44
+ onProgress?: ((share: number) => void) | undefined;
45
+ /** Aborting it stops the upload, and the promise rejects with an `AbortError`. */
46
+ signal?: AbortSignal | undefined;
47
+ }
48
+ /** The API, as far as this package reaches it. */
49
+ export interface Client {
50
+ /**
51
+ * The widget's agent and look, by the publishable key it speaks with (a web channel's key).
52
+ */
53
+ widget: () => Promise<WidgetConfig>;
54
+ /**
55
+ * Who the page speaks for, by its credentials: the business (our own app's cookie) or a person
56
+ * it serves (a token, a publishable key's visitor). What waits for the business's yes is
57
+ * answered by the business alone.
58
+ */
59
+ who: Speaker;
60
+ agents: {
61
+ /** What a person may know of the agent: its name, role, mark, and whether it takes calls. */
62
+ face: (id: string) => Promise<AgentFace>;
63
+ /** What the agent says about itself (null until it has written it) and the facts it rests on. */
64
+ about: (id: string) => Promise<AboutOut>;
65
+ /** Has the agent write about itself anew (a model call, a few seconds); answers like `about`. */
66
+ describe: (id: string) => Promise<AboutOut>;
67
+ /** The agent's own files, by path. */
68
+ files: (id: string) => Promise<StoredFile[]>;
69
+ /** Stores a file of the agent's own; see `Files.put`. */
70
+ putFile: (id: string, path: string, blob: Blob, searchable: boolean) => Promise<StoredFile>;
71
+ deleteFile: (id: string, path: string) => Promise<void>;
72
+ /** What the agent remembered, newest first. */
73
+ memories: (id: string) => Promise<MemoryFact[]>;
74
+ /** Takes one memory from it. */
75
+ forget: (id: string, memoryId: string) => Promise<void>;
9
76
  /**
10
- * `resolve` carries an owner's answer. `pending` is optional: it fills in the cards a run is
11
- * waiting on (`useRunStream`) and the ones a builder conversation still waits on, which only
12
- * a host that follows runs or shows that conversation needs.
77
+ * The owner's call with the agent, from the browser (v3/VOICE.md): the call and its
78
+ * conversation (a test) made now, and where to join it (`VoiceCall`'s `connect`).
13
79
  */
14
- requests?: Pick<Signalcore["requests"], "resolve"> & Partial<Pick<Signalcore["requests"], "pending">>;
15
- /** Where a secret typed on a card goes: straight to the vault. */
16
- vault?: Pick<Signalcore["vault"], "put">;
17
- /** Where a document chosen on a card goes. */
18
- documents?: Pick<Signalcore["documents"], "addFile">;
80
+ call: (id: string) => Promise<CallToken>;
81
+ };
82
+ /**
83
+ * The organization's files, shared by every agent; and the preview of any file the caller may
84
+ * read, the organization's, an agent's own or a conversation's (`preview`).
85
+ */
86
+ files: Files & {
87
+ /** What a viewer draws of the file, by its `kind` (v3/FILES.md, Preview). */
88
+ preview: (at: FileAt) => Promise<FilePreview>;
89
+ };
90
+ /** What an agent does on its own (v3/AUTOMATIONS.md). */
91
+ automations: {
92
+ /** The agent's automations, each as it stands now with its newest run. */
93
+ list: (agentId: string) => Promise<Automation[]>;
94
+ /** One of them by its name, with its newest runs. */
95
+ get: (agentId: string, name: string) => Promise<AutomationView>;
96
+ };
97
+ runs: {
98
+ /** One run of an automation with its record: every call it made, step by step. */
99
+ get: (id: string) => Promise<RunRecord>;
100
+ };
101
+ /**
102
+ * The tasks an agent runs for contacts, each with its newest runs: a person's own only (what
103
+ * they asked the agent for in their conversations); the business's, every one.
104
+ */
105
+ tasks: {
106
+ list: (agentId: string) => Promise<Task[]>;
107
+ /** Pauses it, or turns it on again; answers it as it stands. */
108
+ switch: (agentId: string, taskId: string, on: boolean) => Promise<Task>;
109
+ remove: (agentId: string, taskId: string) => Promise<void>;
110
+ };
111
+ /** Where people write to the organization's agents (v3/CHANNELS.md). */
112
+ channels: {
113
+ /** The organization's channels, or one agent's: the disconnected ones too. */
114
+ list: (agentId?: string) => Promise<Channel[]>;
115
+ };
116
+ conversations: {
117
+ /** One conversation with its messages. */
118
+ get: (id: string) => Promise<ConversationDetail>;
119
+ /** A new conversation with an agent. */
120
+ start: (agentId: string) => Promise<Conversation>;
121
+ /** The files that arrived in a conversation: attached, sent through a form. */
122
+ files: (id: string) => Promise<ConversationFile[]>;
19
123
  /**
20
- * `authorize` gets a fresh consent link when the owner clicks a connect card (the one the
21
- * card was made with is good for one attempt and expires); `refresh` asks the provider
22
- * whether they finished.
124
+ * Stores a file in the conversation as the person picks it, to say it or send it through a
125
+ * form by its id: its bytes as they are, under its type and name.
23
126
  */
24
- connections?: Pick<Signalcore["connections"], "authorize" | "refresh">;
25
- /** A hosted browser's page, and its screenshot while it has no live view. */
26
- browser?: Pick<Signalcore["browser"], "get" | "screenshot">;
27
- /** A live stream's pictures, and the input a person sends back (`LiveView`). */
28
- live?: {
29
- connect: (streamId: string, options?: {
30
- signal?: AbortSignal;
31
- }) => WatchedStream;
32
- };
33
- /** A run's status and its live journal. */
34
- runs?: Pick<Signalcore["runs"], "get" | "stream">;
127
+ upload: (id: string, file: File, options?: UploadOptions) => Promise<ConversationFile>;
35
128
  /**
36
- * The live agent. `invoke` is talking to it as the person it serves (`AgentChat`); `overview`
37
- * and `get` are reading it as its owner, for the windows that fetch for themselves when given
38
- * an `agentId` (`AutomationsWindow`: the overview; `FlowWindow`: the overview and, from the
39
- * agent, its package's files). Each component needs only its own.
129
+ * Where a picture, a video or a sound of the conversation plays from in the page's own
130
+ * player: an address that needs no credential, for an hour, streamed as the player seeks.
40
131
  */
41
- agents?: Partial<Pick<Signalcore["agents"], "invoke" | "overview" | "get">>;
42
- /** What the person said and was answered before, for the chat to open on (`AgentChat`). */
43
- endUsers?: Pick<Signalcore["endUsers"], "myConversation">;
44
- /** The builder: the owner's conversations with the assistant that shapes the agent. */
45
- build?: {
46
- sessions: BuildSessionsClient;
47
- };
132
+ play: (id: string, fileId: string) => Promise<string>;
133
+ /**
134
+ * A call with the agent from the browser, for whoever may talk to it (a person, as theirs):
135
+ * the call and its own conversation made now, where what is said lands, and where to join it
136
+ * (`VoiceCall`'s `connect`).
137
+ */
138
+ call: (agentId: string) => Promise<CallToken>;
139
+ };
140
+ /**
141
+ * The conversation's socket address, signed in: `ws:` beside `http:`, `wss:` beside `https:`,
142
+ * with the token (and the visitor) in its query, since a browser's socket takes no header.
143
+ * `fresh` asks the host's backend for a new token first (`getToken`), for a socket that could
144
+ * not open with the last one.
145
+ */
146
+ liveUrl: (conversationId: string, options?: {
147
+ fresh?: boolean | undefined;
148
+ }) => Promise<string>;
48
149
  }
49
150
  /**
50
- * What `LiveView` uses of a stream. The SDK's `LiveStream` is one, and so is anything with its
51
- * first frame, its pictures (the newest, ending when the stream does, throwing when the
52
- * connection fails), a way to send input and a way to hang up.
151
+ * The API under `baseUrl`: JSON in and out, an `ApiError` for anything but a success, signed in
152
+ * the one way `options` gives. A token asked of the host's backend (`getToken`) that the API
153
+ * refuses (401: it expired) is asked for once more, and the request sent again with it.
53
154
  */
54
- export type WatchedStream = Pick<LiveStream, "info" | "send" | "close"> & AsyncIterable<LiveFrame>;
55
- /**
56
- * The calls of a builder conversation (`BuilderChat`, `useBuildSession`). `say` streams one
57
- * turn; hanging up is stopping the iteration, and a client that can hang up at once (a fetch it
58
- * owns) also honours `signal`, which the SDK's `say` may not take yet: a function that takes
59
- * fewer arguments is still a `say`.
60
- */
61
- export interface BuildSessionsClient extends Pick<Signalcore["build"]["sessions"], "create" | "list" | "history"> {
62
- say: (agentId: string, sessionId: string, message: string, options?: {
63
- signal?: AbortSignal;
64
- }) => AsyncGenerator<BuilderEvent, void>;
65
- }
155
+ export declare function createClient(options: ClientOptions): Client;
156
+ //#endregion
157
+ //# sourceMappingURL=client.d.ts.map
package/dist/client.js CHANGED
@@ -1 +1,204 @@
1
- export {};
1
+ import { signerOf } from "./credentials.js";
2
+ //#region src/client.ts
3
+ /**
4
+ * What the API answered when it was not a success: its status, its sentence (`detail`, written
5
+ * to be shown) and its `code`, for a host to word in its own language.
6
+ */
7
+ var ApiError = class extends Error {
8
+ status;
9
+ detail;
10
+ /** What went wrong, by name (`not_found`, `no_calls`); null when the answer named nothing. */
11
+ code;
12
+ constructor(status, detail, code = null) {
13
+ super(detail);
14
+ this.name = "ApiError";
15
+ this.status = status;
16
+ this.detail = detail;
17
+ this.code = code;
18
+ }
19
+ };
20
+ const isRecord = (value) => typeof value === "object" && value !== null;
21
+ const isIssue = (value) => isRecord(value) && typeof value.msg === "string";
22
+ /**
23
+ * Reads an error body: `{code, detail: "message"}`, or FastAPI's 422 `{detail: [{msg, …}, …]}`
24
+ * (the first issue speaks for all). A body with neither is named by its status alone.
25
+ */
26
+ function parseError(status, body) {
27
+ const detail = isRecord(body) ? body.detail : void 0;
28
+ const code = isRecord(body) && typeof body.code === "string" ? body.code : null;
29
+ if (typeof detail === "string" && detail !== "") return new ApiError(status, detail, code);
30
+ if (Array.isArray(detail)) {
31
+ const issue = detail.find(isIssue);
32
+ if (issue) return new ApiError(status, issue.msg);
33
+ }
34
+ return new ApiError(status, `HTTP ${status}`);
35
+ }
36
+ /** A body read as JSON, or null when it is not. */
37
+ function readJson(text) {
38
+ try {
39
+ return JSON.parse(text);
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+ const seg = encodeURIComponent;
45
+ /** A file's path in a URL: each name of it encoded, the slashes between them kept. */
46
+ const filePath = (path) => path.split("/").map(seg).join("/");
47
+ /** Where a file's preview is read: under its conversation, its agent or the organization. */
48
+ const previewPath = (at) => {
49
+ if ("conversationId" in at) return `/conversations/${seg(at.conversationId)}/files/${seg(at.fileId)}/preview`;
50
+ return `${"agentId" in at ? `/agents/${seg(at.agentId)}` : ""}/files/${filePath(at.path)}/preview`;
51
+ };
52
+ /**
53
+ * The API under `baseUrl`: JSON in and out, an `ApiError` for anything but a success, signed in
54
+ * the one way `options` gives. A token asked of the host's backend (`getToken`) that the API
55
+ * refuses (401: it expired) is asked for once more, and the request sent again with it.
56
+ */
57
+ function createClient(options) {
58
+ const { baseUrl, fetch: call = fetch } = options;
59
+ const signer = signerOf(options);
60
+ /** One request with the cookie or the credential's headers; a body goes as it is, typed. */
61
+ async function attempt(method, path, body) {
62
+ const signed = await signer.sign();
63
+ return {
64
+ response: await call(`${baseUrl}${path}`, {
65
+ method,
66
+ credentials: signer.credentials,
67
+ headers: body === void 0 ? signed.headers : {
68
+ ...signed.headers,
69
+ "Content-Type": body.type
70
+ },
71
+ ...body === void 0 ? {} : { body }
72
+ }),
73
+ signed
74
+ };
75
+ }
76
+ async function send(method, path, body) {
77
+ let { response, signed } = await attempt(method, path, body);
78
+ if (response.status === 401 && signed.renew !== null) {
79
+ signed.renew();
80
+ ({response} = await attempt(method, path, body));
81
+ }
82
+ if (!response.ok) {
83
+ const answer = await response.json().catch(() => null);
84
+ throw parseError(response.status, answer);
85
+ }
86
+ return response;
87
+ }
88
+ async function json(method, path, body) {
89
+ return await (await send(method, path, body)).json();
90
+ }
91
+ /** A request whose answer has no body (204). */
92
+ async function run(method, path) {
93
+ await send(method, path);
94
+ }
95
+ /** The four of `Files` under a prefix: `/files`, or `/agents/{id}/files`. */
96
+ const filesUnder = (prefix) => ({
97
+ list: () => json("GET", prefix),
98
+ put: (path, blob, searchable) => json("PUT", `${prefix}/${filePath(path)}?searchable=${searchable}`, blob),
99
+ delete: (path) => run("DELETE", `${prefix}/${filePath(path)}`)
100
+ });
101
+ const own = (id) => filesUnder(`/agents/${seg(id)}/files`);
102
+ /**
103
+ * A file sent by XMLHttpRequest, the one way a browser tells how much of a body has gone; the
104
+ * cookie goes as with `fetch` on the same origin, any other credential as its headers. Refused
105
+ * with a token asked of the host's backend, it is sent once more with a new one.
106
+ */
107
+ async function sendFile(path, file, options = {}) {
108
+ const signed = await signer.sign();
109
+ try {
110
+ return await post(path, file, signed.headers, options);
111
+ } catch (error) {
112
+ if (!(error instanceof ApiError && error.status === 401) || signed.renew === null) throw error;
113
+ signed.renew();
114
+ return post(path, file, (await signer.sign()).headers, options);
115
+ }
116
+ }
117
+ function post(path, file, headers, { onProgress, signal }) {
118
+ return new Promise((resolve, reject) => {
119
+ const aborted = () => new DOMException("The upload was aborted", "AbortError");
120
+ if (signal?.aborted) {
121
+ reject(aborted());
122
+ return;
123
+ }
124
+ const request = new XMLHttpRequest();
125
+ const abort = () => {
126
+ request.abort();
127
+ };
128
+ request.open("POST", `${baseUrl}${path}`);
129
+ for (const [name, value] of Object.entries(headers)) request.setRequestHeader(name, value);
130
+ request.setRequestHeader("Content-Type", file.type || "application/octet-stream");
131
+ request.setRequestHeader("X-File-Name", encodeURIComponent(file.name));
132
+ request.upload.addEventListener("progress", (event) => {
133
+ if (event.lengthComputable && event.total > 0) onProgress?.(event.loaded / event.total);
134
+ });
135
+ request.addEventListener("loadend", () => {
136
+ signal?.removeEventListener("abort", abort);
137
+ });
138
+ request.addEventListener("load", () => {
139
+ const body = readJson(request.responseText);
140
+ if (request.status >= 200 && request.status < 300) resolve(body);
141
+ else reject(parseError(request.status, body));
142
+ });
143
+ request.addEventListener("error", () => {
144
+ reject(new ApiError(0, "The upload could not reach the server"));
145
+ });
146
+ request.addEventListener("abort", () => {
147
+ reject(aborted());
148
+ });
149
+ signal?.addEventListener("abort", abort, { once: true });
150
+ request.send(file);
151
+ });
152
+ }
153
+ return {
154
+ widget: () => json("GET", "/channels/web/widget"),
155
+ who: signer.who,
156
+ agents: {
157
+ face: (id) => json("GET", `/agents/${seg(id)}/face`),
158
+ about: (id) => json("GET", `/agents/${seg(id)}/about`),
159
+ describe: (id) => json("POST", `/agents/${seg(id)}/describe`),
160
+ files: (id) => own(id).list(),
161
+ putFile: (id, path, blob, searchable) => own(id).put(path, blob, searchable),
162
+ deleteFile: (id, path) => own(id).delete(path),
163
+ memories: (id) => json("GET", `/agents/${seg(id)}/memories`),
164
+ forget: (id, memoryId) => run("DELETE", `/agents/${seg(id)}/memories/${seg(memoryId)}`),
165
+ call: (id) => json("POST", `/agents/${seg(id)}/voice/token`)
166
+ },
167
+ files: {
168
+ ...filesUnder("/files"),
169
+ preview: (at) => json("GET", previewPath(at))
170
+ },
171
+ automations: {
172
+ list: (agentId) => json("GET", `/agents/${seg(agentId)}/automations`),
173
+ get: (agentId, name) => json("GET", `/agents/${seg(agentId)}/automations/${seg(name)}`)
174
+ },
175
+ runs: { get: (id) => json("GET", `/runs/${seg(id)}`) },
176
+ tasks: {
177
+ list: (agentId) => json("GET", `/agents/${seg(agentId)}/tasks`),
178
+ switch: (agentId, taskId, on) => json("PATCH", `/agents/${seg(agentId)}/tasks/${seg(taskId)}`, new Blob([JSON.stringify({ on })], { type: "application/json" })),
179
+ remove: (agentId, taskId) => run("DELETE", `/agents/${seg(agentId)}/tasks/${seg(taskId)}`)
180
+ },
181
+ channels: { list: (agentId) => json("GET", agentId === void 0 ? "/channels" : `/channels?agent=${seg(agentId)}`) },
182
+ conversations: {
183
+ get: (id) => json("GET", `/conversations/${seg(id)}`),
184
+ start: (agentId) => json("POST", `/agents/${seg(agentId)}/conversations`),
185
+ files: (id) => json("GET", `/conversations/${seg(id)}/files`),
186
+ upload: (id, file, options) => sendFile(`/conversations/${seg(id)}/files`, file, options),
187
+ play: async (id, fileId) => {
188
+ const link = await json("GET", `/conversations/${seg(id)}/files/${seg(fileId)}/link`);
189
+ return new URL(`${baseUrl}${link.path}`, window.location.href).href;
190
+ },
191
+ call: (agentId) => json("POST", `/agents/${seg(agentId)}/calls`)
192
+ },
193
+ liveUrl: async (conversationId, { fresh = false } = {}) => {
194
+ const url = new URL(`${baseUrl}/conversations/${seg(conversationId)}/live`, window.location.href);
195
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
196
+ for (const [name, value] of Object.entries(await signer.query(fresh))) url.searchParams.set(name, value);
197
+ return url.href;
198
+ }
199
+ };
200
+ }
201
+ //#endregion
202
+ export { ApiError, createClient, parseError };
203
+
204
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { AboutOut, MemoryFact } from \"./about\";\nimport type { Automation, AutomationView, RunRecord, Task } from \"./automation/types\";\nimport { signerOf, type Credentials, type Speaker } from \"./credentials\";\nimport type {\n AgentFace,\n WidgetConfig,\n CallToken,\n Channel,\n Conversation,\n ConversationDetail,\n ConversationFile,\n FileAt,\n FileLink,\n FilePreview,\n StoredFile,\n} from \"./types\";\n\n/**\n * What the API answered when it was not a success: its status, its sentence (`detail`, written\n * to be shown) and its `code`, for a host to word in its own language.\n */\nexport class ApiError extends Error {\n readonly status: number;\n readonly detail: string;\n /** What went wrong, by name (`not_found`, `no_calls`); null when the answer named nothing. */\n readonly code: string | null;\n\n constructor(status: number, detail: string, code: string | null = null) {\n super(detail);\n this.name = \"ApiError\";\n this.status = status;\n this.detail = detail;\n this.code = code;\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isIssue = (value: unknown): value is { msg: string } =>\n isRecord(value) && typeof value.msg === \"string\";\n\n/**\n * Reads an error body: `{code, detail: \"message\"}`, or FastAPI's 422 `{detail: [{msg, …}, …]}`\n * (the first issue speaks for all). A body with neither is named by its status alone.\n */\nexport function parseError(status: number, body: unknown): ApiError {\n const detail = isRecord(body) ? body.detail : undefined;\n const code = isRecord(body) && typeof body.code === \"string\" ? body.code : null;\n if (typeof detail === \"string\" && detail !== \"\") return new ApiError(status, detail, code);\n if (Array.isArray(detail)) {\n const issue = detail.find(isIssue);\n if (issue) return new ApiError(status, issue.msg);\n }\n return new ApiError(status, `HTTP ${status}`);\n}\n\n/** A body read as JSON, or null when it is not. */\nfunction readJson(text: string): unknown {\n try {\n return JSON.parse(text) as unknown;\n } catch {\n return null;\n }\n}\n\n/**\n * Where the API is, and who calls it (`Credentials`: the cookie, a person's token, a token asked\n * of the host's backend, or a publishable key and its visitor).\n */\nexport type ClientOptions = Credentials & {\n /**\n * The API's origin and prefix: `/api` in our own app (the cookie's, on the page's origin), the\n * public `https://…/v1` from a host's page.\n */\n baseUrl: string;\n /** A host's own `fetch`, when the global one is not the right one. */\n fetch?: typeof fetch | undefined;\n};\n\n/** The files under one owner: the organization's, or an agent's own. */\nexport interface Files {\n /** Every file, by path. */\n list: () => Promise<StoredFile[]>;\n /**\n * Stores the bytes under the path (replacing a file of the same name), with the blob's type\n * as the file's; `searchable` makes it knowledge `search_files` reads (text, PDF).\n */\n put: (path: string, blob: Blob, searchable: boolean) => Promise<StoredFile>;\n delete: (path: string) => Promise<void>;\n}\n\n/** How an upload goes: how much of it has gone, and how to let it go. */\nexport interface UploadOptions {\n /** Hears the share sent so far, from 0 to 1, as it goes. */\n onProgress?: ((share: number) => void) | undefined;\n /** Aborting it stops the upload, and the promise rejects with an `AbortError`. */\n signal?: AbortSignal | undefined;\n}\n\n/** The API, as far as this package reaches it. */\nexport interface Client {\n /**\n * The widget's agent and look, by the publishable key it speaks with (a web channel's key).\n */\n widget: () => Promise<WidgetConfig>;\n /**\n * Who the page speaks for, by its credentials: the business (our own app's cookie) or a person\n * it serves (a token, a publishable key's visitor). What waits for the business's yes is\n * answered by the business alone.\n */\n who: Speaker;\n agents: {\n /** What a person may know of the agent: its name, role, mark, and whether it takes calls. */\n face: (id: string) => Promise<AgentFace>;\n /** What the agent says about itself (null until it has written it) and the facts it rests on. */\n about: (id: string) => Promise<AboutOut>;\n /** Has the agent write about itself anew (a model call, a few seconds); answers like `about`. */\n describe: (id: string) => Promise<AboutOut>;\n /** The agent's own files, by path. */\n files: (id: string) => Promise<StoredFile[]>;\n /** Stores a file of the agent's own; see `Files.put`. */\n putFile: (id: string, path: string, blob: Blob, searchable: boolean) => Promise<StoredFile>;\n deleteFile: (id: string, path: string) => Promise<void>;\n /** What the agent remembered, newest first. */\n memories: (id: string) => Promise<MemoryFact[]>;\n /** Takes one memory from it. */\n forget: (id: string, memoryId: string) => Promise<void>;\n /**\n * The owner's call with the agent, from the browser (v3/VOICE.md): the call and its\n * conversation (a test) made now, and where to join it (`VoiceCall`'s `connect`).\n */\n call: (id: string) => Promise<CallToken>;\n };\n /**\n * The organization's files, shared by every agent; and the preview of any file the caller may\n * read, the organization's, an agent's own or a conversation's (`preview`).\n */\n files: Files & {\n /** What a viewer draws of the file, by its `kind` (v3/FILES.md, Preview). */\n preview: (at: FileAt) => Promise<FilePreview>;\n };\n /** What an agent does on its own (v3/AUTOMATIONS.md). */\n automations: {\n /** The agent's automations, each as it stands now with its newest run. */\n list: (agentId: string) => Promise<Automation[]>;\n /** One of them by its name, with its newest runs. */\n get: (agentId: string, name: string) => Promise<AutomationView>;\n };\n runs: {\n /** One run of an automation with its record: every call it made, step by step. */\n get: (id: string) => Promise<RunRecord>;\n };\n /**\n * The tasks an agent runs for contacts, each with its newest runs: a person's own only (what\n * they asked the agent for in their conversations); the business's, every one.\n */\n tasks: {\n list: (agentId: string) => Promise<Task[]>;\n /** Pauses it, or turns it on again; answers it as it stands. */\n switch: (agentId: string, taskId: string, on: boolean) => Promise<Task>;\n remove: (agentId: string, taskId: string) => Promise<void>;\n };\n /** Where people write to the organization's agents (v3/CHANNELS.md). */\n channels: {\n /** The organization's channels, or one agent's: the disconnected ones too. */\n list: (agentId?: string) => Promise<Channel[]>;\n };\n conversations: {\n /** One conversation with its messages. */\n get: (id: string) => Promise<ConversationDetail>;\n /** A new conversation with an agent. */\n start: (agentId: string) => Promise<Conversation>;\n /** The files that arrived in a conversation: attached, sent through a form. */\n files: (id: string) => Promise<ConversationFile[]>;\n /**\n * Stores a file in the conversation as the person picks it, to say it or send it through a\n * form by its id: its bytes as they are, under its type and name.\n */\n upload: (id: string, file: File, options?: UploadOptions) => Promise<ConversationFile>;\n /**\n * Where a picture, a video or a sound of the conversation plays from in the page's own\n * player: an address that needs no credential, for an hour, streamed as the player seeks.\n */\n play: (id: string, fileId: string) => Promise<string>;\n /**\n * A call with the agent from the browser, for whoever may talk to it (a person, as theirs):\n * the call and its own conversation made now, where what is said lands, and where to join it\n * (`VoiceCall`'s `connect`).\n */\n call: (agentId: string) => Promise<CallToken>;\n };\n /**\n * The conversation's socket address, signed in: `ws:` beside `http:`, `wss:` beside `https:`,\n * with the token (and the visitor) in its query, since a browser's socket takes no header.\n * `fresh` asks the host's backend for a new token first (`getToken`), for a socket that could\n * not open with the last one.\n */\n liveUrl: (conversationId: string, options?: { fresh?: boolean | undefined }) => Promise<string>;\n}\n\nconst seg = encodeURIComponent;\n\n/** A file's path in a URL: each name of it encoded, the slashes between them kept. */\nconst filePath = (path: string): string => path.split(\"/\").map(seg).join(\"/\");\n\n/** Where a file's preview is read: under its conversation, its agent or the organization. */\nconst previewPath = (at: FileAt): string => {\n if (\"conversationId\" in at) {\n return `/conversations/${seg(at.conversationId)}/files/${seg(at.fileId)}/preview`;\n }\n const owner = \"agentId\" in at ? `/agents/${seg(at.agentId)}` : \"\";\n return `${owner}/files/${filePath(at.path)}/preview`;\n};\n\ntype Method = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\n/**\n * The API under `baseUrl`: JSON in and out, an `ApiError` for anything but a success, signed in\n * the one way `options` gives. A token asked of the host's backend (`getToken`) that the API\n * refuses (401: it expired) is asked for once more, and the request sent again with it.\n */\nexport function createClient(options: ClientOptions): Client {\n const { baseUrl, fetch: call = fetch } = options;\n const signer = signerOf(options);\n\n /** One request with the cookie or the credential's headers; a body goes as it is, typed. */\n async function attempt(method: Method, path: string, body: Blob | undefined) {\n const signed = await signer.sign();\n const response = await call(`${baseUrl}${path}`, {\n method,\n credentials: signer.credentials,\n headers:\n body === undefined ? signed.headers : { ...signed.headers, \"Content-Type\": body.type },\n ...(body === undefined ? {} : { body }),\n });\n return { response, signed };\n }\n\n async function send(method: Method, path: string, body?: Blob): Promise<Response> {\n let { response, signed } = await attempt(method, path, body);\n if (response.status === 401 && signed.renew !== null) {\n signed.renew();\n ({ response } = await attempt(method, path, body));\n }\n if (!response.ok) {\n const answer: unknown = await response.json().catch(() => null);\n throw parseError(response.status, answer);\n }\n return response;\n }\n\n async function json<T>(method: Method, path: string, body?: Blob): Promise<T> {\n return (await (await send(method, path, body)).json()) as T;\n }\n\n /** A request whose answer has no body (204). */\n async function run(method: Method, path: string): Promise<void> {\n await send(method, path);\n }\n\n /** The four of `Files` under a prefix: `/files`, or `/agents/{id}/files`. */\n const filesUnder = (prefix: string): Files => ({\n list: () => json(\"GET\", prefix),\n put: (path, blob, searchable) =>\n json(\"PUT\", `${prefix}/${filePath(path)}?searchable=${searchable}`, blob),\n delete: (path) => run(\"DELETE\", `${prefix}/${filePath(path)}`),\n });\n\n const own = (id: string) => filesUnder(`/agents/${seg(id)}/files`);\n\n /**\n * A file sent by XMLHttpRequest, the one way a browser tells how much of a body has gone; the\n * cookie goes as with `fetch` on the same origin, any other credential as its headers. Refused\n * with a token asked of the host's backend, it is sent once more with a new one.\n */\n async function sendFile(\n path: string,\n file: File,\n options: UploadOptions = {},\n ): Promise<ConversationFile> {\n const signed = await signer.sign();\n try {\n return await post(path, file, signed.headers, options);\n } catch (error) {\n const expired = error instanceof ApiError && error.status === 401;\n if (!expired || signed.renew === null) throw error;\n signed.renew();\n return post(path, file, (await signer.sign()).headers, options);\n }\n }\n\n function post(\n path: string,\n file: File,\n headers: Readonly<Record<string, string>>,\n { onProgress, signal }: UploadOptions,\n ): Promise<ConversationFile> {\n return new Promise((resolve, reject) => {\n const aborted = () => new DOMException(\"The upload was aborted\", \"AbortError\");\n if (signal?.aborted) {\n reject(aborted());\n return;\n }\n const request = new XMLHttpRequest();\n const abort = () => {\n request.abort();\n };\n request.open(\"POST\", `${baseUrl}${path}`);\n for (const [name, value] of Object.entries(headers)) request.setRequestHeader(name, value);\n request.setRequestHeader(\"Content-Type\", file.type || \"application/octet-stream\");\n request.setRequestHeader(\"X-File-Name\", encodeURIComponent(file.name));\n request.upload.addEventListener(\"progress\", (event) => {\n if (event.lengthComputable && event.total > 0) onProgress?.(event.loaded / event.total);\n });\n request.addEventListener(\"loadend\", () => {\n signal?.removeEventListener(\"abort\", abort);\n });\n request.addEventListener(\"load\", () => {\n const body = readJson(request.responseText);\n if (request.status >= 200 && request.status < 300) resolve(body as ConversationFile);\n else reject(parseError(request.status, body));\n });\n request.addEventListener(\"error\", () => {\n reject(new ApiError(0, \"The upload could not reach the server\"));\n });\n request.addEventListener(\"abort\", () => {\n reject(aborted());\n });\n signal?.addEventListener(\"abort\", abort, { once: true });\n request.send(file);\n });\n }\n\n return {\n widget: () => json(\"GET\", \"/channels/web/widget\"),\n who: signer.who,\n agents: {\n face: (id) => json(\"GET\", `/agents/${seg(id)}/face`),\n about: (id) => json(\"GET\", `/agents/${seg(id)}/about`),\n describe: (id) => json(\"POST\", `/agents/${seg(id)}/describe`),\n files: (id) => own(id).list(),\n putFile: (id, path, blob, searchable) => own(id).put(path, blob, searchable),\n deleteFile: (id, path) => own(id).delete(path),\n memories: (id) => json(\"GET\", `/agents/${seg(id)}/memories`),\n forget: (id, memoryId) => run(\"DELETE\", `/agents/${seg(id)}/memories/${seg(memoryId)}`),\n call: (id) => json(\"POST\", `/agents/${seg(id)}/voice/token`),\n },\n files: { ...filesUnder(\"/files\"), preview: (at) => json(\"GET\", previewPath(at)) },\n automations: {\n list: (agentId) => json(\"GET\", `/agents/${seg(agentId)}/automations`),\n get: (agentId, name) => json(\"GET\", `/agents/${seg(agentId)}/automations/${seg(name)}`),\n },\n runs: {\n get: (id) => json(\"GET\", `/runs/${seg(id)}`),\n },\n tasks: {\n list: (agentId) => json(\"GET\", `/agents/${seg(agentId)}/tasks`),\n switch: (agentId, taskId, on) =>\n json(\n \"PATCH\",\n `/agents/${seg(agentId)}/tasks/${seg(taskId)}`,\n new Blob([JSON.stringify({ on })], { type: \"application/json\" }),\n ),\n remove: (agentId, taskId) => run(\"DELETE\", `/agents/${seg(agentId)}/tasks/${seg(taskId)}`),\n },\n channels: {\n list: (agentId) =>\n json(\"GET\", agentId === undefined ? \"/channels\" : `/channels?agent=${seg(agentId)}`),\n },\n conversations: {\n get: (id) => json(\"GET\", `/conversations/${seg(id)}`),\n start: (agentId) => json(\"POST\", `/agents/${seg(agentId)}/conversations`),\n files: (id) => json(\"GET\", `/conversations/${seg(id)}/files`),\n upload: (id, file, options) => sendFile(`/conversations/${seg(id)}/files`, file, options),\n play: async (id, fileId) => {\n const link = await json<FileLink>(\n \"GET\",\n `/conversations/${seg(id)}/files/${seg(fileId)}/link`,\n );\n return new URL(`${baseUrl}${link.path}`, window.location.href).href;\n },\n call: (agentId) => json(\"POST\", `/agents/${seg(agentId)}/calls`),\n },\n liveUrl: async (conversationId, { fresh = false } = {}) => {\n const url = new URL(\n `${baseUrl}/conversations/${seg(conversationId)}/live`,\n window.location.href,\n );\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n for (const [name, value] of Object.entries(await signer.query(fresh))) {\n url.searchParams.set(name, value);\n }\n return url.href;\n },\n };\n}\n"],"mappings":";;;;;;AAqBA,IAAa,WAAb,cAA8B,MAAM;CAClC;CACA;;CAEA;CAEA,YAAY,QAAgB,QAAgB,OAAsB,MAAM;EACtE,MAAM,MAAM;EACZ,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,OAAO;CACd;AACF;AAEA,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAA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AC,CAAC,GAAG,EAAE,MAAM,mBAAmB,CAAC,CACjE;GACF,SAAS,SAAS,WAAW,IAAI,UAAU,WAAW,IAAI,OAAO,EAAE,SAAS,IAAI,MAAM,GAAG;EAC3F;EACA,UAAU,EACR,OAAO,YACL,KAAK,OAAO,YAAY,KAAA,IAAY,cAAc,mBAAmB,IAAI,OAAO,GAAG,EACvF;EACA,eAAe;GACb,MAAM,OAAO,KAAK,OAAO,kBAAkB,IAAI,EAAE,GAAG;GACpD,QAAQ,YAAY,KAAK,QAAQ,WAAW,IAAI,OAAO,EAAE,eAAe;GACxE,QAAQ,OAAO,KAAK,OAAO,kBAAkB,IAAI,EAAE,EAAE,OAAO;GAC5D,SAAS,IAAI,MAAM,YAAY,SAAS,kBAAkB,IAAI,EAAE,EAAE,SAAS,MAAM,OAAO;GACxF,MAAM,OAAO,IAAI,WAAW;IAC1B,MAAM,OAAO,MAAM,KACjB,OACA,kBAAkB,IAAI,EAAE,EAAE,SAAS,IAAI,MAAM,EAAE,MACjD;IACA,OAAO,IAAI,IAAI,GAAG,UAAU,KAAK,QAAQ,OAAO,SAAS,IAAI,CAAC,CAAC;GACjE;GACA,OAAO,YAAY,KAAK,QAAQ,WAAW,IAAI,OAAO,EAAE,OAAO;EACjE;EACA,SAAS,OAAO,gBAAgB,EAAE,QAAQ,UAAU,CAAC,MAAM;GACzD,MAAM,MAAM,IAAI,IACd,GAAG,QAAQ,iBAAiB,IAAI,cAAc,EAAE,QAChD,OAAO,SAAS,IAClB;GACA,IAAI,WAAW,IAAI,aAAa,WAAW,SAAS;GACpD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,OAAO,MAAM,KAAK,CAAC,GAClE,IAAI,aAAa,IAAI,MAAM,KAAK;GAElC,OAAO,IAAI;EACb;CACF;AACF"}
@@ -0,0 +1,46 @@
1
+ import { useMemo, useRef, useState } from "react";
2
+ //#region src/conversationFiles.ts
3
+ /**
4
+ * A conversation's files, as its chat's pieces reach them: an upload to it (the composer's, a
5
+ * form's file field), every file known by id (said in its messages, uploaded here, or read back
6
+ * once when one is asked for that neither has), where one plays from, and the host's way to
7
+ * open one.
8
+ */
9
+ function useConversationFiles(client, conversationId, messages, open) {
10
+ const [kept, setKept] = useState(() => /* @__PURE__ */ new Map());
11
+ const listed = useRef(false);
12
+ const known = useMemo(() => {
13
+ const all = new Map(kept);
14
+ for (const message of messages) for (const file of message.files ?? []) all.set(file.id, file);
15
+ return all;
16
+ }, [messages, kept]);
17
+ const keep = (files) => {
18
+ setKept((now) => {
19
+ const next = new Map(now);
20
+ for (const file of files) next.set(file.id, file);
21
+ return next;
22
+ });
23
+ };
24
+ return {
25
+ known,
26
+ open,
27
+ play: (file) => client.conversations.play(conversationId, file.id),
28
+ upload: async (file, progress, signal) => {
29
+ const stored = await client.conversations.upload(conversationId, file, {
30
+ onProgress: progress,
31
+ signal
32
+ });
33
+ keep([stored]);
34
+ return stored;
35
+ },
36
+ find: (ids) => {
37
+ if (listed.current || ids.every((id) => known.has(id))) return;
38
+ listed.current = true;
39
+ client.conversations.files(conversationId).then(keep, () => void 0);
40
+ }
41
+ };
42
+ }
43
+ //#endregion
44
+ export { useConversationFiles };
45
+
46
+ //# sourceMappingURL=conversationFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationFiles.js","names":[],"sources":["../src/conversationFiles.ts"],"sourcesContent":["import { useMemo, useRef, useState } from \"react\";\n\nimport type { Client } from \"./client\";\nimport type { FileHost } from \"./kit/uploads\";\nimport type { Attachment, Message } from \"./types\";\n\n/**\n * A conversation's files, as its chat's pieces reach them: an upload to it (the composer's, a\n * form's file field), every file known by id (said in its messages, uploaded here, or read back\n * once when one is asked for that neither has), where one plays from, and the host's way to\n * open one.\n */\nexport function useConversationFiles(\n client: Client,\n conversationId: string,\n messages: readonly Message[],\n open: ((file: Attachment) => void) | undefined,\n): FileHost {\n const [kept, setKept] = useState<ReadonlyMap<string, Attachment>>(() => new Map());\n const listed = useRef(false);\n\n const known = useMemo(() => {\n const all = new Map(kept);\n for (const message of messages) for (const file of message.files ?? []) all.set(file.id, file);\n return all;\n }, [messages, kept]);\n\n const keep = (files: readonly Attachment[]) => {\n setKept((now) => {\n const next = new Map(now);\n for (const file of files) next.set(file.id, file);\n return next;\n });\n };\n\n return {\n known,\n open,\n play: (file) => client.conversations.play(conversationId, file.id),\n upload: async (file, progress, signal) => {\n const stored = await client.conversations.upload(conversationId, file, {\n onProgress: progress,\n signal,\n });\n keep([stored]);\n return stored;\n },\n find: (ids) => {\n if (listed.current || ids.every((id) => known.has(id))) return;\n listed.current = true;\n client.conversations.files(conversationId).then(keep, () => undefined);\n },\n };\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,qBACd,QACA,gBACA,UACA,MACU;CACV,MAAM,CAAC,MAAM,WAAW,+BAAgD,IAAI,IAAI,CAAC;CACjF,MAAM,SAAS,OAAO,KAAK;CAE3B,MAAM,QAAQ,cAAc;EAC1B,MAAM,MAAM,IAAI,IAAI,IAAI;EACxB,KAAK,MAAM,WAAW,UAAU,KAAK,MAAM,QAAQ,QAAQ,SAAS,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,IAAI;EAC7F,OAAO;CACT,GAAG,CAAC,UAAU,IAAI,CAAC;CAEnB,MAAM,QAAQ,UAAiC;EAC7C,SAAS,QAAQ;GACf,MAAM,OAAO,IAAI,IAAI,GAAG;GACxB,KAAK,MAAM,QAAQ,OAAO,KAAK,IAAI,KAAK,IAAI,IAAI;GAChD,OAAO;EACT,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA,OAAO,SAAS,OAAO,cAAc,KAAK,gBAAgB,KAAK,EAAE;EACjE,QAAQ,OAAO,MAAM,UAAU,WAAW;GACxC,MAAM,SAAS,MAAM,OAAO,cAAc,OAAO,gBAAgB,MAAM;IACrE,YAAY;IACZ;GACF,CAAC;GACD,KAAK,CAAC,MAAM,CAAC;GACb,OAAO;EACT;EACA,OAAO,QAAQ;GACb,IAAI,OAAO,WAAW,IAAI,OAAO,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG;GACxD,OAAO,UAAU;GACjB,OAAO,cAAc,MAAM,cAAc,CAAC,CAAC,KAAK,YAAY,KAAA,CAAS;EACvE;CACF;AACF"}
@@ -0,0 +1,45 @@
1
+ //#region src/credentials.d.ts
2
+ /**
3
+ * Who a client calls as, one way at a time (v3/README.md, Credentials): the owner's session cookie
4
+ * in our own app; a person's token, given as it is or asked of the host's backend (and asked again
5
+ * once it expires); or an anonymous visitor of a site, by the site's publishable key and the id
6
+ * the page keeps for them.
7
+ */
8
+ type Way = "credentials" | "token" | "getToken" | "publishableKey" | "visitorId";
9
+ /** One way of signing in, with none of the others beside it. */
10
+ type Alone<T> = T & { [K in Exclude<Way, keyof T>]?: never; };
11
+ export type Credentials =
12
+ /** Our app, on the API's own origin (`/api`): the session cookie the browser holds. */
13
+ Alone<{
14
+ credentials: "cookie";
15
+ }> |
16
+ /** A person's token the host's backend minted (`POST /v1/tokens`), used as it is. */
17
+ Alone<{
18
+ token: string;
19
+ }> |
20
+ /**
21
+ * A person's token asked of the host's backend: when first needed, and once more each time the
22
+ * API refuses the one kept (it lasts an hour).
23
+ */
24
+ Alone<{
25
+ getToken: () => Promise<string>;
26
+ }> |
27
+ /**
28
+ * An anonymous visitor (the widget): the site's publishable key, and who they are, an id the
29
+ * page keeps; one is made and kept in `localStorage` when none is given.
30
+ */
31
+ Alone<{
32
+ publishableKey: string;
33
+ visitorId?: string | undefined;
34
+ }>;
35
+ /**
36
+ * Who a page speaks for: the business (the owner, in our own app) or a person it serves (a token's
37
+ * person, a publishable key's visitor). The API lets each answer different things: a yes the
38
+ * business decides is the business's alone.
39
+ */
40
+ export type Speaker = "business" | "person";
41
+ /** Where the page keeps its visitor's id, for every SignalCore widget on the site. */
42
+ export declare const VISITOR_KEY = "signalcore.visitor";
43
+ //#endregion
44
+ export {};
45
+ //# sourceMappingURL=credentials.d.ts.map