hex2077
35f3f81d3e
feat(provider): 实现提供商节点自动刷新与预热机制
...
- 新增提供商节点自动刷新队列和并发控制
- 添加系统启动预热功能,按配置预热指定数量节点
- 重构CPU使用率统计,支持子进程独立统计
- 扩展适配器接口,增加强制刷新和过期检查方法
- 更新配置管理,新增预热目标和刷新并发数配置
- 优化提供商选择策略,基于评分系统选择最佳节点
- 改进错误处理,401错误自动触发后台刷新
2026-01-17 17:08:17 +08:00
hex2077
56ef11a168
refactor: 移除 CredentialCacheManager 及相关缓存逻辑
...
重构多个 provider 模块,移除了 CredentialCacheManager 的依赖及相关内存缓存逻辑,改为直接读写文件系统。简化了凭证管理流程,减少了代码复杂度。
- 移除 provider-pool-manager 中的快速预检逻辑
- 移除 service-manager 中的凭证缓存初始化及同步逻辑
- 修改各 provider 核心模块的凭证加载和保存逻辑,直接操作文件系统
- 移除并发刷新时的去重锁和缓存同步机制
2026-01-17 13:16:19 +08:00
leonai
228898bbf7
feat(credentials): 增强凭证解析容错能力并添加预验证机制
...
新增从损坏 JSON 中提取关键凭证字段的恢复方法
凭证缓存管理器增加 token 有效性预检查,跳过无效凭证
配置 API 补充 POOL_SIZE_LIMIT 字段同步
优化日志输出,区分加载失败和跳过的凭证统计
2026-01-16 17:16:38 +08:00
leonai
9f58db2c1f
feat: 引入凭证缓存管理器,优化 OAuth Token 并发处理
...
- 新增 CredentialCacheManager 替代文件锁机制
- 所有 OAuth Provider 迁移到内存缓存
- Token 刷新策略优化:过期阻塞,即将过期后台刷新
- 健康检查增加 Token 预检和超时保护
- 进程退出时自动同步凭证到文件
2026-01-15 21:49:54 +08:00
leonai
ec82841c26
Merge branch 'main' of https://github.com/leonaii/AIClient-2-API
2026-01-14 20:14:55 +08:00
leonai
92c2f44a73
feat(kiro): 添加凭证错误处理和配额恢复机制
...
1. 新增 CredentialError 自定义错误类,支持凭证切换标记
2. 添加 402 配额耗尽错误处理,支持验证用量并设置下月恢复时间
3. 重构 429/5xx 错误处理策略,改为等待后切换凭证而非指数退避重试
4. 新增 markProviderUnhealthyWithRecoveryTime 方法支持计划恢复
5. 添加 _checkAndRecoverScheduledProviders 自动恢复已到期凭证
6. 调整凭证切换最大重试次数从 2 次增加到 5 次
7. 支持 skipErrorCount 标记避免临时错误影响凭证健康度统计
2026-01-14 20:14:40 +08:00
hex2077
5c90100997
feat(并发控制): 实现去重锁机制并优化提供者选择并发安全
...
为关键操作添加去重锁机制,确保并发请求只执行一次共享结果
重构 provider-pool-manager 使用链式锁保证选择操作的原子性
更新各服务提供者使用 withDeduplication 替代自定义单例锁
2026-01-14 16:01:04 +08:00
leonai
3b0fc590d5
fix(kiro): 添加token刷新单例锁并增强JSON解析容错
...
1. 引入tokenRefreshPromises Map实现按凭证文件路径的单例锁机制
2. 防止多个并发请求同时刷新同一个token导致的文件锁串行化问题
3. 添加repairJson函数处理损坏的JSON文件,增强解析容错能力
4. 重构token刷新逻辑,提取_doTokenRefresh和_reloadCredentialsAfterRefresh方法
2026-01-14 13:44:47 +08:00
leonai
3a04777439
Merge branch 'main' of https://github.com/leonaii/AIClient-2-API
2026-01-14 11:37:02 +08:00
leonai
b14ae21917
fix(kiro): 增强401错误处理并支持Gemini格式请求体转换,修复健康KIRO健康检查错误。
...
1. 在callApi和callApiStream方法中添加contents到messages格式的自动转换
2. 401错误时先刷新UUID再刷新token,提高认证恢复成功率
3. 新增_refreshUuid方法用于生成新的UUID标识
4. ProviderPoolManager新增refreshProviderUuid方法支持UUID刷新
5. 移除Kiro OAuth的contents格式备用请求,统一使用messages格式
2026-01-14 11:31:28 +08:00
hex2077
58c66fcd4b
feat(文件锁): 添加文件锁机制防止凭证文件并发写入冲突
...
实现文件锁工具类,用于防止多个异步操作同时写入同一文件导致的竞争条件。修改各认证模块的凭证保存逻辑,在写入文件前获取锁,确保写入操作的原子性。
- 新增 file-lock.js 工具模块,提供 acquireFileLock 和 withFileLock 方法
- 修改所有认证模块的凭证保存逻辑,使用文件锁保护写入操作
- 添加适当的错误处理和锁释放机制,确保资源不会泄漏
2026-01-13 22:10:49 +08:00
leonai
948283187c
feat(kiro): 添加认证错误自动标记不健康及凭证切换重试机制,解决401 和403的问题
...
1. Kiro API 新增 401/403 错误处理逻辑,401 尝试刷新 token 后重试,403 直接标记凭证不健康
2. 新增 _markCredentialUnhealthy 辅助方法,统一处理凭证健康状态标记
3. ProviderPoolManager 新增 markProviderUnhealthyImmediately 方法,用于认证错误立即标记
4. handleStreamRequest/handleUnaryRequest 支持重试上下文,认证失败后自动切换健康凭证重试
5. provider-api 健康检查增加认证错误识别,触发立即标记不健康逻辑
2026-01-13 18:44:34 +08:00
hex2077
e335a13592
fix: 修复多个功能问题并优化服务器配置
...
- 将Claude提供商的AXIOS超时恢复为2分钟
- 扩展CORS头以支持更多方法和头部,并添加预检缓存
- 禁用自动链接提供商配置
- 增强服务器配置,设置超时和最大连接数
- 为更新检查添加代理支持,使用undici进行代理请求
2026-01-13 13:29:03 +08:00
Zhafron Kautsar
debe3ec33d
refactor(kiro): remove schema simplification and size-based compression
...
Eliminated the two-stage compression system that attempted to preserve original
tool schemas and only simplified when exceeding size limits. The provider now
applies consistent description truncation for all tools without conditional
schema processing or size calculations.
Removed:
- TARGET_TOTAL_SIZE constant and size checking logic
- simplifySchema helper function
- Conditional schema simplification based on total size
This change reduces complexity and ensures uniform handling of tool descriptions
regardless of total payload size.
2026-01-12 20:50:43 -05:00
Zhafron Kautsar
2e9e319933
refactor(kiro): simplify tool size compression logic
...
The code refactors the tool building process in initializeAuth to handle
description truncation and size limits more efficiently. It introduces
per-tool description truncation using a fixed max length, and simplifies
the compression logic by removing the iterative description adjustment
loop. This improves code clarity and performance.
2026-01-12 20:43:24 -05:00
hex2077
02712afc30
feat(token): 增强token加载和保存的日志记录与验证
...
refactor(claude): 简化token计算逻辑并改进上下文使用率处理
2026-01-12 15:49:19 +08:00
Zhafron Kautsar
6d8afe5c33
Merge remote-tracking branch 'aiclient/main' into feat/kiro-think-token-fix
2026-01-11 11:07:52 -05:00
hex2077
1d01feee35
fix: 调整Claude模型的总上下文tokens限制为172500
...
更新TOTAL_CONTEXT_TOKENS常量以匹配最新的API限制,从160k提升至173k tokens
2026-01-11 23:54:26 +08:00
Zhafron Kautsar
89083499bc
docs(kiro): restore deleted comments
2026-01-11 10:52:26 -05:00
hex2077
340d6f9e10
fix(claude-kiro): 修复工具调用token计算和web搜索工具过滤问题
...
- 过滤web_search/websearch工具调用
- 将工具调用的name和input内容计入totalContent用于token计算
- 调整总上下文token限制为160k
- 禁用provider_pools.json.example中所有provider的健康检查
- 更新api-potluck插件描述添加管理端和用户端链接
2026-01-11 23:07:02 +08:00
Zhafron Kautsar
d26b4ee162
feat(kiro): implement extended thinking support with streaming and token estimation
...
Add comprehensive support for Claude's extended thinking feature in Kiro provider:
- Add thinking block parsing and streaming with proper tag detection
- Implement thinking prefix injection in system prompts with budget validation
- Add bidirectional conversion between Kiro text format and Claude content blocks
- Enhance token estimation with detailed breakdown for thinking, tools, and content types
- Fix streaming to properly handle thinking blocks with start/stop events
- Improve context usage percentage handling and input token calculation
- Add helper functions for quote-aware tag detection to avoid false positives
2026-01-11 05:06:01 -05:00
Done-0
8b018b562e
fix(kiro): 动态压缩 tools 解决 Claude Code 发送过多工具信息导致的 500 错误
...
问题:
- Claude Code 发送过多工具信息,超出 Kiro API 请求限制导致 500 错误
- 工具包括:内置工具、MCP 工具、Skills
解决方案:
- 先尝试原始大小,超过 20KB 才进行压缩
- 第一步:简化 input_schema,只保留 type/enum/required
- 第二步:按比例缩短 description(最短 50 字符)
- 保留全部工具和 skills 可调用,不丢弃任何工具
效果:
- 80KB+ tools 压缩至 ~15KB
2026-01-10 21:15:08 +08:00
hex2077
2d317e0333
refactor(项目结构): 重构项目目录结构并优化代码组织
...
将常用工具函数移动到utils目录
重构提供商策略模式实现
新增docker-compose构建配置文件
优化UI配置选择器的样式和交互
重构代理工具和API管理模块
更新脚本路径和依赖引用
2026-01-10 18:19:06 +08:00