@celljs/ta-protocol 4.13.1 → 4.14.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.
@@ -56,8 +56,39 @@ export interface TaAccessInfo {
56
56
  requests: TaAccessRequest[];
57
57
  signIns: TaAccessSignIn[];
58
58
  }
59
+ /** The kinds of providers ta serve signs in with: GitHub, Google, WeChat (a website app), an OpenID Connect provider. */
60
+ export type TaSignInKind = 'github' | 'google' | 'wechat' | 'oidc';
61
+ /** A kind of provider as configured: its fields but the secret, which is only said to be there. */
62
+ export interface TaSignInSetup {
63
+ id: TaSignInKind;
64
+ name: string;
65
+ /** It has its id and its secret: it is offered. */
66
+ configured: boolean;
67
+ /** `env`: the environment of ta serve sets it, which this cannot change; `file`: sign-in.json of the agent directory. */
68
+ source?: 'env' | 'file';
69
+ /** `clientId` (`appId` for WeChat), and `url` (GitHub Enterprise), `issuer` and `name` (OpenID Connect). */
70
+ fields: Record<string, string>;
71
+ /** A secret is kept. */
72
+ secret: boolean;
73
+ }
74
+ /** The ways to sign in, to set them up (Settings, Access), and where providers send the browser back. */
75
+ export interface TaSignInConfig {
76
+ providers: TaSignInSetup[];
77
+ /** Register these with a provider: the page of joining by a link on the relay, ta serve's own when it has an address. */
78
+ callbacks: {
79
+ join?: string;
80
+ serve?: string;
81
+ };
82
+ }
59
83
  /** Who may reach this ta serve with an account, for whoever is in (with the token, or an account let in). */
60
84
  export interface TaAccessServer {
85
+ /** The ways to sign in as set up; only the owner. */
86
+ getSignInConfig(): Promise<TaSignInConfig>;
87
+ /**
88
+ * Sets up a kind of provider in sign-in.json, offered at once; `null` takes it out. An empty secret keeps the one kept.
89
+ * One the environment sets is not changed here.
90
+ */
91
+ setSignInProvider(id: TaSignInKind, fields: Record<string, string> | null): Promise<void>;
61
92
  getAccess(): Promise<TaAccessInfo>;
62
93
  /**
63
94
  * Where the browser goes to sign in with `provider` and let that account in at once: the owner, in with
@@ -4,6 +4,7 @@ export * from './gateway-protocol.js';
4
4
  export * from './location.js';
5
5
  export * from './package-protocol.js';
6
6
  export * from './pi-types.js';
7
+ export * from './presence-protocol.js';
7
8
  export * from './relay-protocol.js';
8
9
  export * from './remote-protocol.js';
9
10
  export * from './room-protocol.js';
@@ -4,6 +4,7 @@ export * from './gateway-protocol.js';
4
4
  export * from './location.js';
5
5
  export * from './package-protocol.js';
6
6
  export * from './pi-types.js';
7
+ export * from './presence-protocol.js';
7
8
  export * from './relay-protocol.js';
8
9
  export * from './remote-protocol.js';
9
10
  export * from './room-protocol.js';
@@ -0,0 +1,60 @@
1
+ export declare const TaPresenceServer: unique symbol;
2
+ export declare const TA_PRESENCE_SERVICE = "TaPresenceServer";
3
+ /** A page says what it is at again this often while it lasts, the same or not. */
4
+ export declare const TA_PRESENCE_HEARTBEAT_MS = 20000;
5
+ /** A page that said nothing for this long is gone, its connection open or not. */
6
+ export declare const TA_PRESENCE_EXPIRY_MS = 60000;
7
+ /** What a page of Ta is at now (TaPresenceServer.report). */
8
+ export interface TaPresenceReport {
9
+ /** The conversation the user looks at, in a page shown; none while the page is hidden or shows no conversation. */
10
+ sessionId?: string;
11
+ /** They are typing in its message box. */
12
+ typing?: boolean;
13
+ }
14
+ /**
15
+ * Who else is in this Ta, and where (docs/design/ta-team.md 7): each page says what it is at, as it changes and every
16
+ * TA_PRESENCE_HEARTBEAT_MS; ta serve tells the others through the list of sessions (TaSessionInfo.people), only of the
17
+ * conversations each may see, and keeps nothing on disk.
18
+ */
19
+ export interface TaPresenceServer {
20
+ report(state: TaPresenceReport): Promise<void>;
21
+ }
22
+ /** Someone else at a conversation now, as a page is told (TaSessionInfo.people): never the page's own principal. */
23
+ export interface TaSessionPerson {
24
+ /** TA_OWNER, or the principal of one let in. */
25
+ id: string;
26
+ name: string;
27
+ /** Looks at it, in a page shown. */
28
+ viewing?: boolean;
29
+ /** Types in its message box. */
30
+ typing?: boolean;
31
+ /** Asked the run going on. */
32
+ asked?: boolean;
33
+ }
34
+ /** One person with pages of Ta open, and where the latest of them is (TaPresence.people). */
35
+ export interface TaPresencePerson {
36
+ /** TA_OWNER, or the principal of one let in. */
37
+ id: string;
38
+ name: string;
39
+ /** Their pages that say what they are at. */
40
+ pages: number;
41
+ /** The conversation the latest of them looks at. */
42
+ sessionId?: string;
43
+ typing?: boolean;
44
+ }
45
+ /**
46
+ * A message of the user sent by one let in says who in a line of its `<context>`, `[ta:by <principal> <name>]`: the
47
+ * page shows it as theirs, the model reads who asked. ta serve writes it, and takes out any such line a page wrote, so
48
+ * that no one sends as another.
49
+ */
50
+ export declare namespace TaMessageAuthor {
51
+ /** `message` without the lines of an author. */
52
+ function strip(message: string): string;
53
+ /** `message` as written by `id`, called `name`; a command (`/compact`, `!ls`) stays a command. */
54
+ function mark(message: string, id: string, name: string): string;
55
+ /** Who wrote it; undefined for the user of the Ta (no line). */
56
+ function of(message: string): {
57
+ id: string;
58
+ name: string;
59
+ } | undefined;
60
+ }
@@ -0,0 +1,48 @@
1
+ import { TaMessageContext } from './ta-protocol.js';
2
+ export const TaPresenceServer = Symbol('TaPresenceServer');
3
+ export const TA_PRESENCE_SERVICE = 'TaPresenceServer';
4
+ /** A page says what it is at again this often while it lasts, the same or not. */
5
+ export const TA_PRESENCE_HEARTBEAT_MS = 20000;
6
+ /** A page that said nothing for this long is gone, its connection open or not. */
7
+ export const TA_PRESENCE_EXPIRY_MS = 60000;
8
+ /**
9
+ * A message of the user sent by one let in says who in a line of its `<context>`, `[ta:by <principal> <name>]`: the
10
+ * page shows it as theirs, the model reads who asked. ta serve writes it, and takes out any such line a page wrote, so
11
+ * that no one sends as another.
12
+ */
13
+ export var TaMessageAuthor;
14
+ (function (TaMessageAuthor) {
15
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
16
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
17
+ /** `message` without the lines of an author. */
18
+ function strip(message) {
19
+ const context = TaMessageContext.read(message);
20
+ if (context === undefined || !LINE.test(context)) {
21
+ return message;
22
+ }
23
+ const kept = context.replace(LINES, '').replace(/\n+$/, '');
24
+ const body = TaMessageContext.strip(message);
25
+ return kept.trim() ? TaMessageContext.wrap(kept, body) : body;
26
+ }
27
+ TaMessageAuthor.strip = strip;
28
+ /** `message` as written by `id`, called `name`; a command (`/compact`, `!ls`) stays a command. */
29
+ function mark(message, id, name) {
30
+ const plain = strip(message);
31
+ if (/^[/!]/.test(plain)) {
32
+ return plain;
33
+ }
34
+ const line = `[ta:by ${id.replace(/[\s\]]/g, '')} ${name.replace(/[\]\n]/g, ' ').trim() || id}]`;
35
+ const context = TaMessageContext.read(plain);
36
+ return TaMessageContext.wrap(context === undefined ? line : `${context}\n${line}`, TaMessageContext.strip(plain));
37
+ }
38
+ TaMessageAuthor.mark = mark;
39
+ /** Who wrote it; undefined for the user of the Ta (no line). */
40
+ function of(message) {
41
+ var _a;
42
+ const context = TaMessageContext.read(message);
43
+ const match = context === undefined ? null : LINE.exec(context);
44
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== void 0 ? _a : match[1]).trim() } : undefined;
45
+ }
46
+ TaMessageAuthor.of = of;
47
+ })(TaMessageAuthor || (TaMessageAuthor = {}));
48
+ //# sourceMappingURL=presence-protocol.js.map
@@ -11,6 +11,8 @@ export type TaRoomStatus = 'member' | 'waiting' | 'refused' | 'gone';
11
11
  export interface TaIdentity {
12
12
  id: string;
13
13
  name: string;
14
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
15
+ look?: string;
14
16
  /**
15
17
  * The user's other computers are this Ta too (ta-sync shares the identity, or a move brought it): what answers in a
16
18
  * room agrees first which computer does (docs/design/ta-sync.md 9).
@@ -23,6 +25,8 @@ export interface TaRoomMember {
23
25
  /** The identity of its Ta. */
24
26
  id: string;
25
27
  name: string;
28
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
29
+ look?: string;
26
30
  owner: boolean;
27
31
  online: boolean;
28
32
  self: boolean;
@@ -63,6 +67,8 @@ export interface TaRoomRequest {
63
67
  /** Its identity, and the name it gives. */
64
68
  id: string;
65
69
  name: string;
70
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
71
+ look?: string;
66
72
  /** A friend of the user. */
67
73
  friend: boolean;
68
74
  /** Asks from a browser, without Ta: admitted, it only chats. */
@@ -76,6 +82,8 @@ export interface TaRoomRequest {
76
82
  export interface TaFriend {
77
83
  id: string;
78
84
  name: string;
85
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
86
+ look?: string;
79
87
  status: 'friend' | 'adding';
80
88
  online: boolean;
81
89
  metAt: number;
@@ -85,6 +93,8 @@ export interface TaFriend {
85
93
  export interface TaFriendRequest {
86
94
  id: string;
87
95
  name: string;
96
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
97
+ look?: string;
88
98
  at: number;
89
99
  via: 'link' | 'room';
90
100
  room?: string;
@@ -1,4 +1,6 @@
1
+ import type { TaSignInProvider } from './access-protocol.js';
1
2
  import type { TaPackageServer } from './package-protocol.js';
3
+ import type { TaPresencePerson } from './presence-protocol.js';
2
4
  import type { TaRelayFeature, TaRelayService, TaRelayStore, TaRelayType, TaShares } from './relay-protocol.js';
3
5
  import type { TaRooms } from './room-protocol.js';
4
6
  import type { TaServer } from './ta-protocol.js';
@@ -173,6 +175,31 @@ export interface TaHostTeam {
173
175
  unpair(deviceId: string): void;
174
176
  /** The devices of principals other than the owner. */
175
177
  devices(): TaTeamDevice[];
178
+ /** Accounts of the providers ta serve signs in with, to know who one asking to come in is (docs/design/ta-team.md 17). */
179
+ readonly accounts: TaHostAccounts;
180
+ }
181
+ /** An account as its provider says it: `github:<login>`, `google:<email>`, `wechat:<unionid>`, `oidc:<email or sub>`. */
182
+ export interface TaAccount {
183
+ id: string;
184
+ name?: string;
185
+ avatar?: string;
186
+ }
187
+ /**
188
+ * Signing in with an account to say who one is, not to come into ta serve (that is TaAccessServer): the browser goes to
189
+ * the provider and back to `redirectUri` with a code, which ta serve turns into the account with the secret of the
190
+ * provider and PKCE's verifier, both kept here. Whoever sees the code on its way (the relay of a page it serves) can do
191
+ * nothing with it.
192
+ */
193
+ export interface TaHostAccounts {
194
+ /** Those configured (the environment, sign-in.json of the agent directory); none: no one signs in. */
195
+ providers(): TaSignInProvider[];
196
+ /** Where the browser goes, and the state it comes back with. */
197
+ start(provider: string, redirectUri: string): Promise<{
198
+ url: string;
199
+ state: string;
200
+ }>;
201
+ /** The account of a code, for a state `start` gave (once, for 10 minutes); throws when the provider refuses it. */
202
+ verify(state: string, code: string): Promise<TaAccount>;
176
203
  }
177
204
  /** A device of a principal, and what reaches this Ta with it (RelayPairing). The key goes to that principal alone. */
178
205
  export interface TaTeamPairing {
@@ -196,6 +223,8 @@ export interface TaPresence {
196
223
  pages: number;
197
224
  /** `Date.now()` time a page was last connected: now while one is. 0 for never since the service started. */
198
225
  seenAt: number;
226
+ /** Each one with pages that say what they are at (TaPresenceServer), the user (TA_OWNER) and those let in, and where. */
227
+ people: TaPresencePerson[];
199
228
  }
200
229
  /**
201
230
  * Where the web client keeps the session file of the double's conversation: in the data of packages
@@ -206,6 +235,16 @@ export declare const TA_DOUBLE_FILE: {
206
235
  readonly name: '@celljs/ta-web';
207
236
  readonly key: 'assistant.file';
208
237
  };
238
+ /**
239
+ * Where the web client keeps the kind of dinosaur the double is (`trex` till the user picks another): in the data of
240
+ * packages, under this name and key, a JSON string. It is the look of this Ta that others see (TaIdentity.look): the
241
+ * rooms of ta serve tell it to the Ta of friends and rooms.
242
+ */
243
+ export declare const TA_DOUBLE_LOOK: {
244
+ readonly name: '@celljs/ta-web';
245
+ readonly key: 'assistant.species';
246
+ readonly initial: 'trex';
247
+ };
209
248
  /**
210
249
  * Where the web client keeps the tasks the double handed out: in the data of packages, under this name and key; an
211
250
  * array of `{ sessionId, sessionFile?, takenOver?, removed? }` among other fields. The double tells the user of these
@@ -80,6 +80,12 @@ export const TA_FILE_WRITE_EVENT = 'ta:file-write';
80
80
  * double first opened. The server side of a package that sends to the double reads it there.
81
81
  */
82
82
  export const TA_DOUBLE_FILE = { name: '@celljs/ta-web', key: 'assistant.file' };
83
+ /**
84
+ * Where the web client keeps the kind of dinosaur the double is (`trex` till the user picks another): in the data of
85
+ * packages, under this name and key, a JSON string. It is the look of this Ta that others see (TaIdentity.look): the
86
+ * rooms of ta serve tell it to the Ta of friends and rooms.
87
+ */
88
+ export const TA_DOUBLE_LOOK = { name: '@celljs/ta-web', key: 'assistant.species', initial: 'trex' };
83
89
  /**
84
90
  * Where the web client keeps the tasks the double handed out: in the data of packages, under this name and key; an
85
91
  * array of `{ sessionId, sessionFile?, takenOver?, removed? }` among other fields. The double tells the user of these
@@ -1,5 +1,6 @@
1
1
  import type { TaAuthEvent } from './auth-protocol.js';
2
2
  import type { ImageContent, JsonAgentSessionEvent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, ThinkingLevel } from './pi-types.js';
3
+ import type { TaSessionPerson } from './presence-protocol.js';
3
4
  import type { TaRemoteEvent } from './remote-protocol.js';
4
5
  import type { TaRoomEvent } from './room-protocol.js';
5
6
  import type { TaAsking } from './ta-extension-host.js';
@@ -185,6 +186,11 @@ export interface TaSessionInfo {
185
186
  updatedAt: number;
186
187
  /** TaOpenSessionOptions.group. */
187
188
  group?: string;
189
+ /**
190
+ * Others at it now, as this page is told: who looks at it, types in it, or asked its run (TaPresenceServer); never
191
+ * the page's own principal. None in a Ta its user alone is in.
192
+ */
193
+ people?: TaSessionPerson[];
188
194
  }
189
195
  /**
190
196
  * A conversation in a session file of pi that no session has open: the service closed it while idle, or
@@ -56,8 +56,39 @@ export interface TaAccessInfo {
56
56
  requests: TaAccessRequest[];
57
57
  signIns: TaAccessSignIn[];
58
58
  }
59
+ /** The kinds of providers ta serve signs in with: GitHub, Google, WeChat (a website app), an OpenID Connect provider. */
60
+ export type TaSignInKind = 'github' | 'google' | 'wechat' | 'oidc';
61
+ /** A kind of provider as configured: its fields but the secret, which is only said to be there. */
62
+ export interface TaSignInSetup {
63
+ id: TaSignInKind;
64
+ name: string;
65
+ /** It has its id and its secret: it is offered. */
66
+ configured: boolean;
67
+ /** `env`: the environment of ta serve sets it, which this cannot change; `file`: sign-in.json of the agent directory. */
68
+ source?: 'env' | 'file';
69
+ /** `clientId` (`appId` for WeChat), and `url` (GitHub Enterprise), `issuer` and `name` (OpenID Connect). */
70
+ fields: Record<string, string>;
71
+ /** A secret is kept. */
72
+ secret: boolean;
73
+ }
74
+ /** The ways to sign in, to set them up (Settings, Access), and where providers send the browser back. */
75
+ export interface TaSignInConfig {
76
+ providers: TaSignInSetup[];
77
+ /** Register these with a provider: the page of joining by a link on the relay, ta serve's own when it has an address. */
78
+ callbacks: {
79
+ join?: string;
80
+ serve?: string;
81
+ };
82
+ }
59
83
  /** Who may reach this ta serve with an account, for whoever is in (with the token, or an account let in). */
60
84
  export interface TaAccessServer {
85
+ /** The ways to sign in as set up; only the owner. */
86
+ getSignInConfig(): Promise<TaSignInConfig>;
87
+ /**
88
+ * Sets up a kind of provider in sign-in.json, offered at once; `null` takes it out. An empty secret keeps the one kept.
89
+ * One the environment sets is not changed here.
90
+ */
91
+ setSignInProvider(id: TaSignInKind, fields: Record<string, string> | null): Promise<void>;
61
92
  getAccess(): Promise<TaAccessInfo>;
62
93
  /**
63
94
  * Where the browser goes to sign in with `provider` and let that account in at once: the owner, in with
@@ -4,6 +4,7 @@ export * from './gateway-protocol';
4
4
  export * from './location';
5
5
  export * from './package-protocol';
6
6
  export * from './pi-types';
7
+ export * from './presence-protocol';
7
8
  export * from './relay-protocol';
8
9
  export * from './remote-protocol';
9
10
  export * from './room-protocol';
@@ -20,6 +20,7 @@ __exportStar(require("./gateway-protocol"), exports);
20
20
  __exportStar(require("./location"), exports);
21
21
  __exportStar(require("./package-protocol"), exports);
22
22
  __exportStar(require("./pi-types"), exports);
23
+ __exportStar(require("./presence-protocol"), exports);
23
24
  __exportStar(require("./relay-protocol"), exports);
24
25
  __exportStar(require("./remote-protocol"), exports);
25
26
  __exportStar(require("./room-protocol"), exports);
@@ -0,0 +1,61 @@
1
+ export declare const TaPresenceServer: unique symbol;
2
+ export declare const TA_PRESENCE_SERVICE = "TaPresenceServer";
3
+ /** A page says what it is at again this often while it lasts, the same or not. */
4
+ export declare const TA_PRESENCE_HEARTBEAT_MS = 20000;
5
+ /** A page that said nothing for this long is gone, its connection open or not. */
6
+ export declare const TA_PRESENCE_EXPIRY_MS = 60000;
7
+ /** What a page of Ta is at now (TaPresenceServer.report). */
8
+ export interface TaPresenceReport {
9
+ /** The conversation the user looks at, in a page shown; none while the page is hidden or shows no conversation. */
10
+ sessionId?: string;
11
+ /** They are typing in its message box. */
12
+ typing?: boolean;
13
+ }
14
+ /**
15
+ * Who else is in this Ta, and where (docs/design/ta-team.md 7): each page says what it is at, as it changes and every
16
+ * TA_PRESENCE_HEARTBEAT_MS; ta serve tells the others through the list of sessions (TaSessionInfo.people), only of the
17
+ * conversations each may see, and keeps nothing on disk.
18
+ */
19
+ export interface TaPresenceServer {
20
+ report(state: TaPresenceReport): Promise<void>;
21
+ }
22
+ /** Someone else at a conversation now, as a page is told (TaSessionInfo.people): never the page's own principal. */
23
+ export interface TaSessionPerson {
24
+ /** TA_OWNER, or the principal of one let in. */
25
+ id: string;
26
+ name: string;
27
+ /** Looks at it, in a page shown. */
28
+ viewing?: boolean;
29
+ /** Types in its message box. */
30
+ typing?: boolean;
31
+ /** Asked the run going on. */
32
+ asked?: boolean;
33
+ }
34
+ /** One person with pages of Ta open, and where the latest of them is (TaPresence.people). */
35
+ export interface TaPresencePerson {
36
+ /** TA_OWNER, or the principal of one let in. */
37
+ id: string;
38
+ name: string;
39
+ /** Their pages that say what they are at. */
40
+ pages: number;
41
+ /** The conversation the latest of them looks at. */
42
+ sessionId?: string;
43
+ typing?: boolean;
44
+ }
45
+ /**
46
+ * A message of the user sent by one let in says who in a line of its `<context>`, `[ta:by <principal> <name>]`: the
47
+ * page shows it as theirs, the model reads who asked. ta serve writes it, and takes out any such line a page wrote, so
48
+ * that no one sends as another.
49
+ */
50
+ export declare namespace TaMessageAuthor {
51
+ /** `message` without the lines of an author. */
52
+ function strip(message: string): string;
53
+ /** `message` as written by `id`, called `name`; a command (`/compact`, `!ls`) stays a command. */
54
+ function mark(message: string, id: string, name: string): string;
55
+ /** Who wrote it; undefined for the user of the Ta (no line). */
56
+ function of(message: string): {
57
+ id: string;
58
+ name: string;
59
+ } | undefined;
60
+ }
61
+ //# sourceMappingURL=presence-protocol.d.ts.map
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaMessageAuthor = exports.TA_PRESENCE_EXPIRY_MS = exports.TA_PRESENCE_HEARTBEAT_MS = exports.TA_PRESENCE_SERVICE = exports.TaPresenceServer = void 0;
4
+ const ta_protocol_1 = require("./ta-protocol");
5
+ exports.TaPresenceServer = Symbol('TaPresenceServer');
6
+ exports.TA_PRESENCE_SERVICE = 'TaPresenceServer';
7
+ /** A page says what it is at again this often while it lasts, the same or not. */
8
+ exports.TA_PRESENCE_HEARTBEAT_MS = 20000;
9
+ /** A page that said nothing for this long is gone, its connection open or not. */
10
+ exports.TA_PRESENCE_EXPIRY_MS = 60000;
11
+ /**
12
+ * A message of the user sent by one let in says who in a line of its `<context>`, `[ta:by <principal> <name>]`: the
13
+ * page shows it as theirs, the model reads who asked. ta serve writes it, and takes out any such line a page wrote, so
14
+ * that no one sends as another.
15
+ */
16
+ var TaMessageAuthor;
17
+ (function (TaMessageAuthor) {
18
+ const LINE = /^\[ta:by ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
19
+ const LINES = /^\[ta:by [^\]\n]*\]$\n?/gm;
20
+ /** `message` without the lines of an author. */
21
+ function strip(message) {
22
+ const context = ta_protocol_1.TaMessageContext.read(message);
23
+ if (context === undefined || !LINE.test(context)) {
24
+ return message;
25
+ }
26
+ const kept = context.replace(LINES, '').replace(/\n+$/, '');
27
+ const body = ta_protocol_1.TaMessageContext.strip(message);
28
+ return kept.trim() ? ta_protocol_1.TaMessageContext.wrap(kept, body) : body;
29
+ }
30
+ TaMessageAuthor.strip = strip;
31
+ /** `message` as written by `id`, called `name`; a command (`/compact`, `!ls`) stays a command. */
32
+ function mark(message, id, name) {
33
+ const plain = strip(message);
34
+ if (/^[/!]/.test(plain)) {
35
+ return plain;
36
+ }
37
+ const line = `[ta:by ${id.replace(/[\s\]]/g, '')} ${name.replace(/[\]\n]/g, ' ').trim() || id}]`;
38
+ const context = ta_protocol_1.TaMessageContext.read(plain);
39
+ return ta_protocol_1.TaMessageContext.wrap(context === undefined ? line : `${context}\n${line}`, ta_protocol_1.TaMessageContext.strip(plain));
40
+ }
41
+ TaMessageAuthor.mark = mark;
42
+ /** Who wrote it; undefined for the user of the Ta (no line). */
43
+ function of(message) {
44
+ var _a;
45
+ const context = ta_protocol_1.TaMessageContext.read(message);
46
+ const match = context === undefined ? null : LINE.exec(context);
47
+ return match ? { id: match[1], name: ((_a = match[2]) !== null && _a !== void 0 ? _a : match[1]).trim() } : undefined;
48
+ }
49
+ TaMessageAuthor.of = of;
50
+ })(TaMessageAuthor || (exports.TaMessageAuthor = TaMessageAuthor = {}));
51
+ //# sourceMappingURL=presence-protocol.js.map
@@ -11,6 +11,8 @@ export type TaRoomStatus = 'member' | 'waiting' | 'refused' | 'gone';
11
11
  export interface TaIdentity {
12
12
  id: string;
13
13
  name: string;
14
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
15
+ look?: string;
14
16
  /**
15
17
  * The user's other computers are this Ta too (ta-sync shares the identity, or a move brought it): what answers in a
16
18
  * room agrees first which computer does (docs/design/ta-sync.md 9).
@@ -23,6 +25,8 @@ export interface TaRoomMember {
23
25
  /** The identity of its Ta. */
24
26
  id: string;
25
27
  name: string;
28
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
29
+ look?: string;
26
30
  owner: boolean;
27
31
  online: boolean;
28
32
  self: boolean;
@@ -63,6 +67,8 @@ export interface TaRoomRequest {
63
67
  /** Its identity, and the name it gives. */
64
68
  id: string;
65
69
  name: string;
70
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
71
+ look?: string;
66
72
  /** A friend of the user. */
67
73
  friend: boolean;
68
74
  /** Asks from a browser, without Ta: admitted, it only chats. */
@@ -76,6 +82,8 @@ export interface TaRoomRequest {
76
82
  export interface TaFriend {
77
83
  id: string;
78
84
  name: string;
85
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
86
+ look?: string;
79
87
  status: 'friend' | 'adding';
80
88
  online: boolean;
81
89
  metAt: number;
@@ -85,6 +93,8 @@ export interface TaFriend {
85
93
  export interface TaFriendRequest {
86
94
  id: string;
87
95
  name: string;
96
+ /** The kind of dinosaur its double is (a species of the page, TA_DOUBLE_LOOK): drawn as that double. None from a Ta of before. */
97
+ look?: string;
88
98
  at: number;
89
99
  via: 'link' | 'room';
90
100
  room?: string;
@@ -1,4 +1,6 @@
1
+ import type { TaSignInProvider } from './access-protocol';
1
2
  import type { TaPackageServer } from './package-protocol';
3
+ import type { TaPresencePerson } from './presence-protocol';
2
4
  import type { TaRelayFeature, TaRelayService, TaRelayStore, TaRelayType, TaShares } from './relay-protocol';
3
5
  import type { TaRooms } from './room-protocol';
4
6
  import type { TaServer } from './ta-protocol';
@@ -173,6 +175,31 @@ export interface TaHostTeam {
173
175
  unpair(deviceId: string): void;
174
176
  /** The devices of principals other than the owner. */
175
177
  devices(): TaTeamDevice[];
178
+ /** Accounts of the providers ta serve signs in with, to know who one asking to come in is (docs/design/ta-team.md 17). */
179
+ readonly accounts: TaHostAccounts;
180
+ }
181
+ /** An account as its provider says it: `github:<login>`, `google:<email>`, `wechat:<unionid>`, `oidc:<email or sub>`. */
182
+ export interface TaAccount {
183
+ id: string;
184
+ name?: string;
185
+ avatar?: string;
186
+ }
187
+ /**
188
+ * Signing in with an account to say who one is, not to come into ta serve (that is TaAccessServer): the browser goes to
189
+ * the provider and back to `redirectUri` with a code, which ta serve turns into the account with the secret of the
190
+ * provider and PKCE's verifier, both kept here. Whoever sees the code on its way (the relay of a page it serves) can do
191
+ * nothing with it.
192
+ */
193
+ export interface TaHostAccounts {
194
+ /** Those configured (the environment, sign-in.json of the agent directory); none: no one signs in. */
195
+ providers(): TaSignInProvider[];
196
+ /** Where the browser goes, and the state it comes back with. */
197
+ start(provider: string, redirectUri: string): Promise<{
198
+ url: string;
199
+ state: string;
200
+ }>;
201
+ /** The account of a code, for a state `start` gave (once, for 10 minutes); throws when the provider refuses it. */
202
+ verify(state: string, code: string): Promise<TaAccount>;
176
203
  }
177
204
  /** A device of a principal, and what reaches this Ta with it (RelayPairing). The key goes to that principal alone. */
178
205
  export interface TaTeamPairing {
@@ -196,6 +223,8 @@ export interface TaPresence {
196
223
  pages: number;
197
224
  /** `Date.now()` time a page was last connected: now while one is. 0 for never since the service started. */
198
225
  seenAt: number;
226
+ /** Each one with pages that say what they are at (TaPresenceServer), the user (TA_OWNER) and those let in, and where. */
227
+ people: TaPresencePerson[];
199
228
  }
200
229
  /**
201
230
  * Where the web client keeps the session file of the double's conversation: in the data of packages
@@ -206,6 +235,16 @@ export declare const TA_DOUBLE_FILE: {
206
235
  readonly name: '@celljs/ta-web';
207
236
  readonly key: 'assistant.file';
208
237
  };
238
+ /**
239
+ * Where the web client keeps the kind of dinosaur the double is (`trex` till the user picks another): in the data of
240
+ * packages, under this name and key, a JSON string. It is the look of this Ta that others see (TaIdentity.look): the
241
+ * rooms of ta serve tell it to the Ta of friends and rooms.
242
+ */
243
+ export declare const TA_DOUBLE_LOOK: {
244
+ readonly name: '@celljs/ta-web';
245
+ readonly key: 'assistant.species';
246
+ readonly initial: 'trex';
247
+ };
209
248
  /**
210
249
  * Where the web client keeps the tasks the double handed out: in the data of packages, under this name and key; an
211
250
  * array of `{ sessionId, sessionFile?, takenOver?, removed? }` among other fields. The double tells the user of these
@@ -1,6 +1,6 @@
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_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 = void 0;
4
4
  /**
5
5
  * The event of pi's `pi.events` by which a pi extension asks for the host of its package:
6
6
  * `pi.events.emit(TA_HOST_EVENT, { name, resolve, heard })`. Under `ta serve` `heard` is called as the event
@@ -83,6 +83,12 @@ exports.TA_FILE_WRITE_EVENT = 'ta:file-write';
83
83
  * double first opened. The server side of a package that sends to the double reads it there.
84
84
  */
85
85
  exports.TA_DOUBLE_FILE = { name: '@celljs/ta-web', key: 'assistant.file' };
86
+ /**
87
+ * Where the web client keeps the kind of dinosaur the double is (`trex` till the user picks another): in the data of
88
+ * packages, under this name and key, a JSON string. It is the look of this Ta that others see (TaIdentity.look): the
89
+ * rooms of ta serve tell it to the Ta of friends and rooms.
90
+ */
91
+ exports.TA_DOUBLE_LOOK = { name: '@celljs/ta-web', key: 'assistant.species', initial: 'trex' };
86
92
  /**
87
93
  * Where the web client keeps the tasks the double handed out: in the data of packages, under this name and key; an
88
94
  * array of `{ sessionId, sessionFile?, takenOver?, removed? }` among other fields. The double tells the user of these
@@ -1,5 +1,6 @@
1
1
  import type { TaAuthEvent } from './auth-protocol';
2
2
  import type { ImageContent, JsonAgentSessionEvent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, ThinkingLevel } from './pi-types';
3
+ import type { TaSessionPerson } from './presence-protocol';
3
4
  import type { TaRemoteEvent } from './remote-protocol';
4
5
  import type { TaRoomEvent } from './room-protocol';
5
6
  import type { TaAsking } from './ta-extension-host';
@@ -185,6 +186,11 @@ export interface TaSessionInfo {
185
186
  updatedAt: number;
186
187
  /** TaOpenSessionOptions.group. */
187
188
  group?: string;
189
+ /**
190
+ * Others at it now, as this page is told: who looks at it, types in it, or asked its run (TaPresenceServer); never
191
+ * the page's own principal. None in a Ta its user alone is in.
192
+ */
193
+ people?: TaSessionPerson[];
188
194
  }
189
195
  /**
190
196
  * A conversation in a session file of pi that no session has open: the service closed it while idle, or
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@celljs/ta-protocol",
3
- "version": "4.13.1",
3
+ "version": "4.14.0",
4
4
  "description": "The protocol between ta serve and its clients",
5
- "homepage": "https://github.com/cellbang/cell",
5
+ "homepage": "https://github.com/cellbang/ta",
6
6
  "bugs": {
7
- "url": "https://github.com/cellbang/cell/issues"
7
+ "url": "https://github.com/cellbang/ta/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",