zsbgnw12 and GitHub
9ff0a7f9c5
Merge pull request #38 from xmindlab-heicode/docs/client-api-available-models-telemetry-usage
...
docs(client-api): available-models + config + telemetry + agent usage + #30 billing semantics (#35 )
2026-06-10 13:11:19 +08:00
818f1412d5
feat(heicode): 客户端错误遥测上报端点(默认关闭)( #24 ) ( #27 )
...
* feat(heicode): 客户端错误遥测上报端点(默认关闭)(#24 )
按客户端 winos#23 契约 + 权威 schema 实现,结合 HM 入库逻辑:
- POST /api/heicode/telemetry/events,挂 UserOrV2DeviceAuth(设备配对鉴权)。
- 接收顶层 JSON 数组(非包裹),批量 1-20、<=256KB;校验 body client_id 等于已验签
设备(X-Heicode-Device-Id),不一致 403;无设备身份拒绝。
- 真实 4xx/5xx 码(400 非数组、413 超限、403 设备、410 关闭),让客户端"4xx 丢弃"
语义生效;2xx 返回 {accepted:n}。
- 独立表 telemetry_events,与计费完全隔离:不写 consume log、不碰 quota。
- 宽松入库(最大化采集):未知枚举 / 哨兵 app_version(0.0.0-heicode-local)/ 缺字段
原样入库;schema_version 缺省 1;stack_top/context 存 TEXT(JSON);记 user_id 作
device 到 account 关联 + 服务端 received_at。
- 默认 HEICODE_TELEMETRY_ENABLED=false 时返回 410(kill switch);隐私政策更新 +
端点下发形态确认前不开启外发。
测试用客户端仿真夹具:parseTelemetryBatch / toModel 映射与默认 / 拒绝非数组,全过。
Refs #24(上线门槛:隐私政策 §2 如实披露 + 下发形态 + 去重;见工单评论)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
* feat(heicode): GET /api/heicode/config 下发 telemetry 配置/kill-switch (#24 )
按客户端 #24 拍板:选独立 config 端点(而非塞登录响应),便于 kill switch 在
会话内传导、不依赖重登录。返回 telemetry 块 {enabled, endpoint, max_batch,
flush_interval_sec};enabled 取 HEICODE_TELEMETRY_ENABLED(默认 false)。
未鉴权全局只读(同 capabilities 姿态)。
测试 heicode_config_test.go:enabled 反映 env、endpoint 与摄入路由一致、缺省 false。
Refs #24
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
* fix(telemetry): 服务端二次脱敏 stack_top/context + 明确生产门槛 (#24 review)
按 Fasthei 复审意见补隐私门槛:
- 服务端纵深防御脱敏:新增导出 model.RedactText(包装已上线的 redactAuditSecrets,
#11 ),在 telemetry 入库前对 stack_top / context 再脱敏一遍(sk-/Bearer/URL
token/JSON 密钥字段),即便客户端漏脱敏也不会把明文密钥落库。
- 测试 TestTelemetryToModel_RedactsSecrets:stack_top 里的 sk-、context 里的
Bearer token 被打码,非密钥内容保留。
- 端点默认 HEICODE_TELEMETRY_ENABLED=false,关时 410;隐私政策披露完成前生产
不得开启外发(见 #24 评论记录产品/法务状态)。
go build / vet 干净;controller 测试通过。
Refs #24
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
---------
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-09 22:16:29 +08:00
7d56b54324
feat(agent): 部署上限按订阅档动态化,闭合 #8 个人5/团队8 ( #21 )
...
沿用订阅体系现成先例 MaxPurchasePerUser,给 SubscriptionPlan 加 MaxAgents:
- model: SubscriptionPlan.MaxAgents(0=回退全局默认)+ GetUserMaxAgents(取用户
active 订阅档最高 MaxAgents,无则回退默认)。
- HeicodeDeployAgent: 部署上限改 model.GetUserMaxAgents(userID, 环境默认5)。
团队8=管理员把团队档配成8;个人5=默认;代码不硬编码 tier。
- subscription 控制器: Create/Update 校验 MaxAgents>=0;Update updateMap 补 max_agents。
- 前端管理端套餐表单(plan-form/types/drawer)加「Agent 部署上限」字段 + zh i18n。
测试 model/subscription_max_agents_test.go 全过(无订阅/团队档/0回退/过期/多档取最高/非法用户)。
go build、go vet、前端 tsc 干净。
Fixes #8
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-09 14:28:19 +08:00
af094dde27
feat(agent): 按部署 agent 聚合模型用量,闭合 #9 用量聚合 ( #22 )
...
#9 的审计脱敏半部已由 PR#11 完成。据评审报告(L95 usage/billing 结构完整、
L112 监控 mock metrics 属 AM)核实:HM 侧通用用量聚合并不缺,真正缺的是
agent 维度用量视图。
- model.SumAgentUsage(userId, tokenName, start, end):按 agent 铸币 token 名
'agent:<deployment_id>' 聚合 consume 日志(quota/prompt/completion/调用数),
COALESCE+COUNT/SUM 跨 SQLite/MySQL/PG。
- GET /api/heicode/agents/:deployment_id/usage:返回该 agent 用量 + quota_per_unit
(raw,调用方换算,与 /api/heicode/self 同契约),支持 ?start=&end= 时间窗。
- 测试 model/agent_usage_test.go:聚合正确、排除他人/非消费/不同 token、时间窗、空名。
go build/vet 干净;测试 PASS。
Refs #9 (审计脱敏半部 PR#11 已完成;监控 mock metrics 属 AM 侧)
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-09 14:27:48 +08:00
aa4041f604
fix(web): 钱包余额直读 /api/user/self(去 502) + 部署完成提示/动画 ( #23 )
...
两处 HM web 前端修复(此前已热部署到 VM 验证):
1. 钱包 502:wallet 不再经 /api/heicode-auth → mcp-server 读余额(那条会触发
HM GetUser 同级权限检查 → 502)。HM 本就是 new-api,直接读用户自己的
/api/user/self(GetSelf,无角色检查)。
2. 异步部署无反馈:deploy-agent-page 加快轮询(启动中 3s/稳定 30s)+ 检测
Pending→running 弹「✅ 部署完成,已就绪」(失败弹错误)+「启动中」徽章转圈脉冲。
tsc 干净。
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-09 14:27:19 +08:00
zsbgnw12 and GitHub
9444cdb498
fix agent deploy caps
...
approved
2026-06-08 17:49:35 +08:00
zsbgnw12 and GitHub
b3d864b29b
fix(agent): refresh list status from AM
...
Refresh non-terminal agent statuses before returning /api/heicode/agents.
2026-06-08 16:22:21 +08:00
cbbdd66c2e
docs(reference): correct permission-modes precision per official en page ( #16 )
...
Verified against code.claude.com/docs/en/permission-modes and fixed 6 points:
1. acceptEdits: add PowerShell tool auto-approvals (Set-Content/Add-Content/
Clear-Content/Remove-Item + aliases) and env-prefix/process-wrapper note.
2. Protected paths: .claude exception is ONLY .claude/worktrees (was wrongly
widened to commands/agents/skills); add per-mode protected-write table.
3. defaultMode:"auto" ignored from project files since v2.1.142+.
4. dontAsk: read-only Bash commands also run without allow rules; explicit ask
rules are denied (not prompted).
5. auto conversational boundary: stays in force until user lifts it; Claude's own
judgment doesn't lift it; lost on context compaction; use deny rule for hard.
6. auto consecutive-failure fallback: 3-in-a-row / 20-total pauses & re-prompts;
-p non-interactive aborts the session. Plus dropped broad allow-rules on entry.
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-08 15:26:52 +08:00
efb0016f5c
fix(secret): 撤销资源时删除 Key Vault 凭证材料 ( #4 ) ( #13 )
...
#4:撤销资源此前只把 DB 状态置 "revoked",真凭证仍留在 Azure Key Vault。
现在 DeleteResource 同时删除 KV 中的 secret(best-effort:DB 撤销已提交,
外部 KV 失败只记日志、不阻塞响应)。
- secret_store.go:新增 deleteSecret / purgeSecret / rotateSecret
(AKV REST,api-version=7.4,与 putSecret/getJSONSecret 同风格;404 幂等)。
※ 该文件受组织权限策略保护、自动化无读写权,本段由 HM owner 手动粘贴,
审阅者请核对其与本意一致。
- resource.go:DeleteResource 在撤销事务提交后调用 deleteSecret(resource.SecretRef)。
本轮为 #4 最小修复(堵住"撤销后 KV 材料残留"的洞)。后续仍待:
purgeSecret 接入 30/90 天生命周期、轮换流程。
go build ./... 与 go vet 通过。
影响面(组织规则第 10 条):仅 Manager(HM) —— 涉密钥/安全/审计。
不影响 Client / Swarm / AM 契约 / CodeGW / 计费 / 发布链路。
Refs #4
Co-authored-by: chenchen <chenchen@xinghanlab.com >
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com >
2026-06-08 15:26:47 +08:00
zsbgnw12 and GitHub
696dfecc9d
docs(heicode): set Azure Key Vault as secret-store baseline
...
Align Manager docs with code-enforced azkv:// secret_ref baseline.
Reviewed: docs-only, no code/runtime impact. Follow-up required in heicodeDocs to remove OpenBao/vault:// drift.
2026-06-07 22:49:58 +08:00
zsbgnw12 and GitHub
6d360454dd
fix(relay): return errors instead of panic for Claude conversion stubs
...
Replace unimplemented ConvertClaudeRequest panic stubs with explicit not implemented errors across 11 relay adaptors.
Reviewed: narrow relay hardening only; no billing/secrets/Agent-Swarm/product semantic changes.
2026-06-07 19:59:21 +08:00