@cpretzinger/boss-claude 1.0.0 → 1.0.2
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 +304 -1
- package/bin/boss-claude.js +1138 -0
- package/bin/commands/mode.js +250 -0
- package/bin/onyx-guard.js +259 -0
- package/bin/onyx-guard.sh +251 -0
- package/bin/prompts.js +284 -0
- package/bin/rollback.js +85 -0
- package/bin/setup-wizard.js +492 -0
- package/config/.env.example +17 -0
- package/lib/README.md +83 -0
- package/lib/agent-logger.js +61 -0
- package/lib/agents/memory-engineers/github-memory-engineer.js +251 -0
- package/lib/agents/memory-engineers/postgres-memory-engineer.js +633 -0
- package/lib/agents/memory-engineers/qdrant-memory-engineer.js +358 -0
- package/lib/agents/memory-engineers/redis-memory-engineer.js +383 -0
- package/lib/agents/memory-supervisor.js +526 -0
- package/lib/agents/registry.js +135 -0
- package/lib/auto-monitor.js +131 -0
- package/lib/checkpoint-hook.js +112 -0
- package/lib/checkpoint.js +319 -0
- package/lib/commentator.js +213 -0
- package/lib/context-scribe.js +120 -0
- package/lib/delegation-strategies.js +326 -0
- package/lib/hierarchy-validator.js +643 -0
- package/lib/index.js +15 -0
- package/lib/init-with-mode.js +261 -0
- package/lib/init.js +44 -6
- package/lib/memory-result-aggregator.js +252 -0
- package/lib/memory.js +35 -7
- package/lib/mode-enforcer.js +473 -0
- package/lib/onyx-banner.js +169 -0
- package/lib/onyx-identity.js +214 -0
- package/lib/onyx-monitor.js +381 -0
- package/lib/onyx-reminder.js +188 -0
- package/lib/onyx-tool-interceptor.js +341 -0
- package/lib/onyx-wrapper.js +315 -0
- package/lib/orchestrator-gate.js +334 -0
- package/lib/output-formatter.js +296 -0
- package/lib/postgres.js +1 -1
- package/lib/prompt-injector.js +220 -0
- package/lib/prompts.js +532 -0
- package/lib/session.js +153 -6
- package/lib/setup/README.md +187 -0
- package/lib/setup/env-manager.js +785 -0
- package/lib/setup/error-recovery.js +630 -0
- package/lib/setup/explain-scopes.js +385 -0
- package/lib/setup/github-instructions.js +333 -0
- package/lib/setup/github-repo.js +254 -0
- package/lib/setup/import-credentials.js +498 -0
- package/lib/setup/index.js +62 -0
- package/lib/setup/init-postgres.js +785 -0
- package/lib/setup/init-redis.js +456 -0
- package/lib/setup/integration-test.js +652 -0
- package/lib/setup/progress.js +357 -0
- package/lib/setup/rollback.js +670 -0
- package/lib/setup/rollback.test.js +452 -0
- package/lib/setup/setup-with-rollback.example.js +351 -0
- package/lib/setup/summary.js +400 -0
- package/lib/setup/test-github-setup.js +10 -0
- package/lib/setup/test-postgres-init.js +98 -0
- package/lib/setup/verify-setup.js +102 -0
- package/lib/task-agent-worker.js +235 -0
- package/lib/token-monitor.js +466 -0
- package/lib/tool-wrapper-integration.js +369 -0
- package/lib/tool-wrapper.js +387 -0
- package/lib/validators/README.md +497 -0
- package/lib/validators/config.js +583 -0
- package/lib/validators/config.test.js +175 -0
- package/lib/validators/github.js +310 -0
- package/lib/validators/github.test.js +61 -0
- package/lib/validators/index.js +15 -0
- package/lib/validators/postgres.js +525 -0
- package/package.json +98 -13
- package/scripts/benchmark-memory.js +433 -0
- package/scripts/check-secrets.sh +12 -0
- package/scripts/fetch-todos.mjs +148 -0
- package/scripts/graceful-shutdown.sh +156 -0
- package/scripts/install-onyx-hooks.js +373 -0
- package/scripts/install.js +119 -18
- package/scripts/redis-monitor.js +284 -0
- package/scripts/redis-setup.js +412 -0
- package/scripts/test-memory-retrieval.js +201 -0
- package/scripts/validate-exports.js +68 -0
- package/scripts/validate-package.js +120 -0
- package/scripts/verify-onyx-deployment.js +309 -0
- package/scripts/verify-redis-deployment.js +354 -0
- package/scripts/verify-redis-init.js +219 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
# Boss Claude Validators
|
|
2
|
+
|
|
3
|
+
Validation utilities for Boss Claude integrations and credentials.
|
|
4
|
+
|
|
5
|
+
## GitHub Token Validator
|
|
6
|
+
|
|
7
|
+
Validates GitHub personal access tokens to ensure they have the required permissions for Boss Claude operations.
|
|
8
|
+
|
|
9
|
+
### Required Permissions
|
|
10
|
+
|
|
11
|
+
- **Issues**: Read/Write access
|
|
12
|
+
- **Contents**: Read/Write access
|
|
13
|
+
|
|
14
|
+
### Usage
|
|
15
|
+
|
|
16
|
+
#### Basic Validation
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
import { validateGitHubToken } from './lib/validators/github.js';
|
|
20
|
+
|
|
21
|
+
const result = await validateGitHubToken('ghp_your_token_here');
|
|
22
|
+
|
|
23
|
+
if (result.valid) {
|
|
24
|
+
console.log(`✅ Token valid for user: ${result.user}`);
|
|
25
|
+
console.log(`Scopes: ${result.scopes.join(', ')}`);
|
|
26
|
+
} else {
|
|
27
|
+
console.log(`❌ ${result.error}`);
|
|
28
|
+
console.log(result.suggestion);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Strict Mode
|
|
33
|
+
|
|
34
|
+
Strict mode requires exact scope matches rather than allowing broader scopes:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const result = await validateGitHubToken('ghp_token', { strict: true });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Repository-Specific Testing
|
|
41
|
+
|
|
42
|
+
Test token permissions against a specific repository:
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
import { testTokenOnRepository } from './lib/validators/github.js';
|
|
46
|
+
|
|
47
|
+
const result = await testTokenOnRepository(
|
|
48
|
+
'ghp_token',
|
|
49
|
+
'cpretzinger',
|
|
50
|
+
'boss-claude'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
console.log(`Read Issues: ${result.tests.readIssues}`);
|
|
54
|
+
console.log(`Write Issues: ${result.tests.writeIssues}`);
|
|
55
|
+
console.log(`Read Contents: ${result.tests.readContents}`);
|
|
56
|
+
console.log(`Write Contents: ${result.tests.writeContents}`);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### CLI Validation
|
|
60
|
+
|
|
61
|
+
Use the test script for quick validation:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Basic validation
|
|
65
|
+
node lib/validators/github.test.js ghp_your_token_here
|
|
66
|
+
|
|
67
|
+
# Test against specific repository
|
|
68
|
+
node lib/validators/github.test.js ghp_your_token_here cpretzinger boss-claude
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Response Format
|
|
72
|
+
|
|
73
|
+
#### Success Response
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
{
|
|
77
|
+
valid: true,
|
|
78
|
+
user: 'username',
|
|
79
|
+
scopes: ['repo', 'workflow'],
|
|
80
|
+
permissions: {
|
|
81
|
+
issues: 'read/write',
|
|
82
|
+
contents: 'read/write'
|
|
83
|
+
},
|
|
84
|
+
message: '✅ GitHub token valid for user: username'
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Error Response
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
{
|
|
92
|
+
valid: false,
|
|
93
|
+
user: 'username',
|
|
94
|
+
scopes: ['public_repo'],
|
|
95
|
+
error: 'Token is missing required permissions',
|
|
96
|
+
missingPermissions: ['issues', 'contents'],
|
|
97
|
+
currentPermissions: {
|
|
98
|
+
issues: 'none or read-only',
|
|
99
|
+
contents: 'read/write'
|
|
100
|
+
},
|
|
101
|
+
suggestion: 'To fix this, create a new GitHub token...'
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Supported Token Scopes
|
|
106
|
+
|
|
107
|
+
The validator recognizes these GitHub token scopes:
|
|
108
|
+
|
|
109
|
+
| Scope | Description | Provides Issues R/W | Provides Contents R/W |
|
|
110
|
+
|-------|-------------|--------------------|-----------------------|
|
|
111
|
+
| `repo` | Full repository access | ✅ | ✅ |
|
|
112
|
+
| `public_repo` | Public repository access | ✅ | ✅ |
|
|
113
|
+
| `issues` | Issues read/write | ✅ | ❌ |
|
|
114
|
+
| `contents` | Contents read/write | ❌ | ✅ |
|
|
115
|
+
|
|
116
|
+
### Creating a GitHub Token
|
|
117
|
+
|
|
118
|
+
#### Classic Personal Access Token
|
|
119
|
+
|
|
120
|
+
1. Go to [GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)](https://github.com/settings/tokens)
|
|
121
|
+
2. Click "Generate new token (classic)"
|
|
122
|
+
3. Select scopes:
|
|
123
|
+
- ✅ `repo` (Full control of private repositories) - **Recommended**
|
|
124
|
+
- OR select individual scopes:
|
|
125
|
+
- ✅ `public_repo` (Access public repositories)
|
|
126
|
+
- ✅ `issues` (Read/write issues)
|
|
127
|
+
4. Click "Generate token"
|
|
128
|
+
5. Copy and save the token immediately
|
|
129
|
+
|
|
130
|
+
#### Fine-Grained Personal Access Token
|
|
131
|
+
|
|
132
|
+
1. Go to [GitHub Settings > Developer settings > Personal access tokens > Fine-grained tokens](https://github.com/settings/personal-access-tokens/new)
|
|
133
|
+
2. Set repository access (all repositories or specific repos)
|
|
134
|
+
3. Set permissions:
|
|
135
|
+
- **Issues**: Read and write
|
|
136
|
+
- **Contents**: Read and write
|
|
137
|
+
4. Click "Generate token"
|
|
138
|
+
5. Copy and save the token immediately
|
|
139
|
+
|
|
140
|
+
### Error Handling
|
|
141
|
+
|
|
142
|
+
The validator handles these error cases:
|
|
143
|
+
|
|
144
|
+
- **401 Unauthorized**: Invalid or expired token
|
|
145
|
+
- **403 Forbidden**: Rate limit exceeded or insufficient permissions
|
|
146
|
+
- **Network errors**: Connection issues
|
|
147
|
+
- **Invalid scopes**: Missing required permissions
|
|
148
|
+
|
|
149
|
+
Each error includes:
|
|
150
|
+
- Clear error message
|
|
151
|
+
- Details about what went wrong
|
|
152
|
+
- Actionable suggestions to fix the issue
|
|
153
|
+
|
|
154
|
+
### Integration Example
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
import { validateGitHubToken } from '@cpretzinger/boss-claude/lib/validators/github.js';
|
|
158
|
+
|
|
159
|
+
async function setupGitHub(token) {
|
|
160
|
+
const validation = await validateGitHubToken(token);
|
|
161
|
+
|
|
162
|
+
if (!validation.valid) {
|
|
163
|
+
throw new Error(`GitHub setup failed: ${validation.error}\n${validation.suggestion}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log(`✅ GitHub configured for ${validation.user}`);
|
|
167
|
+
return validation;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Testing
|
|
172
|
+
|
|
173
|
+
Run the test suite:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Test with your token
|
|
177
|
+
npm test -- --token=ghp_your_token_here
|
|
178
|
+
|
|
179
|
+
# Test against specific repository
|
|
180
|
+
npm test -- --token=ghp_token --owner=cpretzinger --repo=boss-claude
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Security Notes
|
|
184
|
+
|
|
185
|
+
- **Never commit tokens to version control**
|
|
186
|
+
- Use environment variables for token storage
|
|
187
|
+
- Rotate tokens regularly
|
|
188
|
+
- Use fine-grained tokens when possible (more secure)
|
|
189
|
+
- Limit token scope to minimum required permissions
|
|
190
|
+
- Set token expiration dates
|
|
191
|
+
|
|
192
|
+
### Troubleshooting
|
|
193
|
+
|
|
194
|
+
#### "Token is missing required permissions"
|
|
195
|
+
|
|
196
|
+
Your token doesn't have the necessary scopes. Create a new token with:
|
|
197
|
+
- `repo` scope (recommended), OR
|
|
198
|
+
- Both `issues` and `contents` scopes
|
|
199
|
+
|
|
200
|
+
#### "Invalid or expired GitHub token"
|
|
201
|
+
|
|
202
|
+
Your token is no longer valid. Generate a new token at GitHub settings.
|
|
203
|
+
|
|
204
|
+
#### "GitHub API rate limit exceeded"
|
|
205
|
+
|
|
206
|
+
You've hit the API rate limit. Authenticated requests have a limit of 5,000 requests per hour. Wait for the rate limit to reset or check your usage.
|
|
207
|
+
|
|
208
|
+
#### "Failed to validate GitHub token"
|
|
209
|
+
|
|
210
|
+
Network or connection issue. Check:
|
|
211
|
+
- Internet connection
|
|
212
|
+
- GitHub API status: https://www.githubstatus.com/
|
|
213
|
+
- Firewall settings
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## PostgreSQL Validator
|
|
218
|
+
|
|
219
|
+
Comprehensive PostgreSQL connection validation with SSL error handling, schema checking, and Railway-specific optimizations.
|
|
220
|
+
|
|
221
|
+
### Features
|
|
222
|
+
|
|
223
|
+
- URL format validation
|
|
224
|
+
- Connection testing with automatic retries
|
|
225
|
+
- SSL error handling (graceful fallback)
|
|
226
|
+
- Schema verification (`boss_claude` schema and tables)
|
|
227
|
+
- PostgreSQL version detection
|
|
228
|
+
- Railway database auto-detection and optimization
|
|
229
|
+
- Detailed error reporting with actionable suggestions
|
|
230
|
+
|
|
231
|
+
### Quick Start
|
|
232
|
+
|
|
233
|
+
```javascript
|
|
234
|
+
import validator from './lib/validators/postgres.js';
|
|
235
|
+
|
|
236
|
+
const result = await validator.validate(process.env.BOSS_CLAUDE_PG_URL);
|
|
237
|
+
|
|
238
|
+
if (result.valid) {
|
|
239
|
+
console.log('✓ PostgreSQL connection is valid');
|
|
240
|
+
console.log(`Database: ${result.connection.database}`);
|
|
241
|
+
console.log(`Version: ${result.connection.versionNumber}`);
|
|
242
|
+
} else {
|
|
243
|
+
console.error('✗ Validation failed:', result.connection.error);
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Formatted Report
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
import validator from './lib/validators/postgres.js';
|
|
251
|
+
|
|
252
|
+
const result = await validator.validate(url);
|
|
253
|
+
validator.printReport(result);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Example output:
|
|
257
|
+
```
|
|
258
|
+
=== PostgreSQL Validation Report ===
|
|
259
|
+
|
|
260
|
+
URL Validation:
|
|
261
|
+
✓ Valid PostgreSQL URL
|
|
262
|
+
Host: your-postgres-host.example.com:5432
|
|
263
|
+
Database: railway
|
|
264
|
+
User: postgres
|
|
265
|
+
Platform: Railway
|
|
266
|
+
|
|
267
|
+
Connection Test:
|
|
268
|
+
✓ Connected successfully
|
|
269
|
+
Version: PostgreSQL 17.7
|
|
270
|
+
Uptime: Wed Jan 21 2026 06:02:51 GMT-0700 (Mountain Standard Time)
|
|
271
|
+
SSL: Enabled
|
|
272
|
+
|
|
273
|
+
Schema Check:
|
|
274
|
+
✓ Schema boss_claude exists
|
|
275
|
+
Tables: 4 (achievements, memory_snapshots, sessions, stats_rollups)
|
|
276
|
+
Functions: 3
|
|
277
|
+
✓ All expected tables present
|
|
278
|
+
|
|
279
|
+
Summary:
|
|
280
|
+
Overall Status: ✓ VALID
|
|
281
|
+
Test Duration: 1186ms
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Individual Functions
|
|
285
|
+
|
|
286
|
+
#### URL Validation
|
|
287
|
+
|
|
288
|
+
```javascript
|
|
289
|
+
import { validateUrl } from './lib/validators/postgres.js';
|
|
290
|
+
|
|
291
|
+
const result = validateUrl('postgresql://user:pass@host:5432/db');
|
|
292
|
+
|
|
293
|
+
if (result.valid) {
|
|
294
|
+
console.log('Host:', result.components.host);
|
|
295
|
+
console.log('Port:', result.components.port);
|
|
296
|
+
console.log('Database:', result.components.database);
|
|
297
|
+
console.log('Is Railway:', result.components.isRailway);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### Connection Test
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
import { testConnection } from './lib/validators/postgres.js';
|
|
305
|
+
|
|
306
|
+
const result = await testConnection(url, {
|
|
307
|
+
ssl: true,
|
|
308
|
+
timeout: 5000,
|
|
309
|
+
maxRetries: 2
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
if (result.connected) {
|
|
313
|
+
console.log('Version:', result.versionNumber);
|
|
314
|
+
console.log('SSL Enabled:', result.sslEnabled);
|
|
315
|
+
console.log('Retries:', result.retryCount);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Schema Check
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
import { checkSchema } from './lib/validators/postgres.js';
|
|
323
|
+
|
|
324
|
+
const result = await checkSchema(url);
|
|
325
|
+
|
|
326
|
+
if (result.exists) {
|
|
327
|
+
console.log('Tables:', result.tables);
|
|
328
|
+
console.log('Missing:', result.missingTables);
|
|
329
|
+
console.log('Complete:', result.complete);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Configuration Options
|
|
334
|
+
|
|
335
|
+
```javascript
|
|
336
|
+
await validator.validate(url, {
|
|
337
|
+
ssl: true, // Enable SSL (default: true)
|
|
338
|
+
timeout: 5000, // Connection timeout in ms (default: 5000)
|
|
339
|
+
maxRetries: 2 // Max SSL retry attempts (default: 2)
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Error Handling
|
|
344
|
+
|
|
345
|
+
The validator handles common PostgreSQL errors gracefully:
|
|
346
|
+
|
|
347
|
+
**SSL Certificate Errors**
|
|
348
|
+
```javascript
|
|
349
|
+
{
|
|
350
|
+
connected: false,
|
|
351
|
+
error: 'SSL connection failed',
|
|
352
|
+
details: {
|
|
353
|
+
suggestion: 'Try setting ssl: false or ensure SSL certificates are valid',
|
|
354
|
+
railwayNote: 'Railway requires rejectUnauthorized: false in SSL config'
|
|
355
|
+
},
|
|
356
|
+
retried: true,
|
|
357
|
+
retryCount: 1
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Authentication Errors**
|
|
362
|
+
```javascript
|
|
363
|
+
{
|
|
364
|
+
connected: false,
|
|
365
|
+
error: 'Authentication failed',
|
|
366
|
+
details: {
|
|
367
|
+
code: '28P01',
|
|
368
|
+
suggestion: 'Verify username and password in connection URL'
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Connection Timeout**
|
|
374
|
+
```javascript
|
|
375
|
+
{
|
|
376
|
+
connected: false,
|
|
377
|
+
error: 'Connection timeout',
|
|
378
|
+
details: {
|
|
379
|
+
timeout: 5000,
|
|
380
|
+
suggestion: 'Check network connectivity or increase timeout value'
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**Connection Refused**
|
|
386
|
+
```javascript
|
|
387
|
+
{
|
|
388
|
+
connected: false,
|
|
389
|
+
error: 'Connection refused',
|
|
390
|
+
details: {
|
|
391
|
+
suggestion: 'Verify host and port are correct and server is running'
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### CLI Testing
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
# Test with environment variable
|
|
400
|
+
export BOSS_CLAUDE_PG_URL="postgresql://user:pass@host:5432/db"
|
|
401
|
+
node test-postgres-validator.js
|
|
402
|
+
|
|
403
|
+
# Test with explicit URL
|
|
404
|
+
node test-postgres-validator.js "postgresql://user:pass@host:5432/db"
|
|
405
|
+
|
|
406
|
+
# Run unit tests
|
|
407
|
+
node test-postgres-validator-units.js
|
|
408
|
+
|
|
409
|
+
# Run error scenario tests
|
|
410
|
+
node test-postgres-validator-scenarios.js
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Railway-Specific Features
|
|
414
|
+
|
|
415
|
+
The validator automatically detects Railway databases and applies optimal settings:
|
|
416
|
+
|
|
417
|
+
- Sets `rejectUnauthorized: false` for SSL (required by Railway)
|
|
418
|
+
- Identifies Railway hosts (`railway.app`, `rlwy.net`)
|
|
419
|
+
- Provides Railway-specific error messages
|
|
420
|
+
|
|
421
|
+
### Schema Requirements
|
|
422
|
+
|
|
423
|
+
Boss Claude expects these tables in the `boss_claude` schema:
|
|
424
|
+
|
|
425
|
+
- `sessions` - Boss Claude session tracking
|
|
426
|
+
- `achievements` - User achievement records
|
|
427
|
+
- `memory_snapshots` - State persistence
|
|
428
|
+
|
|
429
|
+
Missing tables are reported in `missingTables`.
|
|
430
|
+
|
|
431
|
+
### Integration Example
|
|
432
|
+
|
|
433
|
+
```javascript
|
|
434
|
+
import validator from './lib/validators/postgres.js';
|
|
435
|
+
|
|
436
|
+
async function ensureValidConnection() {
|
|
437
|
+
const url = process.env.BOSS_CLAUDE_PG_URL;
|
|
438
|
+
|
|
439
|
+
if (!url) {
|
|
440
|
+
throw new Error('BOSS_CLAUDE_PG_URL not set');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const result = await validator.validate(url, {
|
|
444
|
+
ssl: true,
|
|
445
|
+
timeout: 5000,
|
|
446
|
+
maxRetries: 2
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
if (!result.valid) {
|
|
450
|
+
console.error('PostgreSQL validation failed');
|
|
451
|
+
validator.printReport(result);
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (!result.schema.complete) {
|
|
456
|
+
console.warn('Warning: Missing tables:', result.schema.missingTables);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
console.log('✓ PostgreSQL connection validated');
|
|
460
|
+
return result;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Use in startup
|
|
464
|
+
await ensureValidConnection();
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Troubleshooting
|
|
468
|
+
|
|
469
|
+
**"SSL connection failed"**
|
|
470
|
+
- Railway databases require `rejectUnauthorized: false`
|
|
471
|
+
- The validator handles this automatically with retry logic
|
|
472
|
+
- If retry fails, check firewall/network settings
|
|
473
|
+
|
|
474
|
+
**"Authentication failed"**
|
|
475
|
+
- Verify username and password in connection URL
|
|
476
|
+
- Check if database user exists and has proper permissions
|
|
477
|
+
- Ensure password is URL-encoded if it contains special characters
|
|
478
|
+
|
|
479
|
+
**"Connection timeout"**
|
|
480
|
+
- Increase timeout value: `{ timeout: 10000 }`
|
|
481
|
+
- Check network connectivity
|
|
482
|
+
- Verify database host is accessible
|
|
483
|
+
|
|
484
|
+
**"Schema boss_claude does not exist"**
|
|
485
|
+
- Run database initialization script
|
|
486
|
+
- Create schema manually: `CREATE SCHEMA boss_claude;`
|
|
487
|
+
- Check if connected to correct database
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## Future Validators
|
|
492
|
+
|
|
493
|
+
Additional validators planned for Boss Claude:
|
|
494
|
+
|
|
495
|
+
- **Redis**: Connection and command permission validation
|
|
496
|
+
- **OpenAI**: API key and quota validation
|
|
497
|
+
- **Email**: SMTP/IMAP credential validation
|