tabminal 3.0.14 → 3.0.16

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.
@@ -378,6 +378,134 @@ class TabminalTestAgent {
378
378
  throw new Error('prompt dispatch failed');
379
379
  }
380
380
 
381
+ if (
382
+ commandName === 'cumulative-debug'
383
+ || /cumulative-debug/i.test(promptText)
384
+ ) {
385
+ await this.connection.sessionUpdate({
386
+ sessionId: params.sessionId,
387
+ update: {
388
+ sessionUpdate: 'agent_message_chunk',
389
+ content: {
390
+ type: 'text',
391
+ text: 'Alpha'
392
+ }
393
+ }
394
+ });
395
+ await sleep(20, signal);
396
+ await this.connection.sessionUpdate({
397
+ sessionId: params.sessionId,
398
+ update: {
399
+ sessionUpdate: 'agent_message_chunk',
400
+ content: {
401
+ type: 'text',
402
+ text: 'Alpha Beta'
403
+ }
404
+ }
405
+ });
406
+ return { stopReason: 'end_turn' };
407
+ }
408
+
409
+ if (
410
+ commandName === 'restart-debug'
411
+ || /restart-debug/i.test(promptText)
412
+ ) {
413
+ await this.connection.sessionUpdate({
414
+ sessionId: params.sessionId,
415
+ update: {
416
+ sessionUpdate: 'agent_message_chunk',
417
+ content: {
418
+ type: 'text',
419
+ text: 'Report A\n'
420
+ }
421
+ }
422
+ });
423
+ await sleep(20, signal);
424
+ await this.connection.sessionUpdate({
425
+ sessionId: params.sessionId,
426
+ update: {
427
+ sessionUpdate: 'agent_message_chunk',
428
+ content: {
429
+ type: 'text',
430
+ text: 'line 1\nline 2\n'
431
+ }
432
+ }
433
+ });
434
+ await sleep(20, signal);
435
+ await this.connection.sessionUpdate({
436
+ sessionId: params.sessionId,
437
+ update: {
438
+ sessionUpdate: 'agent_message_chunk',
439
+ content: {
440
+ type: 'text',
441
+ text: 'Report A\n'
442
+ }
443
+ }
444
+ });
445
+ await sleep(20, signal);
446
+ await this.connection.sessionUpdate({
447
+ sessionId: params.sessionId,
448
+ update: {
449
+ sessionUpdate: 'agent_message_chunk',
450
+ content: {
451
+ type: 'text',
452
+ text: 'line 1\nline 2\n'
453
+ }
454
+ }
455
+ });
456
+ return { stopReason: 'end_turn' };
457
+ }
458
+
459
+ if (
460
+ commandName === 'restart-drift-debug'
461
+ || /restart-drift-debug/i.test(promptText)
462
+ ) {
463
+ await this.connection.sessionUpdate({
464
+ sessionId: params.sessionId,
465
+ update: {
466
+ sessionUpdate: 'agent_message_chunk',
467
+ content: {
468
+ type: 'text',
469
+ text: '時間戳:1\n'
470
+ }
471
+ }
472
+ });
473
+ await sleep(20, signal);
474
+ await this.connection.sessionUpdate({
475
+ sessionId: params.sessionId,
476
+ update: {
477
+ sessionUpdate: 'agent_message_chunk',
478
+ content: {
479
+ type: 'text',
480
+ text: 'Dataset A\nDataset B\n'
481
+ }
482
+ }
483
+ });
484
+ await sleep(20, signal);
485
+ await this.connection.sessionUpdate({
486
+ sessionId: params.sessionId,
487
+ update: {
488
+ sessionUpdate: 'agent_message_chunk',
489
+ content: {
490
+ type: 'text',
491
+ text: '時間戳:2\n'
492
+ }
493
+ }
494
+ });
495
+ await sleep(20, signal);
496
+ await this.connection.sessionUpdate({
497
+ sessionId: params.sessionId,
498
+ update: {
499
+ sessionUpdate: 'agent_message_chunk',
500
+ content: {
501
+ type: 'text',
502
+ text: 'Dataset A\n'
503
+ }
504
+ }
505
+ });
506
+ return { stopReason: 'end_turn' };
507
+ }
508
+
381
509
  if (commandName === 'plan') {
382
510
  await sleep(60, signal);
383
511
  await this.sendPlan(params.sessionId, [
package/src/server.mjs CHANGED
@@ -574,6 +574,7 @@ router.post('/api/agents/tabs/:tabId/prompt', async (ctx) => {
574
574
  ctx.body = { error: 'text or attachments are required' };
575
575
  return;
576
576
  }
577
+
577
578
  try {
578
579
  await acpManager.sendPrompt(tabId, text, attachments);
579
580
  ctx.status = 202;
@@ -793,7 +794,7 @@ function findAvailablePort(startPort, host) {
793
794
  })();
794
795
 
795
796
  let isShuttingDown = false;
796
- function shutdown(signal) {
797
+ async function shutdown(signal) {
797
798
  if (isShuttingDown) {
798
799
  return;
799
800
  }
@@ -805,23 +806,38 @@ function shutdown(signal) {
805
806
  }
806
807
  wss.close();
807
808
  terminalManager.dispose();
808
- void acpManager.dispose();
809
+
810
+ const waitForHttpClose = new Promise((resolve) => {
811
+ httpServer.close(() => resolve());
812
+ });
813
+ httpServer.closeIdleConnections?.();
814
+ httpServer.closeAllConnections?.();
815
+ for (const socket of httpConnections) {
816
+ socket.destroy();
817
+ }
809
818
 
810
819
  const forceExitTimer = setTimeout(() => {
811
820
  console.warn('Forced shutdown after timeout.');
812
821
  process.exit(1);
813
822
  }, 5000).unref();
814
823
 
815
- httpServer.close(() => {
824
+ try {
825
+ await Promise.all([
826
+ waitForHttpClose,
827
+ acpManager.dispose()
828
+ ]);
816
829
  clearTimeout(forceExitTimer);
817
830
  process.exit(0);
818
- });
819
- httpServer.closeIdleConnections?.();
820
- httpServer.closeAllConnections?.();
821
- for (const socket of httpConnections) {
822
- socket.destroy();
831
+ } catch (error) {
832
+ clearTimeout(forceExitTimer);
833
+ console.error('Shutdown failed:', error);
834
+ process.exit(0);
823
835
  }
824
836
  }
825
837
 
826
- process.on('SIGINT', () => shutdown('SIGINT'));
827
- process.on('SIGTERM', () => shutdown('SIGTERM'));
838
+ process.on('SIGINT', () => {
839
+ void shutdown('SIGINT');
840
+ });
841
+ process.on('SIGTERM', () => {
842
+ void shutdown('SIGTERM');
843
+ });