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.
- package/{_executeModel-ACI2KGWO.js → _executeModel-EJUKYBFV.js} +17 -17
- package/{agentDeleteCommand-LVSLONDD.js → agentDeleteCommand-OWDZDREL.js} +22 -21
- package/{agentEmailCommands-BKH3Q6I6.js → agentEmailCommands-RJGVOJXD.js} +22 -21
- package/{agentListCommands-JPKRBHMP.js → agentListCommands-GRJAY5ZE.js} +6 -5
- package/{agentMachineCommands-HRORJN73.js → agentMachineCommands-FNYZSZQ4.js} +3 -3
- package/{agentRecordCommands-OSZF2EHL.js → agentRecordCommands-EBDTISRS.js} +21 -20
- package/{agentRunCommand-FCGNSB4D.js → agentRunCommand-GIBVOCOK.js} +22 -21
- package/{agentRuntimeLocal-SWG5ULIJ.js → agentRuntimeLocal-AG7RCTM3.js} +2 -2
- package/{agentSlice-FCDRLXVA.js → agentSlice-LD6SEBSP.js} +1 -1
- package/{appDeleteCommands-YH3BYQYK.js → appDeleteCommands-DXF3IOFE.js} +7 -6
- package/{appDeployCommands-F44TNQJG.js → appDeployCommands-JVKZ3ATD.js} +7 -6
- package/{appDeployStatusCommands-BFTGFVQY.js → appDeployStatusCommands-VLGEMFV6.js} +7 -6
- package/{appGetCommands-SFLFIXPW.js → appGetCommands-JQN7RPBD.js} +7 -6
- package/{appListCommands-RUO5SEAJ.js → appListCommands-MFPVNCVT.js} +7 -6
- package/{authCommand-UIF5UTYV.js → authCommand-AX23Q2Q5.js} +6 -5
- package/{authCommands-BKDT4ZYB.js → authCommands-PIUTADO5.js} +2 -2
- package/{chromeOpsCommands-IWKUA4C3.js → chromeOpsCommands-2KFQEE3H.js} +24 -46
- package/{chunk-6MXCQLLB.js → chunk-53HMDUG6.js} +14 -583
- package/{chunk-OBKPOFOB.js → chunk-5AIXW7RW.js} +10 -10
- package/{chunk-HS7JBDUJ.js → chunk-5LK5OYUB.js} +3 -3
- package/{chunk-QUCQVMYZ.js → chunk-7O6YJN4K.js} +6 -6
- package/{chunk-4KDYRX3O.js → chunk-CFW7JLTH.js} +2 -2
- package/{chunk-PD4KNHVU.js → chunk-CJYL3N3T.js} +2 -2
- package/{chunk-NJI5HZQA.js → chunk-DS47C2AI.js} +2 -2
- package/{chunk-DVSXZC7F.js → chunk-EP2L3JUM.js} +18 -18
- package/{chunk-SGATEZV5.js → chunk-F55WKIWE.js} +18 -18
- package/chunk-G5LNJZJH.js +584 -0
- package/{chunk-H63VHVFY.js → chunk-HZG23JG6.js} +3 -3
- package/{chunk-PT6335JZ.js → chunk-I4ZVPTAI.js} +1 -1
- package/chunk-LKZPX6YH.js +0 -0
- package/{chunk-TCCBECTT.js → chunk-MAS5KGBB.js} +5 -5
- package/{chunk-HTSXDJHA.js → chunk-OC4NVQ5S.js} +12 -12
- package/{chunk-GHKEUJ6I.js → chunk-OES4RYIG.js} +2 -2
- package/{chunk-TDX2L4W2.js → chunk-PS3GU7YU.js} +1857 -1138
- package/{chunk-CGKN34IJ.js → chunk-QZRAVGW3.js} +33 -33
- package/{chunk-GCAOOTIS.js → chunk-SCDJOWJT.js} +2 -2
- package/{chunk-YAN7XTXO.js → chunk-THZHXIKZ.js} +2 -2
- package/{chunk-WQAOAJ5Q.js → chunk-UCE66MIJ.js} +1 -1
- package/{chunk-DTA4JVXW.js → chunk-UXJ7R3EP.js} +2 -2
- package/{chunk-QOKJFYJK.js → chunk-WQ4M3IYD.js} +9 -9
- package/{commandRegistry-UQ4GKJ5B.js → commandRegistry-XRHKJCWS.js} +80 -65
- package/{contentThunks-GZUPF67H.js → contentThunks-FBGQIS5J.js} +6 -6
- package/{cooldownCommands-NS63RGBO.js → cooldownCommands-QFV3ERZX.js} +14 -28
- package/{createAgentAutomationAction-ZOFCBZRE.js → createAgentAutomationAction-ASIS3C6Q.js} +6 -6
- package/{createDialogAction-G7QCYQT7.js → createDialogAction-XJGVTBWO.js} +7 -7
- package/{createPageAction-Z6JQZYS5.js → createPageAction-2IWTNKUE.js} +8 -8
- package/{dialogCommands-MITLWDBY.js → dialogCommands-VKBNO7EI.js} +2 -2
- package/{dialogSlice-PKFXK5WM.js → dialogSlice-BE76QRR4.js} +4 -4
- package/{docCreateCommands-G3S3LZMZ.js → docCreateCommands-HFDVOS2K.js} +11 -38
- package/{docDeleteCommands-MLRCMLVB.js → docDeleteCommands-DMKHPD5R.js} +17 -37
- package/{docReadCommands-6A6SBCOP.js → docReadCommands-VAUSL2N7.js} +12 -28
- package/{docStore-NAEY4CEK.js → docStore-FOTFZMVS.js} +1 -1
- package/{docUpdateCommands-UZQC2NDO.js → docUpdateCommands-6QQUX2IN.js} +19 -73
- package/{handleSendMessageAction-HUQLERJP.js → handleSendMessageAction-U6DQUBLF.js} +10 -10
- package/index.js +17 -7
- package/{localRuntimeAdapter-4DJDFM7A.js → localRuntimeAdapter-DM7ERZ6Z.js} +20 -19
- package/{machineCommands-R2IP5OVT.js → machineCommands-OJPPEMNZ.js} +25 -21
- package/{machineWsRunDispatch-CIJDSHTA.js → machineWsRunDispatch-I5WWJ2EY.js} +21 -20
- package/package.json +1 -1
- package/{readlineWorkspace-YCNAWRDL.js → readlineWorkspace-RMG27VY3.js} +31 -29
- package/{runAgentClientLoop-K7WRMT27.js → runAgentClientLoop-QJL24CN5.js} +15 -15
- package/{secretCommands-7S6REMJV.js → secretCommands-XEQLKDB4.js} +33 -47
- package/{spaceCommands-L537SH5I.js → spaceCommands-Z325DDJU.js} +2 -2
- package/{streamAgentChatTurn-HKUZ7OCA.js → streamAgentChatTurn-4ZA46AEJ.js} +19 -19
- package/{tools-NS37KPGT.js → tools-GWQ4POVC.js} +12 -12
- package/{updateCommands-BXGFH4VX.js → updateCommands-KDYX32JR.js} +3 -1
- package/{updateDialogTitleAction-UUZ5HDM2.js → updateDialogTitleAction-VTE36JGF.js} +6 -6
- package/windowsSelfUpdate-IYQK4IDS.js +14 -0
- package/{agentPullCommand-UXXV5KKW.js → agentPullCommand-7LHBOEYH.js} +1 -1
- package/{chunk-COXNBVP7.js → chunk-FLX5EYLQ.js} +4 -4
- package/{chunk-RV4DPEAM.js → chunk-XLQ646HU.js} +3 -3
- package/{workloadLifecycle-MZ2V5L43.js → workloadLifecycle-2F5YKFGW.js} +7 -7
|
@@ -0,0 +1,584 @@
|
|
|
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
|
+
scheduleWindowsSelfUpdate
|
|
15
|
+
} from "./chunk-53HMDUG6.js";
|
|
16
|
+
import {
|
|
17
|
+
t
|
|
18
|
+
} from "./chunk-PS3GU7YU.js";
|
|
19
|
+
import {
|
|
20
|
+
normalizeServerOrigin
|
|
21
|
+
} from "./chunk-CF7PE763.js";
|
|
22
|
+
|
|
23
|
+
// packages/cli/updateCommands.ts
|
|
24
|
+
import { existsSync, readFileSync, accessSync, constants } from "node:fs";
|
|
25
|
+
import { homedir } from "node:os";
|
|
26
|
+
import { dirname, join } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
function resolvePackageJsonPath() {
|
|
29
|
+
if (isCompiledBinary()) {
|
|
30
|
+
const execDir = dirname(process.execPath);
|
|
31
|
+
const candidate2 = join(execDir, "package.json");
|
|
32
|
+
if (existsSync(candidate2)) return candidate2;
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const CLI_DIR = dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
const candidate = join(CLI_DIR, "package.json");
|
|
37
|
+
return existsSync(candidate) ? candidate : null;
|
|
38
|
+
}
|
|
39
|
+
var PACKAGE_JSON_PATH = resolvePackageJsonPath();
|
|
40
|
+
function getCliInstallChannel(serverUrl) {
|
|
41
|
+
const normalized = normalizeServerOrigin(serverUrl);
|
|
42
|
+
if (!normalized) {
|
|
43
|
+
return "latest";
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const hostname = new URL(normalized).hostname.toLowerCase();
|
|
47
|
+
if (hostname === "us.nolo.chat" || hostname.endsWith(".us.nolo.chat")) {
|
|
48
|
+
return "alpha";
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
if (/us\.nolo\.chat/i.test(normalized)) {
|
|
52
|
+
return "alpha";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return "latest";
|
|
56
|
+
}
|
|
57
|
+
function renderProgressBar(percent, width = 30) {
|
|
58
|
+
const pct = Math.max(0, Math.min(100, percent));
|
|
59
|
+
const filledLen = Math.round(width * pct / 100);
|
|
60
|
+
const emptyLen = width - filledLen;
|
|
61
|
+
const bar = "#".repeat(filledLen) + " ".repeat(emptyLen);
|
|
62
|
+
const pctText = pct.toFixed(1).padStart(5, " ");
|
|
63
|
+
return `[${bar}] ${pctText}%`;
|
|
64
|
+
}
|
|
65
|
+
function buildNpmSelfUpdateCommand(channel = "latest") {
|
|
66
|
+
return ["npm", "install", "-g", `nolo-cli@${channel}`, "--force", "--progress"];
|
|
67
|
+
}
|
|
68
|
+
function resolveStandaloneBundlePlatform(platform = process.platform, arch = process.arch) {
|
|
69
|
+
if (platform === "linux" && arch === "x64") {
|
|
70
|
+
return { tarballName: "nolo-linux-x64.tar.gz", extractSubdir: "nolo-linux-x64" };
|
|
71
|
+
}
|
|
72
|
+
if (platform === "darwin" && arch === "arm64") {
|
|
73
|
+
return { tarballName: "nolo-darwin-arm64.tar.gz", extractSubdir: "nolo-darwin-arm64" };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
function resolveStandaloneBundleRepoBase(channel) {
|
|
78
|
+
return channel === "alpha" ? "https://us.nolo.chat" : "https://nolo.chat";
|
|
79
|
+
}
|
|
80
|
+
function buildStandaloneManualUpdateHint(channel) {
|
|
81
|
+
const repoBase = resolveStandaloneBundleRepoBase(channel);
|
|
82
|
+
return `curl -fsSL ${repoBase}/install-nolo.sh | sh`;
|
|
83
|
+
}
|
|
84
|
+
function resolveStandaloneInstallDir() {
|
|
85
|
+
const candidates = [
|
|
86
|
+
"/usr/local/bin",
|
|
87
|
+
join(homedir(), ".local/bin"),
|
|
88
|
+
join(homedir(), ".nolo/bin")
|
|
89
|
+
];
|
|
90
|
+
for (const dir of candidates) {
|
|
91
|
+
if (!existsSync(dir)) continue;
|
|
92
|
+
try {
|
|
93
|
+
accessSync(dir, constants.W_OK);
|
|
94
|
+
return dir;
|
|
95
|
+
} catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return join(homedir(), ".nolo/bin");
|
|
100
|
+
}
|
|
101
|
+
function readPackageInfo() {
|
|
102
|
+
if (PACKAGE_JSON_PATH) {
|
|
103
|
+
try {
|
|
104
|
+
const raw = readFileSync(PACKAGE_JSON_PATH, "utf8");
|
|
105
|
+
const parsed = JSON.parse(raw);
|
|
106
|
+
return {
|
|
107
|
+
name: parsed.name || "nolo-cli",
|
|
108
|
+
version: parsed.version || "0.0.0"
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
name: process.env.NOLO_CLI_PACKAGE_NAME || "nolo-cli",
|
|
115
|
+
version: process.env.NOLO_CLI_VERSION || "0.0.0"
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function buildCliVersionText(info) {
|
|
119
|
+
return `${info.name} ${info.version}`;
|
|
120
|
+
}
|
|
121
|
+
function buildSelfUpdateCommand(serverUrl) {
|
|
122
|
+
return buildNpmSelfUpdateCommand(getCliInstallChannel(serverUrl));
|
|
123
|
+
}
|
|
124
|
+
function resolveSelfUpdateServerUrl(env = process.env, override) {
|
|
125
|
+
if (override?.trim()) {
|
|
126
|
+
return normalizeServerOrigin(override);
|
|
127
|
+
}
|
|
128
|
+
const fromEnv = env.NOLO_SERVER || env.BASE_URL;
|
|
129
|
+
if (typeof fromEnv === "string" && fromEnv.trim()) {
|
|
130
|
+
return normalizeServerOrigin(fromEnv);
|
|
131
|
+
}
|
|
132
|
+
const profile = loadProfileConfig();
|
|
133
|
+
const profileUrl = profile?.profiles?.[profile.currentProfile]?.serverUrl;
|
|
134
|
+
if (profileUrl?.trim()) {
|
|
135
|
+
return normalizeServerOrigin(profileUrl);
|
|
136
|
+
}
|
|
137
|
+
return DEFAULT_NOLO_SERVER_URL;
|
|
138
|
+
}
|
|
139
|
+
function buildCliDoctorText(info) {
|
|
140
|
+
return [
|
|
141
|
+
t("updateDoctorTitle"),
|
|
142
|
+
"---------------",
|
|
143
|
+
t("updateDoctorVersion", info.packageName, info.version),
|
|
144
|
+
t("updateDoctorInstall", info.installKind),
|
|
145
|
+
t("updateDoctorChannel", info.updateChannel),
|
|
146
|
+
t("updateDoctorEntry", info.entrypoint),
|
|
147
|
+
t("updateDoctorServer", info.serverUrl),
|
|
148
|
+
t("updateDoctorProfile", info.profileName),
|
|
149
|
+
t("updateDoctorCommand"),
|
|
150
|
+
"",
|
|
151
|
+
t("updateDoctorDiff"),
|
|
152
|
+
t("updateDoctorOlder"),
|
|
153
|
+
"",
|
|
154
|
+
t("updateDoctorManual", info.installKind === "standalone-bundle" ? buildStandaloneManualUpdateHint(info.updateChannel) : buildNpmSelfUpdateCommand(info.updateChannel).join(" "))
|
|
155
|
+
].join("\n");
|
|
156
|
+
}
|
|
157
|
+
function isRunSelfUpdateOptions(value) {
|
|
158
|
+
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);
|
|
159
|
+
}
|
|
160
|
+
async function forwardSpawnOutput(stream, output) {
|
|
161
|
+
if (!stream) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
for await (const chunk of stream) {
|
|
165
|
+
output.write(normalizeSpawnChunk(chunk));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function normalizeSpawnChunk(chunk) {
|
|
169
|
+
if (typeof chunk === "string" || chunk instanceof Uint8Array) {
|
|
170
|
+
return chunk;
|
|
171
|
+
}
|
|
172
|
+
if (chunk instanceof ArrayBuffer) {
|
|
173
|
+
return new Uint8Array(chunk);
|
|
174
|
+
}
|
|
175
|
+
return new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
176
|
+
}
|
|
177
|
+
async function runShellScript(script, {
|
|
178
|
+
output,
|
|
179
|
+
spawn,
|
|
180
|
+
env,
|
|
181
|
+
cwd,
|
|
182
|
+
useCustomSink
|
|
183
|
+
}) {
|
|
184
|
+
const proc = spawn({
|
|
185
|
+
cmd: ["sh", "-c", script],
|
|
186
|
+
cwd,
|
|
187
|
+
// Capture mode (TUI sink): ignore stdin — the TUI's own decoder is
|
|
188
|
+
// reading the tty, and a child that reads stdin would race it for keys.
|
|
189
|
+
// The inherit branch is unreachable inside the TUI (useCustomSink is
|
|
190
|
+
// always true there) and stays the correct choice for `nolo update`.
|
|
191
|
+
stdin: useCustomSink ? "ignore" : "inherit",
|
|
192
|
+
stdout: useCustomSink ? "pipe" : "inherit",
|
|
193
|
+
stderr: useCustomSink ? "pipe" : "inherit",
|
|
194
|
+
env
|
|
195
|
+
});
|
|
196
|
+
if (!useCustomSink) {
|
|
197
|
+
return proc.exited;
|
|
198
|
+
}
|
|
199
|
+
const [exitCode] = await Promise.all([
|
|
200
|
+
proc.exited,
|
|
201
|
+
forwardSpawnOutput(proc.stdout, output),
|
|
202
|
+
forwardSpawnOutput(proc.stderr, output)
|
|
203
|
+
]);
|
|
204
|
+
return exitCode;
|
|
205
|
+
}
|
|
206
|
+
function shellQuote(value) {
|
|
207
|
+
return "'" + value.replace(/'/g, "'\\''") + "'";
|
|
208
|
+
}
|
|
209
|
+
function buildStandaloneUpdateScript(args) {
|
|
210
|
+
const curl = "curl -fL --progress-bar --connect-timeout 20 --max-time 600 --speed-limit 1 --speed-time 60";
|
|
211
|
+
return `set -eu
|
|
212
|
+
EXTRACT_DIR=${shellQuote(args.extractDir)}
|
|
213
|
+
ENTRY=${shellQuote(args.symlinkPath)}
|
|
214
|
+
CURRENT_VERSION=${shellQuote(args.currentVersion)}
|
|
215
|
+
STAGING="$EXTRACT_DIR.new.$$"
|
|
216
|
+
BACKUP="$EXTRACT_DIR.old.$$"
|
|
217
|
+
LINK="$ENTRY.new.$$"
|
|
218
|
+
old_moved=0
|
|
219
|
+
new_moved=0
|
|
220
|
+
committed=0
|
|
221
|
+
cleanup() {
|
|
222
|
+
status=$?
|
|
223
|
+
trap - 0 HUP INT TERM
|
|
224
|
+
if [ "$committed" = 0 ]; then
|
|
225
|
+
if [ "$new_moved" = 1 ] && [ -d "$EXTRACT_DIR" ]; then
|
|
226
|
+
mv "$EXTRACT_DIR" "$STAGING" || exit 1
|
|
227
|
+
fi
|
|
228
|
+
if [ "$old_moved" = 1 ] && [ -d "$BACKUP" ]; then
|
|
229
|
+
mv "$BACKUP" "$EXTRACT_DIR" || exit 1
|
|
230
|
+
fi
|
|
231
|
+
fi
|
|
232
|
+
rm -rf "$STAGING" || true
|
|
233
|
+
rm -f "$LINK" || true
|
|
234
|
+
exit "$status"
|
|
235
|
+
}
|
|
236
|
+
# Refuse collisions before installing cleanup: never remove somebody else's path.
|
|
237
|
+
if [ -e "$STAGING" ] || [ -L "$STAGING" ] ||
|
|
238
|
+
[ -e "$BACKUP" ] || [ -L "$BACKUP" ] ||
|
|
239
|
+
[ -e "$LINK" ] || [ -L "$LINK" ]; then
|
|
240
|
+
echo "Error: update staging path already exists" >&2
|
|
241
|
+
exit 1
|
|
242
|
+
fi
|
|
243
|
+
mkdir -p "\${EXTRACT_DIR%/*}"
|
|
244
|
+
mkdir "$STAGING"
|
|
245
|
+
trap cleanup 0
|
|
246
|
+
trap 'exit 1' HUP INT TERM
|
|
247
|
+
|
|
248
|
+
echo ${shellQuote(`Downloading nolo from ${args.tarballUrl}...`)}
|
|
249
|
+
if ! ${curl} ${shellQuote(args.tarballUrl)} -o "$STAGING/bundle.tar.gz"; then
|
|
250
|
+
${args.tarballUrl !== args.fallbackUrl ? `echo ${shellQuote(`Primary source unavailable, trying ${args.fallbackUrl}...`)}
|
|
251
|
+
if ! ${curl} ${shellQuote(args.fallbackUrl)} -o "$STAGING/bundle.tar.gz"; then
|
|
252
|
+
echo "Error: download failed" >&2
|
|
253
|
+
exit 1
|
|
254
|
+
fi` : `echo "Error: download failed" >&2
|
|
255
|
+
exit 1`}
|
|
256
|
+
fi
|
|
257
|
+
tar -xzf "$STAGING/bundle.tar.gz" -C "$STAGING"
|
|
258
|
+
rm -f "$STAGING/bundle.tar.gz"
|
|
259
|
+
chmod +x "$STAGING/nolo"
|
|
260
|
+
# A failing, empty or malformed version response must not touch the live install.
|
|
261
|
+
VERSION_TEXT=$("$STAGING/nolo" -v)
|
|
262
|
+
case "$VERSION_TEXT" in
|
|
263
|
+
"nolo-cli "*) VERSION=\${VERSION_TEXT#nolo-cli } ;;
|
|
264
|
+
*) VERSION=$VERSION_TEXT ;;
|
|
265
|
+
esac
|
|
266
|
+
CORE=\${VERSION%%[-+]*}
|
|
267
|
+
MAJOR=\${CORE%%.*}
|
|
268
|
+
REST=\${CORE#*.}
|
|
269
|
+
MINOR=\${REST%%.*}
|
|
270
|
+
PATCH=\${REST#*.}
|
|
271
|
+
case "$MAJOR:$MINOR:$PATCH" in
|
|
272
|
+
*[!0-9:]*|:*|*::*|*:) echo "Error: invalid bundle version" >&2; exit 1 ;;
|
|
273
|
+
esac
|
|
274
|
+
if [ "$CORE" != "$MAJOR.$MINOR.$PATCH" ]; then
|
|
275
|
+
echo "Error: invalid bundle version" >&2
|
|
276
|
+
exit 1
|
|
277
|
+
fi
|
|
278
|
+
case "$VERSION" in
|
|
279
|
+
*[!0-9A-Za-z.+-]*) echo "Error: invalid bundle version" >&2; exit 1 ;;
|
|
280
|
+
esac
|
|
281
|
+
case "$CURRENT_VERSION" in
|
|
282
|
+
"nolo-cli "*) CUR_VER=\${CURRENT_VERSION#nolo-cli } ;;
|
|
283
|
+
*) CUR_VER=$CURRENT_VERSION ;;
|
|
284
|
+
esac
|
|
285
|
+
CUR_CORE=\${CUR_VER%%[-+]*}
|
|
286
|
+
CUR_MAJOR=\${CUR_CORE%%.*}
|
|
287
|
+
CUR_REST=\${CUR_CORE#*.}
|
|
288
|
+
CUR_MINOR=\${CUR_REST%%.*}
|
|
289
|
+
CUR_PATCH=\${CUR_REST#*.}
|
|
290
|
+
if [ -n "$CUR_MAJOR" ] && [ -n "$CUR_MINOR" ] && [ -n "$CUR_PATCH" ]; then
|
|
291
|
+
case "$CUR_MAJOR:$CUR_MINOR:$CUR_PATCH" in
|
|
292
|
+
*[!0-9:]*|:*|*::*|*:) ;;
|
|
293
|
+
*)
|
|
294
|
+
if [ "$CUR_CORE" = "$CUR_MAJOR.$CUR_MINOR.$CUR_PATCH" ]; then
|
|
295
|
+
is_downgrade=0
|
|
296
|
+
if [ "$MAJOR" -lt "$CUR_MAJOR" ]; then
|
|
297
|
+
is_downgrade=1
|
|
298
|
+
elif [ "$MAJOR" -eq "$CUR_MAJOR" ]; then
|
|
299
|
+
if [ "$MINOR" -lt "$CUR_MINOR" ]; then
|
|
300
|
+
is_downgrade=1
|
|
301
|
+
elif [ "$MINOR" -eq "$CUR_MINOR" ]; then
|
|
302
|
+
if [ "$PATCH" -lt "$CUR_PATCH" ]; then
|
|
303
|
+
is_downgrade=1
|
|
304
|
+
fi
|
|
305
|
+
fi
|
|
306
|
+
fi
|
|
307
|
+
if [ "$is_downgrade" = 1 ]; then
|
|
308
|
+
echo "Error: refusing downgrade from $CURRENT_VERSION to $VERSION" >&2
|
|
309
|
+
exit 11
|
|
310
|
+
fi
|
|
311
|
+
fi
|
|
312
|
+
;;
|
|
313
|
+
esac
|
|
314
|
+
fi
|
|
315
|
+
if [ "$VERSION" = "$CURRENT_VERSION" ]; then
|
|
316
|
+
echo "\u2713 Already up to date (nolo-cli $VERSION)."
|
|
317
|
+
exit 10
|
|
318
|
+
fi
|
|
319
|
+
mkdir -p "\${ENTRY%/*}"
|
|
320
|
+
# mv without -T is portable only when the destination is not a directory.
|
|
321
|
+
if [ -d "$ENTRY" ] || [ -L "$EXTRACT_DIR" ]; then
|
|
322
|
+
echo "Error: refusing directory entrypoint or symlink bundle directory" >&2
|
|
323
|
+
exit 1
|
|
324
|
+
fi
|
|
325
|
+
ln -s "$EXTRACT_DIR/nolo" "$LINK"
|
|
326
|
+
if [ -e "$EXTRACT_DIR" ]; then
|
|
327
|
+
old_moved=1
|
|
328
|
+
mv "$EXTRACT_DIR" "$BACKUP"
|
|
329
|
+
fi
|
|
330
|
+
new_moved=1
|
|
331
|
+
mv "$STAGING" "$EXTRACT_DIR"
|
|
332
|
+
mv -f "$LINK" "$ENTRY"
|
|
333
|
+
committed=1
|
|
334
|
+
# Retain only the newest recovery copy from this run; prune older backups.
|
|
335
|
+
for old_copy in "$EXTRACT_DIR.old."*; do
|
|
336
|
+
if [ -d "$old_copy" ] && [ ! -L "$old_copy" ] && [ "$old_copy" != "$BACKUP" ]; then
|
|
337
|
+
rm -rf "$old_copy" || true
|
|
338
|
+
fi
|
|
339
|
+
done
|
|
340
|
+
# Retain the previous bundle as a recovery copy; never unlink the live entry.
|
|
341
|
+
echo "nolo updated to $ENTRY"
|
|
342
|
+
`;
|
|
343
|
+
}
|
|
344
|
+
async function runStandaloneBundleUpdate(options) {
|
|
345
|
+
const output = options.output ?? process.stdout;
|
|
346
|
+
const spawn = options.spawn ?? resolveDefaultSpawn();
|
|
347
|
+
const env = options.env ?? process.env;
|
|
348
|
+
const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
|
|
349
|
+
const channel = getCliInstallChannel(serverUrl);
|
|
350
|
+
const platform = resolveStandaloneBundlePlatform();
|
|
351
|
+
if (!platform) {
|
|
352
|
+
output.write(
|
|
353
|
+
t("updateUnsupported", process.platform, process.arch, buildStandaloneManualUpdateHint(channel))
|
|
354
|
+
);
|
|
355
|
+
return 1;
|
|
356
|
+
}
|
|
357
|
+
const { tarballName, extractSubdir } = platform;
|
|
358
|
+
const repoBase = resolveStandaloneBundleRepoBase(channel);
|
|
359
|
+
const tarballUrl = `${repoBase}/public/downloads/${tarballName}`;
|
|
360
|
+
const fallbackUrl = `https://nolo.chat/public/downloads/${tarballName}`;
|
|
361
|
+
const extractDir = join(homedir(), ".nolo", extractSubdir);
|
|
362
|
+
const installDir = resolveStandaloneInstallDir();
|
|
363
|
+
const symlinkPath = join(installDir, "nolo");
|
|
364
|
+
const script = buildStandaloneUpdateScript({
|
|
365
|
+
tarballUrl,
|
|
366
|
+
fallbackUrl,
|
|
367
|
+
extractDir,
|
|
368
|
+
symlinkPath,
|
|
369
|
+
currentVersion: readPackageInfo().version
|
|
370
|
+
});
|
|
371
|
+
output.write(`
|
|
372
|
+
${t("updateInstallerTitle")}
|
|
373
|
+
`);
|
|
374
|
+
output.write(`-----------------------------------------
|
|
375
|
+
`);
|
|
376
|
+
output.write(`${t("updateBundleTarget", channel)}
|
|
377
|
+
`);
|
|
378
|
+
output.write(`${t("updateBundleDownloading")}
|
|
379
|
+
`);
|
|
380
|
+
const useCustomSink = options.output !== void 0;
|
|
381
|
+
const exitCode = await runShellScript(script, {
|
|
382
|
+
output,
|
|
383
|
+
spawn,
|
|
384
|
+
env,
|
|
385
|
+
useCustomSink
|
|
386
|
+
});
|
|
387
|
+
if (exitCode === 10) {
|
|
388
|
+
output.write(` ${renderProgressBar(100)}
|
|
389
|
+
`);
|
|
390
|
+
return 0;
|
|
391
|
+
}
|
|
392
|
+
if (exitCode === 0) {
|
|
393
|
+
output.write(` ${renderProgressBar(100)}
|
|
394
|
+
`);
|
|
395
|
+
output.write(`${t("updateCompleted")}
|
|
396
|
+
|
|
397
|
+
`);
|
|
398
|
+
}
|
|
399
|
+
return exitCode;
|
|
400
|
+
}
|
|
401
|
+
var NOLO_UPDATE_CHECK_KILL_SWITCH = "NOLO_CLI_NO_UPDATE_CHECK";
|
|
402
|
+
function parseCliVersion(raw) {
|
|
403
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(raw.trim());
|
|
404
|
+
if (!match) return null;
|
|
405
|
+
return {
|
|
406
|
+
main: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
407
|
+
pre: match[4] ? match[4].split(".") : []
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function compareCliVersions(a, b) {
|
|
411
|
+
const pa = parseCliVersion(a);
|
|
412
|
+
const pb = parseCliVersion(b);
|
|
413
|
+
if (!pa || !pb) return a.localeCompare(b);
|
|
414
|
+
for (let i = 0; i < 3; i++) {
|
|
415
|
+
if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
|
|
416
|
+
}
|
|
417
|
+
if (pa.pre.length === 0 && pb.pre.length === 0) return 0;
|
|
418
|
+
if (pa.pre.length === 0) return 1;
|
|
419
|
+
if (pb.pre.length === 0) return -1;
|
|
420
|
+
const len = Math.max(pa.pre.length, pb.pre.length);
|
|
421
|
+
for (let i = 0; i < len; i++) {
|
|
422
|
+
const x = pa.pre[i];
|
|
423
|
+
const y = pb.pre[i];
|
|
424
|
+
if (x === void 0) return -1;
|
|
425
|
+
if (y === void 0) return 1;
|
|
426
|
+
if (x === y) continue;
|
|
427
|
+
const xn = /^\d+$/.test(x) ? Number(x) : NaN;
|
|
428
|
+
const yn = /^\d+$/.test(y) ? Number(y) : NaN;
|
|
429
|
+
if (!Number.isNaN(xn) && !Number.isNaN(yn)) return xn < yn ? -1 : 1;
|
|
430
|
+
if (!Number.isNaN(xn)) return -1;
|
|
431
|
+
if (!Number.isNaN(yn)) return 1;
|
|
432
|
+
return x < y ? -1 : 1;
|
|
433
|
+
}
|
|
434
|
+
return 0;
|
|
435
|
+
}
|
|
436
|
+
async function checkForCliUpdate(currentVersion, serverUrl, options = {}) {
|
|
437
|
+
const env = options.env ?? process.env;
|
|
438
|
+
if ((env[NOLO_UPDATE_CHECK_KILL_SWITCH] ?? process.env[NOLO_UPDATE_CHECK_KILL_SWITCH]) === "1") {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
if (!currentVersion || !parseCliVersion(currentVersion)) return null;
|
|
442
|
+
const channel = getCliInstallChannel(serverUrl);
|
|
443
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
444
|
+
const timeoutMs = options.timeoutMs ?? 2e3;
|
|
445
|
+
try {
|
|
446
|
+
const res = await fetchImpl(
|
|
447
|
+
`https://registry.npmjs.org/nolo-cli/${channel}`,
|
|
448
|
+
{
|
|
449
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
450
|
+
headers: { accept: "application/json" }
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
if (!res.ok) return null;
|
|
454
|
+
const data = await res.json();
|
|
455
|
+
const latestVersion = data.version;
|
|
456
|
+
if (!latestVersion || !parseCliVersion(latestVersion) || compareCliVersions(latestVersion, currentVersion) <= 0) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
return { latestVersion, channel };
|
|
460
|
+
} catch {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
async function runSelfUpdateDetailed(outputOrOptions) {
|
|
465
|
+
const options = outputOrOptions === void 0 ? {} : isRunSelfUpdateOptions(outputOrOptions) ? outputOrOptions : { output: outputOrOptions };
|
|
466
|
+
if (isCompiledBinary()) {
|
|
467
|
+
return {
|
|
468
|
+
exitCode: await runStandaloneBundleUpdate(options),
|
|
469
|
+
disposition: "completed"
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
const output = options.output ?? process.stdout;
|
|
473
|
+
const spawn = options.spawn ?? resolveDefaultSpawn();
|
|
474
|
+
const env = options.env ?? process.env;
|
|
475
|
+
const serverUrl = resolveSelfUpdateServerUrl(env, options.serverUrl);
|
|
476
|
+
const channel = getCliInstallChannel(serverUrl);
|
|
477
|
+
const command = buildNpmSelfUpdateCommand(channel);
|
|
478
|
+
if ((options.platform ?? process.platform) === "win32") {
|
|
479
|
+
const packageInfo = readPackageInfo();
|
|
480
|
+
const entrypointPath = options.entrypointPath ?? fileURLToPath(import.meta.url);
|
|
481
|
+
const schedule = options.scheduleWindowsUpdate ?? scheduleWindowsSelfUpdate;
|
|
482
|
+
try {
|
|
483
|
+
const scheduled = schedule({
|
|
484
|
+
channel,
|
|
485
|
+
currentVersion: packageInfo.version,
|
|
486
|
+
entrypointPath,
|
|
487
|
+
env
|
|
488
|
+
});
|
|
489
|
+
output.write(`
|
|
490
|
+
${t("updateInstallerTitle")}
|
|
491
|
+
`);
|
|
492
|
+
output.write(`-----------------------------------------
|
|
493
|
+
`);
|
|
494
|
+
output.write(`${t("updateNpmTarget", channel)}
|
|
495
|
+
`);
|
|
496
|
+
output.write(`${t("updateScheduled", String(scheduled.helperPid))}
|
|
497
|
+
`);
|
|
498
|
+
output.write(`${t("updateKeepUsing")}
|
|
499
|
+
`);
|
|
500
|
+
output.write(`${t("updateBackground")}
|
|
501
|
+
`);
|
|
502
|
+
output.write(`${t("updateCheckLog", scheduled.logPath)}
|
|
503
|
+
|
|
504
|
+
`);
|
|
505
|
+
return { exitCode: 0, disposition: "scheduled" };
|
|
506
|
+
} catch (error) {
|
|
507
|
+
output.write(
|
|
508
|
+
`${t("updateScheduleFailed", error instanceof Error ? error.message : String(error))}
|
|
509
|
+
`
|
|
510
|
+
);
|
|
511
|
+
output.write(
|
|
512
|
+
`${t("updateManualClose", command.join(" "))}
|
|
513
|
+
`
|
|
514
|
+
);
|
|
515
|
+
return { exitCode: 1, disposition: "completed" };
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
output.write(`
|
|
519
|
+
${t("updateInstallerTitle")}
|
|
520
|
+
`);
|
|
521
|
+
output.write(`-----------------------------------------
|
|
522
|
+
`);
|
|
523
|
+
output.write(`${t("updateNpmTarget", channel)}
|
|
524
|
+
`);
|
|
525
|
+
output.write(`${t("updateNpmDownloading")}
|
|
526
|
+
`);
|
|
527
|
+
const useCustomSink = options.output !== void 0;
|
|
528
|
+
const proc = spawn({
|
|
529
|
+
cmd: command,
|
|
530
|
+
// Capture mode (TUI sink): ignore stdin — see runShellScript.
|
|
531
|
+
stdin: useCustomSink ? "ignore" : "inherit",
|
|
532
|
+
stdout: useCustomSink ? "pipe" : "inherit",
|
|
533
|
+
stderr: useCustomSink ? "pipe" : "inherit",
|
|
534
|
+
env
|
|
535
|
+
});
|
|
536
|
+
if (!useCustomSink) {
|
|
537
|
+
const exitCode2 = await proc.exited;
|
|
538
|
+
if (exitCode2 === 0) {
|
|
539
|
+
output.write(` ${renderProgressBar(100)}
|
|
540
|
+
`);
|
|
541
|
+
output.write(`${t("updateCompleted")}
|
|
542
|
+
|
|
543
|
+
`);
|
|
544
|
+
}
|
|
545
|
+
return { exitCode: exitCode2, disposition: "completed" };
|
|
546
|
+
}
|
|
547
|
+
const [exitCode] = await Promise.all([
|
|
548
|
+
proc.exited,
|
|
549
|
+
forwardSpawnOutput(proc.stdout, output),
|
|
550
|
+
forwardSpawnOutput(proc.stderr, output)
|
|
551
|
+
]);
|
|
552
|
+
if (exitCode === 0) {
|
|
553
|
+
output.write(` ${renderProgressBar(100)}
|
|
554
|
+
`);
|
|
555
|
+
output.write(`${t("updateCompleted")}
|
|
556
|
+
|
|
557
|
+
`);
|
|
558
|
+
}
|
|
559
|
+
return { exitCode, disposition: "completed" };
|
|
560
|
+
}
|
|
561
|
+
async function runSelfUpdate(outputOrOptions) {
|
|
562
|
+
return (await runSelfUpdateDetailed(outputOrOptions)).exitCode;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export {
|
|
566
|
+
getCliInstallChannel,
|
|
567
|
+
renderProgressBar,
|
|
568
|
+
buildNpmSelfUpdateCommand,
|
|
569
|
+
resolveStandaloneBundlePlatform,
|
|
570
|
+
resolveStandaloneBundleRepoBase,
|
|
571
|
+
buildStandaloneManualUpdateHint,
|
|
572
|
+
readPackageInfo,
|
|
573
|
+
buildCliVersionText,
|
|
574
|
+
buildSelfUpdateCommand,
|
|
575
|
+
resolveSelfUpdateServerUrl,
|
|
576
|
+
buildCliDoctorText,
|
|
577
|
+
buildStandaloneUpdateScript,
|
|
578
|
+
runStandaloneBundleUpdate,
|
|
579
|
+
NOLO_UPDATE_CHECK_KILL_SWITCH,
|
|
580
|
+
compareCliVersions,
|
|
581
|
+
checkForCliUpdate,
|
|
582
|
+
runSelfUpdateDetailed,
|
|
583
|
+
runSelfUpdate
|
|
584
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requireTokenUser
|
|
3
3
|
} from "./chunk-4FZUUCXQ.js";
|
|
4
|
-
import {
|
|
5
|
-
t
|
|
6
|
-
} from "./chunk-TDX2L4W2.js";
|
|
7
4
|
import {
|
|
8
5
|
resolveServerUrl
|
|
9
6
|
} from "./chunk-WACI5I6V.js";
|
|
7
|
+
import {
|
|
8
|
+
t
|
|
9
|
+
} from "./chunk-PS3GU7YU.js";
|
|
10
10
|
|
|
11
11
|
// packages/cli/cliApiClient.ts
|
|
12
12
|
var CliApiError = class extends Error {
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deleteDialog,
|
|
3
|
-
runtime_default,
|
|
4
|
-
toast
|
|
5
|
-
} from "./chunk-HTSXDJHA.js";
|
|
6
1
|
import {
|
|
7
2
|
getCurrentSpaceId,
|
|
8
3
|
getCurrentSpaceIdRaw,
|
|
9
4
|
updateCurrentSpaceIfMatch
|
|
10
5
|
} from "./chunk-ZJ7UHBJS.js";
|
|
6
|
+
import {
|
|
7
|
+
deleteDialog,
|
|
8
|
+
runtime_default,
|
|
9
|
+
toast
|
|
10
|
+
} from "./chunk-OC4NVQ5S.js";
|
|
11
11
|
import {
|
|
12
12
|
formatISO
|
|
13
13
|
} from "./chunk-ZRAU6T47.js";
|