nolo-cli 0.178.0-alpha.1 → 0.179.0-alpha.1

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 (65) hide show
  1. package/{_executeModel-4NEMABMW.js → _executeModel-ZP6M2EWK.js} +12 -12
  2. package/{agentDeleteCommand-7PYJJDKV.js → agentDeleteCommand-7TH3MY5U.js} +14 -14
  3. package/{agentEmailCommands-UYTOH7YV.js → agentEmailCommands-LVSCPVGC.js} +16 -16
  4. package/{agentListCommands-VONVOI52.js → agentListCommands-67HVR7KB.js} +5 -5
  5. package/{agentMachineCommands-XVBXKT5N.js → agentMachineCommands-36IZWYUV.js} +6 -6
  6. package/{agentRecordCommands-2R4K5YRD.js → agentRecordCommands-4AIFNXVY.js} +15 -15
  7. package/{agentRunCommand-7FNT4GPD.js → agentRunCommand-3B224VOA.js} +16 -16
  8. package/{agentRuntimeLocal-5ZHRXBGT.js → agentRuntimeLocal-I4J6XDO7.js} +5 -5
  9. package/{agentSlice-5EC6UO2Q.js → agentSlice-XYVD7VDW.js} +1 -1
  10. package/{appDeleteCommands-I56YU5PK.js → appDeleteCommands-VBI7C4IO.js} +5 -5
  11. package/{appDeployCommands-2BRC7I7B.js → appDeployCommands-FYUG5XWE.js} +5 -5
  12. package/{appDeployStatusCommands-2AM4QUP3.js → appDeployStatusCommands-TYHJOMUA.js} +5 -5
  13. package/{appGetCommands-6NBJYX6X.js → appGetCommands-HINYK5UT.js} +5 -5
  14. package/{appListCommands-QVJMOKWQ.js → appListCommands-NWDNQT4A.js} +5 -5
  15. package/{authCommand-R6RPVFOB.js → authCommand-UIF5UTYV.js} +2 -2
  16. package/{chunk-TWJYVVUB.js → chunk-6MXCQLLB.js} +74 -321
  17. package/{chunk-QULQPNYV.js → chunk-CIM3IW2X.js} +1 -1
  18. package/{chunk-CPCC25EW.js → chunk-CR5WXQX7.js} +1 -1
  19. package/{chunk-T2CVDTOD.js → chunk-CUVJE3L5.js} +2 -2
  20. package/{chunk-77357UA3.js → chunk-EEEBL4MX.js} +7 -7
  21. package/{chunk-OVQJYTGD.js → chunk-FSTHTTI6.js} +2 -2
  22. package/{chunk-7EEVCDHJ.js → chunk-GPA3EA3Q.js} +8 -8
  23. package/{chunk-2JNBSOOP.js → chunk-IAOVXFL7.js} +2 -2
  24. package/{chunk-JGG265CD.js → chunk-IU4FJDRU.js} +2 -2
  25. package/{chunk-MRJABJ7J.js → chunk-KMSMIOOL.js} +1 -1
  26. package/{chunk-7KZSSY4Z.js → chunk-L7PTHI3I.js} +2 -2
  27. package/{chunk-2SK76UW2.js → chunk-LM7VJUSD.js} +1 -1
  28. package/{chunk-ND4TKDIA.js → chunk-LOCHKPC4.js} +10 -10
  29. package/{chunk-QTIJKYFI.js → chunk-LRXTGAZ4.js} +5 -5
  30. package/{chunk-V4P5F66H.js → chunk-LY4HX6OD.js} +9 -9
  31. package/{chunk-Y3ZG4J2D.js → chunk-M7ZURZLR.js} +2 -2
  32. package/{chunk-3TI7DQZT.js → chunk-NQKFBJD4.js} +1 -1
  33. package/{chunk-IM3STC63.js → chunk-P2BGRAW7.js} +1 -1
  34. package/{chunk-2435U3W7.js → chunk-PP4TMS3T.js} +3 -3
  35. package/{chunk-D44HRXTA.js → chunk-UTZF3X4Z.js} +2 -2
  36. package/{chunk-VHBA3RHI.js → chunk-UVPKOBVG.js} +4 -4
  37. package/{chunk-JT5UEE22.js → chunk-X7YSFSY3.js} +3 -3
  38. package/{chunk-52J3DJHF.js → chunk-YO776XHS.js} +1 -1
  39. package/{chunk-ARLRYGPE.js → chunk-YOXGSXOV.js} +8 -8
  40. package/{commandRegistry-GS5FPBNY.js → commandRegistry-OW2MIVIT.js} +52 -52
  41. package/{contentThunks-SGJWVRBO.js → contentThunks-WNBEFSCD.js} +3 -3
  42. package/{createAgentAutomationAction-2USDJSCP.js → createAgentAutomationAction-NTL5ST3J.js} +3 -3
  43. package/{createDialogAction-ZY4NCOX7.js → createDialogAction-JWGDTE6S.js} +4 -4
  44. package/{createPageAction-JCMWP6AG.js → createPageAction-FPM5RD4C.js} +3 -3
  45. package/{dialogCommands-ZMYGE7YA.js → dialogCommands-D4MNLDBH.js} +5 -5
  46. package/{dialogSlice-3YNAYWAK.js → dialogSlice-QVQO4JCU.js} +2 -2
  47. package/{docCreateCommands-ADLHK2RD.js → docCreateCommands-765YJTNP.js} +5 -5
  48. package/{docDeleteCommands-52UOQ4CB.js → docDeleteCommands-G5U77546.js} +5 -5
  49. package/{docReadCommands-M3SUWJ6Q.js → docReadCommands-5YU7WGGT.js} +5 -5
  50. package/{docStore-A5HGECT6.js → docStore-VN2HSHLZ.js} +1 -1
  51. package/{docUpdateCommands-5YL5DPYY.js → docUpdateCommands-H2AHPZRW.js} +5 -5
  52. package/{handleSendMessageAction-EVFYTUQM.js → handleSendMessageAction-DMXH4YLX.js} +8 -8
  53. package/index.js +47 -22
  54. package/{localRuntimeAdapter-KFRYLFNW.js → localRuntimeAdapter-CQH4RFZC.js} +14 -14
  55. package/{machineCommands-ZTMLAMH5.js → machineCommands-TVCJZ5K5.js} +15 -15
  56. package/{machineWsRunDispatch-GU2J67QW.js → machineWsRunDispatch-663CSUA3.js} +15 -15
  57. package/package.json +1 -1
  58. package/{readlineWorkspace-KV3J6BSP.js → readlineWorkspace-PSJS3ZS2.js} +17 -17
  59. package/{runAgentClientLoop-7VHCVJ5F.js → runAgentClientLoop-J3CTCBSI.js} +10 -10
  60. package/{spaceCommands-TJX3HZPD.js → spaceCommands-2ESFYAZG.js} +5 -5
  61. package/{streamAgentChatTurn-K22LTOCL.js → streamAgentChatTurn-Z4DGKLGP.js} +14 -14
  62. package/{tools-4225EUMQ.js → tools-A2L3DK2Y.js} +7 -7
  63. package/{tuiSummaryLlmCaller-AECO3FZT.js → tuiSummaryLlmCaller-A6T54UJ3.js} +2 -2
  64. package/{updateCommands-C56QMWHF.js → updateCommands-BXGFH4VX.js} +1 -1
  65. package/{updateDialogTitleAction-5KXZAYTF.js → updateDialogTitleAction-WM5YYYFZ.js} +3 -3
@@ -28,40 +28,24 @@ import {
28
28
  mkdirSync,
29
29
  openSync,
30
30
  readFileSync,
31
- renameSync,
31
+ readdirSync,
32
32
  rmSync,
33
- statSync,
34
33
  writeSync,
35
34
  writeFileSync
36
35
  } from "node:fs";
37
36
  import { homedir, tmpdir } from "node:os";
38
37
  import { dirname, isAbsolute, join, normalize } from "node:path";
39
38
  import { randomUUID } from "node:crypto";
40
- var UPDATE_STATE_FILE = "update-result.json";
41
- var UPDATE_STALE_MS = 15 * 60 * 1e3;
42
- var UPDATE_CORRUPT_MAX_AGE_MS = 30 * 60 * 1e3;
43
39
  var UPDATE_LOCK_FILE = "update.lock";
44
40
  function resolveNoloHome(env, homeDir = homedir()) {
45
41
  return env.NOLO_HOME?.trim() || join(homeDir, ".nolo");
46
42
  }
47
- function resolveWindowsUpdateStatePath(env = process.env, homeDir = homedir()) {
48
- return join(resolveNoloHome(env, homeDir), "updates", UPDATE_STATE_FILE);
49
- }
50
43
  function resolveTrustedWindowsToolPaths(env, execPath, overrides) {
51
44
  const nodePath = overrides.nodePath ?? execPath;
52
45
  const npmCliPath = overrides.npmCliPath ?? join(dirname(nodePath), "node_modules", "npm", "bin", "npm-cli.js");
53
- const windowsRoot = env.SystemRoot?.trim() || env.WINDIR?.trim();
54
- const powershellPath = overrides.powershellPath ?? (windowsRoot ? join(
55
- windowsRoot,
56
- "System32",
57
- "WindowsPowerShell",
58
- "v1.0",
59
- "powershell.exe"
60
- ) : "");
61
46
  for (const [label, path] of Object.entries({
62
47
  nodePath,
63
- npmCliPath,
64
- powershellPath
48
+ npmCliPath
65
49
  })) {
66
50
  if (!path || !isAbsolute(path) || !existsSync(path)) {
67
51
  throw new Error(
@@ -69,7 +53,7 @@ function resolveTrustedWindowsToolPaths(env, execPath, overrides) {
69
53
  );
70
54
  }
71
55
  }
72
- return { nodePath, npmCliPath, powershellPath };
56
+ return { nodePath, npmCliPath };
73
57
  }
74
58
  function removeOwnedLock(lockPath, updateId) {
75
59
  try {
@@ -81,188 +65,20 @@ function removeOwnedLock(lockPath, updateId) {
81
65
  } catch {
82
66
  }
83
67
  }
84
- function writeJsonAtomic(path, value) {
85
- mkdirSync(dirname(path), { recursive: true });
86
- const tempPath = `${path}.${process.pid}.tmp`;
87
- writeFileSync(tempPath, `${JSON.stringify(value, null, 2)}
88
- `, "utf8");
89
- renameSync(tempPath, path);
90
- }
91
- function readWindowsUpdateState(env = process.env, homeDir = homedir()) {
92
- const statePath = resolveWindowsUpdateStatePath(env, homeDir);
93
- if (!existsSync(statePath)) return null;
94
- try {
95
- const parsed = JSON.parse(
96
- readFileSync(statePath, "utf8")
97
- );
98
- if (!parsed || !["pending", "success", "failed"].includes(parsed.status)) {
99
- return null;
100
- }
101
- return parsed;
102
- } catch {
103
- return null;
104
- }
105
- }
106
- function assessWindowsUpdatePending(state, now, statePath) {
107
- const startedAtMs = Date.parse(state.startedAt);
108
- const MAX_CLOCK_SKEW_MS = 5 * 60 * 1e3;
109
- if (Number.isFinite(startedAtMs) && startedAtMs - now <= MAX_CLOCK_SKEW_MS) {
110
- const ageMs = now - startedAtMs;
111
- const stale = ageMs >= UPDATE_STALE_MS;
112
- return {
113
- classification: stale ? "stale" : "active",
114
- ageMs,
115
- startedAtUsable: true,
116
- blocksStartup: !stale
117
- };
118
- }
119
- let mtimeAge = Number.NaN;
120
- try {
121
- mtimeAge = now - statSync(statePath).mtimeMs;
122
- } catch {
123
- }
124
- if (!Number.isFinite(mtimeAge) || mtimeAge < UPDATE_CORRUPT_MAX_AGE_MS) {
125
- return {
126
- classification: "corrupt-unageable",
127
- ageMs: mtimeAge,
128
- startedAtUsable: false,
129
- blocksStartup: true
130
- };
131
- }
132
- return {
133
- classification: "stale",
134
- ageMs: mtimeAge,
135
- startedAtUsable: false,
136
- blocksStartup: false
137
- };
138
- }
139
- function consumeWindowsUpdateStartupNotice(env = process.env, options = {}) {
68
+ function getWindowsUpdateStatus(env = process.env, options = {}) {
140
69
  const homeDir = options.homeDir ?? homedir();
141
- const statePath = resolveWindowsUpdateStatePath(env, homeDir);
142
- const state = readWindowsUpdateState(env, homeDir);
143
- if (!state) return null;
144
- if (state.status === "pending") {
145
- if (options.ownerUpdateId && state.updateId && options.ownerUpdateId === state.updateId) {
146
- return null;
147
- }
148
- const now = options.now ?? Date.now();
149
- const assessment = assessWindowsUpdatePending(state, now, statePath);
150
- if (assessment.blocksStartup) {
151
- return {
152
- blocking: true,
153
- text: `A Nolo update may still be in progress (${describeUpdatePhase(state)}). Run "nolo update status" for details, or retry shortly.
154
- Log: ${state.logPath}`
155
- };
156
- }
157
- if (state.lockPath && state.updateId) {
158
- removeOwnedLock(state.lockPath, state.updateId);
159
- }
160
- return {
161
- blocking: false,
162
- text: `The previous Nolo update helper stopped unexpectedly and its lock was released. Verify with "nolo -v" / "nolo update status"; a manual npm repair may be required.
163
- Log: ${state.logPath}`
164
- };
165
- }
166
- if (state.noticeAcknowledgedAt) {
167
- return null;
168
- }
169
- const acknowledged = {
170
- ...state,
171
- noticeAcknowledgedAt: (/* @__PURE__ */ new Date()).toISOString()
172
- };
70
+ const installedVersion = options.currentVersion ?? "unknown";
71
+ const logDir = join(resolveNoloHome(env, homeDir), "updates");
72
+ let lastLogPath;
173
73
  try {
174
- writeJsonAtomic(statePath, acknowledged);
74
+ const newest = readdirSync(logDir).filter((name) => name.startsWith("update-") && name.endsWith(".log")).sort().at(-1);
75
+ if (newest) lastLogPath = join(logDir, newest);
175
76
  } catch {
176
77
  }
177
- if (state.status === "success") {
178
- return {
179
- blocking: false,
180
- text: `Nolo updated successfully: ${state.currentVersion} -> ${state.targetVersion ?? "latest"}.
181
- Log: ${state.logPath}`
182
- };
183
- }
184
- return {
185
- blocking: false,
186
- text: `Nolo update failed. Verify with "nolo -v"; npm may require a manual repair.${state.message ? `
187
- ${state.message}` : ""}
188
- Log: ${state.logPath}`
189
- };
190
- }
191
- function describeUpdatePhase(state) {
192
- if (state.phase) {
193
- return `phase: ${state.phase}`;
194
- }
195
- return "helper running";
196
- }
197
- function getWindowsUpdateStatus(env = process.env, options = {}) {
198
- const homeDir = options.homeDir ?? homedir();
199
- const state = readWindowsUpdateState(env, homeDir);
200
- const now = options.now ?? Date.now();
201
- const version = options.currentVersion ?? "unknown";
202
- if (!state) {
203
- return {
204
- status: "none",
205
- alive: false,
206
- text: `No recorded Nolo update.
207
- Installed version: ${version}`
208
- };
209
- }
210
- const lines = [];
211
- lines.push(`Update status: ${state.status}`);
212
- lines.push(`Installed version: ${version}`);
213
- lines.push(`Channel: ${state.channel}`);
214
- lines.push(`From version: ${state.currentVersion}`);
215
- if (state.targetVersion) lines.push(`Target version: ${state.targetVersion}`);
216
- if (state.phase) lines.push(`Phase: ${state.phase}`);
217
- lines.push(`Started: ${state.startedAt}`);
218
- if (state.phaseStartedAt) lines.push(`Phase started: ${state.phaseStartedAt}`);
219
- if (state.phaseDeadline) lines.push(`Phase deadline: ${state.phaseDeadline}`);
220
- if (state.finishedAt) lines.push(`Finished: ${state.finishedAt}`);
221
- if (state.helperPid) lines.push(`Helper pid: ${state.helperPid}`);
222
- if (state.message) lines.push(`Message: ${state.message}`);
223
- lines.push(`Log: ${state.logPath}`);
224
- if (state.status === "pending") {
225
- const statePath = resolveWindowsUpdateStatePath(env, homeDir);
226
- const assessment = assessWindowsUpdatePending(state, now, statePath);
227
- const deadline = state.phaseDeadline ? Date.parse(state.phaseDeadline) : NaN;
228
- const pastDeadline = Number.isFinite(deadline) && now > deadline;
229
- if (pastDeadline) {
230
- lines.push(
231
- `Phase deadline elapsed: the recorded phase has run past its soft ceiling. This can be a hung helper, but it can also be a slow install \u2014 the lock is NOT auto-released on this evidence alone.`
232
- );
233
- }
234
- switch (assessment.classification) {
235
- case "active":
236
- lines.push(
237
- `Diagnosis: update record is fresh (${describeUpdatePhase(state)}). The helper process has not been verified alive; the record simply has not outlived its bound, so startup is still blocked.`
238
- );
239
- break;
240
- case "corrupt-unageable":
241
- lines.push(
242
- `Diagnosis: update record has an unreadable start time and cannot be aged reliably. Startup stays conservatively blocked until the record outlives its hard bound; inspect the log to tell a hung helper from a live one.`
243
- );
244
- break;
245
- case "stale":
246
- lines.push(
247
- `Diagnosis: update record has outlived its bound; the helper is presumed stopped. The startup guard releases the stale lock on next start, then this record remains here for diagnosis.`
248
- );
249
- break;
250
- }
251
- return {
252
- status: "pending",
253
- alive: assessment.blocksStartup,
254
- pendingClassification: assessment.classification,
255
- text: lines.join("\n")
256
- };
257
- }
258
- if (state.status === "success") {
259
- lines.push(
260
- state.noticeAcknowledgedAt ? `Diagnosis: update applied and already acknowledged.` : `Diagnosis: update applied; notice pending on next start.`
261
- );
262
- } else {
263
- lines.push(`Diagnosis: update failed; see the log above.`);
264
- }
265
- return { status: state.status, alive: false, text: lines.join("\n") };
78
+ const text = lastLogPath ? `Installed version: ${installedVersion}
79
+ Last update log: ${lastLogPath}` : `Installed version: ${installedVersion}
80
+ No recorded update log.`;
81
+ return { installedVersion, lastLogPath, text };
266
82
  }
267
83
  function defaultLaunchWindowsUpdateHelper(input) {
268
84
  const child = spawn(input.execPath, [input.helperPath, input.payload], {
@@ -284,26 +100,42 @@ const { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, readdirS
284
100
  const { dirname, isAbsolute, join, normalize, relative } = require("node:path");
285
101
 
286
102
  const payload = JSON.parse(Buffer.from(process.argv[2], "base64url").toString("utf8"));
287
- const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
288
103
  const log = (line) => appendFileSync(payload.logPath, "[" + new Date().toISOString() + "] " + line + "\n", "utf8");
289
- const writeState = (next) => {
290
- mkdirSync(dirname(payload.statePath), { recursive: true });
291
- const temp = payload.statePath + "." + payload.updateId + ".tmp";
292
- writeFileSync(temp, JSON.stringify(next, null, 2) + "\n", "utf8");
293
- renameSync(temp, payload.statePath);
294
- };
295
- // Record the current helper step with a bounded wall-clock deadline so the
296
- // startup guard can tell a live phase from a hung one. Deadline is a soft
297
- // ceiling: a phase that overruns it is reported stale, not killed.
298
- const setPhase = (base, phase, budgetMs) => {
299
- const phaseStartedAt = new Date().toISOString();
300
- const phaseDeadline = new Date(Date.now() + budgetMs).toISOString();
104
+ // 完成通知:best-effort。通知失败(无 PowerShell / 通知被禁用 / 无 notify-send)
105
+ // 一律静默,绝不能影响更新结果本身。
106
+ const notify = (title, message) => {
301
107
  try {
302
- writeState({ ...base, status: "pending", phase, phaseStartedAt, phaseDeadline });
303
- } catch (error) {
304
- log("Could not persist phase " + phase + ": " + (error && error.message ? error.message : String(error)));
305
- }
306
- return { ...base, status: "pending", phase, phaseStartedAt, phaseDeadline };
108
+ if (process.platform === "win32") {
109
+ const psPath = join(process.env.SystemRoot || process.env.WINDIR || "C:\\\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
110
+ // 脚本里不含任何动态文本:title/message 经环境变量传入。
111
+ // 拼接转义永远追不上解释器认的引号集合(ASCII 单引号、弯引号 ‘ ’ 都会被当成引号),
112
+ // 所以这里不用引号包裹,直接用 $env: 取值。
113
+ const ps = [
114
+ "Add-Type -AssemblyName System.Windows.Forms",
115
+ "Add-Type -AssemblyName System.Drawing",
116
+ "$n = New-Object System.Windows.Forms.NotifyIcon",
117
+ "$n.Icon = [System.Drawing.SystemIcons]::Information",
118
+ "$n.Visible = $true",
119
+ "$n.ShowBalloonTip(6000, $env:NOLO_NOTIFY_TITLE, $env:NOLO_NOTIFY_MESSAGE, 'Info')",
120
+ "Start-Sleep -Milliseconds 800",
121
+ "$n.Dispose()",
122
+ ].join("; ");
123
+ spawnSync(psPath, ["-NoProfile", "-NonInteractive", "-Command", ps], {
124
+ windowsHide: true,
125
+ timeout: 15000,
126
+ env: { ...process.env, NOLO_NOTIFY_TITLE: title, NOLO_NOTIFY_MESSAGE: message },
127
+ });
128
+ } else if (process.platform === "darwin") {
129
+ // 同理:AppleScript 通过 argv 取参,脚本正文是常量。
130
+ spawnSync(
131
+ "osascript",
132
+ ["-e", "on run argv", "-e", "display notification (item 2 of argv) with title (item 1 of argv)", "-e", "end run", title, message],
133
+ { timeout: 10000 },
134
+ );
135
+ } else {
136
+ spawnSync("notify-send", [title, message], { timeout: 10000 });
137
+ }
138
+ } catch {}
307
139
  };
308
140
  const runNpm = (args) => {
309
141
  const command = [payload.nodePath, payload.npmCliPath, ...args].join(" ");
@@ -320,20 +152,6 @@ const runNpm = (args) => {
320
152
  if (result.error) throw result.error;
321
153
  return { code: result.status == null ? 1 : result.status, stdout: String(result.stdout || "").trim() };
322
154
  };
323
- const listOtherNoloPids = () => {
324
- const script = "$selfPid=" + process.pid + "; Get-CimInstance Win32_Process | Where-Object { $_.ProcessId -ne $selfPid -and ($_.Name -ieq 'node.exe' -or $_.Name -ieq 'bun.exe') -and $_.CommandLine -and $_.CommandLine -match '\\\\node_modules\\\\nolo-cli\\\\index\\.js' } | ForEach-Object { $_.ProcessId }";
325
- const result = spawnSync(payload.powershellPath, ["-NoProfile", "-NonInteractive", "-Command", script], {
326
- encoding: "utf8",
327
- windowsHide: true,
328
- env: process.env,
329
- cwd: payload.updateDir,
330
- timeout: 10 * 1000,
331
- });
332
- if (result.error || result.status !== 0) {
333
- throw new Error("Could not verify that all other Nolo windows are closed");
334
- }
335
- return String(result.stdout || "").split(/\r?\n/).map((value) => value.trim()).filter(Boolean);
336
- };
337
155
  const parseVersion = (raw) => {
338
156
  const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(String(raw).trim());
339
157
  return match ? { main: [Number(match[1]), Number(match[2]), Number(match[3])], pre: match[4] ? match[4].split(".") : [] } : null;
@@ -478,33 +296,13 @@ const switchWindowsShims = (shimDir, entrypoint) => {
478
296
  updateId: payload.updateId,
479
297
  lockPath: payload.lockPath,
480
298
  };
481
- let progress = base;
299
+ let updateSucceeded = false;
300
+ let alreadyCurrent = false;
482
301
  try {
483
- progress = setPhase(base, "wait-parent-exit", 480 * 250 + 60 * 1000);
484
- log("Waiting for parent process " + payload.parentPid + " to exit");
485
- let parentExited = false;
486
- for (let waited = 0; waited < 480; waited++) {
487
- try { process.kill(payload.parentPid, 0); await delay(250); }
488
- catch { parentExited = true; break; }
489
- }
490
- if (!parentExited) throw new Error("Timed out waiting for the current Nolo process to exit");
491
- await delay(250);
492
-
493
- progress = setPhase(progress, "wait-other-windows", 120 * 1000 + 30 * 1000);
494
- const otherProcessDeadline = Date.now() + 120 * 1000;
495
- let otherPids = listOtherNoloPids();
496
- let checks = 0;
497
- while (otherPids.length > 0 && Date.now() < otherProcessDeadline) {
498
- if (checks === 0 || checks % 10 === 0) log("Waiting for other Nolo processes: " + otherPids.join(", "));
499
- await delay(1000);
500
- otherPids = listOtherNoloPids();
501
- checks++;
502
- }
503
- if (otherPids.length > 0) {
504
- throw new Error("Other Nolo processes are still running: " + otherPids.join(", "));
505
- }
506
-
507
- progress = setPhase(progress, "resolve-prefix", 30 * 1000);
302
+ // 2026-10-27 减法:不再等待父进程或其它 Nolo 窗口退出。
303
+ // 新版本写入独立版本目录、最后只切换入口,因此其它进程继续运行旧版本是安全的;
304
+ // 扫描 PID 也不构成真正的写入互斥(扫描结束后照样可以再启动一个进程)。
305
+ log("phase: resolve-prefix");
508
306
  const prefixResult = runNpm(["prefix", "-g"]);
509
307
  if (prefixResult.code !== 0 || !prefixResult.stdout) throw new Error("Could not resolve npm global prefix");
510
308
  const prefix = prefixResult.stdout.split(/\r?\n/).at(-1).trim();
@@ -514,8 +312,7 @@ const switchWindowsShims = (shimDir, entrypoint) => {
514
312
  if (!isWithin(expectedRoot, oldEntrypoint) && !isWithin(managedRoot, oldEntrypoint)) {
515
313
  throw new Error("Refusing to update a different npm prefix. Current entrypoint: " + payload.entrypointPath + "; npm prefix: " + prefix);
516
314
  }
517
-
518
- progress = setPhase(progress, "resolve-target-version", 30 * 1000);
315
+ log("phase: resolve-target-version");
519
316
  const targetResult = runNpm(["view", "nolo-cli@" + payload.channel, "version"]);
520
317
  if (targetResult.code !== 0 || !parseVersion(targetResult.stdout)) {
521
318
  throw new Error("Could not resolve nolo-cli@" + payload.channel + " target version");
@@ -526,7 +323,7 @@ const switchWindowsShims = (shimDir, entrypoint) => {
526
323
  }
527
324
 
528
325
  if (compare(targetVersion, payload.currentVersion) > 0) {
529
- progress = setPhase(progress, "install-target", 5 * 60 * 1000 + 30 * 1000);
326
+ log("phase: install-target");
530
327
  const versionPrefix = join(payload.managedRoot, targetVersion + "-" + payload.updateId);
531
328
  uncommittedVersionPrefix = versionPrefix;
532
329
  mkdirSync(versionPrefix, { recursive: true });
@@ -542,12 +339,12 @@ const switchWindowsShims = (shimDir, entrypoint) => {
542
339
  const stagedEntrypoint = join(versionPrefix, "node_modules", "nolo-cli", "index.js");
543
340
  if (!existsSync(stagedEntrypoint)) throw new Error("Staged nolo entrypoint is missing");
544
341
  assertLockOwnership();
545
- progress = setPhase(progress, "switch-shims", 60 * 1000);
342
+ log("phase: switch-shims");
546
343
  const switchedShims = switchWindowsShims(prefix, stagedEntrypoint);
547
344
  const verify = spawnSync(payload.nodePath, [stagedEntrypoint, "-v"], {
548
345
  encoding: "utf8",
549
346
  windowsHide: true,
550
- env: { ...process.env, NOLO_UPDATE_OWNER_ID: payload.updateId },
347
+ env: process.env,
551
348
  cwd: payload.updateDir,
552
349
  timeout: 30 * 1000,
553
350
  });
@@ -580,8 +377,9 @@ const switchWindowsShims = (shimDir, entrypoint) => {
580
377
  log("Verified nolo-cli " + targetVersion + " at " + stagedEntrypoint);
581
378
  } else {
582
379
  log("Already current at " + targetVersion);
380
+ alreadyCurrent = true;
583
381
  }
584
- writeState({ ...progress, status: "success", phase: "done", targetVersion, finishedAt: new Date().toISOString() });
382
+ updateSucceeded = true;
585
383
  } catch (error) {
586
384
  const message = error && error.message ? error.message : String(error);
587
385
  log("ERROR: " + message);
@@ -592,11 +390,6 @@ const switchWindowsShims = (shimDir, entrypoint) => {
592
390
  try { rmSync(uncommittedVersionPrefix, { recursive: true, force: true }); } catch {}
593
391
  }
594
392
  }
595
- if (lockOwnershipLost) {
596
- log("Not writing a failed status record: the update lock belongs to another updater");
597
- } else {
598
- writeState({ ...progress, status: "failed", finishedAt: new Date().toISOString(), message });
599
- }
600
393
  process.exitCode = 1;
601
394
  } finally {
602
395
  try {
@@ -606,6 +399,12 @@ const switchWindowsShims = (shimDir, entrypoint) => {
606
399
  }
607
400
  } catch {}
608
401
  try { rmSync(__filename, { force: true }); } catch {}
402
+ // 通知放在锁释放之后:同步通知最多阻塞十几秒,不能拖住下一次更新。
403
+ if (updateSucceeded) {
404
+ notify("Nolo", alreadyCurrent ? "Nolo is already up to date" : "Update finished - the next Nolo launch uses the new version");
405
+ } else {
406
+ notify("Nolo", "Update failed - see log: " + payload.logPath);
407
+ }
609
408
  }
610
409
  })();
611
410
  `;
@@ -613,8 +412,7 @@ const switchWindowsShims = (shimDir, entrypoint) => {
613
412
  function scheduleWindowsSelfUpdate(options) {
614
413
  const env = options.env ?? process.env;
615
414
  const homeDir = options.homeDir ?? homedir();
616
- const statePath = resolveWindowsUpdateStatePath(env, homeDir);
617
- const updateDir = dirname(statePath);
415
+ const updateDir = join(resolveNoloHome(env, homeDir), "updates");
618
416
  const managedRoot = join(resolveNoloHome(env, homeDir), "cli", "versions");
619
417
  const lockPath = join(updateDir, UPDATE_LOCK_FILE);
620
418
  const updateId = randomUUID();
@@ -630,29 +428,14 @@ function scheduleWindowsSelfUpdate(options) {
630
428
  try {
631
429
  const lockFd = openSync(lockPath, "wx");
632
430
  try {
633
- writeSync(
634
- lockFd,
635
- JSON.stringify({ updateId, startedAt }),
636
- void 0,
637
- "utf8"
638
- );
431
+ writeSync(lockFd, JSON.stringify({ updateId, startedAt }), void 0, "utf8");
639
432
  } finally {
640
433
  closeSync(lockFd);
641
434
  }
642
435
  } catch (error) {
643
- if (!readWindowsUpdateState(env, homeDir)) {
644
- try {
645
- const lock = JSON.parse(readFileSync(lockPath, "utf8"));
646
- const age = Date.now() - Date.parse(lock.startedAt ?? "");
647
- if (Number.isFinite(age) && age >= UPDATE_STALE_MS) {
648
- rmSync(lockPath, { force: true });
649
- return scheduleWindowsSelfUpdate(options);
650
- }
651
- } catch {
652
- }
653
- }
654
436
  throw new Error(
655
- `Another Nolo update is already pending (${lockPath}): ${error instanceof Error ? error.message : String(error)}`
437
+ `Another Nolo update is already pending (${lockPath}): ${error instanceof Error ? error.message : String(error)}
438
+ \u9501\u6587\u4EF6\u91CC\u8BB0\u5F55\u4E86\u6301\u6709\u8005\u7684 updateId \u4E0E\u5F00\u59CB\u65F6\u95F4\uFF1B\u66F4\u65B0\u65E5\u5FD7\u5728 ${updateDir} \u4E0B\uFF0C\u6309\u65F6\u95F4\u6392\u5E8F\u53D6\u6700\u65B0\u90A3\u4E2A\u3002\u786E\u8BA4\u6301\u6709\u5B83\u7684\u66F4\u65B0\u8FDB\u7A0B\u5DF2\u7ED3\u675F\u540E\uFF0C\u5220\u9664\u4E0A\u9762\u7684\u9501\u6587\u4EF6\u518D\u91CD\u8BD5\u3002`
656
439
  );
657
440
  }
658
441
  const execPath = options.execPath ?? process.execPath;
@@ -663,20 +446,10 @@ function scheduleWindowsSelfUpdate(options) {
663
446
  removeOwnedLock(lockPath, updateId);
664
447
  throw error;
665
448
  }
666
- const pending = {
667
- status: "pending",
668
- currentVersion: options.currentVersion,
669
- channel: options.channel,
670
- startedAt,
671
- logPath,
672
- updateId,
673
- lockPath
674
- };
675
449
  try {
676
450
  writeFileSync(helperPath, buildWindowsUpdateHelperSource(), "utf8");
677
451
  writeFileSync(logPath, `[${startedAt}] Windows update scheduled
678
452
  `, "utf8");
679
- writeJsonAtomic(statePath, pending);
680
453
  } catch (error) {
681
454
  removeOwnedLock(lockPath, updateId);
682
455
  rmSync(helperPath, { force: true });
@@ -684,12 +457,10 @@ function scheduleWindowsSelfUpdate(options) {
684
457
  }
685
458
  const payload = Buffer.from(
686
459
  JSON.stringify({
687
- parentPid: options.parentPid ?? process.pid,
688
460
  currentVersion: options.currentVersion,
689
461
  channel: options.channel,
690
462
  entrypointPath: normalize(options.entrypointPath),
691
463
  startedAt,
692
- statePath,
693
464
  logPath,
694
465
  updateDir,
695
466
  updateId,
@@ -709,28 +480,11 @@ function scheduleWindowsSelfUpdate(options) {
709
480
  env
710
481
  });
711
482
  } catch (error) {
712
- const state = readWindowsUpdateState(env, homeDir);
713
- if (state?.updateId === updateId) {
714
- rmSync(statePath, { force: true });
715
- }
716
483
  removeOwnedLock(lockPath, updateId);
717
484
  rmSync(helperPath, { force: true });
718
485
  throw error;
719
486
  }
720
- try {
721
- writeJsonAtomic(statePath, { ...pending, helperPid });
722
- } catch (error) {
723
- try {
724
- writeFileSync(
725
- logPath,
726
- `[${(/* @__PURE__ */ new Date()).toISOString()}] Could not persist helper pid: ${error instanceof Error ? error.message : String(error)}
727
- `,
728
- { encoding: "utf8", flag: "a" }
729
- );
730
- } catch {
731
- }
732
- }
733
- return { helperPid, statePath, logPath };
487
+ return { helperPid, logPath };
734
488
  }
735
489
 
736
490
  // packages/cli/updateCommands.ts
@@ -1207,13 +961,13 @@ Nolo Agent CLI Installer & Updater
1207
961
  `);
1208
962
  output.write(`\u2713 Target channel: ${channel} (nolo-cli@${channel})
1209
963
  `);
1210
- output.write(`\u2713 Safe Windows update scheduled (helper pid ${scheduled.helperPid}).
964
+ output.write(`\u2713 Update scheduled in background (helper pid ${scheduled.helperPid}).
1211
965
  `);
1212
- output.write(`\u25B8 Exit Nolo normally. Installation starts after this process releases its files.
966
+ output.write(`\u25B8 You can keep using Nolo \u2014 no need to close this or any other window.
1213
967
  `);
1214
- output.write(`\u25B8 Do not open another Nolo window until the update finishes.
968
+ output.write(`\u25B8 Installation continues in the background; once it finishes, the next Nolo launch uses the new version.
1215
969
  `);
1216
- output.write(` Log: ${scheduled.logPath}
970
+ output.write(` Check version: nolo -v Log: ${scheduled.logPath}
1217
971
 
1218
972
  `);
1219
973
  return { exitCode: 0, disposition: "scheduled" };
@@ -1277,7 +1031,6 @@ async function runSelfUpdate(outputOrOptions) {
1277
1031
  }
1278
1032
 
1279
1033
  export {
1280
- consumeWindowsUpdateStartupNotice,
1281
1034
  getWindowsUpdateStatus,
1282
1035
  getCliInstallChannel,
1283
1036
  renderProgressBar,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-NBTY7YJF.js";
6
6
  import {
7
7
  resolveCliLocalRuntimeKeyCapability
8
- } from "./chunk-7EEVCDHJ.js";
8
+ } from "./chunk-GPA3EA3Q.js";
9
9
  import {
10
10
  HIGH_RISK_MUTATION_TOOL_NAMES
11
11
  } from "./chunk-2GRXE3YJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveAgentImageInputSupport
3
- } from "./chunk-IM3STC63.js";
3
+ } from "./chunk-P2BGRAW7.js";
4
4
  import {
5
5
  TOOL_HAD_IMAGES,
6
6
  hadToolImages
@@ -333,7 +333,7 @@ async function saveDocState(arg, { dispatch, getState }) {
333
333
  ).unwrap();
334
334
  if (dbSpaceId) {
335
335
  try {
336
- const { updateContentTitle } = await import("./contentThunks-SGJWVRBO.js");
336
+ const { updateContentTitle } = await import("./contentThunks-WNBEFSCD.js");
337
337
  await dispatch(
338
338
  updateContentTitle({
339
339
  spaceId: dbSpaceId,
@@ -372,7 +372,7 @@ async function saveDocState(arg, { dispatch, getState }) {
372
372
  }
373
373
  }
374
374
  async function createDocState(args, thunkApi) {
375
- const { createPageAction } = await import("./createPageAction-JCMWP6AG.js");
375
+ const { createPageAction } = await import("./createPageAction-FPM5RD4C.js");
376
376
  return createPageAction(args, thunkApi);
377
377
  }
378
378
  function subscribe(listener) {
@@ -5,7 +5,7 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-2JNBSOOP.js";
8
+ } from "./chunk-IAOVXFL7.js";
9
9
  import {
10
10
  CONFIRMATION_INPUT_KEYS,
11
11
  INVALID_TOOL_ARGS_REPLACEMENT,
@@ -14,16 +14,16 @@ import {
14
14
  performFetchRequest,
15
15
  sanitizeOutboundMessages,
16
16
  stripModelToolArgs
17
- } from "./chunk-JGG265CD.js";
17
+ } from "./chunk-IU4FJDRU.js";
18
18
  import {
19
19
  findToolExecutor,
20
20
  toolDefinitionsByName
21
- } from "./chunk-7EEVCDHJ.js";
21
+ } from "./chunk-GPA3EA3Q.js";
22
22
  import {
23
23
  classifyApiError,
24
24
  classifyGenerationError,
25
25
  extractErrorDiagnostics
26
- } from "./chunk-D44HRXTA.js";
26
+ } from "./chunk-UTZF3X4Z.js";
27
27
  import {
28
28
  createSSEParser,
29
29
  createToolRunId,
@@ -32,7 +32,7 @@ import {
32
32
  toolRunSetPending,
33
33
  toolRunStarted,
34
34
  toolRunSucceeded
35
- } from "./chunk-OVQJYTGD.js";
35
+ } from "./chunk-FSTHTTI6.js";
36
36
  import {
37
37
  getPublicImageAgentMode
38
38
  } from "./chunk-VIDPVFP3.js";
@@ -42,10 +42,10 @@ import {
42
42
  messageStreaming,
43
43
  toolResultNeedsUserConfirmation,
44
44
  updateToolMessage
45
- } from "./chunk-ARLRYGPE.js";
45
+ } from "./chunk-YOXGSXOV.js";
46
46
  import {
47
47
  streamAgentChatTurn
48
- } from "./chunk-2435U3W7.js";
48
+ } from "./chunk-PP4TMS3T.js";
49
49
  import {
50
50
  getCurrentSpaceId
51
51
  } from "./chunk-ZJ7UHBJS.js";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-VYNMQ6HW.js";
9
9
  import {
10
10
  fetchAndCacheTableRows
11
- } from "./chunk-2SK76UW2.js";
11
+ } from "./chunk-LM7VJUSD.js";
12
12
  import {
13
13
  require_react
14
14
  } from "./chunk-YDH3FDFQ.js";
@@ -521,7 +521,7 @@ var executeToolRun = createAsyncThunk(
521
521
  if (!executionInput) {
522
522
  throw new Error(`ToolRun ${id} has no input to execute with.`);
523
523
  }
524
- const { findToolExecutor } = await import("./tools-4225EUMQ.js");
524
+ const { findToolExecutor } = await import("./tools-A2L3DK2Y.js");
525
525
  const { executor } = findToolExecutor(run.toolName);
526
526
  toolRunStarted({
527
527
  id: run.id,