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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Options:
-v, --version output the version number
-p, --port <port> port to run server on (default: 8000)
-d, --debug enable debug mode (runs in foreground)
-m, --mock enable mock mode (simulates Claude CLI responses)
-k, --api-key <key> set API key for endpoint protection
-n, --no-interactive disable interactive API key setup
-P, --production enable production server management features
Expand Down Expand Up @@ -154,6 +155,16 @@ wrapper --stop
wrapper -s # shorthand
```

## 🎭 Mock Mode

Develop and test without Claude CLI dependency! Mock mode provides ultra-fast simulation (300x faster) with complete API compatibility.

```bash
wrapper --mock # Enable mock mode
```

📖 **[Mock Mode Guide](docs/MOCK_MODE.md)** - Complete documentation and configuration.

## 📚 Documentation

📖 **[Full Documentation](docs/README.md)** - Comprehensive guide with detailed examples, production deployment, troubleshooting, and advanced configuration.
Expand Down
29 changes: 29 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Options:
-H, --health-monitoring enable health monitoring system
-s, --stop stop background server
-t, --status check background server status
-m, --mock enable mock mode for testing (instant responses)
-h, --help display help for command
```

Expand All @@ -101,6 +102,34 @@ wrapper --api-key my-secure-key
wrapper -k my-secure-key # shorthand
```

### Mock Mode for Testing

**Mock mode provides instant responses for performance testing and development:**

```bash
# Enable mock mode for testing
wrapper --mock
wrapper -m # shorthand

# Combine with other options
wrapper --mock --debug # mock mode with debug output
wrapper --mock --port 9999 # mock mode on custom port
```

Mock mode returns realistic Claude CLI responses instantly without making actual API calls, perfect for:
- Performance testing and load testing
- Development and debugging
- CI/CD pipeline testing
- Offline development environments

**Mock Mode Features:**
- Instant response generation (no API delays)
- Realistic Claude CLI JSON response format
- Streaming support with word-by-word content deltas
- Automatic token calculation based on prompt length
- Unique session ID generation for each request
- Compatible with all existing endpoints and authentication

## 📡 API Endpoints

| Method | Endpoint | Description |
Expand Down
7 changes: 0 additions & 7 deletions app/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
module.exports = {
// Custom reporter with automatic log cleanup and organized results
reporters: [
"default",
["<rootDir>/tests/scripts/custom-reporter.js", {}],
["<rootDir>/tests/scripts/verbose-reporter.js", {}]
],

// Projects setup for organized test types
projects: [
"<rootDir>/tests/jest.unit.config.js",
Expand Down
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"build": "tsc > build.log 2>&1",
"prepublishOnly": "npm run build",
"start": "node dist/cli.js",
"stop": "node dist/cli.js --stop",
"status": "node dist/cli.js --status",
"dev": "ts-node src/cli.ts",
"test": "jest",
"test:unit": "jest --config tests/jest.unit.config.js",
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/middleware/model-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Request, Response, NextFunction } from 'express';
import { logger } from '../../utils/logger';

// Valid Claude models - only confirmed models from CLI reference
const VALID_CLAUDE_MODELS = ['sonnet', 'opus'];
const VALID_CLAUDE_MODELS = ['sonnet', 'opus', 'haiku'];

export class ModelValidationError extends Error {
public readonly statusCode: number;
Expand Down
154 changes: 0 additions & 154 deletions app/src/api/middleware/session.ts

This file was deleted.

5 changes: 2 additions & 3 deletions app/src/api/routes/chat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router, Request, Response } from 'express';
import { CoreWrapper } from '../../core/wrapper';
import { sharedCoreWrapper } from '../../core/shared-wrapper';
import { StreamingHandler } from '../../streaming/handler';
import { OpenAIRequest } from '../../types';
import { InvalidRequestError } from '../../utils/errors';
Expand All @@ -9,7 +9,6 @@ import { modelValidationMiddleware } from '../middleware/model-validation';
import { logger } from '../../utils/logger';

const router = Router();
const coreWrapper = new CoreWrapper();
const streamingHandler = new StreamingHandler();

// Apply validation and streaming middleware to chat completions
Expand Down Expand Up @@ -61,7 +60,7 @@ router.post('/v1/chat/completions',
});

// Handle non-streaming request
const response = await coreWrapper.handleChatCompletion(request);
const response = await sharedCoreWrapper.handleChatCompletion(request);

logger.info('Chat completion request completed successfully', {
requestId: response.id,
Expand Down
4 changes: 3 additions & 1 deletion app/src/api/routes/health.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Router, Request, Response } from 'express';
import { asyncHandler } from '../middleware/error';
import { EnvironmentManager } from '../../config/env';
import * as packageJson from '../../../package.json';

const router = Router();
Expand All @@ -10,7 +11,8 @@ router.get('/health', asyncHandler(async (_req: Request, res: Response) => {
service: packageJson.name,
version: packageJson.version,
description: packageJson.description,
timestamp: new Date().toISOString()
timestamp: new Date().toISOString(),
mock_mode: EnvironmentManager.isMockMode()
});
}));

Expand Down
Loading
Loading