Repository navigation
Feat: Added auto-captcha solver to enhance start-plan usage - #6
Merged
Merged
Conversation
对start-plan用户添加了自动解决captcha的功能,需要注意的是这个是实验性的,并不代表正式功能 ZCode 源码验证结果: | Provider | 有 refreshToken 方法?| 刷新机制 | | ZAI (Em class) | ❌ 没有 | ZCode 桌面客户端也做不到自动刷新,报错 "Z.ai OAuth 暂未提供 refresh token 交换接口,请重新登录" | | BigModel (Rm class) | ✅ 有 | POST https://zcode.z.ai/api/v1/oauth/token with refresh_token |
Extracted Zcode system prompt
Inspired by the suggestions from @yurchik228336, used jsdom instead of plawright to solve captcha. Also introduced system_prompt injection for start-plan users Co-Authored-By: RusCreat <81516654+yurchik228336@users.noreply.github.com>
Changed a few things so the solver can be bundled within the main script. Removes external deps Co-Authored-By: RusCreat <81516654+yurchik228336@users.noreply.github.com>
对start-plan 业务逻辑修复了一个bug,实测有效 v1.4.8.alpha 三个失败点全部修复在 src/proxy/captcha.ts,单文件改动。 失败点①:CDN 依赖 → 本地 SDK - 模块加载时 readFileSync(HERE/AliyunCaptcha.js) 读入仓库里已有但未接线的 224KB SDK(commit 55c3f2d 加进来却没用上) - jsdom HTML 用 inline <script>${sdkSafe}</script> 替代 <script src="https://o.alicdn.com/..."> - </script> 转义防字符串字面量截断 - 副作用:文件缺失会启动即失败(fail-fast,比运行时 503 好) 失败点②:0 重试 + 短超时 → 3 重试 + 长超时 - 新增 solveInJsdomWithRetry 包装器,默认 3 次重试 - 超时常量全部 env-overridable:ZCODE_CAPTCHA_RETRIES=3 / ZCODE_CAPTCHA_TIMEOUT_MS=40000 / ZCODE_CAPTCHA_SDK_LOAD_MS=20000 - SDK 加载超时 15s → 20s;solve 超时 30s → 40s - finally { w.close() } 释放 jsdom timers/listeners,避免重试间内存泄漏 失败点③:getInstance 静默吞错 → 显式 reject - 替换 (inst.startTracelessVerification || inst.show)?.call(inst) + try {} catch {} - 改成显式 typeof fn !== "function" 检查 → reject(...)(不再用 ?. 静默跳过) - fn.call(inst) 抛错 → reject(...)(不再用 catch {} 吞掉) - 效果:getInstance 出错时立即 reject,外层 40s 超时不再空等 Co-Authored-By: Rushikesh Gaikwad <81632222+wraient@users.noreply.github.com> Co-Authored-By: RusCreat <81516654+yurchik228336@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat: Added auto-captcha solver to enhance start-plan usage