summrise-agent 1.2.457 → 1.2.459

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.
Files changed (2) hide show
  1. package/bin/summrise.js +42 -37
  2. package/package.json +1 -1
package/bin/summrise.js CHANGED
@@ -334,35 +334,35 @@ function desktopTaskPs(installQ) {
334
334
  `Start-ScheduledTask -TaskName SummriseDesktop`,
335
335
  ];
336
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.
337
+ /** The desktop shell's START script, as a file — NOT a `-Command` string.
341
338
  *
342
- * TWO THINGS MEASURED ON THE DEVICE, both of which made the first version of this wrong:
339
+ * WHY A FILE, and this is the third thing the device taught us: the CLI spawns with
340
+ * `shell: true`, so every command goes through cmd.exe, and **cmd treats `&` as a command
341
+ * separator**. The PowerShell call operator `&` therefore split the command in half, the
342
+ * `$t` assignment never ran, and the command fell through to re-registering the task —
343
+ * which then failed on the service account's principal. One metacharacter, two unrelated
344
+ * looking failures. `powershell -File "<path>"` has no metacharacters to mangle, and the
345
+ * operator can READ what the command does.
343
346
  *
344
- * 1. `powershell -File '<path>'` DOES NOT WORK. The single quotes are for PowerShell's own
345
- * strings; at the cmd layer they are literal characters, so PowerShell received a path
346
- * with quotes in it and answered "不支持给定路径的格式" (the path format is not
347
- * supported). Double quotes are what `-File` wants, and `psq()` — which escapes for a
348
- * PS string — is the wrong tool here. The same mistake sat in `setup`, unnoticed because
349
- * the task had been registered by hand.
350
- *
351
- * 2. DO NOT RE-REGISTER THE TASK TO START IT. `Register-ScheduledTask` needs the user's
352
- * principal as `DOMAIN\user`, and a shell running as a service account has no such
353
- * mapping: from a PTY running as systemprofile the device answered "帐户名与安全标识间
354
- * 无任何映射完成 … UserId" while the task itself was Ready. The task already carries the
355
- * right principal — it is `setup` that creates it — so starting it is all that is needed,
356
- * and registering is reserved for the case where it is genuinely absent. */
347
+ * Prints ONE WORD the CLI can trust: `already-running`, `started`, or `not-started`.
348
+ * Pure; the CLI writes it and runs it. unit-tested. */
357
349
  function desktopStartPs(installQ) {
358
350
  return [
359
- `if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'already-running'; exit 0 }`,
360
- `$t = Get-ScheduledTask -TaskName SummriseDesktop -ErrorAction SilentlyContinue`,
351
+ "# written by `summrise desktop` -- ask for the window, or say it is already there.",
352
+ "$ErrorActionPreference = 'Stop'",
353
+ "if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'already-running'; exit 0 }",
354
+ "# DO NOT RE-REGISTER THE TASK TO START IT. Register-ScheduledTask needs the interactive",
355
+ "# user's principal as DOMAIN\\user, and a shell running as a service account has no such",
356
+ "# mapping -- the device answered \"No mapping between account names and security IDs was",
357
+ "# done ... UserId\" from a PTY running as systemprofile, while the task itself was Ready.",
358
+ "# The task already carries the right principal -- `summrise setup` creates it -- so starting",
359
+ "# it is all that is needed.",
360
+ "$t = Get-ScheduledTask -TaskName SummriseDesktop -ErrorAction SilentlyContinue",
361
361
  `if (-not $t) { & powershell -NoProfile -ExecutionPolicy Bypass -File "${installQ}\\scripts\\register-desktop-task.ps1" }`,
362
- `Start-ScheduledTask -TaskName SummriseDesktop -ErrorAction SilentlyContinue`,
363
- `Start-Sleep -Seconds 3`,
364
- `if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'started' } else { Write-Output 'not-started'; exit 1 }`,
365
- ].join("; ");
362
+ "Start-ScheduledTask -TaskName SummriseDesktop -ErrorAction SilentlyContinue",
363
+ "Start-Sleep -Seconds 3",
364
+ "if (Get-Process electron -ErrorAction SilentlyContinue) { Write-Output 'started' } else { Write-Output 'not-started'; exit 1 }",
365
+ ];
366
366
  }
367
367
  // exported: agent bind port plumbing (custom-port installs). server.port
368
368
  // out of <dir>/config.yaml (first `port:` under top-level `server:`),
@@ -1795,8 +1795,8 @@ const commands = {
1795
1795
  fs.writeFileSync(reg, desktopTaskPs(DIR).join("\r\n") + "\r\n");
1796
1796
  sh(
1797
1797
  // DOUBLE quotes — a cmd-layer argument. The single-quoted version this shipped with
1798
- // reached PowerShell with the quotes included and died on the device with
1799
- // "不支持给定路径的格式" (unsupported path format).
1798
+ // reached PowerShell with the quotes included and died on the device with "unsupported
1799
+ // path format" for a path that was perfectly valid.
1800
1800
  `powershell -NoProfile -ExecutionPolicy Bypass -File "${reg}"`);
1801
1801
  console.log("setup: SummriseDesktop registered (logon + a 5-minute watchdog) and started");
1802
1802
  }
@@ -2005,7 +2005,7 @@ const commands = {
2005
2005
  //
2006
2006
  // WHY IT EXISTS. The shell is normally started by the SummriseDesktop task, but the LAUNCHER
2007
2007
  // dies with the console that started it — measured twice on 2026-09-23, both times arriving
2008
- // as "electron 又不见了" — and until now there was no command to ask for it, only a .ps1 path
2008
+ // as "the electron window is gone again" — and until now there was no command to ask for it, only a .ps1 path
2009
2009
  // an operator had to know. Idempotent by construction (the task's ensure-desktop.ps1 exits
2010
2010
  // when electron is alive, so a running shell is never disturbed), and it distinguishes the
2011
2011
  // three outcomes. "ok" without saying WHICH is how an operator ends up staring at a desktop.
@@ -2017,16 +2017,21 @@ const commands = {
2017
2017
  // writes, from the same builder, so the two cannot drift.
2018
2018
  fs.writeFileSync(reg, desktopTaskPs(DIR).join("\r\n") + "\r\n");
2019
2019
  }
2020
- try {
2021
- // DOUBLE quotes: this is a cmd-layer argument, and `psq()` escapes for a PowerShell
2022
- // string instead — the single-quoted version reached PowerShell with the quotes still in
2023
- // it and failed on the device with "unsupported path format". Same fix in `setup` below.
2024
- sh(`powershell -NoProfile -ExecutionPolicy Bypass -File "${reg}"`);
2025
- }
2026
- catch {
2027
- /* the task may already exist and be healthy; the check below is the verdict */
2028
- }
2029
- const r = (0, child_process_1.spawnSync)("powershell", ["-NoProfile", "-Command", desktopStartPs(DIR)], { encoding: "utf8", shell: true });
2020
+ // THE START SCRIPT GOES IN A FILE, AND ONLY IT DECIDES WHETHER TO REGISTER. Spawning with
2021
+ // `shell: true` means cmd.exe, and **cmd splits a command on `&`** — the PowerShell call
2022
+ // operator in the middle of this logic cut the command in half on the device, so the `$t`
2023
+ // assignment never ran and it fell through to re-registering a task that already existed,
2024
+ // which then failed on the service account's principal. Two failures, one metacharacter.
2025
+ const start = path.join(SCRIPTS_DIR, "desktop-start.ps1");
2026
+ fs.writeFileSync(start, desktopStartPs(DIR).join("\r\n") + "\r\n");
2027
+ // The register script is WRITTEN here (a machine that never ran setup still gets a working
2028
+ // task, from the same builder setup uses) but NOT run: desktop-start.ps1 runs it only when
2029
+ // the task is genuinely missing.
2030
+ // ONE STRING, NOT an args array. With `shell: true` Node concatenates the arguments and warns
2031
+ // about it (DEP0190: "the arguments are not escaped, only concatenated") — a warning the
2032
+ // operator saw on the device the first time this command worked. The path is double-quoted,
2033
+ // which is what -File accepts at the cmd layer; nothing here needs an argument list.
2034
+ const r = (0, child_process_1.spawnSync)(`powershell -NoProfile -ExecutionPolicy Bypass -File "${start}"`, { encoding: "utf8", shell: true });
2030
2035
  const out = String(r.stdout || "").trim();
2031
2036
  if (out.endsWith("already-running")) {
2032
2037
  console.log("desktop: the Summrise shell is ALREADY RUNNING (look for the window, or the tray icon)");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "summrise-agent",
3
- "version": "1.2.457",
3
+ "version": "1.2.459",
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": {