Commit Graph
46 Commits
Author SHA1 Message Date
SmartUp Developer 6906c3b998 feat: support Grok platform account imports 2026-07-12 13:16:29 +08:00
SmartUp Developer 40e75c0b51 fix: stream long-running website operations 2026-07-12 12:07:47 +08:00
SmartUp Developer a62ee00115 Improve abnormal account cleanup 2026-07-06 13:48:41 +08:00
SmartUp Developer 5a20e792fe Add SmartUp account pool parameter configuration 2026-07-04 11:59:21 +08:00
SmartUp Developer 9997b9d56a fix: restore api_key from local key_value when syncing upstream models for apikey accounts 2026-07-02 23:38:57 +08:00
SmartUp Developer a0c96ed5da fix: close platform-check silent-success loophole — raise WebsiteError on None list, missing account, or stale platform after update 2026-07-02 23:28:28 +08:00
SmartUp Developer 2c976f4d48 fix: add active check post account platform update to prevent silent ignore by remote backend 2026-07-02 23:06:38 +08:00
SmartUp Developer fd2755d539 feat: resolve account platforms prioritizing structural snapshot values and correction on existing accounts 2026-07-02 22:58:15 +08:00
SmartUp Developer 8746068cd4 feat: implement priority_weighted_plus_percent pricing algorithm 2026-07-02 20:23:20 +08:00
SmartUp Developer c20c9cfd26 fix: add stream close check, recover regression test assertions, and secure credentials type check 2026-07-02 19:18:10 +08:00
SmartUp Developer ece11d66e6 feat: sync upstream models with real-time streaming updates 2026-07-02 18:11:55 +08:00
liumangmang 852bf84246 fix: 优化同步上游模型,过滤克隆载荷中的敏感 credentials 字段,规避重写导致脱敏密钥丢失/清空的事故风险 2026-07-02 17:05:44 +08:00
liumangmang 316ef24188 fix: 优化同步上游模型的写回载荷,克隆并保留远端返回的所有非敏感 credentials,避免丢失 compact_model_mapping 等其它配置 2026-07-02 17:02:37 +08:00
liumangmang 4645460ff9 fix: 一键同步模型接口同步修复并携带上游 base_url,防止 sub2api 账号 base_url 被清空或置为默认值 2026-07-02 16:56:45 +08:00
liumangmang 3c1fff2491 fix: 优化上游模型同步的写回逻辑,采用增量 JSONB merge,避免脱敏的 credentials 覆盖或丢失原有敏感字段 2026-07-02 15:47:34 +08:00
liumangmang 63cbdf4dca feat: 实现一键同步网站账号上游模型功能 2026-07-02 15:43:00 +08:00
SmartUp Developer fe3f9f4a4c feat: 一键整理强制对齐分组逻辑,移除旧托管分组并优化统计消息区分 2026-07-02 10:42:18 +08:00
liumangmang c797aff773 fix: 修正设置并发数无候选时的文案拼写错误 2026-07-02 10:08:30 +08:00
liumangmang 274413bca7 fix: 优化并发数批量设置接口,引入 c.close() 资源管理并增加对 list_accounts() 返回 None 的拦截保护 2026-07-02 10:02:07 +08:00
liumangmang 608ef00920 feat: 实现设置账号并发数功能(支持 bulk-update 与 fallback 逐个更新) 2026-07-02 09:48:59 +08:00
liumangmang 3b23f21ef3 fix: 优化清理失效账号执行响应的 success 标志,对 test_account/delete_account 引入外部 API 日志审计,并对账号 ID 进行安全转义 2026-07-02 00:25:24 +08:00
liumangmang 536c0aa3d4 feat: 实现清理失效账号安全方案(包含预览、SSE测试、安全删除以及本地标记清空) 2026-07-02 00:19:26 +08:00
liumangmang 1ef6188c02 fix: 修正 websites router 中错误的 website.accounts_endpoint 属性调用为默认值,并增加对已存在账号名称回显与默认端点引用的单元测试 2026-07-01 21:15:55 +08:00
liumangmang 94d9550f77 feat: 调整新建/重建账号命名格式为 {上游网站名}-{上游分组名/ID}-{KeyID} 2026-07-01 21:11:37 +08:00
liumangmang 7ae9ad9292 fix: 删除 routers/websites 中残留的死代码函数 _build_rate_priority_map,并为 build_target_group_priority_map 引入严格的分组倍率解析,防止非法/缺失倍率的分组以 1.0 的降级值参与排序 2026-07-01 20:26:23 +08:00
liumangmang dd3649a6ad feat: 修正优先级自动计算算法为分目标分组独立排序,并优化一键分组整理完成后仅触发一次网站级优先级重排 2026-07-01 20:19:54 +08:00
liumangmang ef14382e5f fix: 后端路由 group_id 启用 path 路径匹配转换器,完美兼容带斜杠的远端分组 ID 2026-07-01 17:58:56 +08:00
liumangmang 3172ab18bf fix: 修改目标分组名称后自动同步更新本地绑定表中的名称缓存,并为前端更新分组 URL 中的 groupId 进行 Url 编码 2026-07-01 17:55:53 +08:00
liumangmang 8c2f1c13bb feat: 支持网站目标分组轻量管理(新增、编辑、描述展示),不修改和不提交倍率 2026-07-01 17:47:36 +08:00
liumangmang 8abfa4c5ef feat: 重构接口日志页面与接口监控看板,支持HTTP方法过滤和实时轮询 2026-07-01 15:04:32 +08:00
liumangmang 397a14c978 feat(website): 支持基于现有绑定一键整理分组,支持账号校验补齐、自愈重建与缺失 Key 提示 (含异常保守跳过及名称层级匹配) 2026-07-01 11:21:20 +08:00
liumangmang bf5470caf3 fix(sync): 优先级同步前置过滤远端失效账号防排序污染,移除 locals 隐患,并将自愈结果纳入本地日志与摘要统计 2026-07-01 10:20:13 +08:00
liumangmang efd0a88249 perf(import): 优化账号导入弹窗为秒开体验并支持批量回查校验 2026-07-01 10:00:40 +08:00
liumangmang d92537688a fix(priority): keep readable priority sync details 2026-07-01 09:12:39 +08:00
SmartUp Developer 2d1dcb8f9f fix: round website rates to two decimals 2026-06-30 11:26:48 +08:00
SmartUp Developer b866b387e0 feat: sync upstream keys and reorder priorities 2026-06-03 17:03:11 +08:00
liumangmang f17317b13c fix(priority-sync): handle missing rate data and backfill target group on re-import
P1 - Missing rate data now skips account instead of falling back to 1.0:
  In sync_account_priorities_for_upstream(), the rated list now filters
  out accounts whose upstream snapshot has no rate entry for their group_id.
  If after filtering a competitive bucket has fewer than 2 accounts with
  valid rate data, the entire bucket is silently skipped (no update_account
  call, no webhook) rather than treating missing rates as 1.0 and
  potentially triggering spurious notifications.

P2 - Re-importing an existing account now backfills imported_target_group_id:
  In the exists-is-True idempotency branch of import_upstream_keys_as_accounts(),
  if the current request supplies a target_group_id for the account's source group
  and it differs from what is stored, the field is written back and committed.
  This lets operators fix old data by simply re-running the import dialog.

Tests added:
  - test_missing_rate_skips_entire_competitive_group: all accounts in
    competitive group lack snapshot → bucket skipped, no update called
  - test_partial_missing_rate_sufficient_accounts_still_updates: 3 accounts
    in same bucket, 1 missing rate → the 2 with rates still compete normally

All 27 tests pass.
2026-06-01 19:27:35 +08:00
liumangmang e519d1804b fix(priority-sync): narrow account priority update to competitive groups only
Root cause: sync_account_priorities_for_upstream() was doing a global
priority re-rank across ALL imported accounts on a website whenever any
upstream rate changed, triggering spurious account_priority_changed
notifications for accounts in different target groups with no competition.

Fix:
- Add imported_target_group_id / imported_target_group_name to
  UpstreamGeneratedKey (nullable; old data falls back to group_id)
- Writ imported_target_group_id on account import in websites.py
- Rewrite sync_account_priorities_for_upstream():
  * bucket accounts by competition_group = imported_target_group_id or group_id
  * only process buckets with count > 1 (genuine competition)
  * each competitive bucket independently sorted by rate; priority starts at 1
  * single-account groups: completely skipped (no update_account, no notification)
  * no competitive groups at all: early return, no log, no notification
- Remove auto priority update in re-import idempotency path (was also
  incorrect; now fully delegated to sync_account_priorities_for_upstream)
- Fix Sub2ApiWebsiteClient local import in sync fn → use module-level name
  so monkeypatch works correctly in tests

Tests: rewrite test_priority_sync.py
- REMOVED: test_priority_sync_full_website_update (was asserting the buggy behavior)
- NEW: test_no_update_when_different_groups_single_account_each
- NEW: test_same_target_group_two_accounts_updated
- NEW: test_two_target_groups_independent_priority
- NEW: test_old_data_null_target_group_fallback
- NEW: test_single_account_in_mixed_website
- UPDATED: test_priority_sync_log_structure (now requires competitive group)
- KEPT: test_priority_sync_cross_upstream_group, test_import_auto_priority_by_rate

All 25 tests pass (8 priority_sync + 17 existing upstream tests).
2026-06-01 19:13:14 +08:00
liumangmang bea4344bb3 fix: reconcile upstream keys on list/generate/import to prevent stale key imports
- Extract reconcile_upstream_keys() to website_sync.py (shared scheduler + on-demand)
- Add reconcile_upstream_keys_full() for on-demand reconciliation at three entry points:
  list_generated_keys, generate_keys_by_groups, import_upstream_keys_as_accounts
- Safe on failure: active_group_ids=None / remote_key_ids=None skip cleanup
- Support custom managed_prefix via _fetch_remote_managed_key_ids() helper
- Exclude orphaned keys from frontend importable list
- Remove hardcoded search='SmartUp' from scheduler path
2026-06-01 11:29:37 +08:00
liumangmang 518e3e8efc feat: add one-click sync for website group bindings 2026-06-01 09:06:01 +08:00
liumangmang 5c20ddc8e6 feat: sync account priorities after rate changes 2026-05-29 17:51:12 +08:00
liumangmang c5778bb3e7 feat: persist browser sessions and update admin workflows 2026-05-29 16:00:43 +08:00
liumangmang 6044b00685 feat: 上游 Key 唯一化、分组导入跳过、账号导入平台识别&远端校验&base_url 注入
- 上游 Key 命名改为 {prefix}-{upstream.id}-{safe_group_name}-{group_id}
- 唯一约束 (upstream_id, group_id, managed_prefix) 加 managed_prefix 列
- 上游检测成功时同步 Key 状态,远端已删/分组已删自动清理
- 重复分组导入跳过,目标网站已存在同名分组返回 exists
- 账号导入平台自动识别(auto/manual 模式)
- 全选可导入 Key 按钮 + 目标分组自动匹配
- 导入幂等:已导入过的 Key 校验远端账号,不存在则重建
- 新增同步接口 POST /sync-imported-upstream-keys
- account_exists() 通过拉取账号列表判断,避免 404 误判
- credentials.base_url 注入来源上游地址,避免 401
- 前端导入弹窗自动同步+刷新按钮+并发/优先级设置
- 新增 12 个测试覆盖同步、幂等、远端删除、校验失败路径
2026-05-21 01:16:39 +08:00
SmartUp Developer 2934473770 fix: remove stale _decimal_str ref, add context manager to HTTP clients
- UpstreamClient & Sub2ApiWebsiteClient: add __enter__/__exit__
- Convert all call sites to `with Client(...) as c:` pattern
- Remove unused `upstream_name`/`upstream_base_url` locals in scheduler
- Fix stale _decimal_str→decimal_string in _rate_from_group
2026-05-17 11:29:51 +08:00
SmartUp Developer ad16618406 fix: address multiple code audit findings
- CORS: replace wildcard with explicit origin list from CORS_ORIGINS env
- Auth: enforce strong defaults, JWT blacklist (RevokedToken model), login rate limiting
- Auth: validate password length before bcrypt (72-byte limit)
- Scheduler: single-threaded worker to mitigate SQLite write contention
- Scheduler: graceful shutdown (wait=True)
- Snapshots: add prune_snapshots() with configurable retention count
- Storage: isolate localStorage keys via VITE_APP_KEY prefix
- Config: add cors_origins, login_rate_limit, snapshot_retention_count settings
2026-05-17 10:52:18 +08:00
liumangmangandClaude Opus 4.7 7adc7c00ab Add remote browser pages and website sync
Enable managed remote browser custom pages with login autofill and add website sync workflows so external admin surfaces can be handled inside SmartUp.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 15:43:58 +08:00