@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.
- package/README.md +896 -513
- package/dist/AgentAbout.d.ts +186 -0
- package/dist/AgentAbout.js +1020 -0
- package/dist/AgentAbout.js.map +1 -0
- package/dist/AgentCard.d.ts +49 -0
- package/dist/AgentCard.js +77 -0
- package/dist/AgentCard.js.map +1 -0
- package/dist/AgentChat.d.ts +233 -0
- package/dist/AgentChat.js +1127 -0
- package/dist/AgentChat.js.map +1 -0
- package/dist/AgentSpace.d.ts +112 -0
- package/dist/AgentSpace.js +339 -0
- package/dist/AgentSpace.js.map +1 -0
- package/dist/AgentTasks.d.ts +48 -0
- package/dist/AgentTasks.js +120 -0
- package/dist/AgentTasks.js.map +1 -0
- package/dist/BrowserView.d.ts +52 -0
- package/dist/BrowserView.js +328 -0
- package/dist/BrowserView.js.map +1 -0
- package/dist/FileView.d.ts +63 -0
- package/dist/FileView.js +449 -0
- package/dist/FileView.js.map +1 -0
- package/dist/Modes.d.ts +13 -0
- package/dist/Modes.js +75 -0
- package/dist/Modes.js.map +1 -0
- package/dist/VoiceCall.d.ts +91 -0
- package/dist/VoiceCall.js +302 -0
- package/dist/VoiceCall.js.map +1 -0
- package/dist/about.d.ts +212 -0
- package/dist/about.js +136 -0
- package/dist/about.js.map +1 -0
- package/dist/agentIcons.d.ts +33 -0
- package/dist/agentIcons.js +36 -0
- package/dist/agentIcons.js.map +1 -0
- package/dist/automation/Automation.d.ts +35 -0
- package/dist/automation/Automation.js +268 -0
- package/dist/automation/Automation.js.map +1 -0
- package/dist/automation/RunView.d.ts +25 -0
- package/dist/automation/RunView.js +187 -0
- package/dist/automation/RunView.js.map +1 -0
- package/dist/automation/cron.d.ts +41 -0
- package/dist/automation/cron.js +169 -0
- package/dist/automation/cron.js.map +1 -0
- package/dist/automation/marks.js +121 -0
- package/dist/automation/marks.js.map +1 -0
- package/dist/automation/messages.d.ts +113 -0
- package/dist/automation/messages.js +113 -0
- package/dist/automation/messages.js.map +1 -0
- package/dist/automation/record.d.ts +47 -0
- package/dist/automation/record.js +177 -0
- package/dist/automation/record.js.map +1 -0
- package/dist/automation/types.d.ts +143 -0
- package/dist/automation/when.d.ts +36 -0
- package/dist/automation/when.js +168 -0
- package/dist/automation/when.js.map +1 -0
- package/dist/blocks.d.ts +185 -0
- package/dist/browser.js +292 -0
- package/dist/browser.js.map +1 -0
- package/dist/call.d.ts +89 -0
- package/dist/call.js +218 -0
- package/dist/call.js.map +1 -0
- package/dist/channelParts.js +26 -0
- package/dist/channelParts.js.map +1 -0
- package/dist/classes.js +8 -3
- package/dist/classes.js.map +1 -0
- package/dist/client.d.ts +146 -54
- package/dist/client.js +204 -1
- package/dist/client.js.map +1 -0
- package/dist/conversationFiles.js +46 -0
- package/dist/conversationFiles.js.map +1 -0
- package/dist/credentials.d.ts +45 -0
- package/dist/credentials.js +98 -0
- package/dist/credentials.js.map +1 -0
- package/dist/dev.js +17 -0
- package/dist/dev.js.map +1 -0
- package/dist/es.d.ts +17 -0
- package/dist/es.js +382 -0
- package/dist/es.js.map +1 -0
- package/dist/files.d.ts +21 -0
- package/dist/files.js +214 -0
- package/dist/files.js.map +1 -0
- package/dist/frames.d.ts +115 -0
- package/dist/frames.js +219 -0
- package/dist/frames.js.map +1 -0
- package/dist/icons.js +29 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +63 -60
- package/dist/index.js +59 -45
- package/dist/kit/AudioPlayer.d.ts +20 -0
- package/dist/kit/AudioPlayer.js +116 -0
- package/dist/kit/AudioPlayer.js.map +1 -0
- package/dist/kit/Button.d.ts +29 -0
- package/dist/kit/Button.js +59 -0
- package/dist/kit/Button.js.map +1 -0
- package/dist/kit/Card.d.ts +16 -0
- package/dist/kit/Card.js +36 -0
- package/dist/kit/Card.js.map +1 -0
- package/dist/kit/Chart.js +152 -0
- package/dist/kit/Chart.js.map +1 -0
- package/dist/kit/Choices.d.ts +21 -0
- package/dist/kit/Choices.js +99 -0
- package/dist/kit/Choices.js.map +1 -0
- package/dist/kit/Combobox.d.ts +26 -0
- package/dist/kit/Combobox.js +190 -0
- package/dist/kit/Combobox.js.map +1 -0
- package/dist/kit/DateField.d.ts +17 -0
- package/dist/kit/DateField.js +133 -0
- package/dist/kit/DateField.js.map +1 -0
- package/dist/kit/Field.d.ts +40 -0
- package/dist/kit/Field.js +98 -0
- package/dist/kit/Field.js.map +1 -0
- package/dist/kit/FileField.d.ts +113 -0
- package/dist/kit/FileField.js +341 -0
- package/dist/kit/FileField.js.map +1 -0
- package/dist/kit/FileMark.d.ts +15 -0
- package/dist/kit/FileMark.js +39 -0
- package/dist/kit/FileMark.js.map +1 -0
- package/dist/kit/Inputs.d.ts +59 -0
- package/dist/kit/Inputs.js +205 -0
- package/dist/kit/Inputs.js.map +1 -0
- package/dist/kit/List.d.ts +47 -0
- package/dist/kit/List.js +85 -0
- package/dist/kit/List.js.map +1 -0
- package/dist/kit/Mark.d.ts +30 -0
- package/dist/kit/Mark.js +27 -0
- package/dist/kit/Mark.js.map +1 -0
- package/dist/kit/MarkStack.d.ts +15 -0
- package/dist/kit/MarkStack.js +26 -0
- package/dist/kit/MarkStack.js.map +1 -0
- package/dist/kit/Note.d.ts +11 -0
- package/dist/kit/Note.js +31 -0
- package/dist/kit/Note.js.map +1 -0
- package/dist/kit/Popover.js +90 -0
- package/dist/kit/Popover.js.map +1 -0
- package/dist/kit/RangeField.d.ts +14 -0
- package/dist/kit/RangeField.js +47 -0
- package/dist/kit/RangeField.js.map +1 -0
- package/dist/kit/RatingField.d.ts +14 -0
- package/dist/kit/RatingField.js +50 -0
- package/dist/kit/RatingField.js.map +1 -0
- package/dist/kit/Stat.d.ts +26 -0
- package/dist/kit/Stat.js +46 -0
- package/dist/kit/Stat.js.map +1 -0
- package/dist/kit/Switch.d.ts +14 -0
- package/dist/kit/Switch.js +21 -0
- package/dist/kit/Switch.js.map +1 -0
- package/dist/kit/Tag.d.ts +16 -0
- package/dist/kit/Tag.js +20 -0
- package/dist/kit/Tag.js.map +1 -0
- package/dist/kit/Tile.d.ts +34 -0
- package/dist/kit/Tile.js +52 -0
- package/dist/kit/Tile.js.map +1 -0
- package/dist/kit/TimeField.d.ts +31 -0
- package/dist/kit/TimeField.js +109 -0
- package/dist/kit/TimeField.js.map +1 -0
- package/dist/kit/context.d.ts +22 -0
- package/dist/kit/context.js +46 -0
- package/dist/kit/context.js.map +1 -0
- package/dist/kit/dates.d.ts +14 -0
- package/dist/kit/dates.js +129 -0
- package/dist/kit/dates.js.map +1 -0
- package/dist/kit/messages.d.ts +99 -0
- package/dist/kit/messages.js +66 -0
- package/dist/kit/messages.js.map +1 -0
- package/dist/kit/numbers.d.ts +12 -0
- package/dist/kit/numbers.js +40 -0
- package/dist/kit/numbers.js.map +1 -0
- package/dist/kit/options.d.ts +10 -0
- package/dist/kit/options.js +23 -0
- package/dist/kit/options.js.map +1 -0
- package/dist/kit/uploads.d.ts +42 -0
- package/dist/kit/uploads.js +165 -0
- package/dist/kit/uploads.js.map +1 -0
- package/dist/kit/waveform.js +76 -0
- package/dist/kit/waveform.js.map +1 -0
- package/dist/locale.d.ts +1 -0
- package/dist/locale.js +1 -0
- package/dist/markdown.js +84 -0
- package/dist/markdown.js.map +1 -0
- package/dist/marks.js +217 -0
- package/dist/marks.js.map +1 -0
- package/dist/reveal.js +48 -0
- package/dist/reveal.js.map +1 -0
- package/dist/stepGlyphs.js +62 -0
- package/dist/stepGlyphs.js.map +1 -0
- package/dist/surface/Form.js +264 -0
- package/dist/surface/Form.js.map +1 -0
- package/dist/surface/Markdown.js +42 -0
- package/dist/surface/Markdown.js.map +1 -0
- package/dist/surface/Surface.d.ts +31 -17
- package/dist/surface/Surface.js +480 -57
- package/dist/surface/Surface.js.map +1 -0
- package/dist/surface/scope.d.ts +32 -0
- package/dist/surface/scope.js +23 -0
- package/dist/surface/scope.js.map +1 -0
- package/dist/surface/values.d.ts +44 -0
- package/dist/surface/values.js +237 -0
- package/dist/surface/values.js.map +1 -0
- package/dist/tint.d.ts +10 -0
- package/dist/tint.js +19 -0
- package/dist/tint.js.map +1 -0
- package/dist/types.d.ts +541 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/useAgentFace.d.ts +18 -0
- package/dist/useAgentFace.js +45 -0
- package/dist/useAgentFace.js.map +1 -0
- package/dist/useCall.d.ts +39 -0
- package/dist/useCall.js +273 -0
- package/dist/useCall.js.map +1 -0
- package/dist/useConversation.d.ts +77 -0
- package/dist/useConversation.js +523 -0
- package/dist/useConversation.js.map +1 -0
- package/dist/useDictation.d.ts +17 -0
- package/dist/useDictation.js +68 -0
- package/dist/useDictation.js.map +1 -0
- package/dist/useLive.d.ts +26 -0
- package/dist/useLive.js +88 -0
- package/dist/useLive.js.map +1 -0
- package/dist/usePolled.js +68 -0
- package/dist/usePolled.js.map +1 -0
- package/dist/voice/Orb.d.ts +10 -9
- package/dist/voice/Orb.js +43 -39
- package/dist/voice/Orb.js.map +1 -0
- package/dist/voice/StillOrb.js +33 -0
- package/dist/voice/StillOrb.js.map +1 -0
- package/dist/voice/WebGLOrb.js +98 -0
- package/dist/voice/WebGLOrb.js.map +1 -0
- package/dist/voice/fluidDots.js +161 -0
- package/dist/voice/fluidDots.js.map +1 -0
- package/dist/voice/motion.js +84 -0
- package/dist/voice/motion.js.map +1 -0
- package/dist/voice/orbs.d.ts +32 -0
- package/dist/voice/orbs.js +16 -0
- package/dist/voice/orbs.js.map +1 -0
- package/dist/voice/useReducedMotion.js +16 -16
- package/dist/voice/useReducedMotion.js.map +1 -0
- package/dist/voice/wave.js +116 -0
- package/dist/voice/wave.js.map +1 -0
- package/dist/voice/webgl.js +177 -0
- package/dist/voice/webgl.js.map +1 -0
- package/dist/widget.js +284 -8
- package/package.json +49 -39
- package/src/AgentAbout.tsx +1621 -0
- package/src/AgentCard.tsx +123 -0
- package/src/AgentChat.tsx +1812 -0
- package/src/AgentSpace.tsx +540 -0
- package/src/AgentTasks.tsx +163 -0
- package/src/BrowserView.tsx +442 -0
- package/src/FileView.tsx +620 -0
- package/src/Modes.tsx +112 -0
- package/src/VoiceCall.tsx +411 -0
- package/src/about.ts +355 -0
- package/src/agentIcons.ts +56 -0
- package/src/automation/Automation.tsx +308 -0
- package/src/automation/RunView.tsx +213 -0
- package/src/automation/cron.ts +196 -0
- package/src/automation/marks.tsx +144 -0
- package/src/automation/messages.ts +231 -0
- package/src/automation/record.ts +206 -0
- package/src/automation/types.ts +146 -0
- package/src/automation/when.ts +195 -0
- package/src/blocks.ts +249 -0
- package/src/browser.ts +334 -0
- package/src/call.ts +300 -0
- package/src/channelParts.ts +17 -0
- package/src/classes.ts +10 -0
- package/src/client.ts +397 -0
- package/src/conversationFiles.ts +54 -0
- package/src/credentials.ts +158 -0
- package/src/dev.ts +20 -0
- package/src/es.ts +423 -0
- package/src/files.ts +238 -0
- package/src/frames.ts +291 -0
- package/src/icons.tsx +49 -0
- package/src/index.ts +271 -0
- package/src/kit/AudioPlayer.tsx +129 -0
- package/src/kit/Button.tsx +97 -0
- package/src/kit/Card.tsx +47 -0
- package/src/kit/Chart.tsx +129 -0
- package/src/kit/Choices.tsx +131 -0
- package/src/kit/Combobox.tsx +247 -0
- package/src/kit/DateField.tsx +156 -0
- package/src/kit/Field.tsx +137 -0
- package/src/kit/FileField.tsx +492 -0
- package/src/kit/FileMark.tsx +56 -0
- package/src/kit/Inputs.tsx +250 -0
- package/src/kit/List.tsx +135 -0
- package/src/kit/Mark.tsx +64 -0
- package/src/kit/MarkStack.tsx +29 -0
- package/src/kit/Note.tsx +42 -0
- package/src/kit/Popover.tsx +121 -0
- package/src/kit/RangeField.tsx +53 -0
- package/src/kit/RatingField.tsx +62 -0
- package/src/kit/Stat.tsx +60 -0
- package/src/kit/Switch.tsx +28 -0
- package/src/kit/Tag.tsx +32 -0
- package/src/kit/Tile.tsx +74 -0
- package/src/kit/TimeField.tsx +157 -0
- package/src/kit/context.tsx +246 -0
- package/src/kit/dates.ts +150 -0
- package/src/kit/messages.ts +160 -0
- package/src/kit/numbers.ts +44 -0
- package/src/kit/options.ts +30 -0
- package/src/kit/uploads.ts +244 -0
- package/src/kit/waveform.ts +84 -0
- package/src/locale.ts +6 -0
- package/src/markdown.ts +69 -0
- package/src/marks.tsx +328 -0
- package/src/reveal.ts +52 -0
- package/src/stepGlyphs.ts +83 -0
- package/src/styles.css +6970 -0
- package/src/surface/Form.tsx +299 -0
- package/src/surface/Markdown.tsx +55 -0
- package/src/surface/Surface.tsx +605 -0
- package/src/surface/scope.ts +82 -0
- package/src/surface/values.ts +361 -0
- package/src/tint.ts +14 -0
- package/src/types.ts +604 -0
- package/src/useAgentFace.ts +47 -0
- package/src/useCall.ts +292 -0
- package/src/useConversation.ts +627 -0
- package/src/useDictation.ts +83 -0
- package/src/useLive.ts +115 -0
- package/src/usePolled.ts +60 -0
- package/src/voice/Orb.tsx +45 -0
- package/src/voice/StillOrb.tsx +29 -0
- package/src/voice/WebGLOrb.tsx +98 -0
- package/src/voice/fluidDots.tsx +171 -0
- package/src/voice/motion.ts +112 -0
- package/src/voice/orbs.ts +39 -0
- package/src/voice/useReducedMotion.ts +24 -0
- package/src/voice/wave.tsx +129 -0
- package/src/voice/webgl.ts +209 -0
- package/src/widget/css.d.ts +5 -0
- package/src/widget/element.tsx +535 -0
- package/src/widget/index.ts +10 -0
- package/src/widget/mount.ts +27 -0
- package/src/widget/widget.css +253 -0
- package/dist/SignalcoreProvider.d.ts +0 -113
- package/dist/SignalcoreProvider.js +0 -84
- package/dist/automations/AppMarks.d.ts +0 -11
- package/dist/automations/AppMarks.js +0 -18
- package/dist/automations/AutomationCard.d.ts +0 -27
- package/dist/automations/AutomationCard.js +0 -53
- package/dist/automations/AutomationsWindow.d.ts +0 -38
- package/dist/automations/AutomationsWindow.js +0 -57
- package/dist/automations/Card.d.ts +0 -46
- package/dist/automations/Card.js +0 -45
- package/dist/automations/ScheduleMarks.d.ts +0 -13
- package/dist/automations/ScheduleMarks.js +0 -24
- package/dist/automations/presentationIcons.d.ts +0 -7
- package/dist/automations/presentationIcons.js +0 -67
- package/dist/automations/schedule.d.ts +0 -25
- package/dist/automations/schedule.js +0 -59
- package/dist/automations/time.d.ts +0 -3
- package/dist/automations/time.js +0 -25
- package/dist/browser/BrowserView.d.ts +0 -43
- package/dist/browser/BrowserView.js +0 -94
- package/dist/browser/room.d.ts +0 -21
- package/dist/browser/room.js +0 -33
- package/dist/browser/useBrowserSession.d.ts +0 -17
- package/dist/browser/useBrowserSession.js +0 -67
- package/dist/builder/BuilderChat.d.ts +0 -32
- package/dist/builder/BuilderChat.js +0 -41
- package/dist/builder/BuilderTranscript.d.ts +0 -49
- package/dist/builder/BuilderTranscript.js +0 -62
- package/dist/builder/StatusLine.d.ts +0 -8
- package/dist/builder/StatusLine.js +0 -17
- package/dist/builder/answer.d.ts +0 -7
- package/dist/builder/answer.js +0 -8
- package/dist/builder/blocks.d.ts +0 -31
- package/dist/builder/blocks.js +0 -74
- package/dist/builder/items.d.ts +0 -15
- package/dist/builder/items.js +0 -21
- package/dist/builder/steps.d.ts +0 -20
- package/dist/builder/steps.js +0 -120
- package/dist/builder/time.d.ts +0 -4
- package/dist/builder/time.js +0 -24
- package/dist/builder/useBuildSession.d.ts +0 -36
- package/dist/builder/useBuildSession.js +0 -130
- package/dist/builder/workingOn.d.ts +0 -7
- package/dist/builder/workingOn.js +0 -15
- package/dist/chat/AgentChat.d.ts +0 -37
- package/dist/chat/AgentChat.js +0 -21
- package/dist/chat/ChatView.d.ts +0 -25
- package/dist/chat/ChatView.js +0 -34
- package/dist/chat/Composer.d.ts +0 -20
- package/dist/chat/Composer.js +0 -22
- package/dist/chat/MessageRow.d.ts +0 -22
- package/dist/chat/MessageRow.js +0 -32
- package/dist/chat/arrival.d.ts +0 -15
- package/dist/chat/arrival.js +0 -25
- package/dist/chat/history.d.ts +0 -24
- package/dist/chat/history.js +0 -45
- package/dist/chat/moments.d.ts +0 -25
- package/dist/chat/moments.js +0 -72
- package/dist/chat/types.d.ts +0 -12
- package/dist/chat/types.js +0 -1
- package/dist/chat/useComposer.d.ts +0 -46
- package/dist/chat/useComposer.js +0 -62
- package/dist/chat/useConversation.d.ts +0 -35
- package/dist/chat/useConversation.js +0 -71
- package/dist/chat/useStickToBottom.d.ts +0 -9
- package/dist/chat/useStickToBottom.js +0 -33
- package/dist/chat/useTurns.d.ts +0 -49
- package/dist/chat/useTurns.js +0 -111
- package/dist/classes.d.ts +0 -2
- package/dist/development.d.ts +0 -5
- package/dist/development.js +0 -8
- package/dist/flow/FlowWindow.d.ts +0 -42
- package/dist/flow/FlowWindow.js +0 -126
- package/dist/flow/index.d.ts +0 -16
- package/dist/flow/index.js +0 -16
- package/dist/flow/kinds.d.ts +0 -23
- package/dist/flow/kinds.js +0 -48
- package/dist/flow/map.d.ts +0 -44
- package/dist/flow/map.js +0 -225
- package/dist/flow/nodePaths.d.ts +0 -7
- package/dist/flow/nodePaths.js +0 -17
- package/dist/flow/relations.d.ts +0 -42
- package/dist/flow/relations.js +0 -174
- package/dist/host.d.ts +0 -124
- package/dist/host.js +0 -1
- package/dist/live/LiveView.d.ts +0 -28
- package/dist/live/LiveView.js +0 -55
- package/dist/live/capture.d.ts +0 -20
- package/dist/live/capture.js +0 -100
- package/dist/live/follow.d.ts +0 -26
- package/dist/live/follow.js +0 -72
- package/dist/live/paint.d.ts +0 -13
- package/dist/live/paint.js +0 -77
- package/dist/live/useLiveStream.d.ts +0 -16
- package/dist/live/useLiveStream.js +0 -57
- package/dist/look.d.ts +0 -33
- package/dist/look.js +0 -241
- package/dist/messages/en.d.ts +0 -3
- package/dist/messages/en.js +0 -251
- package/dist/messages/es.d.ts +0 -3
- package/dist/messages/es.js +0 -251
- package/dist/messages/index.d.ts +0 -16
- package/dist/messages/index.js +0 -33
- package/dist/messages/types.d.ts +0 -246
- package/dist/messages/types.js +0 -1
- package/dist/parts/Button.d.ts +0 -18
- package/dist/parts/Button.js +0 -17
- package/dist/parts/Icon.d.ts +0 -39
- package/dist/parts/Icon.js +0 -37
- package/dist/parts/Input.d.ts +0 -6
- package/dist/parts/Input.js +0 -11
- package/dist/parts/Spinner.d.ts +0 -2
- package/dist/parts/Spinner.js +0 -7
- package/dist/patterns.d.ts +0 -15
- package/dist/patterns.js +0 -5
- package/dist/presets.d.ts +0 -82
- package/dist/presets.js +0 -81
- package/dist/primitives.d.ts +0 -22
- package/dist/primitives.js +0 -58
- package/dist/request/RequestCard.d.ts +0 -34
- package/dist/request/RequestCard.js +0 -101
- package/dist/request/approval/ApprovalPreview.d.ts +0 -5
- package/dist/request/approval/ApprovalPreview.js +0 -27
- package/dist/request/approval/shapes.d.ts +0 -32
- package/dist/request/approval/shapes.js +0 -68
- package/dist/request/apps.d.ts +0 -11
- package/dist/request/apps.js +0 -27
- package/dist/request/cards.d.ts +0 -12
- package/dist/request/cards.js +0 -24
- package/dist/request/deliver.d.ts +0 -12
- package/dist/request/deliver.js +0 -21
- package/dist/request/handOver.d.ts +0 -18
- package/dist/request/handOver.js +0 -33
- package/dist/request/kinds/Approval.d.ts +0 -3
- package/dist/request/kinds/Approval.js +0 -9
- package/dist/request/kinds/Choice.d.ts +0 -3
- package/dist/request/kinds/Choice.js +0 -8
- package/dist/request/kinds/Connect.d.ts +0 -9
- package/dist/request/kinds/Connect.js +0 -119
- package/dist/request/kinds/FreeText.d.ts +0 -3
- package/dist/request/kinds/FreeText.js +0 -20
- package/dist/request/kinds/HandOver.d.ts +0 -13
- package/dist/request/kinds/HandOver.js +0 -20
- package/dist/request/kinds/Secret.d.ts +0 -7
- package/dist/request/kinds/Secret.js +0 -49
- package/dist/request/kinds/Upload.d.ts +0 -6
- package/dist/request/kinds/Upload.js +0 -47
- package/dist/request/types.d.ts +0 -83
- package/dist/request/types.js +0 -1
- package/dist/safeUrl.d.ts +0 -6
- package/dist/safeUrl.js +0 -8
- package/dist/stream/builder.d.ts +0 -176
- package/dist/stream/builder.js +0 -202
- package/dist/stream/reduce.d.ts +0 -51
- package/dist/stream/reduce.js +0 -58
- package/dist/stream/untilAborted.d.ts +0 -7
- package/dist/stream/untilAborted.js +0 -32
- package/dist/stream/useRunStream.d.ts +0 -26
- package/dist/stream/useRunStream.js +0 -137
- package/dist/styles.css +0 -2318
- package/dist/surface/HostNode.d.ts +0 -14
- package/dist/surface/HostNode.js +0 -30
- package/dist/surface/Node.d.ts +0 -7
- package/dist/surface/Node.js +0 -49
- package/dist/surface/SurfaceBoundary.d.ts +0 -26
- package/dist/surface/SurfaceBoundary.js +0 -20
- package/dist/surface/bindings.d.ts +0 -14
- package/dist/surface/bindings.js +0 -37
- package/dist/surface/check.d.ts +0 -27
- package/dist/surface/check.js +0 -102
- package/dist/surface/format.d.ts +0 -10
- package/dist/surface/format.js +0 -32
- package/dist/surface/hosts.d.ts +0 -6
- package/dist/surface/hosts.js +0 -11
- package/dist/surface/scene.d.ts +0 -21
- package/dist/surface/scene.js +0 -8
- package/dist/surface/templates/Browser.d.ts +0 -6
- package/dist/surface/templates/Browser.js +0 -11
- package/dist/surface/templates/Chart.d.ts +0 -6
- package/dist/surface/templates/Chart.js +0 -13
- package/dist/surface/templates/Choices.d.ts +0 -3
- package/dist/surface/templates/Choices.js +0 -12
- package/dist/surface/templates/Form.d.ts +0 -3
- package/dist/surface/templates/Form.js +0 -44
- package/dist/surface/templates/KeyValue.d.ts +0 -3
- package/dist/surface/templates/KeyValue.js +0 -7
- package/dist/surface/templates/Layout.d.ts +0 -5
- package/dist/surface/templates/Layout.js +0 -16
- package/dist/surface/templates/Live.d.ts +0 -6
- package/dist/surface/templates/Live.js +0 -9
- package/dist/surface/templates/Media.d.ts +0 -5
- package/dist/surface/templates/Media.js +0 -13
- package/dist/surface/templates/Slots.d.ts +0 -3
- package/dist/surface/templates/Slots.js +0 -19
- package/dist/surface/templates/Table.d.ts +0 -3
- package/dist/surface/templates/Table.js +0 -12
- package/dist/surface/templates/Text.d.ts +0 -4
- package/dist/surface/templates/Text.js +0 -15
- package/dist/surface/templates/index.d.ts +0 -7
- package/dist/surface/templates/index.js +0 -32
- package/dist/surface/types.d.ts +0 -68
- package/dist/surface/types.js +0 -6
- package/dist/theme.d.ts +0 -62
- package/dist/theme.js +0 -9
- package/dist/useTokens.d.ts +0 -7
- package/dist/useTokens.js +0 -41
- package/dist/voice/VoiceWindow.d.ts +0 -18
- package/dist/voice/VoiceWindow.js +0 -35
- package/dist/voice/index.d.ts +0 -13
- package/dist/voice/index.js +0 -12
- package/dist/voice/meter.d.ts +0 -16
- package/dist/voice/meter.js +0 -52
- package/dist/voice/orbColors.d.ts +0 -16
- package/dist/voice/orbColors.js +0 -75
- package/dist/voice/pushable.d.ts +0 -16
- package/dist/voice/pushable.js +0 -56
- package/dist/voice/useDictation.d.ts +0 -24
- package/dist/voice/useDictation.js +0 -60
- package/dist/voice/useReducedMotion.d.ts +0 -5
- package/dist/voice/useVoice.d.ts +0 -70
- package/dist/voice/useVoice.js +0 -197
- package/dist/voice/useVoicePrimitives.d.ts +0 -7
- package/dist/voice/useVoicePrimitives.js +0 -11
- package/dist/voice/voice.d.ts +0 -55
- package/dist/voice/voice.js +0 -9
- package/dist/voice/webSpeech.d.ts +0 -33
- package/dist/voice/webSpeech.js +0 -258
- package/dist/widget.js.map +0 -1
- package/dist/windows/AgentSpace.d.ts +0 -78
- package/dist/windows/AgentSpace.js +0 -135
- package/dist/windows/Captions.d.ts +0 -13
- package/dist/windows/Captions.js +0 -22
- package/dist/windows/Dock.d.ts +0 -37
- package/dist/windows/Dock.js +0 -22
- package/dist/windows/Journal.d.ts +0 -15
- package/dist/windows/Journal.js +0 -19
- package/dist/windows/KindMark.d.ts +0 -7
- package/dist/windows/KindMark.js +0 -31
- package/dist/windows/Pending.d.ts +0 -8
- package/dist/windows/Pending.js +0 -17
- package/dist/windows/Stage.d.ts +0 -18
- package/dist/windows/Stage.js +0 -21
- package/dist/windows/StatusLabel.d.ts +0 -9
- package/dist/windows/StatusLabel.js +0 -7
- package/dist/windows/Strip.d.ts +0 -17
- package/dist/windows/Strip.js +0 -42
- package/dist/windows/SurfaceWindow.d.ts +0 -20
- package/dist/windows/SurfaceWindow.js +0 -12
- package/dist/windows/WindowFrame.d.ts +0 -23
- package/dist/windows/WindowFrame.js +0 -22
- package/dist/windows/hearing.d.ts +0 -11
- package/dist/windows/hearing.js +0 -26
- package/dist/windows/kinds.d.ts +0 -47
- package/dist/windows/kinds.js +0 -28
- package/dist/windows/reduce.d.ts +0 -98
- package/dist/windows/reduce.js +0 -151
- package/dist/windows/registry.d.ts +0 -18
- package/dist/windows/registry.js +0 -61
- package/dist/windows/reveal.d.ts +0 -9
- package/dist/windows/reveal.js +0 -6
- package/dist/windows/space.d.ts +0 -21
- package/dist/windows/space.js +0 -6
- package/dist/windows/status.d.ts +0 -11
- package/dist/windows/status.js +0 -30
- package/dist/windows/types.d.ts +0 -15
- package/dist/windows/types.js +0 -1
- package/dist/windows/useLoaded.d.ts +0 -44
- package/dist/windows/useLoaded.js +0 -58
- package/dist/windows/useUnread.d.ts +0 -7
- package/dist/windows/useUnread.js +0 -21
- package/dist/windows/useWindows.d.ts +0 -70
- package/dist/windows/useWindows.js +0 -60
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentFace.js","names":[],"sources":["../src/useAgentFace.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport type { Client } from \"./client\";\nimport type { AgentFace } from \"./types\";\n\n/** The agent's face as it is read: null until it lands, with what the read threw if it failed. */\nexport interface FaceRead {\n face: AgentFace | null;\n loading: boolean;\n error: unknown;\n}\n\n/** A read that landed, and for which agent: one for another is not this one's. */\ninterface Landed {\n client: Client;\n agentId: string;\n face: AgentFace | null;\n error: unknown;\n}\n\n/**\n * What a person may know of agent `agentId` (`GET /agents/{id}/face`): its name, its role, the\n * mark of its work and whether it takes calls, read once for each agent. Until it lands (and\n * while another agent's is read) there is none; one that lands for an agent no longer asked\n * about is dropped.\n */\nexport function useAgentFace(client: Client, agentId: string): FaceRead {\n const [landed, setLanded] = useState<Landed | null>(null);\n useEffect(() => {\n let asked = true;\n client.agents.face(agentId).then(\n (face) => {\n if (asked) setLanded({ client, agentId, face, error: null });\n },\n (error: unknown) => {\n if (asked) setLanded({ client, agentId, face: null, error });\n },\n );\n return () => {\n asked = false;\n };\n }, [client, agentId]);\n const current = landed !== null && landed.client === client && landed.agentId === agentId;\n return current\n ? { face: landed.face, loading: false, error: landed.error }\n : { face: null, loading: true, error: null };\n}\n"],"mappings":";;;;;;;;AA0BA,SAAgB,aAAa,QAAgB,SAA2B;CACtE,MAAM,CAAC,QAAQ,aAAa,SAAwB,IAAI;CACxD,gBAAgB;EACd,IAAI,QAAQ;EACZ,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,MACzB,SAAS;GACR,IAAI,OAAO,UAAU;IAAE;IAAQ;IAAS;IAAM,OAAO;GAAK,CAAC;EAC7D,IACC,UAAmB;GAClB,IAAI,OAAO,UAAU;IAAE;IAAQ;IAAS,MAAM;IAAM;GAAM,CAAC;EAC7D,CACF;EACA,aAAa;GACX,QAAQ;EACV;CACF,GAAG,CAAC,QAAQ,OAAO,CAAC;CAEpB,OADgB,WAAW,QAAQ,OAAO,WAAW,UAAU,OAAO,YAAY,UAE9E;EAAE,MAAM,OAAO;EAAM,SAAS;EAAO,OAAO,OAAO;CAAM,IACzD;EAAE,MAAM;EAAM,SAAS;EAAM,OAAO;CAAK;AAC/C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CallState } from "./call.js";
|
|
2
|
+
import { RefObject } from "react";
|
|
3
|
+
//#region src/useCall.d.ts
|
|
4
|
+
/** Where a call is joined: LiveKit's address, and a token for the call's room. */
|
|
5
|
+
export interface CallJoin {
|
|
6
|
+
url: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}
|
|
9
|
+
/** How loud each side of the call is right now, from 0 to 1, read when asked (every frame). */
|
|
10
|
+
export interface CallMeter {
|
|
11
|
+
agent: () => number;
|
|
12
|
+
person: () => number;
|
|
13
|
+
}
|
|
14
|
+
/** A call, live: where it stands, how loud it is, and what the person can do on it. */
|
|
15
|
+
export interface Call {
|
|
16
|
+
state: CallState;
|
|
17
|
+
meter: CallMeter;
|
|
18
|
+
/** Turns the microphone off or on; the other way from now when not said. */
|
|
19
|
+
mute: (muted?: boolean) => void;
|
|
20
|
+
/** Ends the call, for both sides. */
|
|
21
|
+
hangUp: () => void;
|
|
22
|
+
/** Lets the agent's voice play where the browser held it until the person pressed something. */
|
|
23
|
+
hear: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A voice call through LiveKit, for as long as the component is mounted: the microphone first
|
|
27
|
+
* (a person who can't be heard has no call, and no call is made for them), then `connect` for
|
|
28
|
+
* where to join (the API's refusal says why there is no call), the room, and the microphone
|
|
29
|
+
* published into it. The agent's voice plays as it comes (its `<audio>` goes into `sink`), and
|
|
30
|
+
* the call is on once the agent joins; its state is what the agent says it is doing. It ends when
|
|
31
|
+
* the person hangs up, when the room closes (the agent's goodbye, or its longest time: the API
|
|
32
|
+
* says which), when the line goes, or when no agent comes. Unmounting hangs up. `connect` is read
|
|
33
|
+
* once, when the call starts.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useCall(connect: () => Promise<CallJoin>, { sink }: {
|
|
36
|
+
sink: RefObject<HTMLElement | null>;
|
|
37
|
+
}): Call;
|
|
38
|
+
//#endregion
|
|
39
|
+
//# sourceMappingURL=useCall.d.ts.map
|
package/dist/useCall.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { CALL_START, activityOf, callProblemOf, callReducer, endedBy, loudness, refusalOf } from "./call.js";
|
|
2
|
+
import { useEffect, useReducer, useRef, useState } from "react";
|
|
3
|
+
import { DisconnectReason, Room, RoomEvent, Track, createAudioAnalyser, createLocalAudioTrack } from "livekit-client";
|
|
4
|
+
//#region src/useCall.ts
|
|
5
|
+
/** How long a room may wait for its agent before the call is given up as unanswered. */
|
|
6
|
+
const ANSWER_WITHIN = 2e4;
|
|
7
|
+
/** How long the agent may be gone from the room before the call counts as dropped (its own end
|
|
8
|
+
* closes the room for everyone, which says why, within this). */
|
|
9
|
+
const GONE_FOR = 1500;
|
|
10
|
+
/** What LiveKit's agents say they are doing, on their participant. */
|
|
11
|
+
const AGENT_STATE = "lk.agent.state";
|
|
12
|
+
/** A voice, cleaned as a phone call's is. */
|
|
13
|
+
const CAPTURE = {
|
|
14
|
+
echoCancellation: true,
|
|
15
|
+
noiseSuppression: true,
|
|
16
|
+
autoGainControl: true
|
|
17
|
+
};
|
|
18
|
+
/** Speech, measured: a wide window of loudness, smoothed a little by the analyser itself. */
|
|
19
|
+
const MEASURE = {
|
|
20
|
+
fftSize: 512,
|
|
21
|
+
smoothingTimeConstant: .5,
|
|
22
|
+
minDecibels: -90,
|
|
23
|
+
maxDecibels: -25
|
|
24
|
+
};
|
|
25
|
+
const SILENT = () => 0;
|
|
26
|
+
/**
|
|
27
|
+
* A voice call through LiveKit, for as long as the component is mounted: the microphone first
|
|
28
|
+
* (a person who can't be heard has no call, and no call is made for them), then `connect` for
|
|
29
|
+
* where to join (the API's refusal says why there is no call), the room, and the microphone
|
|
30
|
+
* published into it. The agent's voice plays as it comes (its `<audio>` goes into `sink`), and
|
|
31
|
+
* the call is on once the agent joins; its state is what the agent says it is doing. It ends when
|
|
32
|
+
* the person hangs up, when the room closes (the agent's goodbye, or its longest time: the API
|
|
33
|
+
* says which), when the line goes, or when no agent comes. Unmounting hangs up. `connect` is read
|
|
34
|
+
* once, when the call starts.
|
|
35
|
+
*/
|
|
36
|
+
function useCall(connect, { sink }) {
|
|
37
|
+
const [state, dispatch] = useReducer(callReducer, CALL_START);
|
|
38
|
+
const given = useRef(connect);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
given.current = connect;
|
|
41
|
+
});
|
|
42
|
+
const line = useRef({
|
|
43
|
+
room: null,
|
|
44
|
+
mic: null,
|
|
45
|
+
hangUp: () => void 0
|
|
46
|
+
});
|
|
47
|
+
const readers = useRef({
|
|
48
|
+
agent: SILENT,
|
|
49
|
+
person: SILENT
|
|
50
|
+
});
|
|
51
|
+
const [meter] = useState(() => ({
|
|
52
|
+
agent: () => readers.current.agent(),
|
|
53
|
+
person: () => readers.current.person()
|
|
54
|
+
}));
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const room = new Room({ disconnectOnPageLeave: true });
|
|
57
|
+
let mic = null;
|
|
58
|
+
let gone = false;
|
|
59
|
+
let hungUp = false;
|
|
60
|
+
let joined = false;
|
|
61
|
+
let answeredAt = null;
|
|
62
|
+
let unanswered;
|
|
63
|
+
let away;
|
|
64
|
+
const releases = [];
|
|
65
|
+
const stopped = () => gone || hungUp;
|
|
66
|
+
/**
|
|
67
|
+
* Lets go of everything the call holds: the timers, the voices playing and the meters, the
|
|
68
|
+
* microphone, the room.
|
|
69
|
+
*/
|
|
70
|
+
const release = () => {
|
|
71
|
+
clearTimeout(unanswered);
|
|
72
|
+
clearTimeout(away);
|
|
73
|
+
for (const each of releases.splice(0)) each();
|
|
74
|
+
readers.current = {
|
|
75
|
+
agent: SILENT,
|
|
76
|
+
person: SILENT
|
|
77
|
+
};
|
|
78
|
+
mic?.stop();
|
|
79
|
+
room.disconnect();
|
|
80
|
+
};
|
|
81
|
+
const fail = (problem) => {
|
|
82
|
+
if (gone) return;
|
|
83
|
+
dispatch({
|
|
84
|
+
type: "failed",
|
|
85
|
+
problem
|
|
86
|
+
});
|
|
87
|
+
release();
|
|
88
|
+
};
|
|
89
|
+
/** A meter over a track, and its release with the call. */
|
|
90
|
+
const measure = (track) => {
|
|
91
|
+
const analyser = createAudioAnalyser(track, MEASURE);
|
|
92
|
+
releases.push(() => {
|
|
93
|
+
analyser.cleanup();
|
|
94
|
+
});
|
|
95
|
+
return () => loudness(analyser.calculateVolume());
|
|
96
|
+
};
|
|
97
|
+
const answer = (agent) => {
|
|
98
|
+
clearTimeout(unanswered);
|
|
99
|
+
clearTimeout(away);
|
|
100
|
+
if (answeredAt === null) {
|
|
101
|
+
answeredAt = Date.now();
|
|
102
|
+
dispatch({
|
|
103
|
+
type: "answered",
|
|
104
|
+
at: answeredAt
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
dispatch({
|
|
108
|
+
type: "agent",
|
|
109
|
+
activity: activityOf(agent.attributes[AGENT_STATE])
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
room.on(RoomEvent.ParticipantConnected, (participant) => {
|
|
113
|
+
if (participant.isAgent) answer(participant);
|
|
114
|
+
}).on(RoomEvent.ParticipantAttributesChanged, (_, participant) => {
|
|
115
|
+
if (!participant.isAgent) return;
|
|
116
|
+
dispatch({
|
|
117
|
+
type: "agent",
|
|
118
|
+
activity: activityOf(participant.attributes[AGENT_STATE])
|
|
119
|
+
});
|
|
120
|
+
}).on(RoomEvent.ActiveSpeakersChanged, (speakers) => {
|
|
121
|
+
dispatch({
|
|
122
|
+
type: "speaking",
|
|
123
|
+
speaking: speakers.some((each) => each.isAgent)
|
|
124
|
+
});
|
|
125
|
+
}).on(RoomEvent.TrackSubscribed, (track, _, participant) => {
|
|
126
|
+
if (track.kind !== Track.Kind.Audio) return;
|
|
127
|
+
const voice = track.attach();
|
|
128
|
+
sink.current?.append(voice);
|
|
129
|
+
releases.push(() => {
|
|
130
|
+
track.detach(voice);
|
|
131
|
+
voice.remove();
|
|
132
|
+
});
|
|
133
|
+
if (participant.isAgent) readers.current.agent = measure(track);
|
|
134
|
+
}).on(RoomEvent.TrackUnsubscribed, (track) => {
|
|
135
|
+
for (const element of track.detach()) element.remove();
|
|
136
|
+
}).on(RoomEvent.AudioPlaybackStatusChanged, () => {
|
|
137
|
+
dispatch({
|
|
138
|
+
type: "silenced",
|
|
139
|
+
silenced: !room.canPlaybackAudio
|
|
140
|
+
});
|
|
141
|
+
}).on(RoomEvent.Reconnecting, () => {
|
|
142
|
+
dispatch({
|
|
143
|
+
type: "reconnecting",
|
|
144
|
+
reconnecting: true
|
|
145
|
+
});
|
|
146
|
+
}).on(RoomEvent.Reconnected, () => {
|
|
147
|
+
dispatch({
|
|
148
|
+
type: "reconnecting",
|
|
149
|
+
reconnecting: false
|
|
150
|
+
});
|
|
151
|
+
}).on(RoomEvent.ParticipantDisconnected, (participant) => {
|
|
152
|
+
if (!participant.isAgent) return;
|
|
153
|
+
away = setTimeout(() => {
|
|
154
|
+
if (gone) return;
|
|
155
|
+
dispatch({
|
|
156
|
+
type: "ended",
|
|
157
|
+
by: "dropped",
|
|
158
|
+
at: Date.now()
|
|
159
|
+
});
|
|
160
|
+
release();
|
|
161
|
+
}, GONE_FOR);
|
|
162
|
+
}).on(RoomEvent.Disconnected, (reason) => {
|
|
163
|
+
if (gone || !joined) return;
|
|
164
|
+
const name = reason === void 0 ? void 0 : DisconnectReason[reason];
|
|
165
|
+
dispatch({
|
|
166
|
+
type: "ended",
|
|
167
|
+
by: endedBy(name, hungUp),
|
|
168
|
+
at: Date.now()
|
|
169
|
+
});
|
|
170
|
+
release();
|
|
171
|
+
});
|
|
172
|
+
const start = async () => {
|
|
173
|
+
if (typeof navigator === "undefined" || !navigator.mediaDevices?.getUserMedia) {
|
|
174
|
+
fail("unsupported");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
mic = await createLocalAudioTrack(CAPTURE);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
fail(callProblemOf(error));
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (stopped()) return release();
|
|
184
|
+
line.current.mic = mic;
|
|
185
|
+
let where;
|
|
186
|
+
try {
|
|
187
|
+
where = await given.current();
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (stopped()) return release();
|
|
190
|
+
fail(refusalOf(error));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (stopped()) return release();
|
|
194
|
+
try {
|
|
195
|
+
await room.connect(where.url, where.token);
|
|
196
|
+
if (stopped()) return release();
|
|
197
|
+
await room.localParticipant.publishTrack(mic, { source: Track.Source.Microphone });
|
|
198
|
+
} catch {
|
|
199
|
+
if (stopped()) return release();
|
|
200
|
+
fail("failed");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (stopped()) return release();
|
|
204
|
+
joined = true;
|
|
205
|
+
readers.current.person = measure(mic);
|
|
206
|
+
dispatch({ type: "ringing" });
|
|
207
|
+
dispatch({
|
|
208
|
+
type: "silenced",
|
|
209
|
+
silenced: !room.canPlaybackAudio
|
|
210
|
+
});
|
|
211
|
+
const agent = [...room.remoteParticipants.values()].find((each) => each.isAgent);
|
|
212
|
+
if (agent) answer(agent);
|
|
213
|
+
else unanswered = setTimeout(() => fail("unanswered"), ANSWER_WITHIN);
|
|
214
|
+
};
|
|
215
|
+
line.current = {
|
|
216
|
+
room,
|
|
217
|
+
mic: null,
|
|
218
|
+
hangUp: () => {
|
|
219
|
+
if (gone || hungUp) return;
|
|
220
|
+
hungUp = true;
|
|
221
|
+
dispatch({
|
|
222
|
+
type: "ended",
|
|
223
|
+
by: "person",
|
|
224
|
+
at: Date.now()
|
|
225
|
+
});
|
|
226
|
+
release();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
start();
|
|
230
|
+
return () => {
|
|
231
|
+
gone = true;
|
|
232
|
+
release();
|
|
233
|
+
room.removeAllListeners();
|
|
234
|
+
line.current = {
|
|
235
|
+
room: null,
|
|
236
|
+
mic: null,
|
|
237
|
+
hangUp: () => void 0
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
}, [sink]);
|
|
241
|
+
return {
|
|
242
|
+
state,
|
|
243
|
+
meter,
|
|
244
|
+
mute: (muted) => {
|
|
245
|
+
const { mic } = line.current;
|
|
246
|
+
if (mic === null || state.stage === "over") return;
|
|
247
|
+
const next = muted ?? !state.muted;
|
|
248
|
+
(next ? mic.mute() : mic.unmute()).then(() => {
|
|
249
|
+
dispatch({
|
|
250
|
+
type: "muted",
|
|
251
|
+
muted: next
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
hangUp: () => {
|
|
256
|
+
line.current.hangUp();
|
|
257
|
+
},
|
|
258
|
+
hear: () => {
|
|
259
|
+
const { room } = line.current;
|
|
260
|
+
if (room === null) return;
|
|
261
|
+
room.startAudio().then(() => {
|
|
262
|
+
dispatch({
|
|
263
|
+
type: "silenced",
|
|
264
|
+
silenced: !room.canPlaybackAudio
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
271
|
+
export { useCall };
|
|
272
|
+
|
|
273
|
+
//# sourceMappingURL=useCall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCall.js","names":[],"sources":["../src/useCall.ts"],"sourcesContent":["import {\n createAudioAnalyser,\n createLocalAudioTrack,\n DisconnectReason,\n Room,\n RoomEvent,\n Track,\n type AudioAnalyserOptions,\n type LocalAudioTrack,\n type LocalTrack,\n type Participant,\n type RemoteAudioTrack,\n} from \"livekit-client\";\nimport { useEffect, useReducer, useRef, useState, type RefObject } from \"react\";\n\nimport {\n activityOf,\n CALL_START,\n callReducer,\n endedBy,\n loudness,\n callProblemOf,\n refusalOf,\n type CallProblem,\n type CallState,\n} from \"./call\";\n\n/** Where a call is joined: LiveKit's address, and a token for the call's room. */\nexport interface CallJoin {\n url: string;\n token: string;\n}\n\n/** How loud each side of the call is right now, from 0 to 1, read when asked (every frame). */\nexport interface CallMeter {\n agent: () => number;\n person: () => number;\n}\n\n/** A call, live: where it stands, how loud it is, and what the person can do on it. */\nexport interface Call {\n state: CallState;\n meter: CallMeter;\n /** Turns the microphone off or on; the other way from now when not said. */\n mute: (muted?: boolean) => void;\n /** Ends the call, for both sides. */\n hangUp: () => void;\n /** Lets the agent's voice play where the browser held it until the person pressed something. */\n hear: () => void;\n}\n\n/** How long a room may wait for its agent before the call is given up as unanswered. */\nconst ANSWER_WITHIN = 20_000;\n/** How long the agent may be gone from the room before the call counts as dropped (its own end\n * closes the room for everyone, which says why, within this). */\nconst GONE_FOR = 1_500;\n/** What LiveKit's agents say they are doing, on their participant. */\nconst AGENT_STATE = \"lk.agent.state\";\n/** A voice, cleaned as a phone call's is. */\nconst CAPTURE = { echoCancellation: true, noiseSuppression: true, autoGainControl: true };\n/** Speech, measured: a wide window of loudness, smoothed a little by the analyser itself. */\nconst MEASURE: AudioAnalyserOptions = {\n fftSize: 512,\n smoothingTimeConstant: 0.5,\n minDecibels: -90,\n maxDecibels: -25,\n};\nconst SILENT = (): number => 0;\n\n/**\n * A voice call through LiveKit, for as long as the component is mounted: the microphone first\n * (a person who can't be heard has no call, and no call is made for them), then `connect` for\n * where to join (the API's refusal says why there is no call), the room, and the microphone\n * published into it. The agent's voice plays as it comes (its `<audio>` goes into `sink`), and\n * the call is on once the agent joins; its state is what the agent says it is doing. It ends when\n * the person hangs up, when the room closes (the agent's goodbye, or its longest time: the API\n * says which), when the line goes, or when no agent comes. Unmounting hangs up. `connect` is read\n * once, when the call starts.\n */\nexport function useCall(\n connect: () => Promise<CallJoin>,\n { sink }: { sink: RefObject<HTMLElement | null> },\n): Call {\n const [state, dispatch] = useReducer(callReducer, CALL_START);\n const given = useRef(connect);\n useEffect(() => {\n given.current = connect;\n });\n // What the person's buttons reach into: the room and the microphone, once they exist.\n const line = useRef<{ room: Room | null; mic: LocalAudioTrack | null; hangUp: () => void }>({\n room: null,\n mic: null,\n hangUp: () => undefined,\n });\n // The meters read whatever track each side has now; silence until it has one.\n const readers = useRef<CallMeter>({ agent: SILENT, person: SILENT });\n const [meter] = useState<CallMeter>(() => ({\n agent: () => readers.current.agent(),\n person: () => readers.current.person(),\n }));\n\n useEffect(() => {\n const room = new Room({ disconnectOnPageLeave: true });\n let mic: LocalAudioTrack | null = null;\n let gone = false;\n let hungUp = false;\n // In the room with the microphone published: from here the room's own end is the call's.\n let joined = false;\n let answeredAt: number | null = null;\n let unanswered: ReturnType<typeof setTimeout> | undefined;\n let away: ReturnType<typeof setTimeout> | undefined;\n const releases: (() => void)[] = [];\n const stopped = () => gone || hungUp;\n\n /**\n * Lets go of everything the call holds: the timers, the voices playing and the meters, the\n * microphone, the room.\n */\n const release = () => {\n clearTimeout(unanswered);\n clearTimeout(away);\n for (const each of releases.splice(0)) each();\n readers.current = { agent: SILENT, person: SILENT };\n mic?.stop();\n void room.disconnect();\n };\n\n const fail = (problem: CallProblem) => {\n if (gone) return;\n dispatch({ type: \"failed\", problem });\n release();\n };\n\n /** A meter over a track, and its release with the call. */\n const measure = (track: LocalAudioTrack | RemoteAudioTrack): (() => number) => {\n const analyser = createAudioAnalyser(track, MEASURE);\n releases.push(() => {\n void analyser.cleanup();\n });\n return () => loudness(analyser.calculateVolume());\n };\n\n const answer = (agent: Participant) => {\n clearTimeout(unanswered);\n clearTimeout(away);\n if (answeredAt === null) {\n answeredAt = Date.now();\n dispatch({ type: \"answered\", at: answeredAt });\n }\n dispatch({ type: \"agent\", activity: activityOf(agent.attributes[AGENT_STATE]) });\n };\n\n room\n .on(RoomEvent.ParticipantConnected, (participant) => {\n if (participant.isAgent) answer(participant);\n })\n .on(RoomEvent.ParticipantAttributesChanged, (_, participant) => {\n if (!participant.isAgent) return;\n dispatch({ type: \"agent\", activity: activityOf(participant.attributes[AGENT_STATE]) });\n })\n .on(RoomEvent.ActiveSpeakersChanged, (speakers) => {\n dispatch({ type: \"speaking\", speaking: speakers.some((each) => each.isAgent) });\n })\n .on(RoomEvent.TrackSubscribed, (track, _, participant) => {\n if (track.kind !== Track.Kind.Audio) return;\n const voice = track.attach();\n sink.current?.append(voice);\n // A room left from here says nothing of its tracks: the call lets go of each itself.\n releases.push(() => {\n track.detach(voice);\n voice.remove();\n });\n if (participant.isAgent) readers.current.agent = measure(track as RemoteAudioTrack);\n })\n .on(RoomEvent.TrackUnsubscribed, (track) => {\n for (const element of track.detach()) element.remove();\n })\n .on(RoomEvent.AudioPlaybackStatusChanged, () => {\n dispatch({ type: \"silenced\", silenced: !room.canPlaybackAudio });\n })\n .on(RoomEvent.Reconnecting, () => {\n dispatch({ type: \"reconnecting\", reconnecting: true });\n })\n .on(RoomEvent.Reconnected, () => {\n dispatch({ type: \"reconnecting\", reconnecting: false });\n })\n .on(RoomEvent.ParticipantDisconnected, (participant) => {\n // The agent left without closing the room: its side fell. A goodbye or the longest time\n // closes the room, whose disconnect comes first and says so.\n if (!participant.isAgent) return;\n away = setTimeout(() => {\n if (gone) return;\n dispatch({ type: \"ended\", by: \"dropped\", at: Date.now() });\n release();\n }, GONE_FOR);\n })\n .on(RoomEvent.Disconnected, (reason) => {\n // Before the call was joined, its start says what went wrong.\n if (gone || !joined) return;\n const name = reason === undefined ? undefined : DisconnectReason[reason];\n dispatch({ type: \"ended\", by: endedBy(name, hungUp), at: Date.now() });\n release();\n });\n\n const start = async () => {\n if (typeof navigator === \"undefined\" || !navigator.mediaDevices?.getUserMedia) {\n fail(\"unsupported\");\n return;\n }\n try {\n mic = await createLocalAudioTrack(CAPTURE);\n } catch (error) {\n fail(callProblemOf(error));\n return;\n }\n if (stopped()) return release();\n line.current.mic = mic;\n let where: CallJoin;\n try {\n where = await given.current();\n } catch (error) {\n if (stopped()) return release();\n fail(refusalOf(error));\n return;\n }\n if (stopped()) return release();\n try {\n await room.connect(where.url, where.token);\n if (stopped()) return release();\n // LiveKit's own types disagree under `exactOptionalPropertyTypes`: the track is one.\n await room.localParticipant.publishTrack(mic as LocalTrack, {\n source: Track.Source.Microphone,\n });\n } catch {\n if (stopped()) return release();\n fail(\"failed\");\n return;\n }\n if (stopped()) return release();\n joined = true;\n readers.current.person = measure(mic);\n dispatch({ type: \"ringing\" });\n dispatch({ type: \"silenced\", silenced: !room.canPlaybackAudio });\n const agent = [...room.remoteParticipants.values()].find((each) => each.isAgent);\n if (agent) answer(agent);\n else unanswered = setTimeout(() => fail(\"unanswered\"), ANSWER_WITHIN);\n };\n\n line.current = {\n room,\n mic: null,\n hangUp: () => {\n if (gone || hungUp) return;\n hungUp = true;\n dispatch({ type: \"ended\", by: \"person\", at: Date.now() });\n release();\n },\n };\n void start();\n\n return () => {\n gone = true;\n release();\n room.removeAllListeners();\n line.current = { room: null, mic: null, hangUp: () => undefined };\n };\n // One call per mount: `connect` is read from `given` when it is needed.\n }, [sink]);\n\n return {\n state,\n meter,\n mute: (muted) => {\n const { mic } = line.current;\n if (mic === null || state.stage === \"over\") return;\n const next = muted ?? !state.muted;\n void (next ? mic.mute() : mic.unmute()).then(() => {\n dispatch({ type: \"muted\", muted: next });\n });\n },\n hangUp: () => {\n line.current.hangUp();\n },\n hear: () => {\n const { room } = line.current;\n if (room === null) return;\n void room.startAudio().then(() => {\n dispatch({ type: \"silenced\", silenced: !room.canPlaybackAudio });\n });\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Action, BrowserControl, BrowserFrame, BrowserInput, BrowserState, Handover, Holder, Message, ToolCall } from "./types.js";
|
|
2
|
+
import { Client } from "./client.js";
|
|
3
|
+
//#region src/useConversation.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runs one of the host's own tools in the page, for the agent: what it resolves to goes back as
|
|
6
|
+
* the tool's output, what it rejects with as why it failed (an error's message).
|
|
7
|
+
*/
|
|
8
|
+
export type ToolHandler = (call: ToolCall) => Promise<unknown>;
|
|
9
|
+
/** What the page answers a tool of the host's when it runs none (no `onTool`), for the agent. */
|
|
10
|
+
export declare const NO_TOOL = "This page can't do that";
|
|
11
|
+
/** A conversation, live: its messages, where its turn stands, and the ways to speak. */
|
|
12
|
+
export interface LiveConversation {
|
|
13
|
+
messages: Message[];
|
|
14
|
+
draft: string;
|
|
15
|
+
pending: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The step the turn waits on: a surface to answer, or an action the person allows (its
|
|
18
|
+
* `request`, `decides: "person"`; `act` on its id with `approve` or `decline`). Nothing else
|
|
19
|
+
* goes until the person acts. A yes the business gives holds nothing.
|
|
20
|
+
*/
|
|
21
|
+
awaiting: string | null;
|
|
22
|
+
open: boolean;
|
|
23
|
+
/** Until the history has landed once. */
|
|
24
|
+
loading: boolean;
|
|
25
|
+
/** What the last history read threw, if it failed. */
|
|
26
|
+
error: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Says something: words, the ids of files uploaded to the conversation for it, or both; false
|
|
29
|
+
* when it cannot go now: nothing to say, a turn running or waiting, the socket closed.
|
|
30
|
+
*/
|
|
31
|
+
say: (text: string, files?: readonly string[]) => boolean;
|
|
32
|
+
/** What the person did on a surface; false when the socket is closed. */
|
|
33
|
+
act: (action: Action) => boolean;
|
|
34
|
+
/** Stops the reply on its way; false when the socket is closed. */
|
|
35
|
+
stop: () => boolean;
|
|
36
|
+
/** The conversation's browser while it is open: where it is, who holds it. */
|
|
37
|
+
browser: BrowserState | null;
|
|
38
|
+
/** Hears each picture of the browser's screen, the latest at once; returns how to stop. */
|
|
39
|
+
watchScreen: (listener: (frame: BrowserFrame) => void) => () => void;
|
|
40
|
+
/** Takes the browser from the agent, or gives it back; false when the socket is closed. */
|
|
41
|
+
control: (to: BrowserControl) => boolean;
|
|
42
|
+
/** Closes the browser now (it stops being billed); false when the socket is closed. */
|
|
43
|
+
closeBrowser: () => boolean;
|
|
44
|
+
/** What the person does on the browser's screen while they hold it. */
|
|
45
|
+
input: (event: BrowserInput) => boolean;
|
|
46
|
+
/** Who answers it now: its agent, a person of the business, or nobody; null until the history lands. */
|
|
47
|
+
holder: Holder | null;
|
|
48
|
+
/** Every change of who answers it, in order, kept live. */
|
|
49
|
+
handovers: Handover[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Conversation `conversationId` as the person sees it: the history, kept live by the socket.
|
|
53
|
+
* Each time the socket opens the history is read, with the socket already listening, so nothing
|
|
54
|
+
* stored can fall between the two; what came live meanwhile is kept. `onError` hears each
|
|
55
|
+
* error's code (the socket's, or `load` for a history that could not be read): the host words
|
|
56
|
+
* it, this hook shows no text; but `tool`, the page's answer to a call no longer waiting (one it
|
|
57
|
+
* answered already, told again), which is let pass (noted in development). `onHolder` hears each
|
|
58
|
+
* change of who answers it, live, for the host's own views of it; `handover` is the last change
|
|
59
|
+
* the host knows of (one it made itself, as its request answered), taken at once, so it shows
|
|
60
|
+
* whether or not the socket tells it.
|
|
61
|
+
* `onStep` hears each step the agent starts, live, by its action's name, for the host's own
|
|
62
|
+
* views of it (the builder's column, opened as the agent asks it).
|
|
63
|
+
* `onTool` runs the host's own tools the agent calls in the page (a `tool` frame), and its answer
|
|
64
|
+
* goes up (`tool_result`); each call runs once, and one told again while it waits (the socket
|
|
65
|
+
* opened anew) is answered again with what it gave. Without `onTool`, each is refused with
|
|
66
|
+
* `NO_TOOL`, so the turn never waits on a page that can't run it. One conversation per mount: key
|
|
67
|
+
* the component on the id.
|
|
68
|
+
*/
|
|
69
|
+
export declare function useConversation(client: Client, conversationId: string, { onError, onHolder, onStep, handover, onTool }?: {
|
|
70
|
+
onError?: ((code: string) => void) | undefined;
|
|
71
|
+
onHolder?: ((holder: Holder, handover: Handover) => void) | undefined;
|
|
72
|
+
onStep?: ((action: string) => void) | undefined;
|
|
73
|
+
handover?: Handover | null | undefined;
|
|
74
|
+
onTool?: ToolHandler | undefined;
|
|
75
|
+
}): LiveConversation;
|
|
76
|
+
//#endregion
|
|
77
|
+
//# sourceMappingURL=useConversation.d.ts.map
|