openclacky 1.2.8 → 1.2.10
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/lib/clacky/agent/llm_caller.rb +3 -0
- data/lib/clacky/agent/message_compressor_helper.rb +6 -5
- data/lib/clacky/agent/session_serializer.rb +4 -0
- data/lib/clacky/agent.rb +9 -0
- data/lib/clacky/agent_config.rb +111 -8
- data/lib/clacky/brand_config.rb +1 -0
- data/lib/clacky/cli.rb +49 -22
- data/lib/clacky/client.rb +6 -2
- data/lib/clacky/default_skills/channel-manager/SKILL.md +33 -110
- data/lib/clacky/default_skills/media-gen/SKILL.md +128 -0
- data/lib/clacky/idle_compression_timer.rb +38 -15
- data/lib/clacky/media/base.rb +68 -0
- data/lib/clacky/media/gemini.rb +36 -0
- data/lib/clacky/media/generator.rb +78 -0
- data/lib/clacky/media/openai_compat.rb +168 -0
- data/lib/clacky/providers.rb +89 -2
- data/lib/clacky/rich_ui_controller.rb +1549 -0
- data/lib/clacky/server/channel/adapters/weixin/adapter.rb +24 -2
- data/lib/clacky/server/channel/channel_manager.rb +89 -2
- data/lib/clacky/server/http_server.rb +334 -29
- data/lib/clacky/session_manager.rb +9 -8
- data/lib/clacky/telemetry.rb +26 -6
- data/lib/clacky/ui2/layout_manager.rb +11 -7
- data/lib/clacky/ui2/ui_controller.rb +2 -2
- data/lib/clacky/ui_interface.rb +1 -1
- data/lib/clacky/utils/model_pricing.rb +75 -53
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +393 -14
- data/lib/clacky/web/billing.js +1 -1
- data/lib/clacky/web/i18n.js +86 -4
- data/lib/clacky/web/index.html +23 -3
- data/lib/clacky/web/model-tester.js +58 -0
- data/lib/clacky/web/onboard.js +17 -30
- data/lib/clacky/web/sessions.js +443 -2
- data/lib/clacky/web/settings.js +372 -97
- data/lib/clacky/web/workspace.js +9 -1
- data/lib/clacky.rb +3 -0
- data/scripts/build/lib/network.sh +61 -30
- data/scripts/install.ps1 +16 -4
- data/scripts/install.sh +61 -30
- data/scripts/install_browser.sh +61 -30
- data/scripts/install_full.sh +61 -30
- data/scripts/install_rails_deps.sh +61 -30
- data/scripts/install_system_deps.sh +61 -30
- metadata +12 -3
- data/lib/clacky/default_skills/channel-manager/feishu_setup.rb +0 -574
|
@@ -17,12 +17,15 @@ DEFAULT_NPM_REGISTRY="https://registry.npmjs.org"
|
|
|
17
17
|
DEFAULT_MISE_INSTALL_URL="https://mise.run"
|
|
18
18
|
|
|
19
19
|
CN_CDN_BASE_URL="https://oss.1024code.com"
|
|
20
|
+
CN_CDN_FALLBACK_URL="https://clackyai-1258723534.cos.ap-guangzhou.myqcloud.com"
|
|
20
21
|
CN_ALIYUN_MIRROR="https://mirrors.aliyun.com"
|
|
21
|
-
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
22
|
-
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
23
22
|
CN_RUBYGEMS_URL="${CN_ALIYUN_MIRROR}/rubygems/"
|
|
24
23
|
CN_NPM_REGISTRY="https://registry.npmmirror.com"
|
|
25
24
|
CN_NODE_MIRROR_URL="https://cdn.npmmirror.com/binaries/node/"
|
|
25
|
+
|
|
26
|
+
# Derived from CN_CDN_BASE_URL — always set via _apply_cdn_base_url()
|
|
27
|
+
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
28
|
+
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
26
29
|
CN_GEM_BASE_URL="${CN_CDN_BASE_URL}/openclacky"
|
|
27
30
|
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
28
31
|
|
|
@@ -85,6 +88,37 @@ _probe_url_with_retry() {
|
|
|
85
88
|
echo "$result"
|
|
86
89
|
}
|
|
87
90
|
|
|
91
|
+
# --------------------------------------------------------------------------
|
|
92
|
+
# CN CDN resolution helpers
|
|
93
|
+
# --------------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
# Probe primary CDN then fallback; echoes the reachable base URL or exits 1
|
|
96
|
+
_resolve_cdn_base_url() {
|
|
97
|
+
local result
|
|
98
|
+
result=$(_probe_url_with_retry "$CN_CDN_BASE_URL")
|
|
99
|
+
_print_probe_result "CN CDN (oss.1024code.com)" "$result"
|
|
100
|
+
! _is_slow_or_unreachable "$result" && return 0
|
|
101
|
+
|
|
102
|
+
print_warning "CN CDN unreachable — trying fallback..."
|
|
103
|
+
result=$(_probe_url_with_retry "$CN_CDN_FALLBACK_URL")
|
|
104
|
+
_print_probe_result "CN CDN fallback" "$result"
|
|
105
|
+
if _is_slow_or_unreachable "$result"; then
|
|
106
|
+
print_error "CN CDN and fallback both unreachable — cannot install."
|
|
107
|
+
exit 2
|
|
108
|
+
fi
|
|
109
|
+
CN_CDN_BASE_URL="$CN_CDN_FALLBACK_URL"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Apply a resolved base URL to all CDN-derived variables
|
|
113
|
+
_apply_cdn_base_url() {
|
|
114
|
+
local base="$1"
|
|
115
|
+
CN_CDN_BASE_URL="$base"
|
|
116
|
+
CN_MISE_INSTALL_URL="${base}/mise.sh"
|
|
117
|
+
CN_RUBY_PRECOMPILED_URL="${base}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
118
|
+
CN_GEM_BASE_URL="${base}/openclacky"
|
|
119
|
+
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
120
|
+
}
|
|
121
|
+
|
|
88
122
|
# --------------------------------------------------------------------------
|
|
89
123
|
# detect_network_region — sets USE_CN_MIRRORS and active mirror variables
|
|
90
124
|
# --------------------------------------------------------------------------
|
|
@@ -92,42 +126,48 @@ detect_network_region() {
|
|
|
92
126
|
print_step "Network pre-flight check..."
|
|
93
127
|
echo ""
|
|
94
128
|
|
|
95
|
-
local
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
local probe_google="https://www.google.com"
|
|
130
|
+
local probe_github="https://raw.githubusercontent.com"
|
|
131
|
+
local probe_baidu="https://www.baidu.com"
|
|
98
132
|
|
|
99
|
-
|
|
100
|
-
|
|
133
|
+
local google_result github_result baidu_result
|
|
134
|
+
google_result=$(_probe_url "$probe_google")
|
|
135
|
+
github_result=$(_probe_url "$probe_github")
|
|
136
|
+
baidu_result=$(_probe_url "$probe_baidu")
|
|
101
137
|
|
|
102
|
-
|
|
138
|
+
_print_probe_result "google.com" "$google_result"
|
|
139
|
+
_print_probe_result "raw.githubusercontent.com" "$github_result"
|
|
140
|
+
_print_probe_result "baidu.com" "$baidu_result"
|
|
141
|
+
|
|
142
|
+
local google_ok=false github_ok=false baidu_ok=false
|
|
103
143
|
! _is_slow_or_unreachable "$google_result" && google_ok=true
|
|
144
|
+
! _is_slow_or_unreachable "$github_result" && github_ok=true
|
|
104
145
|
! _is_slow_or_unreachable "$baidu_result" && baidu_ok=true
|
|
105
146
|
|
|
106
|
-
if [ "$google_ok" = true ]; then
|
|
147
|
+
if [ "$google_ok" = true ] && [ "$github_ok" = true ]; then
|
|
107
148
|
NETWORK_REGION="global"
|
|
108
149
|
print_success "Region: global"
|
|
109
150
|
elif [ "$baidu_ok" = true ]; then
|
|
110
151
|
NETWORK_REGION="china"
|
|
111
152
|
print_success "Region: china"
|
|
112
153
|
else
|
|
113
|
-
|
|
114
|
-
|
|
154
|
+
print_error "Region: unknown (all unreachable) — cannot install."
|
|
155
|
+
exit 2
|
|
115
156
|
fi
|
|
116
157
|
echo ""
|
|
117
158
|
|
|
118
159
|
if [ "$NETWORK_REGION" = "china" ]; then
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
mirror_result=$(_probe_url_with_retry "$CN_RUBYGEMS_URL")
|
|
160
|
+
_resolve_cdn_base_url
|
|
161
|
+
_apply_cdn_base_url "$CN_CDN_BASE_URL"
|
|
122
162
|
|
|
123
|
-
|
|
124
|
-
|
|
163
|
+
local mirror_result
|
|
164
|
+
mirror_result=$(_probe_url_with_retry "$CN_ALIYUN_MIRROR")
|
|
165
|
+
_print_probe_result "Aliyun mirror" "$mirror_result"
|
|
125
166
|
|
|
126
|
-
local
|
|
127
|
-
! _is_slow_or_unreachable "$cdn_result" && cdn_ok=true
|
|
167
|
+
local mirror_ok=false
|
|
128
168
|
! _is_slow_or_unreachable "$mirror_result" && mirror_ok=true
|
|
129
169
|
|
|
130
|
-
if [ "$
|
|
170
|
+
if [ "$mirror_ok" = true ]; then
|
|
131
171
|
USE_CN_MIRRORS=true
|
|
132
172
|
MISE_INSTALL_URL="$CN_MISE_INSTALL_URL"
|
|
133
173
|
RUBYGEMS_INSTALL_URL="$CN_RUBYGEMS_URL"
|
|
@@ -136,19 +176,10 @@ detect_network_region() {
|
|
|
136
176
|
RUBY_VERSION_SPEC="ruby@3.4.8"
|
|
137
177
|
print_info "CN mirrors applied"
|
|
138
178
|
else
|
|
139
|
-
|
|
179
|
+
print_error "CN mirrors unreachable — cannot install."
|
|
180
|
+
exit 2
|
|
140
181
|
fi
|
|
141
182
|
else
|
|
142
|
-
local rubygems_result mise_result
|
|
143
|
-
rubygems_result=$(_probe_url_with_retry "$DEFAULT_RUBYGEMS_URL")
|
|
144
|
-
mise_result=$(_probe_url_with_retry "$DEFAULT_MISE_INSTALL_URL")
|
|
145
|
-
|
|
146
|
-
_print_probe_result "RubyGems" "$rubygems_result"
|
|
147
|
-
_print_probe_result "mise.run" "$mise_result"
|
|
148
|
-
|
|
149
|
-
_is_slow_or_unreachable "$rubygems_result" && print_warning "RubyGems is slow/unreachable."
|
|
150
|
-
_is_slow_or_unreachable "$mise_result" && print_warning "mise.run is slow/unreachable."
|
|
151
|
-
|
|
152
183
|
USE_CN_MIRRORS=false
|
|
153
184
|
RUBY_VERSION_SPEC="ruby@3"
|
|
154
185
|
fi
|
data/scripts/install.ps1
CHANGED
|
@@ -203,14 +203,14 @@ function Get-UbuntuRootfs {
|
|
|
203
203
|
$tarPath = "$safeTemp\ubuntu-wsl-$cpuArch.tar.gz"
|
|
204
204
|
$installDir = $UBUNTU_WSL_DIR
|
|
205
205
|
|
|
206
|
-
# Disk space check (~
|
|
206
|
+
# Disk space check (~4 GB needed: 350 MB download + ~1.5 GB imported + buffer)
|
|
207
207
|
$drive = Split-Path -Qualifier $installDir
|
|
208
208
|
$freeBytes = (Get-PSDrive ($drive.TrimEnd(':'))).Free
|
|
209
|
-
if ($freeBytes -lt
|
|
209
|
+
if ($freeBytes -lt 4GB) {
|
|
210
210
|
Write-Fail "Not enough disk space on $drive."
|
|
211
211
|
Write-Fail " Available : $([math]::Round($freeBytes / 1GB, 1)) GB"
|
|
212
|
-
Write-Fail " Required : ~
|
|
213
|
-
exit
|
|
212
|
+
Write-Fail " Required : ~4 GB"
|
|
213
|
+
exit 3
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
# Check if a valid cached tarball exists (skip download if checksum passes)
|
|
@@ -272,6 +272,17 @@ function Install-UbuntuRootfs {
|
|
|
272
272
|
Write-Success "Ubuntu (WSL$WslVersion) imported successfully."
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
function Test-WslNetwork {
|
|
276
|
+
Write-Info "Checking WSL network connectivity..."
|
|
277
|
+
wsl.exe -d Ubuntu -u root -- bash -c "curl -fsSL --max-time 3 --retry 1 $INSTALL_SCRIPT_URL -o /dev/null 2>/dev/null" | Out-Null
|
|
278
|
+
if ($LASTEXITCODE -ne 0) {
|
|
279
|
+
Write-Fail "WSL cannot reach $CLACKY_CDN_PRIMARY_HOST (curl exit $LASTEXITCODE)."
|
|
280
|
+
Write-Fail "Please fix the network inside WSL and re-run this installer."
|
|
281
|
+
exit 2
|
|
282
|
+
}
|
|
283
|
+
Write-Success "WSL network OK."
|
|
284
|
+
}
|
|
285
|
+
|
|
275
286
|
# Install OpenClacky inside the Ubuntu WSL distro.
|
|
276
287
|
function Run-InstallInWsl {
|
|
277
288
|
Write-Step "Installing $DisplayName inside WSL..."
|
|
@@ -288,6 +299,7 @@ function Run-InstallInWsl {
|
|
|
288
299
|
Write-Info "Local mode: using $wslPath"
|
|
289
300
|
wsl.exe -d Ubuntu -u root -- bash $wslPath --brand-name=$BrandName --command=$CommandName
|
|
290
301
|
} else {
|
|
302
|
+
Test-WslNetwork
|
|
291
303
|
wsl.exe -d Ubuntu -u root -- bash -c "cd ~ && curl -fsSL $INSTALL_SCRIPT_URL | bash -s -- --brand-name=$BrandName --command=$CommandName"
|
|
292
304
|
}
|
|
293
305
|
|
data/scripts/install.sh
CHANGED
|
@@ -129,12 +129,15 @@ DEFAULT_NPM_REGISTRY="https://registry.npmjs.org"
|
|
|
129
129
|
DEFAULT_MISE_INSTALL_URL="https://mise.run"
|
|
130
130
|
|
|
131
131
|
CN_CDN_BASE_URL="https://oss.1024code.com"
|
|
132
|
+
CN_CDN_FALLBACK_URL="https://clackyai-1258723534.cos.ap-guangzhou.myqcloud.com"
|
|
132
133
|
CN_ALIYUN_MIRROR="https://mirrors.aliyun.com"
|
|
133
|
-
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
134
|
-
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
135
134
|
CN_RUBYGEMS_URL="${CN_ALIYUN_MIRROR}/rubygems/"
|
|
136
135
|
CN_NPM_REGISTRY="https://registry.npmmirror.com"
|
|
137
136
|
CN_NODE_MIRROR_URL="https://cdn.npmmirror.com/binaries/node/"
|
|
137
|
+
|
|
138
|
+
# Derived from CN_CDN_BASE_URL — always set via _apply_cdn_base_url()
|
|
139
|
+
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
140
|
+
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
138
141
|
CN_GEM_BASE_URL="${CN_CDN_BASE_URL}/openclacky"
|
|
139
142
|
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
140
143
|
|
|
@@ -197,6 +200,37 @@ _probe_url_with_retry() {
|
|
|
197
200
|
echo "$result"
|
|
198
201
|
}
|
|
199
202
|
|
|
203
|
+
# --------------------------------------------------------------------------
|
|
204
|
+
# CN CDN resolution helpers
|
|
205
|
+
# --------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
# Probe primary CDN then fallback; echoes the reachable base URL or exits 1
|
|
208
|
+
_resolve_cdn_base_url() {
|
|
209
|
+
local result
|
|
210
|
+
result=$(_probe_url_with_retry "$CN_CDN_BASE_URL")
|
|
211
|
+
_print_probe_result "CN CDN (oss.1024code.com)" "$result"
|
|
212
|
+
! _is_slow_or_unreachable "$result" && return 0
|
|
213
|
+
|
|
214
|
+
print_warning "CN CDN unreachable — trying fallback..."
|
|
215
|
+
result=$(_probe_url_with_retry "$CN_CDN_FALLBACK_URL")
|
|
216
|
+
_print_probe_result "CN CDN fallback" "$result"
|
|
217
|
+
if _is_slow_or_unreachable "$result"; then
|
|
218
|
+
print_error "CN CDN and fallback both unreachable — cannot install."
|
|
219
|
+
exit 2
|
|
220
|
+
fi
|
|
221
|
+
CN_CDN_BASE_URL="$CN_CDN_FALLBACK_URL"
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Apply a resolved base URL to all CDN-derived variables
|
|
225
|
+
_apply_cdn_base_url() {
|
|
226
|
+
local base="$1"
|
|
227
|
+
CN_CDN_BASE_URL="$base"
|
|
228
|
+
CN_MISE_INSTALL_URL="${base}/mise.sh"
|
|
229
|
+
CN_RUBY_PRECOMPILED_URL="${base}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
230
|
+
CN_GEM_BASE_URL="${base}/openclacky"
|
|
231
|
+
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
232
|
+
}
|
|
233
|
+
|
|
200
234
|
# --------------------------------------------------------------------------
|
|
201
235
|
# detect_network_region — sets USE_CN_MIRRORS and active mirror variables
|
|
202
236
|
# --------------------------------------------------------------------------
|
|
@@ -204,42 +238,48 @@ detect_network_region() {
|
|
|
204
238
|
print_step "Network pre-flight check..."
|
|
205
239
|
echo ""
|
|
206
240
|
|
|
207
|
-
local
|
|
208
|
-
|
|
209
|
-
|
|
241
|
+
local probe_google="https://www.google.com"
|
|
242
|
+
local probe_github="https://raw.githubusercontent.com"
|
|
243
|
+
local probe_baidu="https://www.baidu.com"
|
|
210
244
|
|
|
211
|
-
|
|
212
|
-
|
|
245
|
+
local google_result github_result baidu_result
|
|
246
|
+
google_result=$(_probe_url "$probe_google")
|
|
247
|
+
github_result=$(_probe_url "$probe_github")
|
|
248
|
+
baidu_result=$(_probe_url "$probe_baidu")
|
|
213
249
|
|
|
214
|
-
|
|
250
|
+
_print_probe_result "google.com" "$google_result"
|
|
251
|
+
_print_probe_result "raw.githubusercontent.com" "$github_result"
|
|
252
|
+
_print_probe_result "baidu.com" "$baidu_result"
|
|
253
|
+
|
|
254
|
+
local google_ok=false github_ok=false baidu_ok=false
|
|
215
255
|
! _is_slow_or_unreachable "$google_result" && google_ok=true
|
|
256
|
+
! _is_slow_or_unreachable "$github_result" && github_ok=true
|
|
216
257
|
! _is_slow_or_unreachable "$baidu_result" && baidu_ok=true
|
|
217
258
|
|
|
218
|
-
if [ "$google_ok" = true ]; then
|
|
259
|
+
if [ "$google_ok" = true ] && [ "$github_ok" = true ]; then
|
|
219
260
|
NETWORK_REGION="global"
|
|
220
261
|
print_success "Region: global"
|
|
221
262
|
elif [ "$baidu_ok" = true ]; then
|
|
222
263
|
NETWORK_REGION="china"
|
|
223
264
|
print_success "Region: china"
|
|
224
265
|
else
|
|
225
|
-
|
|
226
|
-
|
|
266
|
+
print_error "Region: unknown (all unreachable) — cannot install."
|
|
267
|
+
exit 2
|
|
227
268
|
fi
|
|
228
269
|
echo ""
|
|
229
270
|
|
|
230
271
|
if [ "$NETWORK_REGION" = "china" ]; then
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
mirror_result=$(_probe_url_with_retry "$CN_RUBYGEMS_URL")
|
|
272
|
+
_resolve_cdn_base_url
|
|
273
|
+
_apply_cdn_base_url "$CN_CDN_BASE_URL"
|
|
234
274
|
|
|
235
|
-
|
|
236
|
-
|
|
275
|
+
local mirror_result
|
|
276
|
+
mirror_result=$(_probe_url_with_retry "$CN_ALIYUN_MIRROR")
|
|
277
|
+
_print_probe_result "Aliyun mirror" "$mirror_result"
|
|
237
278
|
|
|
238
|
-
local
|
|
239
|
-
! _is_slow_or_unreachable "$cdn_result" && cdn_ok=true
|
|
279
|
+
local mirror_ok=false
|
|
240
280
|
! _is_slow_or_unreachable "$mirror_result" && mirror_ok=true
|
|
241
281
|
|
|
242
|
-
if [ "$
|
|
282
|
+
if [ "$mirror_ok" = true ]; then
|
|
243
283
|
USE_CN_MIRRORS=true
|
|
244
284
|
MISE_INSTALL_URL="$CN_MISE_INSTALL_URL"
|
|
245
285
|
RUBYGEMS_INSTALL_URL="$CN_RUBYGEMS_URL"
|
|
@@ -248,19 +288,10 @@ detect_network_region() {
|
|
|
248
288
|
RUBY_VERSION_SPEC="ruby@3.4.8"
|
|
249
289
|
print_info "CN mirrors applied"
|
|
250
290
|
else
|
|
251
|
-
|
|
291
|
+
print_error "CN mirrors unreachable — cannot install."
|
|
292
|
+
exit 2
|
|
252
293
|
fi
|
|
253
294
|
else
|
|
254
|
-
local rubygems_result mise_result
|
|
255
|
-
rubygems_result=$(_probe_url_with_retry "$DEFAULT_RUBYGEMS_URL")
|
|
256
|
-
mise_result=$(_probe_url_with_retry "$DEFAULT_MISE_INSTALL_URL")
|
|
257
|
-
|
|
258
|
-
_print_probe_result "RubyGems" "$rubygems_result"
|
|
259
|
-
_print_probe_result "mise.run" "$mise_result"
|
|
260
|
-
|
|
261
|
-
_is_slow_or_unreachable "$rubygems_result" && print_warning "RubyGems is slow/unreachable."
|
|
262
|
-
_is_slow_or_unreachable "$mise_result" && print_warning "mise.run is slow/unreachable."
|
|
263
|
-
|
|
264
295
|
USE_CN_MIRRORS=false
|
|
265
296
|
RUBY_VERSION_SPEC="ruby@3"
|
|
266
297
|
fi
|
data/scripts/install_browser.sh
CHANGED
|
@@ -125,12 +125,15 @@ DEFAULT_NPM_REGISTRY="https://registry.npmjs.org"
|
|
|
125
125
|
DEFAULT_MISE_INSTALL_URL="https://mise.run"
|
|
126
126
|
|
|
127
127
|
CN_CDN_BASE_URL="https://oss.1024code.com"
|
|
128
|
+
CN_CDN_FALLBACK_URL="https://clackyai-1258723534.cos.ap-guangzhou.myqcloud.com"
|
|
128
129
|
CN_ALIYUN_MIRROR="https://mirrors.aliyun.com"
|
|
129
|
-
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
130
|
-
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
131
130
|
CN_RUBYGEMS_URL="${CN_ALIYUN_MIRROR}/rubygems/"
|
|
132
131
|
CN_NPM_REGISTRY="https://registry.npmmirror.com"
|
|
133
132
|
CN_NODE_MIRROR_URL="https://cdn.npmmirror.com/binaries/node/"
|
|
133
|
+
|
|
134
|
+
# Derived from CN_CDN_BASE_URL — always set via _apply_cdn_base_url()
|
|
135
|
+
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
136
|
+
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
134
137
|
CN_GEM_BASE_URL="${CN_CDN_BASE_URL}/openclacky"
|
|
135
138
|
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
136
139
|
|
|
@@ -193,6 +196,37 @@ _probe_url_with_retry() {
|
|
|
193
196
|
echo "$result"
|
|
194
197
|
}
|
|
195
198
|
|
|
199
|
+
# --------------------------------------------------------------------------
|
|
200
|
+
# CN CDN resolution helpers
|
|
201
|
+
# --------------------------------------------------------------------------
|
|
202
|
+
|
|
203
|
+
# Probe primary CDN then fallback; echoes the reachable base URL or exits 1
|
|
204
|
+
_resolve_cdn_base_url() {
|
|
205
|
+
local result
|
|
206
|
+
result=$(_probe_url_with_retry "$CN_CDN_BASE_URL")
|
|
207
|
+
_print_probe_result "CN CDN (oss.1024code.com)" "$result"
|
|
208
|
+
! _is_slow_or_unreachable "$result" && return 0
|
|
209
|
+
|
|
210
|
+
print_warning "CN CDN unreachable — trying fallback..."
|
|
211
|
+
result=$(_probe_url_with_retry "$CN_CDN_FALLBACK_URL")
|
|
212
|
+
_print_probe_result "CN CDN fallback" "$result"
|
|
213
|
+
if _is_slow_or_unreachable "$result"; then
|
|
214
|
+
print_error "CN CDN and fallback both unreachable — cannot install."
|
|
215
|
+
exit 2
|
|
216
|
+
fi
|
|
217
|
+
CN_CDN_BASE_URL="$CN_CDN_FALLBACK_URL"
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
# Apply a resolved base URL to all CDN-derived variables
|
|
221
|
+
_apply_cdn_base_url() {
|
|
222
|
+
local base="$1"
|
|
223
|
+
CN_CDN_BASE_URL="$base"
|
|
224
|
+
CN_MISE_INSTALL_URL="${base}/mise.sh"
|
|
225
|
+
CN_RUBY_PRECOMPILED_URL="${base}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
226
|
+
CN_GEM_BASE_URL="${base}/openclacky"
|
|
227
|
+
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
228
|
+
}
|
|
229
|
+
|
|
196
230
|
# --------------------------------------------------------------------------
|
|
197
231
|
# detect_network_region — sets USE_CN_MIRRORS and active mirror variables
|
|
198
232
|
# --------------------------------------------------------------------------
|
|
@@ -200,42 +234,48 @@ detect_network_region() {
|
|
|
200
234
|
print_step "Network pre-flight check..."
|
|
201
235
|
echo ""
|
|
202
236
|
|
|
203
|
-
local
|
|
204
|
-
|
|
205
|
-
|
|
237
|
+
local probe_google="https://www.google.com"
|
|
238
|
+
local probe_github="https://raw.githubusercontent.com"
|
|
239
|
+
local probe_baidu="https://www.baidu.com"
|
|
206
240
|
|
|
207
|
-
|
|
208
|
-
|
|
241
|
+
local google_result github_result baidu_result
|
|
242
|
+
google_result=$(_probe_url "$probe_google")
|
|
243
|
+
github_result=$(_probe_url "$probe_github")
|
|
244
|
+
baidu_result=$(_probe_url "$probe_baidu")
|
|
209
245
|
|
|
210
|
-
|
|
246
|
+
_print_probe_result "google.com" "$google_result"
|
|
247
|
+
_print_probe_result "raw.githubusercontent.com" "$github_result"
|
|
248
|
+
_print_probe_result "baidu.com" "$baidu_result"
|
|
249
|
+
|
|
250
|
+
local google_ok=false github_ok=false baidu_ok=false
|
|
211
251
|
! _is_slow_or_unreachable "$google_result" && google_ok=true
|
|
252
|
+
! _is_slow_or_unreachable "$github_result" && github_ok=true
|
|
212
253
|
! _is_slow_or_unreachable "$baidu_result" && baidu_ok=true
|
|
213
254
|
|
|
214
|
-
if [ "$google_ok" = true ]; then
|
|
255
|
+
if [ "$google_ok" = true ] && [ "$github_ok" = true ]; then
|
|
215
256
|
NETWORK_REGION="global"
|
|
216
257
|
print_success "Region: global"
|
|
217
258
|
elif [ "$baidu_ok" = true ]; then
|
|
218
259
|
NETWORK_REGION="china"
|
|
219
260
|
print_success "Region: china"
|
|
220
261
|
else
|
|
221
|
-
|
|
222
|
-
|
|
262
|
+
print_error "Region: unknown (all unreachable) — cannot install."
|
|
263
|
+
exit 2
|
|
223
264
|
fi
|
|
224
265
|
echo ""
|
|
225
266
|
|
|
226
267
|
if [ "$NETWORK_REGION" = "china" ]; then
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
mirror_result=$(_probe_url_with_retry "$CN_RUBYGEMS_URL")
|
|
268
|
+
_resolve_cdn_base_url
|
|
269
|
+
_apply_cdn_base_url "$CN_CDN_BASE_URL"
|
|
230
270
|
|
|
231
|
-
|
|
232
|
-
|
|
271
|
+
local mirror_result
|
|
272
|
+
mirror_result=$(_probe_url_with_retry "$CN_ALIYUN_MIRROR")
|
|
273
|
+
_print_probe_result "Aliyun mirror" "$mirror_result"
|
|
233
274
|
|
|
234
|
-
local
|
|
235
|
-
! _is_slow_or_unreachable "$cdn_result" && cdn_ok=true
|
|
275
|
+
local mirror_ok=false
|
|
236
276
|
! _is_slow_or_unreachable "$mirror_result" && mirror_ok=true
|
|
237
277
|
|
|
238
|
-
if [ "$
|
|
278
|
+
if [ "$mirror_ok" = true ]; then
|
|
239
279
|
USE_CN_MIRRORS=true
|
|
240
280
|
MISE_INSTALL_URL="$CN_MISE_INSTALL_URL"
|
|
241
281
|
RUBYGEMS_INSTALL_URL="$CN_RUBYGEMS_URL"
|
|
@@ -244,19 +284,10 @@ detect_network_region() {
|
|
|
244
284
|
RUBY_VERSION_SPEC="ruby@3.4.8"
|
|
245
285
|
print_info "CN mirrors applied"
|
|
246
286
|
else
|
|
247
|
-
|
|
287
|
+
print_error "CN mirrors unreachable — cannot install."
|
|
288
|
+
exit 2
|
|
248
289
|
fi
|
|
249
290
|
else
|
|
250
|
-
local rubygems_result mise_result
|
|
251
|
-
rubygems_result=$(_probe_url_with_retry "$DEFAULT_RUBYGEMS_URL")
|
|
252
|
-
mise_result=$(_probe_url_with_retry "$DEFAULT_MISE_INSTALL_URL")
|
|
253
|
-
|
|
254
|
-
_print_probe_result "RubyGems" "$rubygems_result"
|
|
255
|
-
_print_probe_result "mise.run" "$mise_result"
|
|
256
|
-
|
|
257
|
-
_is_slow_or_unreachable "$rubygems_result" && print_warning "RubyGems is slow/unreachable."
|
|
258
|
-
_is_slow_or_unreachable "$mise_result" && print_warning "mise.run is slow/unreachable."
|
|
259
|
-
|
|
260
291
|
USE_CN_MIRRORS=false
|
|
261
292
|
RUBY_VERSION_SPEC="ruby@3"
|
|
262
293
|
fi
|
data/scripts/install_full.sh
CHANGED
|
@@ -129,12 +129,15 @@ DEFAULT_NPM_REGISTRY="https://registry.npmjs.org"
|
|
|
129
129
|
DEFAULT_MISE_INSTALL_URL="https://mise.run"
|
|
130
130
|
|
|
131
131
|
CN_CDN_BASE_URL="https://oss.1024code.com"
|
|
132
|
+
CN_CDN_FALLBACK_URL="https://clackyai-1258723534.cos.ap-guangzhou.myqcloud.com"
|
|
132
133
|
CN_ALIYUN_MIRROR="https://mirrors.aliyun.com"
|
|
133
|
-
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
134
|
-
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
135
134
|
CN_RUBYGEMS_URL="${CN_ALIYUN_MIRROR}/rubygems/"
|
|
136
135
|
CN_NPM_REGISTRY="https://registry.npmmirror.com"
|
|
137
136
|
CN_NODE_MIRROR_URL="https://cdn.npmmirror.com/binaries/node/"
|
|
137
|
+
|
|
138
|
+
# Derived from CN_CDN_BASE_URL — always set via _apply_cdn_base_url()
|
|
139
|
+
CN_MISE_INSTALL_URL="${CN_CDN_BASE_URL}/mise.sh"
|
|
140
|
+
CN_RUBY_PRECOMPILED_URL="${CN_CDN_BASE_URL}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
138
141
|
CN_GEM_BASE_URL="${CN_CDN_BASE_URL}/openclacky"
|
|
139
142
|
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
140
143
|
|
|
@@ -197,6 +200,37 @@ _probe_url_with_retry() {
|
|
|
197
200
|
echo "$result"
|
|
198
201
|
}
|
|
199
202
|
|
|
203
|
+
# --------------------------------------------------------------------------
|
|
204
|
+
# CN CDN resolution helpers
|
|
205
|
+
# --------------------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
# Probe primary CDN then fallback; echoes the reachable base URL or exits 1
|
|
208
|
+
_resolve_cdn_base_url() {
|
|
209
|
+
local result
|
|
210
|
+
result=$(_probe_url_with_retry "$CN_CDN_BASE_URL")
|
|
211
|
+
_print_probe_result "CN CDN (oss.1024code.com)" "$result"
|
|
212
|
+
! _is_slow_or_unreachable "$result" && return 0
|
|
213
|
+
|
|
214
|
+
print_warning "CN CDN unreachable — trying fallback..."
|
|
215
|
+
result=$(_probe_url_with_retry "$CN_CDN_FALLBACK_URL")
|
|
216
|
+
_print_probe_result "CN CDN fallback" "$result"
|
|
217
|
+
if _is_slow_or_unreachable "$result"; then
|
|
218
|
+
print_error "CN CDN and fallback both unreachable — cannot install."
|
|
219
|
+
exit 2
|
|
220
|
+
fi
|
|
221
|
+
CN_CDN_BASE_URL="$CN_CDN_FALLBACK_URL"
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Apply a resolved base URL to all CDN-derived variables
|
|
225
|
+
_apply_cdn_base_url() {
|
|
226
|
+
local base="$1"
|
|
227
|
+
CN_CDN_BASE_URL="$base"
|
|
228
|
+
CN_MISE_INSTALL_URL="${base}/mise.sh"
|
|
229
|
+
CN_RUBY_PRECOMPILED_URL="${base}/ruby/ruby-{version}.{platform}.tar.gz"
|
|
230
|
+
CN_GEM_BASE_URL="${base}/openclacky"
|
|
231
|
+
CN_GEM_LATEST_URL="${CN_GEM_BASE_URL}/latest.txt"
|
|
232
|
+
}
|
|
233
|
+
|
|
200
234
|
# --------------------------------------------------------------------------
|
|
201
235
|
# detect_network_region — sets USE_CN_MIRRORS and active mirror variables
|
|
202
236
|
# --------------------------------------------------------------------------
|
|
@@ -204,42 +238,48 @@ detect_network_region() {
|
|
|
204
238
|
print_step "Network pre-flight check..."
|
|
205
239
|
echo ""
|
|
206
240
|
|
|
207
|
-
local
|
|
208
|
-
|
|
209
|
-
|
|
241
|
+
local probe_google="https://www.google.com"
|
|
242
|
+
local probe_github="https://raw.githubusercontent.com"
|
|
243
|
+
local probe_baidu="https://www.baidu.com"
|
|
210
244
|
|
|
211
|
-
|
|
212
|
-
|
|
245
|
+
local google_result github_result baidu_result
|
|
246
|
+
google_result=$(_probe_url "$probe_google")
|
|
247
|
+
github_result=$(_probe_url "$probe_github")
|
|
248
|
+
baidu_result=$(_probe_url "$probe_baidu")
|
|
213
249
|
|
|
214
|
-
|
|
250
|
+
_print_probe_result "google.com" "$google_result"
|
|
251
|
+
_print_probe_result "raw.githubusercontent.com" "$github_result"
|
|
252
|
+
_print_probe_result "baidu.com" "$baidu_result"
|
|
253
|
+
|
|
254
|
+
local google_ok=false github_ok=false baidu_ok=false
|
|
215
255
|
! _is_slow_or_unreachable "$google_result" && google_ok=true
|
|
256
|
+
! _is_slow_or_unreachable "$github_result" && github_ok=true
|
|
216
257
|
! _is_slow_or_unreachable "$baidu_result" && baidu_ok=true
|
|
217
258
|
|
|
218
|
-
if [ "$google_ok" = true ]; then
|
|
259
|
+
if [ "$google_ok" = true ] && [ "$github_ok" = true ]; then
|
|
219
260
|
NETWORK_REGION="global"
|
|
220
261
|
print_success "Region: global"
|
|
221
262
|
elif [ "$baidu_ok" = true ]; then
|
|
222
263
|
NETWORK_REGION="china"
|
|
223
264
|
print_success "Region: china"
|
|
224
265
|
else
|
|
225
|
-
|
|
226
|
-
|
|
266
|
+
print_error "Region: unknown (all unreachable) — cannot install."
|
|
267
|
+
exit 2
|
|
227
268
|
fi
|
|
228
269
|
echo ""
|
|
229
270
|
|
|
230
271
|
if [ "$NETWORK_REGION" = "china" ]; then
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
mirror_result=$(_probe_url_with_retry "$CN_RUBYGEMS_URL")
|
|
272
|
+
_resolve_cdn_base_url
|
|
273
|
+
_apply_cdn_base_url "$CN_CDN_BASE_URL"
|
|
234
274
|
|
|
235
|
-
|
|
236
|
-
|
|
275
|
+
local mirror_result
|
|
276
|
+
mirror_result=$(_probe_url_with_retry "$CN_ALIYUN_MIRROR")
|
|
277
|
+
_print_probe_result "Aliyun mirror" "$mirror_result"
|
|
237
278
|
|
|
238
|
-
local
|
|
239
|
-
! _is_slow_or_unreachable "$cdn_result" && cdn_ok=true
|
|
279
|
+
local mirror_ok=false
|
|
240
280
|
! _is_slow_or_unreachable "$mirror_result" && mirror_ok=true
|
|
241
281
|
|
|
242
|
-
if [ "$
|
|
282
|
+
if [ "$mirror_ok" = true ]; then
|
|
243
283
|
USE_CN_MIRRORS=true
|
|
244
284
|
MISE_INSTALL_URL="$CN_MISE_INSTALL_URL"
|
|
245
285
|
RUBYGEMS_INSTALL_URL="$CN_RUBYGEMS_URL"
|
|
@@ -248,19 +288,10 @@ detect_network_region() {
|
|
|
248
288
|
RUBY_VERSION_SPEC="ruby@3.4.8"
|
|
249
289
|
print_info "CN mirrors applied"
|
|
250
290
|
else
|
|
251
|
-
|
|
291
|
+
print_error "CN mirrors unreachable — cannot install."
|
|
292
|
+
exit 2
|
|
252
293
|
fi
|
|
253
294
|
else
|
|
254
|
-
local rubygems_result mise_result
|
|
255
|
-
rubygems_result=$(_probe_url_with_retry "$DEFAULT_RUBYGEMS_URL")
|
|
256
|
-
mise_result=$(_probe_url_with_retry "$DEFAULT_MISE_INSTALL_URL")
|
|
257
|
-
|
|
258
|
-
_print_probe_result "RubyGems" "$rubygems_result"
|
|
259
|
-
_print_probe_result "mise.run" "$mise_result"
|
|
260
|
-
|
|
261
|
-
_is_slow_or_unreachable "$rubygems_result" && print_warning "RubyGems is slow/unreachable."
|
|
262
|
-
_is_slow_or_unreachable "$mise_result" && print_warning "mise.run is slow/unreachable."
|
|
263
|
-
|
|
264
295
|
USE_CN_MIRRORS=false
|
|
265
296
|
RUBY_VERSION_SPEC="ruby@3"
|
|
266
297
|
fi
|