@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,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaSaid = void 0;
|
|
4
|
+
const message_protocol_1 = require("./message-protocol");
|
|
5
|
+
/**
|
|
6
|
+
* What a person reads of a message (docs/design/ta-said.md). The text of pi's messages holds marks that are for the
|
|
7
|
+
* model or for a program, not for people: the `<context>` of a message of the user and the line of where it came
|
|
8
|
+
* from in it, pi's notes of images, the `<skill>` block of `/skill:name`, the notes of the double's tasks, the summary
|
|
9
|
+
* an external agent compacts its context to, and fenced blocks of Ta's languages, which a page draws as cards or
|
|
10
|
+
* leaves out. Every place that shows people what was said (a list, a notice, a link shared, a bot's chat, a copy, a
|
|
11
|
+
* voice) reads it here, never the text itself, and never strips a mark of its own: a new mark is added to
|
|
12
|
+
* message-protocol.ts, to words and to SAMPLES, and every place is right at once. The specs of those places run
|
|
13
|
+
* SAMPLES through them and check with leaks that nothing of the model is left.
|
|
14
|
+
*/
|
|
15
|
+
var TaSaid;
|
|
16
|
+
(function (TaSaid) {
|
|
17
|
+
/** Fenced blocks of these languages are Ta's (cards, proposals, what a call says aloud): drawn or left out, never read as text. */
|
|
18
|
+
const CARD = /^ta-/i;
|
|
19
|
+
/** Of a long message, a preview reads so much: enough for its first lines. */
|
|
20
|
+
const READ = 4000;
|
|
21
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
22
|
+
/** A line that is a tag alone (`<summary>`, `</context>`): a mark of a program, never words, even one not known yet. */
|
|
23
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
24
|
+
/** A line of marks only: a rule, the head of a table. */
|
|
25
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
26
|
+
/** The marks of the model that leaks finds, each by a name. */
|
|
27
|
+
const MARKS = [
|
|
28
|
+
['context', /<\/?context>/],
|
|
29
|
+
['source', /\[ta:(?:from|notice|by) /],
|
|
30
|
+
['image note', /\[Image: original \d+x\d+|\[Image converted from /],
|
|
31
|
+
['skill', /<skill name="|<\/skill>/],
|
|
32
|
+
['task note', /<\/?task_(?:update|adopted|renamed)\b/],
|
|
33
|
+
['summary', /<\/?(?:conversation_history_summary|summary)>/],
|
|
34
|
+
];
|
|
35
|
+
/** The text of the content of a message of pi: its text parts, joined by `joiner`. */
|
|
36
|
+
function text(content, joiner = '\n') {
|
|
37
|
+
if (typeof content === 'string') {
|
|
38
|
+
return content;
|
|
39
|
+
}
|
|
40
|
+
return Array.isArray(content)
|
|
41
|
+
? content
|
|
42
|
+
.filter((part) => (part === null || part === void 0 ? void 0 : part.type) === 'text' && typeof part.text === 'string')
|
|
43
|
+
.map(part => part.text)
|
|
44
|
+
.join(joiner)
|
|
45
|
+
: '';
|
|
46
|
+
}
|
|
47
|
+
TaSaid.text = text;
|
|
48
|
+
/**
|
|
49
|
+
* What a person reads of the text of a message, as Markdown, empty when nothing of it is for a person. Of the
|
|
50
|
+
* user's, what they typed: without the context for the model and pi's notes of its images, a skill they ran as
|
|
51
|
+
* `/skill:name` and what follows, a note of the double's tasks as the task (its title, and how it ended), none of a
|
|
52
|
+
* note of a new id. Of the agent's, without the summary it compacted its context to (empty while only its tags
|
|
53
|
+
* have come). A line that is a tag alone, outside code, is left out too; `cards: false` also leaves out the
|
|
54
|
+
* fenced blocks of Ta's languages.
|
|
55
|
+
*/
|
|
56
|
+
function words(role, text, options = {}) {
|
|
57
|
+
const said = role === 'user' ? userWords(text) : message_protocol_1.TaAgentSummary.strip(text);
|
|
58
|
+
return withoutFences(said, language => options.cards === false && CARD.test(language), true).trim();
|
|
59
|
+
}
|
|
60
|
+
TaSaid.words = words;
|
|
61
|
+
/** {@link words} of a message of pi. */
|
|
62
|
+
function of(message, options) {
|
|
63
|
+
return message ? words(message.role, text(message.content), options) : '';
|
|
64
|
+
}
|
|
65
|
+
TaSaid.of = of;
|
|
66
|
+
/**
|
|
67
|
+
* Whether a message is a notice of a part of Ta, not the user's (TaMessageSource.notice): a page shows it as a line
|
|
68
|
+
* of its own, not as their bubble, and a list neither titles a conversation by it nor shows it as what was said last.
|
|
69
|
+
*/
|
|
70
|
+
function notice(message) {
|
|
71
|
+
return (message === null || message === void 0 ? void 0 : message.role) === 'user' && message_protocol_1.TaMessageSource.isNotice(text(message.content));
|
|
72
|
+
}
|
|
73
|
+
TaSaid.notice = notice;
|
|
74
|
+
/** Whether a text that says something holds marks only: a message that is no words for a person (the summary alone). */
|
|
75
|
+
function marksOnly(role, text) {
|
|
76
|
+
return !!text.trim() && !line(words(role, text), { chars: Number.POSITIVE_INFINITY });
|
|
77
|
+
}
|
|
78
|
+
TaSaid.marksOnly = marksOnly;
|
|
79
|
+
/**
|
|
80
|
+
* Markdown as the plain words of a preview, as a messenger shows the last thing said: without fenced blocks (the
|
|
81
|
+
* code of one when there is nothing else, never a block of Ta's languages), the marks of Markdown at the start
|
|
82
|
+
* of lines and around words, a line that is a tag alone, links by their words, pictures by the words that name
|
|
83
|
+
* them in a message of pictures only.
|
|
84
|
+
*/
|
|
85
|
+
function line(markdown, options) {
|
|
86
|
+
var _a;
|
|
87
|
+
const read = markdown.slice(0, READ);
|
|
88
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
89
|
+
const lines = plain(prose || codeOf(read))
|
|
90
|
+
.split('\n')
|
|
91
|
+
.map(part => part
|
|
92
|
+
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, '')
|
|
93
|
+
.replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, '')
|
|
94
|
+
.replace(/\s+/g, ' ')
|
|
95
|
+
.trim())
|
|
96
|
+
.filter(part => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
|
|
97
|
+
const count = (_a = options.lines) !== null && _a !== void 0 ? _a : 1;
|
|
98
|
+
const joined = count <= 1 ? lines.join(' ') : lines.slice(0, count).join('\n');
|
|
99
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
100
|
+
}
|
|
101
|
+
TaSaid.line = line;
|
|
102
|
+
/**
|
|
103
|
+
* The marks of the model a text shown to a person still holds, by name: none is right. For the specs of the
|
|
104
|
+
* places that show what was said; `cards: true` where Ta's pages draw the blocks of its languages.
|
|
105
|
+
*/
|
|
106
|
+
function leaks(shown, options = {}) {
|
|
107
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
108
|
+
const lines = shown.split('\n');
|
|
109
|
+
if (options.cards !== true && lines.some(part => { var _a; var _b; return CARD.test((_b = (_a = FENCE.exec(part)) === null || _a === void 0 ? void 0 : _a[2]) !== null && _b !== void 0 ? _b : ''); })) {
|
|
110
|
+
found.push('card');
|
|
111
|
+
}
|
|
112
|
+
if (lines.some(part => TAG_LINE.test(part.trim()))) {
|
|
113
|
+
found.push('tag');
|
|
114
|
+
}
|
|
115
|
+
return found;
|
|
116
|
+
}
|
|
117
|
+
TaSaid.leaks = leaks;
|
|
118
|
+
const SUMMARY = '<conversation_history_summary>\n<summary>\n1. Primary Request and Intent:\n The user works on the relay.\n</summary>\n</conversation_history_summary>';
|
|
119
|
+
/** A message with each mark, as it comes: what the specs of every place that shows what was said run through it. */
|
|
120
|
+
TaSaid.SAMPLES = [
|
|
121
|
+
{
|
|
122
|
+
mark: 'context and where it came from',
|
|
123
|
+
role: 'user',
|
|
124
|
+
text: '<context>\nThe channel #ops, its members.\n[ta:from @celljs/ta-channels #ops]\n</context>\nCheck the build',
|
|
125
|
+
said: 'Check the build',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
mark: 'a notice, not the user',
|
|
129
|
+
role: 'user',
|
|
130
|
+
text: '<context>\n[ta:notice @celljs/ta-call]\n</context>\nThe work finished. Its last words: tests pass.',
|
|
131
|
+
said: 'The work finished. Its last words: tests pass.',
|
|
132
|
+
},
|
|
133
|
+
{ mark: 'one let in', role: 'user', text: '<context>\n[ta:by p-7 Alice]\n</context>\nHello there', said: 'Hello there' },
|
|
134
|
+
{
|
|
135
|
+
mark: 'notes of images',
|
|
136
|
+
role: 'user',
|
|
137
|
+
text: 'Look at this\n[Image: original 3024x4032, displayed at 1512x2016. Multiply coordinates by 2.00 to map to original image.]\n[Image converted from image/heic to image/png.]',
|
|
138
|
+
said: 'Look at this',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
mark: 'a skill run',
|
|
142
|
+
role: 'user',
|
|
143
|
+
text: '<skill name="ta-package" location="/skills/ta-package/SKILL.md">\n# Ta package\nSteps.\n</skill>\n\nMake a card',
|
|
144
|
+
said: 'Make a card',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
mark: 'a note of a task',
|
|
148
|
+
role: 'user',
|
|
149
|
+
text: '<task_update id="t1" title="Fix login" status="done">\nAll tests pass.\n</task_update>',
|
|
150
|
+
said: 'Fix login',
|
|
151
|
+
},
|
|
152
|
+
{ mark: 'a note of a new id', role: 'user', text: '<task_renamed id="t2" was="t1" title="Fix login">\nNow t2.\n</task_renamed>' },
|
|
153
|
+
{ mark: 'a summary, then the answer', role: 'assistant', text: `${SUMMARY}\nSwitched to voice.`, said: 'Switched to voice.' },
|
|
154
|
+
{ mark: 'a summary alone', role: 'assistant', text: SUMMARY },
|
|
155
|
+
{ mark: 'a summary as it streams', role: 'assistant', text: '<conversation_history_summary>\n<summary>' },
|
|
156
|
+
{
|
|
157
|
+
mark: 'a card after the answer',
|
|
158
|
+
role: 'assistant',
|
|
159
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
160
|
+
said: 'tests pass',
|
|
161
|
+
},
|
|
162
|
+
{ mark: 'a card alone', role: 'assistant', text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
163
|
+
{ mark: 'a proposal', role: 'assistant', text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: 'Committed.' },
|
|
164
|
+
{ mark: 'what a call says aloud', role: 'assistant', text: 'All fixed.\n\n```ta-say\nIt is fixed.\n```', said: 'All fixed.' },
|
|
165
|
+
{ mark: 'a tag not known yet', role: 'assistant', text: '<system-reminder>\n</system-reminder>\nReady.', said: 'Ready.' },
|
|
166
|
+
];
|
|
167
|
+
function userWords(text) {
|
|
168
|
+
const said = message_protocol_1.TaImageNote.strip(message_protocol_1.TaMessageContext.strip(text));
|
|
169
|
+
const skill = message_protocol_1.TaSkillUse.parse(said);
|
|
170
|
+
if (skill) {
|
|
171
|
+
return message_protocol_1.TaSkillUse.command(skill);
|
|
172
|
+
}
|
|
173
|
+
const note = message_protocol_1.TaTaskNote.parse(said);
|
|
174
|
+
if (!note) {
|
|
175
|
+
return said;
|
|
176
|
+
}
|
|
177
|
+
if (note.kind === 'renamed') {
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
return note.kind === 'update' && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The text without the fenced blocks whose language `drop` names (one not closed runs to the end, as it streams),
|
|
184
|
+
* and with `tags` without the lines outside them that are a tag alone.
|
|
185
|
+
*/
|
|
186
|
+
function withoutFences(text, drop, tags = false) {
|
|
187
|
+
const kept = [];
|
|
188
|
+
let fence;
|
|
189
|
+
let left = false;
|
|
190
|
+
for (const part of text.split('\n')) {
|
|
191
|
+
const open = FENCE.exec(part);
|
|
192
|
+
if (!fence && open) {
|
|
193
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
194
|
+
}
|
|
195
|
+
else if (fence && closes(part, fence.mark)) {
|
|
196
|
+
const dropped = fence.dropped;
|
|
197
|
+
fence = undefined;
|
|
198
|
+
if (dropped) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if ((fence === null || fence === void 0 ? void 0 : fence.dropped) || (!fence && tags && TAG_LINE.test(part.trim()))) {
|
|
203
|
+
left = true;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
kept.push(part);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// What was left out leaves no gap of its own.
|
|
210
|
+
return left ? kept.join('\n').replace(/\n{3,}/g, '\n\n') : kept.join('\n');
|
|
211
|
+
}
|
|
212
|
+
/** The code of the fenced blocks of `text` that are not Ta's. */
|
|
213
|
+
function codeOf(text) {
|
|
214
|
+
const code = [];
|
|
215
|
+
let fence;
|
|
216
|
+
for (const part of text.split('\n')) {
|
|
217
|
+
const open = FENCE.exec(part);
|
|
218
|
+
if (!fence && open) {
|
|
219
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
220
|
+
}
|
|
221
|
+
else if (fence && closes(part, fence.mark)) {
|
|
222
|
+
fence = undefined;
|
|
223
|
+
}
|
|
224
|
+
else if (fence && !fence.card) {
|
|
225
|
+
code.push(part);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return code.join('\n');
|
|
229
|
+
}
|
|
230
|
+
function closes(part, mark) {
|
|
231
|
+
var _a;
|
|
232
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === void 0 ? void 0 : _a[1];
|
|
233
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
234
|
+
}
|
|
235
|
+
/** Links by their words; pictures left out of a message that says something else, by the words that name them in one of pictures only. */
|
|
236
|
+
function plain(text) {
|
|
237
|
+
const linked = text.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
238
|
+
const words = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, '').trim();
|
|
239
|
+
return words || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
240
|
+
}
|
|
241
|
+
})(TaSaid || (exports.TaSaid = TaSaid = {}));
|
|
242
|
+
//# sourceMappingURL=said-protocol.js.map
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
export declare const TaScreenShareServer: unique symbol;
|
|
2
|
+
export declare const TA_SCREEN_SHARE_SERVICE = "TaScreenShareServer";
|
|
3
|
+
/**
|
|
4
|
+
* What a call refused for a remote desktop says, in English: the kernel and ta-team say it the same
|
|
5
|
+
* (docs/design/ta-desktop-remote.md 6.7).
|
|
6
|
+
*/
|
|
7
|
+
export declare const TA_DESKTOP_LOCKED_MESSAGE = "Not while someone else works a desktop of this Ta.";
|
|
8
|
+
/**
|
|
9
|
+
* A desktop Ta can show and work (docs/design/ta-desktop-remote.md 4.1): a VNC server reached from the machine of
|
|
10
|
+
* `via`, '' for the machine of ta serve or `ssh://<host>` for a host of ssh directories, at `host`:`port` as that
|
|
11
|
+
* machine sees it (127.0.0.1:5900, its own screen, by default). `name` is what the user called it.
|
|
12
|
+
*/
|
|
13
|
+
export interface TaDesktopTarget {
|
|
14
|
+
via: string;
|
|
15
|
+
host?: string;
|
|
16
|
+
port?: number;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The connection of RFB to a desktop. */
|
|
20
|
+
export type TaDesktopLink = 'connecting' | 'live' | 'locked' | 'asleep' | 'lost';
|
|
21
|
+
/** A screen of a desktop: one of ExtendedDesktopSize, or the whole framebuffer as one. */
|
|
22
|
+
export interface TaDesktopScreen {
|
|
23
|
+
/** The id ExtendedDesktopSize gives, in decimal; `whole` for a framebuffer of one screen. */
|
|
24
|
+
id: string;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
/** Pixels of the framebuffer a point of its system: 2 for a Retina Mac (guessed), else 1. */
|
|
30
|
+
scale: number;
|
|
31
|
+
/** The one at (0, 0), else the first. */
|
|
32
|
+
primary: boolean;
|
|
33
|
+
name?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Who works a desktop: one page at a time; the others look (docs/design/ta-desktop-remote.md 6.4). */
|
|
36
|
+
export interface TaDesktopControl {
|
|
37
|
+
/** The principal: TA_OWNER, or one let in (from the third stage). */
|
|
38
|
+
by: string;
|
|
39
|
+
name: string;
|
|
40
|
+
/** What the page is on: `phone`, `tablet` or `computer`. */
|
|
41
|
+
device: string;
|
|
42
|
+
/** It is the page this answer goes to. */
|
|
43
|
+
self: boolean;
|
|
44
|
+
since: number;
|
|
45
|
+
/** It goes back to looking at this time without input. */
|
|
46
|
+
until: number;
|
|
47
|
+
}
|
|
48
|
+
/** A page looking at a desktop. Without its viewerId: that reads its frames and sends its input. */
|
|
49
|
+
export interface TaDesktopWatcher {
|
|
50
|
+
by: string;
|
|
51
|
+
name: string;
|
|
52
|
+
device: string;
|
|
53
|
+
self: boolean;
|
|
54
|
+
since: number;
|
|
55
|
+
}
|
|
56
|
+
/** What a desktop can do, known once connected. */
|
|
57
|
+
export interface TaDesktopCapabilities {
|
|
58
|
+
keyboard: 'keysym' | 'scancode';
|
|
59
|
+
/** Whether it takes Unicode keysyms; null until the first character beyond ASCII went. */
|
|
60
|
+
unicodeKeys: boolean | null;
|
|
61
|
+
clipboardWrite: boolean;
|
|
62
|
+
/** Always false in the first stage. */
|
|
63
|
+
clipboardRead: boolean;
|
|
64
|
+
/** The pointer's picture comes apart, drawn by the page. */
|
|
65
|
+
cursor: boolean;
|
|
66
|
+
/** ExtendedDesktopSize: its screens, and changes of size. */
|
|
67
|
+
screens: boolean;
|
|
68
|
+
system?: 'mac' | 'windows' | 'linux';
|
|
69
|
+
}
|
|
70
|
+
/** A desktop of the list (TaScreenShareServer.listDesktops). */
|
|
71
|
+
export interface TaDesktopInfo {
|
|
72
|
+
/** `<via>|<host>:<port>`, written whole: how calls and records name it. */
|
|
73
|
+
id: string;
|
|
74
|
+
target: TaDesktopTarget;
|
|
75
|
+
/** Always some: the target's name, else this computer, the ssh host or host:port. */
|
|
76
|
+
name: string;
|
|
77
|
+
/** This computer, a host of ssh directories, or one of the network (`via` '' and a host not of loopback). */
|
|
78
|
+
source: 'this' | 'ssh' | 'lan';
|
|
79
|
+
state: 'idle' | 'connecting' | 'viewing' | 'controlled';
|
|
80
|
+
link?: TaDesktopLink;
|
|
81
|
+
screens?: TaDesktopScreen[];
|
|
82
|
+
control: TaDesktopControl | null;
|
|
83
|
+
viewers: TaDesktopWatcher[];
|
|
84
|
+
/** The viewer of the calling connection: its id and the last frame it made. */
|
|
85
|
+
mine?: {
|
|
86
|
+
viewerId: string;
|
|
87
|
+
built: number;
|
|
88
|
+
};
|
|
89
|
+
capabilities?: TaDesktopCapabilities;
|
|
90
|
+
}
|
|
91
|
+
/** What a page looks at, and how big it draws it (docs/design/ta-desktop-remote.md 5.2). */
|
|
92
|
+
export interface TaDesktopView {
|
|
93
|
+
/** Larger than the last: a view that comes late is dropped. */
|
|
94
|
+
revision: number;
|
|
95
|
+
/** Which screen; the primary one when not given. */
|
|
96
|
+
screen?: string;
|
|
97
|
+
/** A part of the framebuffer; the whole screen when not given. */
|
|
98
|
+
rect?: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
w: number;
|
|
102
|
+
h: number;
|
|
103
|
+
};
|
|
104
|
+
/** Pixels of the device the page draws it in: the server scales the part to them (at most the part itself). */
|
|
105
|
+
width: number;
|
|
106
|
+
height: number;
|
|
107
|
+
quality?: 'auto' | 'crisp' | 'smooth';
|
|
108
|
+
}
|
|
109
|
+
/** One opened view of a desktop by a page (TaScreenShareServer.openDesktop). */
|
|
110
|
+
export interface TaDesktopViewer {
|
|
111
|
+
/** Random, never used again: a new one is a new count of frames. */
|
|
112
|
+
viewerId: string;
|
|
113
|
+
/** The first frame to claim; it is whole. */
|
|
114
|
+
next: number;
|
|
115
|
+
size: {
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
screens: TaDesktopScreen[];
|
|
119
|
+
};
|
|
120
|
+
control: TaDesktopControl | null;
|
|
121
|
+
capabilities: TaDesktopCapabilities;
|
|
122
|
+
}
|
|
123
|
+
/** A picture of part of the view: a JPEG, at its place in the pixels of the view. */
|
|
124
|
+
export interface TaDesktopTile {
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
w: number;
|
|
128
|
+
h: number;
|
|
129
|
+
/** Base64. */
|
|
130
|
+
jpeg: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The answer to claiming frame `want` (TaScreenShareServer.readDesktopFrames, docs/design/ta-desktop-remote.md 5.4):
|
|
134
|
+
* a frame, or `idle` (claim it again), `stale` (claim from seq + 1, which is whole) or `unknown` (open again).
|
|
135
|
+
*/
|
|
136
|
+
export interface TaDesktopFrames {
|
|
137
|
+
seq: number;
|
|
138
|
+
/** The frame it is drawn over: seq - 1; 0 for a whole one. */
|
|
139
|
+
base?: number;
|
|
140
|
+
idle?: true;
|
|
141
|
+
stale?: true;
|
|
142
|
+
unknown?: true;
|
|
143
|
+
/** Milliseconds from the claim to the start of the frame's encoding. */
|
|
144
|
+
waited: number;
|
|
145
|
+
size?: {
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
screens: TaDesktopScreen[];
|
|
149
|
+
};
|
|
150
|
+
/** The part the tiles show and the pixels they are in. */
|
|
151
|
+
view?: {
|
|
152
|
+
rect: {
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
w: number;
|
|
156
|
+
h: number;
|
|
157
|
+
};
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
};
|
|
161
|
+
/** The picture of the pointer, a PNG in base64; null when hidden. Only when it changed. */
|
|
162
|
+
cursor?: {
|
|
163
|
+
hotX: number;
|
|
164
|
+
hotY: number;
|
|
165
|
+
width: number;
|
|
166
|
+
height: number;
|
|
167
|
+
png: string;
|
|
168
|
+
} | null;
|
|
169
|
+
/** The pointer of whoever else works it. */
|
|
170
|
+
pointer?: {
|
|
171
|
+
x: number;
|
|
172
|
+
y: number;
|
|
173
|
+
};
|
|
174
|
+
tiles: TaDesktopTile[];
|
|
175
|
+
/** Only when it changed. */
|
|
176
|
+
control?: TaDesktopControl | null;
|
|
177
|
+
/** Only when it changed. */
|
|
178
|
+
state?: TaDesktopLink;
|
|
179
|
+
/** Why it was lost, in English. */
|
|
180
|
+
error?: string;
|
|
181
|
+
}
|
|
182
|
+
/** What a page does to the desktop it works: positions in the framebuffer. */
|
|
183
|
+
export type TaDesktopInput = {
|
|
184
|
+
kind: 'pointer';
|
|
185
|
+
x: number;
|
|
186
|
+
y: number;
|
|
187
|
+
buttons: number;
|
|
188
|
+
} | {
|
|
189
|
+
kind: 'wheel';
|
|
190
|
+
x: number;
|
|
191
|
+
y: number;
|
|
192
|
+
dx: number;
|
|
193
|
+
dy: number;
|
|
194
|
+
} | {
|
|
195
|
+
kind: 'key';
|
|
196
|
+
keysym: number;
|
|
197
|
+
down: boolean;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* The sign-in a desktop asks for, in one form: the account and the password of the Screen Sharing of macOS
|
|
201
|
+
* (`account`), or the password of VNC alone.
|
|
202
|
+
*/
|
|
203
|
+
export interface TaDesktopPrompt {
|
|
204
|
+
promptId: string;
|
|
205
|
+
desktop: string;
|
|
206
|
+
/** The name of the desktop, for the form. */
|
|
207
|
+
name: string;
|
|
208
|
+
/** It wants an account too (Apple Remote Desktop): the user of the Mac, as they sign in to it. */
|
|
209
|
+
account: boolean;
|
|
210
|
+
/** The account to put in the field: the user of this computer, or the one given last. */
|
|
211
|
+
user?: string;
|
|
212
|
+
/** The desktop refused the one given last (or kept): it is asked again. */
|
|
213
|
+
refused?: boolean;
|
|
214
|
+
/** A password the vault may keep for the next time (answerDesktop's `remember`): there when a package keeps sign-ins. */
|
|
215
|
+
remember?: boolean;
|
|
216
|
+
}
|
|
217
|
+
/** What a page answers a prompt with. */
|
|
218
|
+
export interface TaDesktopSignIn {
|
|
219
|
+
username?: string;
|
|
220
|
+
password: string;
|
|
221
|
+
}
|
|
222
|
+
export type TaDesktopEvent = {
|
|
223
|
+
type: 'prompt';
|
|
224
|
+
prompt: TaDesktopPrompt;
|
|
225
|
+
} | {
|
|
226
|
+
type: 'prompt_closed';
|
|
227
|
+
promptId: string;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The desktops of other computers, seen and worked from a page (docs/design/ta-desktop-remote.md 5): the connection
|
|
231
|
+
* is ta serve's, through the ExecEnvironment of the machine it goes from; a page only gets pictures and sends input.
|
|
232
|
+
*/
|
|
233
|
+
export interface TaScreenShareServer {
|
|
234
|
+
/** This computer, the hosts of ssh directories and the desktops added, and who looks at and works each. */
|
|
235
|
+
listDesktops(): Promise<TaDesktopInfo[]>;
|
|
236
|
+
/** The screens of a desktop, connecting to it when no page does. */
|
|
237
|
+
listDesktopScreens(target: TaDesktopTarget): Promise<TaDesktopScreen[]>;
|
|
238
|
+
/** Adds a desktop of a VNC server a computer reaches at host:port (through `via`). */
|
|
239
|
+
addDesktop(target: TaDesktopTarget): Promise<TaDesktopInfo>;
|
|
240
|
+
removeDesktop(desktopId: string): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Starts looking at a desktop, connecting to it when no page does. The same `clientMessageId` (the page computes it
|
|
243
|
+
* from itself and the desktop) gives the same viewer while it lives. `device`: what the page is on.
|
|
244
|
+
*/
|
|
245
|
+
openDesktop(options: {
|
|
246
|
+
target: TaDesktopTarget;
|
|
247
|
+
view: TaDesktopView;
|
|
248
|
+
clientMessageId: string;
|
|
249
|
+
device?: string;
|
|
250
|
+
}): Promise<TaDesktopViewer>;
|
|
251
|
+
closeDesktop(viewerId: string): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Claims frame `want` (docs/design/ta-desktop-remote.md 5.4): kept, it comes again; the next waits for a change;
|
|
254
|
+
* one beyond waits for the one before; one dropped or beyond built + 4 is `stale`; 10 s without change `idle`; a
|
|
255
|
+
* viewer gone `unknown`. The same (viewerId, want) always gets the same answer.
|
|
256
|
+
*/
|
|
257
|
+
readDesktopFrames(viewerId: string, want: number): Promise<TaDesktopFrames>;
|
|
258
|
+
setDesktopView(viewerId: string, view: TaDesktopView): Promise<void>;
|
|
259
|
+
/** Input of the viewer in control; `seq`, larger each batch, is taken once. */
|
|
260
|
+
sendDesktopInput(viewerId: string, batch: {
|
|
261
|
+
seq: number;
|
|
262
|
+
events: TaDesktopInput[];
|
|
263
|
+
}): Promise<void>;
|
|
264
|
+
/** Puts text into the clipboard of the desktop, taken once by its id; `press` then presses the keys that paste. */
|
|
265
|
+
pasteToDesktop(viewerId: string, input: {
|
|
266
|
+
text: string;
|
|
267
|
+
press?: boolean;
|
|
268
|
+
clientMessageId: string;
|
|
269
|
+
}): Promise<void>;
|
|
270
|
+
/** The text of the clipboard of the desktop: none in the first stage. */
|
|
271
|
+
readDesktopClipboard(viewerId: string): Promise<string | undefined>;
|
|
272
|
+
/** Takes control: a page of the owner at once (`asked` false). */
|
|
273
|
+
takeDesktopControl(viewerId: string): Promise<{
|
|
274
|
+
control: TaDesktopControl | null;
|
|
275
|
+
asked: boolean;
|
|
276
|
+
}>;
|
|
277
|
+
releaseDesktopControl(viewerId: string): Promise<void>;
|
|
278
|
+
/** Ends every viewer of every desktop, at once. */
|
|
279
|
+
endAllDesktops(): Promise<void>;
|
|
280
|
+
/** Prompts open now; later ones come by TaClient.onScreenShareEvent. */
|
|
281
|
+
watchDesktops(): Promise<TaDesktopPrompt[]>;
|
|
282
|
+
/**
|
|
283
|
+
* Answers a prompt; null cancels. The first answer counts. `remember` on a password a prompt offers to keep
|
|
284
|
+
* (TaDesktopPrompt.remember): kept once the desktop took it, and given by itself from then on.
|
|
285
|
+
*/
|
|
286
|
+
answerDesktop(promptId: string, answer: TaDesktopSignIn | null, remember?: boolean): Promise<boolean>;
|
|
287
|
+
}
|
|
288
|
+
export declare namespace TaDesktopUtil {
|
|
289
|
+
const DEFAULT_PORT = 5900;
|
|
290
|
+
/** `<via>|<host>:<port>`: one id for one desktop however it is written, its name aside. */
|
|
291
|
+
function id(target: TaDesktopTarget): string;
|
|
292
|
+
function host(target: TaDesktopTarget): string;
|
|
293
|
+
function port(target: TaDesktopTarget): number;
|
|
294
|
+
/** The target of an id, undefined for one that is none. */
|
|
295
|
+
function parse(id: string): TaDesktopTarget | undefined;
|
|
296
|
+
/** VNC ports of a display (5900 + n) and others a server may listen on; never one of a well-known service. */
|
|
297
|
+
function validPort(port: unknown): port is number;
|
|
298
|
+
/** A host name or an IP address, nothing a shell or a URL could read as more. */
|
|
299
|
+
/** A host of this machine's loopback. */
|
|
300
|
+
function loopback(host: string): boolean;
|
|
301
|
+
function validHost(host: unknown): host is string;
|
|
302
|
+
}
|
|
303
|
+
/** X11 keysyms of the keys a page sends by name (KeyboardEvent.key); a character is its code point (Latin-1) or 0x01000000 + it. */
|
|
304
|
+
export declare const TA_DESKTOP_KEYSYMS: Readonly<Record<string, number>>;
|
|
305
|
+
//# sourceMappingURL=screen-share-protocol.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TA_DESKTOP_KEYSYMS = exports.TaDesktopUtil = exports.TA_DESKTOP_LOCKED_MESSAGE = exports.TA_SCREEN_SHARE_SERVICE = exports.TaScreenShareServer = void 0;
|
|
4
|
+
exports.TaScreenShareServer = Symbol('TaScreenShareServer');
|
|
5
|
+
exports.TA_SCREEN_SHARE_SERVICE = 'TaScreenShareServer';
|
|
6
|
+
/**
|
|
7
|
+
* What a call refused for a remote desktop says, in English: the kernel and ta-team say it the same
|
|
8
|
+
* (docs/design/ta-desktop-remote.md 6.7).
|
|
9
|
+
*/
|
|
10
|
+
exports.TA_DESKTOP_LOCKED_MESSAGE = 'Not while someone else works a desktop of this Ta.';
|
|
11
|
+
var TaDesktopUtil;
|
|
12
|
+
(function (TaDesktopUtil) {
|
|
13
|
+
TaDesktopUtil.DEFAULT_PORT = 5900;
|
|
14
|
+
/** `<via>|<host>:<port>`: one id for one desktop however it is written, its name aside. */
|
|
15
|
+
function id(target) {
|
|
16
|
+
var _a;
|
|
17
|
+
return `${(_a = target.via) !== null && _a !== void 0 ? _a : ''}|${host(target)}:${port(target)}`;
|
|
18
|
+
}
|
|
19
|
+
TaDesktopUtil.id = id;
|
|
20
|
+
function host(target) {
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = target.host) !== null && _a !== void 0 ? _a : '').trim() || '127.0.0.1';
|
|
23
|
+
}
|
|
24
|
+
TaDesktopUtil.host = host;
|
|
25
|
+
function port(target) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = target.port) !== null && _a !== void 0 ? _a : TaDesktopUtil.DEFAULT_PORT;
|
|
28
|
+
}
|
|
29
|
+
TaDesktopUtil.port = port;
|
|
30
|
+
/** The target of an id, undefined for one that is none. */
|
|
31
|
+
function parse(id) {
|
|
32
|
+
const match = /^([^|]*)\|(.+):(\d+)$/.exec(String(id !== null && id !== void 0 ? id : ''));
|
|
33
|
+
if (!match) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const port = Number(match[3]);
|
|
37
|
+
return port > 0 && port < 65536 ? { via: match[1], host: match[2], port } : undefined;
|
|
38
|
+
}
|
|
39
|
+
TaDesktopUtil.parse = parse;
|
|
40
|
+
/** VNC ports of a display (5900 + n) and others a server may listen on; never one of a well-known service. */
|
|
41
|
+
function validPort(port) {
|
|
42
|
+
return typeof port === 'number' && Number.isInteger(port) && port >= 1024 && port < 65536;
|
|
43
|
+
}
|
|
44
|
+
TaDesktopUtil.validPort = validPort;
|
|
45
|
+
/** A host name or an IP address, nothing a shell or a URL could read as more. */
|
|
46
|
+
/** A host of this machine's loopback. */
|
|
47
|
+
function loopback(host) {
|
|
48
|
+
return /^(127\.\d+\.\d+\.\d+|localhost|::1|\[::1\])$/i.test(host);
|
|
49
|
+
}
|
|
50
|
+
TaDesktopUtil.loopback = loopback;
|
|
51
|
+
function validHost(host) {
|
|
52
|
+
return typeof host === 'string' && /^[A-Za-z0-9.:\-[\]]{1,253}$/.test(host);
|
|
53
|
+
}
|
|
54
|
+
TaDesktopUtil.validHost = validHost;
|
|
55
|
+
})(TaDesktopUtil || (exports.TaDesktopUtil = TaDesktopUtil = {}));
|
|
56
|
+
/** X11 keysyms of the keys a page sends by name (KeyboardEvent.key); a character is its code point (Latin-1) or 0x01000000 + it. */
|
|
57
|
+
exports.TA_DESKTOP_KEYSYMS = {
|
|
58
|
+
Backspace: 0xff08,
|
|
59
|
+
Tab: 0xff09,
|
|
60
|
+
Enter: 0xff0d,
|
|
61
|
+
Escape: 0xff1b,
|
|
62
|
+
Delete: 0xffff,
|
|
63
|
+
Home: 0xff50,
|
|
64
|
+
ArrowLeft: 0xff51,
|
|
65
|
+
ArrowUp: 0xff52,
|
|
66
|
+
ArrowRight: 0xff53,
|
|
67
|
+
ArrowDown: 0xff54,
|
|
68
|
+
PageUp: 0xff55,
|
|
69
|
+
PageDown: 0xff56,
|
|
70
|
+
End: 0xff57,
|
|
71
|
+
Insert: 0xff63,
|
|
72
|
+
F1: 0xffbe,
|
|
73
|
+
F2: 0xffbf,
|
|
74
|
+
F3: 0xffc0,
|
|
75
|
+
F4: 0xffc1,
|
|
76
|
+
F5: 0xffc2,
|
|
77
|
+
F6: 0xffc3,
|
|
78
|
+
F7: 0xffc4,
|
|
79
|
+
F8: 0xffc5,
|
|
80
|
+
F9: 0xffc6,
|
|
81
|
+
F10: 0xffc7,
|
|
82
|
+
F11: 0xffc8,
|
|
83
|
+
F12: 0xffc9,
|
|
84
|
+
Shift: 0xffe1,
|
|
85
|
+
Control: 0xffe3,
|
|
86
|
+
Meta: 0xffe7,
|
|
87
|
+
Alt: 0xffe9,
|
|
88
|
+
Super: 0xffeb,
|
|
89
|
+
CapsLock: 0xffe5,
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=screen-share-protocol.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const TaSettingsServer: unique symbol;
|
|
2
2
|
export declare const TA_SETTINGS_SERVICE = "TaSettingsServer";
|
|
3
|
+
/** The api of the models of other coding agents (ta-agents) begins so: `acp-<agent id>`. */
|
|
4
|
+
export declare const TA_AGENT_API_PREFIX = "acp-";
|
|
3
5
|
/** Where a setting of ta is kept: pi's `settings.json` of the user (the agent directory), or of a project (`.ta/` of its directory), which wins. */
|
|
4
6
|
export type TaSettingsScope = 'user' | 'project';
|
|
5
7
|
/** A setting of ta that clients show and change; the key is its path in pi's `settings.json`. */
|
|
@@ -28,6 +30,12 @@ export interface TaSettingsSnapshot {
|
|
|
28
30
|
projectTrusted: boolean;
|
|
29
31
|
/** `<provider>/<model id>` of the models with credentials, for the model setting. */
|
|
30
32
|
models: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Those of `models` that are other coding agents (ta-agents, their api `TA_AGENT_API_PREFIX`…): they work with
|
|
35
|
+
* their own tools, so they cannot run a conversation that may use only some of Ta's (a call's front, a turn for
|
|
36
|
+
* others in a room).
|
|
37
|
+
*/
|
|
38
|
+
agents?: string[];
|
|
31
39
|
/** The names of those of `models` that have one other than their id. */
|
|
32
40
|
modelNames?: Record<string, string>;
|
|
33
41
|
/** By id, the names of the providers of `models` (`Kimi For Coding` for `kimi-coding`), as the lists of models group them. */
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TA_SETTINGS = exports.TA_SETTINGS_SERVICE = exports.TaSettingsServer = void 0;
|
|
3
|
+
exports.TA_SETTINGS = exports.TA_AGENT_API_PREFIX = exports.TA_SETTINGS_SERVICE = exports.TaSettingsServer = void 0;
|
|
4
4
|
exports.TaSettingsServer = Symbol('TaSettingsServer');
|
|
5
5
|
exports.TA_SETTINGS_SERVICE = 'TaSettingsServer';
|
|
6
|
+
/** The api of the models of other coding agents (ta-agents) begins so: `acp-<agent id>`. */
|
|
7
|
+
exports.TA_AGENT_API_PREFIX = 'acp-';
|
|
6
8
|
/** The settings of ta that clients change, as pi names them; other keys of the files are left as they are. */
|
|
7
9
|
exports.TA_SETTINGS = [
|
|
8
10
|
{ key: 'model', type: 'model' },
|