pi-web 0.12.4 → 0.12.5

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.
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto';
3
3
  import { createReadStream, existsSync, readFileSync, statSync, unlinkSync } from 'node:fs';
4
4
  import { readdir } from 'node:fs/promises';
5
5
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
6
+ import { homedir } from 'node:os';
6
7
  import { fileURLToPath } from 'node:url';
7
8
  import { WebSocketServer, WebSocket } from 'ws';
8
9
  import { RpcSession } from './rpc.js';
@@ -48,21 +49,16 @@ const AGENT = parseAgent(getArg('agent'));
48
49
  const PORT = parseInt(getArg('port') || '8192', 10);
49
50
  const HOST = getArg('host') || '127.0.0.1';
50
51
  const AGENT_CMD = getAgentCommand(AGENT);
51
- const DEFAULT_IDLE_SESSION_TTL_MS = 60_000;
52
- const idleSessionTtlMsEnv = parseInt(process.env.PI_WEB_IDLE_SESSION_TTL_MS || '', 10);
53
- const IDLE_SESSION_TTL_MS = Number.isFinite(idleSessionTtlMsEnv) && idleSessionTtlMsEnv >= 0
54
- ? idleSessionTtlMsEnv
55
- : DEFAULT_IDLE_SESSION_TTL_MS;
52
+ const IDLE_SESSION_TTL_MS = 60_000;
56
53
  const isWatchMode = process.argv.includes('--watch') ||
57
- process.execArgv.some((arg) => arg === '--watch' || arg.startsWith('--watch-')) ||
58
- process.env.WATCH_REPORT_DEPENDENCIES != null;
59
- const isDev = process.env.NODE_ENV === 'development' || isWatchMode;
54
+ process.execArgv.some((arg) => arg === '--watch' || arg.startsWith('--watch-'));
55
+ const isDev = isWatchMode;
60
56
  const distDirCandidates = [join(__dirname, 'dist'), join(__dirname, '..', '..', 'dist')];
61
57
  const distDir = distDirCandidates.find((candidate) => existsSync(join(candidate, 'index.html'))) ??
62
58
  distDirCandidates[0];
63
59
  const htmlPath = join(distDir, 'index.html');
64
60
  const htmlCache = isDev || !existsSync(htmlPath) ? null : readFileSync(htmlPath, 'utf-8');
65
- const HOME_DIR = resolve(process.env.HOME || '/');
61
+ const HOME_DIR = resolve(homedir() || '/');
66
62
  function isWithinRoot(path, root) {
67
63
  const rel = relative(root, path);
68
64
  return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
@@ -410,7 +406,7 @@ wss.on('connection', (ws) => {
410
406
  if (msg.type === 'start_session') {
411
407
  const cwd = typeof msg.cwd === 'string' && msg.cwd.trim().length > 0
412
408
  ? resolve(msg.cwd)
413
- : resolve(process.env.HOME || '/');
409
+ : HOME_DIR;
414
410
  const sessionFile = typeof msg.sessionFile === 'string' && msg.sessionFile.length > 0
415
411
  ? basename(msg.sessionFile)
416
412
  : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web",
3
- "version": "0.12.4",
3
+ "version": "0.12.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^24"