Skip to content

Commit 2016a1b

Browse files
committed
revert: restore pre-plugin-migration code
1 parent 1bfbd8e commit 2016a1b

263 files changed

Lines changed: 4278 additions & 40618 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@ updates:
2020
directory: /cliproxyapi-pro-plugins/oauth-model-policy
2121
schedule:
2222
interval: weekly
23-
- package-ecosystem: gomod
24-
directory: /cliproxyapi-pro-plugins/pro-observability
25-
schedule:
26-
interval: weekly

.github/workflows/release-core.yml

Lines changed: 157 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,6 @@ jobs:
285285
cp "${tmp_dir}/arm64/plugins/linux/arm64/proxy-pool.so" "${context_dir}/plugins/linux/arm64/proxy-pool.so"
286286
cp "${tmp_dir}/amd64/plugins/linux/amd64/oauth-model-policy.so" "${context_dir}/plugins/linux/amd64/oauth-model-policy.so"
287287
cp "${tmp_dir}/arm64/plugins/linux/arm64/oauth-model-policy.so" "${context_dir}/plugins/linux/arm64/oauth-model-policy.so"
288-
cp "${tmp_dir}/amd64/plugins/linux/amd64/pro-observability.so" "${context_dir}/plugins/linux/amd64/pro-observability.so"
289-
cp "${tmp_dir}/arm64/plugins/linux/arm64/pro-observability.so" "${context_dir}/plugins/linux/arm64/pro-observability.so"
290288
cp "${tmp_dir}/amd64/config.example.yaml" "${context_dir}/config.example.yaml"
291289
cp customizations-repo/cliproxyapi-pro-core/entrypoint.sh "${context_dir}/entrypoint.sh"
292290
cp customizations-repo/cliproxyapi-pro-core/Dockerfile.runtime "${context_dir}/Dockerfile.runtime"
@@ -300,9 +298,7 @@ jobs:
300298
"${context_dir}/plugins/linux/amd64/proxy-pool.so" \
301299
"${context_dir}/plugins/linux/arm64/proxy-pool.so" \
302300
"${context_dir}/plugins/linux/amd64/oauth-model-policy.so" \
303-
"${context_dir}/plugins/linux/arm64/oauth-model-policy.so" \
304-
"${context_dir}/plugins/linux/amd64/pro-observability.so" \
305-
"${context_dir}/plugins/linux/arm64/pro-observability.so"
301+
"${context_dir}/plugins/linux/arm64/oauth-model-policy.so"
306302
307303
- name: Set up QEMU
308304
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
@@ -367,6 +363,14 @@ jobs:
367363
asset_arch: amd64
368364
archive_format: zip
369365
asset_suffix: ""
366+
- target: windows-arm64-no-plugin
367+
kind: no-plugin
368+
runner: windows-11-arm
369+
goos: windows
370+
goarch: arm64
371+
asset_arch: aarch64
372+
archive_format: zip
373+
asset_suffix: _no-plugin
370374
- target: linux-amd64
371375
kind: linux-glibc-plugin
372376
runner: ubuntu-latest
@@ -385,6 +389,46 @@ jobs:
385389
archive_format: tar.gz
386390
asset_suffix: ""
387391
manylinux_image: quay.io/pypa/manylinux2014_aarch64@sha256:ae34a6ceeefe0b535c525b2e96f297311c8f1e01cfd8b9be5f647eece5b5c60b
392+
- target: linux-amd64-no-plugin
393+
kind: no-plugin
394+
runner: ubuntu-latest
395+
goos: linux
396+
goarch: amd64
397+
asset_arch: amd64
398+
archive_format: tar.gz
399+
asset_suffix: _no-plugin
400+
- target: linux-arm64-no-plugin
401+
kind: no-plugin
402+
runner: ubuntu-latest
403+
goos: linux
404+
goarch: arm64
405+
asset_arch: aarch64
406+
archive_format: tar.gz
407+
asset_suffix: _no-plugin
408+
- target: freebsd-amd64
409+
kind: freebsd-plugin
410+
runner: ubuntu-latest
411+
goos: freebsd
412+
goarch: amd64
413+
asset_arch: amd64
414+
archive_format: tar.gz
415+
asset_suffix: ""
416+
- target: freebsd-amd64-no-plugin
417+
kind: no-plugin
418+
runner: ubuntu-latest
419+
goos: freebsd
420+
goarch: amd64
421+
asset_arch: amd64
422+
archive_format: tar.gz
423+
asset_suffix: _no-plugin
424+
- target: freebsd-arm64-no-plugin
425+
kind: no-plugin
426+
runner: ubuntu-latest
427+
goos: freebsd
428+
goarch: arm64
429+
asset_arch: aarch64
430+
archive_format: tar.gz
431+
asset_suffix: _no-plugin
388432

389433
permissions:
390434
contents: read
@@ -486,7 +530,7 @@ jobs:
486530
if [ "${GOOS}" = "windows" ]; then plugin_extension="dll"; fi
487531
mkdir -p "${archive_dir}/plugins/${GOOS}/${GOARCH}"
488532
plugin_relatives=()
489-
for plugin_name in proxy-pool oauth-model-policy pro-observability; do
533+
for plugin_name in proxy-pool oauth-model-policy; do
490534
plugin_relative="plugins/${GOOS}/${GOARCH}/${plugin_name}.${plugin_extension}"
491535
plugin_source=".${plugin_name}-build"
492536
rm -rf "${plugin_source}"
@@ -524,7 +568,7 @@ jobs:
524568
archive_name="CLIProxyAPI_${RELEASE_TAG#v}_linux_${ASSET_ARCH}.tar.gz"
525569
rm -rf "dist/linux-${GOARCH}"
526570
mkdir -p "${archive_dir}"
527-
for plugin_name in proxy-pool oauth-model-policy pro-observability; do
571+
for plugin_name in proxy-pool oauth-model-policy; do
528572
rm -rf ".${plugin_name}-build"
529573
cp -R "../customizations-repo/cliproxyapi-pro-plugins/${plugin_name}" ".${plugin_name}-build"
530574
done
@@ -562,7 +606,7 @@ jobs:
562606
-o "'"${archive_dir}"'/cli-proxy-api" ./cmd/server/
563607
564608
mkdir -p "'"${archive_dir}"'/plugins/linux/${GOARCH}"
565-
for plugin_name in proxy-pool oauth-model-policy pro-observability; do
609+
for plugin_name in proxy-pool oauth-model-policy; do
566610
go -C ".${plugin_name}-build" mod edit -replace github.com/router-for-me/CLIProxyAPI/v7=/src
567611
CGO_ENABLED=1 GOOS=linux GOARCH="${GOARCH}" go -C ".${plugin_name}-build" build \
568612
-buildvcs=false -trimpath -buildmode=c-shared \
@@ -588,8 +632,110 @@ jobs:
588632
--source-date-epoch "${SOURCE_DATE_EPOCH}" \
589633
cli-proxy-api LICENSE README.md README_EN.md config.example.yaml \
590634
"plugins/linux/${GOARCH}/proxy-pool.so" \
591-
"plugins/linux/${GOARCH}/oauth-model-policy.so" \
592-
"plugins/linux/${GOARCH}/pro-observability.so"
635+
"plugins/linux/${GOARCH}/oauth-model-policy.so"
636+
637+
- name: Install FreeBSD plugin build dependencies
638+
if: matrix.kind == 'freebsd-plugin'
639+
run: |
640+
set -euo pipefail
641+
sudo apt-get update
642+
sudo apt-get install -y clang lld wget
643+
644+
- name: Prepare workspace git metadata for FreeBSD plugin build
645+
if: matrix.kind == 'freebsd-plugin'
646+
env:
647+
BUILD_DATE: ${{ steps.prepare-core.outputs.build_date }}
648+
run: |
649+
set -euo pipefail
650+
git init .
651+
git config user.name "github-actions[bot]"
652+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
653+
GIT_AUTHOR_DATE="${BUILD_DATE}" GIT_COMMITTER_DATE="${BUILD_DATE}" git commit --allow-empty -m "Prepare workspace metadata for cgo action"
654+
655+
- name: Build FreeBSD plugin-capable binary
656+
if: matrix.kind == 'freebsd-plugin'
657+
uses: go-cross/cgo-actions@d0b8f2f2d67923ce9a42d92a7ef0ed1ebd905f0a # v1
658+
env:
659+
GOFLAGS: -buildvcs=false -trimpath
660+
with:
661+
dir: upstream-core
662+
packages: ./cmd/server/
663+
targets: ${{ matrix.goos }}-${{ matrix.goarch }}
664+
out-dir: upstream-core/dist/${{ matrix.target }}/bin
665+
output: cli-proxy-api
666+
flags: -ldflags=-s -w
667+
x-flags: |
668+
main.Version=${{ needs.check-version.outputs.release_tag }}
669+
main.Commit=release-${{ needs.check-version.outputs.core_tag }}
670+
main.BuildDate=${{ steps.prepare-core.outputs.build_date }}
671+
672+
- name: Package FreeBSD plugin-capable archive
673+
if: matrix.kind == 'freebsd-plugin'
674+
env:
675+
RELEASE_TAG: ${{ needs.check-version.outputs.release_tag }}
676+
GOOS: ${{ matrix.goos }}
677+
ASSET_ARCH: ${{ matrix.asset_arch }}
678+
SOURCE_DATE_EPOCH: ${{ steps.prepare-core.outputs.source_date_epoch }}
679+
run: |
680+
set -euo pipefail
681+
cd upstream-core
682+
683+
archive_dir="dist/${{ matrix.target }}/archive"
684+
archive_name="CLIProxyAPI_${RELEASE_TAG#v}_${GOOS}_${ASSET_ARCH}.tar.gz"
685+
mkdir -p "${archive_dir}"
686+
cp "dist/${{ matrix.target }}/bin/cli-proxy-api" "${archive_dir}/cli-proxy-api"
687+
cp LICENSE README.md README_EN.md config.example.yaml "${archive_dir}/"
688+
python ../customizations-repo/scripts/build/create_reproducible_archive.py \
689+
--format tar.gz \
690+
--output "dist/${archive_name}" \
691+
--root "${archive_dir}" \
692+
--source-date-epoch "${SOURCE_DATE_EPOCH}" \
693+
cli-proxy-api LICENSE README.md README_EN.md config.example.yaml
694+
695+
- name: Build no-plugin archive
696+
if: matrix.kind == 'no-plugin'
697+
shell: bash
698+
env:
699+
RELEASE_TAG: ${{ needs.check-version.outputs.release_tag }}
700+
CORE_TAG: ${{ needs.check-version.outputs.core_tag }}
701+
GOOS: ${{ matrix.goos }}
702+
GOARCH: ${{ matrix.goarch }}
703+
ASSET_ARCH: ${{ matrix.asset_arch }}
704+
ARCHIVE_FORMAT: ${{ matrix.archive_format }}
705+
ASSET_SUFFIX: ${{ matrix.asset_suffix }}
706+
BUILD_DATE: ${{ steps.prepare-core.outputs.build_date }}
707+
SOURCE_DATE_EPOCH: ${{ steps.prepare-core.outputs.source_date_epoch }}
708+
run: |
709+
set -euo pipefail
710+
cd upstream-core
711+
712+
binary_name="cli-proxy-api"
713+
if [ "${GOOS}" = "windows" ]; then
714+
binary_name="cli-proxy-api.exe"
715+
fi
716+
717+
archive_dir="dist/${GOOS}-${GOARCH}${ASSET_SUFFIX}/archive"
718+
archive_name="CLIProxyAPI_${RELEASE_TAG#v}_${GOOS}_${ASSET_ARCH}${ASSET_SUFFIX}.${ARCHIVE_FORMAT}"
719+
rm -rf "dist/${GOOS}-${GOARCH}${ASSET_SUFFIX}"
720+
mkdir -p "${archive_dir}"
721+
722+
CGO_ENABLED=0 GOOS="${GOOS}" GOARCH="${GOARCH}" go build -buildvcs=false -trimpath \
723+
-ldflags="-s -w -X main.Version=${RELEASE_TAG} -X main.Commit=release-${CORE_TAG} -X main.BuildDate=${BUILD_DATE}" \
724+
-o "${archive_dir}/${binary_name}" ./cmd/server/
725+
726+
if [ "${GOOS}" = "linux" ] && readelf -l "${archive_dir}/${binary_name}" | grep -q 'Requesting program interpreter'; then
727+
readelf -l "${archive_dir}/${binary_name}" >&2
728+
echo "no-plugin linux binary must not require a dynamic interpreter" >&2
729+
exit 1
730+
fi
731+
732+
cp LICENSE README.md README_EN.md config.example.yaml "${archive_dir}/"
733+
python ../customizations-repo/scripts/build/create_reproducible_archive.py \
734+
--format "${ARCHIVE_FORMAT}" \
735+
--output "dist/${archive_name}" \
736+
--root "${archive_dir}" \
737+
--source-date-epoch "${SOURCE_DATE_EPOCH}" \
738+
"${binary_name}" LICENSE README.md README_EN.md config.example.yaml
593739
594740
- name: Upload core binary assets
595741
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -823,7 +969,7 @@ jobs:
823969
echo "## Assets"
824970
echo
825971
echo "- Pro core default desktop/Linux binaries are built with CGO enabled and support dynamic library plugins when the target platform supports them."
826-
echo "- Pro core release assets require dynamic plugin support because usage persistence is owned by \`pro-observability\`."
972+
echo "- Pro core \`_no-plugin\` binaries are CGO-free portable builds for static or constrained environments."
827973
echo "- Pro Docker images follow upstream with CGO-enabled Debian builds and dynamic library plugin support."
828974
echo "- Pro management panel is published as management.html for automatic panel updates."
829975
echo

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ CLIProxyAPI Pro 是对两个 upstream 项目的最小化定制层集合:
1717
- 路由策略页面统一管理 upstream 路由行为与按 provider 配置的请求状态保护
1818
- 内置动态代理池插件,把多个 HTTP/SOCKS 节点汇聚为固定的本地 SOCKS5 地址,支持轮询、加权、健康隔离与故障转移
1919
- 内置 OAuth 模型策略插件,可按多个提供商的账号套餐分别排除不可用模型,并同步约束模型列表和账号调度
20-
- Pro Observability 插件统一持有 usage、价格、备份、quota cache、路由游标和运行统计,并在启动服务前自动迁移旧 SQLite
2120

2221
## 项目结构
2322

@@ -39,8 +38,7 @@ CLIProxyAPI Pro 是对两个 upstream 项目的最小化定制层集合:
3938
4039
├── cliproxyapi-pro-plugins/
4140
│ ├── proxy-pool/
42-
│ ├── oauth-model-policy/
43-
│ └── pro-observability/
41+
│ └── oauth-model-policy/
4442
4543
├── scripts/validation/
4644
└── .github/workflows/
@@ -59,8 +57,8 @@ CLIProxyAPI Pro 是对两个 upstream 项目的最小化定制层集合:
5957

6058
- 构建 upstream CLIProxyAPI release 的多架构 Docker 镜像。
6159
- 构建与 upstream 平台和打包格式一致的 Pro 二进制 release 资产。
62-
- 通过 required `pro-observability` 插件提供 SQLite usage service 和业务路由
63-
- 暴露兼容的 `/v0/management/usage` 系列 API;Core 仅承载 Management 鉴权和 SSE transport bridge
60+
- 内嵌 SQLite usage service。
61+
- 暴露 `/v0/management/usage` 系列 API,包括状态、增量事件轮询和 SSE
6462
- 支持 usage JSONL/NDJSON 导入导出,包含 usage events、模型价格、quota cache、Pro 设置、路由运行状态、账号巡检调度和最近一次巡检结果快照。
6563
- 支持 WebDAV usage 备份恢复。
6664
- 支持 SQLite-backed quota cache。
@@ -71,7 +69,7 @@ CLIProxyAPI Pro 是对两个 upstream 项目的最小化定制层集合:
7169
- 支持后端账号巡检调度器和执行器,巡检探测前可刷新 token。
7270
- 支持统一路由策略与请求状态保护 API。
7371
- 支持 Komari agent 可选启动。
74-
- 标准 macOS、Windows amd64、Linux Release 和 Docker 镜像预打包并默认启用 `pro-observability`,同时预打包 `proxy-pool``oauth-model-policy``pro-observability` 是唯一的持久化实现;插件缺失或旧 usage 迁移失败时,Core 会阻止代理服务启动
72+
- 标准 macOS、Windows amd64、Linux Release 和 Docker 镜像预打包 `proxy-pool``oauth-model-policy` 动态插件;Windows ARM64、FreeBSD 与 `_no-plugin` 产物暂不内置动态插件
7573
-`/` 跳转到 `/management.html`
7674
- 增强 `/healthz` 返回信息。
7775

@@ -86,13 +84,14 @@ CLIProxyAPI Pro 是对两个 upstream 项目的最小化定制层集合:
8684

8785
主要能力:
8886

89-
- 通过 `pro-observability` 插件动态资源提供唯一的完整监控中心;Management 不再编译 `/monitoring` 页面
87+
- 新增 `/monitoring` 请求监控页面
9088
- 新增 `/account-inspection` 账号巡检页面。
9189
- 新增 `/routing` 路由策略页面。
92-
- `proxy-pool` 插件资源页负责节点配置、连通性测试、运行统计和全局代理接管/恢复;Management 不再维护重复页面。
93-
- `oauth-model-policy` 插件资源页按提供商和 OAuth 套餐编辑模型排除规则、自定义套餐、回退策略和套餐探测缓存。
94-
- 插件监控中心展示请求量、成功率、延迟、token、缓存和成本统计,并提供实时日志、价格、设置和备份管理。
95-
- Management Bridge v2 为插件页代理 JSON、SSE、二进制导入、下载和宿主交互,iframe 不接收 management key、原始 API key 或 auth token。
90+
- 新增 `/proxy-pool` 代理池页面,负责节点配置、连通性测试、运行统计和全局代理接管/恢复。
91+
- 新增 `/oauth-model-policy` 可视化配置页,按提供商和 OAuth 套餐编辑模型排除规则、自定义套餐、回退策略和套餐探测缓存。
92+
- 请求量、成功率、延迟、token 和成本统计。
93+
- 模型价格 SQLite 持久化。
94+
- quota cache SQLite 持久化。
9695
- 配额卡片缓存时间显示和单卡刷新。
9796
- 对接后端账号巡检,负责运行控制、状态轮询、结果展示和操作确认。
9897
- 认证文件页面可显示巡检写入的 `last_error` 健康消息。
@@ -186,7 +185,7 @@ v<core-version>-pro
186185
1. 检查 upstream `router-for-me/CLIProxyAPI` 最新 release。
187186
2. 计算 Pro release tag,例如 `v<core-version>-pro`
188187
3. checkout upstream core 和 upstream management 最新 release。
189-
4. 应用 core patch 并构建启用 CGO 和必需动态插件的 Pro 二进制资产
188+
4. 应用 core patch 并构建 Pro 二进制资产:默认桌面/Linux 包启用 CGO 并支持动态库插件,`_no-plugin` 包保留 CGO-free 静态便携构建
190189
5. 复用已构建的 Linux 资产,通过 `Dockerfile.runtime` 组装并推送多架构 Docker 镜像。
191190
6. 应用 management 定制层,构建单文件 `management.html`
192191
7. 创建或更新当前仓库的 GitHub Release,并上传二进制、`checksums.txt``management.html`
@@ -202,10 +201,11 @@ v<core-version>-pro
202201

203202
Docker 构建参数中 `CLIPROXY_VERSION` 用于选择 upstream core tag,`CLIPROXY_BUILD_VERSION` 用于写入 Pro runtime 版本号。
204203

205-
二进制资产使用 Pro release tag,资产名前缀保持为 `CLIProxyAPI`当前发布 macOS amd64/arm64、Windows amd64、Linux amd64/arm64;所有资产都支持并预打包必需的动态插件。Docker 镜像使用 CGO-enabled Debian 构建
204+
二进制资产平台和压缩格式与 upstream CLIProxyAPI 保持一致,版本号使用 Pro release tag,因此资产名前缀保持为 `CLIProxyAPI`默认桌面/Linux 包支持动态库插件;`_no-plugin` 包用于静态或受限环境。Docker 镜像对齐 upstream,使用 CGO-enabled Debian 构建并支持动态库插件
206205

207206
```text
208207
CLIProxyAPI_<core-version>-pro_<os>_<arch>.<archive>
208+
CLIProxyAPI_<core-version>-pro_<os>_<arch>_no-plugin.<archive>
209209
checksums.txt
210210
management.html
211211
```
@@ -321,9 +321,9 @@ Usage 导入导出会使用 NDJSON 元数据记录保存模型价格、quota cac
321321
### Usage service
322322

323323
```text
324+
USAGE_SERVICE_ENABLED
324325
USAGE_DATA_DIR
325326
USAGE_DB_PATH
326-
PRO_OBSERVABILITY_DB_PATH
327327
USAGE_BATCH_SIZE
328328
USAGE_POLL_INTERVAL_MS
329329
USAGE_QUERY_LIMIT

0 commit comments

Comments
 (0)