summrise-agent 1.2.453 → 1.2.454

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/bin/summrise.js CHANGED
@@ -60,6 +60,10 @@ exports.latestCdnVersion = latestCdnVersion;
60
60
  exports.latestNpmVersion = latestNpmVersion;
61
61
  exports.newestOf = newestOf;
62
62
  exports.latestReleaseVersion = latestReleaseVersion;
63
+ exports.cdnBase = cdnBase;
64
+ exports.componentUrl = componentUrl;
65
+ exports.resolveComponent = resolveComponent;
66
+ exports.ensureElectron = ensureElectron;
63
67
  exports.statusReport = statusReport;
64
68
  exports.isBehind = isBehind;
65
69
  exports.behindBy = behindBy;
@@ -81,6 +85,7 @@ exports.rollbackVersionOk = rollbackVersionOk;
81
85
  const child_process_1 = require("child_process");
82
86
  const crypto = __importStar(require("crypto"));
83
87
  const fs = __importStar(require("fs"));
88
+ const os = __importStar(require("os"));
84
89
  const path = __importStar(require("path"));
85
90
  const EXE_SRC = path.join(__dirname, "..", "summrise-agent.exe");
86
91
  // C1 (2026-08-28): the registry is the single source of truth for the install
@@ -797,6 +802,81 @@ function newestOf(a, b) {
797
802
  function latestReleaseVersion() {
798
803
  return newestOf(latestCdnVersion(), latestNpmVersion());
799
804
  }
805
+ /** The release host this CLI already trusts for version checks. */
806
+ function cdnBase() {
807
+ return (process.env.SUMMRISE_CDN || "https://agent.saisi.online").replace(/\/+$/, "");
808
+ }
809
+ /** Where a boxed component lives on that host. Pure — the tests pin it. */
810
+ function componentUrl(name) {
811
+ return `${cdnBase()}/summrise-agent/${name}`;
812
+ }
813
+ /**
814
+ * A boxed component's local path: the copy inside the package if it is there,
815
+ * otherwise the release host's route for it, downloaded to a temp file.
816
+ *
817
+ * WHY THIS EXISTS (2026-09-23). The npm package carries NONE of the big
818
+ * binaries on purpose (cloudflared 54 MB, playwright 31 MB, electron 234 MB), so
819
+ * "not in the package" used to mean "you do not get it, ever" — setup printed a
820
+ * line and moved on. The same shape for cloudflared left a freshly migrated
821
+ * device with no tunnel, and a device with no tunnel is INVISIBLE TO THE
822
+ * CONSOLE while looking perfectly healthy from inside: an hour of that is what
823
+ * this function is for. The release host serves all three, and for cloudflared
824
+ * it proxies a PINNED upstream asset, which the agent's own sha256 pin then
825
+ * checks again on the path it uses.
826
+ *
827
+ * `null` when neither source works: every component here is optional to the
828
+ * AGENT, and a failed fetch must not fail the install.
829
+ */
830
+ function resolveComponent(name, pkgPath) {
831
+ if (fs.existsSync(pkgPath))
832
+ return pkgPath;
833
+ const dest = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "summrise-comp-")), name);
834
+ // -f: an HTTP error is a FAILURE, not a 404 page written to disk (the
835
+ // HTML-polluted download that round-54 exists to remember).
836
+ const r = (0, child_process_1.spawnSync)("curl", ["-fsSL", "-m", "300", "-o", dest, componentUrl(name)], { encoding: "utf8", timeout: 320000 });
837
+ if (r.status !== 0 || !fs.existsSync(dest) || fs.statSync(dest).size === 0) {
838
+ return null;
839
+ }
840
+ console.log(`setup: ${name} fetched from the release host (not in the package)`);
841
+ return dest;
842
+ }
843
+ /**
844
+ * Ensure the desktop shell's electron RUNTIME. The shell's sources are ~90 KB
845
+ * and ship in the package; the runtime is 234 MB and deliberately does not.
846
+ *
847
+ * WHY IT IS FETCHED AND NOT `npx electron`: the release host serves a PINNED
848
+ * upstream proxy of the official build (v33.4.11 when this was written), so a
849
+ * device behind the GFW needs no GitHub access and no ELECTRON_MIRROR — the two
850
+ * things that made the hand-install on 2026-09-23 need a mirror variable at all.
851
+ * `npx electron` would also mean rewriting the launcher, which calls
852
+ * `<shell>\node_modules\electron\dist\electron.exe` directly.
853
+ *
854
+ * The zip's ROOT is the dist contents (`LICENSES.chromium.html` is its first
855
+ * entry — measured through the route, not assumed), so it expands into `dist`.
856
+ * Idempotent, and non-fatal: an install without a window still installs an agent.
857
+ */
858
+ function ensureElectron() {
859
+ const elDir = path.join(DESK_DIR, "node_modules", "electron");
860
+ const dist = path.join(elDir, "dist");
861
+ if (fs.existsSync(path.join(dist, "electron.exe")))
862
+ return dist;
863
+ const zip = resolveComponent("electron-win32-x64.zip", path.join(__dirname, "..", "electron-win32-x64.zip"));
864
+ if (!zip)
865
+ return null;
866
+ fs.mkdirSync(dist, { recursive: true });
867
+ sh(`powershell -NoProfile -Command "Expand-Archive -Force -Path '${(0, exports.psq)(zip)}' -DestinationPath '${(0, exports.psq)(dist)}'"`);
868
+ if (!fs.existsSync(path.join(dist, "electron.exe")))
869
+ return null;
870
+ try {
871
+ // The electron package's own lookup file; the launcher does not need it, but
872
+ // anything that resolves the package the npm way will.
873
+ fs.writeFileSync(path.join(elDir, "path.txt"), "electron.exe");
874
+ }
875
+ catch {
876
+ /* best-effort */
877
+ }
878
+ return dist;
879
+ }
800
880
  function statusReport(f) {
801
881
  const out = [];
802
882
  out.push(f.agentRunning === null
@@ -1467,8 +1547,8 @@ const commands = {
1467
1547
  // B2: stage the boxed playwright bundle (node_modules ONLY — node.exe is
1468
1548
  // NOT bundled; the system node detected below runs it). Single small
1469
1549
  // artifact in the npm package, Summrise version-locked.
1470
- const PW_ZIP = path.join(__dirname, "..", "summrise-playwright.zip");
1471
- if (fs.existsSync(PW_ZIP)) {
1550
+ const PW_ZIP = resolveComponent("summrise-playwright.zip", path.join(__dirname, "..", "summrise-playwright.zip"));
1551
+ if (PW_ZIP) {
1472
1552
  const pwDir = PW_DIR;
1473
1553
  fs.mkdirSync(pwDir, { recursive: true });
1474
1554
  sh(`powershell -NoProfile -Command "Expand-Archive -Force -Path '${(0, exports.psq)(PW_ZIP)}' -DestinationPath '${(0, exports.psq)(COMPONENTS_DIR)}'"`);
@@ -1503,7 +1583,7 @@ const commands = {
1503
1583
  }
1504
1584
  }
1505
1585
  else {
1506
- console.log("setup: summrise-playwright.zip not in package (browser tools disabled)");
1586
+ console.error("setup: WARNING -- the playwright bundle could not be obtained (not in the package, and the release host did not serve it); browser tools stay disabled.");
1507
1587
  }
1508
1588
  // Node runtime: the device has node (npm works), but the agent runs as
1509
1589
  // SYSTEM which may not see the user PATH — resolve the ABSOLUTE node path
@@ -1526,12 +1606,19 @@ const commands = {
1526
1606
  }
1527
1607
  // C2: stage the boxed cloudflared binary into components/ (optional — local
1528
1608
  // mode works without it; only used when the user opts into public access).
1529
- const CF_SRC = path.join(__dirname, "..", "cloudflared.exe");
1530
- if (fs.existsSync(CF_SRC)) {
1609
+ const CF_SRC = resolveComponent("cloudflared.exe", path.join(__dirname, "..", "cloudflared.exe"));
1610
+ if (CF_SRC) {
1531
1611
  fs.mkdirSync(COMPONENTS_DIR, { recursive: true });
1532
1612
  fs.copyFileSync(CF_SRC, path.join(COMPONENTS_DIR, "cloudflared.exe"));
1533
1613
  console.log("setup: cloudflared staged (tunnel optional -- `summrise tunnel install` to enable)");
1534
1614
  }
1615
+ else {
1616
+ // This branch used to be SILENT, and that silence is what the 2026-09-23
1617
+ // migration cost an hour of: a device with no cloudflared has no tunnel,
1618
+ // and a device with no tunnel cannot be reached from the console at all
1619
+ // while `summrise status` reports it healthy from inside.
1620
+ console.error("setup: WARNING -- cloudflared could NOT be staged (not in the package, and the release host did not serve it); this device will be unreachable from the console until the binary can be fetched.");
1621
+ }
1535
1622
  // P2-4: record the boxed-component versions (never fail-closed).
1536
1623
  writeBoxedVersions(DIR, path.join(__dirname, ".."));
1537
1624
  // round-330: Tauri summrise-desktop staging removed (retired).
@@ -1544,6 +1631,13 @@ const commands = {
1544
1631
  console.log(deskStaged > 0
1545
1632
  ? `setup: summrise-desktop-electron sources staged (${deskStaged} files)`
1546
1633
  : "setup: summrise-desktop-electron sources NOT staged -- the package did not ship them; the desktop shell will not update");
1634
+ // …and the runtime those sources need. Sources without a runtime is a shell
1635
+ // that cannot start: no window, and (before this) nothing in the output said
1636
+ // why — the operator saw only an absent window.
1637
+ const elDist = ensureElectron();
1638
+ console.log(elDist
1639
+ ? "setup: electron runtime ready for the desktop shell"
1640
+ : "setup: WARNING -- the electron runtime could not be obtained (not in the package, and the release host did not serve it); start-desktop.ps1 will not open a window until it can be fetched.");
1547
1641
  // Layout v2: write the start-desktop.ps1 launcher into scripts\ (the
1548
1642
  // SummriseDesktop onlogon task + desktop Summrise.lnk both call it). Was never
1549
1643
  // written before — a real gap that left the shell unlaunchable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "summrise-agent",
3
- "version": "1.2.453",
3
+ "version": "1.2.454",
4
4
  "description": "Summrise Agent — Windows device MCP server (terminal/SSH/serial) + panel. Self-hosted npm distribution.",
5
5
  "//build": "唯一构建路径:在本目录执行 npm run build。它是自包含的:经 npm exec 按需拉取 typescript@5,无需预装任何 node_modules(干净检出可跑;旧脚本引用 ../summrise-desktop-electron/node_modules/.bin/tsc,干净检出必 ENOENT)。必须用 npm exec --package … -- tsc 的形式:npx 会吃掉传给 tsc 的 -p/--outDir 等参数(round-435:npx 写法从未真正跑通过)。先编 electron TS(--noCheck 纯 emit,与 release.yml 一致)同步两处 src/*.js,再编 src/summrise.ts 到 bin/summrise.js 并校验 round-298 标记(弱 oracle,只证某次构建发生,新鲜性由 publish-release.sh 的 tsc 重编 + cmp 门保证)。",
6
6
  "bin": {
Binary file