@rubytech/create-realagent 1.0.635 → 1.0.636

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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Real Agent</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-BTjragNx.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-E3EIZIw0.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-Be6NvmcD.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-rov5CBGT.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-D4y_EM_A.js">
@@ -1,32 +1,9 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
- mod
29
- ));
1
+ import {
2
+ __commonJS,
3
+ __export,
4
+ __toESM,
5
+ readProgressLog
6
+ } from "./chunk-LM5BMENF.js";
30
7
 
31
8
  // ../lib/models/dist/index.js
32
9
  var require_dist = __commonJS({
@@ -2660,8 +2637,8 @@ var createAdaptorServer = (options) => {
2660
2637
  overrideGlobalObjects: options.overrideGlobalObjects,
2661
2638
  autoCleanupIncoming: options.autoCleanupIncoming
2662
2639
  });
2663
- const createServer = options.createServer || createServerHTTP;
2664
- const server = createServer(options.serverOptions || {}, requestListener);
2640
+ const createServer2 = options.createServer || createServerHTTP;
2641
+ const server = createServer2(options.serverOptions || {}, requestListener);
2665
2642
  return server;
2666
2643
  };
2667
2644
  var serve = (options, listeningListener) => {
@@ -32315,7 +32292,9 @@ async function GET13() {
32315
32292
  // app/api/admin/version/upgrade/route.ts
32316
32293
  import { spawn as spawn4 } from "child_process";
32317
32294
  import { existsSync as existsSync24, statSync as statSync9, writeFileSync as writeFileSync16, readFileSync as readFileSync24, openSync as openSync5, closeSync as closeSync5 } from "fs";
32318
- import { resolve as resolve26, join as join11 } from "path";
32295
+ import { createServer } from "net";
32296
+ import { resolve as resolve26, join as join11, dirname as dirname8 } from "path";
32297
+ import { fileURLToPath } from "url";
32319
32298
  var PLATFORM_ROOT10 = process.env.MAXY_PLATFORM_ROOT ?? resolve26(process.cwd(), "..");
32320
32299
  var upgradePkg = "@rubytech/create-maxy";
32321
32300
  var upgradeHostname = "maxy";
@@ -32348,6 +32327,27 @@ function isLockFresh() {
32348
32327
  return false;
32349
32328
  }
32350
32329
  }
32330
+ function probePortFree(port2) {
32331
+ return new Promise((resolve29) => {
32332
+ const probe = createServer();
32333
+ probe.once("error", (err) => {
32334
+ resolve29({ error: `${err.code ?? "EADDRINUSE"} on port ${port2}` });
32335
+ });
32336
+ probe.once("listening", () => {
32337
+ probe.close(() => resolve29(true));
32338
+ });
32339
+ probe.listen(port2, "0.0.0.0");
32340
+ });
32341
+ }
32342
+ function resolveSidecarPath() {
32343
+ try {
32344
+ const here = dirname8(fileURLToPath(import.meta.url));
32345
+ const candidate = join11(here, "upgrade-progress-server.js");
32346
+ return existsSync24(candidate) ? candidate : null;
32347
+ } catch {
32348
+ return null;
32349
+ }
32350
+ }
32351
32351
  async function POST23(req) {
32352
32352
  let body;
32353
32353
  try {
@@ -32365,17 +32365,65 @@ async function POST23(req) {
32365
32365
  if (isLockFresh()) {
32366
32366
  return Response.json({ ok: false, error: "upgrade already in progress" }, { status: 409 });
32367
32367
  }
32368
+ const mainPort = parseInt(process.env.PORT ?? "19200", 10);
32369
+ const sidecarPort = mainPort + 99;
32370
+ const portProbe = await probePortFree(sidecarPort);
32371
+ if (portProbe !== true) {
32372
+ console.error(`[admin/version/upgrade] sidecar port probe failed: ${portProbe.error}`);
32373
+ return Response.json(
32374
+ { ok: false, error: `upgrade progress port ${sidecarPort} is already in use (${portProbe.error})` },
32375
+ { status: 500 }
32376
+ );
32377
+ }
32378
+ const sidecarPath = resolveSidecarPath();
32379
+ const installerScope = `upgrade-${upgradeHostname}`;
32380
+ const sidecarScope = `upgrade-progress-${upgradeHostname}`;
32368
32381
  try {
32369
32382
  writeFileSync16(LOCK_FILE, String(Date.now()));
32370
32383
  } catch (err) {
32371
32384
  console.error("[admin/version/upgrade] failed to write lock file:", err);
32372
32385
  }
32386
+ if (!sidecarPath) {
32387
+ console.error("[admin/version/upgrade] progress sidecar binary not found in dist/");
32388
+ return Response.json(
32389
+ { ok: false, error: "progress sidecar binary missing \u2014 rebuild required" },
32390
+ { status: 500 }
32391
+ );
32392
+ }
32393
+ let sidecarPid;
32394
+ try {
32395
+ const sidecarLogFd = openSync5(LOG_FILE, "a");
32396
+ const sidecar = spawn4("systemd-run", [
32397
+ "--user",
32398
+ "--scope",
32399
+ `--unit=${sidecarScope}`,
32400
+ "--",
32401
+ "node",
32402
+ sidecarPath,
32403
+ `--port=${sidecarPort}`,
32404
+ `--log=${LOG_FILE}`,
32405
+ `--scope=${installerScope}`
32406
+ ], {
32407
+ detached: true,
32408
+ stdio: ["ignore", sidecarLogFd, sidecarLogFd]
32409
+ });
32410
+ sidecar.unref();
32411
+ closeSync5(sidecarLogFd);
32412
+ sidecarPid = sidecar.pid;
32413
+ console.log(`[admin/version/upgrade] spawned progress sidecar (pid ${sidecarPid} port ${sidecarPort})`);
32414
+ } catch (err) {
32415
+ console.error("[admin/version/upgrade] failed to spawn progress sidecar:", err);
32416
+ return Response.json(
32417
+ { ok: false, error: err instanceof Error ? err.message : "failed to spawn progress sidecar" },
32418
+ { status: 500 }
32419
+ );
32420
+ }
32373
32421
  try {
32374
32422
  const logFd = openSync5(LOG_FILE, "w");
32375
32423
  const child = spawn4("systemd-run", [
32376
32424
  "--user",
32377
32425
  "--scope",
32378
- `--unit=upgrade-${upgradeHostname}`,
32426
+ `--unit=${installerScope}`,
32379
32427
  "--",
32380
32428
  "npx",
32381
32429
  "-y",
@@ -32389,7 +32437,9 @@ async function POST23(req) {
32389
32437
  child.unref();
32390
32438
  closeSync5(logFd);
32391
32439
  console.log(`[admin/version/upgrade] spawned upgrade process (pid ${child.pid})`);
32392
- return Response.json({ ok: true, started: true });
32440
+ const host = new URL(req.url).hostname;
32441
+ const progressUrl = `http://${host}:${sidecarPort}/progress`;
32442
+ return Response.json({ ok: true, started: true, progressUrl });
32393
32443
  } catch (err) {
32394
32444
  console.error("[admin/version/upgrade] failed to spawn upgrade process:", err);
32395
32445
  return Response.json(
@@ -32413,40 +32463,8 @@ if (existsSync25(brandPath2)) {
32413
32463
  }
32414
32464
  }
32415
32465
  var LOG_FILE2 = `/tmp/${upgradeHostname2}-upgrade.log`;
32416
- var STEP_RE = /\[(\d+)\/(\d+)\]\s+(.+)/;
32417
- var ANSI_RE = /\x1b\[[0-9;?]*[a-zA-Z]/g;
32418
- var stripAnsi = (s) => s.replace(ANSI_RE, "").replace(/\r/g, "").trimEnd();
32419
- var MAX_SUBSTEPS = 20;
32420
32466
  async function GET14() {
32421
- if (!existsSync25(LOG_FILE2)) {
32422
- return Response.json({ step: 0, total: 0, label: "", started: false, subSteps: [] });
32423
- }
32424
- let content;
32425
- try {
32426
- content = readFileSync25(LOG_FILE2, "utf-8");
32427
- } catch {
32428
- return Response.json({ step: 0, total: 0, label: "", started: false, subSteps: [] });
32429
- }
32430
- const rawLines = content.split("\n");
32431
- let step = 0;
32432
- let total = 0;
32433
- let label = "";
32434
- let markerIdx = -1;
32435
- for (let i = rawLines.length - 1; i >= 0; i--) {
32436
- const match2 = rawLines[i].match(STEP_RE);
32437
- if (match2) {
32438
- step = parseInt(match2[1], 10);
32439
- total = parseInt(match2[2], 10);
32440
- label = match2[3].replace(/\.{3}$/, "").trim();
32441
- markerIdx = i;
32442
- break;
32443
- }
32444
- }
32445
- const subSteps = markerIdx >= 0 ? rawLines.slice(markerIdx + 1).map(stripAnsi).filter((l) => l.length > 0).slice(-MAX_SUBSTEPS) : [];
32446
- const tail = rawLines.slice(-20).join("\n");
32447
- const finished = tail.includes("Open in your browser:");
32448
- const failed = tail.includes("Setup failed:");
32449
- return Response.json({ step, total, label, started: true, finished, failed, subSteps });
32467
+ return Response.json(readProgressLog(LOG_FILE2));
32450
32468
  }
32451
32469
 
32452
32470
  // app/api/admin/sessions/route.ts
@@ -0,0 +1,83 @@
1
+ import {
2
+ readProgressLog
3
+ } from "./chunk-LM5BMENF.js";
4
+
5
+ // server/upgrade-progress-server.ts
6
+ import { createServer } from "http";
7
+ import { spawnSync } from "child_process";
8
+ import { appendFileSync } from "fs";
9
+ function arg(name) {
10
+ const prefix = `--${name}=`;
11
+ const hit = process.argv.find((a) => a.startsWith(prefix));
12
+ return hit?.slice(prefix.length);
13
+ }
14
+ var port = parseInt(arg("port") ?? "0", 10);
15
+ var logPath = arg("log") ?? "";
16
+ var scopeUnit = arg("scope") ?? "";
17
+ if (!port || !logPath || !scopeUnit) {
18
+ console.error(`[progress-server] missing required args: --port=${port} --log=${logPath} --scope=${scopeUnit}`);
19
+ process.exit(2);
20
+ }
21
+ function banner(line) {
22
+ try {
23
+ appendFileSync(logPath, `${line}
24
+ `);
25
+ } catch {
26
+ }
27
+ }
28
+ var server = createServer((req, res) => {
29
+ res.setHeader("Access-Control-Allow-Origin", "*");
30
+ res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
31
+ if (req.method === "OPTIONS") {
32
+ res.statusCode = 204;
33
+ res.end();
34
+ return;
35
+ }
36
+ if (req.url !== "/progress") {
37
+ res.statusCode = 404;
38
+ res.end();
39
+ return;
40
+ }
41
+ const payload = readProgressLog(logPath);
42
+ res.setHeader("Content-Type", "application/json");
43
+ res.statusCode = 200;
44
+ res.end(JSON.stringify(payload));
45
+ });
46
+ server.on("error", (err) => {
47
+ console.error(`[progress-server] listen error: ${err.code ?? ""} ${err.message}`);
48
+ banner(`[progress-server] exiting reason=error code=${err.code ?? "unknown"}`);
49
+ process.exit(1);
50
+ });
51
+ server.listen(port, "0.0.0.0", () => {
52
+ banner(`[progress-server] listening port=${port} log=${logPath} scope=${scopeUnit}`);
53
+ });
54
+ var installerSeenActive = false;
55
+ var WATCHDOG_INTERVAL_MS = 2e3;
56
+ var GRACE_UNTIL = Date.now() + 5e3;
57
+ function shutdown(reason) {
58
+ banner(`[progress-server] exiting reason=${reason}`);
59
+ server.close(() => process.exit(0));
60
+ setTimeout(() => process.exit(0), 500).unref();
61
+ }
62
+ var watchdog = setInterval(() => {
63
+ const result = spawnSync("systemctl", ["--user", "is-active", scopeUnit], { stdio: "pipe" });
64
+ const status = result.stdout?.toString().trim();
65
+ if (status === "active") {
66
+ installerSeenActive = true;
67
+ return;
68
+ }
69
+ if (!installerSeenActive && Date.now() < GRACE_UNTIL) return;
70
+ if (!installerSeenActive) {
71
+ banner(`[progress-server] exiting reason=scope-inactive (installer never reached active)`);
72
+ }
73
+ clearInterval(watchdog);
74
+ shutdown("scope-inactive");
75
+ }, WATCHDOG_INTERVAL_MS);
76
+ process.on("SIGTERM", () => {
77
+ clearInterval(watchdog);
78
+ shutdown("sigterm");
79
+ });
80
+ process.on("SIGINT", () => {
81
+ clearInterval(watchdog);
82
+ shutdown("sigint");
83
+ });