Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0409dec
fix(deepseek): map developer role to system for chat completions (#8287)
seefs001 Nov 10, 2026
579573a
feat(payment): 易支付支持 RSA 签名方式 (#8291)
Calcium-Ion Nov 11, 2026
be5e315
fix(channels): 切换渠道时重置模型重定向同步状态 (#8304)
scarletkc Nov 11, 2026
a9932d1
fix(web): sync risk confirmation text on composition end and blur
Calcium-Ion Nov 12, 2026
f3d8b73
perf: 升级 MoeForge moejs/moego,请求体按需流式读取 (#8311)
Calcium-Ion Nov 12, 2026
7b857f5
feat(plugins): add provider plugins, request plugins and a community …
Calcium-Ion Nov 12, 2026
f2aa912
chore(plugins): release vertex-ai 1.3.1 (#8313)
Calcium-Ion Nov 12, 2026
0bda086
chore(web-deps): upgrade frontend dependencies (#6999)
QuentinHsu Nov 12, 2026
6ef123c
perf(password): improve password validation and feedback (#6928)
QuentinHsu Nov 13, 2026
87c8848
fix(i18n): name the super admin in the compliance lock notice (#6955)
QuentinHsu Nov 13, 2026
b20e056
fix(web): align TanStack router devtools with the router core (#8320)
Calcium-Ion Nov 13, 2026
1122e0f
fix(web): keep channel plugin settings inside the drawer (#8323)
seefs001 Nov 13, 2026
c9c6da2
fix: 升级 moego 到 v0.1.0-alpha.3,修复无 AVX 的 x86-64 CPU 上的 SIGILL 崩溃 (#8322)
Calcium-Ion Nov 13, 2026
e00ec88
feat: add doubao-seedream-5-5-261028 (#8324)
feitianbubu Nov 13, 2026
b388140
docs(plugins): recommend a summary length that fits one marketplace line
Calcium-Ion Nov 13, 2026
e2c79a5
chore: merge upstream main (b388140ac) into fork-main
AdoreJc Nov 14, 2026
45a2e65
fix(moderation): 适配上游退役全局敏感词检查
AdoreJc Nov 14, 2026
a19af8e
test(web): 支付设置测试补齐两边新增的表单字段
AdoreJc Nov 14, 2026
299e7f6
chore: merge fork-main (83fdd4e80) into sync/upstream-b388140ac
AdoreJc Nov 14, 2026
a8def85
fix(moderation): 升级时把原敏感词复制成 default 关键词表
AdoreJc Nov 14, 2026
849e0b6
chore: merge fork-main (9682b8d8a) into sync/upstream-b388140ac
AdoreJc Nov 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
# TASK_TIMEOUT_MINUTES=4320
# 异步任务连续轮询失败阈值(上游 429/5xx/401/403、网络错误、无法识别的响应),达到后任务标记失败并退款;正常轮询成功一次即归零
# TASK_POLL_MAX_FAILURES=20
# 插件每次调用的 JavaScript 最多可分配的内存,单位 MB,默认 512,0 表示不限制;调大 MAX_REQUEST_BODY_MB 时通常也要调大
# PLUGIN_MEMORY_LIMIT_MB=512

# 对话超时设置
# 所有请求超时时间,单位秒,默认为0,表示不限制
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/electron-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
if: runner.os == 'Windows'
run: |
go mod download
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(git describe --tags)'" -o new-api.exe
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(git describe --tags)'" -o new-api.exe

- name: Update Electron version
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:
- name: Build Backend (amd64)
run: |
go mod download
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-$VERSION
- name: Build Backend (arm64)
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y gcc-aarch64-linux-gnu
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-arm64-$VERSION
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION' -extldflags '-static'" -o new-api-arm64-$VERSION
- name: Generate checksums
run: sha256sum new-api-* > checksums-linux.txt

Expand All @@ -64,6 +64,7 @@ jobs:
files: |
new-api-*
checksums-linux.txt
THIRD-PARTY-LICENSES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -102,7 +103,7 @@ jobs:
- name: Build Backend
run: |
go mod download
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-X 'github.com/QuantumNous/new-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-X 'github.com/QuantumNous/new-api/common.Version=$VERSION'" -o new-api-macos-$VERSION
- name: Generate checksums
run: shasum -a 256 new-api-macos-* > checksums-macos.txt

Expand Down Expand Up @@ -153,7 +154,7 @@ jobs:
- name: Build Backend
run: |
go mod download
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$VERSION'" -o new-api-$VERSION.exe
- name: Generate checksums
run: sha256sum new-api-*.exe > checksums-windows.txt

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN go mod download

COPY . .
COPY --from=builder /build/web/dist ./web/dist
RUN go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api
RUN go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(cat VERSION)'" -o new-api

FROM debian:bookworm-slim@sha256:f06537653ac770703bc45b4b113475bd402f451e85223f0f2837acbf89ab020a

Expand Down
396 changes: 393 additions & 3 deletions THIRD-PARTY-LICENSES.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion common/api_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
}
if apiType == -1 {
// Task plugin channels are served by the task relay and must never
// fall back to the OpenAI adaptor.
// fall back to the OpenAI adaptor. A plugin with relay routes gets
// APITypeProviderPlugin from the selected channel's context instead.
if channelType == constant.ChannelTypeTaskPlugin {
return -1, false
}
Expand All @@ -100,6 +101,7 @@ func SupportsResponsesCompact(channelType, apiType int) bool {
case constant.APITypeOpenAI,
constant.APITypeCodex,
constant.APITypeAdvancedCustom,
constant.APITypeProviderPlugin,
constant.APITypeSub2API,
constant.APITypeNewAPI:
return true
Expand Down
91 changes: 80 additions & 11 deletions common/body_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"sync"
"sync/atomic"
"time"

"github.com/MoeForge/moego/ojson"
)

// BodyStorage 请求体存储接口
type BodyStorage interface {
io.ReadSeeker
io.Closer
// Bytes 获取全部内容
// Bytes returns read-only contents. Store edits in a new BodyStorage;
// decoded strings and raw JSON may still refer to these bytes.
Bytes() ([]byte, error)
// Size 获取数据大小
Size() int64
Expand All @@ -37,6 +41,26 @@ type ReplayableBody interface {
NewReader() (io.ReadCloser, error)
}

// ReadBodyJSONFields returns owned copies of the requested values. For valid JSON,
// simple member and array-index paths read disk storage through a bounded window.
func ReadBodyJSONFields(storage BodyStorage, paths ...string) ([]ojson.Result, error) {
if storage.IsDisk() {
reader, err := storage.NewReader()
if err != nil {
return nil, err
}
defer reader.Close()
if readerAt, ok := reader.(io.ReaderAt); ok {
return ojson.GetManyReaderAt(readerAt, storage.Size(), paths...)
}
}
data, err := storage.Bytes()
if err != nil {
return nil, err
}
return ojson.GetManyBytes(data, paths...), nil
}

// ErrStorageClosed 存储已关闭错误
var ErrStorageClosed = fmt.Errorf("body storage is closed")

Expand Down Expand Up @@ -92,7 +116,9 @@ func (m *memoryStorage) Bytes() ([]byte, error) {
if atomic.LoadInt32(&m.closed) == 1 {
return nil, ErrStorageClosed
}
return m.data, nil
// Without spare capacity an append by one reader cannot write where
// another reader's append landed.
return m.data[:len(m.data):len(m.data)], nil
}

func (m *memoryStorage) NewReader() (io.ReadCloser, error) {
Expand Down Expand Up @@ -282,7 +308,8 @@ func (d *diskStorage) IsDisk() bool {
return true
}

// CreateBodyStorage 根据数据大小创建合适的存储
// CreateBodyStorage stores data in memory or on disk according to cache settings.
// It takes ownership of data; callers must keep its backing array immutable.
func CreateBodyStorage(data []byte) (BodyStorage, error) {
size := int64(len(data))
threshold := GetDiskCacheThresholdBytes()
Expand Down Expand Up @@ -347,27 +374,69 @@ func CreateBodyStorageFromReader(reader io.Reader, contentLength int64, maxBytes
return storage, nil
}

// replayableBodyReader is the body of one outbound request. It reads through a
// cursor of its own, opened on the first Read: the shared storage cursor would
// let a transport still writing an earlier attempt, or any GetBodyStorage seek,
// move the position of this one. EOF and Close release only that cursor.
type replayableBodyReader struct {
storage BodyStorage
mu sync.Mutex
cursor io.ReadCloser
ended bool
closed bool
}

func (r replayableBodyReader) Read(p []byte) (int, error) {
return r.storage.Read(p)
func (r *replayableBodyReader) Read(p []byte) (int, error) {
r.mu.Lock()
defer r.mu.Unlock()
if r.closed {
return 0, http.ErrBodyReadAfterClose
}
if r.ended {
return 0, io.EOF
}
if r.cursor == nil {
cursor, err := r.storage.NewReader()
if err != nil {
return 0, err
}
r.cursor = cursor
}
n, err := r.cursor.Read(p)
if err == io.EOF {
r.ended = true
_ = r.cursor.Close()
r.cursor = nil
}
return n, err
}

// Close releases this request's cursor. The storage stays open for GetBody
// replays and is closed by its owner.
func (r *replayableBodyReader) Close() error {
r.mu.Lock()
defer r.mu.Unlock()
r.closed = true
if r.cursor == nil {
return nil
}
err := r.cursor.Close()
r.cursor = nil
return err
}

func (r replayableBodyReader) Size() int64 {
func (r *replayableBodyReader) Size() int64 {
return r.storage.Size()
}

func (r replayableBodyReader) NewReader() (io.ReadCloser, error) {
func (r *replayableBodyReader) NewReader() (io.ReadCloser, error) {
return r.storage.NewReader()
}

// NewReplayableBodyReader exposes the replay capabilities of storage without
// exposing io.Closer. This keeps ownership of the storage lifecycle with the
// caller instead of allowing net/http to close it as the request body.
// NewReplayableBodyReader returns a request body over storage with its own
// cursor. Closing the body, as net/http does, never closes the storage.
func NewReplayableBodyReader(storage BodyStorage) ReplayableBody {
return replayableBodyReader{storage: storage}
return &replayableBodyReader{storage: storage}
}

// CleanupOldCacheFiles 清理旧的缓存文件(用于启动时清理残留)
Expand Down
Loading