@celljs/ta-web 4.32.1 → 4.33.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.
Files changed (37) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-ask-book.d.ts +10 -17
  4. package/esm/browser/assistant/assistant-ask-book.js +24 -61
  5. package/esm/browser/assistant/assistant-conversation.js +0 -2
  6. package/esm/browser/assistant/assistant-protocol.d.ts +4 -2
  7. package/esm/browser/assistant/assistant-role.d.ts +1 -1
  8. package/esm/browser/assistant/assistant-role.js +1 -1
  9. package/esm/browser/assistant/assistant.d.ts +7 -2
  10. package/esm/browser/assistant/assistant.js +39 -8
  11. package/esm/browser/assistant/web-voice.d.ts +14 -0
  12. package/esm/browser/assistant/web-voice.js +36 -0
  13. package/esm/browser/components/chat-home-util.d.ts +5 -2
  14. package/esm/browser/components/chat-home-util.js +6 -3
  15. package/esm/browser/components/chat-list.js +1 -1
  16. package/esm/browser/extension/web-api-components.d.ts +19 -0
  17. package/esm/browser/extension/web-extension-context.js +2 -8
  18. package/esm/browser/util/transcription.d.ts +29 -0
  19. package/esm/browser/util/transcription.js +83 -0
  20. package/lib/browser/assistant/assistant-ask-book.d.ts +10 -17
  21. package/lib/browser/assistant/assistant-ask-book.js +24 -61
  22. package/lib/browser/assistant/assistant-conversation.js +0 -2
  23. package/lib/browser/assistant/assistant-protocol.d.ts +4 -2
  24. package/lib/browser/assistant/assistant-role.d.ts +1 -1
  25. package/lib/browser/assistant/assistant-role.js +1 -1
  26. package/lib/browser/assistant/assistant.d.ts +7 -2
  27. package/lib/browser/assistant/assistant.js +39 -8
  28. package/lib/browser/assistant/web-voice.d.ts +15 -0
  29. package/lib/browser/assistant/web-voice.js +40 -0
  30. package/lib/browser/components/chat-home-util.d.ts +5 -2
  31. package/lib/browser/components/chat-home-util.js +6 -3
  32. package/lib/browser/components/chat-list.js +1 -1
  33. package/lib/browser/extension/web-api-components.d.ts +19 -0
  34. package/lib/browser/extension/web-extension-context.js +2 -8
  35. package/lib/browser/util/transcription.d.ts +30 -0
  36. package/lib/browser/util/transcription.js +86 -0
  37. package/package.json +7 -7
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.WebExtensionContext = void 0;
37
37
  const ta_protocol_1 = require("@celljs/ta-protocol");
38
38
  const React = __importStar(require("react"));
39
- const read_aloud_1 = require("../assistant/read-aloud");
40
39
  const task_views_1 = require("../assistant/task-views");
40
+ const web_voice_1 = require("../assistant/web-voice");
41
41
  const busy_1 = require("../components/busy");
42
42
  const chat_asks_1 = require("../components/chat-asks");
43
43
  const chat_list_util_1 = require("../components/chat-list-util");
@@ -81,7 +81,6 @@ const screen_protocol_1 = require("../screen/screen-protocol");
81
81
  const web_terminal_1 = require("../terminal/web-terminal");
82
82
  const desktop_1 = require("../util/desktop");
83
83
  const file_drag_1 = require("../util/file-drag");
84
- const voice_1 = require("../util/voice");
85
84
  const icons_1 = require("./icons");
86
85
  const web_extension_protocol_1 = require("./web-extension-protocol");
87
86
  const web_extension_run_1 = require("./web-extension-run");
@@ -110,12 +109,7 @@ class WebExtensionContext {
110
109
  remote: this.host.workbench,
111
110
  }); };
112
111
  this.holdToTalk = (props) => React.createElement(hold_to_talk_1.HoldToTalk, { ...props, notices: this.host.notices });
113
- this.voice = {
114
- canListen: () => voice_1.Voice.canListen(),
115
- canSpeak: () => voice_1.Voice.canSpeak(),
116
- speak: (text, onEnd) => read_aloud_1.ReadAloud.of(this.host.workbench).speak(text, this.host.settings.state.language, onEnd !== null && onEnd !== void 0 ? onEnd : (() => undefined), this.host.settings.state.settings.voice),
117
- hush: () => read_aloud_1.ReadAloud.of(this.host.workbench).hush(),
118
- };
112
+ this.voice = (0, web_voice_1.webVoice)(this.host);
119
113
  this.shareSheet = (props) => React.createElement(share_sheet_1.ShareSheet, { ...props, notices: this.host.notices, rooms: this.host.workbench.rooms });
120
114
  this.modelPicker = (props) => React.createElement(model_picker_1.SettingsModelPicker, { ...props, settings: this.host.workbench.settings });
121
115
  this.folderPicker = ({ initial, onPick, onClose }) => { var _a; return React.createElement(folder_picker_1.FolderPicker, {
@@ -0,0 +1,30 @@
1
+ import type { Voice } from './voice';
2
+ /** What hears: the recognizer of the device (Voice) or a voice of a service of voices.json (RealtimeVoice). */
3
+ export interface TranscriptionVoice {
4
+ listen(language: string, onText: (text: string, final: boolean) => void, onEnd: (error?: string) => void, options?: Voice.ListenOptions): Voice.Listening | undefined;
5
+ }
6
+ /**
7
+ * Writes down what is said until stopped, a meeting long (WebVoice.transcribe): a listening after another, each the
8
+ * words of a stretch of speech. A recognizer ends a listening on a silence, an utterance or a limit of its own; the
9
+ * next starts at once. The words of a listening come as they grow (`final` false), then once as they ended.
10
+ */
11
+ export declare namespace Transcription {
12
+ /** A listening that ends this soon having heard nothing counts as a quick one. */
13
+ const QUICK_MS = 1000;
14
+ /** Quick ones this many in a row end it: the recognizer cannot hear, and would be started again without end. */
15
+ const QUICK_TIMES = 5;
16
+ interface Events {
17
+ onText(text: string, final: boolean): void;
18
+ /** Once: stopped (no error), or the recognizer failed. */
19
+ onEnd(error?: string): void;
20
+ }
21
+ interface Transcribing {
22
+ /** Ends it, the words of the listening going on taken as they are. */
23
+ stop(): void;
24
+ }
25
+ /** Starts it; undefined when the voice cannot listen. */
26
+ function start(voice: TranscriptionVoice, language: string, events: Events, options?: {
27
+ hints?: readonly string[];
28
+ }, now?: () => number): Transcribing | undefined;
29
+ }
30
+ //# sourceMappingURL=transcription.d.ts.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Transcription = void 0;
4
+ /**
5
+ * Writes down what is said until stopped, a meeting long (WebVoice.transcribe): a listening after another, each the
6
+ * words of a stretch of speech. A recognizer ends a listening on a silence, an utterance or a limit of its own; the
7
+ * next starts at once. The words of a listening come as they grow (`final` false), then once as they ended.
8
+ */
9
+ var Transcription;
10
+ (function (Transcription) {
11
+ /** A listening that ends this soon having heard nothing counts as a quick one. */
12
+ Transcription.QUICK_MS = 1000;
13
+ /** Quick ones this many in a row end it: the recognizer cannot hear, and would be started again without end. */
14
+ Transcription.QUICK_TIMES = 5;
15
+ /** Starts it; undefined when the voice cannot listen. */
16
+ function start(voice, language, events, options = {}, now = Date.now) {
17
+ let ended = false;
18
+ let listening;
19
+ let heard = '';
20
+ let quick = 0;
21
+ const end = (error) => {
22
+ if (!ended) {
23
+ ended = true;
24
+ events.onEnd(error);
25
+ }
26
+ };
27
+ const commit = () => {
28
+ const text = heard.trim();
29
+ heard = '';
30
+ if (text) {
31
+ events.onText(text, true);
32
+ }
33
+ return text !== '';
34
+ };
35
+ const next = () => {
36
+ const at = now();
37
+ heard = '';
38
+ let done = false;
39
+ listening = voice.listen(language, text => {
40
+ if (!ended && !done) {
41
+ heard = text;
42
+ events.onText(text, false);
43
+ }
44
+ }, error => {
45
+ if (ended || done) {
46
+ return;
47
+ }
48
+ done = true;
49
+ listening = undefined;
50
+ if (commit()) {
51
+ quick = 0;
52
+ }
53
+ else {
54
+ quick = now() - at < Transcription.QUICK_MS ? quick + 1 : 0;
55
+ }
56
+ if (error) {
57
+ end(error);
58
+ }
59
+ else if (quick >= Transcription.QUICK_TIMES) {
60
+ end('no-speech');
61
+ }
62
+ else if (!next()) {
63
+ end('unavailable');
64
+ }
65
+ }, { continuous: true, ...(options.hints ? { hints: options.hints } : {}) });
66
+ return listening !== undefined;
67
+ };
68
+ if (!next()) {
69
+ return undefined;
70
+ }
71
+ return {
72
+ stop: () => {
73
+ if (ended) {
74
+ return;
75
+ }
76
+ commit();
77
+ const stopping = listening;
78
+ listening = undefined;
79
+ end();
80
+ stopping === null || stopping === void 0 ? void 0 : stopping.stop();
81
+ },
82
+ };
83
+ }
84
+ Transcription.start = start;
85
+ })(Transcription || (exports.Transcription = Transcription = {}));
86
+ //# sourceMappingURL=transcription.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-web",
3
- "version": "4.32.1",
3
+ "version": "4.33.0",
4
4
  "description": "The web client of ta serve: sessions, streaming messages, tool runs with diffs, and dialogs",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -33,12 +33,12 @@
33
33
  "watch": "tsc -b -w --preserveWatchOutput"
34
34
  },
35
35
  "dependencies": {
36
- "@celljs/core": "4.32.1",
37
- "@celljs/react": "4.32.1",
38
- "@celljs/ta-client": "4.32.1",
39
- "@celljs/ta-protocol": "4.32.1",
40
- "@celljs/ta-relay": "4.32.1",
41
- "@celljs/widget": "4.32.1",
36
+ "@celljs/core": "4.33.0",
37
+ "@celljs/react": "4.33.0",
38
+ "@celljs/ta-client": "4.33.0",
39
+ "@celljs/ta-protocol": "4.33.0",
40
+ "@celljs/ta-relay": "4.33.0",
41
+ "@celljs/widget": "4.33.0",
42
42
  "@types/three": "^0.187.0",
43
43
  "@xterm/addon-fit": "^0.11.0",
44
44
  "@xterm/addon-unicode11": "^0.9.0",