@plexor-dev/claude-code-plugin 0.1.0-beta.25 → 0.1.0-beta.27
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/commands/plexor-setup.md
CHANGED
|
@@ -31,15 +31,15 @@ Run /plexor-settings to modify configuration.
|
|
|
31
31
|
Run /plexor-enabled off to disable routing.
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
**Step 2: Ask about Claude
|
|
34
|
+
**Step 2: Ask about Claude subscription**
|
|
35
35
|
|
|
36
36
|
Use the AskUserQuestion tool:
|
|
37
37
|
|
|
38
|
-
Question: "
|
|
39
|
-
Header: "
|
|
38
|
+
Question: "How do you pay for Claude usage?"
|
|
39
|
+
Header: "Billing"
|
|
40
40
|
Options:
|
|
41
|
-
1. **
|
|
42
|
-
2. **
|
|
41
|
+
1. **Claude MAX subscription (Pro/Team/Enterprise)** - I have a subscription and want Plexor for optimization & tracking (you'll still need a Plexor API key)
|
|
42
|
+
2. **Pay-per-use via Plexor** - I want Plexor to handle billing and route to the cheapest provider
|
|
43
43
|
|
|
44
44
|
**Step 3A: Claude MAX User Setup**
|
|
45
45
|
|
|
@@ -11,8 +11,30 @@ const https = require('https');
|
|
|
11
11
|
|
|
12
12
|
const CONFIG_PATH = path.join(process.env.HOME, '.plexor', 'config.json');
|
|
13
13
|
const SESSION_PATH = path.join(process.env.HOME, '.plexor', 'session.json');
|
|
14
|
+
const CLAUDE_SETTINGS_PATH = path.join(process.env.HOME, '.claude', 'settings.json');
|
|
14
15
|
const SESSION_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Check if Claude Code is actually routing through Plexor
|
|
19
|
+
* by reading ~/.claude/settings.json
|
|
20
|
+
*/
|
|
21
|
+
function getRoutingStatus() {
|
|
22
|
+
try {
|
|
23
|
+
const data = fs.readFileSync(CLAUDE_SETTINGS_PATH, 'utf8');
|
|
24
|
+
const settings = JSON.parse(data);
|
|
25
|
+
const baseUrl = settings.env?.ANTHROPIC_BASE_URL || '';
|
|
26
|
+
const hasToken = !!settings.env?.ANTHROPIC_AUTH_TOKEN;
|
|
27
|
+
const isPlexorRouting = baseUrl.includes('plexor') || baseUrl.includes('staging.api');
|
|
28
|
+
return {
|
|
29
|
+
active: isPlexorRouting && hasToken,
|
|
30
|
+
baseUrl,
|
|
31
|
+
isStaging: baseUrl.includes('staging')
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return { active: false, baseUrl: null, isStaging: false };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
function loadSessionStats() {
|
|
17
39
|
try {
|
|
18
40
|
const data = fs.readFileSync(SESSION_PATH, 'utf8');
|
|
@@ -138,8 +160,13 @@ ${line(`├── Tokens saved: ${sessionTokensSaved} (${sessionTokensSavedPct}%
|
|
|
138
160
|
${line(`└── Cost saved: $${sessionCostSaved}`)}
|
|
139
161
|
` : '';
|
|
140
162
|
|
|
163
|
+
// Get routing status from Claude settings.json
|
|
164
|
+
const routing = getRoutingStatus();
|
|
165
|
+
const routingIndicator = routing.active ? '🟢 PLEXOR MODE: ON' : '🔴 PLEXOR MODE: OFF';
|
|
166
|
+
const envLabel = routing.isStaging ? '(staging)' : '(production)';
|
|
167
|
+
|
|
141
168
|
console.log(` ┌─────────────────────────────────────────────┐
|
|
142
|
-
${line('
|
|
169
|
+
${line(routingIndicator + (routing.active ? ' ' + envLabel : ''))}
|
|
143
170
|
├─────────────────────────────────────────────┤
|
|
144
171
|
${line(`Account: ${tierName}`)}
|
|
145
172
|
${line(`Email: ${email}`)}
|
package/lib/settings-manager.js
CHANGED
|
@@ -74,7 +74,8 @@ class ClaudeSettingsManager {
|
|
|
74
74
|
* @returns {boolean} success status
|
|
75
75
|
*/
|
|
76
76
|
enablePlexorRouting(apiKey, options = {}) {
|
|
77
|
-
|
|
77
|
+
// Default to production. Use useStaging: true for staging keys.
|
|
78
|
+
const { useStaging = false } = options;
|
|
78
79
|
const apiUrl = useStaging ? PLEXOR_STAGING_URL : PLEXOR_PROD_URL;
|
|
79
80
|
|
|
80
81
|
try {
|
package/package.json
CHANGED