mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-30 11:01:51 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48ae0ef22e | ||
|
|
253a8eeac3 | ||
|
|
1481694b97 |
No files matched your search
+7
-1
@@ -4,15 +4,21 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.3.31] - 2026-11-23
|
||||
|
||||
### 新增与改进
|
||||
|
||||
- 新增一键备份与迁移(#160):在系统配置中下载包含数据库、任务工作区、会话、流量、证据、归档包、MITM 证书和 skills 的单个备份文件,并可在另一实例上传恢复。恢复先校验备份,再在重启时整体替换;数据库替换失败时保留原数据,中断后下次启动继续完成文件替换。
|
||||
- 支持热更新运行中任务的 Worker 并发:任务详情可设置 0(跟随全局)或 1–50;全局工作并发与 Worker 池变更会同步至跟随全局的任务。增容立即补起 Worker,缩容等待当前意图完成后退出,不中断正在执行的工作;详情展示实际存活 Worker 数与目标数。配置持久化,重启恢复时沿用。
|
||||
- 新增原生 Google Gemini API(`gemini`)协议支持(#170):可直接接入 Google AI Studio 或原生兼容网关,支持流式与非流式调用、Base URL 自动归一化及模型列表拉取,并在设置页与类型定义中补齐对应配置说明。
|
||||
- 新增发现页历史漏洞一键清理功能(#157):支持按「全部 / 当前筛选 / 已勾选」范围通过 `DELETE /api/exploration/findings` 原子删除漏洞记录及其来源探索节点、复测记录和归并关系,命中归档或软删中任务时自动拦截返回 409。
|
||||
- 支持热更新运行中任务的 Worker 并发(#171):任务详情可设置 0(跟随全局)或 1–50;全局工作并发与 Worker 池变更会同步至跟随全局的任务。增容立即补起 Worker,缩容等待当前意图完成后退出,不中断正在执行的工作;详情展示实际存活 Worker 数与目标数。配置持久化,重启恢复时沿用。
|
||||
- `PATCH /api/tasks/{id}` 新增 `worker_count`;任务接口返回 `worker_actual_count`(存活池循环,含缩容等待中的 Worker)与 `worker_target_count`(有效目标数),与 `in_flight`(执行中意图数)区分。
|
||||
- 更新 README,补充 ChainReactors 品牌标识、上游 `Autumn-27/ARTEX` 分支说明及商业授权与贡献协议提示。
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复运行中任务仍使用旧 Worker 池模型配置的问题(#141):即使并发数和 slot 名称不变,保存新的 profile 绑定也会替换运行时 Worker;旧配置不可用的空闲 Worker 立即退出,正在执行的 Worker 完成当前意图后切换,新意图不再由旧绑定领取。任务模型链不覆盖显式 Worker 池绑定,历史 blocked 意图不自动重跑。
|
||||
- 修复请求重发器(Repeater)将原始请求目标重新解析并规范化 URL 的问题(#163):前后端拆分 scheme/authority 与原始 request-target,避免查询串特殊字符被自动百分号编码或 `../` 路径段被折叠。
|
||||
|
||||
## [0.3.30] - 2026-11-14
|
||||
|
||||
|
||||
+5
-2
@@ -337,8 +337,9 @@ func (c Config) newProvider(client *http.Client, limiter *RequestLimiter) (llm.P
|
||||
}
|
||||
|
||||
// IsQuotaExhaustedMessage deliberately recognizes only explicit balance,
|
||||
// billing, credit, or quota-exhaustion signals. Generic 429/rate-limit text,
|
||||
// authentication failures, network errors, and server failures are excluded.
|
||||
// billing, credit, quota, or account/plan usage-limit exhaustion signals.
|
||||
// Generic 429/rate-limit text, authentication failures, network errors, and
|
||||
// server failures are excluded.
|
||||
var nonFailoverHTTPStatus = regexp.MustCompile(`(?:status(?:\s+code)?|http(?:\s+status)?)\s*[=:]?\s*(?:401|403|5\d\d)\b`)
|
||||
var transientQuotaLimit = regexp.MustCompile(`(?i)(?:\b(?:rpm|tpm|rpd|qps)\b|quota[_\s-]*metric|rate[_\s-]*limit|too many requests|(?:requests?|tokens?)\s+(?:per|/)\s*(?:second|minute)|(?:per|/)\s*(?:second|minute)\s+(?:requests?|tokens?)|generate[_\s-]*requests[_\s-]*per[_\s-]*(?:minute|second)|tokens?[_\s-]*per[_\s-]*(?:minute|second))`)
|
||||
|
||||
@@ -360,6 +361,8 @@ func IsQuotaExhaustedMessage(message string) bool {
|
||||
"exceeded your current quota", "billing_hard_limit_reached",
|
||||
"billing hard limit", "billing_not_active", "credit balance", "insufficient credit",
|
||||
"insufficient balance", "balance is too low", "payment required", "status 402",
|
||||
"gousagelimiterror", "usage limit reached", "usage_limit_reached",
|
||||
"usage limit exceeded", "exceeded your usage limit", "reached your usage limit",
|
||||
"余额不足", "额度不足", "额度已用尽", "欠费",
|
||||
}
|
||||
for _, marker := range markers {
|
||||
|
||||
@@ -25,6 +25,11 @@ func TestIsQuotaExhaustedMessage(t *testing.T) {
|
||||
`billing_not_active`,
|
||||
`credit balance is too low`,
|
||||
`账户余额不足,请充值`,
|
||||
`{"type":"error","error":{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (5-hour, resets in 2h 9m). To keep going now, turn on Extra Usage or upgrade to Go Plus at https://opencode.ai/console/wrk_01KZNXXXXXXXXXXXXXXXDJFJH/go."},"metadata":{"workspace":"wrk_01KZNXXXXXXXXXXXXXXXXTEDJFJH","limitName":"5 hour"}}`,
|
||||
`{"error":{"code":"usage_limit_reached","message":"plan window exhausted"}}`,
|
||||
`monthly usage limit exceeded`,
|
||||
`You have exceeded your usage limit`,
|
||||
`You have reached your usage limit`,
|
||||
}
|
||||
for _, message := range positive {
|
||||
if !IsQuotaExhaustedMessage(message) {
|
||||
@@ -40,6 +45,10 @@ func TestIsQuotaExhaustedMessage(t *testing.T) {
|
||||
`RESOURCE_EXHAUSTED: TPM quota exceeded`,
|
||||
`tokens per minute quota exceeded`,
|
||||
`rate_limit_exceeded: requests per second`,
|
||||
`rate_limit_error: usage limit reached`,
|
||||
`too many requests: usage limit exceeded`,
|
||||
`RPM usage limit exceeded`,
|
||||
`requests per minute usage limit reached`,
|
||||
`status 401: invalid api key`,
|
||||
`status 401: insufficient_quota`,
|
||||
`HTTP 403: billing_hard_limit_reached`,
|
||||
@@ -63,6 +72,12 @@ func TestQuotaAwareTransportOnlyNormalizesExplicitQuota429(t *testing.T) {
|
||||
wantStatus int
|
||||
}{
|
||||
{name: "quota", status: http.StatusTooManyRequests, body: `{"code":"insufficient_quota"}`, wantStatus: http.StatusPaymentRequired},
|
||||
{
|
||||
name: "opencode go usage limit",
|
||||
status: http.StatusTooManyRequests,
|
||||
body: `{"type":"error","error":{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (5-hour, resets in 2h 9m)."},"metadata":{"limitName":"5 hour"}}`,
|
||||
wantStatus: http.StatusPaymentRequired,
|
||||
},
|
||||
{name: "ordinary rate limit", status: http.StatusTooManyRequests, body: `{"message":"rate limit exceeded"}`, wantStatus: http.StatusTooManyRequests},
|
||||
{name: "server error", status: http.StatusInternalServerError, body: `insufficient_quota`, wantStatus: http.StatusInternalServerError},
|
||||
}
|
||||
@@ -129,3 +144,32 @@ func TestProviderDoesNotRetryExplicitQuota429(t *testing.T) {
|
||||
t.Fatalf("explicit quota request retried %d times, want exactly one request", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderCompleteDoesNotRetryOpenCodeGoUsageLimit429(t *testing.T) {
|
||||
t.Parallel()
|
||||
var requests atomic.Int32
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
requests.Add(1)
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
_, _ = io.WriteString(w, `{"type":"error","error":{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (5-hour, resets in 2h 9m). To keep going now, turn on Extra Usage or upgrade to Go Plus at https://opencode.ai/console/wrk_01KZNXXXXXXXXXXXXXXXDJFJH/go."},"metadata":{"workspace":"wrk_01KZNXXXXXXXXXXXXXXXXTEDJFJH","limitName":"5 hour"}}`)
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
provider, err := ConfigFrom("openai", "test-model", upstream.URL, "test-key", "").NewProvider()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _, _, err = provider.Complete(context.Background(), llm.CompletionRequest{
|
||||
Messages: []llm.Message{llm.UserText("ping")},
|
||||
})
|
||||
if err == nil || !IsQuotaExhaustedMessage(err.Error()) {
|
||||
t.Fatalf("expected explicit quota error, got %v", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "status 402") {
|
||||
t.Fatalf("expected 429 normalized to status 402, got %v", err)
|
||||
}
|
||||
if got := requests.Load(); got != 1 {
|
||||
t.Fatalf("OpenCode Go usage limit 429 retried %d times, want 1", got)
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -119,6 +123,8 @@ func TestIsQuotaExhaustedError(t *testing.T) {
|
||||
`HTTP status 402 Payment Required`,
|
||||
`账户余额不足,请充值`,
|
||||
`credit balance is too low`,
|
||||
`openai: status 429: {"type":"error","error":{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (5-hour, resets in 2h 9m)."}}`,
|
||||
`openai: status 402: {"error":{"code":"usage_limit_reached"}}`,
|
||||
}
|
||||
for _, message := range positive {
|
||||
if !isQuotaExhaustedError(errors.New(message)) {
|
||||
@@ -131,6 +137,8 @@ func TestIsQuotaExhaustedError(t *testing.T) {
|
||||
`RESOURCE_EXHAUSTED: rate limit exceeded`,
|
||||
`HTTP status 429: quota exceeded for quota metric GenerateRequestsPerMinutePerProjectPerBaseModel`,
|
||||
`RESOURCE_EXHAUSTED: TPM quota exceeded`,
|
||||
`HTTP status 429: rate_limit_error: usage limit reached`,
|
||||
`HTTP status 429: too many requests: usage limit exceeded`,
|
||||
`HTTP status 401: invalid api key`,
|
||||
`HTTP status 401: insufficient_quota`,
|
||||
`HTTP status 403: forbidden`,
|
||||
@@ -275,6 +283,73 @@ func TestTaskLLMStreamRetriesPreStreamQuotaOnNextProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskLLMCompleteFailsOverOnOpenCodeGoUsageLimit(t *testing.T) {
|
||||
t.Parallel()
|
||||
var firstCalls, secondCalls atomic.Int32
|
||||
firstServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
firstCalls.Add(1)
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
_, _ = io.WriteString(w, `{"type":"error","error":{"type":"GoUsageLimitError","message":"OpenCode Go usage limit reached (5-hour, resets in 2h 9m). To keep going now, turn on Extra Usage or upgrade to Go Plus at https://opencode.ai/console/wrk_01KZNXXXXXXXXXXXXXXXDJFJH/go."},"metadata":{"workspace":"wrk_01KZNXXXXXXXXXXXXXXXXTEDJFJH","limitName":"5 hour"}}`)
|
||||
}))
|
||||
defer firstServer.Close()
|
||||
|
||||
secondServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
secondCalls.Add(1)
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = io.WriteString(w, `{"id":"chatcmpl-1","object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"fallback-ok"},"finish_reason":"stop"}],"usage":{"prompt_tokens":1,"completion_tokens":1}}`)
|
||||
}))
|
||||
defer secondServer.Close()
|
||||
|
||||
firstProv, err := agent.ConfigFrom("openai", "test-model", firstServer.URL, "key-1", "").NewProvider()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
secondProv, err := agent.ConfigFrom("openai", "test-model", secondServer.URL, "key-2", "").NewProvider()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
active := int64(11)
|
||||
transitions := 0
|
||||
var exhaustCause error
|
||||
hooks := taskLLMStreamHooks{
|
||||
current: func() (taskLLMSelection, error) {
|
||||
if active == 11 {
|
||||
return taskLLMSelection{profileID: 11, provider: firstProv}, nil
|
||||
}
|
||||
return taskLLMSelection{profileID: 22, provider: secondProv}, nil
|
||||
},
|
||||
exhaust: func(selection taskLLMSelection, cause error) (db.TaskLLMTransition, error) {
|
||||
if selection.profileID != 11 {
|
||||
t.Fatalf("unexpected exhausted profile %d", selection.profileID)
|
||||
}
|
||||
exhaustCause = cause
|
||||
active = 22
|
||||
next := active
|
||||
return db.TaskLLMTransition{PreviousProfileID: 11, NextProfileID: &next, Advanced: true}, nil
|
||||
},
|
||||
transition: func(taskLLMSelection, db.TaskLLMTransition, error) { transitions++ },
|
||||
}
|
||||
|
||||
msg, _, _, err := completeTaskLLM(context.Background(), "9", llm.CompletionRequest{
|
||||
Messages: []llm.Message{llm.UserText("ping")},
|
||||
}, hooks)
|
||||
if err != nil {
|
||||
t.Fatalf("expected failover to succeed, got %v", err)
|
||||
}
|
||||
if got := msg.Text(); got != "fallback-ok" {
|
||||
t.Fatalf("reply=%q, want fallback-ok", got)
|
||||
}
|
||||
if firstCalls.Load() != 1 || secondCalls.Load() != 1 || transitions != 1 {
|
||||
t.Fatalf("calls first=%d second=%d transitions=%d, want 1/1/1", firstCalls.Load(), secondCalls.Load(), transitions)
|
||||
}
|
||||
if exhaustCause == nil || !strings.Contains(exhaustCause.Error(), "status 402") {
|
||||
t.Fatalf("exhaustCause=%v, want normalized status 402", exhaustCause)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskLLMStreamRetriesAfterNonContentStartEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
quota := errors.New("anthropic: status 402: insufficient credit balance")
|
||||
|
||||
Reference in new issue
Block a user