@threadbase-sh/streamer 1.28.2 → 1.29.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/dist/cli.cjs CHANGED
@@ -1557,6 +1557,15 @@ function loadTailSize() {
1557
1557
  }
1558
1558
  return void 0;
1559
1559
  }
1560
+ function loadPtyGracePeriodMs() {
1561
+ try {
1562
+ const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
1563
+ const match2 = content.match(/pty_grace_period_ms:\s*(\d+)/);
1564
+ if (match2?.[1]) return Number.parseInt(match2[1], 10);
1565
+ } catch {
1566
+ }
1567
+ return void 0;
1568
+ }
1560
1569
  function loadDefaultPermissionMode() {
1561
1570
  try {
1562
1571
  const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
@@ -143220,7 +143229,7 @@ var StreamerServer = class {
143220
143229
  }
143221
143230
  for (const [sessionId, subscribers] of this.sessionSubscribers) {
143222
143231
  subscribers.delete(ws2);
143223
- if (subscribers.size === 0) {
143232
+ if (subscribers.size === 0 && this.ptyGracePeriodMs > 0) {
143224
143233
  this.startGraceTimer(sessionId, this.ptyGracePeriodMs);
143225
143234
  }
143226
143235
  }
@@ -149083,6 +149092,9 @@ program2.command("serve").description("Start the streamer server").option("-p, -
149083
149092
  ).option(
149084
149093
  "--default-permission-mode <mode>",
149085
149094
  "Claude Code permission mode for spawned sessions: acceptEdits (auto-approve file edits, default) or manual (prompt for everything). Falls back to default_permission_mode: in ~/.threadbase/server.yaml, or a first-run interactive prompt on a human TTY invocation (skip with THREADBASE_SKIP_PERMISSION_MODE_PROMPT=true)."
149095
+ ).option(
149096
+ "--pty-grace-period-ms <ms>",
149097
+ "Ms to keep a PTY alive after the last WebSocket subscriber disconnects before auto-holding it (default 270000, 4.5 min). 0 disables auto-hold entirely (an explicit hold_session still works). Falls back to pty_grace_period_ms: in ~/.threadbase/server.yaml."
149086
149098
  ).option("--no-pair-qr", "Skip the pairing QR on startup").option("--replace-prod", "Stop the launchd-supervised prod streamer and bind its port", false).option("--forget", "Clear this repo's remembered dev-vs-prod choice and re-prompt", false).option("--forget-all", "Clear every repo's remembered dev-vs-prod choice", false).option(
149087
149099
  "--prod",
149088
149100
  "Run as if invoked by launchd: skip the dev-takeover prompt and signal handlers",
@@ -149110,6 +149122,21 @@ program2.command("serve").description("Start the streamer server").option("-p, -
149110
149122
  );
149111
149123
  process.exit(1);
149112
149124
  }
149125
+ let ptyGracePeriodMs;
149126
+ if (opts.ptyGracePeriodMs !== void 0) {
149127
+ const parsed = Number(opts.ptyGracePeriodMs);
149128
+ if (!Number.isInteger(parsed) || parsed < 0) {
149129
+ log7.error(
149130
+ `Invalid --pty-grace-period-ms: ${opts.ptyGracePeriodMs} (expected a non-negative integer; 0 disables auto-hold)`,
149131
+ void 0,
149132
+ "console"
149133
+ );
149134
+ process.exit(1);
149135
+ }
149136
+ ptyGracePeriodMs = parsed;
149137
+ } else {
149138
+ ptyGracePeriodMs = loadPtyGracePeriodMs();
149139
+ }
149113
149140
  const requestedPort = Number.parseInt(opts.port, 10);
149114
149141
  const apiKey = opts.apiKey ?? loadOrCreateApiKey();
149115
149142
  const publicUrl = opts.publicUrl ?? loadPublicUrl() ?? null;
@@ -149153,7 +149180,8 @@ program2.command("serve").description("Start the streamer server").option("-p, -
149153
149180
  logMenubarRequests: opts.logMenubarRequests,
149154
149181
  browseRoot: opts.browseRoot,
149155
149182
  publicUrl: opts.publicUrl,
149156
- defaultPermissionMode: resolvedDefaultPermissionMode
149183
+ defaultPermissionMode: resolvedDefaultPermissionMode,
149184
+ ptyGracePeriodMs
149157
149185
  });
149158
149186
  await server.listen(resolvedPort);
149159
149187
  {