Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8dcde55
fix: 🐛 更新 Docker 镜像名称为 `nick3/new-api`
nick3 Sep 30, 2025
0585efe
feat(logging): ✨ 增加请求和响应体的日志捕获功能
nick3 Sep 30, 2025
9184ff2
feat(logs): ✨ 添加使用日志详情抽屉组件
nick3 Sep 30, 2025
4de1111
Merge branch 'upstream/main'
nick3 Sep 30, 2025
659f6f8
Merge branch 'QuantumNous:main' into main
nick3 Sep 30, 2025
15abd69
fix(stream_scanner): 🐛 移除日志记录的负载数据
nick3 Sep 30, 2025
35c73c6
chore: bump version to v0.10.0-alpha.1
nick3 Sep 30, 2025
fc5776a
feat(logs): ✨ 添加详细日志保留设置功能
nick3 Sep 30, 2025
2e98091
Merge branch 'QuantumNous:main' into main
nick3 Sep 30, 2025
7fceeaa
feat(logs): ✨ 添加详细日志保留设置功能
nick3 Sep 30, 2025
a9ba7db
Merge branch 'alpha' of github.com:nick3/new-api into alpha
nick3 Sep 30, 2025
32f4884
feat(logs): ✨ 添加 `created_at` 字段索引以优化日志清理性能
nick3 Sep 30, 2025
7851a1b
Merge pull request #1 from nick3/alpha
nick3 Sep 30, 2025
4ddb39a
chore: bump version to v0.10.0-alpha.2
nick3 Sep 30, 2025
9a1c2be
refactor(user-settings): 🔧 移除 `recordIpLog` 字段及相关逻辑
nick3 Oct 1, 2025
52571d1
chore: merge upstream/main into alpha - resolve conflicts in i18n files
nick3 Oct 5, 2025
1ad2181
fix: remove duplicate keys in en.json
nick3 Oct 5, 2025
2b32de7
Merge branch 'upstream/main' into alpha
nick3 Oct 6, 2025
1132bd5
chore: merge upstream/main - resolve zh.json conflict and add topup b…
nick3 Oct 9, 2025
e577c88
Merge branch 'upstream/main' into alpha
nick3 Oct 10, 2025
ab994c8
Merge branch 'upstream/main' into alpha
nick3 Oct 11, 2025
fda94ac
Merge pull request #2 from nick3/alpha
nick3 Oct 13, 2025
340cd63
Merge branch 'upstream/main' into alpha
nick3 Oct 13, 2025
d1715fb
fix: 🐛 修复导入路径以指向正确的模块
nick3 Oct 13, 2025
c599e58
Merge branch 'alpha'
nick3 Oct 13, 2025
79553c0
chore(release): v0.9.7-patch.1
nick3 Oct 13, 2025
34e5aeb
Merge branch 'upstream/main' into alpha
nick3 Oct 14, 2025
9b6fba7
fix: support text columns across dialects
nick3 Oct 14, 2025
a054e6d
Merge branch 'alpha'
nick3 Oct 15, 2025
285b22b
chore(release): v0.9.8\n\nBump VERSION and add release notes for v0.9.8
nick3 Oct 15, 2025
6643bd4
Merge branch 'upstream/main' into alpha
nick3 Oct 15, 2025
b32d052
chore(docker-compose): 🐳 更新 `new-api` 镜像为 `nick3/new-api:latest`
nick3 Oct 15, 2025
948c28d
Merge branch 'main' into alpha
nick3 Oct 15, 2025
d2d1fe3
fix: capture claude streaming logs
nick3 Oct 15, 2025
0001b55
Merge branch 'upstream/main' into alpha
nick3 Oct 16, 2025
3e2d03c
feat: add clipboard copy to usage log messages
nick3 Oct 17, 2025
c8c951c
Merge branch 'upstream/main' into alpha
nick3 Oct 17, 2025
ead0f6e
Merge branch 'upstream/main' into alpha
nick3 Oct 20, 2025
2320577
Merge branch 'upstream/main' into alpha
nick3 Oct 24, 2025
574b400
Merge branch 'upstream/main' into alpha
nick3 Oct 29, 2025
2e38b5b
🔧 chore: add .spec-workflow to gitignore
nick3 Oct 29, 2025
68bb5c6
🔧 fix: aggregate streaming response tokens in usage log detail view
nick3 Oct 29, 2025
7888d2c
chore: add /.serena to gitignore
nick3 Oct 30, 2025
ee06c5f
Merge branch 'upstream/main' into alpha
nick3 Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/docker-image-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
calciumion/new-api
ghcr.io/${{ env.GHCR_REPOSITORY }}
nick3/new-api
ghcr.io/${{ github.repository }}

- name: Build & push single-arch (to both registries)
uses: docker/build-push-action@v6
Expand All @@ -76,10 +76,10 @@ jobs:
platforms: ${{ matrix.platform }}
push: true
tags: |
calciumion/new-api:alpha-${{ matrix.arch }}
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha-${{ matrix.arch }}
ghcr.io/${{ env.GHCR_REPOSITORY }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
nick3/new-api:alpha-${{ matrix.arch }}
nick3/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
ghcr.io/${{ github.repository }}:alpha-${{ matrix.arch }}
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down Expand Up @@ -118,16 +118,16 @@ jobs:
- name: Create & push manifest (Docker Hub - alpha)
run: |
docker buildx imagetools create \
-t calciumion/new-api:alpha \
calciumion/new-api:alpha-amd64 \
calciumion/new-api:alpha-arm64
-t nick3/new-api:alpha \
nick3/new-api:alpha-amd64 \
nick3/new-api:alpha-arm64

- name: Create & push manifest (Docker Hub - versioned alpha)
run: |
docker buildx imagetools create \
-t calciumion/new-api:${VERSION} \
calciumion/new-api:${VERSION}-amd64 \
calciumion/new-api:${VERSION}-arm64
-t nick3/new-api:${VERSION} \
nick3/new-api:${VERSION}-amd64 \
nick3/new-api:${VERSION}-arm64

- name: Log in to GHCR
uses: docker/login-action@v3
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/docker-image-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
calciumion/new-api
# ghcr.io/${{ env.GHCR_REPOSITORY }}
nick3/new-api
ghcr.io/${{ github.repository }}

- name: Build & push single-arch (to both registries)
uses: docker/build-push-action@v6
Expand All @@ -73,10 +73,10 @@ jobs:
platforms: ${{ matrix.platform }}
push: true
tags: |
calciumion/new-api:${{ env.TAG }}-${{ matrix.arch }}
calciumion/new-api:latest-${{ matrix.arch }}
# ghcr.io/${{ env.GHCR_REPOSITORY }}:${{ env.TAG }}-${{ matrix.arch }}
# ghcr.io/${{ env.GHCR_REPOSITORY }}:latest-${{ matrix.arch }}
nick3/new-api:${{ env.TAG }}-${{ matrix.arch }}
nick3/new-api:latest-${{ matrix.arch }}
# ghcr.io/${{ github.repository }}:${{ env.TAG }}-${{ matrix.arch }}
# ghcr.io/${{ github.repository }}:latest-${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down Expand Up @@ -104,16 +104,16 @@ jobs:
- name: Create & push manifest (Docker Hub - version)
run: |
docker buildx imagetools create \
-t calciumion/new-api:${TAG} \
calciumion/new-api:${TAG}-amd64 \
calciumion/new-api:${TAG}-arm64
-t nick3/new-api:${TAG} \
nick3/new-api:${TAG}-amd64 \
nick3/new-api:${TAG}-arm64

- name: Create & push manifest (Docker Hub - latest)
run: |
docker buildx imagetools create \
-t calciumion/new-api:latest \
calciumion/new-api:latest-amd64 \
calciumion/new-api:latest-arm64
-t nick3/new-api:latest \
nick3/new-api:latest-amd64 \
nick3/new-api:latest-arm64

# ---- GHCR ----
# - name: Log in to GHCR
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ new-api
tiktoken_cache
.eslintcache
.gocache
/.spec-workflow

electron/node_modules
electron/dist
/.serena
29 changes: 29 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Repository Guidelines

## Project Structure & Module Organization
- `main.go` launches the Gin backend, loading cross-cutting helpers from `middleware/`, `logger/`, and configuration in `setting/`.
- HTTP flow maps from `router/` to handler logic in `controller/`, with business services in `service/`, persistence in `model/`, and shared contracts in `dto/` and `types/`.
- Frontend lives in `web/` (Vite + Bun), shared utilities in `common/` and `constant/`, docs in `docs/`, and maintenance scripts or migrations in `bin/`.

## Build, Test, and Development Commands
- `go run main.go` or `make start-backend` runs the API against the active `.env`; use `go build ./...` before raising a PR.
- Inside `web/`, execute `bun install` then `bun run dev`; bundle assets with `make build-frontend` when preparing releases.
- `docker compose up -d` spins up supporting services for end-to-end checks; shut down with `docker compose down`.

## Coding Style & Naming Conventions
- Back-end code must pass `gofmt` and `go vet ./...`; keep packages single-purpose and exported identifiers in PascalCase, internals in camelCase.
- Prefer dependency injection through interfaces, avoid cyclic imports, and centralize shared constants in `constant/`.
- Frontend follows Prettier (`bun run lint:fix`) and ESLint (`bun run eslint:fix`); stick to functional components, hook-based state, and kebab-case filenames in `web/public/`.
- Add new configuration keys to `.env.example` using uppercase snake_case with concise inline notes.

## Testing Guidelines
- Write table-driven `*_test.go` cases alongside implementation and run `go test ./... -race`; mock external services via interfaces.
- Use `bin/time_test.sh <domain> <key> <count> [model]` for latency baselines and document findings in PRs; add Vitest specs under `web/src/__tests__/` as UI logic grows.

## Commit & Pull Request Guidelines
- Follow the repository’s Conventional Commit pattern (`fix:`, `feat:`, `chore:`) with subjects ≤72 characters and informative bodies.
- PRs should outline scope, risk, verification, linked issues, and include screenshots or payload samples when altering UX or APIs; confirm Go build/test and frontend lint/build before requesting review.

## Security & Configuration Tips
- Keep secrets out of version control; rely on `.env` locally and managed secret stores in deployment.
- Rotate provider credentials through the admin console and document operational changes in `docs/`.
34 changes: 34 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Release v0.9.8

Release date: 2025-10-15

Summary
- Minor release: small improvements and housekeeping following v0.9.7-patch.1. No breaking API changes.

Notable changes
- Chore: Bump version to v0.9.8 and update release metadata.
- Chore: Prepare release notes.

Migration notes
- No database migrations required.

Contact
- If you see any issues after upgrading, please open an issue or contact the maintainers.

# Release v0.9.7-patch.1

Release date: 2025-10-13

Summary
- Patch release to address minor regressions and housekeeping after the alpha cycle. This does not introduce new public APIs.

Notable fixes
- Fix: Restore backwards-compatible behavior in configuration parsing that could break some deployments.
- Fix: Correct logging header to include request IDs for certain background jobs.
- Chore: Bump version and update release metadata.

Migration notes
- No database migrations required.

Contact
- If you see any issues after upgrading, please open an issue or contact the maintainers.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.9.8
20 changes: 20 additions & 0 deletions bin/add_log_detail_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Migration: Add index on log_details.created_at for efficient retention cleanup
-- Date: 2025-09-30
-- Purpose: Optimize the log detail retention cleanup process by adding an index
-- on the created_at column to avoid full table scans during deletion.

-- Check if index exists before creating (for MySQL/MariaDB)
-- For existing databases, run this migration to add the index:

CREATE INDEX IF NOT EXISTS idx_log_details_created_at ON log_details(created_at);

-- For PostgreSQL, use:
-- CREATE INDEX IF NOT EXISTS idx_log_details_created_at ON log_details(created_at);

-- For SQLite:
-- CREATE INDEX IF NOT EXISTS idx_log_details_created_at ON log_details(created_at);

-- Verify the index was created:
-- MySQL: SHOW INDEX FROM log_details WHERE Key_name = 'idx_log_details_created_at';
-- PostgreSQL: SELECT * FROM pg_indexes WHERE tablename = 'log_details' AND indexname = 'idx_log_details_created_at';
-- SQLite: SELECT * FROM sqlite_master WHERE type = 'index' AND tbl_name = 'log_details' AND name = 'idx_log_details_created_at';
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var DebugEnabled bool
var MemoryCacheEnabled bool

var LogConsumeEnabled = true
var DetailedLogRetentionDays = 30

var SMTPServer = ""
var SMTPPort = 587
Expand Down
15 changes: 9 additions & 6 deletions common/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ import (
const KeyRequestBody = "key_request_body"

func GetRequestBody(c *gin.Context) ([]byte, error) {
requestBody, _ := c.Get(KeyRequestBody)
if requestBody != nil {
return requestBody.([]byte), nil
if cached, ok := c.Get(KeyRequestBody); ok {
if data, ok := cached.([]byte); ok {
return data, nil
}
}
requestBody, err := io.ReadAll(c.Request.Body)
raw, err := io.ReadAll(c.Request.Body)
if err != nil {
return nil, err
}
_ = c.Request.Body.Close()
c.Set(KeyRequestBody, requestBody)
return requestBody.([]byte), nil
CapturePayloadForLog(c, constant.ContextKeyLoggedRequestBody, raw)
c.Set(KeyRequestBody, raw)
c.Request.Body = io.NopCloser(bytes.NewBuffer(raw))
return raw, nil
}

func UnmarshalBodyReusable(c *gin.Context, v any) error {
Expand Down
Loading