@celljs/ta-client 4.17.0 → 4.19.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/session-reducer.d.ts +5 -0
- package/esm/common/session-store.js +5 -1
- package/esm/common/ta-connection.d.ts +10 -2
- package/esm/common/ta-connection.js +29 -5
- package/lib/common/session-reducer.d.ts +5 -0
- package/lib/common/session-store.js +5 -1
- package/lib/common/ta-connection.d.ts +10 -2
- package/lib/common/ta-connection.js +28 -4
- package/package.json +2 -2
|
@@ -66,6 +66,11 @@ export interface SessionState {
|
|
|
66
66
|
retry?: RetryState;
|
|
67
67
|
/** What an extension says the agent does while it works (pi's `setWorkingMessage`). */
|
|
68
68
|
workingMessage?: string;
|
|
69
|
+
/**
|
|
70
|
+
* False while the state is not the session's of now: read from what this device kept, or of a store detached. How
|
|
71
|
+
* its last turn ended may be over (the agent went on since); undefined for a state that never was the session's.
|
|
72
|
+
*/
|
|
73
|
+
synced?: boolean;
|
|
69
74
|
/** Which of the last `messages` this client sent that the session does not have yet (SessionStore.send). */
|
|
70
75
|
outbox?: readonly OutboxMessage[];
|
|
71
76
|
}
|
|
@@ -29,7 +29,7 @@ export class SessionStore extends SessionClientTools {
|
|
|
29
29
|
this.holdMs = (_b = options.holdMs) !== null && _b !== void 0 ? _b : HOLD_MS;
|
|
30
30
|
if (options.initial) {
|
|
31
31
|
const { messages, start, tools } = options.initial;
|
|
32
|
-
this.current = this.shown = { ...this.current, messages, start, tools };
|
|
32
|
+
this.current = this.shown = { ...this.current, messages, start, tools, synced: false };
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
get state() {
|
|
@@ -53,6 +53,9 @@ export class SessionStore extends SessionClientTools {
|
|
|
53
53
|
for (const stop of this.stop.splice(0)) {
|
|
54
54
|
stop();
|
|
55
55
|
}
|
|
56
|
+
// Not through `update`: what it shows changes, the calls it runs do not.
|
|
57
|
+
this.current = { ...this.current, synced: false };
|
|
58
|
+
this.show();
|
|
56
59
|
await this.connection.server.detach(this.sessionId);
|
|
57
60
|
}
|
|
58
61
|
subscribe(listener) {
|
|
@@ -293,6 +296,7 @@ export class SessionStore extends SessionClientTools {
|
|
|
293
296
|
pendingUi: result.pendingUi,
|
|
294
297
|
pendingClientTools: result.pendingClientTools,
|
|
295
298
|
working: result.info.isStreaming,
|
|
299
|
+
synced: true,
|
|
296
300
|
};
|
|
297
301
|
if (result.shownUi) {
|
|
298
302
|
// What the extensions show now, whatever events were missed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
1
|
+
import { type TaAccessServer, type TaAccountServer, type TaAuthEvent, type TaAuthServer, type TaDesktopEvent, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaScreenShareServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
2
2
|
import type { TaConnectionOptions, TaSocket } from './ta-connection-options.js';
|
|
3
3
|
interface PendingCall {
|
|
4
4
|
resolve(result: unknown): void;
|
|
@@ -56,7 +56,11 @@ export declare class TaConnection {
|
|
|
56
56
|
/** Behind `ta gateway` only: a Ta service alone does not have it. */
|
|
57
57
|
readonly gateway: TaGatewayServer;
|
|
58
58
|
readonly relay: TaRelayServer;
|
|
59
|
+
/** The user's account and its devices (docs/design/ta-account.md). */
|
|
60
|
+
readonly account: TaAccountServer;
|
|
59
61
|
readonly remote: TaRemoteServer;
|
|
62
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
63
|
+
readonly screenShare: TaScreenShareServer;
|
|
60
64
|
readonly rooms: TaRoomServer;
|
|
61
65
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
62
66
|
readonly presence: TaPresenceServer;
|
|
@@ -77,6 +81,7 @@ export declare class TaConnection {
|
|
|
77
81
|
protected readonly remoteListeners: Set<RemoteEventListener>;
|
|
78
82
|
protected readonly roomListeners: Set<RoomEventListener>;
|
|
79
83
|
protected readonly voiceListeners: Set<VoiceEventListener>;
|
|
84
|
+
protected readonly desktopListeners: Set<(event: TaDesktopEvent) => void>;
|
|
80
85
|
protected pageAsk?: PageAskHandler;
|
|
81
86
|
protected readonly sessionsListeners: Set<SessionsListener>;
|
|
82
87
|
protected readonly openListeners: Set<OpenListener>;
|
|
@@ -110,6 +115,8 @@ export declare class TaConnection {
|
|
|
110
115
|
/** What the voices this connection opened tell (TaVoiceServer.openVoice). */
|
|
111
116
|
/** Answers what ta serve asks this page (TaClient.onPageAsk): one handler, the last set; without one, an error. */
|
|
112
117
|
onPageAsk(handler: PageAskHandler | undefined): void;
|
|
118
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
119
|
+
onScreenShareEvent(listener: (event: TaDesktopEvent) => void): () => void;
|
|
113
120
|
onVoiceEvent(listener: VoiceEventListener): () => void;
|
|
114
121
|
/** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
|
|
115
122
|
onSessions(listener: SessionsListener): () => void;
|
|
@@ -138,7 +145,8 @@ export declare class TaConnection {
|
|
|
138
145
|
protected service<T extends object>(name: string): T;
|
|
139
146
|
/**
|
|
140
147
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
141
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
148
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
149
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
142
150
|
*/
|
|
143
151
|
static resendable(service: string, method: string, params: readonly unknown[]): boolean;
|
|
144
152
|
protected call(service: string, method: string, params: unknown[]): Promise<unknown>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_PAGE_SERVICE, TA_PRESENCE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_ROOM_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_VOICE_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
|
|
1
|
+
import { TA_ACCESS_SERVICE, TA_ACCOUNT_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_PAGE_SERVICE, TA_PRESENCE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_ROOM_SERVICE, TA_SCREEN_SHARE_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_VOICE_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
|
|
2
2
|
import { TaRemoteError } from './ta-remote-error.js';
|
|
3
3
|
/** Methods that only read: sent again after a lost connection. */
|
|
4
4
|
const READ_METHOD = /^(get|list|read|find)[A-Z]/;
|
|
5
5
|
/** Methods whose input carries a clientMessageId, by which ta serve takes a message once however often it comes. */
|
|
6
6
|
const MESSAGE_METHODS = new Set(['prompt', 'steer', 'followUp']);
|
|
7
|
+
/** Calls of TaScreenShareServer that ta serve takes once (an id, a seq, a revision), so that they may go again. */
|
|
8
|
+
const DESKTOP_ONCE = new Set(['openDesktop', 'pasteToDesktop', 'sendDesktopInput', 'setDesktopView']);
|
|
7
9
|
/**
|
|
8
10
|
* A connection to `ta serve` on the `WebSocket` of the platform, with no other dependency, so that it
|
|
9
11
|
* fits a browser, Electron or a mobile app. It reconnects until closed; `onOpen` runs each time, for
|
|
@@ -30,7 +32,11 @@ export class TaConnection {
|
|
|
30
32
|
/** Behind `ta gateway` only: a Ta service alone does not have it. */
|
|
31
33
|
this.gateway = this.service(TA_GATEWAY_SERVICE);
|
|
32
34
|
this.relay = this.service(TA_RELAY_SERVICE);
|
|
35
|
+
/** The user's account and its devices (docs/design/ta-account.md). */
|
|
36
|
+
this.account = this.service(TA_ACCOUNT_SERVICE);
|
|
33
37
|
this.remote = this.service(TA_REMOTE_SERVICE);
|
|
38
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
39
|
+
this.screenShare = this.service(TA_SCREEN_SHARE_SERVICE);
|
|
34
40
|
this.rooms = this.service(TA_ROOM_SERVICE);
|
|
35
41
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
36
42
|
this.presence = this.service(TA_PRESENCE_SERVICE);
|
|
@@ -49,6 +55,7 @@ export class TaConnection {
|
|
|
49
55
|
this.remoteListeners = new Set();
|
|
50
56
|
this.roomListeners = new Set();
|
|
51
57
|
this.voiceListeners = new Set();
|
|
58
|
+
this.desktopListeners = new Set();
|
|
52
59
|
this.sessionsListeners = new Set();
|
|
53
60
|
this.openListeners = new Set();
|
|
54
61
|
this.closeListeners = new Set();
|
|
@@ -107,6 +114,11 @@ export class TaConnection {
|
|
|
107
114
|
onPageAsk(handler) {
|
|
108
115
|
this.pageAsk = handler;
|
|
109
116
|
}
|
|
117
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
118
|
+
onScreenShareEvent(listener) {
|
|
119
|
+
this.desktopListeners.add(listener);
|
|
120
|
+
return () => this.desktopListeners.delete(listener);
|
|
121
|
+
}
|
|
110
122
|
onVoiceEvent(listener) {
|
|
111
123
|
this.voiceListeners.add(listener);
|
|
112
124
|
return () => this.voiceListeners.delete(listener);
|
|
@@ -285,13 +297,17 @@ export class TaConnection {
|
|
|
285
297
|
}
|
|
286
298
|
/**
|
|
287
299
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
288
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
300
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
301
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
289
302
|
*/
|
|
290
303
|
static resendable(service, method, params) {
|
|
291
304
|
var _a;
|
|
292
305
|
if (READ_METHOD.test(method)) {
|
|
293
306
|
return true;
|
|
294
307
|
}
|
|
308
|
+
if (service === TA_SCREEN_SHARE_SERVICE) {
|
|
309
|
+
return DESKTOP_ONCE.has(method);
|
|
310
|
+
}
|
|
295
311
|
return service === TA_SERVER_SERVICE && MESSAGE_METHODS.has(method) && !!((_a = params[1]) === null || _a === void 0 ? void 0 : _a.clientMessageId);
|
|
296
312
|
}
|
|
297
313
|
async call(service, method, params) {
|
|
@@ -374,7 +390,7 @@ export class TaConnection {
|
|
|
374
390
|
}
|
|
375
391
|
}
|
|
376
392
|
receive(text) {
|
|
377
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
393
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
378
394
|
this.lastReceivedAt = Date.now();
|
|
379
395
|
const message = JSON.parse(text);
|
|
380
396
|
if (message.method === `${TA_CLIENT_SERVICE}/onEvents`) {
|
|
@@ -426,12 +442,20 @@ export class TaConnection {
|
|
|
426
442
|
(_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
427
443
|
return;
|
|
428
444
|
}
|
|
445
|
+
if (message.method === `${TA_CLIENT_SERVICE}/onScreenShareEvent`) {
|
|
446
|
+
const [event] = message.params;
|
|
447
|
+
for (const listener of this.desktopListeners) {
|
|
448
|
+
listener(event);
|
|
449
|
+
}
|
|
450
|
+
(_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
429
453
|
if (message.method === `${TA_CLIENT_SERVICE}/onVoiceEvent`) {
|
|
430
454
|
const [event] = message.params;
|
|
431
455
|
for (const listener of this.voiceListeners) {
|
|
432
456
|
listener(event);
|
|
433
457
|
}
|
|
434
|
-
(
|
|
458
|
+
(_h = this.socket) === null || _h === void 0 ? void 0 : _h.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
435
459
|
return;
|
|
436
460
|
}
|
|
437
461
|
if (message.method === `${TA_CLIENT_SERVICE}/onPageAsk`) {
|
|
@@ -444,7 +468,7 @@ export class TaConnection {
|
|
|
444
468
|
for (const listener of this.extensionDataListeners) {
|
|
445
469
|
listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
|
|
446
470
|
}
|
|
447
|
-
(
|
|
471
|
+
(_j = this.socket) === null || _j === void 0 ? void 0 : _j.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
448
472
|
return;
|
|
449
473
|
}
|
|
450
474
|
const call = this.pending.get(message.id);
|
|
@@ -66,6 +66,11 @@ export interface SessionState {
|
|
|
66
66
|
retry?: RetryState;
|
|
67
67
|
/** What an extension says the agent does while it works (pi's `setWorkingMessage`). */
|
|
68
68
|
workingMessage?: string;
|
|
69
|
+
/**
|
|
70
|
+
* False while the state is not the session's of now: read from what this device kept, or of a store detached. How
|
|
71
|
+
* its last turn ended may be over (the agent went on since); undefined for a state that never was the session's.
|
|
72
|
+
*/
|
|
73
|
+
synced?: boolean;
|
|
69
74
|
/** Which of the last `messages` this client sent that the session does not have yet (SessionStore.send). */
|
|
70
75
|
outbox?: readonly OutboxMessage[];
|
|
71
76
|
}
|
|
@@ -32,7 +32,7 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
32
32
|
this.holdMs = (_b = options.holdMs) !== null && _b !== void 0 ? _b : session_store_options_1.HOLD_MS;
|
|
33
33
|
if (options.initial) {
|
|
34
34
|
const { messages, start, tools } = options.initial;
|
|
35
|
-
this.current = this.shown = { ...this.current, messages, start, tools };
|
|
35
|
+
this.current = this.shown = { ...this.current, messages, start, tools, synced: false };
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
get state() {
|
|
@@ -56,6 +56,9 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
56
56
|
for (const stop of this.stop.splice(0)) {
|
|
57
57
|
stop();
|
|
58
58
|
}
|
|
59
|
+
// Not through `update`: what it shows changes, the calls it runs do not.
|
|
60
|
+
this.current = { ...this.current, synced: false };
|
|
61
|
+
this.show();
|
|
59
62
|
await this.connection.server.detach(this.sessionId);
|
|
60
63
|
}
|
|
61
64
|
subscribe(listener) {
|
|
@@ -296,6 +299,7 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
296
299
|
pendingUi: result.pendingUi,
|
|
297
300
|
pendingClientTools: result.pendingClientTools,
|
|
298
301
|
working: result.info.isStreaming,
|
|
302
|
+
synced: true,
|
|
299
303
|
};
|
|
300
304
|
if (result.shownUi) {
|
|
301
305
|
// What the extensions show now, whatever events were missed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
1
|
+
import { type TaAccessServer, type TaAccountServer, type TaAuthEvent, type TaAuthServer, type TaDesktopEvent, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaScreenShareServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
2
2
|
import type { TaConnectionOptions, TaSocket } from './ta-connection-options';
|
|
3
3
|
interface PendingCall {
|
|
4
4
|
resolve(result: unknown): void;
|
|
@@ -56,7 +56,11 @@ export declare class TaConnection {
|
|
|
56
56
|
/** Behind `ta gateway` only: a Ta service alone does not have it. */
|
|
57
57
|
readonly gateway: TaGatewayServer;
|
|
58
58
|
readonly relay: TaRelayServer;
|
|
59
|
+
/** The user's account and its devices (docs/design/ta-account.md). */
|
|
60
|
+
readonly account: TaAccountServer;
|
|
59
61
|
readonly remote: TaRemoteServer;
|
|
62
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
63
|
+
readonly screenShare: TaScreenShareServer;
|
|
60
64
|
readonly rooms: TaRoomServer;
|
|
61
65
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
62
66
|
readonly presence: TaPresenceServer;
|
|
@@ -77,6 +81,7 @@ export declare class TaConnection {
|
|
|
77
81
|
protected readonly remoteListeners: Set<RemoteEventListener>;
|
|
78
82
|
protected readonly roomListeners: Set<RoomEventListener>;
|
|
79
83
|
protected readonly voiceListeners: Set<VoiceEventListener>;
|
|
84
|
+
protected readonly desktopListeners: Set<(event: TaDesktopEvent) => void>;
|
|
80
85
|
protected pageAsk?: PageAskHandler;
|
|
81
86
|
protected readonly sessionsListeners: Set<SessionsListener>;
|
|
82
87
|
protected readonly openListeners: Set<OpenListener>;
|
|
@@ -110,6 +115,8 @@ export declare class TaConnection {
|
|
|
110
115
|
/** What the voices this connection opened tell (TaVoiceServer.openVoice). */
|
|
111
116
|
/** Answers what ta serve asks this page (TaClient.onPageAsk): one handler, the last set; without one, an error. */
|
|
112
117
|
onPageAsk(handler: PageAskHandler | undefined): void;
|
|
118
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
119
|
+
onScreenShareEvent(listener: (event: TaDesktopEvent) => void): () => void;
|
|
113
120
|
onVoiceEvent(listener: VoiceEventListener): () => void;
|
|
114
121
|
/** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
|
|
115
122
|
onSessions(listener: SessionsListener): () => void;
|
|
@@ -138,7 +145,8 @@ export declare class TaConnection {
|
|
|
138
145
|
protected service<T extends object>(name: string): T;
|
|
139
146
|
/**
|
|
140
147
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
141
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
148
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
149
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
142
150
|
*/
|
|
143
151
|
static resendable(service: string, method: string, params: readonly unknown[]): boolean;
|
|
144
152
|
protected call(service: string, method: string, params: unknown[]): Promise<unknown>;
|
|
@@ -7,6 +7,8 @@ const ta_remote_error_1 = require("./ta-remote-error");
|
|
|
7
7
|
const READ_METHOD = /^(get|list|read|find)[A-Z]/;
|
|
8
8
|
/** Methods whose input carries a clientMessageId, by which ta serve takes a message once however often it comes. */
|
|
9
9
|
const MESSAGE_METHODS = new Set(['prompt', 'steer', 'followUp']);
|
|
10
|
+
/** Calls of TaScreenShareServer that ta serve takes once (an id, a seq, a revision), so that they may go again. */
|
|
11
|
+
const DESKTOP_ONCE = new Set(['openDesktop', 'pasteToDesktop', 'sendDesktopInput', 'setDesktopView']);
|
|
10
12
|
/**
|
|
11
13
|
* A connection to `ta serve` on the `WebSocket` of the platform, with no other dependency, so that it
|
|
12
14
|
* fits a browser, Electron or a mobile app. It reconnects until closed; `onOpen` runs each time, for
|
|
@@ -33,7 +35,11 @@ class TaConnection {
|
|
|
33
35
|
/** Behind `ta gateway` only: a Ta service alone does not have it. */
|
|
34
36
|
this.gateway = this.service(ta_protocol_1.TA_GATEWAY_SERVICE);
|
|
35
37
|
this.relay = this.service(ta_protocol_1.TA_RELAY_SERVICE);
|
|
38
|
+
/** The user's account and its devices (docs/design/ta-account.md). */
|
|
39
|
+
this.account = this.service(ta_protocol_1.TA_ACCOUNT_SERVICE);
|
|
36
40
|
this.remote = this.service(ta_protocol_1.TA_REMOTE_SERVICE);
|
|
41
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
42
|
+
this.screenShare = this.service(ta_protocol_1.TA_SCREEN_SHARE_SERVICE);
|
|
37
43
|
this.rooms = this.service(ta_protocol_1.TA_ROOM_SERVICE);
|
|
38
44
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
39
45
|
this.presence = this.service(ta_protocol_1.TA_PRESENCE_SERVICE);
|
|
@@ -52,6 +58,7 @@ class TaConnection {
|
|
|
52
58
|
this.remoteListeners = new Set();
|
|
53
59
|
this.roomListeners = new Set();
|
|
54
60
|
this.voiceListeners = new Set();
|
|
61
|
+
this.desktopListeners = new Set();
|
|
55
62
|
this.sessionsListeners = new Set();
|
|
56
63
|
this.openListeners = new Set();
|
|
57
64
|
this.closeListeners = new Set();
|
|
@@ -110,6 +117,11 @@ class TaConnection {
|
|
|
110
117
|
onPageAsk(handler) {
|
|
111
118
|
this.pageAsk = handler;
|
|
112
119
|
}
|
|
120
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
121
|
+
onScreenShareEvent(listener) {
|
|
122
|
+
this.desktopListeners.add(listener);
|
|
123
|
+
return () => this.desktopListeners.delete(listener);
|
|
124
|
+
}
|
|
113
125
|
onVoiceEvent(listener) {
|
|
114
126
|
this.voiceListeners.add(listener);
|
|
115
127
|
return () => this.voiceListeners.delete(listener);
|
|
@@ -288,13 +300,17 @@ class TaConnection {
|
|
|
288
300
|
}
|
|
289
301
|
/**
|
|
290
302
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
291
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
303
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
304
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
292
305
|
*/
|
|
293
306
|
static resendable(service, method, params) {
|
|
294
307
|
var _a;
|
|
295
308
|
if (READ_METHOD.test(method)) {
|
|
296
309
|
return true;
|
|
297
310
|
}
|
|
311
|
+
if (service === ta_protocol_1.TA_SCREEN_SHARE_SERVICE) {
|
|
312
|
+
return DESKTOP_ONCE.has(method);
|
|
313
|
+
}
|
|
298
314
|
return service === ta_protocol_1.TA_SERVER_SERVICE && MESSAGE_METHODS.has(method) && !!((_a = params[1]) === null || _a === void 0 ? void 0 : _a.clientMessageId);
|
|
299
315
|
}
|
|
300
316
|
async call(service, method, params) {
|
|
@@ -377,7 +393,7 @@ class TaConnection {
|
|
|
377
393
|
}
|
|
378
394
|
}
|
|
379
395
|
receive(text) {
|
|
380
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
396
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
381
397
|
this.lastReceivedAt = Date.now();
|
|
382
398
|
const message = JSON.parse(text);
|
|
383
399
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onEvents`) {
|
|
@@ -429,12 +445,20 @@ class TaConnection {
|
|
|
429
445
|
(_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
430
446
|
return;
|
|
431
447
|
}
|
|
448
|
+
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onScreenShareEvent`) {
|
|
449
|
+
const [event] = message.params;
|
|
450
|
+
for (const listener of this.desktopListeners) {
|
|
451
|
+
listener(event);
|
|
452
|
+
}
|
|
453
|
+
(_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
432
456
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onVoiceEvent`) {
|
|
433
457
|
const [event] = message.params;
|
|
434
458
|
for (const listener of this.voiceListeners) {
|
|
435
459
|
listener(event);
|
|
436
460
|
}
|
|
437
|
-
(
|
|
461
|
+
(_h = this.socket) === null || _h === void 0 ? void 0 : _h.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
438
462
|
return;
|
|
439
463
|
}
|
|
440
464
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onPageAsk`) {
|
|
@@ -447,7 +471,7 @@ class TaConnection {
|
|
|
447
471
|
for (const listener of this.extensionDataListeners) {
|
|
448
472
|
listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
|
|
449
473
|
}
|
|
450
|
-
(
|
|
474
|
+
(_j = this.socket) === null || _j === void 0 ? void 0 : _j.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
451
475
|
return;
|
|
452
476
|
}
|
|
453
477
|
const call = this.pending.get(message.id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.0",
|
|
4
4
|
"description": "A client of ta serve for any JavaScript runtime: connection and UI-independent session state",
|
|
5
5
|
"homepage": "https://github.com/cellbang/ta",
|
|
6
6
|
"bugs": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@celljs/ta-protocol": "4.
|
|
32
|
+
"@celljs/ta-protocol": "4.19.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@earendil-works/pi-ai": "^1.5.2",
|