@seamnet/client 0.12.5 → 0.12.7

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/lib/guardian.js CHANGED
@@ -195,7 +195,7 @@ export async function guardianRun() {
195
195
  const isFirstStart = !guardianState.has('cc_restarted');
196
196
  const isUpgradeRestart = guardianState.has('pending_upgrade_restart');
197
197
  if (ccSession && (isFirstStart || isUpgradeRestart)) {
198
- const safeSession = ccSession.replace(/[^a-zA-Z0-9_-]/g, '_');
198
+ const safeSession = ccSession.replace(/[^a-zA-Z0-9_一-鿿぀-ヿ가-힯-]/g, '_');
199
199
  const tmux = tmuxCmd(ccSocket);
200
200
  hub.logger('guardian').info('auto_restart_cc_scheduled', {
201
201
  session: safeSession,
@@ -240,6 +240,24 @@ export async function guardianRun() {
240
240
  };
241
241
  process.on('SIGTERM', () => shutdown('SIGTERM'));
242
242
  process.on('SIGINT', () => shutdown('SIGINT'));
243
+
244
+ // 最后防线:未捕获异常/Promise 只记录不退出,防止 SDK 一个错误把整个 guardian 炸了
245
+ process.on('uncaughtException', (err) => {
246
+ try {
247
+ hub.logger('guardian').error('uncaught_exception', err, {
248
+ message: err?.message?.slice(0, 300),
249
+ code: err?.code,
250
+ });
251
+ } catch {}
252
+ });
253
+ process.on('unhandledRejection', (reason) => {
254
+ try {
255
+ hub.logger('guardian').error('unhandled_rejection', reason, {
256
+ message: reason?.message?.slice(0, 300) || String(reason).slice(0, 300),
257
+ code: reason?.code,
258
+ });
259
+ } catch {}
260
+ });
243
261
  }
244
262
 
245
263
  export async function guardianStop() {
@@ -374,6 +374,29 @@ function createImPlugin() {
374
374
  log.warn('sdk_not_ready');
375
375
  });
376
376
 
377
+ // SDK 错误事件:记录但不 throw,避免 guardian 整个 crash
378
+ chat.on(TencentCloudChat.EVENT.ERROR, (event) => {
379
+ const err = event?.data || event;
380
+ log.warn('sdk_error', {
381
+ code: err?.code,
382
+ message: err?.message || String(err).slice(0, 200),
383
+ });
384
+ });
385
+
386
+ // 被踢下线(2801 等多端登录场景):记录,SDK 会自动重连
387
+ chat.on(TencentCloudChat.EVENT.KICKED_OUT, (event) => {
388
+ log.warn('sdk_kicked_out', {
389
+ type: event?.data?.type,
390
+ message: event?.data?.message,
391
+ });
392
+ sdkReady = false;
393
+ });
394
+
395
+ // 网络状态变化:断线/重连都只记日志,不干扰主流程
396
+ chat.on(TencentCloudChat.EVENT.NET_STATE_CHANGE, (event) => {
397
+ log.info('sdk_net_state', { state: event?.data?.state });
398
+ });
399
+
377
400
  chat.on(TencentCloudChat.EVENT.MESSAGE_RECEIVED, (event) => {
378
401
  for (const msg of event.data) {
379
402
  if (msg.from === myUserId) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamnet/client",
3
- "version": "0.12.5",
3
+ "version": "0.12.7",
4
4
  "description": "One command to join Seam — the network where people and AI stay in sync.",
5
5
  "bin": {
6
6
  "seam-client": "bin/cli.js",