@celljs/ta-protocol 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/common/app-protocol.d.ts +115 -0
- package/esm/common/app-protocol.js +199 -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 +59 -0
- package/esm/common/deployment-protocol.js +135 -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 +9 -0
- package/esm/common/index.js +9 -0
- package/esm/common/message-protocol.d.ts +95 -0
- package/esm/common/message-protocol.js +237 -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 +7 -1
- package/esm/common/ta-extension-host.d.ts +31 -1
- package/esm/common/ta-extension-host.js +2 -0
- package/esm/common/ta-protocol.d.ts +50 -175
- package/esm/common/ta-protocol.js +0 -234
- package/esm/common/voice-protocol.d.ts +139 -0
- package/esm/common/voice-protocol.js +3 -0
- package/lib/common/app-protocol.d.ts +116 -0
- package/lib/common/app-protocol.js +202 -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 +60 -0
- package/lib/common/deployment-protocol.js +139 -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 +9 -0
- package/lib/common/index.js +9 -0
- package/lib/common/message-protocol.d.ts +96 -0
- package/lib/common/message-protocol.js +240 -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 +7 -1
- package/lib/common/ta-extension-host.d.ts +31 -1
- package/lib/common/ta-extension-host.js +3 -1
- package/lib/common/ta-protocol.d.ts +50 -175
- package/lib/common/ta-protocol.js +1 -235
- package/lib/common/voice-protocol.d.ts +140 -0
- package/lib/common/voice-protocol.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path of one computer as it is on another (docs/design/ta-sync.md 8.4): a move from Windows to Linux or back, a
|
|
3
|
+
* project in another folder. A base is matched whatever its separators, and regardless of case for a path of Windows;
|
|
4
|
+
* what follows it takes the separators of the base it is mapped to.
|
|
5
|
+
*/
|
|
6
|
+
export declare namespace TaPathMap {
|
|
7
|
+
/** A directory as it was, and as it is now. */
|
|
8
|
+
type Pair = readonly [from: string, to: string];
|
|
9
|
+
/** `C:\...`, `c:/...` or `\\server\share`. */
|
|
10
|
+
function isWindows(path: string): boolean;
|
|
11
|
+
/** The parts of `path` after `base`, none when it is `base`; undefined when it is not `base` nor under it. */
|
|
12
|
+
function rest(path: string, base: string): string[] | undefined;
|
|
13
|
+
function under(path: string, base: string): boolean;
|
|
14
|
+
/** `parts` under `base`, with its separator. */
|
|
15
|
+
function join(base: string, parts: readonly string[]): string;
|
|
16
|
+
/** The last part of a path, of either kind. */
|
|
17
|
+
function basename(path: string): string;
|
|
18
|
+
/** A path under the deepest base of `pairs` it is under, as it is there; else itself. */
|
|
19
|
+
function path(value: string, pairs: readonly Pair[]): string;
|
|
20
|
+
/** The paths in a text (a command, `dir:<path>`), each mapped as `path` maps it; a path ends at a space or a quote. */
|
|
21
|
+
function text(value: string, pairs: readonly Pair[]): string;
|
|
22
|
+
/** Every string of a value of JSON, keys too, mapped: a whole path as `path` maps it, paths in a text as `text` does. */
|
|
23
|
+
function json<T>(value: T, pairs: readonly Pair[]): T;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=path-map.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaPathMap = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A path of one computer as it is on another (docs/design/ta-sync.md 8.4): a move from Windows to Linux or back, a
|
|
6
|
+
* project in another folder. A base is matched whatever its separators, and regardless of case for a path of Windows;
|
|
7
|
+
* what follows it takes the separators of the base it is mapped to.
|
|
8
|
+
*/
|
|
9
|
+
var TaPathMap;
|
|
10
|
+
(function (TaPathMap) {
|
|
11
|
+
/** `C:\...`, `c:/...` or `\\server\share`. */
|
|
12
|
+
function isWindows(path) {
|
|
13
|
+
return /^[a-zA-Z]:([\\/]|$)/.test(path) || /^\\\\[^\\]/.test(path);
|
|
14
|
+
}
|
|
15
|
+
TaPathMap.isWindows = isWindows;
|
|
16
|
+
/** The parts of `path` after `base`, none when it is `base`; undefined when it is not `base` nor under it. */
|
|
17
|
+
function rest(path, base) {
|
|
18
|
+
const windows = isWindows(base);
|
|
19
|
+
if (windows ? !isWindows(path) : !base.startsWith('/') || !path.startsWith('/')) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const within = parts(base, windows);
|
|
23
|
+
const all = parts(path, windows);
|
|
24
|
+
if (!within.length || all.length < within.length) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const same = (a, b) => (windows ? a.toLowerCase() === b.toLowerCase() : a === b);
|
|
28
|
+
return within.every((part, i) => same(part, all[i])) ? all.slice(within.length) : undefined;
|
|
29
|
+
}
|
|
30
|
+
TaPathMap.rest = rest;
|
|
31
|
+
function under(path, base) {
|
|
32
|
+
return rest(path, base) !== undefined;
|
|
33
|
+
}
|
|
34
|
+
TaPathMap.under = under;
|
|
35
|
+
/** `parts` under `base`, with its separator. */
|
|
36
|
+
function join(base, parts) {
|
|
37
|
+
if (!parts.length) {
|
|
38
|
+
return base;
|
|
39
|
+
}
|
|
40
|
+
const sep = isWindows(base) ? '\\' : '/';
|
|
41
|
+
return `${base.replace(/[\\/]+$/, '')}${sep}${parts.join(sep)}`;
|
|
42
|
+
}
|
|
43
|
+
TaPathMap.join = join;
|
|
44
|
+
/** The last part of a path, of either kind. */
|
|
45
|
+
function basename(path) {
|
|
46
|
+
var _a;
|
|
47
|
+
return ((_a = path
|
|
48
|
+
.split(/[\\/]+/)
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.pop()) !== null && _a !== void 0 ? _a : '');
|
|
51
|
+
}
|
|
52
|
+
TaPathMap.basename = basename;
|
|
53
|
+
/** A path under the deepest base of `pairs` it is under, as it is there; else itself. */
|
|
54
|
+
function path(value, pairs) {
|
|
55
|
+
for (const [from, to] of deepest(pairs)) {
|
|
56
|
+
const found = rest(value, from);
|
|
57
|
+
if (found) {
|
|
58
|
+
return join(to, found);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
TaPathMap.path = path;
|
|
64
|
+
/** The paths in a text (a command, `dir:<path>`), each mapped as `path` maps it; a path ends at a space or a quote. */
|
|
65
|
+
function text(value, pairs) {
|
|
66
|
+
const order = deepest(pairs);
|
|
67
|
+
if (!order.length) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
const end = String.raw `\s"'<>|*?:;,`;
|
|
71
|
+
const pattern = new RegExp(String.raw `(^|[^\w.~-])(?:${order.map(([from]) => `(${source(from)})`).join('|')})((?:[\\/][^\\/${end}]*)*)(?=$|[\\/${end})\]}])`, 'g');
|
|
72
|
+
return value.replace(pattern, (...match) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const before = match[1];
|
|
75
|
+
const found = order.findIndex((_, i) => match[i + 2] !== undefined);
|
|
76
|
+
const tail = (_a = match[order.length + 2]) !== null && _a !== void 0 ? _a : '';
|
|
77
|
+
return `${before}${join(order[found][1], tail.split(/[\\/]+/).filter(Boolean))}`;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
TaPathMap.text = text;
|
|
81
|
+
/** Every string of a value of JSON, keys too, mapped: a whole path as `path` maps it, paths in a text as `text` does. */
|
|
82
|
+
function json(value, pairs) {
|
|
83
|
+
const order = deepest(pairs);
|
|
84
|
+
if (!order.length) {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
const one = (each) => {
|
|
88
|
+
const whole = path(each, order);
|
|
89
|
+
return whole !== each ? whole : text(each, order);
|
|
90
|
+
};
|
|
91
|
+
const walk = (each) => {
|
|
92
|
+
if (typeof each === 'string') {
|
|
93
|
+
return one(each);
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(each)) {
|
|
96
|
+
return each.map(walk);
|
|
97
|
+
}
|
|
98
|
+
if (each && typeof each === 'object') {
|
|
99
|
+
return Object.fromEntries(Object.entries(each).map(([key, inner]) => [one(key), walk(inner)]));
|
|
100
|
+
}
|
|
101
|
+
return each;
|
|
102
|
+
};
|
|
103
|
+
return walk(value);
|
|
104
|
+
}
|
|
105
|
+
TaPathMap.json = json;
|
|
106
|
+
function parts(path, windows) {
|
|
107
|
+
return path.split(windows ? /[\\/]+/ : /\/+/).filter(Boolean);
|
|
108
|
+
}
|
|
109
|
+
/** The pairs that map something, the deepest base first: a path goes under the nearest. */
|
|
110
|
+
function deepest(pairs) {
|
|
111
|
+
return pairs
|
|
112
|
+
.filter(([from, to]) => from && to && from !== to && parts(from, isWindows(from)).length > 0)
|
|
113
|
+
.sort(([a], [b]) => parts(b, isWindows(b)).length - parts(a, isWindows(a)).length);
|
|
114
|
+
}
|
|
115
|
+
/** A base as a pattern: its parts by any separator, and for Windows regardless of case. */
|
|
116
|
+
function source(base) {
|
|
117
|
+
const windows = isWindows(base);
|
|
118
|
+
const quote = (part) => [...part]
|
|
119
|
+
.map(char => windows && char.toLowerCase() !== char.toUpperCase()
|
|
120
|
+
? `[${char.toLowerCase()}${char.toUpperCase()}]`
|
|
121
|
+
: char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
122
|
+
.join('');
|
|
123
|
+
const each = parts(base, windows).map(quote);
|
|
124
|
+
if (!windows) {
|
|
125
|
+
return `/${each.join('/+')}`;
|
|
126
|
+
}
|
|
127
|
+
return `${base.startsWith('\\\\') ? String.raw `\\\\` : ''}${each.join(String.raw `[\\/]+`)}`;
|
|
128
|
+
}
|
|
129
|
+
})(TaPathMap || (exports.TaPathMap = TaPathMap = {}));
|
|
130
|
+
//# sourceMappingURL=path-map.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaMessageAuthor = exports.TA_PRESENCE_EXPIRY_MS = exports.TA_PRESENCE_HEARTBEAT_MS = exports.TA_PRESENCE_SERVICE = exports.TaPresenceServer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const message_protocol_1 = require("./message-protocol");
|
|
5
5
|
exports.TaPresenceServer = Symbol('TaPresenceServer');
|
|
6
6
|
exports.TA_PRESENCE_SERVICE = 'TaPresenceServer';
|
|
7
7
|
/** A page says what it is at again this often while it lasts, the same or not. */
|
|
@@ -19,13 +19,13 @@ var TaMessageAuthor;
|
|
|
19
19
|
const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
|
|
20
20
|
/** `message` without the lines of an author. */
|
|
21
21
|
function strip(message) {
|
|
22
|
-
const context =
|
|
22
|
+
const context = message_protocol_1.TaMessageContext.read(message);
|
|
23
23
|
if (context === undefined || !LINE.test(context)) {
|
|
24
24
|
return message;
|
|
25
25
|
}
|
|
26
26
|
const kept = context.replace(LINES, '').replace(/\n+$/, '');
|
|
27
|
-
const body =
|
|
28
|
-
return kept.trim() ?
|
|
27
|
+
const body = message_protocol_1.TaMessageContext.strip(message);
|
|
28
|
+
return kept.trim() ? message_protocol_1.TaMessageContext.wrap(kept, body) : body;
|
|
29
29
|
}
|
|
30
30
|
TaMessageAuthor.strip = strip;
|
|
31
31
|
/** `message` as written by `id`, called `name`; a command (`/compact`, `!ls`) stays a command. */
|
|
@@ -35,14 +35,14 @@ var TaMessageAuthor;
|
|
|
35
35
|
return plain;
|
|
36
36
|
}
|
|
37
37
|
const line = `[ta:by ${id.replace(/[\s\]]/g, '')} ${name.replace(/[\]\n]/g, ' ').trim() || id}]`;
|
|
38
|
-
const context =
|
|
39
|
-
return
|
|
38
|
+
const context = message_protocol_1.TaMessageContext.read(plain);
|
|
39
|
+
return message_protocol_1.TaMessageContext.wrap(context === undefined ? line : `${context}\n${line}`, message_protocol_1.TaMessageContext.strip(plain));
|
|
40
40
|
}
|
|
41
41
|
TaMessageAuthor.mark = mark;
|
|
42
42
|
/** Who wrote it; undefined for the user of the Ta (no line). */
|
|
43
43
|
function of(message) {
|
|
44
44
|
var _a;
|
|
45
|
-
const context =
|
|
45
|
+
const context = message_protocol_1.TaMessageContext.read(message);
|
|
46
46
|
const match = context === undefined ? null : LINE.exec(context);
|
|
47
47
|
return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== void 0 ? _a : match[1]).trim() } : undefined;
|
|
48
48
|
}
|
package/lib/common/redactor.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** What a secret is replaced with. */
|
|
2
2
|
export declare const REDACTED = "[redacted]";
|
|
3
|
+
/** Where a secret is in a text (Redactor.spans). */
|
|
4
|
+
export interface RedactorSpan {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
kind: string;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* What looks like a secret in what is shared (docs/design/ta-link.md 2.8): keys of model services and code hosts,
|
|
5
11
|
* tokens, private keys, passwords in assignments and in URLs. It errs on hiding: a shared conversation is read
|
|
@@ -11,6 +17,12 @@ export declare class Redactor {
|
|
|
11
17
|
text(text: string): string;
|
|
12
18
|
/** Strings of a value, deep, each cut to `max` characters. */
|
|
13
19
|
value(value: unknown, max: number): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Where secrets are in a text, by the same patterns, none overlapping, the first first: what the vault of
|
|
22
|
+
* ta-secrets takes out of what the user sends. `kind` names it: `GITHUB_TOKEN`, `API_KEY` (an `sk-` key),
|
|
23
|
+
* `PRIVATE_KEY`, `BEARER_TOKEN`, `URL_PASSWORD`, or the name it was assigned to (`DB_PASSWORD`).
|
|
24
|
+
*/
|
|
25
|
+
static spans(text: string): RedactorSpan[];
|
|
14
26
|
static cut(text: string, max: number): string;
|
|
15
27
|
protected hide(): string;
|
|
16
28
|
/** What is plainly not a secret: an environment variable, a placeholder, what was hidden already. */
|
package/lib/common/redactor.js
CHANGED
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Redactor = exports.REDACTED = void 0;
|
|
4
4
|
/** What a secret is replaced with. */
|
|
5
5
|
exports.REDACTED = '[redacted]';
|
|
6
|
-
/** Secrets that have a shape of their own: the whole match goes. */
|
|
6
|
+
/** Secrets that have a shape of their own, by what they are: the whole match goes. */
|
|
7
7
|
const WHOLE = [
|
|
8
|
-
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
|
|
9
|
-
/\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}/g,
|
|
10
|
-
/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,
|
|
11
|
-
/\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
|
|
12
|
-
/\bglpat-[A-Za-z0-9_-]{20,}\b/g,
|
|
13
|
-
/\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,
|
|
14
|
-
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
15
|
-
/\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
16
|
-
/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
|
|
8
|
+
['PRIVATE_KEY', /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g],
|
|
9
|
+
['API_KEY', /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}/g],
|
|
10
|
+
['GITHUB_TOKEN', /\bgh[pousr]_[A-Za-z0-9]{30,}\b/g],
|
|
11
|
+
['GITHUB_TOKEN', /\bgithub_pat_[A-Za-z0-9_]{40,}\b/g],
|
|
12
|
+
['GITLAB_TOKEN', /\bglpat-[A-Za-z0-9_-]{20,}\b/g],
|
|
13
|
+
['SLACK_TOKEN', /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g],
|
|
14
|
+
['AWS_ACCESS_KEY_ID', /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g],
|
|
15
|
+
['GOOGLE_API_KEY', /\bAIza[0-9A-Za-z_-]{35}\b/g],
|
|
16
|
+
['JWT', /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g],
|
|
17
17
|
];
|
|
18
18
|
/** Secrets named by what is before them: what is before stays. */
|
|
19
19
|
const NAMED = [
|
|
@@ -33,7 +33,7 @@ class Redactor {
|
|
|
33
33
|
}
|
|
34
34
|
text(text) {
|
|
35
35
|
let out = text;
|
|
36
|
-
for (const pattern of WHOLE) {
|
|
36
|
+
for (const [, pattern] of WHOLE) {
|
|
37
37
|
out = out.replace(pattern, () => this.hide());
|
|
38
38
|
}
|
|
39
39
|
out = out.replace(NAMED[0], (_match, before) => before + this.hide());
|
|
@@ -54,6 +54,44 @@ class Redactor {
|
|
|
54
54
|
}
|
|
55
55
|
return value;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Where secrets are in a text, by the same patterns, none overlapping, the first first: what the vault of
|
|
59
|
+
* ta-secrets takes out of what the user sends. `kind` names it: `GITHUB_TOKEN`, `API_KEY` (an `sk-` key),
|
|
60
|
+
* `PRIVATE_KEY`, `BEARER_TOKEN`, `URL_PASSWORD`, or the name it was assigned to (`DB_PASSWORD`).
|
|
61
|
+
*/
|
|
62
|
+
static spans(text) {
|
|
63
|
+
var _a;
|
|
64
|
+
var _b;
|
|
65
|
+
const found = [];
|
|
66
|
+
for (const [kind, pattern] of WHOLE) {
|
|
67
|
+
for (const match of text.matchAll(pattern)) {
|
|
68
|
+
found.push({ start: match.index, end: match.index + match[0].length, kind });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const match of text.matchAll(NAMED[0])) {
|
|
72
|
+
found.push({ start: match.index + match[1].length, end: match.index + match[0].length, kind: 'BEARER_TOKEN' });
|
|
73
|
+
}
|
|
74
|
+
for (const match of text.matchAll(NAMED[1])) {
|
|
75
|
+
if (!Redactor.placeholder(match[2])) {
|
|
76
|
+
const start = match.index + match[1].length;
|
|
77
|
+
const name = (_b = (_a = /[A-Za-z0-9_.-]+/.exec(match[1])) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'SECRET';
|
|
78
|
+
found.push({ start, end: start + match[2].length, kind: name.replace(/[^A-Za-z0-9]+/g, '_').toUpperCase() });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const match of text.matchAll(NAMED[2])) {
|
|
82
|
+
const start = match.index + match[1].length;
|
|
83
|
+
found.push({ start, end: start + match[2].length, kind: 'URL_PASSWORD' });
|
|
84
|
+
}
|
|
85
|
+
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
86
|
+
const spans = [];
|
|
87
|
+
for (const span of found) {
|
|
88
|
+
const last = spans.at(-1);
|
|
89
|
+
if (!last || span.start >= last.end) {
|
|
90
|
+
spans.push(span);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return spans;
|
|
94
|
+
}
|
|
57
95
|
static cut(text, max) {
|
|
58
96
|
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
59
97
|
}
|
|
@@ -105,6 +105,18 @@ export interface TaRelays {
|
|
|
105
105
|
}[];
|
|
106
106
|
/** The types of services packages registered (WebDAV, S3…), to add one of. */
|
|
107
107
|
types?: TaRelayTypeInfo[];
|
|
108
|
+
/** The deployment of Ta joined (TaRelayServer.joinDeployment): its relay is the default of what is new. */
|
|
109
|
+
deployment?: TaJoinedDeployment;
|
|
110
|
+
}
|
|
111
|
+
/** A deployment of Ta joined by its address (docs/design/ta-deploy.md 8). */
|
|
112
|
+
export interface TaJoinedDeployment {
|
|
113
|
+
/** The address the user gave. */
|
|
114
|
+
url: string;
|
|
115
|
+
name?: string;
|
|
116
|
+
/** Its gateway: a Ta in the cloud of one's own account there, or its sandbox as a cloud workspace. */
|
|
117
|
+
gateway?: string;
|
|
118
|
+
/** The id of its relay in TaRelays.relays. */
|
|
119
|
+
relay?: string;
|
|
108
120
|
}
|
|
109
121
|
/** What asking a relay what it is found (TaRelayServer.probeRelay). */
|
|
110
122
|
export interface TaRelayProbe {
|
|
@@ -164,6 +176,14 @@ export interface TaRelayServer {
|
|
|
164
176
|
* on the relay it was made on.
|
|
165
177
|
*/
|
|
166
178
|
chooseRelay(feature: TaRelayFeature, id: string | null): Promise<TaRelays>;
|
|
179
|
+
/**
|
|
180
|
+
* Joins a deployment of Ta by the address of any of its services (its gateway, its relay), which says what it is at
|
|
181
|
+
* /.well-known/ta: its relay is added and made the default of new pairings, rooms and links; what was made before
|
|
182
|
+
* stays where it is.
|
|
183
|
+
*/
|
|
184
|
+
joinDeployment(url: string): Promise<TaRelays>;
|
|
185
|
+
/** Leaves the deployment joined: the relay of this build is the default again. */
|
|
186
|
+
leaveDeployment(): Promise<TaRelays>;
|
|
167
187
|
/** Asks a relay, by its id or address, what it can do and how much; never throws. */
|
|
168
188
|
probeRelay(idOrUrl: string): Promise<TaRelayProbe>;
|
|
169
189
|
/**
|
|
@@ -49,6 +49,8 @@ export interface TaRoomInfo {
|
|
|
49
49
|
relay?: string;
|
|
50
50
|
/** This Ta made it. */
|
|
51
51
|
owner: boolean;
|
|
52
|
+
/** Of a room this Ta made: the members it lets in at most (TaRoomServer.configureRoom). */
|
|
53
|
+
capacity?: number;
|
|
52
54
|
ownerName: string;
|
|
53
55
|
status: TaRoomStatus;
|
|
54
56
|
/** Why it is `gone`: `closed` by the owner, `removed` by the owner, the `invite` no longer works. */
|
|
@@ -155,7 +157,7 @@ export interface TaRoomServer {
|
|
|
155
157
|
}): Promise<TaRoomInfo>;
|
|
156
158
|
/**
|
|
157
159
|
* The link others ask to join by (the owner only): the one of before while it has a day left; else, or with `renew`,
|
|
158
|
-
* a new one for `days` (7 by default,
|
|
160
|
+
* a new one for `days` (7 by default, 365 at most), and the links of before stop working.
|
|
159
161
|
*/
|
|
160
162
|
invite(room: string, options?: {
|
|
161
163
|
days?: number;
|
|
@@ -164,6 +166,10 @@ export interface TaRoomServer {
|
|
|
164
166
|
link: string;
|
|
165
167
|
expiresAt: number;
|
|
166
168
|
}>;
|
|
169
|
+
/** The owner's choices for a room: the members it lets in at most (16 by default, 2 to 100); those in already stay. */
|
|
170
|
+
configureRoom(room: string, options: {
|
|
171
|
+
members?: number;
|
|
172
|
+
}): Promise<TaRoomInfo>;
|
|
167
173
|
/** Asks to join the room of a link: `waiting` till its owner answers. Ask the user first. */
|
|
168
174
|
join(link: string): Promise<TaRoomInfo>;
|
|
169
175
|
/** Those asking to join the rooms of this Ta. */
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { TaSignInProvider } from './access-protocol';
|
|
2
|
+
import type { TaHostCommands } from './app-protocol';
|
|
2
3
|
import type { TaPackageServer } from './package-protocol';
|
|
4
|
+
import type { TaHostPages } from './page-protocol';
|
|
3
5
|
import type { TaPresencePerson } from './presence-protocol';
|
|
4
6
|
import type { TaRelayFeature, TaRelayService, TaRelayStore, TaRelayType, TaShares } from './relay-protocol';
|
|
5
7
|
import type { TaRooms } from './room-protocol';
|
|
6
8
|
import type { TaServer } from './ta-protocol';
|
|
7
9
|
import type { TaAuthorizer, TaMemberInfo, TaResource, TaSharedData, TaSharedRef } from './team-protocol';
|
|
10
|
+
import type { TaExtensionVoices } from './voice-protocol';
|
|
8
11
|
/**
|
|
9
12
|
* What `ta serve` gives the server side of a package: the sessions and the data of packages, in its own
|
|
10
13
|
* process, without a token. A subset of TaServer and TaPackageServer: it can open, drive, stop and close
|
|
11
14
|
* sessions (best those it opened: closing one takes it from every client), not remove anything.
|
|
12
15
|
*/
|
|
13
|
-
export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listSessions' | 'openSession' | 'closeSession' | 'setSessionName' | 'prompt' | 'followUp' | 'abort' | 'getState' | 'getLastAssistantText'>, Pick<TaPackageServer, 'getExtensionData' | 'setExtensionData' | 'listPackages' | 'callPackageHost' | 'installPackage' | 'removePackage'> {
|
|
16
|
+
export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listSessions' | 'openSession' | 'closeSession' | 'setSessionName' | 'prompt' | 'followUp' | 'abort' | 'getState' | 'getLastAssistantText' | 'relocateDirectory'>, Pick<TaPackageServer, 'getExtensionData' | 'setExtensionData' | 'listPackages' | 'callPackageHost' | 'installPackage' | 'removePackage'> {
|
|
14
17
|
/** The agent directory of Ta (`~/.ta/agent`): its `extensions/` holds the packages of the user. */
|
|
15
18
|
readonly agentDir: string;
|
|
16
19
|
/** Where the conversation of a session file works, as clients name it (a path or an `ssh://` location), without opening it; undefined when it cannot be read. */
|
|
@@ -21,8 +24,12 @@ export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listS
|
|
|
21
24
|
readonly rooms: TaRooms;
|
|
22
25
|
/** The services of relays.json, as the user chose them for each feature (docs/design/ta-relays.md). */
|
|
23
26
|
readonly relays: TaExtensionRelays;
|
|
27
|
+
/** The voice services of calls, as packages add types of them (docs/design/ta-voice.md). */
|
|
28
|
+
readonly voices: TaExtensionVoices;
|
|
24
29
|
/** pi's messages of a session file, of the branch it is on (its first message first), without opening it. */
|
|
25
30
|
sessionMessages(sessionFile: string): Promise<unknown[]>;
|
|
31
|
+
/** The role a session file was opened with last (TaOpenSessionOptions.appendSystemPrompt), without opening it; undefined without one. */
|
|
32
|
+
sessionRole(sessionFile: string): Promise<string | undefined>;
|
|
26
33
|
/**
|
|
27
34
|
* A new conversation of `cwd` holding these messages of pi (an assistant's among them), named `name`: its session
|
|
28
35
|
* file, to open with `openSession`. As a conversation brought from elsewhere (a link of another Ta).
|
|
@@ -39,6 +46,13 @@ export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listS
|
|
|
39
46
|
presence(): TaPresence;
|
|
40
47
|
/** The people let into this Ta besides its user, and what they may do (docs/design/ta-team.md). */
|
|
41
48
|
readonly team: TaHostTeam;
|
|
49
|
+
/**
|
|
50
|
+
* The catalog of what can be done to Ta without its pages (docs/design/ta-app-use.md 2): an action a package
|
|
51
|
+
* registers goes when the package stops.
|
|
52
|
+
*/
|
|
53
|
+
readonly commands: TaHostCommands;
|
|
54
|
+
/** The pages of Ta open now, to ask one of them what its web extension answers (docs/design/ta-app-use.md 4.1). */
|
|
55
|
+
readonly pages: TaHostPages;
|
|
42
56
|
/**
|
|
43
57
|
* Rewrites pi's `settings.json` of the user as pi does, under its lock: `update` gets the settings read under the
|
|
44
58
|
* lock and returns them whole; the open sessions read them again. For what changes settings of the user that are no
|
|
@@ -79,7 +93,23 @@ export interface TaExtensionRelays {
|
|
|
79
93
|
export interface TaPackageService {
|
|
80
94
|
/** `ta serve` stops, or the package is turned off. */
|
|
81
95
|
dispose?(): void | Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* A POST to `/api/hooks/<directory name of the package>/<path>` of ta serve, from a script or a service of this
|
|
98
|
+
* machine: reached WITHOUT the token of ta serve, so the package checks a secret of its own in `path` and throws
|
|
99
|
+
* for one it does not know (the caller gets a 404). Its answer is sent back as JSON.
|
|
100
|
+
*/
|
|
101
|
+
webhook?(request: TaWebhookRequest): unknown | Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
/** What a webhook of a package was sent (TaPackageService.webhook). */
|
|
104
|
+
export interface TaWebhookRequest {
|
|
105
|
+
/** After the name of the package, without a leading slash, without the query. */
|
|
106
|
+
path: string;
|
|
107
|
+
/** The body, as text, at most TA_WEBHOOK_MAX_BYTES. */
|
|
108
|
+
body: string;
|
|
109
|
+
contentType?: string;
|
|
82
110
|
}
|
|
111
|
+
/** The largest body a webhook takes; a larger one is refused (413). */
|
|
112
|
+
export declare const TA_WEBHOOK_MAX_BYTES: number;
|
|
83
113
|
/**
|
|
84
114
|
* The default export of a module that a package names in `pi.host` of its package.json. `ta serve` runs it
|
|
85
115
|
* once when it starts (or when the package is turned on), for built-in packages; `ta` without `serve`
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaAskUtil = exports.TA_ASK_ENTRY = exports.TA_BRIEF_SOURCE = exports.TA_KEEP_MARK = exports.TA_WITH_OTHERS_MARK = exports.TA_NOTICES = exports.TA_DOUBLE_TASKS = exports.TA_DOUBLE_LOOK = exports.TA_DOUBLE_FILE = exports.TA_FILE_WRITE_EVENT = exports.TaHostUtil = exports.TA_HOST_EVENT = void 0;
|
|
3
|
+
exports.TaAskUtil = exports.TA_ASK_ENTRY = exports.TA_BRIEF_SOURCE = exports.TA_KEEP_MARK = exports.TA_WITH_OTHERS_MARK = exports.TA_NOTICES = exports.TA_DOUBLE_TASKS = exports.TA_DOUBLE_LOOK = exports.TA_DOUBLE_FILE = exports.TA_FILE_WRITE_EVENT = exports.TaHostUtil = exports.TA_HOST_EVENT = exports.TA_WEBHOOK_MAX_BYTES = void 0;
|
|
4
|
+
/** The largest body a webhook takes; a larger one is refused (413). */
|
|
5
|
+
exports.TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
4
6
|
/**
|
|
5
7
|
* The event of pi's `pi.events` by which a pi extension asks for the host of its package:
|
|
6
8
|
* `pi.events.emit(TA_HOST_EVENT, { name, resolve, heard })`. Under `ta serve` `heard` is called as the event
|