summrise-agent 1.2.454 → 1.2.455
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 +117 -0
- package/package.json +1 -1
- package/summrise-agent.exe +0 -0
package/bin/summrise.js
CHANGED
|
@@ -62,6 +62,9 @@ exports.newestOf = newestOf;
|
|
|
62
62
|
exports.latestReleaseVersion = latestReleaseVersion;
|
|
63
63
|
exports.cdnBase = cdnBase;
|
|
64
64
|
exports.componentUrl = componentUrl;
|
|
65
|
+
exports.componentKey = componentKey;
|
|
66
|
+
exports.componentPins = componentPins;
|
|
67
|
+
exports.sha256File = sha256File;
|
|
65
68
|
exports.resolveComponent = resolveComponent;
|
|
66
69
|
exports.ensureElectron = ensureElectron;
|
|
67
70
|
exports.statusReport = statusReport;
|
|
@@ -810,6 +813,37 @@ function cdnBase() {
|
|
|
810
813
|
function componentUrl(name) {
|
|
811
814
|
return `${cdnBase()}/summrise-agent/${name}`;
|
|
812
815
|
}
|
|
816
|
+
/** The release manifest's key for a component's FILE name (they are not the same string). */
|
|
817
|
+
function componentKey(fileName) {
|
|
818
|
+
if (fileName.startsWith("summrise-playwright"))
|
|
819
|
+
return "playwright";
|
|
820
|
+
if (fileName.startsWith("electron-"))
|
|
821
|
+
return "electron";
|
|
822
|
+
if (fileName.startsWith("cloudflared"))
|
|
823
|
+
return "cloudflared";
|
|
824
|
+
return null; // a file this release does not pin (e.g. fix-tunnel.ps1)
|
|
825
|
+
}
|
|
826
|
+
/** The manifest's component pins, or {} when it carries none (an older release). */
|
|
827
|
+
function componentPins() {
|
|
828
|
+
const r = (0, child_process_1.spawnSync)("curl", ["-s", "-m", "5", `${cdnBase()}/api/version`], {
|
|
829
|
+
encoding: "utf8",
|
|
830
|
+
timeout: 8000,
|
|
831
|
+
});
|
|
832
|
+
if (r.status !== 0 || !r.stdout)
|
|
833
|
+
return {};
|
|
834
|
+
try {
|
|
835
|
+
const j = JSON.parse(r.stdout);
|
|
836
|
+
const c = j && typeof j.components === "object" ? j.components : null;
|
|
837
|
+
return c || {};
|
|
838
|
+
}
|
|
839
|
+
catch {
|
|
840
|
+
return {};
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
/** sha256 of a file. Read whole: the electron runtime is 115 MB and node's heap is fine with it. */
|
|
844
|
+
function sha256File(p) {
|
|
845
|
+
return crypto.createHash("sha256").update(fs.readFileSync(p)).digest("hex");
|
|
846
|
+
}
|
|
813
847
|
/**
|
|
814
848
|
* A boxed component's local path: the copy inside the package if it is there,
|
|
815
849
|
* otherwise the release host's route for it, downloaded to a temp file.
|
|
@@ -837,6 +871,27 @@ function resolveComponent(name, pkgPath) {
|
|
|
837
871
|
if (r.status !== 0 || !fs.existsSync(dest) || fs.statSync(dest).size === 0) {
|
|
838
872
|
return null;
|
|
839
873
|
}
|
|
874
|
+
// VERIFY WHAT WAS FETCHED (grilling Q4). Until this existed, a worker serving
|
|
875
|
+
// different bytes would have been staged without complaint — the components are
|
|
876
|
+
// executed or loaded, so "the host said so" is not an anchor. The manifest that
|
|
877
|
+
// /api/version serves carries a sha256 per component (index/components.json,
|
|
878
|
+
// copied in at publish time); a pin that does not match REFUSES the component,
|
|
879
|
+
// because the failure it prevents is a device running bytes nobody published.
|
|
880
|
+
// No pin at all (an older release) is a warning, not a refusal: it must not make
|
|
881
|
+
// an install impossible.
|
|
882
|
+
const key = componentKey(name);
|
|
883
|
+
const pin = key ? (componentPins()[key] || {}).sha256 || "" : "";
|
|
884
|
+
if (pin) {
|
|
885
|
+
const got = sha256File(dest);
|
|
886
|
+
if (got !== pin) {
|
|
887
|
+
console.error(`setup: REFUSING ${name} — sha256 ${got.slice(0, 12)}… does not match the release manifest's ${pin.slice(0, 12)}… (the host served different bytes than it published)`);
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
console.log(`setup: ${name} verified against the release manifest (${pin.slice(0, 12)}…)`);
|
|
891
|
+
}
|
|
892
|
+
else if (key) {
|
|
893
|
+
console.log(`setup: ${name} fetched WITHOUT a manifest pin — not verified`);
|
|
894
|
+
}
|
|
840
895
|
console.log(`setup: ${name} fetched from the release host (not in the package)`);
|
|
841
896
|
return dest;
|
|
842
897
|
}
|
|
@@ -1638,6 +1693,68 @@ const commands = {
|
|
|
1638
1693
|
console.log(elDist
|
|
1639
1694
|
? "setup: electron runtime ready for the desktop shell"
|
|
1640
1695
|
: "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.");
|
|
1696
|
+
// ── Q9: leave a `summrise` COMMAND behind ──────────────────────────────────
|
|
1697
|
+
// `npx summrise-agent setup` installs the service and nothing puts the CLI on
|
|
1698
|
+
// PATH, so the very commands this output recommends (`summrise update`,
|
|
1699
|
+
// `summrise status`) are command-not-found — measured on d1 on 2026-09-23.
|
|
1700
|
+
// Installing THIS version by name keeps it deterministic and uses npm's own
|
|
1701
|
+
// shims rather than hand-written ones; when npm cannot, say the command.
|
|
1702
|
+
{
|
|
1703
|
+
const selfVer = String(require("../package.json").version || "");
|
|
1704
|
+
const pfx = (0, child_process_1.spawnSync)("npm", ["prefix", "-g"], { encoding: "utf8", shell: true });
|
|
1705
|
+
const pre = pfx.status === 0 ? String(pfx.stdout || "").trim() : "";
|
|
1706
|
+
if (selfVer && pre) {
|
|
1707
|
+
const inst = (0, child_process_1.spawnSync)("npm", [
|
|
1708
|
+
"i",
|
|
1709
|
+
"-g",
|
|
1710
|
+
`summrise-agent@${selfVer}`,
|
|
1711
|
+
"--prefix",
|
|
1712
|
+
pre,
|
|
1713
|
+
"--registry=https://registry.npmjs.org/",
|
|
1714
|
+
"--no-audit",
|
|
1715
|
+
"--no-fund",
|
|
1716
|
+
], { encoding: "utf8", shell: true, timeout: 300000 });
|
|
1717
|
+
console.log(inst.status === 0
|
|
1718
|
+
? `setup: ${selfVer} installed globally -- \`summrise status\` works from any shell`
|
|
1719
|
+
: `setup: WARNING -- could not install the CLI globally; run: npm i -g summrise-agent@${selfVer}`);
|
|
1720
|
+
}
|
|
1721
|
+
else {
|
|
1722
|
+
console.log(`setup: WARNING -- could not resolve npm's global prefix; run: npm i -g summrise-agent@${selfVer || "<version>"}`);
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
// ── the desktop shell's task: ONLOGON + a 5-minute watchdog ────────────────
|
|
1726
|
+
// `summrise autostart` has always said "the desktop task comes from the
|
|
1727
|
+
// installer", and the NSIS installer is RETIRED — so NOTHING created it. Measured
|
|
1728
|
+
// on d1: the window vanished with the console that launched it and
|
|
1729
|
+
// SummriseDesktop did not exist at all. The shape is the app's own, written to a
|
|
1730
|
+
// .ps1 so it can be read rather than escaped into one unreadable line:
|
|
1731
|
+
// ensure-desktop.ps1 exits when electron is already alive (the watchdog never
|
|
1732
|
+
// steals focus), the .vbs wrapper runs it with no console flash, and the 5-minute
|
|
1733
|
+
// repetition is what reborns a dead shell.
|
|
1734
|
+
try {
|
|
1735
|
+
const reg = path.join(SCRIPTS_DIR, "register-desktop-task.ps1");
|
|
1736
|
+
fs.writeFileSync(reg, [
|
|
1737
|
+
"# written by `summrise setup` -- the desktop shell's ONLOGON task + watchdog.",
|
|
1738
|
+
"$ErrorActionPreference = 'Stop'",
|
|
1739
|
+
`$q = '${(0, exports.psq)(DIR)}'`,
|
|
1740
|
+
`$en = Join-Path $q 'scripts\\ensure-desktop.ps1'`,
|
|
1741
|
+
`$vb = Join-Path $q 'scripts\\desktop-pulse.vbs'`,
|
|
1742
|
+
`Set-Content -Path $en -Value ('if (Get-Process electron -ErrorAction SilentlyContinue) { exit }; & powershell -NoProfile -ExecutionPolicy Bypass -File "' + $q + '\\scripts\\start-desktop.ps1"') -Force`,
|
|
1743
|
+
`Set-Content -Path $vb -Value ('CreateObject("WScript.Shell").Run "powershell -NoProfile -ExecutionPolicy Bypass -File " & Chr(34) & "' + $en + '" & Chr(34), 0, False') -Force`,
|
|
1744
|
+
`$da = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('"' + $vb + '"') -WorkingDirectory $q`,
|
|
1745
|
+
`$dt1 = New-ScheduledTaskTrigger -AtLogOn`,
|
|
1746
|
+
`$dw1 = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(3) -RepetitionInterval (New-TimeSpan -Minutes 5)`,
|
|
1747
|
+
`$pr = New-ScheduledTaskPrincipal -UserId ('{0}\\{1}' -f $env:USERDOMAIN, $env:USERNAME) -LogonType Interactive -RunLevel Highest`,
|
|
1748
|
+
`$st = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 10) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -MultipleInstances IgnoreNew`,
|
|
1749
|
+
`Register-ScheduledTask SummriseDesktop -Action $da -Trigger @($dt1,$dw1) -Principal $pr -Settings $st -Force | Out-Null`,
|
|
1750
|
+
`Start-ScheduledTask -TaskName SummriseDesktop`,
|
|
1751
|
+
].join("\r\n") + "\r\n");
|
|
1752
|
+
sh(`powershell -NoProfile -ExecutionPolicy Bypass -File '${(0, exports.psq)(reg)}'`);
|
|
1753
|
+
console.log("setup: SummriseDesktop registered (logon + a 5-minute watchdog) and started");
|
|
1754
|
+
}
|
|
1755
|
+
catch {
|
|
1756
|
+
console.log(`setup: WARNING -- could not register SummriseDesktop; run: powershell -File "${SCRIPTS_DIR}\\register-desktop-task.ps1"`);
|
|
1757
|
+
}
|
|
1641
1758
|
// Layout v2: write the start-desktop.ps1 launcher into scripts\ (the
|
|
1642
1759
|
// SummriseDesktop onlogon task + desktop Summrise.lnk both call it). Was never
|
|
1643
1760
|
// 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.
|
|
3
|
+
"version": "1.2.455",
|
|
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": {
|
package/summrise-agent.exe
CHANGED
|
Binary file
|