@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
|
@@ -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. */
|
|
@@ -99,6 +101,33 @@ export interface TaFriendRequest {
|
|
|
99
101
|
via: 'link' | 'room';
|
|
100
102
|
room?: string;
|
|
101
103
|
}
|
|
104
|
+
/** A group chat a friend invited the user into (TaRoomServer.listGroupInvites): theirs to join or not. */
|
|
105
|
+
export interface TaGroupInvite {
|
|
106
|
+
/** The id of the room. */
|
|
107
|
+
room: string;
|
|
108
|
+
title: string;
|
|
109
|
+
by: {
|
|
110
|
+
id: string;
|
|
111
|
+
name: string;
|
|
112
|
+
look?: string;
|
|
113
|
+
};
|
|
114
|
+
at: number;
|
|
115
|
+
expiresAt: number;
|
|
116
|
+
}
|
|
117
|
+
/** A link a friend sent the user from the share sheet (TaRoomServer.listFriendShares): opened as every link of Ta is. */
|
|
118
|
+
export interface TaFriendShare {
|
|
119
|
+
id: string;
|
|
120
|
+
link: string;
|
|
121
|
+
title: string;
|
|
122
|
+
by: {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
look?: string;
|
|
126
|
+
};
|
|
127
|
+
at: number;
|
|
128
|
+
/** The user opened it once. */
|
|
129
|
+
seen: boolean;
|
|
130
|
+
}
|
|
102
131
|
/**
|
|
103
132
|
* The kind of a Ta's room of friends: unlisted, its members the friends. Features that give friends something keep it
|
|
104
133
|
* in this room (Moments its posts, `post:` and the like); `back:` is the rooms' own.
|
|
@@ -155,7 +184,7 @@ export interface TaRoomServer {
|
|
|
155
184
|
}): Promise<TaRoomInfo>;
|
|
156
185
|
/**
|
|
157
186
|
* 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,
|
|
187
|
+
* a new one for `days` (7 by default, 365 at most), and the links of before stop working.
|
|
159
188
|
*/
|
|
160
189
|
invite(room: string, options?: {
|
|
161
190
|
days?: number;
|
|
@@ -164,6 +193,10 @@ export interface TaRoomServer {
|
|
|
164
193
|
link: string;
|
|
165
194
|
expiresAt: number;
|
|
166
195
|
}>;
|
|
196
|
+
/** The owner's choices for a room: the members it lets in at most (16 by default, 2 to 100); those in already stay. */
|
|
197
|
+
configureRoom(room: string, options: {
|
|
198
|
+
members?: number;
|
|
199
|
+
}): Promise<TaRoomInfo>;
|
|
167
200
|
/** Asks to join the room of a link: `waiting` till its owner answers. Ask the user first. */
|
|
168
201
|
join(link: string): Promise<TaRoomInfo>;
|
|
169
202
|
/** Those asking to join the rooms of this Ta. */
|
|
@@ -197,6 +230,24 @@ export interface TaRoomServer {
|
|
|
197
230
|
addFriend(link: string): Promise<void>;
|
|
198
231
|
/** Asks a member of a room the user is in to be friends (its member id). Ask the user first. */
|
|
199
232
|
offerFriend(room: string, member: string): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Invites friends (their identity ids) into a group chat of the user's own: each finds it in their Ta, and is let in
|
|
235
|
+
* at once once they join; no one else is. How many were invited. Ask the user first. Newer than some Ta services.
|
|
236
|
+
*/
|
|
237
|
+
inviteFriends(room: string, friends: string[]): Promise<number>;
|
|
238
|
+
/** The group chats friends invited the user into, not joined nor turned down. */
|
|
239
|
+
listGroupInvites(): Promise<TaGroupInvite[]>;
|
|
240
|
+
/** Sends a link of Ta to friends, sealed for each (docs/design/ta-links.md 4): how many it went to. */
|
|
241
|
+
sendToFriends(friends: string[], item: {
|
|
242
|
+
link: string;
|
|
243
|
+
title: string;
|
|
244
|
+
}): Promise<number>;
|
|
245
|
+
/** What friends sent the user, the latest first. */
|
|
246
|
+
listFriendShares(): Promise<TaFriendShare[]>;
|
|
247
|
+
/** The user opened one (`keep`), or let it go. */
|
|
248
|
+
answerFriendShare(id: string, keep: boolean): Promise<void>;
|
|
249
|
+
/** The user's answer to an invitation into a group chat (its room id). Only ever on the user's word. */
|
|
250
|
+
answerGroupInvite(room: string, accept: boolean): Promise<void>;
|
|
200
251
|
/** Those asking the user to be friends. */
|
|
201
252
|
listFriendRequests(): Promise<TaFriendRequest[]>;
|
|
202
253
|
/** The user's answer to one asking to be friends (its identity id). Only ever on the user's word, never on an agent's. */
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** How {@link TaSaid.words} reads a message. */
|
|
2
|
+
export interface TaSaidOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Keep the fenced blocks of Ta's languages (`ta-glance`, `ta-plot`…), which Ta's pages draw as cards (the
|
|
5
|
+
* default); false where nothing draws them, as the chat of a bot.
|
|
6
|
+
*/
|
|
7
|
+
cards?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** How long {@link TaSaid.line} is. */
|
|
10
|
+
export interface TaSaidLineOptions {
|
|
11
|
+
/** At most so many characters, an ellipsis where it is cut. */
|
|
12
|
+
chars: number;
|
|
13
|
+
/** At most so many lines, each a line of its own; 1, the default, joins them all on one line. */
|
|
14
|
+
lines?: number;
|
|
15
|
+
}
|
|
16
|
+
/** A message with a mark of the model in it, as it comes (TaSaid.SAMPLES). */
|
|
17
|
+
export interface TaSaidSample {
|
|
18
|
+
/** The mark, in a few words. */
|
|
19
|
+
mark: string;
|
|
20
|
+
role: 'user' | 'assistant';
|
|
21
|
+
text: string;
|
|
22
|
+
/** Words a person reads of it, in what words and line give; none when nothing of it is for a person. */
|
|
23
|
+
said?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What a person reads of a message (docs/design/ta-said.md). The text of pi's messages holds marks that are for the
|
|
27
|
+
* model or for a program, not for people: the `<context>` of a message of the user and the line of where it came
|
|
28
|
+
* from in it, pi's notes of images, the `<skill>` block of `/skill:name`, the notes of the double's tasks, the summary
|
|
29
|
+
* an external agent compacts its context to, and fenced blocks of Ta's languages, which a page draws as cards or
|
|
30
|
+
* leaves out. Every place that shows people what was said (a list, a notice, a link shared, a bot's chat, a copy, a
|
|
31
|
+
* voice) reads it here, never the text itself, and never strips a mark of its own: a new mark is added to
|
|
32
|
+
* message-protocol.ts, to words and to SAMPLES, and every place is right at once. The specs of those places run
|
|
33
|
+
* SAMPLES through them and check with leaks that nothing of the model is left.
|
|
34
|
+
*/
|
|
35
|
+
export declare namespace TaSaid {
|
|
36
|
+
/** The text of the content of a message of pi: its text parts, joined by `joiner`. */
|
|
37
|
+
function text(content: unknown, joiner?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* What a person reads of the text of a message, as Markdown, empty when nothing of it is for a person. Of the
|
|
40
|
+
* user's, what they typed: without the context for the model and pi's notes of its images, a skill they ran as
|
|
41
|
+
* `/skill:name` and what follows, a note of the double's tasks as the task (its title, and how it ended), none of a
|
|
42
|
+
* note of a new id. Of the agent's, without the summary it compacted its context to (empty while only its tags
|
|
43
|
+
* have come). A line that is a tag alone, outside code, is left out too; `cards: false` also leaves out the
|
|
44
|
+
* fenced blocks of Ta's languages.
|
|
45
|
+
*/
|
|
46
|
+
function words(role: string | undefined, text: string, options?: TaSaidOptions): string;
|
|
47
|
+
/** {@link words} of a message of pi. */
|
|
48
|
+
function of(message: {
|
|
49
|
+
role?: string;
|
|
50
|
+
content?: unknown;
|
|
51
|
+
} | undefined, options?: TaSaidOptions): string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a message is a notice of a part of Ta, not the user's (TaMessageSource.notice): a page shows it as a line
|
|
54
|
+
* of its own, not as their bubble, and a list neither titles a conversation by it nor shows it as what was said last.
|
|
55
|
+
*/
|
|
56
|
+
function notice(message: {
|
|
57
|
+
role?: string;
|
|
58
|
+
content?: unknown;
|
|
59
|
+
} | undefined): boolean;
|
|
60
|
+
/** Whether a text that says something holds marks only: a message that is no words for a person (the summary alone). */
|
|
61
|
+
function marksOnly(role: string | undefined, text: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Markdown as the plain words of a preview, as a messenger shows the last thing said: without fenced blocks (the
|
|
64
|
+
* code of one when there is nothing else, never a block of Ta's languages), the marks of Markdown at the start
|
|
65
|
+
* of lines and around words, a line that is a tag alone, links by their words, pictures by the words that name
|
|
66
|
+
* them in a message of pictures only.
|
|
67
|
+
*/
|
|
68
|
+
function line(markdown: string, options: TaSaidLineOptions): string;
|
|
69
|
+
/**
|
|
70
|
+
* The marks of the model a text shown to a person still holds, by name: none is right. For the specs of the
|
|
71
|
+
* places that show what was said; `cards: true` where Ta's pages draw the blocks of its languages.
|
|
72
|
+
*/
|
|
73
|
+
function leaks(shown: string, options?: TaSaidOptions): string[];
|
|
74
|
+
/** A message with each mark, as it comes: what the specs of every place that shows what was said run through it. */
|
|
75
|
+
const SAMPLES: readonly TaSaidSample[];
|
|
76
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { TaAgentSummary, TaImageNote, TaMessageContext, TaMessageSource, TaSkillUse, TaTaskNote } from './message-protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a person reads of a message (docs/design/ta-said.md). The text of pi's messages holds marks that are for the
|
|
4
|
+
* model or for a program, not for people: the `<context>` of a message of the user and the line of where it came
|
|
5
|
+
* from in it, pi's notes of images, the `<skill>` block of `/skill:name`, the notes of the double's tasks, the summary
|
|
6
|
+
* an external agent compacts its context to, and fenced blocks of Ta's languages, which a page draws as cards or
|
|
7
|
+
* leaves out. Every place that shows people what was said (a list, a notice, a link shared, a bot's chat, a copy, a
|
|
8
|
+
* voice) reads it here, never the text itself, and never strips a mark of its own: a new mark is added to
|
|
9
|
+
* message-protocol.ts, to words and to SAMPLES, and every place is right at once. The specs of those places run
|
|
10
|
+
* SAMPLES through them and check with leaks that nothing of the model is left.
|
|
11
|
+
*/
|
|
12
|
+
export var TaSaid;
|
|
13
|
+
(function (TaSaid) {
|
|
14
|
+
/** Fenced blocks of these languages are Ta's (cards, proposals, what a call says aloud): drawn or left out, never read as text. */
|
|
15
|
+
const CARD = /^ta-/i;
|
|
16
|
+
/** Of a long message, a preview reads so much: enough for its first lines. */
|
|
17
|
+
const READ = 4000;
|
|
18
|
+
const FENCE = /^\s*(`{3,}|~{3,})\s*([^\s`]*)/;
|
|
19
|
+
/** A line that is a tag alone (`<summary>`, `</context>`): a mark of a program, never words, even one not known yet. */
|
|
20
|
+
const TAG_LINE = /^<\/?[A-Za-z][\w:.-]*(?:\s[^<>]*)?\/?>$/;
|
|
21
|
+
/** A line of marks only: a rule, the head of a table. */
|
|
22
|
+
const MARKS_ONLY = /^[-*_=|:+\s]+$/;
|
|
23
|
+
/** The marks of the model that leaks finds, each by a name. */
|
|
24
|
+
const MARKS = [
|
|
25
|
+
['context', /<\/?context>/],
|
|
26
|
+
['source', /\[ta:(?:from|notice|by) /],
|
|
27
|
+
['image note', /\[Image: original \d+x\d+|\[Image converted from /],
|
|
28
|
+
['skill', /<skill name="|<\/skill>/],
|
|
29
|
+
['task note', /<\/?task_(?:update|adopted|renamed)\b/],
|
|
30
|
+
['summary', /<\/?(?:conversation_history_summary|summary)>/],
|
|
31
|
+
];
|
|
32
|
+
/** The text of the content of a message of pi: its text parts, joined by `joiner`. */
|
|
33
|
+
function text(content, joiner = '\n') {
|
|
34
|
+
if (typeof content === 'string') {
|
|
35
|
+
return content;
|
|
36
|
+
}
|
|
37
|
+
return Array.isArray(content)
|
|
38
|
+
? content
|
|
39
|
+
.filter((part) => (part === null || part === void 0 ? void 0 : part.type) === 'text' && typeof part.text === 'string')
|
|
40
|
+
.map(part => part.text)
|
|
41
|
+
.join(joiner)
|
|
42
|
+
: '';
|
|
43
|
+
}
|
|
44
|
+
TaSaid.text = text;
|
|
45
|
+
/**
|
|
46
|
+
* What a person reads of the text of a message, as Markdown, empty when nothing of it is for a person. Of the
|
|
47
|
+
* user's, what they typed: without the context for the model and pi's notes of its images, a skill they ran as
|
|
48
|
+
* `/skill:name` and what follows, a note of the double's tasks as the task (its title, and how it ended), none of a
|
|
49
|
+
* note of a new id. Of the agent's, without the summary it compacted its context to (empty while only its tags
|
|
50
|
+
* have come). A line that is a tag alone, outside code, is left out too; `cards: false` also leaves out the
|
|
51
|
+
* fenced blocks of Ta's languages.
|
|
52
|
+
*/
|
|
53
|
+
function words(role, text, options = {}) {
|
|
54
|
+
const said = role === 'user' ? userWords(text) : TaAgentSummary.strip(text);
|
|
55
|
+
return withoutFences(said, language => options.cards === false && CARD.test(language), true).trim();
|
|
56
|
+
}
|
|
57
|
+
TaSaid.words = words;
|
|
58
|
+
/** {@link words} of a message of pi. */
|
|
59
|
+
function of(message, options) {
|
|
60
|
+
return message ? words(message.role, text(message.content), options) : '';
|
|
61
|
+
}
|
|
62
|
+
TaSaid.of = of;
|
|
63
|
+
/**
|
|
64
|
+
* Whether a message is a notice of a part of Ta, not the user's (TaMessageSource.notice): a page shows it as a line
|
|
65
|
+
* of its own, not as their bubble, and a list neither titles a conversation by it nor shows it as what was said last.
|
|
66
|
+
*/
|
|
67
|
+
function notice(message) {
|
|
68
|
+
return (message === null || message === void 0 ? void 0 : message.role) === 'user' && TaMessageSource.isNotice(text(message.content));
|
|
69
|
+
}
|
|
70
|
+
TaSaid.notice = notice;
|
|
71
|
+
/** Whether a text that says something holds marks only: a message that is no words for a person (the summary alone). */
|
|
72
|
+
function marksOnly(role, text) {
|
|
73
|
+
return !!text.trim() && !line(words(role, text), { chars: Number.POSITIVE_INFINITY });
|
|
74
|
+
}
|
|
75
|
+
TaSaid.marksOnly = marksOnly;
|
|
76
|
+
/**
|
|
77
|
+
* Markdown as the plain words of a preview, as a messenger shows the last thing said: without fenced blocks (the
|
|
78
|
+
* code of one when there is nothing else, never a block of Ta's languages), the marks of Markdown at the start
|
|
79
|
+
* of lines and around words, a line that is a tag alone, links by their words, pictures by the words that name
|
|
80
|
+
* them in a message of pictures only.
|
|
81
|
+
*/
|
|
82
|
+
function line(markdown, options) {
|
|
83
|
+
var _a;
|
|
84
|
+
const read = markdown.slice(0, READ);
|
|
85
|
+
const prose = withoutFences(read, () => true, true).trim();
|
|
86
|
+
const lines = plain(prose || codeOf(read))
|
|
87
|
+
.split('\n')
|
|
88
|
+
.map(part => part
|
|
89
|
+
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/, '')
|
|
90
|
+
.replace(/\*{1,3}|`+|~~|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, '')
|
|
91
|
+
.replace(/\s+/g, ' ')
|
|
92
|
+
.trim())
|
|
93
|
+
.filter(part => part && !MARKS_ONLY.test(part) && !TAG_LINE.test(part));
|
|
94
|
+
const count = (_a = options.lines) !== null && _a !== void 0 ? _a : 1;
|
|
95
|
+
const joined = count <= 1 ? lines.join(' ') : lines.slice(0, count).join('\n');
|
|
96
|
+
return joined.length > options.chars ? `${joined.slice(0, Math.max(0, options.chars - 1)).trimEnd()}…` : joined;
|
|
97
|
+
}
|
|
98
|
+
TaSaid.line = line;
|
|
99
|
+
/**
|
|
100
|
+
* The marks of the model a text shown to a person still holds, by name: none is right. For the specs of the
|
|
101
|
+
* places that show what was said; `cards: true` where Ta's pages draw the blocks of its languages.
|
|
102
|
+
*/
|
|
103
|
+
function leaks(shown, options = {}) {
|
|
104
|
+
const found = MARKS.filter(([, mark]) => mark.test(shown)).map(([name]) => name);
|
|
105
|
+
const lines = shown.split('\n');
|
|
106
|
+
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 : ''); })) {
|
|
107
|
+
found.push('card');
|
|
108
|
+
}
|
|
109
|
+
if (lines.some(part => TAG_LINE.test(part.trim()))) {
|
|
110
|
+
found.push('tag');
|
|
111
|
+
}
|
|
112
|
+
return found;
|
|
113
|
+
}
|
|
114
|
+
TaSaid.leaks = leaks;
|
|
115
|
+
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>';
|
|
116
|
+
/** A message with each mark, as it comes: what the specs of every place that shows what was said run through it. */
|
|
117
|
+
TaSaid.SAMPLES = [
|
|
118
|
+
{
|
|
119
|
+
mark: 'context and where it came from',
|
|
120
|
+
role: 'user',
|
|
121
|
+
text: '<context>\nThe channel #ops, its members.\n[ta:from @celljs/ta-channels #ops]\n</context>\nCheck the build',
|
|
122
|
+
said: 'Check the build',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
mark: 'a notice, not the user',
|
|
126
|
+
role: 'user',
|
|
127
|
+
text: '<context>\n[ta:notice @celljs/ta-call]\n</context>\nThe work finished. Its last words: tests pass.',
|
|
128
|
+
said: 'The work finished. Its last words: tests pass.',
|
|
129
|
+
},
|
|
130
|
+
{ mark: 'one let in', role: 'user', text: '<context>\n[ta:by p-7 Alice]\n</context>\nHello there', said: 'Hello there' },
|
|
131
|
+
{
|
|
132
|
+
mark: 'notes of images',
|
|
133
|
+
role: 'user',
|
|
134
|
+
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.]',
|
|
135
|
+
said: 'Look at this',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
mark: 'a skill run',
|
|
139
|
+
role: 'user',
|
|
140
|
+
text: '<skill name="ta-package" location="/skills/ta-package/SKILL.md">\n# Ta package\nSteps.\n</skill>\n\nMake a card',
|
|
141
|
+
said: 'Make a card',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
mark: 'a note of a task',
|
|
145
|
+
role: 'user',
|
|
146
|
+
text: '<task_update id="t1" title="Fix login" status="done">\nAll tests pass.\n</task_update>',
|
|
147
|
+
said: 'Fix login',
|
|
148
|
+
},
|
|
149
|
+
{ mark: 'a note of a new id', role: 'user', text: '<task_renamed id="t2" was="t1" title="Fix login">\nNow t2.\n</task_renamed>' },
|
|
150
|
+
{ mark: 'a summary, then the answer', role: 'assistant', text: `${SUMMARY}\nSwitched to voice.`, said: 'Switched to voice.' },
|
|
151
|
+
{ mark: 'a summary alone', role: 'assistant', text: SUMMARY },
|
|
152
|
+
{ mark: 'a summary as it streams', role: 'assistant', text: '<conversation_history_summary>\n<summary>' },
|
|
153
|
+
{
|
|
154
|
+
mark: 'a card after the answer',
|
|
155
|
+
role: 'assistant',
|
|
156
|
+
text: '**Done**: tests pass.\n\n```ta-glance\n{"status":"done","blocks":[]}\n```',
|
|
157
|
+
said: 'tests pass',
|
|
158
|
+
},
|
|
159
|
+
{ mark: 'a card alone', role: 'assistant', text: '```ta-glance\n{"status":"done","blocks":[]}\n```' },
|
|
160
|
+
{ mark: 'a proposal', role: 'assistant', text: 'Committed.\n\n```ta-propose\n{"kind":"git.push","title":"Push"}\n```', said: 'Committed.' },
|
|
161
|
+
{ mark: 'what a call says aloud', role: 'assistant', text: 'All fixed.\n\n```ta-say\nIt is fixed.\n```', said: 'All fixed.' },
|
|
162
|
+
{ mark: 'a tag not known yet', role: 'assistant', text: '<system-reminder>\n</system-reminder>\nReady.', said: 'Ready.' },
|
|
163
|
+
];
|
|
164
|
+
function userWords(text) {
|
|
165
|
+
const said = TaImageNote.strip(TaMessageContext.strip(text));
|
|
166
|
+
const skill = TaSkillUse.parse(said);
|
|
167
|
+
if (skill) {
|
|
168
|
+
return TaSkillUse.command(skill);
|
|
169
|
+
}
|
|
170
|
+
const note = TaTaskNote.parse(said);
|
|
171
|
+
if (!note) {
|
|
172
|
+
return said;
|
|
173
|
+
}
|
|
174
|
+
if (note.kind === 'renamed') {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
return note.kind === 'update' && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The text without the fenced blocks whose language `drop` names (one not closed runs to the end, as it streams),
|
|
181
|
+
* and with `tags` without the lines outside them that are a tag alone.
|
|
182
|
+
*/
|
|
183
|
+
function withoutFences(text, drop, tags = false) {
|
|
184
|
+
const kept = [];
|
|
185
|
+
let fence;
|
|
186
|
+
let left = false;
|
|
187
|
+
for (const part of text.split('\n')) {
|
|
188
|
+
const open = FENCE.exec(part);
|
|
189
|
+
if (!fence && open) {
|
|
190
|
+
fence = { mark: open[1], dropped: drop(open[2]) };
|
|
191
|
+
}
|
|
192
|
+
else if (fence && closes(part, fence.mark)) {
|
|
193
|
+
const dropped = fence.dropped;
|
|
194
|
+
fence = undefined;
|
|
195
|
+
if (dropped) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if ((fence === null || fence === void 0 ? void 0 : fence.dropped) || (!fence && tags && TAG_LINE.test(part.trim()))) {
|
|
200
|
+
left = true;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
kept.push(part);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// What was left out leaves no gap of its own.
|
|
207
|
+
return left ? kept.join('\n').replace(/\n{3,}/g, '\n\n') : kept.join('\n');
|
|
208
|
+
}
|
|
209
|
+
/** The code of the fenced blocks of `text` that are not Ta's. */
|
|
210
|
+
function codeOf(text) {
|
|
211
|
+
const code = [];
|
|
212
|
+
let fence;
|
|
213
|
+
for (const part of text.split('\n')) {
|
|
214
|
+
const open = FENCE.exec(part);
|
|
215
|
+
if (!fence && open) {
|
|
216
|
+
fence = { mark: open[1], card: CARD.test(open[2]) };
|
|
217
|
+
}
|
|
218
|
+
else if (fence && closes(part, fence.mark)) {
|
|
219
|
+
fence = undefined;
|
|
220
|
+
}
|
|
221
|
+
else if (fence && !fence.card) {
|
|
222
|
+
code.push(part);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return code.join('\n');
|
|
226
|
+
}
|
|
227
|
+
function closes(part, mark) {
|
|
228
|
+
var _a;
|
|
229
|
+
const close = (_a = /^\s*(`{3,}|~{3,})\s*$/.exec(part)) === null || _a === void 0 ? void 0 : _a[1];
|
|
230
|
+
return !!close && close[0] === mark[0] && close.length >= mark.length;
|
|
231
|
+
}
|
|
232
|
+
/** 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. */
|
|
233
|
+
function plain(text) {
|
|
234
|
+
const linked = text.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
235
|
+
const words = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, '').trim();
|
|
236
|
+
return words || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
237
|
+
}
|
|
238
|
+
})(TaSaid || (TaSaid = {}));
|
|
239
|
+
//# sourceMappingURL=said-protocol.js.map
|