pplx-zero 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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/cli.js +6988 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kenzo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# 🚀 PPLX-Zero
|
|
2
|
+
|
|
3
|
+
> Minimal, fast Perplexity AI search CLI - zero configuration, zero compromises
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/pplx-zero)
|
|
6
|
+
[](https://aur.archlinux.org/packages/pplx-zero)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
PPLX-Zero is a blazing-fast, production-ready TypeScript implementation of Perplexity AI search integration. Built with Bun runtime for maximum performance and zero bloat.
|
|
10
|
+
|
|
11
|
+
## ✨ Key Features
|
|
12
|
+
|
|
13
|
+
- **⚡ Lightning Fast** - Concurrent searches with intelligent rate limiting
|
|
14
|
+
- **🎯 Zero Config** - Works out of the box with just an API key
|
|
15
|
+
- **📦 Batch Processing** - Handle multiple queries simultaneously
|
|
16
|
+
- **🔄 Real-time Streaming** - Progress updates via JSONL events
|
|
17
|
+
- **🛡️ Type Safe** - Full Zod validation and TypeScript support
|
|
18
|
+
- **🌍 Cross-Platform** - Native Bun runtime everywhere
|
|
19
|
+
|
|
20
|
+
## 🚀 Quick Start
|
|
21
|
+
|
|
22
|
+
### 1️⃣ Install
|
|
23
|
+
|
|
24
|
+
**📦 Package Manager Installation (Recommended)**
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# npm (Node.js package manager)
|
|
28
|
+
npm install -g pplx-zero
|
|
29
|
+
|
|
30
|
+
# AUR (Arch Linux)
|
|
31
|
+
yay -S pplx-zero
|
|
32
|
+
# or
|
|
33
|
+
pikaur -S pplx-zero
|
|
34
|
+
# or manual AUR
|
|
35
|
+
git clone https://aur.archlinux.org/pplx-zero.git
|
|
36
|
+
cd pplx-zero
|
|
37
|
+
makepkg -si
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**🔨 Manual Installation**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Clone and build locally
|
|
44
|
+
git clone https://github.com/codewithkenzo/pplx-zero.git
|
|
45
|
+
cd pplx-zero
|
|
46
|
+
bun install && bun run build
|
|
47
|
+
|
|
48
|
+
# Add to PATH
|
|
49
|
+
sudo ln -s "$(pwd)/dist/cli.js" /usr/local/bin/pplx
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2️⃣ Setup API Key
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
export PERPLEXITY_API_KEY="your-perplexity-api-key"
|
|
56
|
+
# Or use the fallback
|
|
57
|
+
export PERPLEXITY_AI_API_KEY="your-alternative-api-key"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 3️⃣ Start Searching
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Single query (CLI command is 'pplx')
|
|
64
|
+
pplx "latest AI developments"
|
|
65
|
+
|
|
66
|
+
# Batch from file
|
|
67
|
+
pplx --input queries.json
|
|
68
|
+
|
|
69
|
+
# Stream from stdin
|
|
70
|
+
cat queries.jsonl | pplx --stdin
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 📖 Usage Guide
|
|
74
|
+
|
|
75
|
+
### Command Line Interface
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Basic usage
|
|
79
|
+
pplx "your search query"
|
|
80
|
+
|
|
81
|
+
# Advanced options
|
|
82
|
+
pplx --concurrency 10 --timeout 60000 --format jsonl "machine learning trends"
|
|
83
|
+
|
|
84
|
+
# Dry run validation
|
|
85
|
+
pplx --dry-run "test query"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Batch Processing
|
|
89
|
+
|
|
90
|
+
Create `queries.json`:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"version": "1.0.0",
|
|
95
|
+
"requests": [
|
|
96
|
+
{"op": "search", "args": {"query": "AI trends", "maxResults": 5}},
|
|
97
|
+
{"op": "search", "args": {"query": "TypeScript patterns", "maxResults": 3}},
|
|
98
|
+
{"op": "search", "args": {"query": "Bun performance", "maxResults": 3}}
|
|
99
|
+
],
|
|
100
|
+
"options": {
|
|
101
|
+
"concurrency": 5,
|
|
102
|
+
"timeoutMs": 30000
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Process with:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pplx --input queries.json --format jsonl
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Programmatic Usage
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { PerplexitySearchTool } from 'pplx-zero';
|
|
117
|
+
|
|
118
|
+
const tool = new PerplexitySearchTool();
|
|
119
|
+
|
|
120
|
+
const result = await tool.runBatch({
|
|
121
|
+
version: "1.0.0",
|
|
122
|
+
requests: [{
|
|
123
|
+
op: "search",
|
|
124
|
+
args: { query: "TypeScript best practices", maxResults: 5 }
|
|
125
|
+
}]
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
console.log(result);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## ⚙️ Configuration
|
|
132
|
+
|
|
133
|
+
| Option | Short | Type | Default | Description |
|
|
134
|
+
|--------|-------|------|---------|-------------|
|
|
135
|
+
| `--input` | `-i` | string | - | Read batch requests from JSON file |
|
|
136
|
+
| `--stdin` | `-s` | boolean | false | Read JSONL requests from stdin |
|
|
137
|
+
| `--concurrency` | `-c` | number | 5 | Max concurrent requests (1-20) |
|
|
138
|
+
| `--timeout` | `-t` | number | 30000 | Request timeout in ms (1000-300000) |
|
|
139
|
+
| `--format` | `-f` | string | json | Output format: json|jsonl |
|
|
140
|
+
| `--dry-run` | `-d` | boolean | false | Validate input without executing |
|
|
141
|
+
| `--version` | `-v` | boolean | - | Show version |
|
|
142
|
+
| `--help` | `-h` | boolean | - | Show help |
|
|
143
|
+
|
|
144
|
+
## 📊 Output Formats
|
|
145
|
+
|
|
146
|
+
### JSON (Default)
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"version": "1.0.0",
|
|
150
|
+
"ok": true,
|
|
151
|
+
"summary": {
|
|
152
|
+
"total": 1,
|
|
153
|
+
"successful": 1,
|
|
154
|
+
"failed": 0,
|
|
155
|
+
"totalDuration": 572
|
|
156
|
+
},
|
|
157
|
+
"results": [...]
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### JSONL (Streaming)
|
|
162
|
+
```bash
|
|
163
|
+
pplx --format jsonl "AI trends"
|
|
164
|
+
```
|
|
165
|
+
Each result printed as a separate JSON line for real-time processing.
|
|
166
|
+
|
|
167
|
+
## 🔧 Development
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Development mode
|
|
171
|
+
bun run dev
|
|
172
|
+
|
|
173
|
+
# Type checking
|
|
174
|
+
bun run typecheck
|
|
175
|
+
|
|
176
|
+
# Run tests
|
|
177
|
+
bun test
|
|
178
|
+
|
|
179
|
+
# Build for production
|
|
180
|
+
bun run build
|
|
181
|
+
|
|
182
|
+
# Create binary
|
|
183
|
+
bun run build:binary
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 🏗️ Architecture
|
|
187
|
+
|
|
188
|
+
- **Bun Runtime** - Ultra-fast JavaScript runtime
|
|
189
|
+
- **Zod Validation** - Type-safe schema validation
|
|
190
|
+
- **Circuit Breaker** - Resilient error handling
|
|
191
|
+
- **Semaphore Pattern** - Controlled concurrency
|
|
192
|
+
- **Streaming Events** - Real-time progress updates
|
|
193
|
+
|
|
194
|
+
## 🛡️ Security Features
|
|
195
|
+
|
|
196
|
+
- Environment variable API key management
|
|
197
|
+
- Input validation and sanitization
|
|
198
|
+
- Request timeout protection
|
|
199
|
+
- Error information filtering
|
|
200
|
+
- No external dependencies beyond core runtime
|
|
201
|
+
|
|
202
|
+
## 📋 Error Handling
|
|
203
|
+
|
|
204
|
+
PPLX-Zero provides comprehensive error classification:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
enum ErrorCode {
|
|
208
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
209
|
+
API_KEY_MISSING = "API_KEY_MISSING",
|
|
210
|
+
API_ERROR = "API_ERROR",
|
|
211
|
+
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
212
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
213
|
+
RATE_LIMIT_ERROR = "RATE_LIMIT_ERROR",
|
|
214
|
+
UNEXPECTED_ERROR = "UNEXPECTED_ERROR"
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 🤝 Contributing
|
|
219
|
+
|
|
220
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
221
|
+
|
|
222
|
+
## 📄 License
|
|
223
|
+
|
|
224
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
**Built with ❤️ using [Bun](https://bun.sh) and [Perplexity AI](https://www.perplexity.ai)**
|