pi-web 0.12.3 → 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.
package/README.md CHANGED
@@ -15,8 +15,8 @@ Then open [http://127.0.0.1:8192](http://127.0.0.1:8192) in your browser.
15
15
  ## Options
16
16
 
17
17
  ```
18
- --port <number> Port to listen on (default: 8192, env: PORT)
19
- --host <string> Host to bind to (default: 127.0.0.1, env: HOST)
18
+ --port <number> Port to listen on (default: 8192)
19
+ --host <string> Host to bind to (default: 127.0.0.1)
20
20
  --agent <pi|omp> Agent backend profile (default: pi)
21
21
  --help Show help
22
22
  ```
@@ -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';
@@ -15,8 +16,8 @@ pi-web - Web UI for the pi coding agent
15
16
  Usage: pi-web [options]
16
17
 
17
18
  Options:
18
- --port <number> Port to listen on (default: 8192, env: PORT)
19
- --host <string> Host to bind to (default: 127.0.0.1, env: HOST)
19
+ --port <number> Port to listen on (default: 8192)
20
+ --host <string> Host to bind to (default: 127.0.0.1)
20
21
  --agent <pi|omp> Agent backend profile (default: pi)
21
22
  -h, --help Show this help message
22
23
  `.trim());
@@ -45,24 +46,19 @@ function getAgentCommand(agent) {
45
46
  : 'npx -y @mariozechner/pi-coding-agent@latest';
46
47
  }
47
48
  const AGENT = parseAgent(getArg('agent'));
48
- const PORT = parseInt(getArg('port') || process.env.PORT || '8192', 10);
49
- const HOST = getArg('host') || process.env.HOST || '127.0.0.1';
49
+ const PORT = parseInt(getArg('port') || '8192', 10);
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.3",
3
+ "version": "0.12.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^24"