summrise-agent 1.2.455 → 1.2.456
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 +77 -16
- package/package.json +1 -1
- package/summrise-agent.exe +0 -0
package/bin/summrise.js
CHANGED
|
@@ -38,6 +38,8 @@ exports.BOOT_TASKS = exports.psq = void 0;
|
|
|
38
38
|
exports.psArgv = psArgv;
|
|
39
39
|
exports.deskShortcutRepairPs = deskShortcutRepairPs;
|
|
40
40
|
exports.startDesktopPs = startDesktopPs;
|
|
41
|
+
exports.desktopTaskPs = desktopTaskPs;
|
|
42
|
+
exports.desktopStartPs = desktopStartPs;
|
|
41
43
|
exports.parseAgentPort = parseAgentPort;
|
|
42
44
|
exports.parseDeviceToken = parseDeviceToken;
|
|
43
45
|
exports.parseTargetArg = parseTargetArg;
|
|
@@ -305,6 +307,45 @@ function startDesktopPs(deskDirQ) {
|
|
|
305
307
|
`& "$dir\\node_modules\\electron\\dist\\electron.exe" .`,
|
|
306
308
|
];
|
|
307
309
|
}
|
|
310
|
+
/** The desktop shell's watchdog pair + its task, as ONE PowerShell script.
|
|
311
|
+
*
|
|
312
|
+
* WHY IT IS A FILE AND NOT AN INLINE -Command: it has to write two other files whose
|
|
313
|
+
* contents contain quotes, and every attempt to do that inside one command string turns
|
|
314
|
+
* into quoting hell — the first version of this shipped as a hand-written file for that
|
|
315
|
+
* reason. `summrise setup` writes it and `summrise desktop` runs it, so a machine that
|
|
316
|
+
* never ran setup can still get a working task by asking for the window. Idempotent:
|
|
317
|
+
* ensure-desktop.ps1 exits when electron is already alive, so the 5-minute trigger never
|
|
318
|
+
* steals focus. unit-tested. */
|
|
319
|
+
function desktopTaskPs(installQ) {
|
|
320
|
+
return [
|
|
321
|
+
"# written by `summrise setup` / `summrise desktop` -- the desktop shell's task + watchdog.",
|
|
322
|
+
"$ErrorActionPreference = 'Stop'",
|
|
323
|
+
`$q = '${installQ}'`,
|
|
324
|
+
`$en = Join-Path $q 'scripts\\ensure-desktop.ps1'`,
|
|
325
|
+
`$vb = Join-Path $q 'scripts\\desktop-pulse.vbs'`,
|
|
326
|
+
`Set-Content -Path $en -Value ('if (Get-Process electron -ErrorAction SilentlyContinue) { exit }; & powershell -NoProfile -ExecutionPolicy Bypass -File "' + $q + '\\scripts\\start-desktop.ps1"') -Force`,
|
|
327
|
+
`Set-Content -Path $vb -Value ('CreateObject("WScript.Shell").Run "powershell -NoProfile -ExecutionPolicy Bypass -File " & Chr(34) & "' + $en + '" & Chr(34), 0, False') -Force`,
|
|
328
|
+
`$da = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('"' + $vb + '"') -WorkingDirectory $q`,
|
|
329
|
+
`$dt1 = New-ScheduledTaskTrigger -AtLogOn`,
|
|
330
|
+
`$dw1 = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(3) -RepetitionInterval (New-TimeSpan -Minutes 5)`,
|
|
331
|
+
`$pr = New-ScheduledTaskPrincipal -UserId ('{0}\\{1}' -f $env:USERDOMAIN, $env:USERNAME) -LogonType Interactive -RunLevel Highest`,
|
|
332
|
+
`$st = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 10) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -MultipleInstances IgnoreNew`,
|
|
333
|
+
`Register-ScheduledTask SummriseDesktop -Action $da -Trigger @($dt1,$dw1) -Principal $pr -Settings $st -Force | Out-Null`,
|
|
334
|
+
`Start-ScheduledTask -TaskName SummriseDesktop`,
|
|
335
|
+
];
|
|
336
|
+
}
|
|
337
|
+
/** Ask whether the shell is up, and start it if it is not — printing ONE WORD the caller
|
|
338
|
+
* can trust: `already-running`, `started`, or `not-started`. A command that says "ok"
|
|
339
|
+
* without distinguishing those three is how an operator ends up staring at a desktop
|
|
340
|
+
* wondering whether anything happened. Pure; the CLI runs it. */
|
|
341
|
+
function desktopStartPs(installQ) {
|
|
342
|
+
return [
|
|
343
|
+
`if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'already-running'; exit 0 }`,
|
|
344
|
+
`& powershell -NoProfile -ExecutionPolicy Bypass -File '${installQ}\\scripts\\ensure-desktop.ps1'`,
|
|
345
|
+
`Start-Sleep -Seconds 3`,
|
|
346
|
+
`if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'started' } else { Write-Output 'not-started'; exit 1 }`,
|
|
347
|
+
].join("; ");
|
|
348
|
+
}
|
|
308
349
|
// exported: agent bind port plumbing (custom-port installs). server.port
|
|
309
350
|
// out of <dir>/config.yaml (first `port:` under top-level `server:`),
|
|
310
351
|
// canonical 18080 when absent/invalid/missing (fresh installs have no
|
|
@@ -1733,22 +1774,7 @@ const commands = {
|
|
|
1733
1774
|
// repetition is what reborns a dead shell.
|
|
1734
1775
|
try {
|
|
1735
1776
|
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");
|
|
1777
|
+
fs.writeFileSync(reg, desktopTaskPs(DIR).join("\r\n") + "\r\n");
|
|
1752
1778
|
sh(`powershell -NoProfile -ExecutionPolicy Bypass -File '${(0, exports.psq)(reg)}'`);
|
|
1753
1779
|
console.log("setup: SummriseDesktop registered (logon + a 5-minute watchdog) and started");
|
|
1754
1780
|
}
|
|
@@ -1953,6 +1979,41 @@ const commands = {
|
|
|
1953
1979
|
},
|
|
1954
1980
|
// Live view: redraw in place every few seconds until Ctrl+C. `summrise watch
|
|
1955
1981
|
// <host:port[/path]>` narrows it to one target and adds its outage log.
|
|
1982
|
+
// `summrise desktop` = put the window back, or say it is already there.
|
|
1983
|
+
//
|
|
1984
|
+
// WHY IT EXISTS. The shell is normally started by the SummriseDesktop task, but the LAUNCHER
|
|
1985
|
+
// dies with the console that started it — measured twice on 2026-09-23, both times arriving
|
|
1986
|
+
// as "electron 又不见了" — and until now there was no command to ask for it, only a .ps1 path
|
|
1987
|
+
// an operator had to know. Idempotent by construction (the task's ensure-desktop.ps1 exits
|
|
1988
|
+
// when electron is alive, so a running shell is never disturbed), and it distinguishes the
|
|
1989
|
+
// three outcomes. "ok" without saying WHICH is how an operator ends up staring at a desktop.
|
|
1990
|
+
desktop() {
|
|
1991
|
+
const reg = path.join(SCRIPTS_DIR, "register-desktop-task.ps1");
|
|
1992
|
+
fs.mkdirSync(SCRIPTS_DIR, { recursive: true });
|
|
1993
|
+
if (!fs.existsSync(reg)) {
|
|
1994
|
+
// A machine that never ran setup still gets a working task: the same script setup
|
|
1995
|
+
// writes, from the same builder, so the two cannot drift.
|
|
1996
|
+
fs.writeFileSync(reg, desktopTaskPs(DIR).join("\r\n") + "\r\n");
|
|
1997
|
+
}
|
|
1998
|
+
try {
|
|
1999
|
+
sh(`powershell -NoProfile -ExecutionPolicy Bypass -File '${(0, exports.psq)(reg)}'`);
|
|
2000
|
+
}
|
|
2001
|
+
catch {
|
|
2002
|
+
/* the task may already exist and be healthy; the check below is the verdict */
|
|
2003
|
+
}
|
|
2004
|
+
const r = (0, child_process_1.spawnSync)("powershell", ["-NoProfile", "-Command", desktopStartPs(DIR)], { encoding: "utf8", shell: true });
|
|
2005
|
+
const out = String(r.stdout || "").trim();
|
|
2006
|
+
if (out.endsWith("already-running")) {
|
|
2007
|
+
console.log("desktop: the Summrise shell is ALREADY RUNNING (look for the window, or the tray icon)");
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
if (out.endsWith("started")) {
|
|
2011
|
+
console.log("desktop: started -- the window should be on your desktop now");
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
console.error(`desktop: the shell did NOT come up. Try it directly to see why: powershell -File "${path.join(SCRIPTS_DIR, "start-desktop.ps1")}"`);
|
|
2015
|
+
process.exit(1);
|
|
2016
|
+
},
|
|
1956
2017
|
status() {
|
|
1957
2018
|
// NOT via shell: `shell: true` concatenates argv into one cmd.exe string,
|
|
1958
2019
|
// so the unquoted filter "IMAGENAME eq …" was split at its spaces, tasklist
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "summrise-agent",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.456",
|
|
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
|