@celljs/ta-web 4.27.0 → 4.28.0
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/esm/browser/assistant/assistant-role.d.ts +9 -4
- package/esm/browser/assistant/assistant-role.js +17 -5
- package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
- package/esm/browser/assistant/assistant-task-util.js +12 -1
- package/esm/browser/assistant/assistant-view.js +4 -1
- package/esm/browser/assistant/assistant.d.ts +2 -1
- package/esm/browser/assistant/assistant.js +9 -7
- package/esm/browser/assistant/call-conversing.d.ts +45 -0
- package/esm/browser/assistant/call-conversing.js +91 -0
- package/esm/browser/assistant/call-face.d.ts +13 -0
- package/esm/browser/assistant/call-face.js +81 -0
- package/esm/browser/assistant/call-keeper.d.ts +8 -4
- package/esm/browser/assistant/call-keeper.js +32 -11
- package/esm/browser/assistant/call-partnering.d.ts +37 -0
- package/esm/browser/assistant/call-partnering.js +79 -0
- package/esm/browser/assistant/call-scenes.d.ts +25 -0
- package/esm/browser/assistant/call-scenes.js +82 -0
- package/esm/browser/assistant/call-screen.d.ts +3 -0
- package/esm/browser/assistant/call-screen.js +15 -0
- package/esm/browser/assistant/mic-sense.d.ts +31 -0
- package/esm/browser/assistant/mic-sense.js +119 -0
- package/esm/browser/assistant/noise-gate.d.ts +32 -0
- package/esm/browser/assistant/noise-gate.js +66 -0
- package/esm/browser/assistant/pcm-util.d.ts +10 -0
- package/esm/browser/assistant/pcm-util.js +55 -0
- package/esm/browser/assistant/read-aloud.d.ts +2 -1
- package/esm/browser/assistant/realtime-voice-protocol.d.ts +84 -0
- package/esm/browser/assistant/realtime-voice-protocol.js +40 -0
- package/esm/browser/assistant/realtime-voice.d.ts +50 -62
- package/esm/browser/assistant/realtime-voice.js +213 -134
- package/esm/browser/assistant/spoken-timeline.d.ts +27 -0
- package/esm/browser/assistant/spoken-timeline.js +49 -0
- package/esm/browser/assistant/voice-call-bar.d.ts +9 -2
- package/esm/browser/assistant/voice-call-bar.js +81 -31
- package/esm/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/esm/browser/assistant/voice-call.d.ts +16 -23
- package/esm/browser/assistant/voice-call.js +134 -117
- package/esm/browser/assistant/voice-reading.d.ts +83 -0
- package/esm/browser/assistant/voice-reading.js +150 -0
- package/esm/browser/avatar/dino-talk.d.ts +15 -0
- package/esm/browser/avatar/dino-talk.js +34 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/conversation-scroll-util.d.ts +8 -1
- package/esm/browser/components/conversation-scroll-util.js +21 -0
- package/esm/browser/components/conversation-scroll.js +10 -11
- package/esm/browser/components/gallery.js +28 -7
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/image-pull.d.ts +64 -0
- package/esm/browser/components/image-pull.js +202 -0
- package/esm/browser/components/kept-call-bar.js +2 -1
- package/esm/browser/components/lightbox.d.ts +1 -1
- package/esm/browser/components/lightbox.js +57 -2
- package/esm/browser/components/markdown.d.ts +3 -1
- package/esm/browser/components/markdown.js +8 -4
- package/esm/browser/components/partner-row.js +2 -1
- package/esm/browser/components/relay-services.d.ts +9 -3
- package/esm/browser/components/relay-services.js +73 -35
- package/esm/browser/components/session-view.js +4 -2
- package/esm/browser/components/settings-parts.js +2 -0
- package/esm/browser/components/ta-avatar.d.ts +15 -1
- package/esm/browser/components/ta-avatar.js +38 -5
- package/esm/browser/components/voice-services.js +6 -1
- package/esm/browser/extension/web-api-call.d.ts +64 -2
- package/esm/browser/extension/web-api-contributions.d.ts +1 -0
- package/esm/browser/extension/web-api-partners.d.ts +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +6 -6
- package/esm/browser/extension/web-extension-context.js +1 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +3 -1
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +2 -0
- package/esm/browser/i18n/locales.d.ts +24 -5
- package/esm/browser/i18n/messages-ja.js +25 -6
- package/esm/browser/i18n/messages-zh-tw.js +25 -6
- package/esm/browser/i18n/messages.d.ts +23 -4
- package/esm/browser/i18n/messages.js +50 -12
- package/esm/browser/markdown/code-renderers.d.ts +2 -0
- package/esm/browser/markdown/code-renderers.js +2 -0
- package/esm/browser/screen/page-answers.d.ts +2 -1
- package/esm/browser/screen/page-answers.js +7 -4
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +1 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +6 -1
- package/esm/browser/style/device.js +1 -0
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +1 -1
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +135 -57
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +8 -0
- package/esm/browser/style/video-call.d.ts +2 -0
- package/esm/browser/style/video-call.js +52 -0
- package/esm/browser/style.js +2 -0
- package/esm/browser/util/desktop.d.ts +10 -1
- package/esm/browser/util/desktop.js +10 -0
- package/esm/browser/util/image-pull.d.ts +61 -0
- package/esm/browser/util/image-pull.js +88 -0
- package/esm/browser/util/spoken.d.ts +3 -3
- package/esm/browser/util/spoken.js +4 -4
- package/esm/browser/video-call/call-camera.d.ts +59 -0
- package/esm/browser/video-call/call-camera.js +188 -0
- package/esm/browser/video-call/call-window.d.ts +19 -0
- package/esm/browser/video-call/call-window.js +80 -0
- package/esm/browser/video-call/clip-plan.d.ts +47 -0
- package/esm/browser/video-call/clip-plan.js +60 -0
- package/esm/browser/video-call/face-clips.d.ts +33 -0
- package/esm/browser/video-call/face-clips.js +93 -0
- package/esm/browser/video-call/face-files.d.ts +31 -0
- package/esm/browser/video-call/face-files.js +77 -0
- package/esm/browser/video-call/video-call-view.d.ts +19 -0
- package/esm/browser/video-call/video-call-view.js +214 -0
- package/esm/browser/video-call/video-face.d.ts +13 -0
- package/esm/browser/video-call/video-face.js +497 -0
- package/esm/browser/workbench-hosts.d.ts +1 -0
- package/esm/browser/workbench-protocol.d.ts +2 -0
- package/esm/browser/workbench-util.d.ts +5 -0
- package/esm/browser/workbench-util.js +18 -0
- package/esm/browser/workbench.d.ts +6 -0
- package/esm/browser/workbench.js +36 -5
- package/lib/browser/assistant/assistant-role.d.ts +9 -4
- package/lib/browser/assistant/assistant-role.js +17 -5
- package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
- package/lib/browser/assistant/assistant-task-util.js +11 -0
- package/lib/browser/assistant/assistant-view.js +3 -0
- package/lib/browser/assistant/assistant.d.ts +2 -1
- package/lib/browser/assistant/assistant.js +9 -7
- package/lib/browser/assistant/call-conversing.d.ts +46 -0
- package/lib/browser/assistant/call-conversing.js +96 -0
- package/lib/browser/assistant/call-face.d.ts +14 -0
- package/lib/browser/assistant/call-face.js +117 -0
- package/lib/browser/assistant/call-keeper.d.ts +8 -4
- package/lib/browser/assistant/call-keeper.js +32 -11
- package/lib/browser/assistant/call-partnering.d.ts +38 -0
- package/lib/browser/assistant/call-partnering.js +83 -0
- package/lib/browser/assistant/call-scenes.d.ts +26 -0
- package/lib/browser/assistant/call-scenes.js +85 -0
- package/lib/browser/assistant/call-screen.d.ts +3 -0
- package/lib/browser/assistant/call-screen.js +15 -0
- package/lib/browser/assistant/mic-sense.d.ts +32 -0
- package/lib/browser/assistant/mic-sense.js +123 -0
- package/lib/browser/assistant/noise-gate.d.ts +33 -0
- package/lib/browser/assistant/noise-gate.js +71 -0
- package/lib/browser/assistant/pcm-util.d.ts +11 -0
- package/lib/browser/assistant/pcm-util.js +58 -0
- package/lib/browser/assistant/read-aloud.d.ts +2 -1
- package/lib/browser/assistant/realtime-voice-protocol.d.ts +85 -0
- package/lib/browser/assistant/realtime-voice-protocol.js +43 -0
- package/lib/browser/assistant/realtime-voice.d.ts +50 -62
- package/lib/browser/assistant/realtime-voice.js +217 -138
- package/lib/browser/assistant/spoken-timeline.d.ts +28 -0
- package/lib/browser/assistant/spoken-timeline.js +53 -0
- package/lib/browser/assistant/voice-call-bar.d.ts +9 -2
- package/lib/browser/assistant/voice-call-bar.js +81 -30
- package/lib/browser/assistant/voice-call-protocol.d.ts +61 -4
- package/lib/browser/assistant/voice-call.d.ts +16 -23
- package/lib/browser/assistant/voice-call.js +134 -117
- package/lib/browser/assistant/voice-reading.d.ts +84 -0
- package/lib/browser/assistant/voice-reading.js +156 -0
- package/lib/browser/avatar/dino-talk.d.ts +16 -0
- package/lib/browser/avatar/dino-talk.js +37 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/conversation-scroll-util.d.ts +8 -1
- package/lib/browser/components/conversation-scroll-util.js +21 -0
- package/lib/browser/components/conversation-scroll.js +10 -11
- package/lib/browser/components/gallery.js +28 -7
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/image-pull.d.ts +65 -0
- package/lib/browser/components/image-pull.js +206 -0
- package/lib/browser/components/kept-call-bar.js +2 -1
- package/lib/browser/components/lightbox.d.ts +1 -1
- package/lib/browser/components/lightbox.js +57 -2
- package/lib/browser/components/markdown.d.ts +3 -1
- package/lib/browser/components/markdown.js +7 -3
- package/lib/browser/components/partner-row.js +2 -1
- package/lib/browser/components/relay-services.d.ts +9 -3
- package/lib/browser/components/relay-services.js +71 -33
- package/lib/browser/components/session-view.js +3 -1
- package/lib/browser/components/settings-parts.js +2 -0
- package/lib/browser/components/ta-avatar.d.ts +15 -1
- package/lib/browser/components/ta-avatar.js +38 -5
- package/lib/browser/components/voice-services.js +5 -0
- package/lib/browser/extension/web-api-call.d.ts +64 -2
- package/lib/browser/extension/web-api-contributions.d.ts +1 -0
- package/lib/browser/extension/web-api-partners.d.ts +2 -0
- package/lib/browser/extension/web-extension-api.d.ts +6 -6
- package/lib/browser/extension/web-extension-context.js +1 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +3 -1
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +2 -0
- package/lib/browser/i18n/locales.d.ts +24 -5
- package/lib/browser/i18n/messages-ja.js +25 -6
- package/lib/browser/i18n/messages-zh-tw.js +25 -6
- package/lib/browser/i18n/messages.d.ts +23 -4
- package/lib/browser/i18n/messages.js +50 -12
- package/lib/browser/markdown/code-renderers.d.ts +2 -0
- package/lib/browser/markdown/code-renderers.js +3 -1
- package/lib/browser/screen/page-answers.d.ts +2 -1
- package/lib/browser/screen/page-answers.js +7 -4
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +1 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +6 -1
- package/lib/browser/style/device.js +1 -0
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +1 -1
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +135 -57
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +8 -0
- package/lib/browser/style/video-call.d.ts +3 -0
- package/lib/browser/style/video-call.js +55 -0
- package/lib/browser/style.js +2 -0
- package/lib/browser/util/desktop.d.ts +10 -1
- package/lib/browser/util/desktop.js +10 -0
- package/lib/browser/util/image-pull.d.ts +62 -0
- package/lib/browser/util/image-pull.js +91 -0
- package/lib/browser/util/spoken.d.ts +3 -3
- package/lib/browser/util/spoken.js +4 -4
- package/lib/browser/video-call/call-camera.d.ts +60 -0
- package/lib/browser/video-call/call-camera.js +192 -0
- package/lib/browser/video-call/call-window.d.ts +20 -0
- package/lib/browser/video-call/call-window.js +83 -0
- package/lib/browser/video-call/clip-plan.d.ts +48 -0
- package/lib/browser/video-call/clip-plan.js +64 -0
- package/lib/browser/video-call/face-clips.d.ts +34 -0
- package/lib/browser/video-call/face-clips.js +96 -0
- package/lib/browser/video-call/face-files.d.ts +32 -0
- package/lib/browser/video-call/face-files.js +82 -0
- package/lib/browser/video-call/video-call-view.d.ts +20 -0
- package/lib/browser/video-call/video-call-view.js +250 -0
- package/lib/browser/video-call/video-face.d.ts +14 -0
- package/lib/browser/video-call/video-face.js +533 -0
- package/lib/browser/workbench-hosts.d.ts +1 -0
- package/lib/browser/workbench-protocol.d.ts +2 -0
- package/lib/browser/workbench-util.d.ts +5 -0
- package/lib/browser/workbench-util.js +18 -0
- package/lib/browser/workbench.d.ts +6 -0
- package/lib/browser/workbench.js +35 -4
- package/package.json +7 -7
- package/public/faces/README.md +27 -0
- package/public/faces/clap.mp4 +0 -0
- package/public/faces/dance.mp4 +0 -0
- package/public/faces/happy.mp4 +0 -0
- package/public/faces/heart.mp4 +0 -0
- package/public/faces/idle-1.mp4 +0 -0
- package/public/faces/idle-2.mp4 +0 -0
- package/public/faces/idle-3.mp4 +0 -0
- package/public/faces/laugh.mp4 +0 -0
- package/public/faces/lips.json +1 -0
- package/public/faces/listening.mp4 +0 -0
- package/public/faces/poster.jpg +0 -0
- package/public/faces/shy.mp4 +0 -0
- package/public/faces/sorry.mp4 +0 -0
- package/public/faces/stretch.mp4 +0 -0
- package/public/faces/surprised.mp4 +0 -0
- package/public/faces/talk-1.mp4 +0 -0
- package/public/faces/talk-2.mp4 +0 -0
- package/public/faces/think-2.mp4 +0 -0
- package/public/faces/thinking.mp4 +0 -0
- package/public/faces/wave.mp4 +0 -0
|
@@ -43,6 +43,7 @@ exports.useCallTurns = useCallTurns;
|
|
|
43
43
|
exports.useCallAnnouncements = useCallAnnouncements;
|
|
44
44
|
exports.dialogAnnouncements = dialogAnnouncements;
|
|
45
45
|
exports.callAction = callAction;
|
|
46
|
+
exports.videoCallAction = videoCallAction;
|
|
46
47
|
exports.CallBar = CallBar;
|
|
47
48
|
const react_1 = require("@celljs/react");
|
|
48
49
|
const lucide_react_1 = require("lucide-react");
|
|
@@ -52,7 +53,10 @@ const hooks_1 = require("../hooks");
|
|
|
52
53
|
const use_t_1 = require("../i18n/use-t");
|
|
53
54
|
const screen_protocol_1 = require("../screen/screen-protocol");
|
|
54
55
|
const spoken_1 = require("../util/spoken");
|
|
56
|
+
const call_camera_1 = require("../video-call/call-camera");
|
|
57
|
+
const call_window_1 = require("../video-call/call-window");
|
|
55
58
|
const call_keeper_1 = require("./call-keeper");
|
|
59
|
+
const call_scenes_1 = require("./call-scenes");
|
|
56
60
|
const call_screen_1 = require("./call-screen");
|
|
57
61
|
const realtime_voice_1 = require("./realtime-voice");
|
|
58
62
|
const voice_call_1 = require("./voice-call");
|
|
@@ -95,30 +99,49 @@ function useVoiceCall(options, target, title) {
|
|
|
95
99
|
function made() {
|
|
96
100
|
const latest = { current: options };
|
|
97
101
|
const partnering = { current: { callPartner, target } };
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
const call = new voice_call_1.VoiceCall({
|
|
103
|
+
language: () => latest.current.language(),
|
|
104
|
+
voice: () => latest.current.voice(),
|
|
105
|
+
// What the user says goes with the note that asks for what to say back (SpokenReply), and what is new of the call.
|
|
106
|
+
send: text => latest.current.send(spoken_1.SpokenReply.asked(text, call_scenes_1.CallScenes.next(call, bench.pages.device))),
|
|
107
|
+
ended: (reason, detail) => { var _a, _b; return (_b = (_a = latest.current).ended) === null || _b === void 0 ? void 0 : _b.call(_a, reason, detail); },
|
|
108
|
+
openVoice: async (opening) => {
|
|
109
|
+
var _a;
|
|
110
|
+
await online();
|
|
111
|
+
// A Ta of before, or one let in who may not see the settings: the voice of the device.
|
|
112
|
+
const voices = await bench.voice.listVoices().catch(() => undefined);
|
|
113
|
+
if (!(voices === null || voices === void 0 ? void 0 : voices.use)) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
// The service's own model answers with the brain of the partner opened for it (docs/design/ta-voice.md 8).
|
|
117
|
+
const brain = CallPartnerUtil.voiced(voices) ? (_a = (await opening)) === null || _a === void 0 ? void 0 : _a.brain : undefined;
|
|
118
|
+
return new realtime_voice_1.RealtimeVoice(bench).open(latest.current.language(), brain ? { brain } : {});
|
|
119
|
+
},
|
|
120
|
+
openPartner: plain => {
|
|
121
|
+
const { callPartner: partner, target: called } = partnering.current;
|
|
122
|
+
return partner && called
|
|
123
|
+
? online().then(async () => {
|
|
124
|
+
const voiced = !plain && CallPartnerUtil.voiced(await bench.voice.listVoices().catch(() => undefined));
|
|
125
|
+
const device = bench.pages.device;
|
|
126
|
+
const scene = call_scenes_1.CallScenes.of(call, device);
|
|
127
|
+
const target = { ...called, language: latest.current.language(), device, scene, ...(voiced ? { voiced } : {}) };
|
|
128
|
+
return CallPartnerUtil.open(partner, target, text => call_camera_1.CallCameras.frame(call, text), changed => call_scenes_1.CallScenes.watch(call, device, changed));
|
|
129
|
+
})
|
|
130
|
+
: undefined;
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
return { refs: { latest, partnering }, call };
|
|
120
134
|
}
|
|
121
135
|
const state = React.useSyncExternalStore(listener => call.subscribe(listener), () => call.state);
|
|
136
|
+
// The conversation of the call going on took its own id (one loaded again is known by its file first): the keeper knows it by it.
|
|
137
|
+
const targetId = target === null || target === void 0 ? void 0 : target.sessionId;
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
var _a;
|
|
140
|
+
var _b;
|
|
141
|
+
if (targetId && call.state.active) {
|
|
142
|
+
keeper.begin({ sessionId: targetId, double: (_a = held.refs.partnering.current.target) === null || _a === void 0 ? void 0 : _a.double, title: (_b = named.current) !== null && _b !== void 0 ? _b : '', held });
|
|
143
|
+
}
|
|
144
|
+
}, [targetId, call, held, keeper]);
|
|
122
145
|
React.useEffect(() => {
|
|
123
146
|
// The call going on is the keeper's as it begins: it floats while its conversation is not in front (KeptCallBar).
|
|
124
147
|
const begun = () => {
|
|
@@ -132,11 +155,12 @@ function useVoiceCall(options, target, title) {
|
|
|
132
155
|
const offBegun = call.subscribe(begun);
|
|
133
156
|
// Its call went on as the page went away (it loaded again, the app restarted): it goes on.
|
|
134
157
|
const { target: called } = held.refs.partnering.current;
|
|
135
|
-
|
|
136
|
-
|
|
158
|
+
const resumed = called && !call.state.active ? keeper.resume(called.sessionId, called.double) : undefined;
|
|
159
|
+
if (resumed) {
|
|
160
|
+
call.start(undefined, { video: resumed.video === true });
|
|
137
161
|
}
|
|
138
162
|
// Another app in front or the screen locked: the device stops listening and reading, so the call waits.
|
|
139
|
-
const shown = () => (
|
|
163
|
+
const shown = () => (call_window_1.CallWindow.hidden() ? call.pause() : call.resume());
|
|
140
164
|
document.addEventListener('visibilitychange', shown);
|
|
141
165
|
window.addEventListener('pagehide', shown);
|
|
142
166
|
return () => {
|
|
@@ -172,36 +196,52 @@ function talkCall(call) {
|
|
|
172
196
|
}
|
|
173
197
|
var CallPartnerUtil;
|
|
174
198
|
(function (CallPartnerUtil) {
|
|
199
|
+
/** Calls are answered by the voice service's own model: the user chose it, and the service in use thinks. */
|
|
200
|
+
function voiced(voices) {
|
|
201
|
+
var _a;
|
|
202
|
+
const service = (voices === null || voices === void 0 ? void 0 : voices.use) ? voices.services.find(each => each.id === voices.use) : undefined;
|
|
203
|
+
return (voices === null || voices === void 0 ? void 0 : voices.brain) === 'service' && !!service && !!((_a = voices.types.find(type => type.type === service.type)) === null || _a === void 0 ? void 0 : _a.thinks);
|
|
204
|
+
}
|
|
205
|
+
CallPartnerUtil.voiced = voiced;
|
|
175
206
|
/**
|
|
176
207
|
* The side of a call of a partner of an extension, its replies said whole (SpokenReply.whole: they are written for
|
|
177
208
|
* the ear); undefined when it leaves the call to the conversation.
|
|
178
209
|
*/
|
|
179
|
-
async function open(partner, target) {
|
|
210
|
+
async function open(partner, target, look, scenes) {
|
|
180
211
|
const session = await partner.open(target);
|
|
181
212
|
let closed = false;
|
|
213
|
+
// How the call changes (video or voice, the camera, how it shows) goes to the partner as it does.
|
|
214
|
+
const offScenes = (session === null || session === void 0 ? void 0 : session.scene) ? scenes === null || scenes === void 0 ? void 0 : scenes(scene => { var _a; return (_a = session.scene) === null || _a === void 0 ? void 0 : _a.call(session, scene); }) : undefined;
|
|
215
|
+
// In a video call, what the camera sees goes with what the user said, when it changed (CallCameras.frame).
|
|
216
|
+
const seen = (text) => {
|
|
217
|
+
const image = look === null || look === void 0 ? void 0 : look(text);
|
|
218
|
+
return image ? { images: [image] } : {};
|
|
219
|
+
};
|
|
182
220
|
return (session && {
|
|
183
221
|
say: async (text, options) => {
|
|
184
|
-
const reply = await session.say(text, options);
|
|
222
|
+
const reply = await session.say(text, { ...options, ...seen(text) });
|
|
185
223
|
return reply ? spoken_1.SpokenReply.whole(reply) : undefined;
|
|
186
224
|
},
|
|
187
|
-
...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text) } : {}),
|
|
225
|
+
...(session.draft ? { draft: (text) => CallPartnerUtil.draft(session, text, seen(text)) } : {}),
|
|
188
226
|
news: listener => {
|
|
189
227
|
if (session.next) {
|
|
190
228
|
void CallPartnerUtil.follow(session.next.bind(session), () => closed, text => listener(spoken_1.SpokenReply.whole(text)));
|
|
191
229
|
}
|
|
192
230
|
},
|
|
193
231
|
ending: () => { var _a; return ((_a = session.ending) === null || _a === void 0 ? void 0 : _a.call(session)) === true; },
|
|
232
|
+
...(session.brain ? { brain: session.brain } : {}),
|
|
194
233
|
close: () => {
|
|
195
234
|
closed = true;
|
|
235
|
+
offScenes === null || offScenes === void 0 ? void 0 : offScenes();
|
|
196
236
|
session.close();
|
|
197
237
|
},
|
|
198
238
|
});
|
|
199
239
|
}
|
|
200
240
|
CallPartnerUtil.open = open;
|
|
201
241
|
/** An answer begun by the partner before the user was known to be done, its reply said whole. */
|
|
202
|
-
function draft(session, text) {
|
|
242
|
+
function draft(session, text, options) {
|
|
203
243
|
var _a;
|
|
204
|
-
const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text);
|
|
244
|
+
const begun = (_a = session.draft) === null || _a === void 0 ? void 0 : _a.call(session, text, options);
|
|
205
245
|
return {
|
|
206
246
|
reply: begun ? begun.reply.then(reply => (reply ? spoken_1.SpokenReply.whole(reply) : undefined)) : Promise.reject(new Error('No drafts.')),
|
|
207
247
|
keep: () => begun === null || begun === void 0 ? void 0 : begun.keep(),
|
|
@@ -288,6 +328,17 @@ function callAction(state, call, t) {
|
|
|
288
328
|
run: () => call.start(),
|
|
289
329
|
};
|
|
290
330
|
}
|
|
331
|
+
/** Video call, beside Call: Ta shows as a person who speaks, and sees the user once they turn their camera on (docs/design/ta-call.md 12). */
|
|
332
|
+
function videoCallAction(state, call, t) {
|
|
333
|
+
return {
|
|
334
|
+
key: 'videoCall',
|
|
335
|
+
label: t('ta.call.video'),
|
|
336
|
+
title: t('ta.call.videoTitle'),
|
|
337
|
+
icon: React.createElement(icon_1.Icon, { icon: lucide_react_1.Video, size: 16 }),
|
|
338
|
+
disabled: state.active,
|
|
339
|
+
run: () => call.start(undefined, { video: true }),
|
|
340
|
+
};
|
|
341
|
+
}
|
|
291
342
|
/**
|
|
292
343
|
* A caption in the one line of the bar of a call, as a ticker: what the user says keeps its newest words in sight as
|
|
293
344
|
* it grows (`follow`); a sentence Ta reads shows from its start and scrolls on to its end, about as fast as it is read
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TaVoiceBrainRef } from '@celljs/ta-protocol';
|
|
1
2
|
import type { Voice } from '../util/voice';
|
|
2
3
|
import type { CallTurnTimes } from './call-turn-end';
|
|
3
4
|
/** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
|
|
@@ -20,6 +21,10 @@ export interface CallState {
|
|
|
20
21
|
partnered?: boolean;
|
|
21
22
|
/** Its voice hears the user cut in while Ta speaks: no need to tap. */
|
|
22
23
|
bargeIn?: boolean;
|
|
24
|
+
/** A video call: Ta shows as a person who speaks (docs/design/ta-call.md 12), and sees the user once they turn their camera on. */
|
|
25
|
+
video?: boolean;
|
|
26
|
+
/** When the call began (ms since the epoch). */
|
|
27
|
+
since?: number;
|
|
23
28
|
}
|
|
24
29
|
/** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
|
|
25
30
|
export interface CallVoice {
|
|
@@ -32,6 +37,50 @@ export interface CallVoice {
|
|
|
32
37
|
readonly cutsIn?: boolean;
|
|
33
38
|
/** The call ended: it lets go of what it holds (the microphone, the service). */
|
|
34
39
|
stop?(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Its own model answers (a voice service that thinks, docs/design/ta-voice.md 8): it hears, thinks and speaks by
|
|
42
|
+
* itself, and the call only shows what goes on (converse); it neither listens nor speaks by turns.
|
|
43
|
+
*/
|
|
44
|
+
readonly thinks?: boolean;
|
|
45
|
+
/** Of one that thinks: what goes on in the call is told `talk`. */
|
|
46
|
+
converse?(talk: CallTalk): void;
|
|
47
|
+
/** Of one that thinks: the microphone goes quiet (the page hidden), or on again. */
|
|
48
|
+
mute?(muted: boolean): void;
|
|
49
|
+
/** How loud what it plays now is (RMS, 0 to 1), for the face of the call to speak by; one without cannot tell. */
|
|
50
|
+
level?(): number;
|
|
51
|
+
/** Of a voice that plays what a service reads: what it reads now, on the clock of its sound (CallReading). */
|
|
52
|
+
nowReading?(): CallReading | undefined;
|
|
53
|
+
/** The sound of what it reads as it comes, PCM16 mono at `rate`; `pcm` undefined once all of it came. */
|
|
54
|
+
onSound?(listener: (say: number, pcm: Uint8Array | undefined, rate: number) => void): () => void;
|
|
55
|
+
/** Each reading plays `ms` after its sound began to come: what is drawn with it has the time to be ready. */
|
|
56
|
+
hold?(ms: number): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a voice reads now (CallVoice.reading), on the clock of its sound: the captions, the clip of the person of a
|
|
60
|
+
* video call and the frames of her mouth all follow it (docs/design/ta-call.md 12).
|
|
61
|
+
*/
|
|
62
|
+
export interface CallReading {
|
|
63
|
+
say: number;
|
|
64
|
+
pieces: readonly string[];
|
|
65
|
+
/** Where it is, in seconds of its sound; negative before it plays (held). */
|
|
66
|
+
now(): number;
|
|
67
|
+
/** The sentence heard at that second of it, the same for every one who asks (SpokenTimeline). */
|
|
68
|
+
pieceAt(seconds: number): number;
|
|
69
|
+
}
|
|
70
|
+
/** What goes on in a call a voice that thinks answers (CallVoice.converse). */
|
|
71
|
+
export interface CallTalk {
|
|
72
|
+
/** What the user says so far; `final` once they are done with it. */
|
|
73
|
+
heard(text: string, final: boolean): void;
|
|
74
|
+
/** Its answer so far, as it says it; `paced`: its sentences show as they are heard (reading), not all at once. */
|
|
75
|
+
replying(text: string, paced?: boolean): void;
|
|
76
|
+
/** The sentence of its answer heard now, as its sound plays. */
|
|
77
|
+
reading?(pieces: string[], at: number): void;
|
|
78
|
+
/** It said all of its answer; `end`: it hung up. */
|
|
79
|
+
replied(end: boolean): void;
|
|
80
|
+
/** The user began to speak: what it said stops. */
|
|
81
|
+
cut(): void;
|
|
82
|
+
/** The service is gone (ta serve restarted, the connection dropped). */
|
|
83
|
+
lost(error: string): void;
|
|
35
84
|
}
|
|
36
85
|
/**
|
|
37
86
|
* Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
|
|
@@ -51,6 +100,8 @@ export interface CallPartner {
|
|
|
51
100
|
draft?(text: string): CallDraft;
|
|
52
101
|
/** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
|
|
53
102
|
ending?(): boolean;
|
|
103
|
+
/** Of a call the voice service answers: the brain its voice opens with (WebCallSession.brain). */
|
|
104
|
+
brain?: TaVoiceBrainRef;
|
|
54
105
|
close(): void;
|
|
55
106
|
}
|
|
56
107
|
/** An answer begun before the user was known to be done (CallPartner.draft). */
|
|
@@ -69,10 +120,16 @@ export interface CallOptions extends CallTurnTimes {
|
|
|
69
120
|
send(text: string): Promise<unknown>;
|
|
70
121
|
/** The call ended by itself: why, for a notice; `detail` what the voice service said. */
|
|
71
122
|
ended?(reason: CallEnd, detail?: string): void;
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The voice of a service the call opens as it starts; undefined for that of the device. With the partner opening,
|
|
125
|
+
* a service that thinks may answer with its brain (CallPartner.brain).
|
|
126
|
+
*/
|
|
127
|
+
openVoice?(partner?: Promise<CallPartner | undefined>): Promise<CallVoice | undefined> | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. `plain`:
|
|
130
|
+
* one that answers itself, never leaving it to the voice service.
|
|
131
|
+
*/
|
|
132
|
+
openPartner?(plain?: boolean): Promise<CallPartner | undefined> | undefined;
|
|
76
133
|
/** How long nobody may speak before the call ends by itself; default SILENT_MS. */
|
|
77
134
|
silentMs?: number;
|
|
78
135
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Voice } from '../util/voice';
|
|
2
|
+
import { CallConversing, CallDrafts } from './call-conversing';
|
|
3
|
+
import { CallPartnering } from './call-partnering';
|
|
2
4
|
import { CallTurnEnd } from './call-turn-end';
|
|
3
|
-
import type {
|
|
5
|
+
import type { CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol';
|
|
6
|
+
import { CallSounds } from './voice-reading';
|
|
4
7
|
import { VoiceReopen } from './voice-reopen';
|
|
5
8
|
/**
|
|
6
9
|
* A call with a conversation (the double's, or any other), by the voice of the page: Ta listens until the user pauses, sends what they said, reads
|
|
@@ -33,30 +36,27 @@ export declare class VoiceCall {
|
|
|
33
36
|
protected opening: boolean;
|
|
34
37
|
protected waiting?: string;
|
|
35
38
|
/** Who answers in this call in place of the conversation (CallOptions.openPartner), once open. */
|
|
36
|
-
protected
|
|
39
|
+
protected readonly partners: CallPartnering;
|
|
37
40
|
/** Its voice service opening again (revoice). */
|
|
38
41
|
protected reopening?: VoiceReopen;
|
|
39
|
-
/** The answer begun on what the user said so far (CallPartner.draft)
|
|
40
|
-
protected
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
/** A partner whose draft failed (an older Ta): it answers once the user is done only. */
|
|
45
|
-
protected draftless?: CallPartner;
|
|
42
|
+
/** The answer begun on what the user said so far (CallPartner.draft). */
|
|
43
|
+
protected readonly drafts: CallDrafts;
|
|
44
|
+
/** Of a voice that thinks, which answers by itself. */
|
|
45
|
+
protected readonly conversing: CallConversing;
|
|
46
46
|
constructor(options: CallOptions, device?: CallVoice);
|
|
47
47
|
subscribe(listener: () => void): () => void;
|
|
48
48
|
/**
|
|
49
49
|
* Begins the call: Ta listens. With what the user said as they called (let go over 通话 of a talk), already being
|
|
50
50
|
* sent by the box, Ta waits for its turn and reads the answer instead; should the sending fail, it listens.
|
|
51
|
-
* `direct`: the conversation's voice kept on (let go over 持续说),
|
|
52
|
-
*/
|
|
51
|
+
* `direct`: the conversation's voice kept on (let go over 持续说), no partner; `video`: a video call (CallState.video). */
|
|
53
52
|
start(said?: {
|
|
54
53
|
text: string;
|
|
55
54
|
sent: Promise<unknown>;
|
|
56
|
-
}, { direct }?: {
|
|
55
|
+
}, { direct, video }?: {
|
|
57
56
|
direct?: boolean;
|
|
57
|
+
video?: boolean;
|
|
58
58
|
}): void;
|
|
59
|
-
/** The voice of a service is the call's now: it hears the user cut in. */
|
|
59
|
+
/** The voice of a service is the call's now: it hears the user cut in, or answers by itself (thinks). */
|
|
60
60
|
protected takeVoice(voice: CallVoice): void;
|
|
61
61
|
/** Its voice is there: the answer that came meanwhile is read, a turn at work is waited for, else Ta listens. */
|
|
62
62
|
protected voiced(): void;
|
|
@@ -83,6 +83,9 @@ export declare class VoiceCall {
|
|
|
83
83
|
pause(): void;
|
|
84
84
|
/** The page shows again: the answer that waits is read, a turn at work is waited for, else Ta listens. */
|
|
85
85
|
resume(): void;
|
|
86
|
+
/** For the face of the call (CallSounds): Ta's voice, whichever the call has (it opens after the call shows). */
|
|
87
|
+
readonly sounds: CallSounds;
|
|
88
|
+
readonly level: () => number | undefined;
|
|
86
89
|
/** While Ta speaks (an answer, or news it tells by itself): it stops and listens to the user, before any more news. */
|
|
87
90
|
interrupt(): void;
|
|
88
91
|
/** The run of the turn the call asked has started: its reply is the first after `before`. */
|
|
@@ -130,18 +133,8 @@ export declare class VoiceCall {
|
|
|
130
133
|
* should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
|
|
131
134
|
*/
|
|
132
135
|
protected suspect(text: string): void;
|
|
133
|
-
/** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
|
|
134
|
-
protected kept(draft: CallDraft, said: string): void;
|
|
135
|
-
protected dropDraft(): void;
|
|
136
136
|
/** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
|
|
137
137
|
protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
|
|
138
|
-
/** The partner answers what the user said; its reply is read as a turn's is. */
|
|
139
|
-
protected ask(text: string, sent?: boolean): void;
|
|
140
|
-
/**
|
|
141
|
-
* The partner did not answer (the Ta service restarted, its side of the call is gone): it opens again once and
|
|
142
|
-
* answers what was said; failing that, the conversation answers from then on. The call goes on either way.
|
|
143
|
-
*/
|
|
144
|
-
protected reopen(failed: CallPartner, text: string, sent?: boolean): void;
|
|
145
138
|
/** What the user said did not go: not in the captions as if it had, and Ta listens again. */
|
|
146
139
|
protected unsent(): void;
|
|
147
140
|
protected end(reason: CallEnd, detail?: string): void;
|