Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 31 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,44 @@ permissions:

jobs:
check:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- uses: actions/setup-go@v5
with:
go-version: 1.26.5
# The formal Host Git package still pins Protocol as a nested Git dependency.
# Use the Node 22 bundled npm until Host publishes a dependency-closed package.
- run: npm ci
- run: npm run check
- name: Prepare the pinned CLIProxyAPI plugin host
run: |
git clone --depth 1 --filter=blob:none --no-checkout https://github.com/router-for-me/CLIProxyAPI.git "$RUNNER_TEMP/cliproxy-source"
git -C "$RUNNER_TEMP/cliproxy-source" fetch --depth 1 origin 85d2faddd17e6f4f8675a84ee28b131f702e8eaa
git -C "$RUNNER_TEMP/cliproxy-source" checkout --detach FETCH_HEAD
- name: Pack and verify the Linux and macOS resources
run: |
node scripts/sync-runtime-resources.mjs
node scripts/sync-package-manifest.mjs
mkdir -p "$RUNNER_TEMP/release" "$RUNNER_TEMP/release-package"
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/release"
archive="cordisx-plugin-cli-proxy-api-$(node -p "require('./package.json').version").tgz"
tar -xzf "$RUNNER_TEMP/release/$archive" -C "$RUNNER_TEMP/release-package"
node scripts/check-release-targets.mjs "$RUNNER_TEMP/release-package/package"
(cd "$RUNNER_TEMP/release" && sha256sum "$archive" > SHA256SUMS)
- name: Load the packaged Linux bridge through the real plugin host
env:
CLIPROXY_SOURCE: ${{ runner.temp }}/cliproxy-source
CORDISX_GATEWAY_REPO: ${{ runner.temp }}/release-package/package
run: node scripts/test-native-integration.mjs
- uses: actions/upload-artifact@v4
with:
name: release-candidate-${{ github.sha }}
path: |
${{ runner.temp }}/release/*.tgz
${{ runner.temp }}/release/SHA256SUMS
if-no-files-found: error
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ the CordisX interface.

## Install

Plugin ID: `cli-proxy-api`. Current release: `0.1.2`.
Plugin ID: `cli-proxy-api`. Current release: `0.1.3`.

The packaged gateway bridge supports macOS arm64 and Linux x64.

The CordisX Community Marketplace feed must already be configured and enabled
before `--source` can select it:

```sh
FEED_URL=https://raw.githubusercontent.com/cordisx/marketplace/main/marketplace.json
npx cordisx@beta source add "$FEED_URL" --yes
npx cordisx@beta plugin install cli-proxy-api --source "$FEED_URL" --version 0.1.2
npx cordisx@beta plugin install cli-proxy-api --source "$FEED_URL" --version 0.1.3
```

Skip `source add` when that exact feed is already enabled. For another profile,
Expand All @@ -24,9 +26,9 @@ the source change only; it does not approve plugin permissions. A discovery
source is not a trust root.

The install command becomes available after the Marketplace v3 entry lists the
verified `0.1.2` artifact. Until then, download the archive and `SHA256SUMS`
verified `0.1.3` artifact. Until then, download the archive and `SHA256SUMS`
from the
[GitHub release](https://github.com/cordisx/plugin-cli-proxy-api/releases/tag/v0.1.2).
[GitHub release](https://github.com/cordisx/plugin-cli-proxy-api/releases/tag/v0.1.3).

## Use

Expand Down Expand Up @@ -64,7 +66,7 @@ provider or model when an exact identity is unavailable.

## Troubleshooting

- **Install cannot find version `0.1.2`:** confirm the Marketplace v3 entry
- **Install cannot find version `0.1.3`:** confirm the Marketplace v3 entry
lists the verified artifact. `--source` does not add or repair a feed.
- **No models or sessions appear:** confirm CLIProxyAPI is running, its accounts
are enabled, and model/catalog read permissions are granted.
Expand Down
12 changes: 7 additions & 5 deletions README.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ CLIProxy Providers 将 CordisX 连接到 CLIProxyAPI runtime 提供的模型与

## 安装

插件 ID:`cli-proxy-api`。当前版本:`0.1.2`。
插件 ID:`cli-proxy-api`。当前版本:`0.1.3`。

内置的 gateway 桥接支持 macOS arm64 和 Linux x64。

CordisX Community Marketplace feed 必须先完成配置并启用,`--source` 才能选择它:

```sh
FEED_URL=https://raw.githubusercontent.com/cordisx/marketplace/main/marketplace.json
npx cordisx@beta source add "$FEED_URL" --yes
npx cordisx@beta plugin install cli-proxy-api --source "$FEED_URL" --version 0.1.2
npx cordisx@beta plugin install cli-proxy-api --source "$FEED_URL" --version 0.1.3
```

若该 feed 已启用,可跳过 `source add`。使用其他 profile 时,两条命令都要添加
相同的 `--profile <profile>`。`--yes` 只确认来源变更,不会批准插件权限;发现来源
也不等同于 trust root。

Marketplace v3 条目列出已验证的 `0.1.2` artifact 后,安装命令才可用。在此之前,
Marketplace v3 条目列出已验证的 `0.1.3` artifact 后,安装命令才可用。在此之前,
可从
[GitHub Release](https://github.com/cordisx/plugin-cli-proxy-api/releases/tag/v0.1.2)
[GitHub Release](https://github.com/cordisx/plugin-cli-proxy-api/releases/tag/v0.1.3)
下载压缩包与 `SHA256SUMS`。

## 使用
Expand Down Expand Up @@ -55,7 +57,7 @@ CLIProxyAPI 账号与 endpoint 必须在外部 runtime 中配置。Host 负责

## 排错

- **找不到 `0.1.2`:**确认 Marketplace v3 条目已列出验证后的 artifact;`--source`
- **找不到 `0.1.3`:**确认 Marketplace v3 条目已列出验证后的 artifact;`--source`
不会添加或修复 feed。
- **没有模型或会话:**确认 CLIProxyAPI 正在运行、账号已启用,并授予模型和 catalog
读取权限。
Expand Down
2 changes: 1 addition & 1 deletion cordisx-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/cordisx/cordisx-protocol/main/schemas/plugin-package.v14.schema.json",
"schemaVersion": 14,
"id": "cli-proxy-api",
"version": "0.1.2",
"version": "0.1.3",
"entry": "./dist/runtime/module.js",
"readme": "./README.md",
"canonicalSource": "https://github.com/cordisx/plugin-cli-proxy-api",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cordisx/plugin-cli-proxy-api",
"version": "0.1.2",
"version": "0.1.3",
"private": true,
"license": "AGPL-3.0-or-later",
"description": "CLIProxyAPI provider sessions plugin for CordisX",
Expand Down
4 changes: 3 additions & 1 deletion scripts/build-native.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const execFileAsync = promisify(execFile)
const root = fileURLToPath(new URL('../', import.meta.url))
const source = path.join(root, 'native/gateway-bridge')
const extension = process.platform === 'darwin' ? '.dylib' : process.platform === 'win32' ? '.dll' : '.so'
const directory = path.join(root, 'runtime/cli-proxy-plugins', process.platform, process.arch)
// CLIProxyAPI uses Go's architecture names for plugin discovery.
const nativeArchitecture = process.arch === 'x64' ? 'amd64' : process.arch
const directory = path.join(root, 'runtime/cli-proxy-plugins', process.platform, nativeArchitecture)
const output = path.join(directory, `cordisx-gateway-bridge${extension}`)

if (!['darwin', 'linux', 'win32'].includes(process.platform) || !['arm64', 'x64'].includes(process.arch)) {
Expand Down
37 changes: 37 additions & 0 deletions scripts/check-release-targets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import assert from 'node:assert/strict'
import { createHash } from 'node:crypto'
import { readFile } from 'node:fs/promises'
import path from 'node:path'

const root = process.argv[2]
if (!root || !path.isAbsolute(root)) throw new Error('provide an absolute extracted package path')
const digest = bytes => 'sha256:' + createHash('sha256').update(bytes).digest('hex')
const [packageText, runtimeText] = await Promise.all([
readFile(path.join(root, 'cordisx-package.json')),
readFile(path.join(root, 'runtime-manifest.json')),
])
const packageManifest = JSON.parse(packageText)
const runtimeManifest = JSON.parse(runtimeText)
assert.equal(packageManifest.runtimeManifest.digest, digest(runtimeText))
const resources = runtimeManifest.services.find(service => service.id === 'gateway-runtime')?.runtimeResources
assert.ok(Array.isArray(resources), 'gateway runtime resources are missing')
for (
const [platform, nativeArchitecture, architecture, extension] of [
['darwin', 'arm64', 'arm64', 'dylib'],
['linux', 'amd64', 'x64', 'so'],
]
) {
const relative = './runtime/cli-proxy-plugins/' + platform + '/' + nativeArchitecture + '/cordisx-gateway-bridge.'
+ extension
const resource = resources.find(item => item.path === relative)
assert.ok(resource, 'missing ' + platform + '/' + architecture + ' bridge declaration')
assert.equal(resource.mode, 'executable')
assert.deepEqual(resource.platforms, [platform])
assert.deepEqual(resource.architectures, [architecture])
}
for (const resource of resources) {
assert.ok(resource.path.startsWith('./') && !resource.path.split('/').includes('..'))
const bytes = await readFile(path.join(root, resource.path))
assert.equal(resource.byteLength, bytes.byteLength, resource.path)
assert.equal(resource.digest, digest(bytes), resource.path)
}
5 changes: 4 additions & 1 deletion scripts/sync-runtime-resources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ for (const platform of await readdir(nativeRoot).catch(() => [])) {
const directory = path.join(nativeRoot, platform, architecture)
for (const file of await readdir(directory)) {
if (!/^cordisx-gateway-bridge(?:\.dylib|\.so|\.dll)$/.test(file)) continue
if (!['arm64', 'amd64'].includes(architecture)) {
throw new Error('unsupported native plugin discovery architecture: ' + architecture)
}
resources.push({
...await declaration(`./runtime/cli-proxy-plugins/${platform}/${architecture}/${file}`, 'executable'),
platforms: [platform],
architectures: [architecture],
architectures: [architecture === 'amd64' ? 'x64' : architecture],
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-native-integration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ await execFileAsync('go', ['test', '-mod=mod', '-count=1', '-timeout', '90s', '-
cwd: work,
env: {
...process.env,
CORDISX_GATEWAY_REPO: root,
CORDISX_GATEWAY_REPO: process.env.CORDISX_GATEWAY_REPO ?? root,
},
maxBuffer: 16 * 1024 * 1024,
})
4 changes: 2 additions & 2 deletions test/package-artifact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ test('publishes schema-valid v14 package and runtime manifests with exact reques
assert.deepEqual(executableResources.map(resource => resource.path).sort(), actualExecutablePaths.sort())
for (const resource of executableResources) {
const match =
/^\.\/runtime\/cli-proxy-plugins\/(darwin|linux|win32)\/(arm64|x64)\/cordisx-gateway-bridge\.(dylib|so|dll)$/
/^\.\/runtime\/cli-proxy-plugins\/(darwin|linux|win32)\/(arm64|amd64)\/cordisx-gateway-bridge\.(dylib|so|dll)$/
.exec(
resource.path,
)
assert.notEqual(match, null, `invalid native resource path ${resource.path}`)
const [, platform, architecture, extension] = match
assert.equal(extension, nativeExtensions[platform], `native resource extension does not match ${platform}`)
assert.deepEqual(resource.platforms, [platform])
assert.deepEqual(resource.architectures, [architecture])
assert.deepEqual(resource.architectures, [architecture === 'amd64' ? 'x64' : architecture])
}
for (const resource of gateway.runtimeResources) {
const bytes = await readFile(new URL(`../${resource.path.slice(2)}`, import.meta.url))
Expand Down
Loading