@celljs/ta-host 4.11.0 → 4.13.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/README.en.md +3 -2
- package/README.md +3 -2
- package/esm/node/extension-data-notifier.d.ts +3 -0
- package/esm/node/extension-data-notifier.js +8 -2
- package/esm/node/extension-providers.js +1 -1
- package/esm/node/host-protocol.d.ts +20 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/keep-awake.d.ts +44 -0
- package/esm/node/keep-awake.js +112 -0
- package/esm/node/package-host-extension.js +2 -0
- package/esm/node/package-hosts.d.ts +23 -1
- package/esm/node/package-hosts.js +61 -3
- package/esm/node/relay-bridge.d.ts +37 -3
- package/esm/node/relay-bridge.js +271 -10
- package/esm/node/rooms-bridge.d.ts +13 -2
- package/esm/node/rooms-bridge.js +34 -4
- package/esm/node/session-catalog.d.ts +1 -1
- package/esm/node/session-catalog.js +5 -0
- package/esm/node/session-list-feed.d.ts +11 -1
- package/esm/node/session-list-feed.js +17 -3
- package/esm/node/session-resume.d.ts +52 -0
- package/esm/node/session-resume.js +174 -0
- package/esm/node/settings-store.d.ts +3 -0
- package/esm/node/settings-store.js +22 -0
- package/esm/node/ta-errors.d.ts +1 -0
- package/esm/node/ta-errors.js +4 -0
- package/esm/node/ta-server-impl.d.ts +10 -0
- package/esm/node/ta-server-impl.js +57 -9
- package/esm/node/ta-session-factory.js +5 -2
- package/esm/node/ta-session-registry.d.ts +12 -1
- package/esm/node/ta-session-registry.js +30 -1
- package/esm/node/ta-session.d.ts +3 -0
- package/esm/node/ta-session.js +16 -0
- package/esm/node/team/authority.d.ts +19 -0
- package/esm/node/team/authority.js +79 -0
- package/esm/node/team/call-util.d.ts +23 -0
- package/esm/node/team/call-util.js +88 -0
- package/esm/node/team/connections.d.ts +15 -0
- package/esm/node/team/connections.js +81 -0
- package/esm/node/team/host-team.d.ts +13 -0
- package/esm/node/team/host-team.js +69 -0
- package/esm/node/team/index.d.ts +13 -0
- package/esm/node/team/index.js +14 -0
- package/esm/node/team/member-devices.d.ts +11 -0
- package/esm/node/team/member-devices.js +56 -0
- package/esm/node/team/package-permissions.d.ts +23 -0
- package/esm/node/team/package-permissions.js +75 -0
- package/esm/node/team/principals.d.ts +22 -0
- package/esm/node/team/principals.js +72 -0
- package/esm/node/team/run-actors.d.ts +21 -0
- package/esm/node/team/run-actors.js +100 -0
- package/esm/node/team/shared-data.d.ts +18 -0
- package/esm/node/team/shared-data.js +55 -0
- package/esm/node/team/team-calls.d.ts +33 -0
- package/esm/node/team/team-calls.js +266 -0
- package/esm/node/team/team-gate.d.ts +31 -0
- package/esm/node/team/team-gate.js +177 -0
- package/esm/node/team/team-protocol.d.ts +89 -0
- package/esm/node/team/team-protocol.js +27 -0
- package/esm/node/team/visibility.d.ts +13 -0
- package/esm/node/team/visibility.js +50 -0
- package/esm/node/terminal-service.d.ts +5 -0
- package/esm/node/terminal-service.js +11 -2
- package/lib/node/extension-data-notifier.d.ts +3 -0
- package/lib/node/extension-data-notifier.js +8 -2
- package/lib/node/extension-providers.js +1 -1
- package/lib/node/host-protocol.d.ts +20 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/lib/node/keep-awake.d.ts +45 -0
- package/lib/node/keep-awake.js +115 -0
- package/lib/node/package-host-extension.js +2 -0
- package/lib/node/package-hosts.d.ts +23 -1
- package/lib/node/package-hosts.js +60 -2
- package/lib/node/relay-bridge.d.ts +37 -3
- package/lib/node/relay-bridge.js +269 -8
- package/lib/node/rooms-bridge.d.ts +13 -2
- package/lib/node/rooms-bridge.js +34 -4
- package/lib/node/session-catalog.d.ts +1 -1
- package/lib/node/session-catalog.js +5 -0
- package/lib/node/session-list-feed.d.ts +11 -1
- package/lib/node/session-list-feed.js +17 -3
- package/lib/node/session-resume.d.ts +53 -0
- package/lib/node/session-resume.js +177 -0
- package/lib/node/settings-store.d.ts +3 -0
- package/lib/node/settings-store.js +22 -0
- package/lib/node/ta-errors.d.ts +1 -0
- package/lib/node/ta-errors.js +4 -0
- package/lib/node/ta-server-impl.d.ts +10 -0
- package/lib/node/ta-server-impl.js +57 -9
- package/lib/node/ta-session-factory.js +4 -1
- package/lib/node/ta-session-registry.d.ts +12 -1
- package/lib/node/ta-session-registry.js +30 -1
- package/lib/node/ta-session.d.ts +3 -0
- package/lib/node/ta-session.js +16 -0
- package/lib/node/team/authority.d.ts +20 -0
- package/lib/node/team/authority.js +82 -0
- package/lib/node/team/call-util.d.ts +24 -0
- package/lib/node/team/call-util.js +91 -0
- package/lib/node/team/connections.d.ts +16 -0
- package/lib/node/team/connections.js +84 -0
- package/lib/node/team/host-team.d.ts +14 -0
- package/lib/node/team/host-team.js +72 -0
- package/lib/node/team/index.d.ts +14 -0
- package/lib/node/team/index.js +30 -0
- package/lib/node/team/member-devices.d.ts +12 -0
- package/lib/node/team/member-devices.js +59 -0
- package/lib/node/team/package-permissions.d.ts +24 -0
- package/lib/node/team/package-permissions.js +78 -0
- package/lib/node/team/principals.d.ts +23 -0
- package/lib/node/team/principals.js +75 -0
- package/lib/node/team/run-actors.d.ts +22 -0
- package/lib/node/team/run-actors.js +103 -0
- package/lib/node/team/shared-data.d.ts +19 -0
- package/lib/node/team/shared-data.js +58 -0
- package/lib/node/team/team-calls.d.ts +34 -0
- package/lib/node/team/team-calls.js +270 -0
- package/lib/node/team/team-gate.d.ts +32 -0
- package/lib/node/team/team-gate.js +180 -0
- package/lib/node/team/team-protocol.d.ts +90 -0
- package/lib/node/team/team-protocol.js +30 -0
- package/lib/node/team/visibility.d.ts +14 -0
- package/lib/node/team/visibility.js +53 -0
- package/lib/node/terminal-service.d.ts +5 -0
- package/lib/node/terminal-service.js +11 -2
- package/package.json +14 -10
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
3
|
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
4
|
-
import { type TaPackageShare, type TaRelayDevice, type TaRelayInfo, TaRelayServer, type TaSharedContent, type TaShareInfo, type TaShareInput, type TaShares } from '@celljs/ta-protocol';
|
|
5
|
-
import { type RelayContentShare, RelayHost, RelayHubs, type RelayPublicIdentity, RelayStore } from '@celljs/ta-relay/lib/node';
|
|
4
|
+
import { type TaExtensionRelays, type TaPackageShare, type TaRelayDevice, type TaRelayFeature, type TaRelayInfo, type TaRelayProbe, TaRelayServer, type TaRelayStore, type TaRelays, type TaRelayType, type TaSharedContent, type TaShareInfo, type TaShareInput, type TaShares } from '@celljs/ta-protocol';
|
|
5
|
+
import { type RelayContentShare, RelayHost, RelayHubs, type RelayPublicIdentity, RelayStore, RelaysFile } from '@celljs/ta-relay/lib/node';
|
|
6
6
|
import { ServerAware } from '@celljs/web/lib/node';
|
|
7
|
-
import { WebExtensionCatalog } from './host-protocol.js';
|
|
7
|
+
import { KeepAwake, WebExtensionCatalog } from './host-protocol.js';
|
|
8
8
|
import { type TaAccess } from './ta-access.js';
|
|
9
9
|
/** The id of {@link RelayBridge}, for TaRelayServerImpl. */
|
|
10
10
|
export declare const RELAY_BRIDGE: unique symbol;
|
|
@@ -16,12 +16,18 @@ export declare const RELAY_BRIDGE: unique symbol;
|
|
|
16
16
|
export declare class RelayBridge implements ServerAware, ApplicationLifecycle<Application> {
|
|
17
17
|
protected readonly access: TaAccess;
|
|
18
18
|
readonly store: RelayStore;
|
|
19
|
+
/** Which relay each feature uses (docs/design/ta-relays.md); without the file, the relay of relay.json or the official one. */
|
|
20
|
+
readonly relays: RelaysFile;
|
|
19
21
|
/** The identity, friends and rooms of this Ta (RoomsBridge runs them): shares with Ta friends need them too. */
|
|
20
22
|
readonly hubs: RelayHubs;
|
|
23
|
+
/** The relay a feature uses now: as relays.json says, else the relay of relay.json (what was used before it), else the official one. */
|
|
24
|
+
relayFor(feature: string): string;
|
|
21
25
|
protected host?: RelayHost;
|
|
22
26
|
/** Content shared by links (TaExtensionHost.shares): kept in the agent directory, handed on by this server, a copy sealed on the relay if asked. */
|
|
23
27
|
readonly shares: TaShares;
|
|
24
28
|
get online(): boolean;
|
|
29
|
+
/** The paired devices connected now (RelayHost.devicesOpen). */
|
|
30
|
+
get devicesOpen(): number;
|
|
25
31
|
/** relay.json changed here: no need to wait for the watch. */
|
|
26
32
|
refresh(): void;
|
|
27
33
|
setServer(server: Server): Promise<void>;
|
|
@@ -35,18 +41,46 @@ export declare class RelayBridge implements ServerAware, ApplicationLifecycle<Ap
|
|
|
35
41
|
protected friendsOf(ids: readonly string[] | undefined): RelayPublicIdentity[];
|
|
36
42
|
protected info(content: RelayContentShare): TaShareInfo;
|
|
37
43
|
protected start(server: Server): void;
|
|
44
|
+
/** The relays, and which one each feature uses. */
|
|
45
|
+
listRelays(): TaRelays;
|
|
46
|
+
/** The types of services packages registered (TaExtensionRelays.registerType), by their names in relays.json. */
|
|
47
|
+
protected readonly types: Map<string, TaRelayType>;
|
|
48
|
+
/** The store of a service of a type a package registered. */
|
|
49
|
+
openStore(id: string): TaRelayStore;
|
|
50
|
+
/**
|
|
51
|
+
* Adds a service of a registered type after trying it: a file written, read back and removed, so that a wrong
|
|
52
|
+
* address or password is said now, not at the first sync.
|
|
53
|
+
*/
|
|
54
|
+
addStore(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
55
|
+
/** Writes, reads back and removes a small file: whether the store takes what sync will put there. */
|
|
56
|
+
static tryStore(store: TaRelayStore): Promise<number>;
|
|
57
|
+
/** relays.json for the server side of packages (TaExtensionHost.relays). */
|
|
58
|
+
readonly extensionRelays: TaExtensionRelays;
|
|
59
|
+
/** relays.json changed: what connects to relays follows. */
|
|
60
|
+
relaysChanged(): void;
|
|
38
61
|
}
|
|
39
62
|
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
40
63
|
export declare class TaRelayServerImpl implements TaRelayServer {
|
|
41
64
|
protected readonly bridge: RelayBridge;
|
|
42
65
|
protected readonly catalog: WebExtensionCatalog;
|
|
43
66
|
protected readonly environments: ExecEnvironmentFactory;
|
|
67
|
+
protected readonly keepAwake: KeepAwake;
|
|
44
68
|
sharePackage(id: string): Promise<TaPackageShare>;
|
|
45
69
|
unsharePackage(id: string): Promise<void>;
|
|
46
70
|
getRelay(): Promise<TaRelayInfo>;
|
|
71
|
+
setKeepAwake(on: boolean): Promise<void>;
|
|
47
72
|
pair(relay: string, name: string): Promise<{
|
|
48
73
|
link: string;
|
|
49
74
|
device: TaRelayDevice;
|
|
50
75
|
}>;
|
|
51
76
|
unpair(deviceId: string): Promise<void>;
|
|
77
|
+
listRelays(): Promise<TaRelays>;
|
|
78
|
+
addRelay(url: string, name?: string): Promise<string>;
|
|
79
|
+
addFolder(path: string, name?: string): Promise<string>;
|
|
80
|
+
addStore(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
81
|
+
removeRelay(id: string): Promise<void>;
|
|
82
|
+
chooseRelay(feature: TaRelayFeature, id: string | null): Promise<TaRelays>;
|
|
83
|
+
probeRelay(idOrUrl: string): Promise<TaRelayProbe>;
|
|
84
|
+
/** A change of relays.json; what it refuses is said as the errors of Ta. */
|
|
85
|
+
protected relaysCall<T>(change: () => T): T;
|
|
52
86
|
}
|
package/esm/node/relay-bridge.js
CHANGED
|
@@ -16,9 +16,9 @@ import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
|
16
16
|
import { PackageArchive } from '@celljs/ta-harness/lib/node/package-archive';
|
|
17
17
|
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
18
18
|
import { TA_WEBSOCKET_PATH, TaRelayServer, } from '@celljs/ta-protocol';
|
|
19
|
-
import { RELAY_CONTENT_MAX_BYTES,
|
|
19
|
+
import { RELAY_CONTENT_MAX_BYTES, RELAY_FEATURES, RELAY_SHARE_MAX_BYTES, RelayBlobClient, RelayBytes, RelayContentError, RelayContentUtil, RelayHost, RelayHubFiles, RelayHubs, RelayInfoUtil, RelayPairingUtil, RelayServiceUtil, RelayShareUtil, RelayStore, RelaysConfigError, RelaysFile, RelayTypes, } from '@celljs/ta-relay/lib/node';
|
|
20
20
|
import { ServerAware } from '@celljs/web/lib/node';
|
|
21
|
-
import { WebExtensionCatalog } from './host-protocol.js';
|
|
21
|
+
import { KeepAwake, WebExtensionCatalog } from './host-protocol.js';
|
|
22
22
|
import { TA_ACCESS } from './ta-access.js';
|
|
23
23
|
import { TaErrors } from './ta-errors.js';
|
|
24
24
|
/** The id of {@link RelayBridge}, for TaRelayServerImpl. */
|
|
@@ -33,11 +33,13 @@ const WATCH_INTERVAL_MS = 2000;
|
|
|
33
33
|
let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
34
34
|
constructor() {
|
|
35
35
|
this.store = new RelayStore(TaBrand.agentDir());
|
|
36
|
+
/** Which relay each feature uses (docs/design/ta-relays.md); without the file, the relay of relay.json or the official one. */
|
|
37
|
+
this.relays = new RelaysFile(TaBrand.agentDir());
|
|
36
38
|
/** The identity, friends and rooms of this Ta (RoomsBridge runs them): shares with Ta friends need them too. */
|
|
37
39
|
this.hubs = new RelayHubs({
|
|
38
40
|
store: new RelayHubFiles(TaBrand.agentDir()),
|
|
39
41
|
name: RelayHubFiles.userName,
|
|
40
|
-
relay: () =>
|
|
42
|
+
relay: (use) => this.relayFor(use !== null && use !== void 0 ? use : 'rooms'),
|
|
41
43
|
});
|
|
42
44
|
/** Content shared by links (TaExtensionHost.shares): kept in the agent directory, handed on by this server, a copy sealed on the relay if asked. */
|
|
43
45
|
this.shares = {
|
|
@@ -46,12 +48,56 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
46
48
|
remove: async (id) => this.unshare(id),
|
|
47
49
|
open: (link, password) => this.open(link, password),
|
|
48
50
|
};
|
|
51
|
+
/** The types of services packages registered (TaExtensionRelays.registerType), by their names in relays.json. */
|
|
52
|
+
this.types = new Map();
|
|
53
|
+
/** relays.json for the server side of packages (TaExtensionHost.relays). */
|
|
54
|
+
this.extensionRelays = {
|
|
55
|
+
serviceFor: async (feature) => {
|
|
56
|
+
var _a;
|
|
57
|
+
const listed = this.listRelays();
|
|
58
|
+
return ((_a = listed.relays.find(service => service.id === listed.use[feature])) !== null && _a !== void 0 ? _a : { id: '', type: 'ta-relay', url: this.relayFor(feature), builtin: false });
|
|
59
|
+
},
|
|
60
|
+
addFolder: async (path, name) => this.relays.addFolder(path, name),
|
|
61
|
+
list: async () => this.listRelays().relays,
|
|
62
|
+
registerType: (type, definition) => {
|
|
63
|
+
const unregister = RelayTypes.register(type, { features: ['sync'], key: options => definition.key(options) });
|
|
64
|
+
this.types.set(type, definition);
|
|
65
|
+
return () => {
|
|
66
|
+
unregister();
|
|
67
|
+
if (this.types.get(type) === definition) {
|
|
68
|
+
this.types.delete(type);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
openStore: async (id) => this.openStore(id),
|
|
73
|
+
storeConfig: async (id) => {
|
|
74
|
+
const service = this.relays.services().find(each => each.id === id);
|
|
75
|
+
return service && 'options' in service
|
|
76
|
+
? { type: service.type, options: service.options, ...(service.name ? { name: service.name } : {}) }
|
|
77
|
+
: undefined;
|
|
78
|
+
},
|
|
79
|
+
addStore: (type, options, name) => this.addStore(type, options, name),
|
|
80
|
+
choose: async (feature, id) => {
|
|
81
|
+
this.relays.use(feature, id !== null && id !== void 0 ? id : undefined);
|
|
82
|
+
this.relaysChanged();
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** The relay a feature uses now: as relays.json says, else the relay of relay.json (what was used before it), else the official one. */
|
|
87
|
+
relayFor(feature) {
|
|
88
|
+
return this.relays.urlFor(feature, this.store.read().url);
|
|
49
89
|
}
|
|
50
90
|
get online() {
|
|
51
91
|
var _a;
|
|
52
92
|
var _b;
|
|
53
93
|
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.online) !== null && _b !== void 0 ? _b : false;
|
|
54
94
|
}
|
|
95
|
+
/** The paired devices connected now (RelayHost.devicesOpen). */
|
|
96
|
+
get devicesOpen() {
|
|
97
|
+
var _a;
|
|
98
|
+
var _b;
|
|
99
|
+
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.devicesOpen) !== null && _b !== void 0 ? _b : 0;
|
|
100
|
+
}
|
|
55
101
|
/** relay.json changed here: no need to wait for the watch. */
|
|
56
102
|
refresh() {
|
|
57
103
|
var _a;
|
|
@@ -84,7 +130,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
84
130
|
if (people && people.length === 0) {
|
|
85
131
|
throw new RelayContentError('people', 'Choose the Ta friends to share it with: none of them is a friend of this Ta.');
|
|
86
132
|
}
|
|
87
|
-
const { content, link } = await this.store.addContent({ ...input, createdAt, people, ...(people ? { identity: await this.hubs.identity() } : {}) }, createdAt);
|
|
133
|
+
const { content, link } = await this.store.addContent({ ...input, createdAt, people, relay: this.relayFor('share'), ...(people ? { identity: await this.hubs.identity() } : {}) }, createdAt);
|
|
88
134
|
if (content.offline) {
|
|
89
135
|
const key = RelayBytes.fromBase64(content.key);
|
|
90
136
|
try {
|
|
@@ -106,11 +152,11 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
106
152
|
return this.info(content);
|
|
107
153
|
}
|
|
108
154
|
async unshare(id) {
|
|
109
|
-
const
|
|
155
|
+
const config = this.store.read();
|
|
110
156
|
const content = this.store.removeContent(id);
|
|
111
157
|
this.refresh();
|
|
112
158
|
if (content === null || content === void 0 ? void 0 : content.offline) {
|
|
113
|
-
await RelayBlobClient.remove(
|
|
159
|
+
await RelayBlobClient.remove(RelayStore.relayOf(content, config), content.id, content.offline.token).catch(() => undefined);
|
|
114
160
|
}
|
|
115
161
|
return !!content;
|
|
116
162
|
}
|
|
@@ -160,6 +206,105 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
160
206
|
host.start();
|
|
161
207
|
watchFile(this.store.file, { interval: WATCH_INTERVAL_MS }, () => host.refresh());
|
|
162
208
|
}
|
|
209
|
+
/** The relays, and which one each feature uses. */
|
|
210
|
+
listRelays() {
|
|
211
|
+
const { config, error } = this.relays.safeRead();
|
|
212
|
+
const services = this.relays.services(config).map(service => {
|
|
213
|
+
const name = service.name ? { name: service.name } : {};
|
|
214
|
+
if (RelayServiceUtil.isFolder(service)) {
|
|
215
|
+
return { id: service.id, type: 'folder', path: service.path, builtin: false, only: ['sync'], ...name };
|
|
216
|
+
}
|
|
217
|
+
if (RelayServiceUtil.isRelay(service)) {
|
|
218
|
+
return { id: service.id, type: 'ta-relay', url: service.url, builtin: service.builtin, ...name };
|
|
219
|
+
}
|
|
220
|
+
const options = 'options' in service ? service.options : {};
|
|
221
|
+
const definition = this.types.get(service.type);
|
|
222
|
+
if (!definition) {
|
|
223
|
+
return { id: service.id, type: service.type, builtin: false, only: [], unavailable: true, ...name };
|
|
224
|
+
}
|
|
225
|
+
// What the page sees of it: never a password or a key.
|
|
226
|
+
const secret = new Set(definition.options.filter(option => option.secret).map(option => option.key));
|
|
227
|
+
const shown = Object.fromEntries(Object.entries(options).filter(([key]) => !secret.has(key)));
|
|
228
|
+
return { id: service.id, type: service.type, builtin: false, only: ['sync'], options: shown, where: definition.where(options), ...name };
|
|
229
|
+
});
|
|
230
|
+
const fallback = this.store.read().url;
|
|
231
|
+
// Without relays.json, the relay of relay.json is the one of every feature: listed, as one added.
|
|
232
|
+
if (fallback && !services.some(service => service.url === fallback)) {
|
|
233
|
+
services.push({ id: 'relay-json', type: 'ta-relay', url: fallback, name: new URL(fallback).host, builtin: false });
|
|
234
|
+
}
|
|
235
|
+
const use = Object.fromEntries(RELAY_FEATURES.map(feature => {
|
|
236
|
+
var _a;
|
|
237
|
+
const service = this.relays.serviceFor(feature, fallback);
|
|
238
|
+
const url = RelayServiceUtil.isRelay(service) ? service.url : undefined;
|
|
239
|
+
return [feature, service.id || ((_a = services.find(each => each.type === 'ta-relay' && each.url === url)) === null || _a === void 0 ? void 0 : _a.id) || ''];
|
|
240
|
+
}));
|
|
241
|
+
const drives = RelayServiceUtil.drives().filter(drive => !services.some(service => service.type === 'folder' && service.path === drive.path));
|
|
242
|
+
const types = [...this.types].map(([type, { title, hint, icon, options }]) => ({
|
|
243
|
+
type,
|
|
244
|
+
title,
|
|
245
|
+
...(hint ? { hint } : {}),
|
|
246
|
+
...(icon ? { icon } : {}),
|
|
247
|
+
options,
|
|
248
|
+
}));
|
|
249
|
+
return {
|
|
250
|
+
relays: services,
|
|
251
|
+
use,
|
|
252
|
+
file: this.relays.file,
|
|
253
|
+
...(drives.length ? { drives } : {}),
|
|
254
|
+
...(types.length ? { types } : {}),
|
|
255
|
+
...(error ? { error } : {}),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/** The store of a service of a type a package registered. */
|
|
259
|
+
openStore(id) {
|
|
260
|
+
var _a;
|
|
261
|
+
const service = this.relays.services().find(each => each.id === id);
|
|
262
|
+
if (!service || !('options' in service)) {
|
|
263
|
+
throw new RelaysConfigError(`There is no store ${id} in relays.json.`);
|
|
264
|
+
}
|
|
265
|
+
const definition = this.types.get(service.type);
|
|
266
|
+
if (!definition) {
|
|
267
|
+
throw new RelaysConfigError(`${(_a = service.name) !== null && _a !== void 0 ? _a : id} is a service of type ${service.type}: turn on the package that adds it.`);
|
|
268
|
+
}
|
|
269
|
+
return definition.create(service.options);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Adds a service of a registered type after trying it: a file written, read back and removed, so that a wrong
|
|
273
|
+
* address or password is said now, not at the first sync.
|
|
274
|
+
*/
|
|
275
|
+
async addStore(type, options, name) {
|
|
276
|
+
var _a;
|
|
277
|
+
const definition = this.types.get(type);
|
|
278
|
+
if (!definition) {
|
|
279
|
+
throw new RelaysConfigError(`There is no type ${type}: turn on the package that adds it.`);
|
|
280
|
+
}
|
|
281
|
+
for (const option of definition.options) {
|
|
282
|
+
if (!option.optional && !String((_a = options === null || options === void 0 ? void 0 : options[option.key]) !== null && _a !== void 0 ? _a : '').trim()) {
|
|
283
|
+
throw new RelaysConfigError(`${option.key} is needed.`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
await RelayBridge_1.tryStore(definition.create(options));
|
|
287
|
+
const id = this.relays.addStore(type, options, name);
|
|
288
|
+
this.relaysChanged();
|
|
289
|
+
return id;
|
|
290
|
+
}
|
|
291
|
+
/** Writes, reads back and removes a small file: whether the store takes what sync will put there. */
|
|
292
|
+
static async tryStore(store) {
|
|
293
|
+
const started = Date.now();
|
|
294
|
+
const path = `ta-sync/.ta-check-${Math.random().toString(36).slice(2, 10)}`;
|
|
295
|
+
const bytes = new TextEncoder().encode('ta');
|
|
296
|
+
await store.write(path, bytes);
|
|
297
|
+
const back = await store.read(path);
|
|
298
|
+
await store.remove(path).catch(() => undefined);
|
|
299
|
+
if (!back || new TextDecoder().decode(back) !== 'ta') {
|
|
300
|
+
throw new RelaysConfigError('The store took the file but did not give it back.');
|
|
301
|
+
}
|
|
302
|
+
return Date.now() - started;
|
|
303
|
+
}
|
|
304
|
+
/** relays.json changed: what connects to relays follows. */
|
|
305
|
+
relaysChanged() {
|
|
306
|
+
this.refresh();
|
|
307
|
+
}
|
|
163
308
|
};
|
|
164
309
|
__decorate([
|
|
165
310
|
Autowired(TA_ACCESS),
|
|
@@ -169,7 +314,7 @@ RelayBridge = RelayBridge_1 = __decorate([
|
|
|
169
314
|
Component([RELAY_BRIDGE, ServerAware, ApplicationLifecycle])
|
|
170
315
|
], RelayBridge);
|
|
171
316
|
export { RelayBridge };
|
|
172
|
-
const device = ({ id, name, createdAt }) => ({ id, name, createdAt });
|
|
317
|
+
const device = ({ id, name, createdAt, relay }) => ({ id, name, createdAt, ...(relay ? { relay } : {}) });
|
|
173
318
|
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
174
319
|
let TaRelayServerImpl = class TaRelayServerImpl {
|
|
175
320
|
sharePackage(id) {
|
|
@@ -183,7 +328,7 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
183
328
|
if (size > RELAY_SHARE_MAX_BYTES) {
|
|
184
329
|
throw TaErrors.invalidArgument(`${pkg.name} is ${(size / 1024 / 1024).toFixed(1)} MB packed, more than the ${RELAY_SHARE_MAX_BYTES / 1024 / 1024} MB a link takes.`, 'Publish it to npm or Git and share that, or export it as a file.');
|
|
185
330
|
}
|
|
186
|
-
const { link, share } = this.bridge.store.shareRoot(pkg.root, pkg.name);
|
|
331
|
+
const { link, share } = this.bridge.store.shareRoot(pkg.root, pkg.name, Date.now(), this.bridge.relayFor('share'));
|
|
187
332
|
this.bridge.refresh();
|
|
188
333
|
return { link: RelayShareUtil.link(link), expiresAt: share.expiresAt, maxBytes: RELAY_SHARE_MAX_BYTES };
|
|
189
334
|
});
|
|
@@ -196,8 +341,22 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
196
341
|
});
|
|
197
342
|
}
|
|
198
343
|
async getRelay() {
|
|
199
|
-
const
|
|
200
|
-
|
|
344
|
+
const config = this.bridge.store.read();
|
|
345
|
+
const { devices, keepAwake } = config;
|
|
346
|
+
const relay = this.bridge.relayFor('devices');
|
|
347
|
+
return {
|
|
348
|
+
// The relay a new device goes through; online, whether ta serve is at every relay its devices are on.
|
|
349
|
+
...(devices.length ? { relay } : {}),
|
|
350
|
+
defaultRelay: relay,
|
|
351
|
+
online: this.bridge.online,
|
|
352
|
+
// Those of people let in are theirs, not the user's: ta-team lists them.
|
|
353
|
+
devices: devices.filter(each => !each.member).map(each => device({ ...each, relay: RelayStore.relayOf(each, config) })),
|
|
354
|
+
...(this.keepAwake.supported ? { keepAwake: keepAwake !== false } : {}),
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
async setKeepAwake(on) {
|
|
358
|
+
this.bridge.store.setKeepAwake(on !== false);
|
|
359
|
+
this.keepAwake.check();
|
|
201
360
|
}
|
|
202
361
|
pair(relay, name) {
|
|
203
362
|
return TaErrors.guard(() => {
|
|
@@ -215,6 +374,104 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
215
374
|
this.bridge.store.remove(deviceId);
|
|
216
375
|
this.bridge.refresh();
|
|
217
376
|
}
|
|
377
|
+
async listRelays() {
|
|
378
|
+
return this.bridge.listRelays();
|
|
379
|
+
}
|
|
380
|
+
addRelay(url, name) {
|
|
381
|
+
return TaErrors.guard(async () => {
|
|
382
|
+
var _a;
|
|
383
|
+
let address;
|
|
384
|
+
try {
|
|
385
|
+
address = RelayInfoUtil.normalize(url);
|
|
386
|
+
}
|
|
387
|
+
catch (_b) {
|
|
388
|
+
throw TaErrors.invalidArgument(`${url} is not the address of a relay.`, 'Pass https://<host> of a relay of Ta: one of your own Cloudflare, or ta relay behind HTTPS.');
|
|
389
|
+
}
|
|
390
|
+
const probe = await RelayInfoUtil.probe(address);
|
|
391
|
+
if (!probe.online) {
|
|
392
|
+
throw TaErrors.invalidArgument(`${address} does not answer as a relay of Ta: ${(_a = probe.error) !== null && _a !== void 0 ? _a : 'no answer'}.`, 'Check the address, and that the relay runs.');
|
|
393
|
+
}
|
|
394
|
+
return this.relaysCall(() => this.bridge.relays.add(address, typeof name === 'string' ? name : undefined));
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
addFolder(path, name) {
|
|
398
|
+
return TaErrors.guard(async () => this.relaysCall(() => this.bridge.relays.addFolder(String(path !== null && path !== void 0 ? path : ''), typeof name === 'string' ? name : undefined)));
|
|
399
|
+
}
|
|
400
|
+
addStore(type, options, name) {
|
|
401
|
+
return TaErrors.guard(async () => {
|
|
402
|
+
const given = options && typeof options === 'object' ? options : {};
|
|
403
|
+
try {
|
|
404
|
+
return await this.bridge.addStore(String(type !== null && type !== void 0 ? type : ''), given, typeof name === 'string' ? name : undefined);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
if (error instanceof RelaysConfigError) {
|
|
408
|
+
throw TaErrors.invalidArgument(error.message, 'Check what you filled in, and that the package of the type is on.');
|
|
409
|
+
}
|
|
410
|
+
throw TaErrors.invalidArgument(`The store does not take a file: ${error instanceof Error ? error.message : String(error)}`, 'Check the address, the user and the password or keys.');
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
removeRelay(id) {
|
|
415
|
+
return TaErrors.guard(async () => this.relaysCall(() => this.bridge.relays.remove(String(id !== null && id !== void 0 ? id : ''))));
|
|
416
|
+
}
|
|
417
|
+
chooseRelay(feature, id) {
|
|
418
|
+
return TaErrors.guard(async () => {
|
|
419
|
+
if (!RELAY_FEATURES.includes(feature)) {
|
|
420
|
+
throw TaErrors.invalidArgument(`${feature} is not a feature that goes through a relay.`, `Pass one of ${RELAY_FEATURES.join(', ')}.`);
|
|
421
|
+
}
|
|
422
|
+
this.relaysCall(() => this.bridge.relays.use(feature, typeof id === 'string' && id ? id : undefined));
|
|
423
|
+
this.bridge.relaysChanged();
|
|
424
|
+
return this.bridge.listRelays();
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
async probeRelay(idOrUrl) {
|
|
428
|
+
var _a, _b, _c;
|
|
429
|
+
const text = String(idOrUrl !== null && idOrUrl !== void 0 ? idOrUrl : '');
|
|
430
|
+
const service = this.bridge.listRelays().relays.find(relay => relay.id === text);
|
|
431
|
+
if ((service === null || service === void 0 ? void 0 : service.type) === 'folder') {
|
|
432
|
+
const started = Date.now();
|
|
433
|
+
const problem = RelayServiceUtil.checkFolder((_a = service.path) !== null && _a !== void 0 ? _a : '');
|
|
434
|
+
return {
|
|
435
|
+
online: !problem,
|
|
436
|
+
capabilities: ['store'],
|
|
437
|
+
persistent: true,
|
|
438
|
+
path: RelayServiceUtil.expand((_b = service.path) !== null && _b !== void 0 ? _b : ''),
|
|
439
|
+
ms: Date.now() - started,
|
|
440
|
+
...(problem ? { error: problem } : {}),
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
if (service && service.type !== 'ta-relay') {
|
|
444
|
+
// A store of a package: whether it takes a file now.
|
|
445
|
+
try {
|
|
446
|
+
const ms = await RelayBridge.tryStore(this.bridge.openStore(service.id));
|
|
447
|
+
return { online: true, capabilities: ['store'], persistent: true, ms };
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
return { online: false, capabilities: ['store'], error: error instanceof Error ? error.message : String(error) };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const url = (_c = service === null || service === void 0 ? void 0 : service.url) !== null && _c !== void 0 ? _c : text;
|
|
454
|
+
const probe = await RelayInfoUtil.probe(url);
|
|
455
|
+
return {
|
|
456
|
+
online: probe.online,
|
|
457
|
+
...(probe.info ? { capabilities: probe.info.capabilities, limits: probe.info.limits, persistent: probe.info.persistent } : {}),
|
|
458
|
+
...(probe.legacy ? { legacy: true } : {}),
|
|
459
|
+
...(probe.ms !== undefined ? { ms: probe.ms } : {}),
|
|
460
|
+
...(probe.error ? { error: probe.error } : {}),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
/** A change of relays.json; what it refuses is said as the errors of Ta. */
|
|
464
|
+
relaysCall(change) {
|
|
465
|
+
try {
|
|
466
|
+
return change();
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
if (error instanceof RelaysConfigError) {
|
|
470
|
+
throw TaErrors.invalidArgument(error.message, `Fix ${this.bridge.relays.file} by hand, or choose otherwise.`);
|
|
471
|
+
}
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
218
475
|
};
|
|
219
476
|
__decorate([
|
|
220
477
|
Autowired(RELAY_BRIDGE),
|
|
@@ -228,6 +485,10 @@ __decorate([
|
|
|
228
485
|
Autowired(ExecEnvironmentFactory),
|
|
229
486
|
__metadata("design:type", Object)
|
|
230
487
|
], TaRelayServerImpl.prototype, "environments", void 0);
|
|
488
|
+
__decorate([
|
|
489
|
+
Autowired(KeepAwake),
|
|
490
|
+
__metadata("design:type", Object)
|
|
491
|
+
], TaRelayServerImpl.prototype, "keepAwake", void 0);
|
|
231
492
|
TaRelayServerImpl = __decorate([
|
|
232
493
|
Rpc(TaRelayServer)
|
|
233
494
|
], TaRelayServerImpl);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
2
2
|
import { type RpcConnection } from '@celljs/rpc/lib/node';
|
|
3
|
-
import { type TaFriend, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
3
|
+
import { type TaFriend, type TaFriendRequest, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
4
4
|
import type { RelayHubs } from '@celljs/ta-relay/lib/node';
|
|
5
5
|
import { type RelayBridge } from './relay-bridge.js';
|
|
6
6
|
/** The id of {@link RoomsBridge}. */
|
|
@@ -21,7 +21,7 @@ export declare class RoomsBridge implements ApplicationLifecycle<Application> {
|
|
|
21
21
|
/** `watch` undefined: no more. */
|
|
22
22
|
watch(connection: RpcConnection, watch: TaRoomWatch | undefined): void;
|
|
23
23
|
protected broadcast(event: TaRoomEvent): void;
|
|
24
|
-
protected static identity({ id, name }: TaIdentity): TaIdentity;
|
|
24
|
+
protected static identity({ id, name, shared }: TaIdentity): TaIdentity;
|
|
25
25
|
}
|
|
26
26
|
/** The rooms for clients (TaRoomServer): those of RoomsBridge, what goes wrong said as the errors of Ta. */
|
|
27
27
|
export declare class TaRoomServerImpl implements TaRoomServer {
|
|
@@ -34,6 +34,8 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
34
34
|
kind: string;
|
|
35
35
|
title: string;
|
|
36
36
|
view?: string;
|
|
37
|
+
unlisted?: boolean;
|
|
38
|
+
use?: string;
|
|
37
39
|
}): Promise<TaRoomInfo>;
|
|
38
40
|
invite(room: string, options?: {
|
|
39
41
|
days?: number;
|
|
@@ -54,7 +56,16 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
54
56
|
version: number;
|
|
55
57
|
}>;
|
|
56
58
|
listFriends(): Promise<TaFriend[]>;
|
|
59
|
+
friendLink(renew?: boolean): Promise<{
|
|
60
|
+
link: string;
|
|
61
|
+
expiresAt: number;
|
|
62
|
+
}>;
|
|
63
|
+
addFriend(link: string): Promise<void>;
|
|
64
|
+
offerFriend(room: string, member: string): Promise<void>;
|
|
65
|
+
listFriendRequests(): Promise<TaFriendRequest[]>;
|
|
66
|
+
answerFriend(id: string, accept: boolean): Promise<void>;
|
|
57
67
|
removeFriend(id: string): Promise<boolean>;
|
|
68
|
+
friendRoom(): Promise<TaRoomInfo>;
|
|
58
69
|
watch(messages?: boolean, state?: string[]): Promise<void>;
|
|
59
70
|
unwatch(): Promise<void>;
|
|
60
71
|
}
|
package/esm/node/rooms-bridge.js
CHANGED
|
@@ -39,9 +39,21 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
39
39
|
send: (room, data, to) => this.hubs.send(room, data, to),
|
|
40
40
|
getState: (room, prefix) => this.hubs.getState(room, prefix),
|
|
41
41
|
setState: (room, key, value, version) => this.hubs.setState(room, key, value, version),
|
|
42
|
-
listFriends: async () => this.hubs.
|
|
43
|
-
|
|
42
|
+
listFriends: async () => this.hubs.listFriends(),
|
|
43
|
+
friendLink: renew => this.hubs.friendLink(renew === true),
|
|
44
|
+
addFriend: link => this.hubs.addFriend(link),
|
|
45
|
+
offerFriend: (room, member) => this.hubs.offerFriend(room, member),
|
|
46
|
+
listFriendRequests: async () => this.hubs.friendRequests(),
|
|
47
|
+
answerFriend: (id, accept) => this.hubs.answerFriend(id, accept),
|
|
48
|
+
removeFriend: id => this.hubs.removeFriend(id),
|
|
49
|
+
friendRoom: () => this.hubs.friendRoom(),
|
|
44
50
|
onEvent: listener => this.hubs.onEvent(listener),
|
|
51
|
+
exportIdentity: async () => (await this.hubs.exportIdentity()),
|
|
52
|
+
importIdentity: (bundle, options) => this.hubs.importIdentity(bundle, options !== null && options !== void 0 ? options : {}),
|
|
53
|
+
setIdentityShared: shared => this.hubs.setShared(shared),
|
|
54
|
+
upsertRoom: async (record) => this.hubs.upsert(record),
|
|
55
|
+
forgetRoom: async (room, member) => this.hubs.forget(room, member),
|
|
56
|
+
mergeFriends: async (friends) => this.hubs.mergeFriends(friends),
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
59
|
get hubs() {
|
|
@@ -75,8 +87,8 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
|
-
static identity({ id, name }) {
|
|
79
|
-
return { id, name };
|
|
90
|
+
static identity({ id, name, shared }) {
|
|
91
|
+
return { id, name, ...(shared ? { shared } : {}) };
|
|
80
92
|
}
|
|
81
93
|
};
|
|
82
94
|
__decorate([
|
|
@@ -134,9 +146,27 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
134
146
|
listFriends() {
|
|
135
147
|
return TaErrors.guard(() => this.rooms.listFriends());
|
|
136
148
|
}
|
|
149
|
+
friendLink(renew) {
|
|
150
|
+
return TaErrors.guard(() => this.rooms.friendLink(renew === true));
|
|
151
|
+
}
|
|
152
|
+
addFriend(link) {
|
|
153
|
+
return TaErrors.guard(() => this.rooms.addFriend(link));
|
|
154
|
+
}
|
|
155
|
+
offerFriend(room, member) {
|
|
156
|
+
return TaErrors.guard(() => this.rooms.offerFriend(room, member));
|
|
157
|
+
}
|
|
158
|
+
listFriendRequests() {
|
|
159
|
+
return TaErrors.guard(() => this.rooms.listFriendRequests());
|
|
160
|
+
}
|
|
161
|
+
answerFriend(id, accept) {
|
|
162
|
+
return TaErrors.guard(() => this.rooms.answerFriend(id, accept === true));
|
|
163
|
+
}
|
|
137
164
|
removeFriend(id) {
|
|
138
165
|
return TaErrors.guard(() => this.rooms.removeFriend(id));
|
|
139
166
|
}
|
|
167
|
+
friendRoom() {
|
|
168
|
+
return TaErrors.guard(() => this.rooms.friendRoom());
|
|
169
|
+
}
|
|
140
170
|
async watch(messages, state) {
|
|
141
171
|
this.bridge.watch(RpcContext.requireConnection(), TaRoomWatchUtil.of(messages !== null && messages !== void 0 ? messages : undefined, state));
|
|
142
172
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
2
|
-
import type
|
|
2
|
+
import { type TaSavedSessionInfo, type TaSavedSessionQuery } from '@celljs/ta-protocol';
|
|
3
3
|
import { TaSessionCatalog } from './host-protocol.js';
|
|
4
4
|
import { PiDirectories } from './remote/remote-protocol.js';
|
|
5
5
|
/** What a list shows of a session file, with the directory pi worked in, before it is a location. */
|
|
@@ -11,6 +11,7 @@ import { readdir, readFile, stat } from 'node:fs/promises';
|
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
import { CODING_AGENT_OPTIONS, PiSdkUtil } from '@celljs/ai-coding-agent';
|
|
13
13
|
import { Autowired, Component, Value } from '@celljs/core';
|
|
14
|
+
import { TaAskUtil } from '@celljs/ta-protocol';
|
|
14
15
|
import { TaSessionCatalog } from './host-protocol.js';
|
|
15
16
|
import { PiDirectories } from './remote/remote-protocol.js';
|
|
16
17
|
import { SessionInfoUtil } from './session-info-util.js';
|
|
@@ -78,6 +79,7 @@ export var SessionCatalogUtil;
|
|
|
78
79
|
let messageCount = 0;
|
|
79
80
|
let updatedAt;
|
|
80
81
|
const marks = [];
|
|
82
|
+
let asking;
|
|
81
83
|
for (const line of text.split('\n')) {
|
|
82
84
|
const entry = parse(line);
|
|
83
85
|
if (!entry) {
|
|
@@ -95,12 +97,14 @@ export var SessionCatalogUtil;
|
|
|
95
97
|
}
|
|
96
98
|
else if (entry.type === 'custom') {
|
|
97
99
|
marks.push(entry);
|
|
100
|
+
asking = TaAskUtil.next(asking, entry);
|
|
98
101
|
}
|
|
99
102
|
else if (entry.type === 'message' && entry.message && typeof entry.message === 'object') {
|
|
100
103
|
const message = entry.message;
|
|
101
104
|
messageCount++;
|
|
102
105
|
firstMessage !== null && firstMessage !== void 0 ? firstMessage : (firstMessage = SessionInfoUtil.firstMessage([message]));
|
|
103
106
|
messages.push(message);
|
|
107
|
+
asking = TaAskUtil.next(asking, { type: 'message', message });
|
|
104
108
|
if (typeof message.timestamp === 'number') {
|
|
105
109
|
updatedAt = Math.max(updatedAt !== null && updatedAt !== void 0 ? updatedAt : 0, message.timestamp);
|
|
106
110
|
}
|
|
@@ -121,6 +125,7 @@ export var SessionCatalogUtil;
|
|
|
121
125
|
createdAt,
|
|
122
126
|
updatedAt: updatedAt !== null && updatedAt !== void 0 ? updatedAt : createdAt,
|
|
123
127
|
group: groupOf(marks),
|
|
128
|
+
asking,
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
131
|
SessionCatalogUtil.summarize = summarize;
|
|
@@ -17,10 +17,20 @@ interface Watcher {
|
|
|
17
17
|
export declare class SessionListFeed {
|
|
18
18
|
protected readonly list: () => TaSessionInfo[];
|
|
19
19
|
protected readonly intervalMs: number;
|
|
20
|
+
/** What a connection may see of the list: all of it, but for those let in (docs/design/ta-team.md). */
|
|
21
|
+
protected readonly filter: (connection: RpcConnection, list: TaSessionInfo[]) => TaSessionInfo[];
|
|
20
22
|
protected readonly watchers: Map<RpcConnection, Watcher>;
|
|
21
|
-
|
|
23
|
+
/** `Date.now()` time the last connection stopped watching; 0 for none yet. */
|
|
24
|
+
protected leftAt: number;
|
|
25
|
+
constructor(list: () => TaSessionInfo[], intervalMs?: number,
|
|
26
|
+
/** What a connection may see of the list: all of it, but for those let in (docs/design/ta-team.md). */
|
|
27
|
+
filter?: (connection: RpcConnection, list: TaSessionInfo[]) => TaSessionInfo[]);
|
|
22
28
|
/** The list now; the connection is told of each change from now on, until it closes. */
|
|
23
29
|
watch(connection: RpcConnection): TaSessionInfo[];
|
|
30
|
+
/** The connections watching now. */
|
|
31
|
+
get watching(): number;
|
|
32
|
+
/** `Date.now()` time a connection last watched: now while one does; 0 for never. */
|
|
33
|
+
get watchedAt(): number;
|
|
24
34
|
/** What a list shows changed: a session opened or closed, or one of them changed. */
|
|
25
35
|
changed(): void;
|
|
26
36
|
protected schedule(connection: RpcConnection, watcher: Watcher): void;
|