@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
@@ -1,176 +0,0 @@
1
- /**
2
- * The conversation with the builder as a list of blocks, built by folding events.
3
- *
4
- * Pure: the same events give the same transcript, whether they arrive live from the stream or
5
- * replayed from history. Only the block that changes gets a new object, so memoized components
6
- * re-render just that block while tokens stream in.
7
- *
8
- * The events are the builder's vocabulary (`signalcore_builder.events` on the server), the one
9
- * `build.sessions.say` streams and `build.sessions.history` replays.
10
- */
11
- import type { RequestCardData } from "../request/types.js";
12
- import type { SurfaceData } from "../surface/types.js";
13
- /** A request put to the owner, as `RequestCard` draws it. */
14
- export type Card = RequestCardData;
15
- export interface Change {
16
- id: string;
17
- change: "added" | "changed" | "removed";
18
- what: "automation" | "skill";
19
- title: string;
20
- }
21
- /** The change a turn closed (`docs/product-identity.md` section 4): what the owner activates. */
22
- export interface ChangeRef {
23
- id: string;
24
- description: string;
25
- state: string;
26
- }
27
- export type BuildEvent = {
28
- type: "owner";
29
- text: string;
30
- } | {
31
- type: "text";
32
- text: string;
33
- } | {
34
- type: "tool";
35
- id: string;
36
- name: string;
37
- input: Record<string, unknown>;
38
- } | {
39
- type: "tool_done";
40
- id: string;
41
- ok: boolean;
42
- summary: string;
43
- } | ({
44
- type: "card";
45
- } & Card)
46
- /** Something the builder showed the owner (a surface of the catalog). */
47
- | {
48
- type: "surface";
49
- surface: SurfaceData;
50
- } | {
51
- type: "published";
52
- version: number;
53
- summary: string;
54
- } | {
55
- type: "configured";
56
- }
57
- /** Where to look on the canvas: "automation:<id>", "automations" or "knowledge". */
58
- | {
59
- type: "canvas";
60
- focus: string;
61
- } | {
62
- type: "changes";
63
- items: Change[];
64
- learned: string[];
65
- change?: ChangeRef | null;
66
- }
67
- /**
68
- * Where a browser the agent drives is now, for the `Browser` surface the chat already shows
69
- * for that session. Live only: history keeps the surface, not each step.
70
- */
71
- | {
72
- type: "browser";
73
- session_id: string;
74
- status: "open" | "closed";
75
- step?: number;
76
- caption?: string;
77
- url?: string;
78
- title?: string;
79
- summary?: string;
80
- } | {
81
- type: "error";
82
- message: string;
83
- } | {
84
- type: "done";
85
- ok: boolean;
86
- turns: number;
87
- cost_usd: number | null;
88
- session_id: string | null;
89
- errors: string[];
90
- };
91
- /** Our own server's events: checking the tag is enough, anything else is ignored. */
92
- export declare function isBuildEvent(value: unknown): value is BuildEvent;
93
- export type StepStatus = "running" | "ok" | "error" | "stopped";
94
- export type Block = {
95
- kind: "owner";
96
- id: string;
97
- text: string;
98
- } | {
99
- kind: "text";
100
- id: string;
101
- text: string;
102
- open: boolean;
103
- } | {
104
- kind: "step";
105
- id: string;
106
- name: string;
107
- input: Record<string, unknown>;
108
- status: StepStatus;
109
- summary?: string;
110
- } | {
111
- kind: "card";
112
- id: string;
113
- card: Card;
114
- } | {
115
- kind: "surface";
116
- id: string;
117
- surface: SurfaceData;
118
- } | {
119
- kind: "published";
120
- id: string;
121
- version: number;
122
- summary: string;
123
- } | {
124
- kind: "changes";
125
- id: string;
126
- items: Change[];
127
- learned: string[];
128
- change: ChangeRef | null;
129
- } | {
130
- kind: "error";
131
- id: string;
132
- message: string;
133
- };
134
- export interface TurnResult {
135
- ok: boolean;
136
- costUsd: number | null;
137
- durationMs: number;
138
- }
139
- export interface Transcript {
140
- blocks: Block[];
141
- /** A turn is streaming. */
142
- live: boolean;
143
- turnStartedAt: number | null;
144
- lastTurn: TurnResult | null;
145
- /** What the builder is working on, for the canvas to show; `seq` changes on every event. */
146
- focus: {
147
- target: string;
148
- seq: number;
149
- } | null;
150
- }
151
- export type TranscriptAction =
152
- /** Replace everything with a conversation read back, plus cards still waiting for an answer. */
153
- {
154
- type: "load";
155
- events: BuildEvent[];
156
- pending: Card[];
157
- }
158
- /** The owner sent a message: the turn begins. */
159
- | {
160
- type: "start";
161
- text: string;
162
- at: number;
163
- } | {
164
- type: "event";
165
- event: BuildEvent;
166
- at: number;
167
- }
168
- /** The turn ended without its `done` (stopped, or the connection was lost). */
169
- | {
170
- type: "stop";
171
- at: number;
172
- };
173
- export declare const emptyTranscript: Transcript;
174
- export declare function reduceTranscript(state: Transcript, action: TranscriptAction): Transcript;
175
- /** What the builder is doing right now, for the status line. */
176
- export declare function activity(state: Transcript): Block | undefined;
@@ -1,202 +0,0 @@
1
- /**
2
- * The conversation with the builder as a list of blocks, built by folding events.
3
- *
4
- * Pure: the same events give the same transcript, whether they arrive live from the stream or
5
- * replayed from history. Only the block that changes gets a new object, so memoized components
6
- * re-render just that block while tokens stream in.
7
- *
8
- * The events are the builder's vocabulary (`signalcore_builder.events` on the server), the one
9
- * `build.sessions.say` streams and `build.sessions.history` replays.
10
- */
11
- const TYPES = new Set([
12
- "owner",
13
- "text",
14
- "tool",
15
- "tool_done",
16
- "card",
17
- "surface",
18
- "published",
19
- "configured",
20
- "canvas",
21
- "changes",
22
- "browser",
23
- "error",
24
- "done",
25
- ]);
26
- /** Our own server's events: checking the tag is enough, anything else is ignored. */
27
- export function isBuildEvent(value) {
28
- return (typeof value === "object" &&
29
- value !== null &&
30
- "type" in value &&
31
- typeof value.type === "string" &&
32
- TYPES.has(value.type));
33
- }
34
- export const emptyTranscript = {
35
- blocks: [],
36
- live: false,
37
- turnStartedAt: null,
38
- lastTurn: null,
39
- focus: null,
40
- };
41
- export function reduceTranscript(state, action) {
42
- switch (action.type) {
43
- case "load": {
44
- let next = emptyTranscript;
45
- for (const event of action.events)
46
- next = apply(next, event, null);
47
- const shown = new Set(next.blocks.map((b) => (b.kind === "card" ? b.card.request_id : "")));
48
- for (const card of action.pending) {
49
- if (!shown.has(card.request_id))
50
- next = push(next, { kind: "card", id: "", card });
51
- }
52
- return { ...next, focus: null, blocks: close(next.blocks), live: false };
53
- }
54
- case "start": {
55
- const next = push(state, { kind: "owner", id: "", text: action.text });
56
- return { ...next, live: true, turnStartedAt: action.at, lastTurn: null };
57
- }
58
- case "event":
59
- return apply(state, action.event, action.at);
60
- case "stop": {
61
- const blocks = close(state.blocks).map((b) => b.kind === "step" && b.status === "running" ? { ...b, status: "stopped" } : b);
62
- return { ...state, blocks, live: false, turnStartedAt: null };
63
- }
64
- }
65
- }
66
- /** `at` is when the event arrived; null when replaying history, where it is unknown. */
67
- function apply(state, event, at) {
68
- switch (event.type) {
69
- case "owner":
70
- return push(state, { kind: "owner", id: "", text: event.text });
71
- case "text": {
72
- const last = state.blocks.at(-1);
73
- if (last?.kind === "text" && last.open) {
74
- return replaceLast(state, { ...last, text: last.text + event.text });
75
- }
76
- return push(state, { kind: "text", id: "", text: event.text, open: true });
77
- }
78
- case "tool":
79
- return push(state, {
80
- kind: "step",
81
- id: event.id,
82
- name: event.name,
83
- input: event.input,
84
- status: "running",
85
- });
86
- case "tool_done":
87
- return {
88
- ...state,
89
- blocks: state.blocks.map((b) => b.kind === "step" && b.id === event.id
90
- ? { ...b, status: event.ok ? "ok" : "error", summary: event.summary }
91
- : b),
92
- };
93
- case "card": {
94
- const card = {
95
- request_id: event.request_id,
96
- kind: event.kind,
97
- title: event.title,
98
- payload: event.payload,
99
- };
100
- return push(state, { kind: "card", id: "", card });
101
- }
102
- case "surface":
103
- return push(state, { kind: "surface", id: "", surface: event.surface });
104
- case "published":
105
- return push(state, {
106
- kind: "published",
107
- id: "",
108
- version: event.version,
109
- summary: event.summary,
110
- });
111
- case "error":
112
- return push(state, { kind: "error", id: "", message: event.message });
113
- case "done": {
114
- const started = state.turnStartedAt;
115
- const blocks = close(state.blocks);
116
- const errors = event.errors.map((message, i) => ({
117
- kind: "error",
118
- id: `e${blocks.length + i}`,
119
- message,
120
- }));
121
- return {
122
- ...state,
123
- blocks: [...blocks, ...errors],
124
- live: false,
125
- turnStartedAt: null,
126
- lastTurn: started !== null && at !== null
127
- ? { ok: event.ok, costUsd: event.cost_usd, durationMs: at - started }
128
- : state.lastTurn,
129
- };
130
- }
131
- case "canvas":
132
- return { ...state, focus: { target: event.focus, seq: (state.focus?.seq ?? 0) + 1 } };
133
- case "changes":
134
- return push(state, {
135
- kind: "changes",
136
- id: "",
137
- items: event.items,
138
- learned: event.learned,
139
- change: event.change ?? null,
140
- });
141
- case "browser":
142
- return showBrowser(state, event);
143
- case "configured":
144
- return state;
145
- }
146
- }
147
- // What a browser event can say about the session; each one is written only when it carries it.
148
- const BROWSER_FIELDS = ["status", "caption", "step", "url", "title", "summary"];
149
- const isSession = (component, sessionId) => component.component === "Browser" && component.session_id === sessionId;
150
- /**
151
- * A browser event says where a session is now. It lands in the `Browser` component the chat
152
- * already shows for that session (the last surface that holds it), so it adds no block, and a
153
- * session the chat never showed changes nothing.
154
- */
155
- function showBrowser(state, event) {
156
- const index = state.blocks.findLastIndex((block) => block.kind === "surface" &&
157
- block.surface.components.some((component) => isSession(component, event.session_id)));
158
- const block = state.blocks[index];
159
- if (block?.kind !== "surface")
160
- return state;
161
- const carried = {};
162
- for (const field of BROWSER_FIELDS) {
163
- if (event[field] !== undefined)
164
- carried[field] = event[field];
165
- }
166
- const components = block.surface.components.map((component) => isSession(component, event.session_id) ? { ...component, ...carried } : component);
167
- return replaceAt(state, index, { ...block, surface: { ...block.surface, components } });
168
- }
169
- /** Append a block, closing the one before it (a reply ends when something else starts). */
170
- function push(state, block) {
171
- const blocks = close(state.blocks);
172
- const id = block.id || `${block.kind}-${blocks.length}`;
173
- return { ...state, blocks: [...blocks, { ...block, id }] };
174
- }
175
- function replaceAt(state, index, block) {
176
- return { ...state, blocks: state.blocks.map((b, i) => (i === index ? block : b)) };
177
- }
178
- function replaceLast(state, block) {
179
- return replaceAt(state, state.blocks.length - 1, block);
180
- }
181
- /** Mark the trailing reply as finished. */
182
- function close(blocks) {
183
- const last = blocks.at(-1);
184
- if (last?.kind !== "text" || !last.open)
185
- return blocks;
186
- return [...blocks.slice(0, -1), { ...last, open: false }];
187
- }
188
- /** What the builder is doing right now, for the status line. */
189
- export function activity(state) {
190
- if (!state.live)
191
- return undefined;
192
- for (let i = state.blocks.length - 1; i >= 0; i--) {
193
- const block = state.blocks[i];
194
- if (block?.kind === "step" && block.status === "running")
195
- return block;
196
- if (block?.kind === "owner")
197
- return undefined;
198
- if (block?.kind === "text" && block.open)
199
- return block;
200
- }
201
- return undefined;
202
- }
@@ -1,51 +0,0 @@
1
- import type { Schemas } from "@signalcore/sdk";
2
- import type { RequestCardData } from "../request/types.js";
3
- import type { SurfaceData } from "../surface/types.js";
4
- /** One event of a run's journal, as the API sends it (the contract's own union). */
5
- export type RunEvent = Schemas["RunEventPage"]["items"][number];
6
- /**
7
- * Where the stream stands: `connecting` before the first answer, `streaming` while events come,
8
- * `paused` while the run waits for an answer to a request, `done` when the run ended, `failed`
9
- * when the stream could not be kept (see `error`).
10
- */
11
- export type StreamStatus = "connecting" | "streaming" | "paused" | "done" | "failed";
12
- export interface StreamState {
13
- /** The run this state is of: a state of another run is not this one's. */
14
- runId: string | undefined;
15
- /** Everything the run recorded, in order. */
16
- events: RunEvent[];
17
- /** What the agent showed (`ui.surface`), in order, the ones that can be drawn. */
18
- surfaces: SurfaceData[];
19
- /** What the run asked of the owner (`request.created`), as cards to answer. */
20
- requests: RequestCardData[];
21
- status: StreamStatus;
22
- error: Error | undefined;
23
- /** The `id` of the last event seen: where to go on from after a drop. */
24
- lastEventId: string | undefined;
25
- }
26
- export type Step = {
27
- type: "begin";
28
- runId: string | undefined;
29
- lastEventId: string | undefined;
30
- } | {
31
- type: "event";
32
- event: RunEvent;
33
- id: string | undefined;
34
- } | {
35
- type: "status";
36
- status: StreamStatus;
37
- } | {
38
- type: "failed";
39
- error: Error;
40
- } | {
41
- type: "payloads";
42
- pending: PendingRequest[];
43
- };
44
- /** A request as the API lists it, with the payload its card is drawn from. */
45
- export interface PendingRequest {
46
- id: string;
47
- agent_id: string;
48
- payload: Record<string, unknown>;
49
- }
50
- export declare function begin(runId: string | undefined, lastEventId: string | undefined): StreamState;
51
- export declare function reduce(state: StreamState, step: Step): StreamState;
@@ -1,58 +0,0 @@
1
- import { isAnswerable } from "../request/cards.js";
2
- import { surfaceOf } from "../surface/check.js";
3
- export function begin(runId, lastEventId) {
4
- return {
5
- runId,
6
- events: [],
7
- surfaces: [],
8
- requests: [],
9
- status: "connecting",
10
- error: undefined,
11
- lastEventId,
12
- };
13
- }
14
- export function reduce(state, step) {
15
- switch (step.type) {
16
- case "begin":
17
- return begin(step.runId, step.lastEventId);
18
- case "event":
19
- return {
20
- ...state,
21
- events: [...state.events, step.event],
22
- surfaces: withSurface(state.surfaces, step.event),
23
- requests: withRequest(state.requests, step.event),
24
- lastEventId: step.id ?? state.lastEventId,
25
- };
26
- case "status":
27
- return { ...state, status: step.status };
28
- case "failed":
29
- return { ...state, status: "failed", error: step.error };
30
- case "payloads":
31
- return {
32
- ...state,
33
- requests: state.requests.map((card) => {
34
- const found = step.pending.find((item) => item.id === card.request_id);
35
- return found ? { ...card, agent_id: found.agent_id, payload: found.payload } : card;
36
- }),
37
- };
38
- }
39
- }
40
- function withSurface(surfaces, event) {
41
- if (event.type !== "ui.surface")
42
- return surfaces;
43
- const surface = surfaceOf(event.surface);
44
- return surface ? [...surfaces, surface] : surfaces;
45
- }
46
- function withRequest(requests, event) {
47
- if (event.type !== "request.created" || !isAnswerable(event.kind))
48
- return requests;
49
- if (requests.some((card) => card.request_id === event.request_id))
50
- return requests;
51
- const card = {
52
- request_id: event.request_id,
53
- kind: event.kind,
54
- title: event.title,
55
- payload: {},
56
- };
57
- return [...requests, card];
58
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * The items of `source` until `signal` aborts. A generator finishes the read it is in before it
3
- * obeys `return()`, so a stream waiting on a quiet connection would keep a stopped turn on
4
- * screen until its next event. This stops listening the moment the signal fires and hangs up on
5
- * the stream behind, in the background.
6
- */
7
- export declare function untilAborted<T>(source: AsyncGenerator<T, void>, signal: AbortSignal): AsyncGenerator<T, void>;
@@ -1,32 +0,0 @@
1
- const ABORTED = Symbol("aborted");
2
- /**
3
- * The items of `source` until `signal` aborts. A generator finishes the read it is in before it
4
- * obeys `return()`, so a stream waiting on a quiet connection would keep a stopped turn on
5
- * screen until its next event. This stops listening the moment the signal fires and hangs up on
6
- * the stream behind, in the background.
7
- */
8
- export async function* untilAborted(source, signal) {
9
- const aborted = new Promise((resolve) => {
10
- if (signal.aborted)
11
- resolve(ABORTED);
12
- else {
13
- signal.addEventListener("abort", () => {
14
- resolve(ABORTED);
15
- }, { once: true });
16
- }
17
- });
18
- try {
19
- for (;;) {
20
- const read = source.next();
21
- // If the abort wins, this read is never awaited: its failure must not go unheard of.
22
- read.catch(() => undefined);
23
- const item = await Promise.race([read, aborted]);
24
- if (item === ABORTED || item.done)
25
- return;
26
- yield item.value;
27
- }
28
- }
29
- finally {
30
- source.return().catch(() => undefined);
31
- }
32
- }
@@ -1,26 +0,0 @@
1
- import { type StreamState } from "./reduce.js";
2
- export interface RunStreamOptions {
3
- /** The `id` of the last event already seen, to go on from there (after a reload). */
4
- lastEventId?: string | undefined;
5
- /**
6
- * Ask the API what the requests a run raises say, to draw them as cards (default). A host that
7
- * never draws them, such as the chat of the people an agent serves, turns it off, and the API
8
- * is not asked for what nobody will see.
9
- */
10
- cards?: boolean | undefined;
11
- }
12
- /** What a run has said so far; see `StreamState`. `done` is `status === "done"`. */
13
- export interface RunStream extends StreamState {
14
- done: boolean;
15
- }
16
- /**
17
- * Follows a run live through the provider's client (`runs.stream`), accumulating what it says:
18
- * every event, the surfaces the agent showed, and the requests it is waiting on, as cards ready
19
- * for `RequestCard`. When the run pauses on a request the stream is closed; once the request is
20
- * answered (anywhere: this card, the inbox, another tab) it opens again from the last event
21
- * seen, and carries on until the run is `done`. A stream that drops is opened again the same way.
22
- *
23
- * Needs a client with `runs`; without one it stays `connecting`. Stops when the component goes
24
- * away or `runId` changes.
25
- */
26
- export declare function useRunStream(runId: string | undefined, options?: RunStreamOptions): RunStream;
@@ -1,137 +0,0 @@
1
- import { useEffect, useReducer } from "react";
2
- import { useSignalcore } from "../SignalcoreProvider.js";
3
- import { begin, reduce } from "./reduce.js";
4
- /** How often a paused run is asked whether it has gone on. */
5
- const RESUME_POLL_MS = 2_000;
6
- /** How long to wait before opening a stream that closed without saying why. */
7
- const RETRY_MS = 1_000;
8
- /** How many times in a row that may happen without a single event before giving up. */
9
- const MAX_SILENT_DROPS = 5;
10
- /**
11
- * Follows a run live through the provider's client (`runs.stream`), accumulating what it says:
12
- * every event, the surfaces the agent showed, and the requests it is waiting on, as cards ready
13
- * for `RequestCard`. When the run pauses on a request the stream is closed; once the request is
14
- * answered (anywhere: this card, the inbox, another tab) it opens again from the last event
15
- * seen, and carries on until the run is `done`. A stream that drops is opened again the same way.
16
- *
17
- * Needs a client with `runs`; without one it stays `connecting`. Stops when the component goes
18
- * away or `runId` changes.
19
- */
20
- export function useRunStream(runId, options = {}) {
21
- const { client } = useSignalcore();
22
- const { lastEventId, cards = true } = options;
23
- const [state, dispatch] = useReducer(reduce, undefined, () => begin(runId, lastEventId));
24
- useEffect(() => {
25
- if (!client?.runs || !runId)
26
- return undefined;
27
- const stop = new AbortController();
28
- const send = (step) => {
29
- if (!stop.signal.aborted)
30
- dispatch(step);
31
- };
32
- send({ type: "begin", runId, lastEventId });
33
- follow(client, runId, lastEventId, stop.signal, send, cards).catch((reason) => {
34
- send({ type: "failed", error: reason instanceof Error ? reason : new Error(String(reason)) });
35
- });
36
- return () => {
37
- stop.abort();
38
- };
39
- }, [client, runId, lastEventId, cards]);
40
- // Until the effect has started over for a new run, the state is still the old run's.
41
- const current = state.runId === runId ? state : begin(runId, lastEventId);
42
- return { ...current, done: current.status === "done" };
43
- }
44
- /**
45
- * The whole life of the stream: open, read, and open again until the run is over. Stopping it
46
- * (`signal`) ends it with an abort error, which nobody is told of.
47
- */
48
- async function follow(client, runId, startAt, signal, send, cards) {
49
- const runs = client.runs;
50
- if (!runs)
51
- return;
52
- let lastId = startAt;
53
- let silentDrops = 0;
54
- for (;;) {
55
- signal.throwIfAborted();
56
- send({ type: "status", status: "connecting" });
57
- let ending;
58
- let heard = false;
59
- for await (const frame of runs.stream(runId, lastId === undefined ? {} : { lastEventId: lastId })) {
60
- signal.throwIfAborted();
61
- if (frame.event === "done" || frame.event === "paused") {
62
- ending = frame.event;
63
- break;
64
- }
65
- const event = eventOf(frame);
66
- if (!event)
67
- continue;
68
- if (!heard)
69
- send({ type: "status", status: "streaming" });
70
- heard = true;
71
- lastId = frame.id ?? lastId;
72
- send({ type: "event", event, id: frame.id });
73
- if (cards && event.type === "request.created")
74
- void fillIn(client, send);
75
- }
76
- if (ending === "done") {
77
- send({ type: "status", status: "done" });
78
- return;
79
- }
80
- if (ending === "paused") {
81
- send({ type: "status", status: "paused" });
82
- await untilResumed(client, runId, signal);
83
- continue;
84
- }
85
- // The stream ended without saying why: the connection dropped. Open it again, a few times.
86
- silentDrops = heard ? 0 : silentDrops + 1;
87
- if (silentDrops >= MAX_SILENT_DROPS)
88
- throw new Error("The stream kept closing before the run ended");
89
- await sleep(RETRY_MS, signal);
90
- }
91
- }
92
- /** The journal event a frame carries; its type is the frame's own when the data omits it. */
93
- function eventOf(frame) {
94
- try {
95
- const data = frame.json();
96
- if (typeof data !== "object" || data === null || Array.isArray(data))
97
- return undefined;
98
- return { type: frame.event, ...data };
99
- }
100
- catch {
101
- return undefined;
102
- }
103
- }
104
- /** A request's card is drawn from its payload, which the event leaves out: ask the API for it. */
105
- async function fillIn(client, send) {
106
- const requests = client.requests;
107
- if (!requests?.pending)
108
- return;
109
- try {
110
- const page = await requests.pending();
111
- send({ type: "payloads", pending: page.items });
112
- }
113
- catch {
114
- // The card stays as bare as the event made it: its title is still worth showing.
115
- }
116
- }
117
- /** Waits for a paused run to leave `waiting`: its request was answered, wherever that happened. */
118
- async function untilResumed(client, runId, signal) {
119
- const runs = client.runs;
120
- if (!runs)
121
- return;
122
- for (;;) {
123
- await sleep(RESUME_POLL_MS, signal);
124
- signal.throwIfAborted();
125
- if ((await runs.get(runId)).status !== "waiting")
126
- return;
127
- }
128
- }
129
- function sleep(ms, signal) {
130
- return new Promise((resolve) => {
131
- const timer = setTimeout(resolve, ms);
132
- signal.addEventListener("abort", () => {
133
- clearTimeout(timer);
134
- resolve();
135
- }, { once: true });
136
- });
137
- }