@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,339 @@
1
+ import { classes } from "./classes.js";
2
+ import { KitProvider } from "./kit/context.js";
3
+ import { Button } from "./kit/Button.js";
4
+ import { agentGlyph } from "./agentIcons.js";
5
+ import { ApiError } from "./client.js";
6
+ import { agentTint } from "./tint.js";
7
+ import { AgentTasks, TASK_MESSAGES, useTasks } from "./AgentTasks.js";
8
+ import { useConversation } from "./useConversation.js";
9
+ import { AgentChat } from "./AgentChat.js";
10
+ import { Modes } from "./Modes.js";
11
+ import { useAgentFace } from "./useAgentFace.js";
12
+ import { Suspense, lazy, useEffect, useRef, useState } from "react";
13
+ import { PhoneIcon, XIcon } from "@phosphor-icons/react";
14
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
+ //#region src/AgentSpace.tsx
16
+ const VoiceCall = lazy(() => import("./VoiceCall.js").then((module) => ({ default: module.VoiceCall })));
17
+ const SPACE_MESSAGES = {
18
+ modes: {
19
+ label: "Mode",
20
+ text: "Text",
21
+ voice: "Voice"
22
+ },
23
+ again: "Call again",
24
+ close: "Close",
25
+ agent: "Agent",
26
+ opening: "Opening the conversation…",
27
+ failed: "The conversation couldn't be opened.",
28
+ retry: "Try again",
29
+ chat: {},
30
+ voice: {},
31
+ tasks: TASK_MESSAGES
32
+ };
33
+ /** How big a call's orb is drawn in each layout: a small panel keeps room for what is said. */
34
+ const ORB_SIZES = {
35
+ compact: 200,
36
+ full: 280
37
+ };
38
+ /**
39
+ * An agent in a host's page, for the people it serves: the conversation, and when the agent has a
40
+ * voice, two modes beside the composer's paperclip, text and voice. Voice turns the space into
41
+ * the call (`VoiceCall`, with the orb and what is being said), in the same place and size, with
42
+ * the modes at its foot to go back; a call is a conversation of its own (the API makes one with
43
+ * each), and once the agent took it the space goes on in it, where what was said shows, told
44
+ * through `onConversation`. Ending the call, or choosing text, comes back to writing; a call that
45
+ * couldn't begin stays to say why, and offers to try again. While the agent runs tasks for the
46
+ * person (what they asked it to do later), a line over the chat opens them, with their runs, to
47
+ * pause or take away. The conversation is the one given, or
48
+ * one the space starts. The agent's face over it all is the host's to turn on (`header`). Styled
49
+ * as `AgentChat` is: the tokens, `messages`, `classNames` and `components`. One agent per mount:
50
+ * key it on the agent's id.
51
+ */
52
+ function AgentSpace({ client, agentId, conversationId, onConversation, layout = "compact", header = false, steps, messages, classNames, components, locale, suggestions, onTool, onError, orb, onClose, tasks: showsTasks = true }) {
53
+ const words = {
54
+ ...SPACE_MESSAGES,
55
+ ...messages
56
+ };
57
+ const theirs = useTasks(client, agentId, showsTasks && client.who === "person");
58
+ const [listing, setListing] = useState(false);
59
+ const { face, loading } = useAgentFace(client, agentId);
60
+ const opened = useOpened(client, agentId, conversationId, onConversation);
61
+ const [mode, setMode] = useState("text");
62
+ const [attempt, setAttempt] = useState(0);
63
+ const [called, setCalled] = useState(null);
64
+ const answered = useRef(false);
65
+ const [refocus, setRefocus] = useState(false);
66
+ const root = useRef(null);
67
+ const tint = agentTint(agentId);
68
+ const Glyph = agentGlyph(face?.icon);
69
+ const name = face?.name ?? (loading ? "" : words.agent);
70
+ const id = opened.id;
71
+ const voice = face?.voice.enabled === true;
72
+ const parts = [`sc-space--${layout}`];
73
+ if (mode === "voice") parts.push("sc-space--voice");
74
+ /** Back to writing: in the call's conversation once the agent took the call. */
75
+ const write = () => {
76
+ if (answered.current && called !== null) opened.go(called);
77
+ setMode("text");
78
+ };
79
+ const choose = (next) => {
80
+ setRefocus(root.current?.matches(":focus-within") ?? false);
81
+ if (next === "text") {
82
+ write();
83
+ return;
84
+ }
85
+ answered.current = false;
86
+ setCalled(null);
87
+ setAttempt((count) => count + 1);
88
+ setMode("voice");
89
+ };
90
+ const modes = (current) => /* @__PURE__ */ jsx(Modes, {
91
+ mode: current,
92
+ onChange: choose,
93
+ words: words.modes,
94
+ classNames,
95
+ focus: refocus
96
+ });
97
+ const body = () => {
98
+ if (opened.failed) return /* @__PURE__ */ jsxs("div", {
99
+ className: classes(classNames, "sc-space__status"),
100
+ children: [/* @__PURE__ */ jsx("p", { children: words.failed }), /* @__PURE__ */ jsx(Button, {
101
+ size: "sm",
102
+ onClick: opened.retry,
103
+ children: words.retry
104
+ })]
105
+ });
106
+ if (id === null || loading) return /* @__PURE__ */ jsx("p", {
107
+ role: "status",
108
+ className: classes(classNames, "sc-space__status"),
109
+ children: words.opening
110
+ });
111
+ if (listing && theirs.tasks !== null) return /* @__PURE__ */ jsx(AgentTasks, {
112
+ client,
113
+ agentId,
114
+ tasks: theirs.tasks,
115
+ onChange: theirs.refresh,
116
+ onBack: () => {
117
+ setListing(false);
118
+ },
119
+ words: words.tasks,
120
+ classNames
121
+ });
122
+ if (mode === "voice" && voice) return /* @__PURE__ */ jsxs("div", {
123
+ part: "voice",
124
+ className: classes(classNames, "sc-space__voice"),
125
+ children: [/* @__PURE__ */ jsx(Suspense, {
126
+ fallback: null,
127
+ children: /* @__PURE__ */ jsx(VoiceCall, {
128
+ connect: async () => {
129
+ const join = await client.conversations.call(agentId);
130
+ setCalled(join.conversation_id);
131
+ return join;
132
+ },
133
+ onAnswer: () => {
134
+ answered.current = true;
135
+ },
136
+ onEnd: (_, problem) => {
137
+ if (problem !== null) return;
138
+ setRefocus(root.current?.matches(":focus-within") ?? false);
139
+ write();
140
+ },
141
+ name,
142
+ tint,
143
+ orb,
144
+ orbSize: ORB_SIZES[layout],
145
+ messages: words.voice,
146
+ classNames,
147
+ captions: called !== null && /* @__PURE__ */ jsx(Captions, {
148
+ client,
149
+ conversationId: called,
150
+ onTool,
151
+ classNames
152
+ }),
153
+ after: /* @__PURE__ */ jsx(Button, {
154
+ tone: "primary",
155
+ icon: PhoneIcon,
156
+ onClick: () => {
157
+ choose("voice");
158
+ },
159
+ children: words.again
160
+ })
161
+ }, attempt)
162
+ }), /* @__PURE__ */ jsx("div", {
163
+ className: classes(classNames, "sc-space__foot"),
164
+ children: modes("voice")
165
+ })]
166
+ });
167
+ const count = theirs.tasks?.length ?? 0;
168
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [count > 0 && /* @__PURE__ */ jsx("button", {
169
+ type: "button",
170
+ part: "tasks-open",
171
+ className: classes(classNames, "sc-space__tasks"),
172
+ onClick: () => {
173
+ setListing(true);
174
+ theirs.refresh();
175
+ },
176
+ children: words.tasks.open(count)
177
+ }), /* @__PURE__ */ jsx(AgentChat, {
178
+ client,
179
+ conversationId: id,
180
+ name,
181
+ messages: words.chat,
182
+ classNames,
183
+ components,
184
+ locale,
185
+ suggestions,
186
+ steps,
187
+ actions: voice ? modes("text") : void 0,
188
+ onTool,
189
+ onError
190
+ })] });
191
+ };
192
+ const close = onClose && /* @__PURE__ */ jsx(Button, {
193
+ tone: "ghost",
194
+ size: "sm",
195
+ icon: XIcon,
196
+ "aria-label": words.close,
197
+ title: words.close,
198
+ onClick: onClose,
199
+ part: "close",
200
+ className: classes(classNames, "sc-space__close")
201
+ });
202
+ return /* @__PURE__ */ jsx(KitProvider, {
203
+ classNames,
204
+ messages: words.chat.kit,
205
+ locale,
206
+ children: /* @__PURE__ */ jsxs("section", {
207
+ ref: root,
208
+ "aria-label": name || void 0,
209
+ part: "space",
210
+ className: `sc ${classes(classNames, "sc-space", ...parts)}`,
211
+ children: [header ? /* @__PURE__ */ jsxs("header", {
212
+ part: "header",
213
+ className: classes(classNames, "sc-space__face"),
214
+ children: [
215
+ /* @__PURE__ */ jsx("span", {
216
+ "aria-hidden": true,
217
+ className: classes(classNames, "sc-space__mark", `sc-space__mark--${tint}`),
218
+ children: /* @__PURE__ */ jsx(Glyph, { weight: "duotone" })
219
+ }),
220
+ /* @__PURE__ */ jsxs("div", {
221
+ className: classes(classNames, "sc-space__who"),
222
+ children: [/* @__PURE__ */ jsx("h2", {
223
+ className: classes(classNames, "sc-space__name"),
224
+ children: name
225
+ }), face?.role && /* @__PURE__ */ jsx("p", {
226
+ className: classes(classNames, "sc-space__role"),
227
+ children: face.role
228
+ })]
229
+ }),
230
+ close
231
+ ]
232
+ }) : close, /* @__PURE__ */ jsx("div", {
233
+ className: classes(classNames, "sc-space__body"),
234
+ children: body()
235
+ })]
236
+ })
237
+ });
238
+ }
239
+ /**
240
+ * What is being said on the call, under the orb: the person's last words, and the agent's answer
241
+ * as it comes, read live from the call's own conversation (where the platform keeps them). The
242
+ * host's tools the agent calls meanwhile run here too, as in the chat.
243
+ */
244
+ function Captions({ client, conversationId, onTool, classNames }) {
245
+ const { person, agent } = captionsOf(useConversation(client, conversationId, { onTool }));
246
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [person !== "" && /* @__PURE__ */ jsx("p", {
247
+ className: classes(classNames, "sc-space__caption", "sc-space__caption--person"),
248
+ children: person
249
+ }), agent !== "" && /* @__PURE__ */ jsx("p", {
250
+ className: classes(classNames, "sc-space__caption", "sc-space__caption--agent"),
251
+ children: agent
252
+ })] });
253
+ }
254
+ /**
255
+ * The last exchange of a call, as its captions say it: what the person last said, and the agent's
256
+ * words after it (as they stream, else the last it said; its greeting before anything was said).
257
+ */
258
+ function captionsOf({ messages, pending, draft }) {
259
+ const lastSaid = messages.findLastIndex((message) => message.role === "user");
260
+ const replied = messages.slice(lastSaid + 1).findLast((message) => message.role === "assistant" && message.author !== "operator" && message.text !== "");
261
+ return {
262
+ person: messages[lastSaid]?.text ?? "",
263
+ agent: pending && draft !== "" ? draft : replied?.text ?? ""
264
+ };
265
+ }
266
+ /** Whether a conversation asked for is gone for this person: not there, or not theirs. */
267
+ const isGone = (error) => error instanceof ApiError && (error.status === 404 || error.status === 403);
268
+ /**
269
+ * The conversation the space shows: the one given while it is still the person's, else a new one
270
+ * with the agent, told to `onConversation`. Asked once per attempt (a second effect of the same
271
+ * attempt, as React's strict mode runs, waits on the first rather than starting another); after
272
+ * that, the conversation it opened is the one it goes on with, until it goes on in another (`go`:
273
+ * a call's), told the same way.
274
+ */
275
+ function useOpened(client, agentId, given, onConversation) {
276
+ const kept = useRef(given);
277
+ const asking = useRef(null);
278
+ const [id, setId] = useState(null);
279
+ const [failed, setFailed] = useState(false);
280
+ const [attempt, setAttempt] = useState(0);
281
+ const told = useRef(onConversation);
282
+ useEffect(() => {
283
+ told.current = onConversation;
284
+ });
285
+ const started = (conversation) => {
286
+ told.current?.(conversation);
287
+ };
288
+ useEffect(() => {
289
+ let current = true;
290
+ const start = () => client.conversations.start(agentId).then((conversation) => {
291
+ started(conversation.id);
292
+ return conversation.id;
293
+ });
294
+ const open = () => {
295
+ const known = kept.current;
296
+ if (known === void 0) return start();
297
+ return client.conversations.get(known).then((conversation) => conversation.id, (error) => isGone(error) ? start() : Promise.reject(error));
298
+ };
299
+ const asked = asking.current;
300
+ const ask = asked?.client === client && asked.attempt === attempt ? asked : {
301
+ client,
302
+ attempt,
303
+ id: open()
304
+ };
305
+ asking.current = ask;
306
+ ask.id.then((opened) => {
307
+ if (!current) return;
308
+ kept.current = opened;
309
+ setId(opened);
310
+ }, () => {
311
+ if (current) setFailed(true);
312
+ });
313
+ return () => {
314
+ current = false;
315
+ };
316
+ }, [
317
+ client,
318
+ agentId,
319
+ attempt
320
+ ]);
321
+ return {
322
+ id,
323
+ failed,
324
+ retry: () => {
325
+ setFailed(false);
326
+ setAttempt((count) => count + 1);
327
+ },
328
+ go: (conversation) => {
329
+ if (conversation === kept.current) return;
330
+ kept.current = conversation;
331
+ setId(conversation);
332
+ started(conversation);
333
+ }
334
+ };
335
+ }
336
+ //#endregion
337
+ export { AgentSpace, SPACE_MESSAGES, captionsOf };
338
+
339
+ //# sourceMappingURL=AgentSpace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentSpace.js","names":[],"sources":["../src/AgentSpace.tsx"],"sourcesContent":["import { PhoneIcon, XIcon } from \"@phosphor-icons/react\";\nimport { lazy, Suspense, useEffect, useRef, useState } from \"react\";\n\nimport { AgentChat, type ChatMessages, type ChatPart, type ChatSteps } from \"./AgentChat\";\nimport { agentGlyph } from \"./agentIcons\";\nimport {\n AgentTasks,\n TASK_MESSAGES,\n useTasks,\n type TaskMessages,\n type TaskPart,\n} from \"./AgentTasks\";\nimport type { BrowserPart } from \"./BrowserView\";\nimport { classes } from \"./classes\";\nimport { ApiError, type Client } from \"./client\";\nimport { Button } from \"./kit/Button\";\nimport { KitProvider, type KitPart } from \"./kit/context\";\nimport type { KitLocale } from \"./kit/messages\";\nimport { Modes, type ModeMessages, type ModePart, type SpaceMode } from \"./Modes\";\nimport type { SurfaceComponents, SurfacePart } from \"./surface/scope\";\nimport { agentTint, type AgentTint } from \"./tint\";\nimport { useAgentFace } from \"./useAgentFace\";\nimport { useConversation, type LiveConversation, type ToolHandler } from \"./useConversation\";\nimport type { VoiceCallMessages, VoiceCallPart } from \"./VoiceCall\";\nimport type { OrbStyle } from \"./voice/orbs\";\n\n// The call, and LiveKit under it, load the first time someone calls.\nconst VoiceCall = lazy(() =>\n import(\"./VoiceCall\").then((module) => ({ default: module.VoiceCall })),\n);\n\n/** The words the space says around the chat and the call; a host gives its own, in its language. */\nexport interface SpaceMessages {\n /** The two modes beside the composer's paperclip: the group's name, and each mode's. */\n modes: ModeMessages;\n /** After a call that couldn't begin: try it again. */\n again: string;\n /** The button that closes the space, where the host gives `onClose`. */\n close: string;\n /** The agent's name when its face can't be read. */\n agent: string;\n /** While the conversation is found, or started. */\n opening: string;\n /** The conversation could not be opened; and the button that tries again. */\n failed: string;\n retry: string;\n /** What the chat says (`AgentChat`'s words). */\n chat: Partial<ChatMessages>;\n /** What a call says (`VoiceCall`'s words). */\n voice: Partial<VoiceCallMessages>;\n /** What the person's tasks say (`AgentTasks`'s words). */\n tasks: TaskMessages;\n}\n\nexport const SPACE_MESSAGES: SpaceMessages = {\n modes: { label: \"Mode\", text: \"Text\", voice: \"Voice\" },\n again: \"Call again\",\n close: \"Close\",\n agent: \"Agent\",\n opening: \"Opening the conversation…\",\n failed: \"The conversation couldn't be opened.\",\n retry: \"Try again\",\n chat: {},\n voice: {},\n tasks: TASK_MESSAGES,\n};\n\n/** The space's parts, by the class each carries; `classNames` adds a host's own under the same keys. */\nexport type SpacePart =\n | \"sc-space\"\n | \"sc-space--compact\"\n | \"sc-space--full\"\n | \"sc-space--voice\"\n | \"sc-space__face\"\n | \"sc-space__mark\"\n | `sc-space__mark--${AgentTint}`\n | \"sc-space__who\"\n | \"sc-space__name\"\n | \"sc-space__role\"\n | \"sc-space__close\"\n | \"sc-space__body\"\n | \"sc-space__voice\"\n | \"sc-space__foot\"\n | \"sc-space__caption\"\n | \"sc-space__caption--person\"\n | \"sc-space__caption--agent\"\n | \"sc-space__status\"\n | \"sc-space__tasks\"\n | ModePart;\n\n/**\n * How the space sits: `compact` in a small panel (a widget's, a side of the host's page); `full`\n * as a page's main column, the conversation at a reading measure.\n */\nexport type SpaceLayout = \"compact\" | \"full\";\n\n/** How big a call's orb is drawn in each layout: a small panel keeps room for what is said. */\nconst ORB_SIZES: Readonly<Record<SpaceLayout, number>> = { compact: 200, full: 280 };\n\nexport interface AgentSpaceProps {\n client: Client;\n /** The agent the person talks to (its face is read with `client`). One per mount: key on it. */\n agentId: string;\n /**\n * The person's conversation to go on with, read when the space opens. Without one, or once it\n * is gone (not theirs, not there), a new one starts, told through `onConversation`.\n */\n conversationId?: string | undefined;\n /** Hears the conversation the space started, for the host to keep and give back next time. */\n onConversation?: ((id: string) => void) | undefined;\n layout?: SpaceLayout | undefined;\n /**\n * Draws the agent's face at the top: its mark in its tint, its name and role (and the close).\n * Off by default: the host's page says who it is, or draws its own with `useAgentFace`.\n */\n header?: boolean | undefined;\n /**\n * Whether the chat shows the agent's steps (`AgentChat`'s `steps`): by default hidden for a\n * person or a visitor, shown for the business.\n */\n steps?: ChatSteps | undefined;\n messages?: Partial<SpaceMessages> | undefined;\n classNames?:\n | Partial<\n Record<\n SpacePart | ChatPart | SurfacePart | KitPart | BrowserPart | VoiceCallPart | TaskPart,\n string\n >\n >\n | undefined;\n /** The host's own drawing of a block type, for every surface the agent shows. */\n components?: SurfaceComponents | undefined;\n /** The language of the surfaces' calendars, days, times and numbers; English by default. */\n locale?: KitLocale | undefined;\n /** A few things the person might say first, offered while nothing has been said. */\n suggestions?: readonly string[] | undefined;\n /** Runs the host's own tools the agent calls in the page (`AgentChat`'s `onTool`). */\n onTool?: ToolHandler | undefined;\n /** An error's code, from the chat's socket or `load`; the host words it. */\n onError?: ((code: string) => void) | undefined;\n /** How a call's orb is drawn: `\"wave\"` (the default) or `\"fluid-dots\"`. */\n orb?: OrbStyle | undefined;\n /** Draws a close button (in the face, or at the top's end without it), for a space in a panel. */\n onClose?: (() => void) | undefined;\n /**\n * Whether a person sees the tasks the agent runs for them (`AgentTasks`): a line over the chat\n * while there are any, which opens them. On by default; the business's own space never has it.\n */\n tasks?: boolean | undefined;\n}\n\n/**\n * An agent in a host's page, for the people it serves: the conversation, and when the agent has a\n * voice, two modes beside the composer's paperclip, text and voice. Voice turns the space into\n * the call (`VoiceCall`, with the orb and what is being said), in the same place and size, with\n * the modes at its foot to go back; a call is a conversation of its own (the API makes one with\n * each), and once the agent took it the space goes on in it, where what was said shows, told\n * through `onConversation`. Ending the call, or choosing text, comes back to writing; a call that\n * couldn't begin stays to say why, and offers to try again. While the agent runs tasks for the\n * person (what they asked it to do later), a line over the chat opens them, with their runs, to\n * pause or take away. The conversation is the one given, or\n * one the space starts. The agent's face over it all is the host's to turn on (`header`). Styled\n * as `AgentChat` is: the tokens, `messages`, `classNames` and `components`. One agent per mount:\n * key it on the agent's id.\n */\nexport function AgentSpace({\n client,\n agentId,\n conversationId,\n onConversation,\n layout = \"compact\",\n header = false,\n steps,\n messages,\n classNames,\n components,\n locale,\n suggestions,\n onTool,\n onError,\n orb,\n onClose,\n tasks: showsTasks = true,\n}: AgentSpaceProps) {\n const words = { ...SPACE_MESSAGES, ...messages };\n const theirs = useTasks(client, agentId, showsTasks && client.who === \"person\");\n const [listing, setListing] = useState(false);\n const { face, loading } = useAgentFace(client, agentId);\n const opened = useOpened(client, agentId, conversationId, onConversation);\n const [mode, setMode] = useState<SpaceMode>(\"text\");\n // Each call made is a new attempt, which keys a new `VoiceCall`.\n const [attempt, setAttempt] = useState(0);\n // The conversation the call being made is (each call is one of its own, made with it), and\n // whether the agent took it: once it did, the space goes on in it.\n const [called, setCalled] = useState<string | null>(null);\n const answered = useRef(false);\n // Whether the modes drawn after a switch take the keyboard: when it was in the space (asked of\n // the space itself, which a shadow root's focus answers too).\n const [refocus, setRefocus] = useState(false);\n const root = useRef<HTMLElement>(null);\n const tint = agentTint(agentId);\n const Glyph = agentGlyph(face?.icon);\n const name = face?.name ?? (loading ? \"\" : words.agent);\n const id = opened.id;\n const voice = face?.voice.enabled === true;\n const parts: SpacePart[] = [`sc-space--${layout}`];\n if (mode === \"voice\") parts.push(\"sc-space--voice\");\n\n /** Back to writing: in the call's conversation once the agent took the call. */\n const write = () => {\n if (answered.current && called !== null) opened.go(called);\n setMode(\"text\");\n };\n const choose = (next: SpaceMode) => {\n setRefocus(root.current?.matches(\":focus-within\") ?? false);\n if (next === \"text\") {\n write();\n return;\n }\n answered.current = false;\n setCalled(null);\n setAttempt((count) => count + 1);\n setMode(\"voice\");\n };\n const modes = (current: SpaceMode) => (\n <Modes\n mode={current}\n onChange={choose}\n words={words.modes}\n classNames={classNames}\n focus={refocus}\n />\n );\n\n const body = () => {\n if (opened.failed) {\n return (\n <div className={classes(classNames, \"sc-space__status\")}>\n <p>{words.failed}</p>\n <Button size=\"sm\" onClick={opened.retry}>\n {words.retry}\n </Button>\n </div>\n );\n }\n if (id === null || loading) {\n return (\n <p role=\"status\" className={classes(classNames, \"sc-space__status\")}>\n {words.opening}\n </p>\n );\n }\n if (listing && theirs.tasks !== null) {\n return (\n <AgentTasks\n client={client}\n agentId={agentId}\n tasks={theirs.tasks}\n onChange={theirs.refresh}\n onBack={() => {\n setListing(false);\n }}\n words={words.tasks}\n classNames={classNames}\n />\n );\n }\n if (mode === \"voice\" && voice) {\n return (\n <div part=\"voice\" className={classes(classNames, \"sc-space__voice\")}>\n <Suspense fallback={null}>\n <VoiceCall\n key={attempt}\n connect={async () => {\n const join = await client.conversations.call(agentId);\n setCalled(join.conversation_id);\n return join;\n }}\n onAnswer={() => {\n answered.current = true;\n }}\n // Over, the call gives the space back to writing; one that couldn't begin stays to\n // say why, with the way to try again and the modes to go back.\n onEnd={(_, problem) => {\n if (problem !== null) return;\n setRefocus(root.current?.matches(\":focus-within\") ?? false);\n write();\n }}\n name={name}\n tint={tint}\n orb={orb}\n orbSize={ORB_SIZES[layout]}\n messages={words.voice}\n classNames={classNames}\n captions={\n called !== null && (\n <Captions\n client={client}\n conversationId={called}\n onTool={onTool}\n classNames={classNames}\n />\n )\n }\n after={\n <Button\n tone=\"primary\"\n icon={PhoneIcon}\n onClick={() => {\n choose(\"voice\");\n }}\n >\n {words.again}\n </Button>\n }\n />\n </Suspense>\n <div className={classes(classNames, \"sc-space__foot\")}>{modes(\"voice\")}</div>\n </div>\n );\n }\n const count = theirs.tasks?.length ?? 0;\n return (\n <>\n {count > 0 && (\n <button\n type=\"button\"\n part=\"tasks-open\"\n className={classes(classNames, \"sc-space__tasks\")}\n onClick={() => {\n setListing(true);\n void theirs.refresh();\n }}\n >\n {words.tasks.open(count)}\n </button>\n )}\n <AgentChat\n client={client}\n conversationId={id}\n name={name}\n messages={words.chat}\n classNames={classNames}\n components={components}\n locale={locale}\n suggestions={suggestions}\n steps={steps}\n actions={voice ? modes(\"text\") : undefined}\n onTool={onTool}\n onError={onError}\n />\n </>\n );\n };\n\n const close = onClose && (\n <Button\n tone=\"ghost\"\n size=\"sm\"\n icon={XIcon}\n aria-label={words.close}\n title={words.close}\n onClick={onClose}\n part=\"close\"\n className={classes(classNames, \"sc-space__close\")}\n />\n );\n\n return (\n <KitProvider classNames={classNames} messages={words.chat.kit} locale={locale}>\n <section\n ref={root}\n aria-label={name || undefined}\n part=\"space\"\n className={`sc ${classes(classNames, \"sc-space\", ...parts)}`}\n >\n {header ? (\n <header part=\"header\" className={classes(classNames, \"sc-space__face\")}>\n <span\n aria-hidden\n className={classes(classNames, \"sc-space__mark\", `sc-space__mark--${tint}`)}\n >\n <Glyph weight=\"duotone\" />\n </span>\n <div className={classes(classNames, \"sc-space__who\")}>\n <h2 className={classes(classNames, \"sc-space__name\")}>{name}</h2>\n {face?.role && <p className={classes(classNames, \"sc-space__role\")}>{face.role}</p>}\n </div>\n {close}\n </header>\n ) : (\n close\n )}\n <div className={classes(classNames, \"sc-space__body\")}>{body()}</div>\n </section>\n </KitProvider>\n );\n}\n\n/**\n * What is being said on the call, under the orb: the person's last words, and the agent's answer\n * as it comes, read live from the call's own conversation (where the platform keeps them). The\n * host's tools the agent calls meanwhile run here too, as in the chat.\n */\nfunction Captions({\n client,\n conversationId,\n onTool,\n classNames,\n}: {\n client: Client;\n conversationId: string;\n onTool: ToolHandler | undefined;\n classNames: Partial<Record<SpacePart, string>> | undefined;\n}) {\n const live = useConversation(client, conversationId, { onTool });\n const { person, agent } = captionsOf(live);\n return (\n <>\n {person !== \"\" && (\n <p className={classes(classNames, \"sc-space__caption\", \"sc-space__caption--person\")}>\n {person}\n </p>\n )}\n {agent !== \"\" && (\n <p className={classes(classNames, \"sc-space__caption\", \"sc-space__caption--agent\")}>\n {agent}\n </p>\n )}\n </>\n );\n}\n\n/**\n * The last exchange of a call, as its captions say it: what the person last said, and the agent's\n * words after it (as they stream, else the last it said; its greeting before anything was said).\n */\nexport function captionsOf({\n messages,\n pending,\n draft,\n}: Pick<LiveConversation, \"messages\" | \"pending\" | \"draft\">): {\n person: string;\n agent: string;\n} {\n const lastSaid = messages.findLastIndex((message) => message.role === \"user\");\n const replied = messages\n .slice(lastSaid + 1)\n .findLast(\n (message) =>\n message.role === \"assistant\" && message.author !== \"operator\" && message.text !== \"\",\n );\n return {\n person: messages[lastSaid]?.text ?? \"\",\n agent: pending && draft !== \"\" ? draft : (replied?.text ?? \"\"),\n };\n}\n\n/** Whether a conversation asked for is gone for this person: not there, or not theirs. */\nconst isGone = (error: unknown): boolean =>\n error instanceof ApiError && (error.status === 404 || error.status === 403);\n\n/**\n * The conversation the space shows: the one given while it is still the person's, else a new one\n * with the agent, told to `onConversation`. Asked once per attempt (a second effect of the same\n * attempt, as React's strict mode runs, waits on the first rather than starting another); after\n * that, the conversation it opened is the one it goes on with, until it goes on in another (`go`:\n * a call's), told the same way.\n */\nfunction useOpened(\n client: Client,\n agentId: string,\n given: string | undefined,\n onConversation: ((id: string) => void) | undefined,\n): { id: string | null; failed: boolean; retry: () => void; go: (id: string) => void } {\n const kept = useRef(given);\n const asking = useRef<{ client: Client; attempt: number; id: Promise<string> } | null>(null);\n const [id, setId] = useState<string | null>(null);\n const [failed, setFailed] = useState(false);\n const [attempt, setAttempt] = useState(0);\n // The host's ear as it last gave it, told from the effect's answer and from a call's end alike.\n const told = useRef(onConversation);\n useEffect(() => {\n told.current = onConversation;\n });\n const started = (conversation: string) => {\n told.current?.(conversation);\n };\n\n useEffect(() => {\n let current = true;\n const start = () =>\n client.conversations.start(agentId).then((conversation) => {\n started(conversation.id);\n return conversation.id;\n });\n const open = (): Promise<string> => {\n const known = kept.current;\n if (known === undefined) return start();\n return client.conversations.get(known).then(\n (conversation) => conversation.id,\n (error: unknown) => (isGone(error) ? start() : Promise.reject(error)),\n );\n };\n const asked = asking.current;\n const ask =\n asked?.client === client && asked.attempt === attempt\n ? asked\n : { client, attempt, id: open() };\n asking.current = ask;\n ask.id.then(\n (opened) => {\n if (!current) return;\n kept.current = opened;\n setId(opened);\n },\n () => {\n if (current) setFailed(true);\n },\n );\n return () => {\n current = false;\n };\n }, [client, agentId, attempt]);\n\n return {\n id,\n failed,\n retry: () => {\n setFailed(false);\n setAttempt((count) => count + 1);\n },\n go: (conversation) => {\n if (conversation === kept.current) return;\n kept.current = conversation;\n setId(conversation);\n started(conversation);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,YAAY,WAChB,OAAO,iBAAc,CAAC,MAAM,YAAY,EAAE,SAAS,OAAO,UAAU,EAAE,CACxE;AAyBA,MAAa,iBAAgC;CAC3C,OAAO;EAAE,OAAO;EAAQ,MAAM;EAAQ,OAAO;CAAQ;CACrD,OAAO;CACP,OAAO;CACP,OAAO;CACP,SAAS;CACT,QAAQ;CACR,OAAO;CACP,MAAM,CAAC;CACP,OAAO,CAAC;CACR,OAAO;AACT;;AAgCA,MAAM,YAAmD;CAAE,SAAS;CAAK,MAAM;AAAI;;;;;;;;;;;;;;;AAoEnF,SAAgB,WAAW,EACzB,QACA,SACA,gBACA,gBACA,SAAS,WACT,SAAS,OACT,OACA,UACA,YACA,YACA,QACA,aACA,QACA,SACA,KACA,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AAc,SAAS,CAAC;CAExC,MAAM,OAAO,OAAO,cAAc;CAClC,gBAAgB;EACd,KAAK,UAAU;CACjB,CAAC;CACD,MAAM,WAAW,iBAAyB;EACxC,KAAK,UAAU,YAAY;CAC7B;CAEA,gBAAgB;EACd,IAAI,UAAU;EACd,MAAM,cACJ,OAAO,cAAc,MAAM,OAAO,CAAC,CAAC,MAAM,iBAAiB;GACzD,QAAQ,aAAa,EAAE;GACvB,OAAO,aAAa;EACtB,CAAC;EACH,MAAM,aAA8B;GAClC,MAAM,QAAQ,KAAK;GACnB,IAAI,UAAU,KAAA,GAAW,OAAO,MAAM;GACtC,OAAO,OAAO,cAAc,IAAI,KAAK,CAAC,CAAC,MACpC,iBAAiB,aAAa,KAC9B,UAAoB,OAAO,KAAK,IAAI,MAAM,IAAI,QAAQ,OAAO,KAAK,CACrE;EACF;EACA,MAAM,QAAQ,OAAO;EACrB,MAAM,MACJ,OAAO,WAAW,UAAU,MAAM,YAAY,UAC1C,QACA;GAAE;GAAQ;GAAS,IAAI,KAAK;EAAE;EACpC,OAAO,UAAU;EACjB,IAAI,GAAG,MACJ,WAAW;GACV,IAAI,CAAC,SAAS;GACd,KAAK,UAAU;GACf,MAAM,MAAM;EACd,SACM;GACJ,IAAI,SAAS,UAAU,IAAI;EAC7B,CACF;EACA,aAAa;GACX,UAAU;EACZ;CACF,GAAG;EAAC;EAAQ;EAAS;CAAO,CAAC;CAE7B,OAAO;EACL;EACA;EACA,aAAa;GACX,UAAU,KAAK;GACf,YAAY,UAAU,QAAQ,CAAC;EACjC;EACA,KAAK,iBAAiB;GACpB,IAAI,iBAAiB,KAAK,SAAS;GACnC,KAAK,UAAU;GACf,MAAM,YAAY;GAClB,QAAQ,YAAY;EACtB;CACF;AACF"}
@@ -0,0 +1,48 @@
1
+ import { Task } from "./automation/types.js";
2
+ import { Client } from "./client.js";
3
+ //#region src/AgentTasks.d.ts
4
+ /** What the person's tasks say, in the space; a host gives its own, in its language. */
5
+ export interface TaskMessages {
6
+ /** Over the chat, when the agent runs any for them: how many, to open them. */
7
+ open: (count: number) => string;
8
+ /** Over the list. */
9
+ title: string;
10
+ back: string;
11
+ /** Taking one away. */
12
+ remove: string;
13
+ /** None left. */
14
+ empty: string;
15
+ /** A change that didn't go through. */
16
+ failed: string;
17
+ }
18
+ export declare const TASK_MESSAGES: TaskMessages;
19
+ export type TaskPart = "sc-tasks" | "sc-tasks__head" | "sc-tasks__title" | "sc-tasks__list" | "sc-tasks__empty" | "sc-tasks__problem";
20
+ /** How often the person's tasks are read again while the space is open. */
21
+ export declare const TASKS_POLL_MS = 20000;
22
+ /**
23
+ * The tasks the agent runs for the person the client speaks for, read when the space opens,
24
+ * again every `TASKS_POLL_MS` and on `refresh`. Null until read, and whenever it can't be (an API
25
+ * without tasks, the business's own client): the space then shows none.
26
+ */
27
+ export declare function useTasks(client: Client, agentId: string, enabled: boolean): {
28
+ tasks: Task[] | null;
29
+ refresh: () => Promise<void>;
30
+ };
31
+ export interface AgentTasksProps {
32
+ client: Client;
33
+ agentId: string;
34
+ tasks: readonly Task[];
35
+ /** Read them again, after a change. */
36
+ onChange: () => Promise<void>;
37
+ onBack: () => void;
38
+ words: TaskMessages;
39
+ classNames?: Partial<Record<TaskPart, string>> | undefined;
40
+ }
41
+ /**
42
+ * The person's tasks, as they asked the agent for them: each as an automation reads (when, its
43
+ * words, its last runs and how each went), with their switch to pause it and the way to take it
44
+ * away; the way back to the conversation over them.
45
+ */
46
+ export declare function AgentTasks({ client, agentId, tasks, onChange, onBack, words, classNames }: AgentTasksProps): import("react").JSX.Element;
47
+ //#endregion
48
+ //# sourceMappingURL=AgentTasks.d.ts.map
@@ -0,0 +1,120 @@
1
+ import { classes } from "./classes.js";
2
+ import { Automation } from "./automation/Automation.js";
3
+ import { Button } from "./kit/Button.js";
4
+ import { useCallback, useEffect, useRef, useState } from "react";
5
+ import { ArrowLeftIcon, TrashIcon } from "@phosphor-icons/react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/AgentTasks.tsx
8
+ const TASK_MESSAGES = {
9
+ open: (count) => count === 1 ? "1 task set up for you" : `${count} tasks set up for you`,
10
+ title: "Your tasks",
11
+ back: "Back to the conversation",
12
+ remove: "Remove",
13
+ empty: "Nothing set up. Ask the agent to remind you of something, or to check back later.",
14
+ failed: "That didn't go through. Try again."
15
+ };
16
+ /** How often the person's tasks are read again while the space is open. */
17
+ const TASKS_POLL_MS = 2e4;
18
+ /**
19
+ * The tasks the agent runs for the person the client speaks for, read when the space opens,
20
+ * again every `TASKS_POLL_MS` and on `refresh`. Null until read, and whenever it can't be (an API
21
+ * without tasks, the business's own client): the space then shows none.
22
+ */
23
+ function useTasks(client, agentId, enabled) {
24
+ const [tasks, setTasks] = useState(null);
25
+ const live = useRef(true);
26
+ const refresh = useCallback(async () => {
27
+ try {
28
+ const read = await client.tasks.list(agentId);
29
+ if (live.current) setTasks(read);
30
+ } catch {
31
+ if (live.current) setTasks(null);
32
+ }
33
+ }, [client, agentId]);
34
+ useEffect(() => {
35
+ live.current = true;
36
+ if (!enabled) return;
37
+ refresh();
38
+ const timer = setInterval(() => void refresh(), TASKS_POLL_MS);
39
+ return () => {
40
+ live.current = false;
41
+ clearInterval(timer);
42
+ };
43
+ }, [enabled, refresh]);
44
+ return {
45
+ tasks: enabled ? tasks : null,
46
+ refresh
47
+ };
48
+ }
49
+ /**
50
+ * The person's tasks, as they asked the agent for them: each as an automation reads (when, its
51
+ * words, its last runs and how each went), with their switch to pause it and the way to take it
52
+ * away; the way back to the conversation over them.
53
+ */
54
+ function AgentTasks({ client, agentId, tasks, onChange, onBack, words, classNames }) {
55
+ const [busy, setBusy] = useState(null);
56
+ const [failed, setFailed] = useState(false);
57
+ const change = async (task, doing) => {
58
+ setBusy(task.id);
59
+ setFailed(false);
60
+ try {
61
+ await doing();
62
+ await onChange();
63
+ } catch {
64
+ setFailed(true);
65
+ } finally {
66
+ setBusy(null);
67
+ }
68
+ };
69
+ return /* @__PURE__ */ jsxs("section", {
70
+ "aria-label": words.title,
71
+ part: "tasks",
72
+ className: classes(classNames, "sc-tasks"),
73
+ children: [
74
+ /* @__PURE__ */ jsxs("header", {
75
+ className: classes(classNames, "sc-tasks__head"),
76
+ children: [/* @__PURE__ */ jsx(Button, {
77
+ tone: "ghost",
78
+ size: "sm",
79
+ icon: ArrowLeftIcon,
80
+ "aria-label": words.back,
81
+ title: words.back,
82
+ onClick: onBack
83
+ }), /* @__PURE__ */ jsx("h3", {
84
+ className: classes(classNames, "sc-tasks__title"),
85
+ children: words.title
86
+ })]
87
+ }),
88
+ failed && /* @__PURE__ */ jsx("p", {
89
+ role: "alert",
90
+ className: classes(classNames, "sc-tasks__problem"),
91
+ children: words.failed
92
+ }),
93
+ tasks.length === 0 ? /* @__PURE__ */ jsx("p", {
94
+ className: classes(classNames, "sc-tasks__empty"),
95
+ children: words.empty
96
+ }) : /* @__PURE__ */ jsx("div", {
97
+ className: classes(classNames, "sc-tasks__list"),
98
+ children: tasks.map((task) => /* @__PURE__ */ jsx(Automation, {
99
+ automation: task,
100
+ runs: task.runs,
101
+ switching: busy === task.id,
102
+ onSwitch: (on) => void change(task, () => client.tasks.switch(agentId, task.id, on)),
103
+ actions: /* @__PURE__ */ jsx(Button, {
104
+ tone: "ghost",
105
+ size: "sm",
106
+ icon: TrashIcon,
107
+ "aria-label": words.remove,
108
+ title: words.remove,
109
+ disabled: busy === task.id,
110
+ onClick: () => void change(task, () => client.tasks.remove(agentId, task.id))
111
+ })
112
+ }, task.id))
113
+ })
114
+ ]
115
+ });
116
+ }
117
+ //#endregion
118
+ export { AgentTasks, TASKS_POLL_MS, TASK_MESSAGES, useTasks };
119
+
120
+ //# sourceMappingURL=AgentTasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentTasks.js","names":[],"sources":["../src/AgentTasks.tsx"],"sourcesContent":["import { ArrowLeftIcon, TrashIcon } from \"@phosphor-icons/react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { Automation } from \"./automation/Automation\";\nimport type { Task } from \"./automation/types\";\nimport { classes } from \"./classes\";\nimport type { Client } from \"./client\";\nimport { Button } from \"./kit/Button\";\n\n/** What the person's tasks say, in the space; a host gives its own, in its language. */\nexport interface TaskMessages {\n /** Over the chat, when the agent runs any for them: how many, to open them. */\n open: (count: number) => string;\n /** Over the list. */\n title: string;\n back: string;\n /** Taking one away. */\n remove: string;\n /** None left. */\n empty: string;\n /** A change that didn't go through. */\n failed: string;\n}\n\nexport const TASK_MESSAGES: TaskMessages = {\n open: (count) => (count === 1 ? \"1 task set up for you\" : `${count} tasks set up for you`),\n title: \"Your tasks\",\n back: \"Back to the conversation\",\n remove: \"Remove\",\n empty: \"Nothing set up. Ask the agent to remind you of something, or to check back later.\",\n failed: \"That didn't go through. Try again.\",\n};\n\nexport type TaskPart =\n | \"sc-tasks\"\n | \"sc-tasks__head\"\n | \"sc-tasks__title\"\n | \"sc-tasks__list\"\n | \"sc-tasks__empty\"\n | \"sc-tasks__problem\";\n\n/** How often the person's tasks are read again while the space is open. */\nexport const TASKS_POLL_MS = 20_000;\n\n/**\n * The tasks the agent runs for the person the client speaks for, read when the space opens,\n * again every `TASKS_POLL_MS` and on `refresh`. Null until read, and whenever it can't be (an API\n * without tasks, the business's own client): the space then shows none.\n */\nexport function useTasks(\n client: Client,\n agentId: string,\n enabled: boolean,\n): { tasks: Task[] | null; refresh: () => Promise<void> } {\n const [tasks, setTasks] = useState<Task[] | null>(null);\n const live = useRef(true);\n const refresh = useCallback(async () => {\n try {\n const read = await client.tasks.list(agentId);\n if (live.current) setTasks(read);\n } catch {\n if (live.current) setTasks(null);\n }\n }, [client, agentId]);\n useEffect(() => {\n live.current = true;\n if (!enabled) return;\n void refresh();\n const timer = setInterval(() => void refresh(), TASKS_POLL_MS);\n return () => {\n live.current = false;\n clearInterval(timer);\n };\n }, [enabled, refresh]);\n return { tasks: enabled ? tasks : null, refresh };\n}\n\nexport interface AgentTasksProps {\n client: Client;\n agentId: string;\n tasks: readonly Task[];\n /** Read them again, after a change. */\n onChange: () => Promise<void>;\n onBack: () => void;\n words: TaskMessages;\n classNames?: Partial<Record<TaskPart, string>> | undefined;\n}\n\n/**\n * The person's tasks, as they asked the agent for them: each as an automation reads (when, its\n * words, its last runs and how each went), with their switch to pause it and the way to take it\n * away; the way back to the conversation over them.\n */\nexport function AgentTasks({\n client,\n agentId,\n tasks,\n onChange,\n onBack,\n words,\n classNames,\n}: AgentTasksProps) {\n const [busy, setBusy] = useState<string | null>(null);\n const [failed, setFailed] = useState(false);\n const change = async (task: Task, doing: () => Promise<unknown>) => {\n setBusy(task.id);\n setFailed(false);\n try {\n await doing();\n await onChange();\n } catch {\n setFailed(true);\n } finally {\n setBusy(null);\n }\n };\n return (\n <section aria-label={words.title} part=\"tasks\" className={classes(classNames, \"sc-tasks\")}>\n <header className={classes(classNames, \"sc-tasks__head\")}>\n <Button\n tone=\"ghost\"\n size=\"sm\"\n icon={ArrowLeftIcon}\n aria-label={words.back}\n title={words.back}\n onClick={onBack}\n />\n <h3 className={classes(classNames, \"sc-tasks__title\")}>{words.title}</h3>\n </header>\n {failed && (\n <p role=\"alert\" className={classes(classNames, \"sc-tasks__problem\")}>\n {words.failed}\n </p>\n )}\n {tasks.length === 0 ? (\n <p className={classes(classNames, \"sc-tasks__empty\")}>{words.empty}</p>\n ) : (\n <div className={classes(classNames, \"sc-tasks__list\")}>\n {tasks.map((task) => (\n <Automation\n key={task.id}\n automation={task}\n runs={task.runs}\n switching={busy === task.id}\n onSwitch={(on) => void change(task, () => client.tasks.switch(agentId, task.id, on))}\n actions={\n <Button\n tone=\"ghost\"\n size=\"sm\"\n icon={TrashIcon}\n aria-label={words.remove}\n title={words.remove}\n disabled={busy === task.id}\n onClick={() => void change(task, () => client.tasks.remove(agentId, task.id))}\n />\n }\n />\n ))}\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAA8B;CACzC,OAAO,UAAW,UAAU,IAAI,0BAA0B,GA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L,MAAK;KACL,MAAM;KACN,cAAY,MAAM;KAClB,OAAO,MAAM;KACb,SAAS;IACV,CAAA,GACD,oBAAC,MAAD;KAAI,WAAW,QAAQ,YAAY,iBAAiB;KAAI,UAAA,MAAM;IAAU,CAAA,CAClE;;GACP,UACC,oBAAC,KAAD;IAAG,MAAK;IAAQ,WAAW,QAAQ,YAAY,mBAAmB;IAC/D,UAAA,MAAM;GACN,CAAA;GAEJ,MAAM,WAAW,IAChB,oBAAC,KAAD;IAAG,WAAW,QAAQ,YAAY,iBAAiB;IAAI,UAAA,MAAM;GAAS,CAAA,IAEtE,oBAAC,OAAD;IAAK,WAAW,QAAQ,YAAY,gBAAgB;IACjD,UAAA,MAAM,KAAK,SACV,oBAAC,YAAD;KAEE,YAAY;KACZ,MAAM,KAAK;KACX,WAAW,SAAS,KAAK;KACzB,WAAW,OAAO,KAAK,OAAO,YAAY,OAAO,MAAM,OAAO,SAAS,KAAK,IAAI,EAAE,CAAC;KACnF,SACE,oBAAC,QAAD;MACE,MAAK;MACL,MAAK;MACL,MAAM;MACN,cAAY,MAAM;MAClB,OAAO,MAAM;MACb,UAAU,SAAS,KAAK;MACxB,eAAe,KAAK,OAAO,YAAY,OAAO,MAAM,OAAO,SAAS,KAAK,EAAE,CAAC;KAC7E,CAAA;IAEJ,GAhBM,KAAK,EAgBX,CACF;GACE,CAAA;EAEA;;AAEb"}
@@ -0,0 +1,52 @@
1
+ import { LiveConversation } from "./useConversation.js";
2
+ //#region src/BrowserView.d.ts
3
+ /** The words the browser says; a host gives its own, in its language. */
4
+ export interface BrowserMessages {
5
+ /** Who holds it: the agent, by its name. */
6
+ agent: (name: string) => string;
7
+ /** Who holds it: the agent, in the owner's own Chrome. */
8
+ agentMine: (name: string) => string;
9
+ /** Who holds it: the person. */
10
+ person: string;
11
+ /** Take it from the agent. */
12
+ take: string;
13
+ /** Give it back to the agent, after taking it. */
14
+ giveBack: string;
15
+ /** The agent handed it over: what heads its reason. */
16
+ handedOver: (name: string) => string;
17
+ /** The person is done with what the agent handed over: the agent goes on. */
18
+ done: string;
19
+ /** A hand-over waits, but the browser closed meanwhile (nobody used it for a while). */
20
+ closed: string;
21
+ expand: string;
22
+ shrink: string;
23
+ /** The way to close it now: it stops running, and being billed. */
24
+ close: string;
25
+ /** Where the browser is when it shows no web page. */
26
+ blank: string;
27
+ /** The screen's name, for those who cannot see it. */
28
+ screen: (where: string) => string;
29
+ }
30
+ export declare const BROWSER_MESSAGES: BrowserMessages;
31
+ /** The browser's parts, by the class each carries; `classNames` adds a host's own under the same keys. */
32
+ export type BrowserPart = "sc-browser" | "sc-browser--large" | "sc-browser--yours" | "sc-browser--handed" | "sc-browser--closed" | "sc-browser__bar" | "sc-browser__who" | "sc-browser__address" | "sc-browser__title" | "sc-browser__controls" | "sc-browser__handover" | "sc-browser__screen" | "sc-browser__screen--waiting" | "sc-browser__canvas";
33
+ export interface BrowserViewProps {
34
+ /** The conversation the browser is of (`useConversation`). */
35
+ live: LiveConversation;
36
+ /** The agent's name, for the words that say it holds the browser. */
37
+ name: string;
38
+ messages?: Partial<BrowserMessages> | undefined;
39
+ classNames?: Partial<Record<BrowserPart, string>> | undefined;
40
+ }
41
+ /**
42
+ * The browser the agent drives, live, while the conversation has one: a compact tile while the
43
+ * agent works (its screen small, where it is, who holds it), which the person can enlarge or
44
+ * take over. Taken, or handed over by the agent, it glides open large and the person's pointer
45
+ * and keys go to the page; a hand-over says why, ringed in the accent, and "done" gives the
46
+ * browser back, the panel gliding small again, and lets the agent go on. Draws nothing when
47
+ * there is no browser, unless a hand-over still waits for one that closed: then the person can
48
+ * go on without it.
49
+ */
50
+ export declare function BrowserView({ live, name, messages, classNames }: BrowserViewProps): import("react").JSX.Element | null;
51
+ //#endregion
52
+ //# sourceMappingURL=BrowserView.d.ts.map