@celljs/ta-client 4.10.0 → 4.11.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.
@@ -82,8 +82,13 @@ export declare class SessionStore {
82
82
  protected readonly resending: Set<Sent>;
83
83
  constructor(connection: SessionConnection, sessionId: string, options?: SessionStoreOptions);
84
84
  get state(): SessionState;
85
- /** Starts following the session. */
86
- attach(): Promise<TaSessionInfo>;
85
+ /** The conversation as the session has it, without the messages sent from here on their way: for another store of it to start from. */
86
+ get snapshot(): SessionSnapshot;
87
+ /**
88
+ * Starts following the session; `attached`: what opening it attached already (TaOpenedSession.attached),
89
+ * taken at once, in the same turn of the event loop as its answer, so that no event after it is missed.
90
+ */
91
+ attach(attached?: TaAttachResult): Promise<TaSessionInfo>;
87
92
  /** Stops following it. The session goes on. */
88
93
  detach(): Promise<void>;
89
94
  subscribe(listener: Listener): () => void;
@@ -138,7 +143,7 @@ export declare class SessionStore {
138
143
  */
139
144
  onGone(listener: () => void): () => void;
140
145
  respondUi(response: RpcExtensionUIResponse): Promise<boolean>;
141
- protected attachAgain(): Promise<TaAttachResult>;
146
+ protected attachAgain(attached?: TaAttachResult): Promise<TaAttachResult>;
142
147
  /**
143
148
  * The latest messages, after the earlier ones the store had if they are still the same where the
144
149
  * latest start: a reconnect does not drop what was loaded further up.
@@ -40,10 +40,18 @@ export class SessionStore {
40
40
  get state() {
41
41
  return this.shown;
42
42
  }
43
- /** Starts following the session. */
44
- async attach() {
43
+ /** The conversation as the session has it, without the messages sent from here on their way: for another store of it to start from. */
44
+ get snapshot() {
45
+ const { messages, start, tools } = this.current;
46
+ return { messages, start, tools };
47
+ }
48
+ /**
49
+ * Starts following the session; `attached`: what opening it attached already (TaOpenedSession.attached),
50
+ * taken at once, in the same turn of the event loop as its answer, so that no event after it is missed.
51
+ */
52
+ async attach(attached) {
45
53
  this.stop.push(this.connection.onEvents(events => this.apply(events)), this.connection.onOpen(() => void this.attachAgain().catch(error => this.lost(error))));
46
- return (await this.attachAgain()).info;
54
+ return (await this.attachAgain(attached)).info;
47
55
  }
48
56
  /** Stops following it. The session goes on. */
49
57
  async detach() {
@@ -261,11 +269,12 @@ export class SessionStore {
261
269
  respondUi(response) {
262
270
  return this.connection.server.respondUi(this.sessionId, response);
263
271
  }
264
- async attachAgain() {
272
+ async attachAgain(attached) {
265
273
  var _a, _b;
266
- const result = await this.connection.server.attach(this.sessionId, this.lastSeq, this.pageBytes ? { recentBytes: this.pageBytes } : undefined);
274
+ const result = attached !== null && attached !== void 0 ? attached : (await this.connection.server.attach(this.sessionId, this.lastSeq, this.pageBytes ? { recentBytes: this.pageBytes } : undefined));
267
275
  let state = this.current;
268
- if (this.lastSeq === undefined || result.gap) {
276
+ // A conversation given (one attached as it opened) is the session's from scratch, whatever this store had.
277
+ if (this.lastSeq === undefined || result.gap || (attached === null || attached === void 0 ? void 0 : attached.conversation)) {
269
278
  // The conversation as of lastSeq, with the message being written and the calls running.
270
279
  const conversation = (_a = result.conversation) !== null && _a !== void 0 ? _a : { ...(await this.connection.server.getMessages(this.sessionId)), tools: {} };
271
280
  const { messages, start } = SessionStore.withEarlier(this.current, conversation.messages, (_b = conversation.start) !== null && _b !== void 0 ? _b : 0);
@@ -1,4 +1,4 @@
1
- import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, TaErrorCode, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaServer, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
1
+ import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, TaErrorCode, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
2
2
  /**
3
3
  * A failed call. `code` is set for failures the server names; `rpcCode` is the code of JSON-RPC's error,
4
4
  * by which a client tells a method an older ta serve does not have (`TaRemoteError.METHOD_NOT_FOUND`).
@@ -87,6 +87,8 @@ type TerminalListener = (terminalId: string, data: string, exitCode?: number) =>
87
87
  type ExtensionDataListener = (name: string, keys: string[], cwd?: string) => void;
88
88
  type AuthEventListener = (loginId: string, event: TaAuthEvent) => void;
89
89
  type RemoteEventListener = (event: TaRemoteEvent) => void;
90
+ type RoomEventListener = (event: TaRoomEvent) => void;
91
+ type SessionsListener = (sessions: TaSessionInfo[]) => void;
90
92
  type OpenListener = () => void;
91
93
  type CloseListener = () => void;
92
94
  type ReconnectingListener = (delayMs: number, attempt: number) => void;
@@ -116,6 +118,7 @@ export declare class TaConnection {
116
118
  readonly gateway: TaGatewayServer;
117
119
  readonly relay: TaRelayServer;
118
120
  readonly remote: TaRemoteServer;
121
+ readonly rooms: TaRoomServer;
119
122
  protected socket?: TaSocket;
120
123
  protected closed: boolean;
121
124
  protected attempts: number;
@@ -127,6 +130,8 @@ export declare class TaConnection {
127
130
  protected readonly extensionDataListeners: Set<ExtensionDataListener>;
128
131
  protected readonly authListeners: Set<AuthEventListener>;
129
132
  protected readonly remoteListeners: Set<RemoteEventListener>;
133
+ protected readonly roomListeners: Set<RoomEventListener>;
134
+ protected readonly sessionsListeners: Set<SessionsListener>;
130
135
  protected readonly openListeners: Set<OpenListener>;
131
136
  protected readonly closeListeners: Set<CloseListener>;
132
137
  protected readonly reconnectingListeners: Set<ReconnectingListener>;
@@ -153,6 +158,10 @@ export declare class TaConnection {
153
158
  onAuthEvent(listener: AuthEventListener): () => void;
154
159
  /** What happens with the remote machines, once this connection called TaRemoteServer.watch. */
155
160
  onRemoteEvent(listener: RemoteEventListener): () => void;
161
+ /** What happens in the rooms, once this connection called TaRoomServer.watch. */
162
+ onRoomEvent(listener: RoomEventListener): () => void;
163
+ /** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
164
+ onSessions(listener: SessionsListener): () => void;
156
165
  onOpen(listener: OpenListener): () => void;
157
166
  /** Runs each time an open connection is lost; it reconnects unless closed. */
158
167
  onClose(listener: CloseListener): () => void;
@@ -1,4 +1,4 @@
1
- import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
1
+ import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_ROOM_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
2
2
  /**
3
3
  * A failed call. `code` is set for failures the server names; `rpcCode` is the code of JSON-RPC's error,
4
4
  * by which a client tells a method an older ta serve does not have (`TaRemoteError.METHOD_NOT_FOUND`).
@@ -73,6 +73,7 @@ export class TaConnection {
73
73
  this.gateway = this.service(TA_GATEWAY_SERVICE);
74
74
  this.relay = this.service(TA_RELAY_SERVICE);
75
75
  this.remote = this.service(TA_REMOTE_SERVICE);
76
+ this.rooms = this.service(TA_ROOM_SERVICE);
76
77
  this.closed = false;
77
78
  this.attempts = 0;
78
79
  this.nextId = 0;
@@ -82,6 +83,8 @@ export class TaConnection {
82
83
  this.extensionDataListeners = new Set();
83
84
  this.authListeners = new Set();
84
85
  this.remoteListeners = new Set();
86
+ this.roomListeners = new Set();
87
+ this.sessionsListeners = new Set();
85
88
  this.openListeners = new Set();
86
89
  this.closeListeners = new Set();
87
90
  this.reconnectingListeners = new Set();
@@ -129,6 +132,16 @@ export class TaConnection {
129
132
  this.remoteListeners.add(listener);
130
133
  return () => this.remoteListeners.delete(listener);
131
134
  }
135
+ /** What happens in the rooms, once this connection called TaRoomServer.watch. */
136
+ onRoomEvent(listener) {
137
+ this.roomListeners.add(listener);
138
+ return () => this.roomListeners.delete(listener);
139
+ }
140
+ /** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
141
+ onSessions(listener) {
142
+ this.sessionsListeners.add(listener);
143
+ return () => this.sessionsListeners.delete(listener);
144
+ }
132
145
  onOpen(listener) {
133
146
  this.openListeners.add(listener);
134
147
  return () => this.openListeners.delete(listener);
@@ -369,7 +382,7 @@ export class TaConnection {
369
382
  }, Math.min(1000, stallMs));
370
383
  }
371
384
  receive(text) {
372
- var _a, _b, _c, _d, _e;
385
+ var _a, _b, _c, _d, _e, _f, _g;
373
386
  this.lastReceivedAt = Date.now();
374
387
  const message = JSON.parse(text);
375
388
  if (message.method === `${TA_CLIENT_SERVICE}/onEvents`) {
@@ -380,13 +393,21 @@ export class TaConnection {
380
393
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
381
394
  return;
382
395
  }
396
+ if (message.method === `${TA_CLIENT_SERVICE}/onSessions`) {
397
+ const [sessions] = message.params;
398
+ for (const listener of this.sessionsListeners) {
399
+ listener(sessions);
400
+ }
401
+ (_b = this.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
402
+ return;
403
+ }
383
404
  if (message.method === `${TA_CLIENT_SERVICE}/onTerminalData`) {
384
405
  const [terminalId, data, exitCode] = message.params;
385
406
  for (const listener of this.terminalListeners) {
386
407
  // JSON has no undefined: a terminal still running may send null.
387
408
  listener(terminalId, data, exitCode !== null && exitCode !== void 0 ? exitCode : undefined);
388
409
  }
389
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
410
+ (_c = this.socket) === null || _c === void 0 ? void 0 : _c.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
390
411
  return;
391
412
  }
392
413
  if (message.method === `${TA_CLIENT_SERVICE}/onAuthEvent`) {
@@ -394,7 +415,7 @@ export class TaConnection {
394
415
  for (const listener of this.authListeners) {
395
416
  listener(loginId, event);
396
417
  }
397
- (_c = this.socket) === null || _c === void 0 ? void 0 : _c.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
418
+ (_d = this.socket) === null || _d === void 0 ? void 0 : _d.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
398
419
  return;
399
420
  }
400
421
  if (message.method === `${TA_CLIENT_SERVICE}/onRemoteEvent`) {
@@ -402,7 +423,15 @@ export class TaConnection {
402
423
  for (const listener of this.remoteListeners) {
403
424
  listener(event);
404
425
  }
405
- (_d = this.socket) === null || _d === void 0 ? void 0 : _d.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
426
+ (_e = this.socket) === null || _e === void 0 ? void 0 : _e.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
427
+ return;
428
+ }
429
+ if (message.method === `${TA_CLIENT_SERVICE}/onRoomEvent`) {
430
+ const [event] = message.params;
431
+ for (const listener of this.roomListeners) {
432
+ listener(event);
433
+ }
434
+ (_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
406
435
  return;
407
436
  }
408
437
  if (message.method === `${TA_CLIENT_SERVICE}/onExtensionData`) {
@@ -410,7 +439,7 @@ export class TaConnection {
410
439
  for (const listener of this.extensionDataListeners) {
411
440
  listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
412
441
  }
413
- (_e = this.socket) === null || _e === void 0 ? void 0 : _e.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
442
+ (_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
414
443
  return;
415
444
  }
416
445
  const call = this.pending.get(message.id);
@@ -82,8 +82,13 @@ export declare class SessionStore {
82
82
  protected readonly resending: Set<Sent>;
83
83
  constructor(connection: SessionConnection, sessionId: string, options?: SessionStoreOptions);
84
84
  get state(): SessionState;
85
- /** Starts following the session. */
86
- attach(): Promise<TaSessionInfo>;
85
+ /** The conversation as the session has it, without the messages sent from here on their way: for another store of it to start from. */
86
+ get snapshot(): SessionSnapshot;
87
+ /**
88
+ * Starts following the session; `attached`: what opening it attached already (TaOpenedSession.attached),
89
+ * taken at once, in the same turn of the event loop as its answer, so that no event after it is missed.
90
+ */
91
+ attach(attached?: TaAttachResult): Promise<TaSessionInfo>;
87
92
  /** Stops following it. The session goes on. */
88
93
  detach(): Promise<void>;
89
94
  subscribe(listener: Listener): () => void;
@@ -138,7 +143,7 @@ export declare class SessionStore {
138
143
  */
139
144
  onGone(listener: () => void): () => void;
140
145
  respondUi(response: RpcExtensionUIResponse): Promise<boolean>;
141
- protected attachAgain(): Promise<TaAttachResult>;
146
+ protected attachAgain(attached?: TaAttachResult): Promise<TaAttachResult>;
142
147
  /**
143
148
  * The latest messages, after the earlier ones the store had if they are still the same where the
144
149
  * latest start: a reconnect does not drop what was loaded further up.
@@ -43,10 +43,18 @@ class SessionStore {
43
43
  get state() {
44
44
  return this.shown;
45
45
  }
46
- /** Starts following the session. */
47
- async attach() {
46
+ /** The conversation as the session has it, without the messages sent from here on their way: for another store of it to start from. */
47
+ get snapshot() {
48
+ const { messages, start, tools } = this.current;
49
+ return { messages, start, tools };
50
+ }
51
+ /**
52
+ * Starts following the session; `attached`: what opening it attached already (TaOpenedSession.attached),
53
+ * taken at once, in the same turn of the event loop as its answer, so that no event after it is missed.
54
+ */
55
+ async attach(attached) {
48
56
  this.stop.push(this.connection.onEvents(events => this.apply(events)), this.connection.onOpen(() => void this.attachAgain().catch(error => this.lost(error))));
49
- return (await this.attachAgain()).info;
57
+ return (await this.attachAgain(attached)).info;
50
58
  }
51
59
  /** Stops following it. The session goes on. */
52
60
  async detach() {
@@ -264,11 +272,12 @@ class SessionStore {
264
272
  respondUi(response) {
265
273
  return this.connection.server.respondUi(this.sessionId, response);
266
274
  }
267
- async attachAgain() {
275
+ async attachAgain(attached) {
268
276
  var _a, _b;
269
- const result = await this.connection.server.attach(this.sessionId, this.lastSeq, this.pageBytes ? { recentBytes: this.pageBytes } : undefined);
277
+ const result = attached !== null && attached !== void 0 ? attached : (await this.connection.server.attach(this.sessionId, this.lastSeq, this.pageBytes ? { recentBytes: this.pageBytes } : undefined));
270
278
  let state = this.current;
271
- if (this.lastSeq === undefined || result.gap) {
279
+ // A conversation given (one attached as it opened) is the session's from scratch, whatever this store had.
280
+ if (this.lastSeq === undefined || result.gap || (attached === null || attached === void 0 ? void 0 : attached.conversation)) {
272
281
  // The conversation as of lastSeq, with the message being written and the calls running.
273
282
  const conversation = (_a = result.conversation) !== null && _a !== void 0 ? _a : { ...(await this.connection.server.getMessages(this.sessionId)), tools: {} };
274
283
  const { messages, start } = SessionStore.withEarlier(this.current, conversation.messages, (_b = conversation.start) !== null && _b !== void 0 ? _b : 0);
@@ -1,4 +1,4 @@
1
- import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, TaErrorCode, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaServer, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
1
+ import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, TaErrorCode, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
2
2
  /**
3
3
  * A failed call. `code` is set for failures the server names; `rpcCode` is the code of JSON-RPC's error,
4
4
  * by which a client tells a method an older ta serve does not have (`TaRemoteError.METHOD_NOT_FOUND`).
@@ -87,6 +87,8 @@ type TerminalListener = (terminalId: string, data: string, exitCode?: number) =>
87
87
  type ExtensionDataListener = (name: string, keys: string[], cwd?: string) => void;
88
88
  type AuthEventListener = (loginId: string, event: TaAuthEvent) => void;
89
89
  type RemoteEventListener = (event: TaRemoteEvent) => void;
90
+ type RoomEventListener = (event: TaRoomEvent) => void;
91
+ type SessionsListener = (sessions: TaSessionInfo[]) => void;
90
92
  type OpenListener = () => void;
91
93
  type CloseListener = () => void;
92
94
  type ReconnectingListener = (delayMs: number, attempt: number) => void;
@@ -116,6 +118,7 @@ export declare class TaConnection {
116
118
  readonly gateway: TaGatewayServer;
117
119
  readonly relay: TaRelayServer;
118
120
  readonly remote: TaRemoteServer;
121
+ readonly rooms: TaRoomServer;
119
122
  protected socket?: TaSocket;
120
123
  protected closed: boolean;
121
124
  protected attempts: number;
@@ -127,6 +130,8 @@ export declare class TaConnection {
127
130
  protected readonly extensionDataListeners: Set<ExtensionDataListener>;
128
131
  protected readonly authListeners: Set<AuthEventListener>;
129
132
  protected readonly remoteListeners: Set<RemoteEventListener>;
133
+ protected readonly roomListeners: Set<RoomEventListener>;
134
+ protected readonly sessionsListeners: Set<SessionsListener>;
130
135
  protected readonly openListeners: Set<OpenListener>;
131
136
  protected readonly closeListeners: Set<CloseListener>;
132
137
  protected readonly reconnectingListeners: Set<ReconnectingListener>;
@@ -153,6 +158,10 @@ export declare class TaConnection {
153
158
  onAuthEvent(listener: AuthEventListener): () => void;
154
159
  /** What happens with the remote machines, once this connection called TaRemoteServer.watch. */
155
160
  onRemoteEvent(listener: RemoteEventListener): () => void;
161
+ /** What happens in the rooms, once this connection called TaRoomServer.watch. */
162
+ onRoomEvent(listener: RoomEventListener): () => void;
163
+ /** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
164
+ onSessions(listener: SessionsListener): () => void;
156
165
  onOpen(listener: OpenListener): () => void;
157
166
  /** Runs each time an open connection is lost; it reconnects unless closed. */
158
167
  onClose(listener: CloseListener): () => void;
@@ -77,6 +77,7 @@ class TaConnection {
77
77
  this.gateway = this.service(ta_protocol_1.TA_GATEWAY_SERVICE);
78
78
  this.relay = this.service(ta_protocol_1.TA_RELAY_SERVICE);
79
79
  this.remote = this.service(ta_protocol_1.TA_REMOTE_SERVICE);
80
+ this.rooms = this.service(ta_protocol_1.TA_ROOM_SERVICE);
80
81
  this.closed = false;
81
82
  this.attempts = 0;
82
83
  this.nextId = 0;
@@ -86,6 +87,8 @@ class TaConnection {
86
87
  this.extensionDataListeners = new Set();
87
88
  this.authListeners = new Set();
88
89
  this.remoteListeners = new Set();
90
+ this.roomListeners = new Set();
91
+ this.sessionsListeners = new Set();
89
92
  this.openListeners = new Set();
90
93
  this.closeListeners = new Set();
91
94
  this.reconnectingListeners = new Set();
@@ -133,6 +136,16 @@ class TaConnection {
133
136
  this.remoteListeners.add(listener);
134
137
  return () => this.remoteListeners.delete(listener);
135
138
  }
139
+ /** What happens in the rooms, once this connection called TaRoomServer.watch. */
140
+ onRoomEvent(listener) {
141
+ this.roomListeners.add(listener);
142
+ return () => this.roomListeners.delete(listener);
143
+ }
144
+ /** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
145
+ onSessions(listener) {
146
+ this.sessionsListeners.add(listener);
147
+ return () => this.sessionsListeners.delete(listener);
148
+ }
136
149
  onOpen(listener) {
137
150
  this.openListeners.add(listener);
138
151
  return () => this.openListeners.delete(listener);
@@ -373,7 +386,7 @@ class TaConnection {
373
386
  }, Math.min(1000, stallMs));
374
387
  }
375
388
  receive(text) {
376
- var _a, _b, _c, _d, _e;
389
+ var _a, _b, _c, _d, _e, _f, _g;
377
390
  this.lastReceivedAt = Date.now();
378
391
  const message = JSON.parse(text);
379
392
  if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onEvents`) {
@@ -384,13 +397,21 @@ class TaConnection {
384
397
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
385
398
  return;
386
399
  }
400
+ if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onSessions`) {
401
+ const [sessions] = message.params;
402
+ for (const listener of this.sessionsListeners) {
403
+ listener(sessions);
404
+ }
405
+ (_b = this.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
406
+ return;
407
+ }
387
408
  if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onTerminalData`) {
388
409
  const [terminalId, data, exitCode] = message.params;
389
410
  for (const listener of this.terminalListeners) {
390
411
  // JSON has no undefined: a terminal still running may send null.
391
412
  listener(terminalId, data, exitCode !== null && exitCode !== void 0 ? exitCode : undefined);
392
413
  }
393
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
414
+ (_c = this.socket) === null || _c === void 0 ? void 0 : _c.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
394
415
  return;
395
416
  }
396
417
  if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onAuthEvent`) {
@@ -398,7 +419,7 @@ class TaConnection {
398
419
  for (const listener of this.authListeners) {
399
420
  listener(loginId, event);
400
421
  }
401
- (_c = this.socket) === null || _c === void 0 ? void 0 : _c.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
422
+ (_d = this.socket) === null || _d === void 0 ? void 0 : _d.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
402
423
  return;
403
424
  }
404
425
  if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onRemoteEvent`) {
@@ -406,7 +427,15 @@ class TaConnection {
406
427
  for (const listener of this.remoteListeners) {
407
428
  listener(event);
408
429
  }
409
- (_d = this.socket) === null || _d === void 0 ? void 0 : _d.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
430
+ (_e = this.socket) === null || _e === void 0 ? void 0 : _e.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
431
+ return;
432
+ }
433
+ if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onRoomEvent`) {
434
+ const [event] = message.params;
435
+ for (const listener of this.roomListeners) {
436
+ listener(event);
437
+ }
438
+ (_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
410
439
  return;
411
440
  }
412
441
  if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onExtensionData`) {
@@ -414,7 +443,7 @@ class TaConnection {
414
443
  for (const listener of this.extensionDataListeners) {
415
444
  listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
416
445
  }
417
- (_e = this.socket) === null || _e === void 0 ? void 0 : _e.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
446
+ (_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
418
447
  return;
419
448
  }
420
449
  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.10.0",
3
+ "version": "4.11.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/cell",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  "watch": "tsc -b -w --preserveWatchOutput"
30
30
  },
31
31
  "dependencies": {
32
- "@celljs/ta-protocol": "4.10.0"
32
+ "@celljs/ta-protocol": "4.11.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@earendil-works/pi-ai": "^1.5.2",