clawdex-mobile 5.0.2 → 5.0.4
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/README.md +59 -193
- package/bin/clawdex.js +2 -1
- package/docs/setup-and-operations.md +39 -1
- package/package.json +11 -1
- package/scripts/bridge-binary.js +24 -3
- package/scripts/setup-secure-dev.sh +14 -0
- package/scripts/setup-wizard.sh +143 -5
- package/services/rust-bridge/Cargo.lock +1 -1
- package/services/rust-bridge/Cargo.toml +1 -1
- package/services/rust-bridge/src/main.rs +5893 -1907
- package/vendor/bridge-binaries/darwin-arm64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/darwin-x64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/linux-arm64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/linux-armv7l/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/linux-x64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/win32-x64/codex-rust-bridge.exe +0 -0
package/scripts/setup-wizard.sh
CHANGED
|
@@ -28,6 +28,8 @@ NETWORK_MODE=""
|
|
|
28
28
|
TAILSCALE_IP=""
|
|
29
29
|
BRIDGE_HOST=""
|
|
30
30
|
BRIDGE_PORT=""
|
|
31
|
+
ACTIVE_ENGINE="${BRIDGE_ACTIVE_ENGINE:-codex}"
|
|
32
|
+
ENGINE_PRESET="false"
|
|
31
33
|
AUTO_START="true"
|
|
32
34
|
SECURE_ENV_FILE="$ROOT_DIR/.env.secure"
|
|
33
35
|
MENU_RESULT=""
|
|
@@ -45,6 +47,10 @@ ok() { rail_echo "${GREEN}$*${RESET}"; }
|
|
|
45
47
|
fail() { printf "%s ${RED}%s${RESET}\n" "$RAIL_GLYPH" "$*" >&2; }
|
|
46
48
|
SETUP_VERBOSE_INSTALLS="${CLAWDEX_SETUP_VERBOSE:-false}"
|
|
47
49
|
|
|
50
|
+
if [[ -n "${BRIDGE_ACTIVE_ENGINE:-}" ]]; then
|
|
51
|
+
ENGINE_PRESET="true"
|
|
52
|
+
fi
|
|
53
|
+
|
|
48
54
|
run_quiet_command() {
|
|
49
55
|
local label="$1"
|
|
50
56
|
shift
|
|
@@ -76,10 +82,34 @@ Usage: $(basename "$0") [options]
|
|
|
76
82
|
|
|
77
83
|
Options:
|
|
78
84
|
--no-start Configure everything but do not start bridge
|
|
85
|
+
--engine <codex|opencode>
|
|
86
|
+
Set preferred engine before writing .env.secure
|
|
79
87
|
-h, --help Show this help
|
|
80
88
|
EOF
|
|
81
89
|
}
|
|
82
90
|
|
|
91
|
+
validate_engine_name() {
|
|
92
|
+
case "$1" in
|
|
93
|
+
codex|opencode)
|
|
94
|
+
return 0
|
|
95
|
+
;;
|
|
96
|
+
*)
|
|
97
|
+
return 1
|
|
98
|
+
;;
|
|
99
|
+
esac
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
format_engine_name() {
|
|
103
|
+
case "$1" in
|
|
104
|
+
opencode)
|
|
105
|
+
printf 'OpenCode'
|
|
106
|
+
;;
|
|
107
|
+
*)
|
|
108
|
+
printf 'Codex'
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
}
|
|
112
|
+
|
|
83
113
|
parse_args() {
|
|
84
114
|
while (($# > 0)); do
|
|
85
115
|
case "$1" in
|
|
@@ -87,6 +117,21 @@ parse_args() {
|
|
|
87
117
|
AUTO_START="false"
|
|
88
118
|
shift
|
|
89
119
|
;;
|
|
120
|
+
--engine)
|
|
121
|
+
if (($# < 2)); then
|
|
122
|
+
echo "error: --engine requires a value ('codex' or 'opencode')." >&2
|
|
123
|
+
print_usage >&2
|
|
124
|
+
exit 1
|
|
125
|
+
fi
|
|
126
|
+
if ! validate_engine_name "$2"; then
|
|
127
|
+
echo "error: unsupported engine '$2'. Use 'codex' or 'opencode'." >&2
|
|
128
|
+
print_usage >&2
|
|
129
|
+
exit 1
|
|
130
|
+
fi
|
|
131
|
+
ACTIVE_ENGINE="$2"
|
|
132
|
+
ENGINE_PRESET="true"
|
|
133
|
+
shift 2
|
|
134
|
+
;;
|
|
90
135
|
-h|--help)
|
|
91
136
|
print_usage
|
|
92
137
|
exit 0
|
|
@@ -628,6 +673,7 @@ print_existing_setup_summary() {
|
|
|
628
673
|
local port=""
|
|
629
674
|
local token=""
|
|
630
675
|
local network_mode=""
|
|
676
|
+
local engine=""
|
|
631
677
|
local source_path=""
|
|
632
678
|
|
|
633
679
|
if [[ ! -f "$SECURE_ENV_FILE" ]]; then
|
|
@@ -638,6 +684,10 @@ print_existing_setup_summary() {
|
|
|
638
684
|
port="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_PORT")"
|
|
639
685
|
token="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_AUTH_TOKEN")"
|
|
640
686
|
network_mode="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_NETWORK_MODE")"
|
|
687
|
+
engine="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_ACTIVE_ENGINE")"
|
|
688
|
+
if ! validate_engine_name "$engine"; then
|
|
689
|
+
engine="codex"
|
|
690
|
+
fi
|
|
641
691
|
|
|
642
692
|
if [[ -z "$host" ]] && [[ -z "$port" ]] && [[ -z "$token" ]]; then
|
|
643
693
|
return 1
|
|
@@ -653,6 +703,9 @@ print_existing_setup_summary() {
|
|
|
653
703
|
if [[ -n "$network_mode" ]]; then
|
|
654
704
|
echo "bridge.networkMode: $network_mode"
|
|
655
705
|
fi
|
|
706
|
+
if [[ -n "$engine" ]]; then
|
|
707
|
+
echo "bridge.engine: $engine"
|
|
708
|
+
fi
|
|
656
709
|
if [[ -n "$token" ]]; then
|
|
657
710
|
echo "bridge.token: present"
|
|
658
711
|
fi
|
|
@@ -735,6 +788,23 @@ choose_bridge_network_mode() {
|
|
|
735
788
|
esac
|
|
736
789
|
}
|
|
737
790
|
|
|
791
|
+
choose_runtime_engine() {
|
|
792
|
+
menu_select "Preferred engine" "Codex" "OpenCode"
|
|
793
|
+
case "$MENU_RESULT" in
|
|
794
|
+
"Codex")
|
|
795
|
+
ACTIVE_ENGINE="codex"
|
|
796
|
+
info "Codex selected."
|
|
797
|
+
;;
|
|
798
|
+
"OpenCode")
|
|
799
|
+
ACTIVE_ENGINE="opencode"
|
|
800
|
+
info "OpenCode selected."
|
|
801
|
+
;;
|
|
802
|
+
*)
|
|
803
|
+
abort_wizard "Unexpected preferred engine."
|
|
804
|
+
;;
|
|
805
|
+
esac
|
|
806
|
+
}
|
|
807
|
+
|
|
738
808
|
infer_network_mode_from_host() {
|
|
739
809
|
local host="$1"
|
|
740
810
|
host="$(printf '%s' "$host" | tr -d '[:space:]')"
|
|
@@ -801,9 +871,9 @@ ensure_codex_cli() {
|
|
|
801
871
|
fi
|
|
802
872
|
fi
|
|
803
873
|
|
|
804
|
-
if ! command -v codex >/dev/null 2>&1
|
|
874
|
+
if ! command -v codex >/dev/null 2>&1; then
|
|
805
875
|
if confirm_prompt "Open Codex docs in browser now?" "Y"; then
|
|
806
|
-
|
|
876
|
+
open_url "https://developers.openai.com/codex"
|
|
807
877
|
fi
|
|
808
878
|
fi
|
|
809
879
|
|
|
@@ -818,6 +888,48 @@ ensure_codex_cli() {
|
|
|
818
888
|
fi
|
|
819
889
|
}
|
|
820
890
|
|
|
891
|
+
ensure_opencode_cli() {
|
|
892
|
+
while ! command -v opencode >/dev/null 2>&1; do
|
|
893
|
+
warn "OpenCode CLI not found in PATH."
|
|
894
|
+
if confirm_prompt "Try installing OpenCode CLI via npm now?" "Y"; then
|
|
895
|
+
if npm install -g opencode-ai; then
|
|
896
|
+
hash -r
|
|
897
|
+
else
|
|
898
|
+
warn "Automatic install failed."
|
|
899
|
+
fi
|
|
900
|
+
fi
|
|
901
|
+
|
|
902
|
+
if ! command -v opencode >/dev/null 2>&1; then
|
|
903
|
+
if confirm_prompt "Open OpenCode docs in browser now?" "Y"; then
|
|
904
|
+
open_url "https://opencode.ai/docs/"
|
|
905
|
+
fi
|
|
906
|
+
fi
|
|
907
|
+
|
|
908
|
+
if ! command -v opencode >/dev/null 2>&1 && ! confirm_prompt "Retry OpenCode CLI check?" "Y"; then
|
|
909
|
+
abort_wizard "Install OpenCode CLI and rerun: clawdex init --engine opencode"
|
|
910
|
+
fi
|
|
911
|
+
done
|
|
912
|
+
|
|
913
|
+
ok "Found opencode: $(command -v opencode)"
|
|
914
|
+
if opencode --version >/dev/null 2>&1; then
|
|
915
|
+
info "opencode version: $(opencode --version 2>/dev/null | head -n1)"
|
|
916
|
+
fi
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
ensure_selected_engine_cli() {
|
|
920
|
+
case "$ACTIVE_ENGINE" in
|
|
921
|
+
codex)
|
|
922
|
+
ensure_codex_cli
|
|
923
|
+
;;
|
|
924
|
+
opencode)
|
|
925
|
+
ensure_opencode_cli
|
|
926
|
+
;;
|
|
927
|
+
*)
|
|
928
|
+
abort_wizard "Unsupported preferred engine '$ACTIVE_ENGINE'."
|
|
929
|
+
;;
|
|
930
|
+
esac
|
|
931
|
+
}
|
|
932
|
+
|
|
821
933
|
ensure_tailscale_cli() {
|
|
822
934
|
if command -v tailscale >/dev/null 2>&1; then
|
|
823
935
|
ok "Found tailscale: $(command -v tailscale)"
|
|
@@ -1188,7 +1300,6 @@ else
|
|
|
1188
1300
|
info "No packaged bridge binary found for this host. Falling back to local Rust build."
|
|
1189
1301
|
ensure_local_rust_build_toolchain
|
|
1190
1302
|
fi
|
|
1191
|
-
ensure_codex_cli
|
|
1192
1303
|
|
|
1193
1304
|
section "Config handling"
|
|
1194
1305
|
choose_config_action
|
|
@@ -1198,6 +1309,29 @@ if [[ "$CONFIG_ACTION" == "reset" ]]; then
|
|
|
1198
1309
|
ok "Previous secure config removed: $SECURE_ENV_FILE"
|
|
1199
1310
|
fi
|
|
1200
1311
|
|
|
1312
|
+
section "Preferred engine"
|
|
1313
|
+
EXISTING_ACTIVE_ENGINE="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_ACTIVE_ENGINE")"
|
|
1314
|
+
if ! validate_engine_name "$EXISTING_ACTIVE_ENGINE"; then
|
|
1315
|
+
EXISTING_ACTIVE_ENGINE="codex"
|
|
1316
|
+
fi
|
|
1317
|
+
if [[ "$CONFIG_ACTION" == "keep" ]]; then
|
|
1318
|
+
if [[ "$ENGINE_PRESET" == "false" ]]; then
|
|
1319
|
+
ACTIVE_ENGINE="$EXISTING_ACTIVE_ENGINE"
|
|
1320
|
+
info "Keeping existing preferred engine: $(format_engine_name "$ACTIVE_ENGINE")."
|
|
1321
|
+
else
|
|
1322
|
+
info "Preferred engine preset via flag: $(format_engine_name "$ACTIVE_ENGINE")."
|
|
1323
|
+
fi
|
|
1324
|
+
else
|
|
1325
|
+
if [[ "$ENGINE_PRESET" == "false" ]]; then
|
|
1326
|
+
choose_runtime_engine
|
|
1327
|
+
else
|
|
1328
|
+
info "Preferred engine preset via flag: $(format_engine_name "$ACTIVE_ENGINE")."
|
|
1329
|
+
fi
|
|
1330
|
+
fi
|
|
1331
|
+
|
|
1332
|
+
section "Runtime dependency"
|
|
1333
|
+
ensure_selected_engine_cli
|
|
1334
|
+
|
|
1201
1335
|
if [[ "$CONFIG_ACTION" != "keep" ]]; then
|
|
1202
1336
|
section "Bridge network mode"
|
|
1203
1337
|
choose_bridge_network_mode
|
|
@@ -1221,7 +1355,7 @@ if [[ "$CONFIG_ACTION" != "keep" ]]; then
|
|
|
1221
1355
|
esac
|
|
1222
1356
|
|
|
1223
1357
|
section "Write secure config"
|
|
1224
|
-
BRIDGE_NETWORK_MODE="$NETWORK_MODE" BRIDGE_HOST_OVERRIDE="$BRIDGE_HOST" "$SCRIPT_DIR/setup-secure-dev.sh"
|
|
1358
|
+
BRIDGE_NETWORK_MODE="$NETWORK_MODE" BRIDGE_HOST_OVERRIDE="$BRIDGE_HOST" BRIDGE_ACTIVE_ENGINE="$ACTIVE_ENGINE" "$SCRIPT_DIR/setup-secure-dev.sh"
|
|
1225
1359
|
else
|
|
1226
1360
|
ok "Keeping existing secure config."
|
|
1227
1361
|
NETWORK_MODE="$(extract_env_value "$SECURE_ENV_FILE" "BRIDGE_NETWORK_MODE")"
|
|
@@ -1246,7 +1380,10 @@ else
|
|
|
1246
1380
|
fi
|
|
1247
1381
|
|
|
1248
1382
|
section "Write secure config"
|
|
1249
|
-
BRIDGE_NETWORK_MODE="$NETWORK_MODE" BRIDGE_HOST_OVERRIDE="$BRIDGE_HOST" "$SCRIPT_DIR/setup-secure-dev.sh"
|
|
1383
|
+
BRIDGE_NETWORK_MODE="$NETWORK_MODE" BRIDGE_HOST_OVERRIDE="$BRIDGE_HOST" BRIDGE_ACTIVE_ENGINE="$ACTIVE_ENGINE" "$SCRIPT_DIR/setup-secure-dev.sh"
|
|
1384
|
+
elif [[ "$ACTIVE_ENGINE" != "$EXISTING_ACTIVE_ENGINE" ]]; then
|
|
1385
|
+
section "Write secure config"
|
|
1386
|
+
BRIDGE_NETWORK_MODE="$NETWORK_MODE" BRIDGE_HOST_OVERRIDE="$BRIDGE_HOST" BRIDGE_ACTIVE_ENGINE="$ACTIVE_ENGINE" "$SCRIPT_DIR/setup-secure-dev.sh"
|
|
1250
1387
|
fi
|
|
1251
1388
|
fi
|
|
1252
1389
|
|
|
@@ -1276,6 +1413,7 @@ BRIDGE_PORT="${BRIDGE_PORT:-8787}"
|
|
|
1276
1413
|
section "Summary"
|
|
1277
1414
|
rail_echo "Bridge mode: $NETWORK_MODE"
|
|
1278
1415
|
rail_echo "Bridge endpoint: http://$BRIDGE_HOST:$BRIDGE_PORT"
|
|
1416
|
+
rail_echo "Preferred engine: $(format_engine_name "$ACTIVE_ENGINE")"
|
|
1279
1417
|
rail_echo "Secure env: $SECURE_ENV_FILE"
|
|
1280
1418
|
if [[ "$FLOW" == "quickstart" ]]; then
|
|
1281
1419
|
rail_echo "${DIM}Tip: re-run with Manual mode for full control at each step.${RESET}"
|