Commit Graph
92 Commits
Author SHA1 Message Date
chenchenandClaude Opus 4.7 610fde5d03 feat(mcp-server): Heicode integration + register transaction hardening
== Heicode integration (~41 endpoints across 5 modules) ==
- §2 ResourceBinding (5 endpoints) — resources.py / resource_grants.py
- §4 NewAPI metadata proxy (4 endpoints) — heicode_proxy.py + heicode_client.py
- §5 Agnet platform stub (12 endpoints, in-memory mock) — agnet_stub.py
- §6 Task orchestration (5 endpoints + 3 extension endpoints) — heicode_tasks.py
  6.1-6.5: intent / list / get / answer / messages
  6.6-6.8: execution / delivery / audit?tab=... (Slice 8/9/10)
- §7 SSE single channel + approvals (4 endpoints + 5 event types) —
  heicode_events.py + event_bus.py
- §7.8.1 internal billing-provider PUT endpoint — auth.py (routes)

== Schema changes ==
- migrations/026 heicode_tasks (orchestration state)
- migrations/027 users.billing_provider (litellm | newapi switch)
- migrations/028 heicode_approvals (high-risk approval queue)

== Register transaction hardening (P0 + P1 + P2) ==
routes/auth.py register():
- Pre-existing P0: failed register returned IntegrityError str verbatim
  (leaking SQL params + ~50 plaintext LiteLLM keys per attempt).
  Now logs exc_info, returns {code: REGISTER_FAILED, message: ...}.
- Pre-existing P0: model dedupe — two ModelProvider rows with overlapping
  supported_models (e.g. taiji/gpt-4o-mini in both taiji and azure providers)
  collide on uq_tenant_model. seen_models set deduplicates within the loop.
- New P1: track created_litellm_keys; on any failure call delete_key() for
  each — prevents remote orphan keys when DB rollback fires.
- New P1: replace verify_code with peek_verification_code at the start;
  only call verify_code (which consumes) after commit succeeds. Failed
  registrations no longer burn the user's one-shot code.
- New P2: narrow inner `except (LiteLLMClientError, Exception)` to just
  LiteLLMClientError so SQLAlchemy errors bubble to the outer rollback
  instead of being silently swallowed into a half-allocated 200 response.
- New P2: same narrowing on outer `except (AgentManagerError, Exception)`.

== Auth middleware ==
- app/auth.py: allow /api/auth/internal/billing-provider and
  /api/auth/internal/approvals to bypass user JWT (service-token auth
  via HEICODE_INTERNAL_SERVICE_TOKEN, validated in-route).

== Docs ==
- Heicode-接口契约文档.md v2.2 (41 endpoints + SSE schema + 6.6-6.8)
- Heicode-对接进度与待办.md (through §7.14 SSE + 7.8.2 delivery回执)
- Heicode-完整调用流程图.md (sequence + routing diagrams)
- Agent-Manager-Heicode对接需求文档.md
- HEICODE_API_INTEGRATION.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 15:43:10 +08:00
chenchenandClaude Opus 4.7 eb17ed84f8 fix(mcp-server): plug LiteLLM API key leak via register & tenant model assignment errors
A failed POST /api/auth/register returned the SQLAlchemy IntegrityError verbatim
to the caller, which included the full INSERT INTO tenant_model_keys statement
along with every bound parameter — ~50 plaintext LiteLLM API keys per failed
attempt. Same pattern was reproduced in 3 channel.py endpoints that wrap
LiteLLM key INSERTs.

Changes:
- channel.py: assign_resources_to_tenant / assign_model_to_tenant /
  update_tenant_model_quota — log full exc_info, return a typed
  {code, message} error instead of f"...{str(e)}". 6 leakage points sealed.
- email_verification.py: add peek_verification_code() — checks a code
  without burning it. Lets the register handler verify *before* the
  multi-step transaction so a downstream failure doesn't waste the user's
  one-shot code.
- scripts/cleanup_orphan_litellm_keys.py: one-shot orphan key reaper.
  Scans LiteLLM /key/list by metadata.tenant_id (plus a manual list of
  the 8 publicly-leaked sk- prefixes from the original incident).
  Used to nuke 16 orphan keys for tenant fab9dc27-… on 2026-05-12.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 15:42:38 +08:00
chenchen d0b79030f1 更新heicode 2026-05-05 14:13:59 +08:00
unknown 3692b165a0 更新备份 2026-03-25 21:34:44 +08:00
unknown e379f9dee6 备份 2026-03-25 20:48:00 +08:00
zhanggangyong 40447f86f6 更新开发者平台 2026-03-16 04:05:44 +00:00
zhanggangyong a3d7ef6a6e 备份 2026-03-15 15:30:24 +00:00
zhanggangyong 648921b26c 生产备份 2026-03-13 02:53:27 +00:00
zhanggangyong 7ddac1bea7 计费备份 2026-03-12 02:32:23 +00:00
zhanggangyong a540e6d61a 更新计费 2026-03-10 06:40:38 +00:00
zhanggangyong 368198f53c 更新爆改前的备份 2026-02-09 06:40:04 +00:00
zhanggangyong a498072888 备份 2026-02-02 14:08:13 +00:00
zhanggangyong fe69a70a3a 更新外部数据工具和工具集 2026-01-23 10:57:13 +00:00
zhanggangyong d59dcfa941 geng 2026-01-22 03:32:09 +00:00
zhanggangyong 6d164c838b 更新大志备注 2026-01-16 10:38:17 +00:00
zhanggangyong 9ceb72abf1 更新yaml文件 2026-01-15 07:43:09 +00:00
zhanggangyong 6ead42a050 更新停止agent文档 2026-01-14 14:11:20 +00:00
zhanggangyong 31ba6fb8f1 更新agent域名 2026-01-14 13:42:36 +00:00
zhanggangyong e17f38112b 更新信息接口 2026-01-14 06:37:39 +00:00
zhanggangyong 5b1c384764 更新agent DNS 2026-01-14 06:28:45 +00:00
zhanggangyong 8f86d22f00 更新信息查询 2026-01-13 13:36:41 +00:00
zhanggangyong 1b079ed870 更新自定agent的工具列表 2026-01-13 12:12:18 +00:00
zhanggangyong b165123bd9 更新计费余额不足时中止agent 2026-01-13 09:15:41 +00:00
zhanggangyong faf2c8afd3 更新前端模板 2026-01-13 05:07:06 +00:00
zhanggangyong 0ddc548d0f 更新超级管理查看资源分配 2026-01-12 17:16:55 +00:00
zhanggangyong 1154b4e7ae 更新租户配额 2026-01-12 16:47:41 +00:00
zhanggangyong dd8c4c194d 更新自由注册邮箱验证 2026-01-12 14:43:14 +00:00
zhanggangyong cd4dea8a0d 更新agent manager数据接口 2026-01-12 13:52:38 +00:00
zhanggangyong e3d2cee85a 赌博前的备份 2026-01-12 10:27:19 +00:00
zhanggangyong b75f9671ff 更新超级管理员收入 2026-01-12 07:47:50 +00:00
zhanggangyong 0ad63198f5 备份自由搏击前代码 2026-01-11 16:55:45 +00:00
zhanggangyong 726b4dd4c6 feat: 添加用户注册和个人信息管理接口
- 添加用户注册接口 POST /api/auth/register
- 添加获取用户信息接口 GET /api/user/profile
- 添加更新用户信息接口 PUT /api/user/profile
2026-01-11 16:22:40 +00:00
zhanggangyong 22bd9d812f 备份 2026-01-11 13:00:46 +00:00
zhanggangyong d221d9db04 更新智慧的王接口前的关键保命备份 2026-01-11 09:21:25 +00:00
zhanggangyong f01c0053e7 更新会带哦 2026-01-11 07:52:54 +00:00
zhanggangyong 51ea6b8310 更新资源积分 2026-01-10 19:27:57 +00:00
zhanggangyong 613dd08118 更新正在运行的pods 2026-01-09 13:59:26 +00:00
zhanggangyong db34b21d58 更新回调架构图 2026-01-09 06:56:43 +00:00
zhanggangyong 625afdf441 更新模型计费 2026-01-08 15:03:52 +00:00
zhanggangyong 6fb4f29208 更新渠道配置litellm 2026-01-08 07:51:54 +00:00
zhanggangyong 9f2ed20fa9 更新litemll 2026-01-07 14:46:15 +00:00
zhanggangyong bb719db8ed 更新litellm 2026-01-07 10:46:55 +00:00
zhanggangyong 8bbc97ae36 更新用户端测试文档 2026-01-07 07:09:49 +00:00
zhanggangyong 4343cf8347 更新渠道端文档 2026-01-06 17:23:36 +00:00
zhanggangyong 81bb3146ff 超级管理员完整 2026-01-06 16:00:33 +00:00
zhanggangyong 92c9d6ea68 更新超级管理员对接文档 2026-01-06 13:41:29 +00:00
zhanggangyong 4a7a0881a4 更新删除重复接口 2026-01-06 10:17:33 +00:00
zhanggangyong 369d9951d2 刚更新 2026-01-06 09:08:32 +00:00
zhanggangyong 6e9d4df6ce 更新技术 2026-01-06 08:35:09 +00:00
zhanggangyong 991a5dd01e 更新超级管理员端 2026-01-06 06:09:12 +00:00