@celljs/ta-protocol 4.15.2 → 4.17.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 (67) hide show
  1. package/esm/common/app-protocol.d.ts +115 -0
  2. package/esm/common/app-protocol.js +199 -0
  3. package/esm/common/delegate-protocol.d.ts +30 -0
  4. package/esm/common/delegate-protocol.js +52 -0
  5. package/esm/common/deployment-protocol.d.ts +59 -0
  6. package/esm/common/deployment-protocol.js +135 -0
  7. package/esm/common/error-protocol.d.ts +42 -0
  8. package/esm/common/error-protocol.js +45 -0
  9. package/esm/common/event-protocol.d.ts +63 -0
  10. package/esm/common/event-protocol.js +2 -0
  11. package/esm/common/gateway-protocol.d.ts +54 -2
  12. package/esm/common/index.d.ts +9 -0
  13. package/esm/common/index.js +9 -0
  14. package/esm/common/location.d.ts +18 -1
  15. package/esm/common/location.js +51 -4
  16. package/esm/common/message-protocol.d.ts +95 -0
  17. package/esm/common/message-protocol.js +237 -0
  18. package/esm/common/page-protocol.d.ts +56 -0
  19. package/esm/common/page-protocol.js +12 -0
  20. package/esm/common/path-map.d.ts +24 -0
  21. package/esm/common/path-map.js +127 -0
  22. package/esm/common/presence-protocol.js +1 -1
  23. package/esm/common/redactor.d.ts +12 -0
  24. package/esm/common/redactor.js +49 -11
  25. package/esm/common/relay-protocol.d.ts +20 -0
  26. package/esm/common/remote-protocol.d.ts +12 -4
  27. package/esm/common/room-protocol.d.ts +7 -1
  28. package/esm/common/ta-extension-host.d.ts +31 -1
  29. package/esm/common/ta-extension-host.js +2 -0
  30. package/esm/common/ta-protocol.d.ts +50 -175
  31. package/esm/common/ta-protocol.js +0 -234
  32. package/esm/common/voice-protocol.d.ts +139 -0
  33. package/esm/common/voice-protocol.js +3 -0
  34. package/lib/common/app-protocol.d.ts +116 -0
  35. package/lib/common/app-protocol.js +202 -0
  36. package/lib/common/delegate-protocol.d.ts +31 -0
  37. package/lib/common/delegate-protocol.js +55 -0
  38. package/lib/common/deployment-protocol.d.ts +60 -0
  39. package/lib/common/deployment-protocol.js +139 -0
  40. package/lib/common/error-protocol.d.ts +43 -0
  41. package/lib/common/error-protocol.js +48 -0
  42. package/lib/common/event-protocol.d.ts +64 -0
  43. package/lib/common/event-protocol.js +3 -0
  44. package/lib/common/gateway-protocol.d.ts +54 -2
  45. package/lib/common/index.d.ts +9 -0
  46. package/lib/common/index.js +9 -0
  47. package/lib/common/location.d.ts +18 -1
  48. package/lib/common/location.js +51 -4
  49. package/lib/common/message-protocol.d.ts +96 -0
  50. package/lib/common/message-protocol.js +240 -0
  51. package/lib/common/page-protocol.d.ts +57 -0
  52. package/lib/common/page-protocol.js +15 -0
  53. package/lib/common/path-map.d.ts +25 -0
  54. package/lib/common/path-map.js +130 -0
  55. package/lib/common/presence-protocol.js +7 -7
  56. package/lib/common/redactor.d.ts +12 -0
  57. package/lib/common/redactor.js +49 -11
  58. package/lib/common/relay-protocol.d.ts +20 -0
  59. package/lib/common/remote-protocol.d.ts +12 -4
  60. package/lib/common/room-protocol.d.ts +7 -1
  61. package/lib/common/ta-extension-host.d.ts +31 -1
  62. package/lib/common/ta-extension-host.js +3 -1
  63. package/lib/common/ta-protocol.d.ts +50 -175
  64. package/lib/common/ta-protocol.js +1 -235
  65. package/lib/common/voice-protocol.d.ts +140 -0
  66. package/lib/common/voice-protocol.js +6 -0
  67. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaSkillUse = exports.TaAgentSummary = exports.TaImageSize = exports.TaImageNote = exports.TaMessageSource = exports.TaMessageContext = exports.TaSlashCommandUtil = exports.TA_RPC_ERROR_CODE = exports.TaErrorUtil = exports.TaErrorCode = exports.TA_RESUME_MESSAGE = exports.TA_SERVE_RESTART_EXIT_CODE = exports.TA_SERVE_FILE = exports.TA_CLIENT_SERVICE = exports.TA_SERVER_SERVICE = exports.TA_WEBSOCKET_PATH = exports.TaClient = exports.TaServer = void 0;
3
+ exports.TaSlashCommandUtil = exports.TA_RESUME_MESSAGE = exports.TA_SERVE_RESTART_EXIT_CODE = exports.TA_SERVE_FILE = exports.TA_CLIENT_SERVICE = exports.TA_SERVER_SERVICE = exports.TA_WEBSOCKET_PATH = exports.TaClient = exports.TaServer = void 0;
4
4
  exports.TaServer = Symbol('TaServer');
5
5
  exports.TaClient = Symbol('TaClient');
6
6
  /** Path of the WebSocket endpoint of `ta serve`, and the JSON-RPC method prefixes of both sides. */
@@ -16,50 +16,6 @@ exports.TA_SERVE_RESTART_EXIT_CODE = 75;
16
16
  * the conversation again and has it carry on (TaSessionResume of ta-host); the web client shows it as a mark.
17
17
  */
18
18
  exports.TA_RESUME_MESSAGE = 'ta-resume';
19
- /** The stable `code` of each failure of a {@link TaServer} call. */
20
- exports.TaErrorCode = {
21
- SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
22
- SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
23
- TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
24
- MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
25
- MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
26
- INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
27
- COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
28
- /** Compacting found nothing to compact: the conversation is still short. */
29
- NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT',
30
- /** Compacting found nothing to compact: nothing came after the last compaction. */
31
- ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED',
32
- /** The session is answering or compacting, which has to end first. */
33
- SESSION_BUSY: 'CELL_TA_SESSION_BUSY',
34
- /** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
35
- CANCELLED: 'CELL_TA_CANCELLED',
36
- /** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
37
- NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
38
- /** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
39
- ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
40
- /** Behind a gateway: more messages a minute than one may send; try again in a moment. */
41
- RATE_LIMITED: 'CELL_TA_RATE_LIMITED',
42
- /** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
43
- FORBIDDEN: 'CELL_TA_FORBIDDEN',
44
- /** As many runs of people let in go as the owner lets at once (docs/design/ta-team.md 9): try again once one ended. */
45
- LIMIT: 'CELL_TA_LIMIT',
46
- /** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
47
- CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
48
- };
49
- var TaErrorUtil;
50
- (function (TaErrorUtil) {
51
- /** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
52
- function code(error) {
53
- var _a;
54
- var _b;
55
- const failure = error;
56
- const code = (_b = failure === null || failure === void 0 ? void 0 : failure.code) !== null && _b !== void 0 ? _b : (_a = failure === null || failure === void 0 ? void 0 : failure.data) === null || _a === void 0 ? void 0 : _a.code;
57
- return typeof code === 'string' ? code : undefined;
58
- }
59
- TaErrorUtil.code = code;
60
- })(TaErrorUtil || (exports.TaErrorUtil = TaErrorUtil = {}));
61
- /** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
62
- exports.TA_RPC_ERROR_CODE = -32050;
63
19
  var TaSlashCommandUtil;
64
20
  (function (TaSlashCommandUtil) {
65
21
  /** Its description in a language such as `zh-CN`: in that language, else in its first part (`zh`), else its own. */
@@ -70,194 +26,4 @@ var TaSlashCommandUtil;
70
26
  }
71
27
  TaSlashCommandUtil.description = description;
72
28
  })(TaSlashCommandUtil || (exports.TaSlashCommandUtil = TaSlashCommandUtil = {}));
73
- /**
74
- * A message of the user may start with a `<context>` block: what the model reads besides the message
75
- * (where it is said, who is there, what was said before), which a client leaves out when it shows it.
76
- */
77
- var TaMessageContext;
78
- (function (TaMessageContext) {
79
- const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
80
- function wrap(context, message) {
81
- return `<context>\n${context}\n</context>\n${message}`;
82
- }
83
- TaMessageContext.wrap = wrap;
84
- /** The message without its context: what the user sees of it. */
85
- function strip(message) {
86
- return message.replace(BLOCK, '');
87
- }
88
- TaMessageContext.strip = strip;
89
- /** The context of the message, without its tags; undefined without one. */
90
- function read(message) {
91
- var _a;
92
- const block = (_a = BLOCK.exec(message)) === null || _a === void 0 ? void 0 : _a[0];
93
- return block === null || block === void 0 ? void 0 : block.replace(/^<context>\n?/, '').replace(/\n?<\/context>\n?$/, '');
94
- }
95
- TaMessageContext.read = read;
96
- })(TaMessageContext || (exports.TaMessageContext = TaMessageContext = {}));
97
- /**
98
- * A message a package sends as the user (a choice in a card, a scheduled task, a channel) says so in the last line
99
- * of its `<context>` block, `[ta:from <name> <detail>]`: a page shows where it came from, the model reads it too,
100
- * and a page older than it leaves it out with the rest of the context. A command (`/compact`, `!ls`) is not marked.
101
- */
102
- var TaMessageSource;
103
- (function (TaMessageSource) {
104
- /** The double of the web page: the tasks it hands out, what it tells them on the way. */
105
- TaMessageSource.DOUBLE = 'ta:double';
106
- const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
107
- /** `message` as sent by `from`; as it was when it is a command or says where it came from already. */
108
- function mark(message, from, detail) {
109
- if (/^[/!]/.test(message) || of(message)) {
110
- return message;
111
- }
112
- const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, ' ')}` : ''}]`;
113
- const context = TaMessageContext.read(message);
114
- return TaMessageContext.wrap(context === undefined ? line : `${context}\n${line}`, TaMessageContext.strip(message));
115
- }
116
- TaMessageSource.mark = mark;
117
- function of(message) {
118
- const context = TaMessageContext.read(message);
119
- const match = context === undefined ? null : LINE.exec(context);
120
- return match ? { from: match[1], ...(match[2] ? { detail: match[2].trim() } : {}) } : undefined;
121
- }
122
- TaMessageSource.of = of;
123
- })(TaMessageSource || (exports.TaMessageSource = TaMessageSource = {}));
124
- /**
125
- * pi adds a line to the text of a message of the user for each image it took, for the model's sake: how big
126
- * the image was before it made it smaller, and what it was converted from. Clients leave them out.
127
- */
128
- var TaImageNote;
129
- (function (TaImageNote) {
130
- const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
131
- /** The text without the notes of its images: what the user sees of it. */
132
- function strip(text) {
133
- const lines = text.split('\n');
134
- const kept = lines.filter(line => !NOTE.test(line.trim()));
135
- if (kept.length === lines.length) {
136
- return text;
137
- }
138
- return kept.join('\n').replace(/\n+$/, '').replace(/^\n+/, '');
139
- }
140
- TaImageNote.strip = strip;
141
- })(TaImageNote || (exports.TaImageNote = TaImageNote = {}));
142
- /** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
143
- var TaImageSize;
144
- (function (TaImageSize) {
145
- /** How much of a JPEG is read for its size: the frame header follows what the camera wrote, a thumbnail too. */
146
- const JPEG_BYTES = 256 * 1024;
147
- function of(base64) {
148
- var _a, _b, _c;
149
- let bytes;
150
- try {
151
- // Whole groups of four characters only.
152
- const binary = atob(base64.slice(0, Math.ceil((JPEG_BYTES * 4) / 3 / 4) * 4));
153
- bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
154
- }
155
- catch (_d) {
156
- return undefined;
157
- }
158
- const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== void 0 ? _a : gif(bytes)) !== null && _b !== void 0 ? _b : webp(bytes)) !== null && _c !== void 0 ? _c : jpeg(bytes);
159
- return size && size.width > 0 && size.height > 0 ? size : undefined;
160
- }
161
- TaImageSize.of = of;
162
- function u16be(bytes, at) {
163
- return (bytes[at] << 8) | bytes[at + 1];
164
- }
165
- function u16le(bytes, at) {
166
- return bytes[at] | (bytes[at + 1] << 8);
167
- }
168
- function u24le(bytes, at) {
169
- return bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16);
170
- }
171
- function u32be(bytes, at) {
172
- return ((bytes[at] << 24) | (bytes[at + 1] << 16) | (bytes[at + 2] << 8) | bytes[at + 3]) >>> 0;
173
- }
174
- function text(bytes, at, length) {
175
- return String.fromCharCode(...bytes.subarray(at, at + length));
176
- }
177
- function png(bytes) {
178
- return bytes.length >= 24 && bytes[0] === 0x89 && text(bytes, 1, 3) === 'PNG' ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
179
- }
180
- function gif(bytes) {
181
- return bytes.length >= 10 && text(bytes, 0, 3) === 'GIF' ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
182
- }
183
- function webp(bytes) {
184
- if (bytes.length < 30 || text(bytes, 0, 4) !== 'RIFF' || text(bytes, 8, 4) !== 'WEBP') {
185
- return undefined;
186
- }
187
- switch (text(bytes, 12, 4)) {
188
- case 'VP8 ':
189
- return { width: u16le(bytes, 26) & 0x3fff, height: u16le(bytes, 28) & 0x3fff };
190
- case 'VP8L': {
191
- const bits = bytes[21] | (bytes[22] << 8) | (bytes[23] << 16) | (bytes[24] << 24);
192
- return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };
193
- }
194
- case 'VP8X':
195
- return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
196
- default:
197
- return undefined;
198
- }
199
- }
200
- function jpeg(bytes) {
201
- if (bytes[0] !== 0xff || bytes[1] !== 0xd8) {
202
- return undefined;
203
- }
204
- let at = 2;
205
- while (at + 9 < bytes.length) {
206
- if (bytes[at] !== 0xff) {
207
- return undefined;
208
- }
209
- const marker = bytes[at + 1];
210
- // A start of frame (not DHT, JPG or DAC, which share the range) says the size.
211
- if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
212
- return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
213
- }
214
- at += 2 + u16be(bytes, at + 2);
215
- }
216
- return undefined;
217
- }
218
- })(TaImageSize || (exports.TaImageSize = TaImageSize = {}));
219
- /**
220
- * An external agent that compacts its own context says the summary it goes on from as text, in tags
221
- * (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
222
- */
223
- var TaAgentSummary;
224
- (function (TaAgentSummary) {
225
- const START = /^\s*<conversation_history_summary>/;
226
- const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
227
- /** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
228
- function read(text) {
229
- if (!START.test(text)) {
230
- return undefined;
231
- }
232
- return text
233
- .replace(/<\/?(?:conversation_history_summary|summary)>/g, '')
234
- .replace(/<\/?\w*$/, '')
235
- .trim();
236
- }
237
- TaAgentSummary.read = read;
238
- /** The text without the summary it starts with. */
239
- function strip(text) {
240
- return text.replace(BLOCK, '');
241
- }
242
- TaAgentSummary.strip = strip;
243
- })(TaAgentSummary || (exports.TaAgentSummary = TaAgentSummary = {}));
244
- /** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
245
- var TaSkillUse;
246
- (function (TaSkillUse) {
247
- const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
248
- function parse(message) {
249
- var _a;
250
- const match = BLOCK.exec(message);
251
- if (!match) {
252
- return undefined;
253
- }
254
- return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined };
255
- }
256
- TaSkillUse.parse = parse;
257
- /** What the user typed: `/skill:name` and what follows. */
258
- function command(use) {
259
- return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
260
- }
261
- TaSkillUse.command = command;
262
- })(TaSkillUse || (exports.TaSkillUse = TaSkillUse = {}));
263
29
  //# sourceMappingURL=ta-protocol.js.map
@@ -0,0 +1,140 @@
1
+ import type { TaPackageText } from './package-protocol';
2
+ import type { TaRelayOption } from './relay-protocol';
3
+ export declare const TaVoiceServer: unique symbol;
4
+ export declare const TA_VOICE_SERVICE = "TaVoiceServer";
5
+ /** A field of the form to add a service of a type (docs/design/ta-voice.md): the same as those of relays. */
6
+ export type TaVoiceOption = TaRelayOption;
7
+ /** A type of voice service a package registered, as the page shows it to add one. */
8
+ export interface TaVoiceTypeInfo {
9
+ type: string;
10
+ title: TaPackageText;
11
+ hint?: TaPackageText;
12
+ /** The name of an icon of `pi.ui.icons`. */
13
+ icon?: string;
14
+ options: TaVoiceOption[];
15
+ /** It reads text given to it; without, Ta reads with the voice of the device and the service only listens. */
16
+ speaks: boolean;
17
+ }
18
+ /** A service of voices.json, as the page sees it: never a password or a key. */
19
+ export interface TaVoiceService {
20
+ id: string;
21
+ type: string;
22
+ name?: string;
23
+ /** Where it is, in a few words (a host). */
24
+ where?: string;
25
+ options?: Record<string, unknown>;
26
+ /** Its type is of a package that is off. */
27
+ unavailable?: boolean;
28
+ }
29
+ /** The services of calls and the one in use (TaVoiceServer.listVoices). */
30
+ export interface TaVoices {
31
+ services: TaVoiceService[];
32
+ /** The service calls use; undefined: the voice of the device. */
33
+ use?: string;
34
+ types: TaVoiceTypeInfo[];
35
+ /** voices.json in the agent directory, to edit by hand. */
36
+ file: string;
37
+ }
38
+ /** A voice opened for a call (TaVoiceServer.openVoice). */
39
+ export interface TaVoiceSession {
40
+ voiceId: string;
41
+ /** The rate of the PCM16 mono a page sends (sendVoice). */
42
+ inputRate: number;
43
+ /** The rate of the PCM16 mono of `audio` events. */
44
+ outputRate: number;
45
+ speaks: boolean;
46
+ }
47
+ /** What a voice opened by a connection tells it (TaClient.onVoiceEvent). */
48
+ export type TaVoiceEvent =
49
+ /** The user began to speak: Ta stops reading (barge-in). */
50
+ {
51
+ voiceId: string;
52
+ type: 'speech';
53
+ }
54
+ /** What the user said so far; `final` once a sentence ended. */
55
+ | {
56
+ voiceId: string;
57
+ type: 'text';
58
+ text: string;
59
+ final: boolean;
60
+ }
61
+ /** Audio of the reading `say`: base64 of PCM16 mono at `outputRate`. */
62
+ | {
63
+ voiceId: string;
64
+ type: 'audio';
65
+ say: number;
66
+ data: string;
67
+ }
68
+ /** The reading `say` has all its audio sent. */
69
+ | {
70
+ voiceId: string;
71
+ type: 'said';
72
+ say: number;
73
+ }
74
+ /** It closed, by itself (`error` then says why) or as asked. */
75
+ | {
76
+ voiceId: string;
77
+ type: 'closed';
78
+ error?: string;
79
+ };
80
+ /** The voices of calls for pages (docs/design/ta-voice.md). */
81
+ export interface TaVoiceServer {
82
+ listVoices(): Promise<TaVoices>;
83
+ /** Adds a service of a registered type after opening it once: a wrong key is said now. Its id. */
84
+ addVoice(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
85
+ /**
86
+ * Changes a service after opening it once with what it would be: its fields (a secret left empty keeps the one
87
+ * kept) and its name; a wrong key is said now and nothing changes.
88
+ */
89
+ updateVoice(id: string, options: Record<string, unknown>, name?: string): Promise<void>;
90
+ removeVoice(id: string): Promise<void>;
91
+ /** The service calls use from now on; null for the voice of the device. */
92
+ chooseVoice(id: string | null): Promise<void>;
93
+ /** Opens the service in use for a call of this connection; it closes as the connection does. */
94
+ openVoice(options: {
95
+ language: string;
96
+ }): Promise<TaVoiceSession>;
97
+ /** PCM16 mono at `inputRate`, base64. */
98
+ sendVoice(voiceId: string, audio: string): Promise<void>;
99
+ /** Reads text: the id its audio and its `said` carry. */
100
+ sayVoice(voiceId: string, text: string): Promise<number>;
101
+ /** Stops what it reads. */
102
+ hushVoice(voiceId: string): Promise<void>;
103
+ closeVoice(voiceId: string): Promise<void>;
104
+ }
105
+ /** What a voice service tells Ta as it runs (TaVoiceType.open). */
106
+ export interface TaVoiceEngineEvents {
107
+ speech(): void;
108
+ text(text: string, final: boolean): void;
109
+ audio(pcm: Uint8Array, say: number): void;
110
+ said(say: number): void;
111
+ /** It closed by itself: the connection dropped, the service refused. */
112
+ closed(error?: string): void;
113
+ }
114
+ /** A voice service opened (TaVoiceType.open): what Ta sends it. */
115
+ export interface TaVoiceEngine {
116
+ readonly inputRate: number;
117
+ readonly outputRate: number;
118
+ /** PCM16 mono at `inputRate`. */
119
+ send(pcm: Uint8Array): void;
120
+ /** Reads text aloud, its audio told with `say`; only of a type that `speaks`. */
121
+ say?(text: string, say: number): void;
122
+ /** Stops what it reads; its audio coming late is dropped by Ta anyway. */
123
+ hush(): void;
124
+ close(): void;
125
+ }
126
+ /** A type of voice service a package adds (TaExtensionVoices.registerType): its form, and how it opens. */
127
+ export interface TaVoiceType extends Omit<TaVoiceTypeInfo, 'type'> {
128
+ /** Where it is, in a few words for the list: a host. */
129
+ where(options: Record<string, unknown>): string;
130
+ /** Connects; resolves once it is ready to hear, rejects with why it is not (a wrong key). */
131
+ open(options: Record<string, unknown>, call: {
132
+ language: string;
133
+ }, events: TaVoiceEngineEvents): Promise<TaVoiceEngine>;
134
+ }
135
+ /** voices.json for the server side of packages (TaExtensionHost.voices). */
136
+ export interface TaExtensionVoices {
137
+ /** A type of service: `"type": "<type>"` in voices.json and a form in Settings. Gone with what it returns, or when the package stops. */
138
+ registerType(type: string, definition: TaVoiceType): () => void;
139
+ }
140
+ //# sourceMappingURL=voice-protocol.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TA_VOICE_SERVICE = exports.TaVoiceServer = void 0;
4
+ exports.TaVoiceServer = Symbol('TaVoiceServer');
5
+ exports.TA_VOICE_SERVICE = 'TaVoiceServer';
6
+ //# sourceMappingURL=voice-protocol.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-protocol",
3
- "version": "4.15.2",
3
+ "version": "4.17.0",
4
4
  "description": "The protocol between ta serve and its clients",
5
5
  "homepage": "https://github.com/cellbang/ta",
6
6
  "bugs": {