codex-webstrapper 0.1.5 → 0.2.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/src/server.mjs CHANGED
@@ -114,6 +114,7 @@ async function main() {
114
114
  const config = parseConfig();
115
115
 
116
116
  const tokenResult = await ensurePersistentToken(config.tokenFile);
117
+ const runtimeMetadataPath = `${tokenResult.tokenFilePath}.runtime`;
117
118
  const sessionStore = new SessionStore({ ttlMs: 1000 * 60 * 60 * 12 });
118
119
  const auth = createAuthController({ token: tokenResult.token, sessionStore });
119
120
 
@@ -299,6 +300,25 @@ async function main() {
299
300
  server.listen(config.port, config.bind, resolve);
300
301
  });
301
302
 
303
+ try {
304
+ await fs.writeFile(
305
+ runtimeMetadataPath,
306
+ JSON.stringify({
307
+ bind: config.bind,
308
+ port: config.port,
309
+ tokenFile: tokenResult.tokenFilePath,
310
+ pid: process.pid,
311
+ startedAt: Date.now()
312
+ }) + "\n",
313
+ { mode: 0o600 }
314
+ );
315
+ } catch (error) {
316
+ logger.warn("Failed to write runtime metadata file", {
317
+ path: runtimeMetadataPath,
318
+ error: toErrorMessage(error)
319
+ });
320
+ }
321
+
302
322
  const authHint = `http://${config.bind}:${config.port}/__webstrapper/auth?token=<redacted>`;
303
323
  const loginCommand = `open \"http://${config.bind}:${config.port}/__webstrapper/auth?token=$(cat ${tokenResult.tokenFilePath})\"`;
304
324
 
@@ -356,6 +376,11 @@ async function main() {
356
376
  await new Promise((resolve) => {
357
377
  server.close(() => resolve());
358
378
  });
379
+ try {
380
+ await fs.unlink(runtimeMetadataPath);
381
+ } catch {
382
+ // ignore
383
+ }
359
384
 
360
385
  process.exit(0);
361
386
  }