cliproxy-server-termux 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -0
- package/bin/cliproxy-login.js +33 -0
- package/bin/cliproxy.js +37 -0
- package/bin/cliproxyapi +1 -0
- package/config/config-termux.yaml +38 -0
- package/package.json +58 -0
- package/scripts/postinstall.js +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# CLIProxyAPIPlus Server for Termux
|
|
2
|
+
|
|
3
|
+
> Multi-provider AI API proxy with OAuth support for Android Termux
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/cliproxy-server-termux)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- š **OAuth Authentication** - Secure login for multiple AI providers
|
|
10
|
+
- š **Multi-Provider Support** - Gemini, Claude, OpenAI, Grok, Qwen, and more
|
|
11
|
+
- š **Local API Server** - Runs on `http://localhost:8317`
|
|
12
|
+
- š± **Termux Optimized** - Built specifically for Android ARM64
|
|
13
|
+
- ā” **Zero Configuration** - Works out of the box
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g cliproxy-server-termux
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### 1. Login with OAuth
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cliproxy-login
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Follow the prompts to authenticate with your AI provider accounts.
|
|
30
|
+
|
|
31
|
+
### 2. Start Server
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cliproxy
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Server will start on `http://localhost:8317/v1`
|
|
38
|
+
|
|
39
|
+
### 3. Test API
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
curl http://localhost:8317/v1/models
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage with Codex
|
|
46
|
+
|
|
47
|
+
Install the companion Codex package:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g cliproxy-codex-termux
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then use Codex with all models available:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
codex
|
|
57
|
+
# Press / then type "model" to see all available models
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Available Commands
|
|
61
|
+
|
|
62
|
+
| Command | Description |
|
|
63
|
+
|---------|-------------|
|
|
64
|
+
| `cliproxy` | Start the API server |
|
|
65
|
+
| `cliproxy-login` | Run OAuth authentication |
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
Config file location: `~/.config/cliproxyapi/config.yaml`
|
|
70
|
+
|
|
71
|
+
Default settings:
|
|
72
|
+
- Port: `8317`
|
|
73
|
+
- Base URL: `http://localhost:8317/v1`
|
|
74
|
+
- Auth directory: `~/.config/cliproxyapi/auth`
|
|
75
|
+
|
|
76
|
+
## Supported Providers
|
|
77
|
+
|
|
78
|
+
- Google Gemini (2.5 Pro, 3 Pro Preview)
|
|
79
|
+
- Anthropic Claude (Opus 4.5, Sonnet 4.5)
|
|
80
|
+
- OpenAI (GPT-4, GPT-3.5)
|
|
81
|
+
- xAI Grok
|
|
82
|
+
- Alibaba Qwen
|
|
83
|
+
- Kiro AI
|
|
84
|
+
|
|
85
|
+
## Troubleshooting
|
|
86
|
+
|
|
87
|
+
### Server won't start
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Check if port 8317 is already in use
|
|
91
|
+
lsof -i :8317
|
|
92
|
+
|
|
93
|
+
# Kill existing process
|
|
94
|
+
pkill cliproxyapi
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### OAuth login fails
|
|
98
|
+
|
|
99
|
+
Make sure you have:
|
|
100
|
+
1. Active internet connection
|
|
101
|
+
2. Valid credentials for the provider
|
|
102
|
+
3. Termux storage permission
|
|
103
|
+
|
|
104
|
+
### API returns 401
|
|
105
|
+
|
|
106
|
+
Run `cliproxy-login` again to refresh authentication.
|
|
107
|
+
|
|
108
|
+
## Requirements
|
|
109
|
+
|
|
110
|
+
- Android device with ARM64 architecture
|
|
111
|
+
- Termux app
|
|
112
|
+
- Node.js 14 or higher
|
|
113
|
+
- Internet connection for OAuth
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT
|
|
118
|
+
|
|
119
|
+
## Links
|
|
120
|
+
|
|
121
|
+
- [GitHub Repository](https://github.com/julianromli/CLIProxyAPIPlus-Easy-Installation)
|
|
122
|
+
- [Report Issues](https://github.com/julianromli/CLIProxyAPIPlus-Easy-Installation/issues)
|
|
123
|
+
- [Codex Package](https://www.npmjs.com/package/cliproxy-codex-termux)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const binaryPath = join(__dirname, 'cliproxyapi');
|
|
11
|
+
|
|
12
|
+
console.log('š Starting OAuth login flow...\n');
|
|
13
|
+
|
|
14
|
+
// Run OAuth login
|
|
15
|
+
const login = spawn(binaryPath, ['oauth', 'login'], {
|
|
16
|
+
stdio: 'inherit',
|
|
17
|
+
env: {
|
|
18
|
+
...process.env,
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
login.on('error', (err) => {
|
|
23
|
+
console.error('Failed to start OAuth login:', err);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
login.on('exit', (code) => {
|
|
28
|
+
if (code === 0) {
|
|
29
|
+
console.log('\nā
Login successful!');
|
|
30
|
+
console.log('You can now start the server with: cliproxy');
|
|
31
|
+
}
|
|
32
|
+
process.exit(code || 0);
|
|
33
|
+
});
|
package/bin/cliproxy.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const binaryPath = join(__dirname, 'cliproxyapi');
|
|
11
|
+
const configPath = join(__dirname, '..', 'config', 'config-termux.yaml');
|
|
12
|
+
|
|
13
|
+
// Start CLIProxyAPIPlus server
|
|
14
|
+
const server = spawn(binaryPath, ['-config', configPath], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
env: {
|
|
17
|
+
...process.env,
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
server.on('error', (err) => {
|
|
22
|
+
console.error('Failed to start CLIProxyAPIPlus server:', err);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
server.on('exit', (code) => {
|
|
27
|
+
process.exit(code || 0);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Handle termination
|
|
31
|
+
process.on('SIGINT', () => {
|
|
32
|
+
server.kill('SIGINT');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
process.on('SIGTERM', () => {
|
|
36
|
+
server.kill('SIGTERM');
|
|
37
|
+
});
|
package/bin/cliproxyapi
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Not Found
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# CLIProxyAPI-Plus Configuration for Termux
|
|
2
|
+
# Optimized for Android/Termux environment
|
|
3
|
+
|
|
4
|
+
# Server port (default: 8317)
|
|
5
|
+
port: 8317
|
|
6
|
+
|
|
7
|
+
# Directory to store OAuth tokens
|
|
8
|
+
# Termux uses standard home directory
|
|
9
|
+
auth-dir: "~/.cli-proxy-api"
|
|
10
|
+
|
|
11
|
+
# API keys for authentication (use any dummy key)
|
|
12
|
+
# These are accepted by the proxy for compatibility with OpenAI clients
|
|
13
|
+
api-keys:
|
|
14
|
+
- "sk-dummy"
|
|
15
|
+
- "sk-termux-cliproxy"
|
|
16
|
+
|
|
17
|
+
# Quota exceeded behavior
|
|
18
|
+
quota-exceeded:
|
|
19
|
+
switch-project: true # Auto-switch to another project when quota exceeded
|
|
20
|
+
switch-preview-model: true # Auto-switch to preview model when quota exceeded
|
|
21
|
+
|
|
22
|
+
# Browser settings for Termux
|
|
23
|
+
# Termux uses termux-open to launch browser
|
|
24
|
+
incognito-browser: false
|
|
25
|
+
|
|
26
|
+
# Network settings optimized for mobile
|
|
27
|
+
request-retry: 3
|
|
28
|
+
request-timeout: 60
|
|
29
|
+
|
|
30
|
+
# Remote management settings
|
|
31
|
+
remote-management:
|
|
32
|
+
allow-remote: false # Only allow localhost access for security
|
|
33
|
+
secret-key: "" # Leave empty to disable management API
|
|
34
|
+
disable-control-panel: false
|
|
35
|
+
|
|
36
|
+
# Logging
|
|
37
|
+
log-level: "info" # Options: debug, info, warn, error
|
|
38
|
+
log-file: "~/.cli-proxy-api/cliproxy.log"
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cliproxy-server-termux",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLIProxyAPIPlus server for Termux - Multi-provider AI API proxy with OAuth support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "bin/cliproxy.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cliproxy": "bin/cliproxy.js",
|
|
9
|
+
"cliproxy-login": "bin/cliproxy-login.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/cliproxy.js",
|
|
13
|
+
"bin/cliproxy-login.js",
|
|
14
|
+
"bin/cliproxyapi",
|
|
15
|
+
"config/config-termux.yaml",
|
|
16
|
+
"scripts/postinstall.js",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"postinstall": "node scripts/postinstall.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"cliproxy",
|
|
24
|
+
"cliproxyapiplus",
|
|
25
|
+
"gemini",
|
|
26
|
+
"claude",
|
|
27
|
+
"openai",
|
|
28
|
+
"grok",
|
|
29
|
+
"qwen",
|
|
30
|
+
"api-proxy",
|
|
31
|
+
"oauth",
|
|
32
|
+
"termux",
|
|
33
|
+
"android",
|
|
34
|
+
"arm64",
|
|
35
|
+
"ai",
|
|
36
|
+
"multi-provider"
|
|
37
|
+
],
|
|
38
|
+
"author": "CLIProxyAPIPlus",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/julianromli/CLIProxyAPIPlus-Easy-Installation.git"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/julianromli/CLIProxyAPIPlus-Easy-Installation#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/julianromli/CLIProxyAPIPlus-Easy-Installation/issues"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=14.0.0"
|
|
50
|
+
},
|
|
51
|
+
"os": [
|
|
52
|
+
"android",
|
|
53
|
+
"linux"
|
|
54
|
+
],
|
|
55
|
+
"cpu": [
|
|
56
|
+
"arm64"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdir, copyFile, access, constants } from 'fs/promises';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { homedir } from 'os';
|
|
6
|
+
|
|
7
|
+
const CONFIG_DIR = join(homedir(), '.config', 'cliproxyapi');
|
|
8
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.yaml');
|
|
9
|
+
const SOURCE_CONFIG = join(process.cwd(), 'config', 'config-termux.yaml');
|
|
10
|
+
|
|
11
|
+
async function postinstall() {
|
|
12
|
+
try {
|
|
13
|
+
console.log('š¦ Setting up CLIProxyAPIPlus...\n');
|
|
14
|
+
|
|
15
|
+
// Create config directory
|
|
16
|
+
await mkdir(CONFIG_DIR, { recursive: true });
|
|
17
|
+
console.log('ā
Created config directory:', CONFIG_DIR);
|
|
18
|
+
|
|
19
|
+
// Check if config already exists
|
|
20
|
+
try {
|
|
21
|
+
await access(CONFIG_FILE, constants.F_OK);
|
|
22
|
+
console.log('ā ļø Config file already exists, skipping copy');
|
|
23
|
+
} catch {
|
|
24
|
+
// Copy default config
|
|
25
|
+
await copyFile(SOURCE_CONFIG, CONFIG_FILE);
|
|
26
|
+
console.log('ā
Copied default config to:', CONFIG_FILE);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('\nš Installation complete!');
|
|
30
|
+
console.log('\nNext steps:');
|
|
31
|
+
console.log('1. Run: cliproxy-login');
|
|
32
|
+
console.log('2. Complete OAuth authentication');
|
|
33
|
+
console.log('3. Start server: cliproxy');
|
|
34
|
+
console.log('\nServer will run on: http://localhost:8317');
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('ā Installation failed:', error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
postinstall();
|