@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,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deployment of Ta: its gateway, its relay, or both, for one group of people (docs/design/ta-deploy.md). Inside and
|
|
3
|
+
* outside a company each have one; nothing passes between them.
|
|
4
|
+
*/
|
|
5
|
+
/** What every service of a deployment answers, to anyone (it holds nothing secret). */
|
|
6
|
+
export const TA_WELL_KNOWN_PATH = '/.well-known/ta';
|
|
7
|
+
export class TaDeploymentError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export var TaDeploymentUtil;
|
|
10
|
+
(function (TaDeploymentUtil) {
|
|
11
|
+
TaDeploymentUtil.DISTRIBUTION_FILE = 'distribution.json';
|
|
12
|
+
/** An address of a service as it is kept: http(s), its origin and path, no trailing slash; undefined for what is not one. */
|
|
13
|
+
function url(value) {
|
|
14
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const parsed = new URL(value.trim());
|
|
19
|
+
if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, '');
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
TaDeploymentUtil.url = url;
|
|
29
|
+
function name(value) {
|
|
30
|
+
return typeof value === 'string' && value.trim() ? value.trim().slice(0, 80) : undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What a service answers: `own` its own part (its address, TA_PUBLIC_URL or the origin it was reached at), the rest
|
|
34
|
+
* from the environment.
|
|
35
|
+
*/
|
|
36
|
+
function describe(env, own, version) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const gateway = (_a = url(own.gateway)) !== null && _a !== void 0 ? _a : url(env.TA_GATEWAY_URL);
|
|
39
|
+
const relay = (_b = url(own.relay)) !== null && _b !== void 0 ? _b : url(env.TA_RELAY_URL);
|
|
40
|
+
const called = name(env.TA_DEPLOYMENT_NAME);
|
|
41
|
+
return { v: 1, ...(called ? { name: called } : {}), ...(gateway ? { gateway } : {}), ...(relay ? { relay } : {}), ...(version ? { version } : {}) };
|
|
42
|
+
}
|
|
43
|
+
TaDeploymentUtil.describe = describe;
|
|
44
|
+
TaDeploymentUtil.HEADERS = {
|
|
45
|
+
'content-type': 'application/json',
|
|
46
|
+
'access-control-allow-origin': '*',
|
|
47
|
+
'cache-control': 'no-store',
|
|
48
|
+
};
|
|
49
|
+
/** What a deployment said, kept to what is known; undefined for what is not one. */
|
|
50
|
+
function parse(value) {
|
|
51
|
+
const given = value;
|
|
52
|
+
if (!given || typeof given !== 'object' || given.v !== 1) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
|
|
56
|
+
const version = name(given.version);
|
|
57
|
+
return version ? { ...deployment, version } : deployment;
|
|
58
|
+
}
|
|
59
|
+
TaDeploymentUtil.parse = parse;
|
|
60
|
+
/** Asks a service of a deployment what it is part of: rejects with what went wrong. */
|
|
61
|
+
async function discover(address, timeoutMs = 6000) {
|
|
62
|
+
const base = url(address);
|
|
63
|
+
if (!base) {
|
|
64
|
+
throw new TaDeploymentError(`${address} is not an address of http or https.`);
|
|
65
|
+
}
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
68
|
+
try {
|
|
69
|
+
const response = await fetch(`${base}${TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: 'follow' });
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
|
|
72
|
+
}
|
|
73
|
+
const deployment = parse(await response.json().catch(() => undefined));
|
|
74
|
+
if (!deployment || (!deployment.gateway && !deployment.relay)) {
|
|
75
|
+
throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
|
|
76
|
+
}
|
|
77
|
+
return deployment;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError') {
|
|
81
|
+
throw new TaDeploymentError(`${base} did not answer in time.`);
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
TaDeploymentUtil.discover = discover;
|
|
90
|
+
/** A distribution as its file holds it: throws on what it cannot be, for a build not to ship a wrong one. */
|
|
91
|
+
function distribution(value) {
|
|
92
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
93
|
+
throw new TaDeploymentError(`${TaDeploymentUtil.DISTRIBUTION_FILE} holds a JSON object.`);
|
|
94
|
+
}
|
|
95
|
+
const given = value;
|
|
96
|
+
const result = {};
|
|
97
|
+
if (given.name !== undefined) {
|
|
98
|
+
result.name = name(given.name);
|
|
99
|
+
}
|
|
100
|
+
for (const key of ['relay', 'gateway']) {
|
|
101
|
+
if (given[key] !== undefined) {
|
|
102
|
+
const address = url(given[key]);
|
|
103
|
+
if (!address) {
|
|
104
|
+
throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
105
|
+
}
|
|
106
|
+
result[key] = address;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (given.updates !== undefined) {
|
|
110
|
+
const updates = given.updates;
|
|
111
|
+
const base = url(updates === null || updates === void 0 ? void 0 : updates.base);
|
|
112
|
+
if (!base && (updates === null || updates === void 0 ? void 0 : updates.base) !== undefined) {
|
|
113
|
+
throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
114
|
+
}
|
|
115
|
+
const key = typeof (updates === null || updates === void 0 ? void 0 : updates.key) === 'string' && updates.key.includes('PUBLIC KEY') ? updates.key : undefined;
|
|
116
|
+
if ((updates === null || updates === void 0 ? void 0 : updates.key) !== undefined && !key) {
|
|
117
|
+
throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is a public key in PEM.`);
|
|
118
|
+
}
|
|
119
|
+
result.updates = { ...(base ? { base } : {}), ...(key ? { key } : {}) };
|
|
120
|
+
}
|
|
121
|
+
if (given.reach !== undefined) {
|
|
122
|
+
result.reach = reach(given.reach);
|
|
123
|
+
}
|
|
124
|
+
if (given.inside !== undefined) {
|
|
125
|
+
const inside = url(given.inside);
|
|
126
|
+
if (!inside) {
|
|
127
|
+
throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
|
|
128
|
+
}
|
|
129
|
+
result.inside = inside;
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
TaDeploymentUtil.distribution = distribution;
|
|
134
|
+
function reach(value) {
|
|
135
|
+
const given = typeof value === 'string' ? { '*': value } : value;
|
|
136
|
+
const entries = given && typeof given === 'object' && !Array.isArray(given) ? Object.entries(given) : [];
|
|
137
|
+
const result = {};
|
|
138
|
+
for (const [language, text] of entries) {
|
|
139
|
+
if (typeof text !== 'string' || !text.trim()) {
|
|
140
|
+
throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not a sentence.`);
|
|
141
|
+
}
|
|
142
|
+
result[language] = text.trim().slice(0, 200);
|
|
143
|
+
}
|
|
144
|
+
if (Object.keys(result).length === 0) {
|
|
145
|
+
throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is a sentence, or one by language.`);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/** The sentence of `reach` in `language` (`zh-CN`): that language, else another of its kind (`zh`), else any, else English. */
|
|
150
|
+
function reachIn(reach, language) {
|
|
151
|
+
var _a, _b, _c, _d, _e;
|
|
152
|
+
if (!reach) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
const base = language.split('-')[0];
|
|
156
|
+
const near = Object.keys(reach).find(key => key.split('-')[0] === base);
|
|
157
|
+
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];
|
|
158
|
+
}
|
|
159
|
+
TaDeploymentUtil.reachIn = reachIn;
|
|
160
|
+
/** The environment a distribution gives: its defaults, for what `env` does not set already. */
|
|
161
|
+
function apply(distribution, env) {
|
|
162
|
+
const defaults = { TA_DEPLOYMENT_NAME: distribution.name, TA_RELAY_URL: distribution.relay, TA_GATEWAY_URL: distribution.gateway };
|
|
163
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
164
|
+
if (value && !env[key]) {
|
|
165
|
+
env[key] = value;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
TaDeploymentUtil.apply = apply;
|
|
170
|
+
})(TaDeploymentUtil || (TaDeploymentUtil = {}));
|
|
171
|
+
//# sourceMappingURL=deployment-protocol.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
2
|
+
export declare const TaErrorCode: {
|
|
3
|
+
readonly SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND';
|
|
4
|
+
readonly SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED';
|
|
5
|
+
readonly TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS';
|
|
6
|
+
readonly MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT';
|
|
7
|
+
readonly MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND';
|
|
8
|
+
readonly INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT';
|
|
9
|
+
readonly COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED';
|
|
10
|
+
/** Compacting found nothing to compact: the conversation is still short. */
|
|
11
|
+
readonly NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT';
|
|
12
|
+
/** Compacting found nothing to compact: nothing came after the last compaction. */
|
|
13
|
+
readonly ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED';
|
|
14
|
+
/** The session is answering or compacting, which has to end first. */
|
|
15
|
+
readonly SESSION_BUSY: 'CELL_TA_SESSION_BUSY';
|
|
16
|
+
/** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
|
|
17
|
+
readonly CANCELLED: 'CELL_TA_CANCELLED';
|
|
18
|
+
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
19
|
+
readonly NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN';
|
|
20
|
+
/** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
|
|
21
|
+
readonly ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED';
|
|
22
|
+
/** Behind a gateway: more messages a minute than one may send; try again in a moment. */
|
|
23
|
+
readonly RATE_LIMITED: 'CELL_TA_RATE_LIMITED';
|
|
24
|
+
/** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
|
|
25
|
+
readonly FORBIDDEN: 'CELL_TA_FORBIDDEN';
|
|
26
|
+
/** 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. */
|
|
27
|
+
readonly LIMIT: 'CELL_TA_LIMIT';
|
|
28
|
+
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
29
|
+
readonly CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST';
|
|
30
|
+
};
|
|
31
|
+
export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
|
|
32
|
+
export declare namespace TaErrorUtil {
|
|
33
|
+
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
34
|
+
function code(error: unknown): string | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
37
|
+
export declare const TA_RPC_ERROR_CODE = -32050;
|
|
38
|
+
export interface TaErrorData {
|
|
39
|
+
code: TaErrorCode;
|
|
40
|
+
/** One sentence on what to do about it. */
|
|
41
|
+
hint: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
2
|
+
export const TaErrorCode = {
|
|
3
|
+
SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
|
|
4
|
+
SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
|
|
5
|
+
TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
|
|
6
|
+
MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
|
|
7
|
+
MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
|
|
8
|
+
INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
|
|
9
|
+
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
10
|
+
/** Compacting found nothing to compact: the conversation is still short. */
|
|
11
|
+
NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT',
|
|
12
|
+
/** Compacting found nothing to compact: nothing came after the last compaction. */
|
|
13
|
+
ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED',
|
|
14
|
+
/** The session is answering or compacting, which has to end first. */
|
|
15
|
+
SESSION_BUSY: 'CELL_TA_SESSION_BUSY',
|
|
16
|
+
/** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
|
|
17
|
+
CANCELLED: 'CELL_TA_CANCELLED',
|
|
18
|
+
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
19
|
+
NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
|
|
20
|
+
/** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
|
|
21
|
+
ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
|
|
22
|
+
/** Behind a gateway: more messages a minute than one may send; try again in a moment. */
|
|
23
|
+
RATE_LIMITED: 'CELL_TA_RATE_LIMITED',
|
|
24
|
+
/** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
|
|
25
|
+
FORBIDDEN: 'CELL_TA_FORBIDDEN',
|
|
26
|
+
/** 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. */
|
|
27
|
+
LIMIT: 'CELL_TA_LIMIT',
|
|
28
|
+
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
29
|
+
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
30
|
+
};
|
|
31
|
+
export var TaErrorUtil;
|
|
32
|
+
(function (TaErrorUtil) {
|
|
33
|
+
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
34
|
+
function code(error) {
|
|
35
|
+
var _a;
|
|
36
|
+
var _b;
|
|
37
|
+
const failure = error;
|
|
38
|
+
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;
|
|
39
|
+
return typeof code === 'string' ? code : undefined;
|
|
40
|
+
}
|
|
41
|
+
TaErrorUtil.code = code;
|
|
42
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
43
|
+
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
44
|
+
export const TA_RPC_ERROR_CODE = -32050;
|
|
45
|
+
//# sourceMappingURL=error-protocol.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { JsonAgentSessionEvent, RpcExtensionUIRequest } from './pi-types.js';
|
|
2
|
+
import type { TaSessionInfo } from './ta-protocol.js';
|
|
3
|
+
/** An extension's dialog was answered by another client, or expired. */
|
|
4
|
+
export interface TaUiRequestResolved {
|
|
5
|
+
type: 'ui_request_resolved';
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
/** An extension threw while handling an event. */
|
|
9
|
+
export interface TaExtensionError {
|
|
10
|
+
type: 'extension_error';
|
|
11
|
+
extensionPath: string;
|
|
12
|
+
event: string;
|
|
13
|
+
error: string;
|
|
14
|
+
}
|
|
15
|
+
/** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`, `navigateTree`): read it again. */
|
|
16
|
+
export interface TaSessionReplaced {
|
|
17
|
+
type: 'session_replaced';
|
|
18
|
+
info: TaSessionInfo;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The session loaded its extensions, skills, prompts and themes again (`reload`, or an extension's
|
|
22
|
+
* `ctx.reload()`): its commands may have changed, read them again (`getCommands`).
|
|
23
|
+
*/
|
|
24
|
+
export interface TaSessionReloaded {
|
|
25
|
+
type: 'session_reloaded';
|
|
26
|
+
}
|
|
27
|
+
/** The session was closed; no more events come. */
|
|
28
|
+
export interface TaSessionClosed {
|
|
29
|
+
type: 'session_closed';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What the agent is doing while it works, from an extension (pi's `setWorkingMessage`), as starting the
|
|
33
|
+
* program of an external agent; none: the client's own words again.
|
|
34
|
+
*/
|
|
35
|
+
export interface TaWorkingMessage {
|
|
36
|
+
type: 'working_message';
|
|
37
|
+
message?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The model called a tool of `clientTools`: a client that runs it takes it with `claimClientTool`, so
|
|
41
|
+
* that one client runs it, however many are attached, and answers with `respondClientTool`. When that
|
|
42
|
+
* client leaves the session before it answers, the request comes again with the same id, for another.
|
|
43
|
+
* `client_tool_resolved` tells the others it was answered.
|
|
44
|
+
*/
|
|
45
|
+
export interface TaClientToolRequest {
|
|
46
|
+
type: 'client_tool_request';
|
|
47
|
+
/** The id of the tool call. */
|
|
48
|
+
id: string;
|
|
49
|
+
toolName: string;
|
|
50
|
+
input: unknown;
|
|
51
|
+
}
|
|
52
|
+
/** A call of a client tool was answered, or ended because the run was aborted or the session closed. */
|
|
53
|
+
export interface TaClientToolResolved {
|
|
54
|
+
type: 'client_tool_resolved';
|
|
55
|
+
id: string;
|
|
56
|
+
}
|
|
57
|
+
export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionReloaded | TaSessionClosed | TaWorkingMessage;
|
|
58
|
+
export interface TaEventEnvelope {
|
|
59
|
+
sessionId: string;
|
|
60
|
+
/** Increases by one per event of the session. */
|
|
61
|
+
seq: number;
|
|
62
|
+
event: TaEvent;
|
|
63
|
+
}
|
|
@@ -28,6 +28,15 @@ export interface TaGatewayLimits {
|
|
|
28
28
|
/** Whether they may run their Ta in a Ta service of their own. */
|
|
29
29
|
own?: boolean | null;
|
|
30
30
|
}
|
|
31
|
+
/** A connection of a sandbox the proxy of the gateway refused, the latest of its kind: `count` of them lately. */
|
|
32
|
+
export interface TaEgressRefusal {
|
|
33
|
+
/** `host`, or `host:port` for a port other than 80 and 443. */
|
|
34
|
+
host: string;
|
|
35
|
+
/** Not among the hosts of the policy, a port it does not let out, or a private network or the gateway's machine. */
|
|
36
|
+
reason: 'host' | 'port' | 'network';
|
|
37
|
+
at: number;
|
|
38
|
+
count: number;
|
|
39
|
+
}
|
|
31
40
|
/** Why one's Ta does not start: suspended by an administrator, or this month's free minutes used up. */
|
|
32
41
|
export type TaQuotaBlock = 'suspended' | 'minutes';
|
|
33
42
|
/** What one used of what one may, this month (of UTC), as one sees it and administrators do. */
|
|
@@ -55,6 +64,11 @@ export interface TaQuotaState {
|
|
|
55
64
|
promptsPerMinute?: number;
|
|
56
65
|
connections?: number;
|
|
57
66
|
blocked?: TaQuotaBlock;
|
|
67
|
+
/** When the sandboxes go out through the gateway: the bytes moved this month, and the latest connections refused. */
|
|
68
|
+
egress?: {
|
|
69
|
+
bytes: number;
|
|
70
|
+
refused: TaEgressRefusal[];
|
|
71
|
+
};
|
|
58
72
|
}
|
|
59
73
|
/** One hour of what agents took: tokens and dollars. */
|
|
60
74
|
export interface TaUsagePoint {
|
|
@@ -99,6 +113,18 @@ export interface TaGatewayAuditEntry {
|
|
|
99
113
|
target?: string;
|
|
100
114
|
detail?: string;
|
|
101
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The way out of the sandboxes: the proxy of the gateway, by which each sandbox goes out with credentials of its
|
|
118
|
+
* own epoch (those of a sandbox made again since stop working).
|
|
119
|
+
*/
|
|
120
|
+
export interface TaGatewayEgress {
|
|
121
|
+
/** Whether the sandboxes go out through the gateway (`egress` of sandboxes.json, with the firewall of the machine). */
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
/** The hosts members' sandboxes may reach, set by owners; none: any public host. Owners are not held to them. */
|
|
124
|
+
hosts: string[];
|
|
125
|
+
/** Private networks the sandboxes may reach too (`egress.networks` of sandboxes.json); never the gateway's machine. */
|
|
126
|
+
networks: string[];
|
|
127
|
+
}
|
|
102
128
|
/** The defaults of the gateway and who manages it. */
|
|
103
129
|
export interface TaGatewayPolicy {
|
|
104
130
|
defaults: TaGatewayLimits;
|
|
@@ -108,6 +134,7 @@ export interface TaGatewayPolicy {
|
|
|
108
134
|
role: 'owner' | 'admin';
|
|
109
135
|
}[];
|
|
110
136
|
idleMinutes: number;
|
|
137
|
+
egress: TaGatewayEgress;
|
|
111
138
|
}
|
|
112
139
|
/**
|
|
113
140
|
* Where the Ta of a tenant runs: a sandbox of the gateway's provider (a container, a machine), or a Ta service
|
|
@@ -331,6 +358,8 @@ export interface TaGatewayServer {
|
|
|
331
358
|
grantMinutes(tenantId: string, minutes: number): Promise<void>;
|
|
332
359
|
/** For administrators: a suspended account's Ta stops and does not start until it is let go again. */
|
|
333
360
|
setSuspended(tenantId: string, suspended: boolean): Promise<void>;
|
|
361
|
+
/** For owners: the hosts members' sandboxes may reach through the proxy of the gateway; none: any public host. */
|
|
362
|
+
setEgressHosts(hosts: string[]): Promise<TaGatewayPolicy>;
|
|
334
363
|
/** For owners: makes an account that signed in an admin, or a member again. Owners stay owners. */
|
|
335
364
|
setRole(account: string, role: 'admin' | 'member'): Promise<TaGatewayPolicy>;
|
|
336
365
|
/** For administrators: what administrators did lately, newest first, `limit` at most (100 by default). */
|
package/esm/common/index.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
export * from './access-protocol.js';
|
|
2
|
+
export * from './app-protocol.js';
|
|
2
3
|
export * from './auth-protocol.js';
|
|
4
|
+
export * from './delegate-protocol.js';
|
|
5
|
+
export * from './deployment-protocol.js';
|
|
6
|
+
export * from './error-protocol.js';
|
|
7
|
+
export * from './event-protocol.js';
|
|
3
8
|
export * from './gateway-protocol.js';
|
|
4
9
|
export * from './language.js';
|
|
5
10
|
export * from './location.js';
|
|
11
|
+
export * from './message-protocol.js';
|
|
6
12
|
export * from './package-protocol.js';
|
|
13
|
+
export * from './page-protocol.js';
|
|
14
|
+
export * from './path-map.js';
|
|
7
15
|
export * from './pi-types.js';
|
|
8
16
|
export * from './presence-protocol.js';
|
|
9
17
|
export * from './relay-protocol.js';
|
|
10
18
|
export * from './remote-protocol.js';
|
|
11
19
|
export * from './room-protocol.js';
|
|
20
|
+
export * from './said-protocol.js';
|
|
21
|
+
export * from './screen-share-protocol.js';
|
|
12
22
|
export * from './settings-protocol.js';
|
|
13
23
|
export * from './ta-extension-host.js';
|
|
14
24
|
export * from './ta-protocol.js';
|
|
15
25
|
export * from './team-protocol.js';
|
|
16
26
|
export * from './usage-protocol.js';
|
|
27
|
+
export * from './voice-protocol.js';
|
|
17
28
|
export * from './workspace-protocol.js';
|
package/esm/common/index.js
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
export * from './access-protocol.js';
|
|
2
|
+
export * from './app-protocol.js';
|
|
2
3
|
export * from './auth-protocol.js';
|
|
4
|
+
export * from './delegate-protocol.js';
|
|
5
|
+
export * from './deployment-protocol.js';
|
|
6
|
+
export * from './error-protocol.js';
|
|
7
|
+
export * from './event-protocol.js';
|
|
3
8
|
export * from './gateway-protocol.js';
|
|
4
9
|
export * from './language.js';
|
|
5
10
|
export * from './location.js';
|
|
11
|
+
export * from './message-protocol.js';
|
|
6
12
|
export * from './package-protocol.js';
|
|
13
|
+
export * from './page-protocol.js';
|
|
14
|
+
export * from './path-map.js';
|
|
7
15
|
export * from './pi-types.js';
|
|
8
16
|
export * from './presence-protocol.js';
|
|
9
17
|
export * from './relay-protocol.js';
|
|
10
18
|
export * from './remote-protocol.js';
|
|
11
19
|
export * from './room-protocol.js';
|
|
20
|
+
export * from './said-protocol.js';
|
|
21
|
+
export * from './screen-share-protocol.js';
|
|
12
22
|
export * from './settings-protocol.js';
|
|
13
23
|
export * from './ta-extension-host.js';
|
|
14
24
|
export * from './ta-protocol.js';
|
|
15
25
|
export * from './team-protocol.js';
|
|
16
26
|
export * from './usage-protocol.js';
|
|
27
|
+
export * from './voice-protocol.js';
|
|
17
28
|
export * from './workspace-protocol.js';
|
|
18
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
3
|
+
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace TaMessageContext {
|
|
6
|
+
function wrap(context: string, message: string): string;
|
|
7
|
+
/** The message without its context: what the user sees of it. */
|
|
8
|
+
function strip(message: string): string;
|
|
9
|
+
/** The context of the message, without its tags; undefined without one. */
|
|
10
|
+
function read(message: string): string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Where a message of the user came from, when not from what they typed: see {@link TaMessageSource}. */
|
|
13
|
+
export interface TaMessageFrom {
|
|
14
|
+
/** The name of the package that sent it, or TaMessageSource.DOUBLE. */
|
|
15
|
+
from: string;
|
|
16
|
+
/** What the package says of it besides, in a few words (the channel and who spoke in it). */
|
|
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;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
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.
|
|
29
|
+
*/
|
|
30
|
+
export declare namespace TaMessageSource {
|
|
31
|
+
/** The double of the web page: the tasks it hands out, what it tells them on the way. */
|
|
32
|
+
const DOUBLE = "ta:double";
|
|
33
|
+
/** `message` as sent by `from` for the user; as it was when it is a command or says where it came from already. */
|
|
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;
|
|
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;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
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
|
|
48
|
+
* the image was before it made it smaller, and what it was converted from. Clients leave them out.
|
|
49
|
+
*/
|
|
50
|
+
export declare namespace TaImageNote {
|
|
51
|
+
/** The text without the notes of its images: what the user sees of it. */
|
|
52
|
+
function strip(text: string): string;
|
|
53
|
+
}
|
|
54
|
+
/** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
|
|
55
|
+
export declare namespace TaImageSize {
|
|
56
|
+
function of(base64: string): {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
} | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* An external agent that compacts its own context says the summary it goes on from as text, in tags
|
|
63
|
+
* (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
|
|
64
|
+
*/
|
|
65
|
+
export declare namespace TaAgentSummary {
|
|
66
|
+
/** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
|
|
67
|
+
function read(text: string): string | undefined;
|
|
68
|
+
/** The text without the summary it starts with. */
|
|
69
|
+
function strip(text: string): string;
|
|
70
|
+
}
|
|
71
|
+
/** A skill the user ran with `/skill:name`, as pi puts it in the message: the skill's file, then what the user wrote. */
|
|
72
|
+
export interface TaSkillUse {
|
|
73
|
+
name: string;
|
|
74
|
+
/** The path of its SKILL.md. */
|
|
75
|
+
location: string;
|
|
76
|
+
/** What pi read of it, for the model. */
|
|
77
|
+
content: string;
|
|
78
|
+
/** What the user wrote after `/skill:name`. */
|
|
79
|
+
message?: string;
|
|
80
|
+
}
|
|
81
|
+
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
82
|
+
export declare namespace TaSkillUse {
|
|
83
|
+
function parse(message: string): TaSkillUse | undefined;
|
|
84
|
+
/** What the user typed: `/skill:name` and what follows. */
|
|
85
|
+
function command(use: TaSkillUse): string;
|
|
86
|
+
}
|
|
87
|
+
/** What a note of the double's tasks is about: how one ended, that the user handed it one, that one has another id now. */
|
|
88
|
+
export type TaTaskNoteKind = 'update' | 'adopted' | 'renamed';
|
|
89
|
+
/** A note of the double's tasks, as {@link TaTaskNote.write} puts it and {@link TaTaskNote.parse} reads it. */
|
|
90
|
+
export interface TaTaskNote {
|
|
91
|
+
kind: TaTaskNoteKind;
|
|
92
|
+
id: string;
|
|
93
|
+
title: string;
|
|
94
|
+
/** How the task stands: running, done, failed, stopped; none in a note of a new id. */
|
|
95
|
+
status?: string;
|
|
96
|
+
/** The id it had, in a note of a new id. */
|
|
97
|
+
was?: string;
|
|
98
|
+
/** What the note says, for the double. */
|
|
99
|
+
body: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The double hears of its tasks in messages of the user (`<task_update id="t1" title="…" status="done">…</task_update>`
|
|
103
|
+
* and the like): notes, not what the user said, which a client shows as the task they are about, and a list of
|
|
104
|
+
* conversations says by the task's title.
|
|
105
|
+
*/
|
|
106
|
+
export declare namespace TaTaskNote {
|
|
107
|
+
function write(note: TaTaskNote): string;
|
|
108
|
+
/** The note `text` is, all of it; undefined for anything else. */
|
|
109
|
+
function parse(text: string): TaTaskNote | undefined;
|
|
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
|
+
}
|