@celljs/ta-protocol 4.16.0 → 4.18.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/common/access-protocol.d.ts +41 -0
- package/esm/common/access-protocol.js +7 -0
- package/esm/common/app-protocol.d.ts +120 -0
- package/esm/common/app-protocol.js +213 -0
- package/esm/common/delegate-protocol.d.ts +30 -0
- package/esm/common/delegate-protocol.js +52 -0
- package/esm/common/deployment-protocol.d.ts +72 -0
- package/esm/common/deployment-protocol.js +171 -0
- package/esm/common/error-protocol.d.ts +42 -0
- package/esm/common/error-protocol.js +45 -0
- package/esm/common/event-protocol.d.ts +63 -0
- package/esm/common/event-protocol.js +2 -0
- package/esm/common/gateway-protocol.d.ts +29 -0
- package/esm/common/index.d.ts +11 -0
- package/esm/common/index.js +11 -0
- package/esm/common/message-protocol.d.ts +134 -0
- package/esm/common/message-protocol.js +322 -0
- package/esm/common/page-protocol.d.ts +56 -0
- package/esm/common/page-protocol.js +12 -0
- package/esm/common/path-map.d.ts +24 -0
- package/esm/common/path-map.js +127 -0
- package/esm/common/presence-protocol.js +1 -1
- package/esm/common/redactor.d.ts +12 -0
- package/esm/common/redactor.js +49 -11
- package/esm/common/relay-protocol.d.ts +20 -0
- package/esm/common/room-protocol.d.ts +52 -1
- package/esm/common/said-protocol.d.ts +76 -0
- package/esm/common/said-protocol.js +239 -0
- package/esm/common/screen-share-protocol.d.ts +304 -0
- package/esm/common/screen-share-protocol.js +88 -0
- package/esm/common/settings-protocol.d.ts +8 -0
- package/esm/common/settings-protocol.js +2 -0
- package/esm/common/ta-extension-host.d.ts +64 -1
- package/esm/common/ta-extension-host.js +8 -0
- package/esm/common/ta-protocol.d.ts +53 -175
- package/esm/common/ta-protocol.js +0 -234
- package/esm/common/team-protocol.d.ts +13 -2
- package/esm/common/team-protocol.js +27 -2
- package/esm/common/voice-protocol.d.ts +184 -0
- package/esm/common/voice-protocol.js +57 -0
- package/lib/common/access-protocol.d.ts +41 -0
- package/lib/common/access-protocol.js +8 -1
- package/lib/common/app-protocol.d.ts +121 -0
- package/lib/common/app-protocol.js +216 -0
- package/lib/common/delegate-protocol.d.ts +31 -0
- package/lib/common/delegate-protocol.js +55 -0
- package/lib/common/deployment-protocol.d.ts +73 -0
- package/lib/common/deployment-protocol.js +175 -0
- package/lib/common/error-protocol.d.ts +43 -0
- package/lib/common/error-protocol.js +48 -0
- package/lib/common/event-protocol.d.ts +64 -0
- package/lib/common/event-protocol.js +3 -0
- package/lib/common/gateway-protocol.d.ts +29 -0
- package/lib/common/index.d.ts +11 -0
- package/lib/common/index.js +11 -0
- package/lib/common/message-protocol.d.ts +135 -0
- package/lib/common/message-protocol.js +325 -0
- package/lib/common/page-protocol.d.ts +57 -0
- package/lib/common/page-protocol.js +15 -0
- package/lib/common/path-map.d.ts +25 -0
- package/lib/common/path-map.js +130 -0
- package/lib/common/presence-protocol.js +7 -7
- package/lib/common/redactor.d.ts +12 -0
- package/lib/common/redactor.js +49 -11
- package/lib/common/relay-protocol.d.ts +20 -0
- package/lib/common/room-protocol.d.ts +52 -1
- package/lib/common/said-protocol.d.ts +77 -0
- package/lib/common/said-protocol.js +242 -0
- package/lib/common/screen-share-protocol.d.ts +305 -0
- package/lib/common/screen-share-protocol.js +91 -0
- package/lib/common/settings-protocol.d.ts +8 -0
- package/lib/common/settings-protocol.js +3 -1
- package/lib/common/ta-extension-host.d.ts +64 -1
- package/lib/common/ta-extension-host.js +9 -1
- package/lib/common/ta-protocol.d.ts +53 -175
- package/lib/common/ta-protocol.js +1 -235
- package/lib/common/team-protocol.d.ts +13 -2
- package/lib/common/team-protocol.js +28 -3
- package/lib/common/voice-protocol.d.ts +185 -0
- package/lib/common/voice-protocol.js +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { TaPackageText } from './package-protocol.js';
|
|
2
|
+
import type { TaRelayOption } from './relay-protocol.js';
|
|
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
|
+
/** When a sound stops what a service reads: voices.json `bargeIn` over the defaults. */
|
|
38
|
+
bargeIn: TaBargeIn;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* When a sound heard while Ta reads is the user cutting in (voices.json `bargeIn`, docs/design/ta-voice.md): the reading
|
|
42
|
+
* first goes on lower, and stops only once the sound is speech long enough or words in its transcript.
|
|
43
|
+
*/
|
|
44
|
+
export interface TaBargeIn {
|
|
45
|
+
/** How loud the reading goes on while a sound may be the user cutting in, 0 to 1. */
|
|
46
|
+
duck: number;
|
|
47
|
+
/** ms of speech that stop the reading: a cough, a knock, a cup set down is shorter. */
|
|
48
|
+
speechMs: number;
|
|
49
|
+
/** The level (RMS, 0 to 1) of the microphone, after its noise suppression, that counts as speech. */
|
|
50
|
+
level: number;
|
|
51
|
+
/** Letters or digits heard in the sound that stop the reading. */
|
|
52
|
+
words: number;
|
|
53
|
+
/** ms after which a sound not known as speech lets the reading go on loud again. */
|
|
54
|
+
waitMs: number;
|
|
55
|
+
/**
|
|
56
|
+
* Ta's own voice heard back: a sound of the microphone softer than this times what plays (after the lowering) is
|
|
57
|
+
* taken for its echo, not the user; nor are words heard while Ta plays with no such louder sound. 0: none is.
|
|
58
|
+
*/
|
|
59
|
+
echo: number;
|
|
60
|
+
/** A sentence the service ended while the user's voice was heard this few ms before goes on: a short pause. */
|
|
61
|
+
joinMs: number;
|
|
62
|
+
/** Only a tap stops the reading: the user's voice never does. */
|
|
63
|
+
tap: boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare namespace TaBargeIn {
|
|
66
|
+
const DEFAULTS: TaBargeIn;
|
|
67
|
+
/**
|
|
68
|
+
* The steps of the sensitivity of Settings, from the least to the most: how long and how loud speech must be to
|
|
69
|
+
* stop the reading. The middle one is the default.
|
|
70
|
+
*/
|
|
71
|
+
const SENSITIVITY: Pick<TaBargeIn, 'speechMs' | 'level'>[];
|
|
72
|
+
/** The step of SENSITIVITY nearest to `bargeIn`, by how long speech must be. */
|
|
73
|
+
function sensitivity(bargeIn: TaBargeIn): number;
|
|
74
|
+
/** Of what is given, the keys of TaBargeIn of the right kind, numbers each kept in its range. */
|
|
75
|
+
function pick(value: unknown): Partial<TaBargeIn>;
|
|
76
|
+
/** What voices.json says, each value a number in its range, the default for one left out or wrong. */
|
|
77
|
+
function resolve(value: unknown): TaBargeIn;
|
|
78
|
+
}
|
|
79
|
+
/** A voice opened for a call (TaVoiceServer.openVoice). */
|
|
80
|
+
export interface TaVoiceSession {
|
|
81
|
+
voiceId: string;
|
|
82
|
+
/** The rate of the PCM16 mono a page sends (sendVoice). */
|
|
83
|
+
inputRate: number;
|
|
84
|
+
/** The rate of the PCM16 mono of `audio` events. */
|
|
85
|
+
outputRate: number;
|
|
86
|
+
speaks: boolean;
|
|
87
|
+
/** When a sound stops the reading: voices.json `bargeIn` over the defaults. */
|
|
88
|
+
bargeIn?: TaBargeIn;
|
|
89
|
+
}
|
|
90
|
+
/** What a voice opened by a connection tells it (TaClient.onVoiceEvent). */
|
|
91
|
+
export type TaVoiceEvent =
|
|
92
|
+
/** The user began to speak: Ta stops reading (barge-in). */
|
|
93
|
+
{
|
|
94
|
+
voiceId: string;
|
|
95
|
+
type: 'speech';
|
|
96
|
+
}
|
|
97
|
+
/** What the user said so far; `final` once a sentence ended. */
|
|
98
|
+
| {
|
|
99
|
+
voiceId: string;
|
|
100
|
+
type: 'text';
|
|
101
|
+
text: string;
|
|
102
|
+
final: boolean;
|
|
103
|
+
}
|
|
104
|
+
/** Audio of the reading `say`: base64 of PCM16 mono at `outputRate`. */
|
|
105
|
+
| {
|
|
106
|
+
voiceId: string;
|
|
107
|
+
type: 'audio';
|
|
108
|
+
say: number;
|
|
109
|
+
data: string;
|
|
110
|
+
}
|
|
111
|
+
/** The reading `say` has all its audio sent. */
|
|
112
|
+
| {
|
|
113
|
+
voiceId: string;
|
|
114
|
+
type: 'said';
|
|
115
|
+
say: number;
|
|
116
|
+
}
|
|
117
|
+
/** It closed, by itself (`error` then says why) or as asked. */
|
|
118
|
+
| {
|
|
119
|
+
voiceId: string;
|
|
120
|
+
type: 'closed';
|
|
121
|
+
error?: string;
|
|
122
|
+
};
|
|
123
|
+
/** The voices of calls for pages (docs/design/ta-voice.md). */
|
|
124
|
+
export interface TaVoiceServer {
|
|
125
|
+
listVoices(): Promise<TaVoices>;
|
|
126
|
+
/** Adds a service of a registered type after opening it once: a wrong key is said now. Its id. */
|
|
127
|
+
addVoice(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
128
|
+
/**
|
|
129
|
+
* Changes a service after opening it once with what it would be: its fields (a secret left empty keeps the one
|
|
130
|
+
* kept) and its name; a wrong key is said now and nothing changes.
|
|
131
|
+
*/
|
|
132
|
+
updateVoice(id: string, options: Record<string, unknown>, name?: string): Promise<void>;
|
|
133
|
+
removeVoice(id: string): Promise<void>;
|
|
134
|
+
/** The service calls use from now on; null for the voice of the device. */
|
|
135
|
+
chooseVoice(id: string | null): Promise<void>;
|
|
136
|
+
/** Sets keys of `bargeIn` in voices.json, the others kept; the next call goes by it. */
|
|
137
|
+
setBargeIn(bargeIn: Partial<TaBargeIn>): Promise<void>;
|
|
138
|
+
/** Opens the service in use for a call of this connection; it closes as the connection does. */
|
|
139
|
+
openVoice(options: {
|
|
140
|
+
language: string;
|
|
141
|
+
}): Promise<TaVoiceSession>;
|
|
142
|
+
/** PCM16 mono at `inputRate`, base64. */
|
|
143
|
+
sendVoice(voiceId: string, audio: string): Promise<void>;
|
|
144
|
+
/** Reads text: the id its audio and its `said` carry. */
|
|
145
|
+
sayVoice(voiceId: string, text: string): Promise<number>;
|
|
146
|
+
/** Stops what it reads. */
|
|
147
|
+
hushVoice(voiceId: string): Promise<void>;
|
|
148
|
+
closeVoice(voiceId: string): Promise<void>;
|
|
149
|
+
}
|
|
150
|
+
/** What a voice service tells Ta as it runs (TaVoiceType.open). */
|
|
151
|
+
export interface TaVoiceEngineEvents {
|
|
152
|
+
speech(): void;
|
|
153
|
+
text(text: string, final: boolean): void;
|
|
154
|
+
audio(pcm: Uint8Array, say: number): void;
|
|
155
|
+
said(say: number): void;
|
|
156
|
+
/** It closed by itself: the connection dropped, the service refused. */
|
|
157
|
+
closed(error?: string): void;
|
|
158
|
+
}
|
|
159
|
+
/** A voice service opened (TaVoiceType.open): what Ta sends it. */
|
|
160
|
+
export interface TaVoiceEngine {
|
|
161
|
+
readonly inputRate: number;
|
|
162
|
+
readonly outputRate: number;
|
|
163
|
+
/** PCM16 mono at `inputRate`. */
|
|
164
|
+
send(pcm: Uint8Array): void;
|
|
165
|
+
/** Reads text aloud, its audio told with `say`; only of a type that `speaks`. */
|
|
166
|
+
say?(text: string, say: number): void;
|
|
167
|
+
/** Stops what it reads; its audio coming late is dropped by Ta anyway. */
|
|
168
|
+
hush(): void;
|
|
169
|
+
close(): void;
|
|
170
|
+
}
|
|
171
|
+
/** A type of voice service a package adds (TaExtensionVoices.registerType): its form, and how it opens. */
|
|
172
|
+
export interface TaVoiceType extends Omit<TaVoiceTypeInfo, 'type'> {
|
|
173
|
+
/** Where it is, in a few words for the list: a host. */
|
|
174
|
+
where(options: Record<string, unknown>): string;
|
|
175
|
+
/** Connects; resolves once it is ready to hear, rejects with why it is not (a wrong key). */
|
|
176
|
+
open(options: Record<string, unknown>, call: {
|
|
177
|
+
language: string;
|
|
178
|
+
}, events: TaVoiceEngineEvents): Promise<TaVoiceEngine>;
|
|
179
|
+
}
|
|
180
|
+
/** voices.json for the server side of packages (TaExtensionHost.voices). */
|
|
181
|
+
export interface TaExtensionVoices {
|
|
182
|
+
/** A type of service: `"type": "<type>"` in voices.json and a form in Settings. Gone with what it returns, or when the package stops. */
|
|
183
|
+
registerType(type: string, definition: TaVoiceType): () => void;
|
|
184
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const TaVoiceServer = Symbol('TaVoiceServer');
|
|
2
|
+
export const TA_VOICE_SERVICE = 'TaVoiceServer';
|
|
3
|
+
export var TaBargeIn;
|
|
4
|
+
(function (TaBargeIn) {
|
|
5
|
+
TaBargeIn.DEFAULTS = { duck: 0.2, speechMs: 500, level: 0.02, words: 2, waitMs: 1500, echo: 0.3, joinMs: 300, tap: false };
|
|
6
|
+
/**
|
|
7
|
+
* The steps of the sensitivity of Settings, from the least to the most: how long and how loud speech must be to
|
|
8
|
+
* stop the reading. The middle one is the default.
|
|
9
|
+
*/
|
|
10
|
+
TaBargeIn.SENSITIVITY = [
|
|
11
|
+
{ speechMs: 1000, level: 0.05 },
|
|
12
|
+
{ speechMs: 750, level: 0.035 },
|
|
13
|
+
{ speechMs: TaBargeIn.DEFAULTS.speechMs, level: TaBargeIn.DEFAULTS.level },
|
|
14
|
+
{ speechMs: 300, level: 0.012 },
|
|
15
|
+
{ speechMs: 150, level: 0.006 },
|
|
16
|
+
];
|
|
17
|
+
/** The step of SENSITIVITY nearest to `bargeIn`, by how long speech must be. */
|
|
18
|
+
function sensitivity(bargeIn) {
|
|
19
|
+
let nearest = 0;
|
|
20
|
+
TaBargeIn.SENSITIVITY.forEach((step, index) => {
|
|
21
|
+
if (Math.abs(step.speechMs - bargeIn.speechMs) < Math.abs(TaBargeIn.SENSITIVITY[nearest].speechMs - bargeIn.speechMs)) {
|
|
22
|
+
nearest = index;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return nearest;
|
|
26
|
+
}
|
|
27
|
+
TaBargeIn.sensitivity = sensitivity;
|
|
28
|
+
/** Of what is given, the keys of TaBargeIn of the right kind, numbers each kept in its range. */
|
|
29
|
+
function pick(value) {
|
|
30
|
+
const given = value && typeof value === 'object' ? value : {};
|
|
31
|
+
const out = typeof given.tap === 'boolean' ? { tap: given.tap } : {};
|
|
32
|
+
for (const key of Object.keys(RANGES)) {
|
|
33
|
+
const number = given[key];
|
|
34
|
+
if (typeof number === 'number' && Number.isFinite(number)) {
|
|
35
|
+
const [min, max] = RANGES[key];
|
|
36
|
+
out[key] = Math.min(max, Math.max(min, number));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
TaBargeIn.pick = pick;
|
|
42
|
+
const RANGES = {
|
|
43
|
+
duck: [0, 1],
|
|
44
|
+
speechMs: [0, 5000],
|
|
45
|
+
level: [0, 1],
|
|
46
|
+
words: [1, 50],
|
|
47
|
+
waitMs: [100, 10000],
|
|
48
|
+
echo: [0, 4],
|
|
49
|
+
joinMs: [0, 3000],
|
|
50
|
+
};
|
|
51
|
+
/** What voices.json says, each value a number in its range, the default for one left out or wrong. */
|
|
52
|
+
function resolve(value) {
|
|
53
|
+
return { ...TaBargeIn.DEFAULTS, ...pick(value) };
|
|
54
|
+
}
|
|
55
|
+
TaBargeIn.resolve = resolve;
|
|
56
|
+
})(TaBargeIn || (TaBargeIn = {}));
|
|
57
|
+
//# sourceMappingURL=voice-protocol.js.map
|
|
@@ -6,6 +6,42 @@ export declare const TA_ACCESS_SERVICE = "TaAccessServer";
|
|
|
6
6
|
* pages the browser goes to, not calls: they need no token, and give one.
|
|
7
7
|
*/
|
|
8
8
|
export declare const TA_SIGN_IN_PATH = "/sign-in";
|
|
9
|
+
/**
|
|
10
|
+
* Signing in a device that is not a browser of this address (the app on a phone, Ta Desktop, another Ta): as OAuth 2.0's
|
|
11
|
+
* device flow (RFC 8628), the device asks for a code (`POST` this path), the user signs in in a browser at
|
|
12
|
+
* {@link TaDeviceSignIn.url} and lets it in, and the device takes its token (`POST <path>/poll`). These two answer
|
|
13
|
+
* any origin: they hold no cookie, and what they give goes to who holds the secret of the device.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TA_DEVICE_SIGN_IN_PATH = "/sign-in/device";
|
|
16
|
+
/** What `POST` {@link TA_DEVICE_SIGN_IN_PATH} answers: the device keeps `device`, the user sees `code`. */
|
|
17
|
+
export interface TaDeviceSignIn {
|
|
18
|
+
/** The secret the device polls with: whoever holds it gets the token. */
|
|
19
|
+
device: string;
|
|
20
|
+
/** What the device shows, and the page of {@link url} too: the user checks they are the same. */
|
|
21
|
+
code: string;
|
|
22
|
+
/** Where the user signs in, with the code in it. */
|
|
23
|
+
url: string;
|
|
24
|
+
/** Until when the user may sign in (`Date.now()` time). */
|
|
25
|
+
expiresAt: number;
|
|
26
|
+
/** How often the device polls, in milliseconds. */
|
|
27
|
+
interval: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What polling says: `pending` until the user signed in; `waiting` while their account is not let in yet (they asked, and
|
|
31
|
+
* whoever manages it lets them in, or not); `done` once, with the token; `expired` for a device unknown or too late.
|
|
32
|
+
*/
|
|
33
|
+
export type TaDeviceSignInState = {
|
|
34
|
+
status: 'pending';
|
|
35
|
+
} | {
|
|
36
|
+
status: 'waiting';
|
|
37
|
+
account: string;
|
|
38
|
+
} | {
|
|
39
|
+
status: 'done';
|
|
40
|
+
token: string;
|
|
41
|
+
account: string;
|
|
42
|
+
} | {
|
|
43
|
+
status: 'expired';
|
|
44
|
+
};
|
|
9
45
|
/** What a sign-in that did not let the browser in says in the fragment of the page it comes back to. */
|
|
10
46
|
export type TaSignInOutcome = 'denied' | 'failed';
|
|
11
47
|
/** A way to sign in: `github`, `google`, `wechat`, `oidc` (a provider of the operator's). */
|
|
@@ -18,6 +54,11 @@ export interface TaSignInProvider {
|
|
|
18
54
|
* back: Ta's own GitHub app, which needs no secret, for those asking to come in (docs/design/ta-team.md 17.4).
|
|
19
55
|
*/
|
|
20
56
|
device?: true;
|
|
57
|
+
/**
|
|
58
|
+
* One signs in at it in a browser that does not come back, and Ta asks it who agreed (a company's sign-in for CLIs): for a
|
|
59
|
+
* device only, `<path>/<provider>?device=<code>` (TA_DEVICE_SIGN_IN_PATH); a page of this address signs in as a device.
|
|
60
|
+
*/
|
|
61
|
+
polled?: true;
|
|
21
62
|
}
|
|
22
63
|
/** The answer of `GET` {@link TA_SIGN_IN_PATH}. */
|
|
23
64
|
export interface TaSignInWays {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TA_SIGN_IN_PATH = exports.TA_ACCESS_SERVICE = exports.TaAccessServer = void 0;
|
|
3
|
+
exports.TA_DEVICE_SIGN_IN_PATH = exports.TA_SIGN_IN_PATH = exports.TA_ACCESS_SERVICE = exports.TaAccessServer = void 0;
|
|
4
4
|
exports.TaAccessServer = Symbol('TaAccessServer');
|
|
5
5
|
exports.TA_ACCESS_SERVICE = 'TaAccessServer';
|
|
6
6
|
/**
|
|
@@ -9,4 +9,11 @@ exports.TA_ACCESS_SERVICE = 'TaAccessServer';
|
|
|
9
9
|
* pages the browser goes to, not calls: they need no token, and give one.
|
|
10
10
|
*/
|
|
11
11
|
exports.TA_SIGN_IN_PATH = '/sign-in';
|
|
12
|
+
/**
|
|
13
|
+
* Signing in a device that is not a browser of this address (the app on a phone, Ta Desktop, another Ta): as OAuth 2.0's
|
|
14
|
+
* device flow (RFC 8628), the device asks for a code (`POST` this path), the user signs in in a browser at
|
|
15
|
+
* {@link TaDeviceSignIn.url} and lets it in, and the device takes its token (`POST <path>/poll`). These two answer
|
|
16
|
+
* any origin: they hold no cookie, and what they give goes to who holds the secret of the device.
|
|
17
|
+
*/
|
|
18
|
+
exports.TA_DEVICE_SIGN_IN_PATH = `${exports.TA_SIGN_IN_PATH}/device`;
|
|
12
19
|
//# sourceMappingURL=access-protocol.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { TaLanguage } from './language';
|
|
2
|
+
/**
|
|
3
|
+
* What an action of the catalog of Ta risks (docs/design/ta-app-use.md 7): `read` only looks, `act` changes what can
|
|
4
|
+
* be changed back (a setting, a pin), `danger` what cannot or should not without the user (remove, publish, grant,
|
|
5
|
+
* answer for them): asked for by a run, that one waits for the user to agree on their screen (TA_PAGE_CONFIRM).
|
|
6
|
+
*/
|
|
7
|
+
export type TaAppRisk = 'read' | 'act' | 'danger';
|
|
8
|
+
/** An action of the catalog, as the model and the pages read it. */
|
|
9
|
+
export interface TaAppCommandInfo {
|
|
10
|
+
/** `<area>.<verb>`: `settings.set`. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** For the user, in the notice of what Ta did. */
|
|
13
|
+
title: Readonly<Record<TaLanguage, string>>;
|
|
14
|
+
/** For the model, in English: what it does, when to use it, what it answers. */
|
|
15
|
+
description: string;
|
|
16
|
+
/** A JSON schema of an object; none: it takes nothing. */
|
|
17
|
+
input?: Record<string, unknown>;
|
|
18
|
+
risk: TaAppRisk;
|
|
19
|
+
/** What it needs of who asked the run, an action of TA_ACTIONS or one a package declares. */
|
|
20
|
+
action: string;
|
|
21
|
+
/** The package that added it; none for those of Ta itself. */
|
|
22
|
+
owner?: string;
|
|
23
|
+
}
|
|
24
|
+
/** What an action did. */
|
|
25
|
+
export interface TaAppCommandResult {
|
|
26
|
+
/** For the model, in English, short. */
|
|
27
|
+
text: string;
|
|
28
|
+
/** What it read or changed, as JSON. */
|
|
29
|
+
data?: unknown;
|
|
30
|
+
/** For the user, in their language, a few words of what Ta did (`修改了设置`): the head of the notice; none for no notice. */
|
|
31
|
+
notice?: string;
|
|
32
|
+
/** For the user, in their language: what changed, a row each under the head of the notice. */
|
|
33
|
+
changes?: TaAppChange[];
|
|
34
|
+
/** What changes it back: an action and its input. */
|
|
35
|
+
undo?: {
|
|
36
|
+
command: string;
|
|
37
|
+
input: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** One thing an action changed, as the user reads it: `通话字幕 关 → 开`, or a name alone (`登录修复`). */
|
|
41
|
+
export interface TaAppChange {
|
|
42
|
+
label?: string;
|
|
43
|
+
before?: string;
|
|
44
|
+
after: string;
|
|
45
|
+
}
|
|
46
|
+
/** Who an action runs for. */
|
|
47
|
+
export interface TaAppCommandContext {
|
|
48
|
+
/** TA_OWNER, or one let in (ta-team). */
|
|
49
|
+
principal: string;
|
|
50
|
+
/** That of the pages (TaLanguageUtil.server). */
|
|
51
|
+
language: TaLanguage;
|
|
52
|
+
/** The conversation whose run asked for it. */
|
|
53
|
+
sessionFile?: string;
|
|
54
|
+
}
|
|
55
|
+
/** An action of the catalog and what runs it. */
|
|
56
|
+
export interface TaAppCommand extends Omit<TaAppCommandInfo, 'owner'> {
|
|
57
|
+
/**
|
|
58
|
+
* For a danger action, what the user agrees to beyond its title, in their language (`登录修复:用哪个分支 → dev`);
|
|
59
|
+
* it may throw for an input that cannot run, so the user is not asked for nothing.
|
|
60
|
+
*/
|
|
61
|
+
detail?(input: Record<string, unknown>, context: TaAppCommandContext): Promise<string | undefined>;
|
|
62
|
+
run(input: Record<string, unknown>, context: TaAppCommandContext): Promise<TaAppCommandResult>;
|
|
63
|
+
}
|
|
64
|
+
/** Who asks for an action: the run of a conversation (each who asked it), or one principal (a tap on a page). */
|
|
65
|
+
export interface TaAppRunOptions {
|
|
66
|
+
sessionFile?: string;
|
|
67
|
+
principal?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The catalog of what can be done to Ta without its pages (docs/design/ta-app-use.md 2): change a setting, pin a
|
|
71
|
+
* conversation, turn an extension off. The buttons of the pages change the same data, so a page shows at once
|
|
72
|
+
* what an action did, and an agent does what the user can without moving a cursor.
|
|
73
|
+
*/
|
|
74
|
+
export interface TaHostCommands {
|
|
75
|
+
list(): TaAppCommandInfo[];
|
|
76
|
+
/**
|
|
77
|
+
* Runs an action for who asked (TaAppRunOptions): each must be let to do its `action`. Throws with what is wrong:
|
|
78
|
+
* no such action, not let to, an input it does not take, a `danger` one the user did not agree to on their screen.
|
|
79
|
+
*/
|
|
80
|
+
run(id: string, input?: Record<string, unknown>, options?: TaAppRunOptions): Promise<TaAppCommandResult>;
|
|
81
|
+
/** Adds an action, gone with the function returned or when the package stops. */
|
|
82
|
+
register(command: TaAppCommand): () => void;
|
|
83
|
+
}
|
|
84
|
+
/** The tools of ta-app-use, the catalog and the screen: a call's front has them too. */
|
|
85
|
+
export declare const TA_APP_TOOLS: readonly ['app_commands', 'app_run', 'app_look', 'app_go', 'app_do'];
|
|
86
|
+
/** Where the web client keeps its settings (TaState `user`): in the data of packages, under this name and key. */
|
|
87
|
+
export declare const TA_WEB_SETTINGS_DATA: {
|
|
88
|
+
readonly name: '@celljs/ta-web';
|
|
89
|
+
readonly key: 'settings';
|
|
90
|
+
};
|
|
91
|
+
/** Where the web client keeps the conversations pinned to the top of its lists: their session files, and keys of folders. */
|
|
92
|
+
export declare const TA_CHAT_PINNED: {
|
|
93
|
+
readonly name: '@celljs/ta-web';
|
|
94
|
+
readonly key: 'chat.pinned';
|
|
95
|
+
};
|
|
96
|
+
/** A setting of the web client an action may change (settings.set), as the settings page offers it. */
|
|
97
|
+
export interface TaWebSettingSpec {
|
|
98
|
+
key: string;
|
|
99
|
+
type: 'boolean' | 'enum' | 'number' | 'string' | 'model';
|
|
100
|
+
/** The values it may be, for `enum` and `number`. */
|
|
101
|
+
values?: readonly (string | number)[];
|
|
102
|
+
default: boolean | number | string;
|
|
103
|
+
/** For the model, in English. */
|
|
104
|
+
what: string;
|
|
105
|
+
title: Readonly<Record<TaLanguage, string>>;
|
|
106
|
+
/** What the user calls its values, by value, where the value itself is a word of the code. */
|
|
107
|
+
shown?: Readonly<Record<string, Readonly<Record<TaLanguage, string>>>>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The settings of the web client (Settings of ta-web) an agent may change: those the settings page shows with a
|
|
111
|
+
* switch or a choice. Not `trustedDomains` (links open without asking), nor `navigation` and `builtinsOff`, which
|
|
112
|
+
* have pages and actions of their own. The tests of ta-web hold these to its defaults and choices.
|
|
113
|
+
*/
|
|
114
|
+
export declare const TA_WEB_SETTINGS: readonly TaWebSettingSpec[];
|
|
115
|
+
export declare namespace TaAppUtil {
|
|
116
|
+
/** `value` for the setting, or why not: a value of its type and among its values. */
|
|
117
|
+
function check(spec: TaWebSettingSpec, value: unknown): string | undefined;
|
|
118
|
+
/** A value as the user reads it: on and off for a switch, the words of a choice (TaWebSettingSpec.shown). */
|
|
119
|
+
function shown(value: unknown, language: TaLanguage, spec?: TaWebSettingSpec): string;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=app-protocol.d.ts.map
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaAppUtil = exports.TA_WEB_SETTINGS = exports.TA_CHAT_PINNED = exports.TA_WEB_SETTINGS_DATA = exports.TA_APP_TOOLS = void 0;
|
|
4
|
+
const delegate_protocol_1 = require("./delegate-protocol");
|
|
5
|
+
const language_1 = require("./language");
|
|
6
|
+
/** The tools of ta-app-use, the catalog and the screen: a call's front has them too. */
|
|
7
|
+
exports.TA_APP_TOOLS = ['app_commands', 'app_run', 'app_look', 'app_go', 'app_do'];
|
|
8
|
+
/** Where the web client keeps its settings (TaState `user`): in the data of packages, under this name and key. */
|
|
9
|
+
exports.TA_WEB_SETTINGS_DATA = { name: '@celljs/ta-web', key: 'settings' };
|
|
10
|
+
/** Where the web client keeps the conversations pinned to the top of its lists: their session files, and keys of folders. */
|
|
11
|
+
exports.TA_CHAT_PINNED = { name: '@celljs/ta-web', key: 'chat.pinned' };
|
|
12
|
+
const FONT_SIZES = ['small', 'standard', 'large', 'xlarge'];
|
|
13
|
+
const words = (en, zh, tw, ja) => ({ 'en-US': en, 'zh-CN': zh, 'zh-TW': tw, 'ja-JP': ja });
|
|
14
|
+
const SYSTEM = words('as the system', '跟随系统', '跟隨系統', 'システムに合わせる');
|
|
15
|
+
const FONT_SHOWN = {
|
|
16
|
+
small: words('small', '小', '小', '小'),
|
|
17
|
+
standard: words('standard', '标准', '標準', '標準'),
|
|
18
|
+
large: words('large', '大', '大', '大'),
|
|
19
|
+
xlarge: words('extra large', '特大', '特大', '特大'),
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The settings of the web client (Settings of ta-web) an agent may change: those the settings page shows with a
|
|
23
|
+
* switch or a choice. Not `trustedDomains` (links open without asking), nor `navigation` and `builtinsOff`, which
|
|
24
|
+
* have pages and actions of their own. The tests of ta-web hold these to its defaults and choices.
|
|
25
|
+
*/
|
|
26
|
+
exports.TA_WEB_SETTINGS = [
|
|
27
|
+
{
|
|
28
|
+
key: 'theme',
|
|
29
|
+
type: 'enum',
|
|
30
|
+
values: ['system', 'light', 'dark'],
|
|
31
|
+
default: 'system',
|
|
32
|
+
what: 'Light or dark look; system follows the device.',
|
|
33
|
+
title: words('Theme', '外观', '外觀', '外観'),
|
|
34
|
+
shown: { system: SYSTEM, light: words('light', '浅色', '淺色', 'ライト'), dark: words('dark', '深色', '深色', 'ダーク') },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: 'language',
|
|
38
|
+
type: 'enum',
|
|
39
|
+
values: ['system', ...language_1.TaLanguageUtil.ALL],
|
|
40
|
+
default: 'system',
|
|
41
|
+
what: "The language of Ta's pages and of what Ta says; system follows the device.",
|
|
42
|
+
title: words('Language', '语言', '語言', '言語'),
|
|
43
|
+
shown: {
|
|
44
|
+
system: SYSTEM,
|
|
45
|
+
...Object.fromEntries(language_1.TaLanguageUtil.ALL.map(language => [
|
|
46
|
+
language,
|
|
47
|
+
words(language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language], language_1.TaLanguageUtil.NAMES[language]),
|
|
48
|
+
])),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'fontSize',
|
|
53
|
+
type: 'enum',
|
|
54
|
+
values: FONT_SIZES,
|
|
55
|
+
default: 'standard',
|
|
56
|
+
what: 'The size of the text of the whole page.',
|
|
57
|
+
title: words('Text size', '字体大小', '字型大小', '文字サイズ'),
|
|
58
|
+
shown: FONT_SHOWN,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: 'chatFontSize',
|
|
62
|
+
type: 'enum',
|
|
63
|
+
values: FONT_SIZES,
|
|
64
|
+
default: 'standard',
|
|
65
|
+
what: 'The size of the text of conversations, on top of fontSize.',
|
|
66
|
+
title: words('Text size of conversations', '对话字体大小', '對話字型大小', '会話の文字サイズ'),
|
|
67
|
+
shown: FONT_SHOWN,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: 'speak',
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
default: false,
|
|
73
|
+
what: 'Read every reply aloud.',
|
|
74
|
+
title: words('Read replies aloud', '朗读回复', '朗讀回覆', '返信を読み上げ'),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: 'speakTalk',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: false,
|
|
80
|
+
what: 'Read the reply aloud when the user spoke to the double by voice.',
|
|
81
|
+
title: words('Read aloud what was asked by voice', '语音提问时朗读回复', '語音提問時朗讀回覆', '音声で聞いたら読み上げ'),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: 'callCaptions',
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
default: false,
|
|
87
|
+
what: 'Show captions in a call: what the user says and what Ta reads.',
|
|
88
|
+
title: words('Call captions', '通话字幕', '通話字幕', '通話の字幕'),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: 'voice',
|
|
92
|
+
type: 'string',
|
|
93
|
+
default: '',
|
|
94
|
+
what: "The voice replies are read with (a voiceURI of the device's voices); empty for the most natural one.",
|
|
95
|
+
title: words('Voice', '朗读声音', '朗讀聲音', '読み上げの声'),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: 'confirmTasks',
|
|
99
|
+
type: 'boolean',
|
|
100
|
+
default: false,
|
|
101
|
+
what: 'The double asks before it hands out work.',
|
|
102
|
+
title: words('Ask before handing out work', '派任务前先问我', '派任務前先問我', '作業を割り当てる前に確認'),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: 'maxTasks',
|
|
106
|
+
type: 'number',
|
|
107
|
+
values: [0, 2, 4, 8],
|
|
108
|
+
default: 0,
|
|
109
|
+
what: "How many of the double's tasks run at once; 0 for as many as it starts.",
|
|
110
|
+
title: words('Tasks at once', '同时运行的任务', '同時執行的任務', '同時に実行するタスク'),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: 'delegate',
|
|
114
|
+
type: 'enum',
|
|
115
|
+
values: delegate_protocol_1.TaDelegateUtil.LEVELS,
|
|
116
|
+
default: delegate_protocol_1.TaDelegateUtil.DEFAULT,
|
|
117
|
+
what: 'How much of the work the double hands out to tasks rather than doing it itself.',
|
|
118
|
+
title: words('Hand out work', '派活多少', '派活多少', '作業の割り当て'),
|
|
119
|
+
shown: { less: words('less', '少', '少', '少なめ'), balanced: words('balanced', '适中', '適中', 'ふつう'), more: words('more', '多', '多', '多め') },
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
key: 'assistantModel',
|
|
123
|
+
type: 'model',
|
|
124
|
+
default: '',
|
|
125
|
+
what: 'The model of the double, <provider>/<model id>; empty for the default model.',
|
|
126
|
+
title: words('Model of the double', '分身的模型', '分身的模型', '分身のモデル'),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
key: 'taskModel',
|
|
130
|
+
type: 'model',
|
|
131
|
+
default: '',
|
|
132
|
+
what: 'The model of the tasks the double starts; empty for the default model.',
|
|
133
|
+
title: words('Model of tasks', '任务的模型', '任務的模型', 'タスクのモデル'),
|
|
134
|
+
},
|
|
135
|
+
{ key: 'reduceMotion', type: 'boolean', default: false, what: 'Fewer animations.', title: words('Reduce motion', '减少动画', '減少動畫', '動きを減らす') },
|
|
136
|
+
{
|
|
137
|
+
key: 'diagramStyle',
|
|
138
|
+
type: 'enum',
|
|
139
|
+
values: ['clean', 'sketch', 'colour', 'motion'],
|
|
140
|
+
default: 'clean',
|
|
141
|
+
what: 'How diagrams in replies draw: in the colours of the page, as by hand, a colour to a node, or coming in with flowing lines.',
|
|
142
|
+
title: words('Diagram style', '图表风格', '圖表風格', '図のスタイル'),
|
|
143
|
+
shown: {
|
|
144
|
+
clean: words('clean', '简洁', '簡潔', 'シンプル'),
|
|
145
|
+
sketch: words('sketch', '草图', '草圖', 'スケッチ'),
|
|
146
|
+
colour: words('colour', '彩色', '彩色', 'カラー'),
|
|
147
|
+
motion: words('motion', '动效', '動效', 'モーション'),
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
key: 'keepAliveMinutes',
|
|
152
|
+
type: 'number',
|
|
153
|
+
values: [1, 5, 15, 30],
|
|
154
|
+
default: 5,
|
|
155
|
+
what: 'How long an extension started on open keeps running once left, in minutes.',
|
|
156
|
+
title: words('Keep extensions running', '扩展离开后保留', '擴充功能離開後保留', '拡張機能を保持'),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
key: 'chatFoldDays',
|
|
160
|
+
type: 'number',
|
|
161
|
+
values: [3, 7, 30, 0],
|
|
162
|
+
default: 7,
|
|
163
|
+
what: 'Conversations not updated for these days fold at the end of the list; 0 for none.',
|
|
164
|
+
title: words('Fold old conversations', '折叠旧对话', '摺疊舊對話', '古い会話を折りたたむ'),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: 'chatArchiveDays',
|
|
168
|
+
type: 'number',
|
|
169
|
+
values: [30, 90, 365, 0],
|
|
170
|
+
default: 30,
|
|
171
|
+
what: 'Conversations not updated for these days are archived (out of the list, found by search); 0 for none.',
|
|
172
|
+
title: words('Archive old conversations', '归档旧对话', '歸檔舊對話', '古い会話をアーカイブ'),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
key: 'recentShots',
|
|
176
|
+
type: 'boolean',
|
|
177
|
+
default: true,
|
|
178
|
+
what: 'The screenshot just taken is offered above the message box, once.',
|
|
179
|
+
title: words('Offer recent screenshots', '提示刚截的图', '提示剛截的圖', '撮ったばかりのスクリーンショットを提案'),
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
var TaAppUtil;
|
|
183
|
+
(function (TaAppUtil) {
|
|
184
|
+
/** `value` for the setting, or why not: a value of its type and among its values. */
|
|
185
|
+
function check(spec, value) {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
switch (spec.type) {
|
|
188
|
+
case 'boolean':
|
|
189
|
+
return typeof value === 'boolean' ? undefined : 'true or false';
|
|
190
|
+
case 'string':
|
|
191
|
+
return typeof value === 'string' ? undefined : 'a string';
|
|
192
|
+
case 'model':
|
|
193
|
+
return value === '' || (typeof value === 'string' && /^[^/\s]+\/\S+$/.test(value)) ? undefined : '<provider>/<model id>, or empty';
|
|
194
|
+
default:
|
|
195
|
+
return ((_a = spec.values) === null || _a === void 0 ? void 0 : _a.includes(value)) ? undefined : `one of ${(_b = spec.values) === null || _b === void 0 ? void 0 : _b.map(one => JSON.stringify(one)).join(', ')}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
TaAppUtil.check = check;
|
|
199
|
+
/** A value as the user reads it: on and off for a switch, the words of a choice (TaWebSettingSpec.shown). */
|
|
200
|
+
function shown(value, language, spec) {
|
|
201
|
+
var _a;
|
|
202
|
+
const named = (_a = spec === null || spec === void 0 ? void 0 : spec.shown) === null || _a === void 0 ? void 0 : _a[String(value)];
|
|
203
|
+
if (named) {
|
|
204
|
+
return language_1.TaLanguageUtil.pick(language, named);
|
|
205
|
+
}
|
|
206
|
+
if (typeof value === 'boolean') {
|
|
207
|
+
return language_1.TaLanguageUtil.pick(language, value ? words('on', '开', '開', 'オン') : words('off', '关', '關', 'オフ'));
|
|
208
|
+
}
|
|
209
|
+
if (value === '' || value === undefined || value === null) {
|
|
210
|
+
return language_1.TaLanguageUtil.pick(language, words('default', '默认', '預設', 'デフォルト'));
|
|
211
|
+
}
|
|
212
|
+
return String(value);
|
|
213
|
+
}
|
|
214
|
+
TaAppUtil.shown = shown;
|
|
215
|
+
})(TaAppUtil || (exports.TaAppUtil = TaAppUtil = {}));
|
|
216
|
+
//# sourceMappingURL=app-protocol.js.map
|