@celljs/ta-protocol 4.17.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 +7 -2
- package/esm/common/app-protocol.js +14 -0
- package/esm/common/deployment-protocol.d.ts +13 -0
- package/esm/common/deployment-protocol.js +36 -0
- package/esm/common/index.d.ts +2 -0
- package/esm/common/index.js +2 -0
- package/esm/common/message-protocol.d.ts +43 -4
- package/esm/common/message-protocol.js +97 -12
- package/esm/common/room-protocol.d.ts +45 -0
- 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 +33 -0
- package/esm/common/ta-extension-host.js +6 -0
- package/esm/common/ta-protocol.d.ts +3 -0
- package/esm/common/team-protocol.d.ts +13 -2
- package/esm/common/team-protocol.js +27 -2
- package/esm/common/voice-protocol.d.ts +45 -0
- package/esm/common/voice-protocol.js +54 -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 +7 -2
- package/lib/common/app-protocol.js +14 -0
- package/lib/common/deployment-protocol.d.ts +13 -0
- package/lib/common/deployment-protocol.js +36 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/message-protocol.d.ts +43 -4
- package/lib/common/message-protocol.js +98 -13
- package/lib/common/room-protocol.d.ts +45 -0
- 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 +33 -0
- package/lib/common/ta-extension-host.js +7 -1
- package/lib/common/ta-protocol.d.ts +3 -0
- package/lib/common/team-protocol.d.ts +13 -2
- package/lib/common/team-protocol.js +28 -3
- package/lib/common/voice-protocol.d.ts +45 -0
- package/lib/common/voice-protocol.js +55 -1
- package/package.json +1 -1
|
@@ -26,6 +26,8 @@ export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listS
|
|
|
26
26
|
readonly relays: TaExtensionRelays;
|
|
27
27
|
/** The voice services of calls, as packages add types of them (docs/design/ta-voice.md). */
|
|
28
28
|
readonly voices: TaExtensionVoices;
|
|
29
|
+
/** Where sign-ins Ta itself uses are kept, as a package keeps them (the vault): the password of a remote desktop. */
|
|
30
|
+
readonly credentials: TaExtensionCredentials;
|
|
29
31
|
/** pi's messages of a session file, of the branch it is on (its first message first), without opening it. */
|
|
30
32
|
sessionMessages(sessionFile: string): Promise<unknown[]>;
|
|
31
33
|
/** The role a session file was opened with last (TaOpenSessionOptions.appendSystemPrompt), without opening it; undefined without one. */
|
|
@@ -60,6 +62,31 @@ export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listS
|
|
|
60
62
|
*/
|
|
61
63
|
updateSettings(update: (settings: Record<string, unknown>) => Record<string, unknown>): Promise<void>;
|
|
62
64
|
}
|
|
65
|
+
/** A sign-in Ta gives on the user's behalf: the account of the Screen Sharing of macOS, or the password of VNC. */
|
|
66
|
+
export interface TaCredential {
|
|
67
|
+
username?: string;
|
|
68
|
+
password: string;
|
|
69
|
+
}
|
|
70
|
+
/** What a sign-in is for, for the page that lists what is kept. */
|
|
71
|
+
export interface TaCredentialAbout {
|
|
72
|
+
/** `desktop`: a remote desktop. */
|
|
73
|
+
feature: 'desktop';
|
|
74
|
+
/** The name of what it signs in to: the computer. */
|
|
75
|
+
name: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Where Ta keeps sign-ins it gives by itself, by an id of its own (`desktop:<id of the desktop>`). Never for the
|
|
79
|
+
* model, nor a command, nor a page: ta serve alone reads them.
|
|
80
|
+
*/
|
|
81
|
+
export interface TaCredentialStore {
|
|
82
|
+
get(id: string): Promise<TaCredential | undefined>;
|
|
83
|
+
set(id: string, credential: TaCredential, about: TaCredentialAbout): Promise<void>;
|
|
84
|
+
remove(id: string): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
/** Sign-ins for the server side of packages: one package keeps them (the vault), gone again with what register returns. */
|
|
87
|
+
export interface TaExtensionCredentials {
|
|
88
|
+
register(store: TaCredentialStore): () => void;
|
|
89
|
+
}
|
|
63
90
|
/** relays.json for the server side of packages: which service a feature uses, and choosing one for it. */
|
|
64
91
|
export interface TaExtensionRelays {
|
|
65
92
|
/** The service a feature uses now: a relay of Ta, or a folder (only `sync` goes to one). */
|
|
@@ -329,6 +356,12 @@ export interface TaNotice {
|
|
|
329
356
|
* conversations, what they asked before) leaves such a session out: what it says goes to others.
|
|
330
357
|
*/
|
|
331
358
|
export declare const TA_WITH_OTHERS_MARK = "[ta:speaks-with-others]";
|
|
359
|
+
/**
|
|
360
|
+
* In the role of a session a package opened that tells the user of its turns itself (the conversation of a goal,
|
|
361
|
+
* ta-goals): ta-notify tells of its turns only when they fail or ask, as of a session of a `group`, which this one is
|
|
362
|
+
* not, so that it stays a conversation of the lists.
|
|
363
|
+
*/
|
|
364
|
+
export declare const TA_TELLS_OF_ITS_TURNS_MARK = "[ta:tells-of-its-turns]";
|
|
332
365
|
/**
|
|
333
366
|
* Starts the `<context>` of a message of the user that asks Ta to keep how a conversation got its work done, so that it
|
|
334
367
|
* need not be told again (Keep of ta-recall, in the + of the message box): Ta picks the form that fits. A package that
|
|
@@ -105,6 +105,12 @@ export const TA_NOTICES = { name: '@celljs/ta-notify', key: 'notices' };
|
|
|
105
105
|
* conversations, what they asked before) leaves such a session out: what it says goes to others.
|
|
106
106
|
*/
|
|
107
107
|
export const TA_WITH_OTHERS_MARK = '[ta:speaks-with-others]';
|
|
108
|
+
/**
|
|
109
|
+
* In the role of a session a package opened that tells the user of its turns itself (the conversation of a goal,
|
|
110
|
+
* ta-goals): ta-notify tells of its turns only when they fail or ask, as of a session of a `group`, which this one is
|
|
111
|
+
* not, so that it stays a conversation of the lists.
|
|
112
|
+
*/
|
|
113
|
+
export const TA_TELLS_OF_ITS_TURNS_MARK = '[ta:tells-of-its-turns]';
|
|
108
114
|
/**
|
|
109
115
|
* Starts the `<context>` of a message of the user that asks Ta to keep how a conversation got its work done, so that it
|
|
110
116
|
* need not be told again (Keep of ta-recall, in the + of the message box): Ta picks the form that fits. A package that
|
|
@@ -4,6 +4,7 @@ import type { ImageContent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIRes
|
|
|
4
4
|
import type { TaSessionPerson } from './presence-protocol.js';
|
|
5
5
|
import type { TaRemoteEvent } from './remote-protocol.js';
|
|
6
6
|
import type { TaRoomEvent } from './room-protocol.js';
|
|
7
|
+
import type { TaDesktopEvent } from './screen-share-protocol.js';
|
|
7
8
|
import type { TaAsking } from './ta-extension-host.js';
|
|
8
9
|
import type { TaMemberInfo } from './team-protocol.js';
|
|
9
10
|
import type { TaVoiceEvent } from './voice-protocol.js';
|
|
@@ -483,6 +484,8 @@ export interface TaClient {
|
|
|
483
484
|
onRoomEvent(event: TaRoomEvent): Promise<void>;
|
|
484
485
|
/** What a voice this connection opened for a call tells (TaVoiceServer.openVoice). */
|
|
485
486
|
onVoiceEvent(event: TaVoiceEvent): Promise<void>;
|
|
487
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
488
|
+
onScreenShareEvent(event: TaDesktopEvent): Promise<void>;
|
|
486
489
|
/**
|
|
487
490
|
* ta serve asks this page something (TaPageServer.attach said it answers `kind`): what it answers, or an error. Only
|
|
488
491
|
* a page of the person whose run asks is asked (docs/design/ta-app-use.md 4.1).
|
|
@@ -16,7 +16,7 @@ export interface TaSharedRef {
|
|
|
16
16
|
/** What an action is done on. */
|
|
17
17
|
export interface TaResource {
|
|
18
18
|
/** `session`: a conversation, by its file; `dir`: a directory or a file in it, by its path; `agent`, `channel`: one of ta-channels, by its id. */
|
|
19
|
-
kind: 'session' | 'dir' | 'agent' | 'channel';
|
|
19
|
+
kind: 'session' | 'dir' | 'agent' | 'channel' | 'desktop';
|
|
20
20
|
/** The session file, the path, or the id of the agent or channel. */
|
|
21
21
|
id: string;
|
|
22
22
|
/** A session: where it works. */
|
|
@@ -128,14 +128,25 @@ export interface TaActionInfo {
|
|
|
128
128
|
scoped?: boolean;
|
|
129
129
|
/** Reaches beyond what Ta checks (a command can touch any file): only for people trusted. */
|
|
130
130
|
risky?: boolean;
|
|
131
|
+
/** `single`: given only on its own to one person, never by a role (docs/design/ta-desktop-remote.md 6.2). */
|
|
132
|
+
grant?: 'role' | 'single';
|
|
131
133
|
}
|
|
132
|
-
export type TaActionArea = 'chat' | 'agent' | 'channel' | 'task' | 'files' | 'commands' | 'hosts' | 'models' | 'cron' | 'extensions' | 'settings' | 'members' | 'audit';
|
|
134
|
+
export type TaActionArea = 'chat' | 'agent' | 'channel' | 'task' | 'files' | 'commands' | 'hosts' | 'models' | 'cron' | 'extensions' | 'settings' | 'members' | 'audit' | 'desktop';
|
|
133
135
|
/** Every action of Ta itself; packages add their own (`pi.permissions` of their package.json). */
|
|
134
136
|
export declare const TA_ACTIONS: readonly TaActionInfo[];
|
|
137
|
+
/**
|
|
138
|
+
* Actions of the owner alone (docs/design/ta-desktop-remote.md 6.2): their words for records and notices, never in
|
|
139
|
+
* TA_ACTIONS, so that no role or grant gives them; TaActionUtil.grantable says no to every one of their areas.
|
|
140
|
+
*/
|
|
141
|
+
export declare const TA_OWNER_ACTIONS: readonly TaActionInfo[];
|
|
135
142
|
export declare namespace TaActionUtil {
|
|
136
143
|
function info(id: string): TaActionInfo | undefined;
|
|
137
144
|
/** Its title in a language such as `zh-CN`; the id for an action of no catalog. */
|
|
138
145
|
function title(id: string, language: string): string;
|
|
146
|
+
/** Whether an action may be given to someone at all, by a role or on its own: one of TA_ACTIONS, of no area of the owner's. */
|
|
147
|
+
function grantable(id: string): boolean;
|
|
148
|
+
/** Whether an action may be in a role: grantable, and not one given only on its own (`grant: 'single'`). */
|
|
149
|
+
function inRoles(id: string): boolean;
|
|
139
150
|
/** Whether `path` is `dir` or inside it; both absolute, `/` separated. */
|
|
140
151
|
function inside(dir: string, path: string): boolean;
|
|
141
152
|
}
|
|
@@ -67,7 +67,8 @@ export const TA_ACTIONS = [
|
|
|
67
67
|
action('commands.terminal', 'Open terminals', '打开终端', '開啟終端機', 'ターミナルを開く', { scoped: true, risky: true }),
|
|
68
68
|
action('hosts.use', 'Use remote hosts', '使用远程主机', '使用遠端主機', 'リモートホストを使用', { risky: true }),
|
|
69
69
|
action('models.use', 'Use the models', '使用模型', '使用模型', 'モデルを使用'),
|
|
70
|
-
|
|
70
|
+
// In no role: who has it may send the owner's conversations to a service of their own (docs/design/ta-desktop-remote.md 6.2).
|
|
71
|
+
action('models.manage', 'Sign in to models', '登录和更换模型账号', '登入和更換模型帳號', 'モデルアカウントにサインイン・変更', { grant: 'single' }),
|
|
71
72
|
action('cron.view', 'See scheduled tasks', '查看定时任务', '檢視定時任務', 'スケジュールタスクを確認'),
|
|
72
73
|
action('cron.manage', 'Change scheduled tasks', '管理定时任务', '管理定時任務', 'スケジュールタスクを管理'),
|
|
73
74
|
action('extensions.use', 'Use extensions', '使用扩展', '使用擴充功能', '拡張機能を使用'),
|
|
@@ -80,9 +81,21 @@ export const TA_ACTIONS = [
|
|
|
80
81
|
action('members.roles', 'Change roles and members', '管理角色和成员', '管理角色和成員', 'ロールとメンバーを管理'),
|
|
81
82
|
action('audit.view', 'See the record', '查看记录', '檢視記錄', 'レコードを確認'),
|
|
82
83
|
];
|
|
84
|
+
/**
|
|
85
|
+
* Actions of the owner alone (docs/design/ta-desktop-remote.md 6.2): their words for records and notices, never in
|
|
86
|
+
* TA_ACTIONS, so that no role or grant gives them; TaActionUtil.grantable says no to every one of their areas.
|
|
87
|
+
*/
|
|
88
|
+
export const TA_OWNER_ACTIONS = [
|
|
89
|
+
action('desktop.view', 'See remote desktops', '查看远程桌面', '檢視遠端桌面', 'リモートデスクトップを見る', { risky: true }),
|
|
90
|
+
action('desktop.control', 'Work remote desktops', '操作远程桌面', '操作遠端桌面', 'リモートデスクトップを操作', { risky: true }),
|
|
91
|
+
];
|
|
92
|
+
/** The areas of TA_OWNER_ACTIONS: nothing of them is given to anyone, whatever a role or team.json says. */
|
|
93
|
+
const OWNER_AREAS = ['desktop'];
|
|
83
94
|
export var TaActionUtil;
|
|
84
95
|
(function (TaActionUtil) {
|
|
85
96
|
const byId = new Map(TA_ACTIONS.map(one => [one.id, one]));
|
|
97
|
+
/** Titles of the owner's actions too, for records and notices. */
|
|
98
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map(one => [one.id, one]));
|
|
86
99
|
function info(id) {
|
|
87
100
|
return byId.get(id);
|
|
88
101
|
}
|
|
@@ -91,7 +104,7 @@ export var TaActionUtil;
|
|
|
91
104
|
function title(id, language) {
|
|
92
105
|
var _a;
|
|
93
106
|
var _b, _c;
|
|
94
|
-
const title = (_a =
|
|
107
|
+
const title = (_a = titled.get(id)) === null || _a === void 0 ? void 0 : _a.title;
|
|
95
108
|
if (!title) {
|
|
96
109
|
return id;
|
|
97
110
|
}
|
|
@@ -103,6 +116,18 @@ export var TaActionUtil;
|
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
TaActionUtil.title = title;
|
|
119
|
+
/** Whether an action may be given to someone at all, by a role or on its own: one of TA_ACTIONS, of no area of the owner's. */
|
|
120
|
+
function grantable(id) {
|
|
121
|
+
const info = byId.get(id);
|
|
122
|
+
return !!info && !OWNER_AREAS.includes(info.area);
|
|
123
|
+
}
|
|
124
|
+
TaActionUtil.grantable = grantable;
|
|
125
|
+
/** Whether an action may be in a role: grantable, and not one given only on its own (`grant: 'single'`). */
|
|
126
|
+
function inRoles(id) {
|
|
127
|
+
var _a;
|
|
128
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === void 0 ? void 0 : _a.grant) !== 'single';
|
|
129
|
+
}
|
|
130
|
+
TaActionUtil.inRoles = inRoles;
|
|
106
131
|
/** Whether `path` is `dir` or inside it; both absolute, `/` separated. */
|
|
107
132
|
function inside(dir, path) {
|
|
108
133
|
const base = dir.replace(/\/+$/, '');
|
|
@@ -34,6 +34,47 @@ export interface TaVoices {
|
|
|
34
34
|
types: TaVoiceTypeInfo[];
|
|
35
35
|
/** voices.json in the agent directory, to edit by hand. */
|
|
36
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;
|
|
37
78
|
}
|
|
38
79
|
/** A voice opened for a call (TaVoiceServer.openVoice). */
|
|
39
80
|
export interface TaVoiceSession {
|
|
@@ -43,6 +84,8 @@ export interface TaVoiceSession {
|
|
|
43
84
|
/** The rate of the PCM16 mono of `audio` events. */
|
|
44
85
|
outputRate: number;
|
|
45
86
|
speaks: boolean;
|
|
87
|
+
/** When a sound stops the reading: voices.json `bargeIn` over the defaults. */
|
|
88
|
+
bargeIn?: TaBargeIn;
|
|
46
89
|
}
|
|
47
90
|
/** What a voice opened by a connection tells it (TaClient.onVoiceEvent). */
|
|
48
91
|
export type TaVoiceEvent =
|
|
@@ -90,6 +133,8 @@ export interface TaVoiceServer {
|
|
|
90
133
|
removeVoice(id: string): Promise<void>;
|
|
91
134
|
/** The service calls use from now on; null for the voice of the device. */
|
|
92
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>;
|
|
93
138
|
/** Opens the service in use for a call of this connection; it closes as the connection does. */
|
|
94
139
|
openVoice(options: {
|
|
95
140
|
language: string;
|
|
@@ -1,3 +1,57 @@
|
|
|
1
1
|
export const TaVoiceServer = Symbol('TaVoiceServer');
|
|
2
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 = {}));
|
|
3
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
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TaLanguage } from './language';
|
|
2
2
|
/**
|
|
3
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
|
-
*
|
|
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
6
|
*/
|
|
7
7
|
export type TaAppRisk = 'read' | 'act' | 'danger';
|
|
8
8
|
/** An action of the catalog, as the model and the pages read it. */
|
|
@@ -54,6 +54,11 @@ export interface TaAppCommandContext {
|
|
|
54
54
|
}
|
|
55
55
|
/** An action of the catalog and what runs it. */
|
|
56
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>;
|
|
57
62
|
run(input: Record<string, unknown>, context: TaAppCommandContext): Promise<TaAppCommandResult>;
|
|
58
63
|
}
|
|
59
64
|
/** Who asks for an action: the run of a conversation (each who asked it), or one principal (a tap on a page). */
|
|
@@ -133,6 +133,20 @@ exports.TA_WEB_SETTINGS = [
|
|
|
133
133
|
title: words('Model of tasks', '任务的模型', '任務的模型', 'タスクのモデル'),
|
|
134
134
|
},
|
|
135
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
|
+
},
|
|
136
150
|
{
|
|
137
151
|
key: 'keepAliveMinutes',
|
|
138
152
|
type: 'number',
|
|
@@ -26,6 +26,17 @@ export interface TaDistribution {
|
|
|
26
26
|
base?: string;
|
|
27
27
|
key?: string;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* What a device does to reach the deployment, told when its gateway does not answer: by language (`zh-CN`, `en`,
|
|
31
|
+
* `*` for any), one sentence, as "Turn on Remote Work in your company's VPN app". A gateway on an intranet has one.
|
|
32
|
+
*/
|
|
33
|
+
reach?: Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* An address of the company's network that answers without its VPN (its sign-in, as `https://iam.example.com`): a
|
|
36
|
+
* device that reaches it while the gateway does not is the company's, told `reach`; one that reaches neither is
|
|
37
|
+
* someone else's, shown no deployment at all.
|
|
38
|
+
*/
|
|
39
|
+
inside?: string;
|
|
29
40
|
}
|
|
30
41
|
/** The environment a deployment is told by: the variables a distribution gives defaults of. */
|
|
31
42
|
export interface TaDeploymentEnv {
|
|
@@ -54,6 +65,8 @@ export declare namespace TaDeploymentUtil {
|
|
|
54
65
|
function discover(address: string, timeoutMs?: number): Promise<TaDeployment>;
|
|
55
66
|
/** A distribution as its file holds it: throws on what it cannot be, for a build not to ship a wrong one. */
|
|
56
67
|
function distribution(value: unknown): TaDistribution;
|
|
68
|
+
/** The sentence of `reach` in `language` (`zh-CN`): that language, else another of its kind (`zh`), else any, else English. */
|
|
69
|
+
function reachIn(reach: Record<string, string> | undefined, language: string): string | undefined;
|
|
57
70
|
/** The environment a distribution gives: its defaults, for what `env` does not set already. */
|
|
58
71
|
function apply(distribution: TaDistribution, env: Record<string, string | undefined>): void;
|
|
59
72
|
}
|
|
@@ -122,9 +122,45 @@ var TaDeploymentUtil;
|
|
|
122
122
|
}
|
|
123
123
|
result.updates = { ...(base ? { base } : {}), ...(key ? { key } : {}) };
|
|
124
124
|
}
|
|
125
|
+
if (given.reach !== undefined) {
|
|
126
|
+
result.reach = reach(given.reach);
|
|
127
|
+
}
|
|
128
|
+
if (given.inside !== undefined) {
|
|
129
|
+
const inside = url(given.inside);
|
|
130
|
+
if (!inside) {
|
|
131
|
+
throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
132
|
+
}
|
|
133
|
+
result.inside = inside;
|
|
134
|
+
}
|
|
125
135
|
return result;
|
|
126
136
|
}
|
|
127
137
|
TaDeploymentUtil.distribution = distribution;
|
|
138
|
+
function reach(value) {
|
|
139
|
+
const given = typeof value === 'string' ? { '*': value } : value;
|
|
140
|
+
const entries = given && typeof given === 'object' && !Array.isArray(given) ? Object.entries(given) : [];
|
|
141
|
+
const result = {};
|
|
142
|
+
for (const [language, text] of entries) {
|
|
143
|
+
if (typeof text !== 'string' || !text.trim()) {
|
|
144
|
+
throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not a sentence.`);
|
|
145
|
+
}
|
|
146
|
+
result[language] = text.trim().slice(0, 200);
|
|
147
|
+
}
|
|
148
|
+
if (Object.keys(result).length === 0) {
|
|
149
|
+
throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is a sentence, or one by language.`);
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
/** The sentence of `reach` in `language` (`zh-CN`): that language, else another of its kind (`zh`), else any, else English. */
|
|
154
|
+
function reachIn(reach, language) {
|
|
155
|
+
var _a, _b, _c, _d, _e;
|
|
156
|
+
if (!reach) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const base = language.split('-')[0];
|
|
160
|
+
const near = Object.keys(reach).find(key => key.split('-')[0] === base);
|
|
161
|
+
return (_e = (_d = (_c = (_b = (_a = reach[language]) !== null && _a !== void 0 ? _a : reach[base]) !== null && _b !== void 0 ? _b : (near && reach[near])) !== null && _c !== void 0 ? _c : reach['*']) !== null && _d !== void 0 ? _d : reach.en) !== null && _e !== void 0 ? _e : Object.values(reach)[0];
|
|
162
|
+
}
|
|
163
|
+
TaDeploymentUtil.reachIn = reachIn;
|
|
128
164
|
/** The environment a distribution gives: its defaults, for what `env` does not set already. */
|
|
129
165
|
function apply(distribution, env) {
|
|
130
166
|
const defaults = { TA_DEPLOYMENT_NAME: distribution.name, TA_RELAY_URL: distribution.relay, TA_GATEWAY_URL: distribution.gateway };
|
package/lib/common/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export * from './presence-protocol';
|
|
|
17
17
|
export * from './relay-protocol';
|
|
18
18
|
export * from './remote-protocol';
|
|
19
19
|
export * from './room-protocol';
|
|
20
|
+
export * from './said-protocol';
|
|
21
|
+
export * from './screen-share-protocol';
|
|
20
22
|
export * from './settings-protocol';
|
|
21
23
|
export * from './ta-extension-host';
|
|
22
24
|
export * from './ta-protocol';
|
package/lib/common/index.js
CHANGED
|
@@ -33,6 +33,8 @@ __exportStar(require("./presence-protocol"), exports);
|
|
|
33
33
|
__exportStar(require("./relay-protocol"), exports);
|
|
34
34
|
__exportStar(require("./remote-protocol"), exports);
|
|
35
35
|
__exportStar(require("./room-protocol"), exports);
|
|
36
|
+
__exportStar(require("./said-protocol"), exports);
|
|
37
|
+
__exportStar(require("./screen-share-protocol"), exports);
|
|
36
38
|
__exportStar(require("./settings-protocol"), exports);
|
|
37
39
|
__exportStar(require("./ta-extension-host"), exports);
|
|
38
40
|
__exportStar(require("./ta-protocol"), exports);
|
|
@@ -15,18 +15,33 @@ export interface TaMessageFrom {
|
|
|
15
15
|
from: string;
|
|
16
16
|
/** What the package says of it besides, in a few words (the channel and who spoke in it). */
|
|
17
17
|
detail?: string;
|
|
18
|
+
/** Not the user's: news or an event of that part of Ta, which the model weighs below what the user said (TaMessageSource.notice). */
|
|
19
|
+
notice?: true;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* Who wrote a message of the user's role (docs/design/ta-sources.md). What the user typed has no mark. A message a
|
|
23
|
+
* package sends for the user (their choice in a card, what they said in a call, a task they scheduled) says so in the
|
|
24
|
+
* last line of its `<context>` block, `[ta:from <name> <detail>]`: it is theirs. A message that is not theirs (news of
|
|
25
|
+
* work elsewhere, a time limit, a grant) is a notice, `[ta:notice <name> <detail>]`: the model reads it as information
|
|
26
|
+
* below what the user said (the section `<ta-sources>` of the system prompt), and a page shows it as a line, not as a
|
|
27
|
+
* bubble of the user. A page older than these leaves them out with the rest of the context. A command (`/compact`,
|
|
28
|
+
* `!ls`) is not marked.
|
|
23
29
|
*/
|
|
24
30
|
export declare namespace TaMessageSource {
|
|
25
31
|
/** The double of the web page: the tasks it hands out, what it tells them on the way. */
|
|
26
32
|
const DOUBLE = "ta:double";
|
|
27
|
-
/** `message` as sent by `from
|
|
33
|
+
/** `message` as sent by `from` for the user; as it was when it is a command or says where it came from already. */
|
|
28
34
|
function mark(message: string, from: string, detail?: string): string;
|
|
35
|
+
/** `message` as a notice of `from`: not the user's; as it was when it says where it came from already. */
|
|
36
|
+
function notice(message: string, from: string, detail?: string): string;
|
|
37
|
+
/** The line of the context that says a message came from `from` (a notice of it, with `notice`), for one who writes the context of their own. */
|
|
38
|
+
function line(from: string, detail?: string, notice?: boolean): string;
|
|
29
39
|
function of(message: string): TaMessageFrom | undefined;
|
|
40
|
+
/** Whether a message is a notice: not the user's (TaMessageSource.notice). */
|
|
41
|
+
function isNotice(message: string): boolean;
|
|
42
|
+
/** The section of the system prompt that says who wrote a message, and that the user's words come first (SourcesExtension of ta-host). */
|
|
43
|
+
const SECTION = "ta-sources";
|
|
44
|
+
const PROMPT: string;
|
|
30
45
|
}
|
|
31
46
|
/**
|
|
32
47
|
* 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
|
|
@@ -93,4 +108,28 @@ export declare namespace TaTaskNote {
|
|
|
93
108
|
/** The note `text` is, all of it; undefined for anything else. */
|
|
94
109
|
function parse(text: string): TaTaskNote | undefined;
|
|
95
110
|
}
|
|
111
|
+
/** What a name of the vault stands for in what the user sent: a personal detail of a kind, or another secret. */
|
|
112
|
+
export type TaSecretKind = 'phone' | 'email' | 'idNumber' | 'bankCard' | 'secret';
|
|
113
|
+
/** A part of a text: words as they are, or a name of the vault (`$TA_SECRET_PHONE`). */
|
|
114
|
+
export type TaSecretPart = {
|
|
115
|
+
text: string;
|
|
116
|
+
} | {
|
|
117
|
+
secret: string;
|
|
118
|
+
kind: TaSecretKind;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The names the vault of Ta (ta-secrets) puts in place of what it took out of a message (`$TA_SECRET_PHONE`,
|
|
122
|
+
* `${TA_SECRET_GITHUB_TOKEN}`): the model reads them so; a page shows each as what it stands for, not as a variable.
|
|
123
|
+
*/
|
|
124
|
+
export declare namespace TaSecretRef {
|
|
125
|
+
/** The package of the vault: `list` of its host gives what it keeps by name, the masked hint of a personal detail, never a value. */
|
|
126
|
+
const PACKAGE = "@celljs/ta-secrets";
|
|
127
|
+
function has(text: string): boolean;
|
|
128
|
+
/** What a name is of: the kinds of personal details the vault takes in by itself, `secret` for the rest. */
|
|
129
|
+
function kind(name: string): TaSecretKind;
|
|
130
|
+
/** The text in parts, its names apart; one part of words when it has none. */
|
|
131
|
+
function split(text: string): TaSecretPart[];
|
|
132
|
+
/** The text with each name as `label` says it, for a line that shows no more than words (a preview). */
|
|
133
|
+
function plain(text: string, label: (name: string, kind: TaSecretKind) => string): string;
|
|
134
|
+
}
|
|
96
135
|
//# sourceMappingURL=message-protocol.d.ts.map
|