karnel-termux 4.16.1 → 4.16.3
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.
|
@@ -188,7 +188,10 @@ _cactus_write_wrapper() {
|
|
|
188
188
|
cat >"$temporary" <<EOF
|
|
189
189
|
#!$PREFIX/bin/bash
|
|
190
190
|
# Karnel-managed Cactus wrapper (qemu-aarch64 emulation)
|
|
191
|
-
|
|
191
|
+
# The server loads the engine via ctypes inside the python process, so the
|
|
192
|
+
# whole interpreter must run under qemu-aarch64; CACTUS_EMULATE=1 makes the
|
|
193
|
+
# CLI wrap native subprocess children (bin/run) with qemu as well.
|
|
194
|
+
exec proot-distro login --shared-tmp ubuntu -- env CACTUS_EMULATE=1 qemu-aarch64 -cpu max -L / $CACTUS_CONTAINER_DIR/venv/bin/python -m cactus "\$@"
|
|
192
195
|
EOF
|
|
193
196
|
else
|
|
194
197
|
cat >"$temporary" <<EOF
|
|
@@ -336,12 +339,18 @@ _cactus_cli_create_glibc_wrapper() {
|
|
|
336
339
|
log_error "Wrapper template not found at $wrapper_src"
|
|
337
340
|
return 1
|
|
338
341
|
fi
|
|
339
|
-
|
|
342
|
+
sed "1s|^#!.*|#!$PREFIX/bin/bash|" "$wrapper_src" >"$PREFIX/bin/cactus"
|
|
340
343
|
chmod +x "$PREFIX/bin/cactus"
|
|
341
344
|
return 0
|
|
342
345
|
}
|
|
343
346
|
|
|
344
347
|
_cactus_cli_install_native() {
|
|
348
|
+
if ! _cactus_cpu_supported; then
|
|
349
|
+
log_error "This CPU lacks ARMv8.1 features (LSE/fp16/dotprod) required by the native Cactus engine — it would crash with Illegal instruction"
|
|
350
|
+
list_item "Re-run ${D_CYAN}karnel install ai --cactus${D_NC} and choose ${D_CYAN}proot-distro (ubuntu container)${D_NC}"
|
|
351
|
+
list_item "That method runs under qemu-aarch64 emulation: functional but very slow on this CPU"
|
|
352
|
+
return 1
|
|
353
|
+
fi
|
|
345
354
|
_cactus_cli_install_deps_native || return 1
|
|
346
355
|
_cactus_cli_install_pip_glibc || return 1
|
|
347
356
|
_cactus_cli_verify_glibc || return 1
|
|
@@ -370,7 +379,7 @@ _cactus_cli_create_proot_wrapper() {
|
|
|
370
379
|
log_error "Wrapper template not found at $wrapper_src"
|
|
371
380
|
return 1
|
|
372
381
|
fi
|
|
373
|
-
|
|
382
|
+
sed "1s|^#!.*|#!$PREFIX/bin/bash|" "$wrapper_src" >"$PREFIX/bin/cactus"
|
|
374
383
|
chmod +x "$PREFIX/bin/cactus"
|
|
375
384
|
return 0
|
|
376
385
|
}
|
|
@@ -396,7 +405,7 @@ _cactus_cli_installed_version() {
|
|
|
396
405
|
fi
|
|
397
406
|
|
|
398
407
|
if [ "$method" = "proot" ]; then
|
|
399
|
-
_spin_capture "Detecting version" bash -c 'proot-distro login --shared-tmp ubuntu --
|
|
408
|
+
_spin_capture "Detecting version" bash -c 'proot-distro login --shared-tmp ubuntu -- /opt/karnel/cactus/venv/bin/python -c "from importlib.metadata import version; print(version(\"cactus-compute\"))" 2>/dev/null'
|
|
400
409
|
else
|
|
401
410
|
_spin_capture "Detecting version" bash -c 'printf "%s\n" "from importlib.metadata import version; print(version(\"cactus-compute\"))" | glibc-runner -s "$PREFIX/glibc/bin/python" - 2>/dev/null'
|
|
402
411
|
fi
|
|
@@ -409,14 +418,11 @@ _cactus_update_native() {
|
|
|
409
418
|
fi
|
|
410
419
|
|
|
411
420
|
if [ "$method" = "proot" ]; then
|
|
412
|
-
|
|
421
|
+
_cactus_ensure_ubuntu || return 1
|
|
422
|
+
if ! _install_cactus_inside_ubuntu || ! _cactus_apply_emulation_patch || ! _cactus_write_wrapper || ! _cactus_validate; then
|
|
413
423
|
log_error "Failed to update Cactus Engine CLI"
|
|
414
424
|
return 1
|
|
415
425
|
fi
|
|
416
|
-
if ! timeout 300 proot-distro login --shared-tmp ubuntu -- python3 -c "import cactus" &>>"$CACTUS_CLI_LOG_FILE"; then
|
|
417
|
-
log_error "Cactus Engine CLI updated but the native engine failed to load"
|
|
418
|
-
return 1
|
|
419
|
-
fi
|
|
420
426
|
log_success "Cactus Engine CLI (proot-distro) updated"
|
|
421
427
|
return 0
|
|
422
428
|
fi
|
|
@@ -434,7 +440,7 @@ _cactus_uninstall_native() {
|
|
|
434
440
|
fi
|
|
435
441
|
|
|
436
442
|
if [ "$method" = "proot" ]; then
|
|
437
|
-
|
|
443
|
+
proot-distro login ubuntu -- rm -rf /opt/karnel/cactus &>>"$CACTUS_CLI_LOG_FILE"
|
|
438
444
|
rm -f "$PREFIX/bin/cactus"
|
|
439
445
|
rm -rf "$CACTUS_DATA_DIR"
|
|
440
446
|
log_success "Cactus Engine CLI (proot-distro) uninstalled"
|
|
@@ -1144,18 +1144,22 @@ agent_server_ensure() {
|
|
|
1144
1144
|
if ! command -v cactus &>/dev/null; then
|
|
1145
1145
|
echo
|
|
1146
1146
|
log_warn "Cactus (the local model server) is not installed"
|
|
1147
|
-
|
|
1147
|
+
list_item "Install: ${D_CYAN}karnel install ai --cactus${D_NC}"
|
|
1148
|
+
echo
|
|
1149
|
+
if agent_confirm "Install Cactus now?" _agent_install_cactus; then
|
|
1148
1150
|
import "@/tools/ai/cactus/install"
|
|
1149
|
-
|
|
1151
|
+
install_cactus
|
|
1152
|
+
local _cactus_rc=$?
|
|
1153
|
+
if (( _cactus_rc == 0 || _cactus_rc == 2 )); then
|
|
1150
1154
|
log_success "Cactus installed — starting the model server…"
|
|
1151
1155
|
else
|
|
1152
|
-
log_error "Cactus installation failed —
|
|
1153
|
-
list_item "${D_CYAN}$
|
|
1156
|
+
log_error "Cactus installation failed — try again later:"
|
|
1157
|
+
list_item "${D_CYAN}karnel install ai --cactus${D_NC}"
|
|
1158
|
+
list_item "Log: ${D_CYAN}$KARNEL_CACHE/install_ai.log${D_NC}"
|
|
1154
1159
|
return 1
|
|
1155
1160
|
fi
|
|
1156
1161
|
else
|
|
1157
|
-
|
|
1158
|
-
list_item "Or start the server manually: ${D_CYAN}$AGENT_SERVER_CMD${D_NC}"
|
|
1162
|
+
list_item "When it is installed, the server starts automatically"
|
|
1159
1163
|
return 1
|
|
1160
1164
|
fi
|
|
1161
1165
|
fi
|
|
@@ -1202,7 +1206,7 @@ agent_server_stop() {
|
|
|
1202
1206
|
agent_confirm() {
|
|
1203
1207
|
local prompt="$1" var="$2" _val
|
|
1204
1208
|
while true; do
|
|
1205
|
-
printf ' %
|
|
1209
|
+
printf ' %b%b [%b]%b\n' "$D_YELLOW" "$prompt" "${D_GREEN}y${GRAY}/${D_RED}n${NC}" "$NC" >&2
|
|
1206
1210
|
printf ' > ' >&2
|
|
1207
1211
|
read -rn1 _val
|
|
1208
1212
|
echo >&2
|
|
@@ -1215,7 +1219,7 @@ agent_confirm() {
|
|
|
1215
1219
|
read -r "$var" <<<"n"
|
|
1216
1220
|
return 1
|
|
1217
1221
|
;;
|
|
1218
|
-
*) printf ' %
|
|
1222
|
+
*) printf ' %b✖%b Reply y or n\n' "$RED" "$NC" >&2 ;;
|
|
1219
1223
|
esac
|
|
1220
1224
|
done
|
|
1221
1225
|
}
|
|
@@ -121,7 +121,14 @@ agent_models_url() {
|
|
|
121
121
|
agent_check_server() {
|
|
122
122
|
local models
|
|
123
123
|
models=$(curl -fsS -m 6 "$(agent_models_url)" 2>/dev/null) || {
|
|
124
|
-
if
|
|
124
|
+
if agent_server_running; then
|
|
125
|
+
log_warn "The model server is starting — first run downloads the model (${D_CYAN}this can take several minutes${D_NC})"
|
|
126
|
+
list_item "Watch progress: ${D_CYAN}tail -f $AGENT_SERVER_LOG${D_NC}"
|
|
127
|
+
list_item "It will answer automatically once ${D_CYAN}$AGENT_ENDPOINT${D_NC} is up"
|
|
128
|
+
elif pgrep -f "cactus.* serve|cactus.launcher.py serve" &>/dev/null; then
|
|
129
|
+
log_warn "A Cactus server process is running but ${D_CYAN}$AGENT_ENDPOINT${D_NC} is not answering yet — it may still be downloading or loading the model"
|
|
130
|
+
list_item "Watch progress: ${D_CYAN}tail -f $AGENT_SERVER_LOG${D_NC}"
|
|
131
|
+
elif ! command -v cactus &>/dev/null; then
|
|
125
132
|
log_warn "Cannot reach endpoint: ${D_CYAN}$AGENT_ENDPOINT${D_NC} — Cactus is not installed"
|
|
126
133
|
list_item "Install it: ${D_CYAN}karnel install ai --cactus${D_NC}"
|
|
127
134
|
list_item "Or point to a running server: ${D_CYAN}karnel agent config endpoint <url>${D_NC}"
|
package/package.json
CHANGED