@tiflis-io/tiflis-code-workstation 0.3.19 → 0.3.21
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/dist/main.js +31 -79
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -5070,21 +5070,7 @@ var MessageBroadcasterImpl = class {
|
|
|
5070
5070
|
* connected to the tunnel and will re-authenticate soon.
|
|
5071
5071
|
*/
|
|
5072
5072
|
broadcastToAll(message) {
|
|
5073
|
-
|
|
5074
|
-
const authenticatedCount = clients.filter((c) => c.isAuthenticated).length;
|
|
5075
|
-
this.logger.info(
|
|
5076
|
-
{
|
|
5077
|
-
totalClients: clients.length,
|
|
5078
|
-
authenticatedClients: authenticatedCount,
|
|
5079
|
-
messagePreview: message.slice(0, 100)
|
|
5080
|
-
},
|
|
5081
|
-
"broadcastToAll called"
|
|
5082
|
-
);
|
|
5083
|
-
const sent = this.deps.tunnelClient.send(message);
|
|
5084
|
-
this.logger.info(
|
|
5085
|
-
{ sent, authenticatedClients: authenticatedCount },
|
|
5086
|
-
"Broadcast to all - message sent to tunnel"
|
|
5087
|
-
);
|
|
5073
|
+
this.deps.tunnelClient.send(message);
|
|
5088
5074
|
}
|
|
5089
5075
|
/**
|
|
5090
5076
|
* Broadcasts a message to all clients subscribed to a session.
|
|
@@ -5096,15 +5082,7 @@ var MessageBroadcasterImpl = class {
|
|
|
5096
5082
|
(c) => c.isAuthenticated
|
|
5097
5083
|
).length;
|
|
5098
5084
|
if (authenticatedCount > 0) {
|
|
5099
|
-
|
|
5100
|
-
this.logger.debug(
|
|
5101
|
-
{
|
|
5102
|
-
sessionId: sessionId.value,
|
|
5103
|
-
sent,
|
|
5104
|
-
authenticatedSubscribers: authenticatedCount
|
|
5105
|
-
},
|
|
5106
|
-
"Broadcast to session"
|
|
5107
|
-
);
|
|
5085
|
+
this.deps.tunnelClient.send(message);
|
|
5108
5086
|
}
|
|
5109
5087
|
}
|
|
5110
5088
|
/**
|
|
@@ -5118,17 +5096,6 @@ var MessageBroadcasterImpl = class {
|
|
|
5118
5096
|
* but not yet re-authenticated with the workstation
|
|
5119
5097
|
*/
|
|
5120
5098
|
sendToClient(deviceId, message) {
|
|
5121
|
-
const device = new DeviceId(deviceId);
|
|
5122
|
-
const client = this.deps.clientRegistry.getByDeviceId(device);
|
|
5123
|
-
this.logger.info(
|
|
5124
|
-
{
|
|
5125
|
-
deviceId,
|
|
5126
|
-
clientInRegistry: !!client,
|
|
5127
|
-
clientAuthenticated: client?.isAuthenticated,
|
|
5128
|
-
messagePreview: message.slice(0, 100)
|
|
5129
|
-
},
|
|
5130
|
-
"sendToClient - sending via tunnel (supports HTTP polling clients)"
|
|
5131
|
-
);
|
|
5132
5099
|
return this.deps.tunnelClient.sendToDevice(deviceId, message);
|
|
5133
5100
|
}
|
|
5134
5101
|
/**
|
|
@@ -5141,37 +5108,12 @@ var MessageBroadcasterImpl = class {
|
|
|
5141
5108
|
const authenticatedSubscribers = subscribers.filter(
|
|
5142
5109
|
(c) => c.isAuthenticated
|
|
5143
5110
|
);
|
|
5144
|
-
const allClients = this.deps.clientRegistry.getAll();
|
|
5145
|
-
this.logger.info(
|
|
5146
|
-
{
|
|
5147
|
-
sessionId,
|
|
5148
|
-
totalClients: allClients.length,
|
|
5149
|
-
totalSubscribers: subscribers.length,
|
|
5150
|
-
authenticatedSubscribers: authenticatedSubscribers.length,
|
|
5151
|
-
clientsInfo: allClients.map((c) => ({
|
|
5152
|
-
deviceId: c.deviceId.value,
|
|
5153
|
-
isAuthenticated: c.isAuthenticated,
|
|
5154
|
-
isConnected: c.isConnected,
|
|
5155
|
-
status: c.status,
|
|
5156
|
-
subscriptions: c.getSubscriptions()
|
|
5157
|
-
}))
|
|
5158
|
-
},
|
|
5159
|
-
"broadcastToSubscribers - client state"
|
|
5160
|
-
);
|
|
5161
5111
|
if (authenticatedSubscribers.length === 0) {
|
|
5162
|
-
this.logger.warn(
|
|
5163
|
-
{ sessionId, totalClients: allClients.length },
|
|
5164
|
-
"broadcastToSubscribers - no authenticated subscribers found"
|
|
5165
|
-
);
|
|
5166
5112
|
return;
|
|
5167
5113
|
}
|
|
5168
5114
|
for (const client of authenticatedSubscribers) {
|
|
5169
5115
|
this.deps.tunnelClient.sendToDevice(client.deviceId.value, message);
|
|
5170
5116
|
}
|
|
5171
|
-
this.logger.debug(
|
|
5172
|
-
{ sessionId, subscriberCount: authenticatedSubscribers.length },
|
|
5173
|
-
"Broadcast to subscribers - messages sent"
|
|
5174
|
-
);
|
|
5175
5117
|
}
|
|
5176
5118
|
};
|
|
5177
5119
|
|
|
@@ -9264,6 +9206,34 @@ async function bootstrap() {
|
|
|
9264
9206
|
},
|
|
9265
9207
|
"Starting workstation server"
|
|
9266
9208
|
);
|
|
9209
|
+
const registerSignalHandlers = (shutdown2) => {
|
|
9210
|
+
let signalCount = 0;
|
|
9211
|
+
const handleSignal = (signal) => {
|
|
9212
|
+
signalCount++;
|
|
9213
|
+
logger.info({ signal, count: signalCount }, "Signal received, initiating shutdown");
|
|
9214
|
+
if (signalCount === 1) {
|
|
9215
|
+
console.log("\nShutting down gracefully...");
|
|
9216
|
+
shutdown2(signal).then(() => {
|
|
9217
|
+
process.exit(0);
|
|
9218
|
+
}).catch((error) => {
|
|
9219
|
+
logger.error({ error }, "Error during shutdown");
|
|
9220
|
+
process.exit(1);
|
|
9221
|
+
});
|
|
9222
|
+
} else {
|
|
9223
|
+
console.log("\nForce exiting...");
|
|
9224
|
+
process.exit(1);
|
|
9225
|
+
}
|
|
9226
|
+
};
|
|
9227
|
+
process.on("SIGTERM", () => handleSignal("SIGTERM"));
|
|
9228
|
+
process.on("SIGINT", () => handleSignal("SIGINT"));
|
|
9229
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
9230
|
+
logger.error({ reason, promise }, "Unhandled rejection");
|
|
9231
|
+
});
|
|
9232
|
+
process.on("uncaughtException", (error) => {
|
|
9233
|
+
logger.fatal({ error }, "Uncaught exception");
|
|
9234
|
+
process.exit(1);
|
|
9235
|
+
});
|
|
9236
|
+
};
|
|
9267
9237
|
const dataDir = env.DATA_DIR;
|
|
9268
9238
|
initDatabase(dataDir);
|
|
9269
9239
|
logger.info({ dataDir }, "Database initialized");
|
|
@@ -11396,25 +11366,7 @@ async function bootstrap() {
|
|
|
11396
11366
|
process.exit(1);
|
|
11397
11367
|
}
|
|
11398
11368
|
};
|
|
11399
|
-
|
|
11400
|
-
const handleSignal = (signal) => {
|
|
11401
|
-
signalCount++;
|
|
11402
|
-
if (signalCount === 1) {
|
|
11403
|
-
void shutdown(signal);
|
|
11404
|
-
} else {
|
|
11405
|
-
logger.warn({ signal, count: signalCount }, "Force exit on repeated signal");
|
|
11406
|
-
process.exit(1);
|
|
11407
|
-
}
|
|
11408
|
-
};
|
|
11409
|
-
process.on("SIGTERM", () => handleSignal("SIGTERM"));
|
|
11410
|
-
process.on("SIGINT", () => handleSignal("SIGINT"));
|
|
11411
|
-
process.on("unhandledRejection", (reason, promise) => {
|
|
11412
|
-
logger.error({ reason, promise }, "Unhandled rejection");
|
|
11413
|
-
});
|
|
11414
|
-
process.on("uncaughtException", (error) => {
|
|
11415
|
-
logger.fatal({ error }, "Uncaught exception");
|
|
11416
|
-
process.exit(1);
|
|
11417
|
-
});
|
|
11369
|
+
registerSignalHandlers(shutdown);
|
|
11418
11370
|
}
|
|
11419
11371
|
bootstrap().catch((error) => {
|
|
11420
11372
|
console.error("Failed to bootstrap:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiflis-io/tiflis-code-workstation",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"description": "Workstation server for tiflis-code - manages agent sessions and terminal access",
|
|
5
5
|
"author": "Roman Barinov <rbarinov@gmail.com>",
|
|
6
6
|
"license": "FSL-1.1-NC",
|