nolo-cli 0.180.0-alpha.2 → 0.181.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 (72) hide show
  1. package/{_executeModel-ACI2KGWO.js → _executeModel-EJUKYBFV.js} +17 -17
  2. package/{agentDeleteCommand-LVSLONDD.js → agentDeleteCommand-OWDZDREL.js} +22 -21
  3. package/{agentEmailCommands-BKH3Q6I6.js → agentEmailCommands-RJGVOJXD.js} +22 -21
  4. package/{agentListCommands-JPKRBHMP.js → agentListCommands-GRJAY5ZE.js} +6 -5
  5. package/{agentMachineCommands-HRORJN73.js → agentMachineCommands-FNYZSZQ4.js} +3 -3
  6. package/{agentRecordCommands-OSZF2EHL.js → agentRecordCommands-EBDTISRS.js} +21 -20
  7. package/{agentRunCommand-FCGNSB4D.js → agentRunCommand-GIBVOCOK.js} +22 -21
  8. package/{agentRuntimeLocal-SWG5ULIJ.js → agentRuntimeLocal-AG7RCTM3.js} +2 -2
  9. package/{agentSlice-FCDRLXVA.js → agentSlice-LD6SEBSP.js} +1 -1
  10. package/{appDeleteCommands-YH3BYQYK.js → appDeleteCommands-DXF3IOFE.js} +7 -6
  11. package/{appDeployCommands-F44TNQJG.js → appDeployCommands-JVKZ3ATD.js} +7 -6
  12. package/{appDeployStatusCommands-BFTGFVQY.js → appDeployStatusCommands-VLGEMFV6.js} +7 -6
  13. package/{appGetCommands-SFLFIXPW.js → appGetCommands-JQN7RPBD.js} +7 -6
  14. package/{appListCommands-RUO5SEAJ.js → appListCommands-MFPVNCVT.js} +7 -6
  15. package/{authCommand-UIF5UTYV.js → authCommand-AX23Q2Q5.js} +6 -5
  16. package/{authCommands-BKDT4ZYB.js → authCommands-PIUTADO5.js} +2 -2
  17. package/{chromeOpsCommands-IWKUA4C3.js → chromeOpsCommands-2KFQEE3H.js} +24 -46
  18. package/{chunk-6MXCQLLB.js → chunk-53HMDUG6.js} +14 -583
  19. package/{chunk-OBKPOFOB.js → chunk-5AIXW7RW.js} +10 -10
  20. package/{chunk-HS7JBDUJ.js → chunk-5LK5OYUB.js} +3 -3
  21. package/{chunk-QUCQVMYZ.js → chunk-7O6YJN4K.js} +6 -6
  22. package/{chunk-4KDYRX3O.js → chunk-CFW7JLTH.js} +2 -2
  23. package/{chunk-PD4KNHVU.js → chunk-CJYL3N3T.js} +2 -2
  24. package/{chunk-NJI5HZQA.js → chunk-DS47C2AI.js} +2 -2
  25. package/{chunk-DVSXZC7F.js → chunk-EP2L3JUM.js} +18 -18
  26. package/{chunk-SGATEZV5.js → chunk-F55WKIWE.js} +18 -18
  27. package/chunk-G5LNJZJH.js +584 -0
  28. package/{chunk-H63VHVFY.js → chunk-HZG23JG6.js} +3 -3
  29. package/{chunk-PT6335JZ.js → chunk-I4ZVPTAI.js} +1 -1
  30. package/chunk-LKZPX6YH.js +0 -0
  31. package/{chunk-TCCBECTT.js → chunk-MAS5KGBB.js} +5 -5
  32. package/{chunk-HTSXDJHA.js → chunk-OC4NVQ5S.js} +12 -12
  33. package/{chunk-GHKEUJ6I.js → chunk-OES4RYIG.js} +2 -2
  34. package/{chunk-TDX2L4W2.js → chunk-PS3GU7YU.js} +1857 -1138
  35. package/{chunk-CGKN34IJ.js → chunk-QZRAVGW3.js} +33 -33
  36. package/{chunk-GCAOOTIS.js → chunk-SCDJOWJT.js} +2 -2
  37. package/{chunk-YAN7XTXO.js → chunk-THZHXIKZ.js} +2 -2
  38. package/{chunk-WQAOAJ5Q.js → chunk-UCE66MIJ.js} +1 -1
  39. package/{chunk-DTA4JVXW.js → chunk-UXJ7R3EP.js} +2 -2
  40. package/{chunk-QOKJFYJK.js → chunk-WQ4M3IYD.js} +9 -9
  41. package/{commandRegistry-UQ4GKJ5B.js → commandRegistry-XRHKJCWS.js} +80 -65
  42. package/{contentThunks-GZUPF67H.js → contentThunks-FBGQIS5J.js} +6 -6
  43. package/{cooldownCommands-NS63RGBO.js → cooldownCommands-QFV3ERZX.js} +14 -28
  44. package/{createAgentAutomationAction-ZOFCBZRE.js → createAgentAutomationAction-ASIS3C6Q.js} +6 -6
  45. package/{createDialogAction-G7QCYQT7.js → createDialogAction-XJGVTBWO.js} +7 -7
  46. package/{createPageAction-Z6JQZYS5.js → createPageAction-2IWTNKUE.js} +8 -8
  47. package/{dialogCommands-MITLWDBY.js → dialogCommands-VKBNO7EI.js} +2 -2
  48. package/{dialogSlice-PKFXK5WM.js → dialogSlice-BE76QRR4.js} +4 -4
  49. package/{docCreateCommands-G3S3LZMZ.js → docCreateCommands-HFDVOS2K.js} +11 -38
  50. package/{docDeleteCommands-MLRCMLVB.js → docDeleteCommands-DMKHPD5R.js} +17 -37
  51. package/{docReadCommands-6A6SBCOP.js → docReadCommands-VAUSL2N7.js} +12 -28
  52. package/{docStore-NAEY4CEK.js → docStore-FOTFZMVS.js} +1 -1
  53. package/{docUpdateCommands-UZQC2NDO.js → docUpdateCommands-6QQUX2IN.js} +19 -73
  54. package/{handleSendMessageAction-HUQLERJP.js → handleSendMessageAction-U6DQUBLF.js} +10 -10
  55. package/index.js +17 -7
  56. package/{localRuntimeAdapter-4DJDFM7A.js → localRuntimeAdapter-DM7ERZ6Z.js} +20 -19
  57. package/{machineCommands-R2IP5OVT.js → machineCommands-OJPPEMNZ.js} +25 -21
  58. package/{machineWsRunDispatch-CIJDSHTA.js → machineWsRunDispatch-I5WWJ2EY.js} +21 -20
  59. package/package.json +1 -1
  60. package/{readlineWorkspace-YCNAWRDL.js → readlineWorkspace-RMG27VY3.js} +31 -29
  61. package/{runAgentClientLoop-K7WRMT27.js → runAgentClientLoop-QJL24CN5.js} +15 -15
  62. package/{secretCommands-7S6REMJV.js → secretCommands-XEQLKDB4.js} +33 -47
  63. package/{spaceCommands-L537SH5I.js → spaceCommands-Z325DDJU.js} +2 -2
  64. package/{streamAgentChatTurn-HKUZ7OCA.js → streamAgentChatTurn-4ZA46AEJ.js} +19 -19
  65. package/{tools-NS37KPGT.js → tools-GWQ4POVC.js} +12 -12
  66. package/{updateCommands-BXGFH4VX.js → updateCommands-KDYX32JR.js} +3 -1
  67. package/{updateDialogTitleAction-UUZ5HDM2.js → updateDialogTitleAction-VTE36JGF.js} +6 -6
  68. package/windowsSelfUpdate-IYQK4IDS.js +14 -0
  69. package/{agentPullCommand-UXXV5KKW.js → agentPullCommand-7LHBOEYH.js} +1 -1
  70. package/{chunk-COXNBVP7.js → chunk-FLX5EYLQ.js} +4 -4
  71. package/{chunk-RV4DPEAM.js → chunk-XLQ646HU.js} +3 -3
  72. package/{workloadLifecycle-MZ2V5L43.js → workloadLifecycle-2F5YKFGW.js} +7 -7
@@ -1,24 +1,6 @@
1
1
  import {
2
- isCompiledBinary
3
- } from "./chunk-WACI5I6V.js";
4
- import {
5
- DEFAULT_NOLO_SERVER_URL
6
- } from "./chunk-OLZBQWZU.js";
7
- import {
8
- loadProfileConfig
9
- } from "./chunk-R5GO3YZP.js";
10
- import {
11
- resolveDefaultSpawn
12
- } from "./chunk-Y6ROFCZO.js";
13
- import {
14
- normalizeServerOrigin
15
- } from "./chunk-CF7PE763.js";
16
-
17
- // packages/cli/updateCommands.ts
18
- import { existsSync as existsSync2, readFileSync as readFileSync2, accessSync, constants } from "node:fs";
19
- import { homedir as homedir2 } from "node:os";
20
- import { dirname as dirname2, join as join2 } from "node:path";
21
- import { fileURLToPath } from "node:url";
2
+ t
3
+ } from "./chunk-PS3GU7YU.js";
22
4
 
23
5
  // packages/cli/windowsSelfUpdate.ts
24
6
  import { spawn } from "node:child_process";
@@ -400,10 +382,11 @@ const switchWindowsShims = (shimDir, entrypoint) => {
400
382
  } catch {}
401
383
  try { rmSync(__filename, { force: true }); } catch {}
402
384
  // 通知放在锁释放之后:同步通知最多阻塞十几秒,不能拖住下一次更新。
385
+ if (!payload.notifications) return;
403
386
  if (updateSucceeded) {
404
- notify("Nolo", alreadyCurrent ? "Nolo is already up to date" : "Update finished - the next Nolo launch uses the new version");
387
+ notify(payload.notifications.title, alreadyCurrent ? payload.notifications.current : payload.notifications.finished);
405
388
  } else {
406
- notify("Nolo", "Update failed - see log: " + payload.logPath);
389
+ notify(payload.notifications.title, payload.notifications.failed);
407
390
  }
408
391
  }
409
392
  })();
@@ -457,6 +440,12 @@ function scheduleWindowsSelfUpdate(options) {
457
440
  }
458
441
  const payload = Buffer.from(
459
442
  JSON.stringify({
443
+ notifications: {
444
+ title: t("updateNotifyTitle"),
445
+ current: t("updateNotifyCurrent"),
446
+ finished: t("updateNotifyFinished"),
447
+ failed: t("updateNotifyFailed", logPath)
448
+ },
460
449
  currentVersion: options.currentVersion,
461
450
  channel: options.channel,
462
451
  entrypointPath: normalize(options.entrypointPath),
@@ -487,567 +476,9 @@ function scheduleWindowsSelfUpdate(options) {
487
476
  return { helperPid, logPath };
488
477
  }
489
478
 
490
- // packages/cli/updateCommands.ts
491
- function resolvePackageJsonPath() {
492
- if (isCompiledBinary()) {
493
- const execDir = dirname2(process.execPath);
494
- const candidate2 = join2(execDir, "package.json");
495
- if (existsSync2(candidate2)) return candidate2;
496
- return null;
497
- }
498
- const CLI_DIR = dirname2(fileURLToPath(import.meta.url));
499
- const candidate = join2(CLI_DIR, "package.json");
500
- return existsSync2(candidate) ? candidate : null;
501
- }
502
- var PACKAGE_JSON_PATH = resolvePackageJsonPath();
503
- function getCliInstallChannel(serverUrl) {
504
- const normalized = normalizeServerOrigin(serverUrl);
505
- if (!normalized) {
506
- return "latest";
507
- }
508
- try {
509
- const hostname = new URL(normalized).hostname.toLowerCase();
510
- if (hostname === "us.nolo.chat" || hostname.endsWith(".us.nolo.chat")) {
511
- return "alpha";
512
- }
513
- } catch {
514
- if (/us\.nolo\.chat/i.test(normalized)) {
515
- return "alpha";
516
- }
517
- }
518
- return "latest";
519
- }
520
- function renderProgressBar(percent, width = 30) {
521
- const pct = Math.max(0, Math.min(100, percent));
522
- const filledLen = Math.round(width * pct / 100);
523
- const emptyLen = width - filledLen;
524
- const bar = "#".repeat(filledLen) + " ".repeat(emptyLen);
525
- const pctText = pct.toFixed(1).padStart(5, " ");
526
- return `[${bar}] ${pctText}%`;
527
- }
528
- function buildNpmSelfUpdateCommand(channel = "latest") {
529
- return ["npm", "install", "-g", `nolo-cli@${channel}`, "--force", "--progress"];
530
- }
531
- function resolveStandaloneBundlePlatform(platform = process.platform, arch = process.arch) {
532
- if (platform === "linux" && arch === "x64") {
533
- return { tarballName: "nolo-linux-x64.tar.gz", extractSubdir: "nolo-linux-x64" };
534
- }
535
- if (platform === "darwin" && arch === "arm64") {
536
- return { tarballName: "nolo-darwin-arm64.tar.gz", extractSubdir: "nolo-darwin-arm64" };
537
- }
538
- return null;
539
- }
540
- function resolveStandaloneBundleRepoBase(channel) {
541
- return channel === "alpha" ? "https://us.nolo.chat" : "https://nolo.chat";
542
- }
543
- function buildStandaloneManualUpdateHint(channel) {
544
- const repoBase = resolveStandaloneBundleRepoBase(channel);
545
- return `curl -fsSL ${repoBase}/install-nolo.sh | sh`;
546
- }
547
- function resolveStandaloneInstallDir() {
548
- const candidates = [
549
- "/usr/local/bin",
550
- join2(homedir2(), ".local/bin"),
551
- join2(homedir2(), ".nolo/bin")
552
- ];
553
- for (const dir of candidates) {
554
- if (!existsSync2(dir)) continue;
555
- try {
556
- accessSync(dir, constants.W_OK);
557
- return dir;
558
- } catch {
559
- continue;
560
- }
561
- }
562
- return join2(homedir2(), ".nolo/bin");
563
- }
564
- function readPackageInfo() {
565
- if (PACKAGE_JSON_PATH) {
566
- try {
567
- const raw = readFileSync2(PACKAGE_JSON_PATH, "utf8");
568
- const parsed = JSON.parse(raw);
569
- return {
570
- name: parsed.name || "nolo-cli",
571
- version: parsed.version || "0.0.0"
572
- };
573
- } catch {
574
- }
575
- }
576
- return {
577
- name: process.env.NOLO_CLI_PACKAGE_NAME || "nolo-cli",
578
- version: process.env.NOLO_CLI_VERSION || "0.0.0"
579
- };
580
- }
581
- function buildCliVersionText(info) {
582
- return `${info.name} ${info.version}`;
583
- }
584
- function buildSelfUpdateCommand(serverUrl) {
585
- return buildNpmSelfUpdateCommand(getCliInstallChannel(serverUrl));
586
- }
587
- function resolveSelfUpdateServerUrl(env = process.env, override) {
588
- if (override?.trim()) {
589
- return normalizeServerOrigin(override);
590
- }
591
- const fromEnv = env.NOLO_SERVER || env.BASE_URL;
592
- if (typeof fromEnv === "string" && fromEnv.trim()) {
593
- return normalizeServerOrigin(fromEnv);
594
- }
595
- const profile = loadProfileConfig();
596
- const profileUrl = profile?.profiles?.[profile.currentProfile]?.serverUrl;
597
- if (profileUrl?.trim()) {
598
- return normalizeServerOrigin(profileUrl);
599
- }
600
- return DEFAULT_NOLO_SERVER_URL;
601
- }
602
- function buildCliDoctorText(info) {
603
- return [
604
- "Nolo CLI doctor",
605
- "---------------",
606
- `version ${info.packageName} ${info.version}`,
607
- `install ${info.installKind}`,
608
- `channel ${info.updateChannel}`,
609
- `entry ${info.entrypoint}`,
610
- `server ${info.serverUrl}`,
611
- `profile ${info.profileName}`,
612
- `update nolo update`,
613
- "",
614
- "If direct `nolo` differs from repo-local `bun ./packages/cli/index.ts`,",
615
- "the global install is older than this checkout.",
616
- "",
617
- `Manual update: ${info.installKind === "standalone-bundle" ? buildStandaloneManualUpdateHint(info.updateChannel) : buildNpmSelfUpdateCommand(info.updateChannel).join(" ")}`
618
- ].join("\n");
619
- }
620
- function isRunSelfUpdateOptions(value) {
621
- return typeof value === "object" && value !== null && ("output" in value || "spawn" in value || "entrypointPath" in value || "serverUrl" in value || "env" in value || "platform" in value || "scheduleWindowsUpdate" in value);
622
- }
623
- async function forwardSpawnOutput(stream, output) {
624
- if (!stream) {
625
- return;
626
- }
627
- for await (const chunk of stream) {
628
- output.write(normalizeSpawnChunk(chunk));
629
- }
630
- }
631
- function normalizeSpawnChunk(chunk) {
632
- if (typeof chunk === "string" || chunk instanceof Uint8Array) {
633
- return chunk;
634
- }
635
- if (chunk instanceof ArrayBuffer) {
636
- return new Uint8Array(chunk);
637
- }
638
- return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
639
- }
640
- async function runShellScript(script, {
641
- output,
642
- spawn: spawn2,
643
- env,
644
- cwd,
645
- useCustomSink
646
- }) {
647
- const proc = spawn2({
648
- cmd: ["sh", "-c", script],
649
- cwd,
650
- // Capture mode (TUI sink): ignore stdin — the TUI's own decoder is
651
- // reading the tty, and a child that reads stdin would race it for keys.
652
- // The inherit branch is unreachable inside the TUI (useCustomSink is
653
- // always true there) and stays the correct choice for `nolo update`.
654
- stdin: useCustomSink ? "ignore" : "inherit",
655
- stdout: useCustomSink ? "pipe" : "inherit",
656
- stderr: useCustomSink ? "pipe" : "inherit",
657
- env
658
- });
659
- if (!useCustomSink) {
660
- return proc.exited;
661
- }
662
- const [exitCode] = await Promise.all([
663
- proc.exited,
664
- forwardSpawnOutput(proc.stdout, output),
665
- forwardSpawnOutput(proc.stderr, output)
666
- ]);
667
- return exitCode;
668
- }
669
- function shellQuote(value) {
670
- return "'" + value.replace(/'/g, "'\\''") + "'";
671
- }
672
- function buildStandaloneUpdateScript(args) {
673
- const curl = "curl -fL --progress-bar --connect-timeout 20 --max-time 600 --speed-limit 1 --speed-time 60";
674
- return `set -eu
675
- EXTRACT_DIR=${shellQuote(args.extractDir)}
676
- ENTRY=${shellQuote(args.symlinkPath)}
677
- CURRENT_VERSION=${shellQuote(args.currentVersion)}
678
- STAGING="$EXTRACT_DIR.new.$$"
679
- BACKUP="$EXTRACT_DIR.old.$$"
680
- LINK="$ENTRY.new.$$"
681
- old_moved=0
682
- new_moved=0
683
- committed=0
684
- cleanup() {
685
- status=$?
686
- trap - 0 HUP INT TERM
687
- if [ "$committed" = 0 ]; then
688
- if [ "$new_moved" = 1 ] && [ -d "$EXTRACT_DIR" ]; then
689
- mv "$EXTRACT_DIR" "$STAGING" || exit 1
690
- fi
691
- if [ "$old_moved" = 1 ] && [ -d "$BACKUP" ]; then
692
- mv "$BACKUP" "$EXTRACT_DIR" || exit 1
693
- fi
694
- fi
695
- rm -rf "$STAGING" || true
696
- rm -f "$LINK" || true
697
- exit "$status"
698
- }
699
- # Refuse collisions before installing cleanup: never remove somebody else's path.
700
- if [ -e "$STAGING" ] || [ -L "$STAGING" ] ||
701
- [ -e "$BACKUP" ] || [ -L "$BACKUP" ] ||
702
- [ -e "$LINK" ] || [ -L "$LINK" ]; then
703
- echo "Error: update staging path already exists" >&2
704
- exit 1
705
- fi
706
- mkdir -p "\${EXTRACT_DIR%/*}"
707
- mkdir "$STAGING"
708
- trap cleanup 0
709
- trap 'exit 1' HUP INT TERM
710
-
711
- echo ${shellQuote(`Downloading nolo from ${args.tarballUrl}...`)}
712
- if ! ${curl} ${shellQuote(args.tarballUrl)} -o "$STAGING/bundle.tar.gz"; then
713
- ${args.tarballUrl !== args.fallbackUrl ? `echo ${shellQuote(`Primary source unavailable, trying ${args.fallbackUrl}...`)}
714
- if ! ${curl} ${shellQuote(args.fallbackUrl)} -o "$STAGING/bundle.tar.gz"; then
715
- echo "Error: download failed" >&2
716
- exit 1
717
- fi` : `echo "Error: download failed" >&2
718
- exit 1`}
719
- fi
720
- tar -xzf "$STAGING/bundle.tar.gz" -C "$STAGING"
721
- rm -f "$STAGING/bundle.tar.gz"
722
- chmod +x "$STAGING/nolo"
723
- # A failing, empty or malformed version response must not touch the live install.
724
- VERSION_TEXT=$("$STAGING/nolo" -v)
725
- case "$VERSION_TEXT" in
726
- "nolo-cli "*) VERSION=\${VERSION_TEXT#nolo-cli } ;;
727
- *) VERSION=$VERSION_TEXT ;;
728
- esac
729
- CORE=\${VERSION%%[-+]*}
730
- MAJOR=\${CORE%%.*}
731
- REST=\${CORE#*.}
732
- MINOR=\${REST%%.*}
733
- PATCH=\${REST#*.}
734
- case "$MAJOR:$MINOR:$PATCH" in
735
- *[!0-9:]*|:*|*::*|*:) echo "Error: invalid bundle version" >&2; exit 1 ;;
736
- esac
737
- if [ "$CORE" != "$MAJOR.$MINOR.$PATCH" ]; then
738
- echo "Error: invalid bundle version" >&2
739
- exit 1
740
- fi
741
- case "$VERSION" in
742
- *[!0-9A-Za-z.+-]*) echo "Error: invalid bundle version" >&2; exit 1 ;;
743
- esac
744
- case "$CURRENT_VERSION" in
745
- "nolo-cli "*) CUR_VER=\${CURRENT_VERSION#nolo-cli } ;;
746
- *) CUR_VER=$CURRENT_VERSION ;;
747
- esac
748
- CUR_CORE=\${CUR_VER%%[-+]*}
749
- CUR_MAJOR=\${CUR_CORE%%.*}
750
- CUR_REST=\${CUR_CORE#*.}
751
- CUR_MINOR=\${CUR_REST%%.*}
752
- CUR_PATCH=\${CUR_REST#*.}
753
- if [ -n "$CUR_MAJOR" ] && [ -n "$CUR_MINOR" ] && [ -n "$CUR_PATCH" ]; then
754
- case "$CUR_MAJOR:$CUR_MINOR:$CUR_PATCH" in
755
- *[!0-9:]*|:*|*::*|*:) ;;
756
- *)
757
- if [ "$CUR_CORE" = "$CUR_MAJOR.$CUR_MINOR.$CUR_PATCH" ]; then
758
- is_downgrade=0
759
- if [ "$MAJOR" -lt "$CUR_MAJOR" ]; then
760
- is_downgrade=1
761
- elif [ "$MAJOR" -eq "$CUR_MAJOR" ]; then
762
- if [ "$MINOR" -lt "$CUR_MINOR" ]; then
763
- is_downgrade=1
764
- elif [ "$MINOR" -eq "$CUR_MINOR" ]; then
765
- if [ "$PATCH" -lt "$CUR_PATCH" ]; then
766
- is_downgrade=1
767
- fi
768
- fi
769
- fi
770
- if [ "$is_downgrade" = 1 ]; then
771
- echo "Error: refusing downgrade from $CURRENT_VERSION to $VERSION" >&2
772
- exit 11
773
- fi
774
- fi
775
- ;;
776
- esac
777
- fi
778
- if [ "$VERSION" = "$CURRENT_VERSION" ]; then
779
- echo "\u2713 Already up to date (nolo-cli $VERSION)."
780
- exit 10
781
- fi
782
- mkdir -p "\${ENTRY%/*}"
783
- # mv without -T is portable only when the destination is not a directory.
784
- if [ -d "$ENTRY" ] || [ -L "$EXTRACT_DIR" ]; then
785
- echo "Error: refusing directory entrypoint or symlink bundle directory" >&2
786
- exit 1
787
- fi
788
- ln -s "$EXTRACT_DIR/nolo" "$LINK"
789
- if [ -e "$EXTRACT_DIR" ]; then
790
- old_moved=1
791
- mv "$EXTRACT_DIR" "$BACKUP"
792
- fi
793
- new_moved=1
794
- mv "$STAGING" "$EXTRACT_DIR"
795
- mv -f "$LINK" "$ENTRY"
796
- committed=1
797
- # Retain only the newest recovery copy from this run; prune older backups.
798
- for old_copy in "$EXTRACT_DIR.old."*; do
799
- if [ -d "$old_copy" ] && [ ! -L "$old_copy" ] && [ "$old_copy" != "$BACKUP" ]; then
800
- rm -rf "$old_copy" || true
801
- fi
802
- done
803
- # Retain the previous bundle as a recovery copy; never unlink the live entry.
804
- echo "nolo updated to $ENTRY"
805
- `;
806
- }
807
- async function runStandaloneBundleUpdate(options) {
808
- const output = options.output ?? process.stdout;
809
- const spawn2 = options.spawn ?? resolveDefaultSpawn();
810
- const env = options.env ?? process.env;
811
- const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
812
- const channel = getCliInstallChannel(serverUrl);
813
- const platform = resolveStandaloneBundlePlatform();
814
- if (!platform) {
815
- output.write(
816
- `\u2717 Standalone-bundle self-update is not supported on this platform
817
- (platform=${process.platform}, arch=${process.arch}).
818
- Only linux-x64 and darwin-arm64 bundles are published.
819
- Falling back is not possible from a compiled binary; reinstall via:
820
- ${buildStandaloneManualUpdateHint(channel)}
821
- `
822
- );
823
- return 1;
824
- }
825
- const { tarballName, extractSubdir } = platform;
826
- const repoBase = resolveStandaloneBundleRepoBase(channel);
827
- const tarballUrl = `${repoBase}/public/downloads/${tarballName}`;
828
- const fallbackUrl = `https://nolo.chat/public/downloads/${tarballName}`;
829
- const extractDir = join2(homedir2(), ".nolo", extractSubdir);
830
- const installDir = resolveStandaloneInstallDir();
831
- const symlinkPath = join2(installDir, "nolo");
832
- const script = buildStandaloneUpdateScript({
833
- tarballUrl,
834
- fallbackUrl,
835
- extractDir,
836
- symlinkPath,
837
- currentVersion: readPackageInfo().version
838
- });
839
- output.write(`
840
- Nolo Agent CLI Installer & Updater
841
- `);
842
- output.write(`-----------------------------------------
843
- `);
844
- output.write(`\u2713 Target channel: ${channel} (standalone bundle)
845
- `);
846
- output.write(`\u25B8 Downloading and installing bundle...
847
- `);
848
- const useCustomSink = options.output !== void 0;
849
- const exitCode = await runShellScript(script, {
850
- output,
851
- spawn: spawn2,
852
- env,
853
- useCustomSink
854
- });
855
- if (exitCode === 10) {
856
- output.write(` ${renderProgressBar(100)}
857
- `);
858
- return 0;
859
- }
860
- if (exitCode === 0) {
861
- output.write(` ${renderProgressBar(100)}
862
- `);
863
- output.write(`\u2713 Update completed successfully!
864
-
865
- `);
866
- }
867
- return exitCode;
868
- }
869
- var NOLO_UPDATE_CHECK_KILL_SWITCH = "NOLO_CLI_NO_UPDATE_CHECK";
870
- function parseCliVersion(raw) {
871
- const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(raw.trim());
872
- if (!match) return null;
873
- return {
874
- main: [Number(match[1]), Number(match[2]), Number(match[3])],
875
- pre: match[4] ? match[4].split(".") : []
876
- };
877
- }
878
- function compareCliVersions(a, b) {
879
- const pa = parseCliVersion(a);
880
- const pb = parseCliVersion(b);
881
- if (!pa || !pb) return a.localeCompare(b);
882
- for (let i = 0; i < 3; i++) {
883
- if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
884
- }
885
- if (pa.pre.length === 0 && pb.pre.length === 0) return 0;
886
- if (pa.pre.length === 0) return 1;
887
- if (pb.pre.length === 0) return -1;
888
- const len = Math.max(pa.pre.length, pb.pre.length);
889
- for (let i = 0; i < len; i++) {
890
- const x = pa.pre[i];
891
- const y = pb.pre[i];
892
- if (x === void 0) return -1;
893
- if (y === void 0) return 1;
894
- if (x === y) continue;
895
- const xn = /^\d+$/.test(x) ? Number(x) : NaN;
896
- const yn = /^\d+$/.test(y) ? Number(y) : NaN;
897
- if (!Number.isNaN(xn) && !Number.isNaN(yn)) return xn < yn ? -1 : 1;
898
- if (!Number.isNaN(xn)) return -1;
899
- if (!Number.isNaN(yn)) return 1;
900
- return x < y ? -1 : 1;
901
- }
902
- return 0;
903
- }
904
- async function checkForCliUpdate(currentVersion, serverUrl, options = {}) {
905
- const env = options.env ?? process.env;
906
- if ((env[NOLO_UPDATE_CHECK_KILL_SWITCH] ?? process.env[NOLO_UPDATE_CHECK_KILL_SWITCH]) === "1") {
907
- return null;
908
- }
909
- if (!currentVersion || !parseCliVersion(currentVersion)) return null;
910
- const channel = getCliInstallChannel(serverUrl);
911
- const fetchImpl = options.fetchImpl ?? fetch;
912
- const timeoutMs = options.timeoutMs ?? 2e3;
913
- try {
914
- const res = await fetchImpl(
915
- `https://registry.npmjs.org/nolo-cli/${channel}`,
916
- {
917
- signal: AbortSignal.timeout(timeoutMs),
918
- headers: { accept: "application/json" }
919
- }
920
- );
921
- if (!res.ok) return null;
922
- const data = await res.json();
923
- const latestVersion = data.version;
924
- if (!latestVersion || !parseCliVersion(latestVersion) || compareCliVersions(latestVersion, currentVersion) <= 0) {
925
- return null;
926
- }
927
- return { latestVersion, channel };
928
- } catch {
929
- return null;
930
- }
931
- }
932
- async function runSelfUpdateDetailed(outputOrOptions) {
933
- const options = outputOrOptions === void 0 ? {} : isRunSelfUpdateOptions(outputOrOptions) ? outputOrOptions : { output: outputOrOptions };
934
- if (isCompiledBinary()) {
935
- return {
936
- exitCode: await runStandaloneBundleUpdate(options),
937
- disposition: "completed"
938
- };
939
- }
940
- const output = options.output ?? process.stdout;
941
- const spawn2 = options.spawn ?? resolveDefaultSpawn();
942
- const env = options.env ?? process.env;
943
- const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
944
- const channel = getCliInstallChannel(serverUrl);
945
- const command = buildNpmSelfUpdateCommand(channel);
946
- if ((options.platform ?? process.platform) === "win32") {
947
- const packageInfo = readPackageInfo();
948
- const entrypointPath = options.entrypointPath ?? fileURLToPath(import.meta.url);
949
- const schedule = options.scheduleWindowsUpdate ?? scheduleWindowsSelfUpdate;
950
- try {
951
- const scheduled = schedule({
952
- channel,
953
- currentVersion: packageInfo.version,
954
- entrypointPath,
955
- env
956
- });
957
- output.write(`
958
- Nolo Agent CLI Installer & Updater
959
- `);
960
- output.write(`-----------------------------------------
961
- `);
962
- output.write(`\u2713 Target channel: ${channel} (nolo-cli@${channel})
963
- `);
964
- output.write(`\u2713 Update scheduled in background (helper pid ${scheduled.helperPid}).
965
- `);
966
- output.write(`\u25B8 You can keep using Nolo \u2014 no need to close this or any other window.
967
- `);
968
- output.write(`\u25B8 Installation continues in the background; once it finishes, the next Nolo launch uses the new version.
969
- `);
970
- output.write(` Check version: nolo -v Log: ${scheduled.logPath}
971
-
972
- `);
973
- return { exitCode: 0, disposition: "scheduled" };
974
- } catch (error) {
975
- output.write(
976
- `\u2717 Could not schedule the Windows update: ${error instanceof Error ? error.message : String(error)}
977
- `
978
- );
979
- output.write(
980
- ` Manual update after closing every Nolo window: ${command.join(" ")}
981
- `
982
- );
983
- return { exitCode: 1, disposition: "completed" };
984
- }
985
- }
986
- output.write(`
987
- Nolo Agent CLI Installer & Updater
988
- `);
989
- output.write(`-----------------------------------------
990
- `);
991
- output.write(`\u2713 Target channel: ${channel} (nolo-cli@${channel})
992
- `);
993
- output.write(`\u25B8 Downloading and installing package via npm...
994
- `);
995
- const useCustomSink = options.output !== void 0;
996
- const proc = spawn2({
997
- cmd: command,
998
- // Capture mode (TUI sink): ignore stdin — see runShellScript.
999
- stdin: useCustomSink ? "ignore" : "inherit",
1000
- stdout: useCustomSink ? "pipe" : "inherit",
1001
- stderr: useCustomSink ? "pipe" : "inherit",
1002
- env
1003
- });
1004
- if (!useCustomSink) {
1005
- const exitCode2 = await proc.exited;
1006
- if (exitCode2 === 0) {
1007
- output.write(` ${renderProgressBar(100)}
1008
- `);
1009
- output.write(`\u2713 Update completed successfully!
1010
-
1011
- `);
1012
- }
1013
- return { exitCode: exitCode2, disposition: "completed" };
1014
- }
1015
- const [exitCode] = await Promise.all([
1016
- proc.exited,
1017
- forwardSpawnOutput(proc.stdout, output),
1018
- forwardSpawnOutput(proc.stderr, output)
1019
- ]);
1020
- if (exitCode === 0) {
1021
- output.write(` ${renderProgressBar(100)}
1022
- `);
1023
- output.write(`\u2713 Update completed successfully!
1024
-
1025
- `);
1026
- }
1027
- return { exitCode, disposition: "completed" };
1028
- }
1029
- async function runSelfUpdate(outputOrOptions) {
1030
- return (await runSelfUpdateDetailed(outputOrOptions)).exitCode;
1031
- }
1032
-
1033
479
  export {
1034
480
  getWindowsUpdateStatus,
1035
- getCliInstallChannel,
1036
- renderProgressBar,
1037
- buildNpmSelfUpdateCommand,
1038
- resolveStandaloneBundlePlatform,
1039
- resolveStandaloneBundleRepoBase,
1040
- buildStandaloneManualUpdateHint,
1041
- readPackageInfo,
1042
- buildCliVersionText,
1043
- buildSelfUpdateCommand,
1044
- resolveSelfUpdateServerUrl,
1045
- buildCliDoctorText,
1046
- buildStandaloneUpdateScript,
1047
- runStandaloneBundleUpdate,
1048
- NOLO_UPDATE_CHECK_KILL_SWITCH,
1049
- compareCliVersions,
1050
- checkForCliUpdate,
1051
- runSelfUpdateDetailed,
1052
- runSelfUpdate
481
+ defaultLaunchWindowsUpdateHelper,
482
+ buildWindowsUpdateHelperSource,
483
+ scheduleWindowsSelfUpdate
1053
484
  };
@@ -5,7 +5,7 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-GCAOOTIS.js";
8
+ } from "./chunk-SCDJOWJT.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-YAN7XTXO.js";
17
+ } from "./chunk-THZHXIKZ.js";
18
18
  import {
19
19
  findToolExecutor,
20
20
  toolDefinitionsByName
21
- } from "./chunk-CGKN34IJ.js";
21
+ } from "./chunk-QZRAVGW3.js";
22
22
  import {
23
23
  classifyApiError,
24
24
  classifyGenerationError,
25
25
  extractErrorDiagnostics
26
- } from "./chunk-DTA4JVXW.js";
26
+ } from "./chunk-UXJ7R3EP.js";
27
27
  import {
28
28
  createSSEParser,
29
29
  createToolRunId,
@@ -32,23 +32,23 @@ import {
32
32
  toolRunSetPending,
33
33
  toolRunStarted,
34
34
  toolRunSucceeded
35
- } from "./chunk-NJI5HZQA.js";
35
+ } from "./chunk-DS47C2AI.js";
36
36
  import {
37
37
  getPublicImageAgentMode
38
38
  } from "./chunk-VIDPVFP3.js";
39
+ import {
40
+ getCurrentSpaceId
41
+ } from "./chunk-ZJ7UHBJS.js";
39
42
  import {
40
43
  addToolMessage,
41
44
  messageStreamEnd,
42
45
  messageStreaming,
43
46
  toolResultNeedsUserConfirmation,
44
47
  updateToolMessage
45
- } from "./chunk-HTSXDJHA.js";
48
+ } from "./chunk-OC4NVQ5S.js";
46
49
  import {
47
50
  streamAgentChatTurn
48
- } from "./chunk-HS7JBDUJ.js";
49
- import {
50
- getCurrentSpaceId
51
- } from "./chunk-ZJ7UHBJS.js";
51
+ } from "./chunk-5LK5OYUB.js";
52
52
  import {
53
53
  addActiveController,
54
54
  removeActiveController,
@@ -347,7 +347,7 @@ var slice = createSliceWithThunks({
347
347
  const overrides = {};
348
348
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
349
349
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
350
- const { _executeModel } = await import("./_executeModel-ACI2KGWO.js");
350
+ const { _executeModel } = await import("./_executeModel-EJUKYBFV.js");
351
351
  return _executeModel(
352
352
  {
353
353
  isStreaming: args.isStreaming ?? false,
@@ -368,7 +368,7 @@ var slice = createSliceWithThunks({
368
368
  * - 循环直到无工具调用或触发其他运行时停止条件
369
369
  */
370
370
  runAgent: create.asyncThunk(async (args, thunkApi) => {
371
- const { runAgentClientLoop } = await import("./runAgentClientLoop-K7WRMT27.js");
371
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-QJL24CN5.js");
372
372
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
373
373
  {
374
374
  agentKey: args.agentKey,
@@ -384,7 +384,7 @@ var slice = createSliceWithThunks({
384
384
  * 聊天轮次流式 Agent 调用
385
385
  */
386
386
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
387
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-HKUZ7OCA.js");
387
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-4ZA46AEJ.js");
388
388
  return streamAgentChatTurnHandler(args, thunkApi);
389
389
  }),
390
390
  /**