jasper-context-compactor 0.3.6 → 0.3.7

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.
Files changed (2) hide show
  1. package/cli.js +35 -14
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -48,12 +48,42 @@ function backupConfig() {
48
48
  }
49
49
 
50
50
  // Local model providers that benefit from context compaction
51
- const LOCAL_PROVIDERS = ['ollama', 'lmstudio', 'llamacpp', 'mlx', 'friend-gpu', 'openrouter'];
51
+ const LOCAL_PROVIDER_NAMES = ['ollama', 'lmstudio', 'llamacpp', 'mlx', 'friend-gpu', 'openrouter'];
52
52
 
53
- function isLocalProvider(providerId) {
53
+ // URLs that indicate local/Ollama endpoints
54
+ const LOCAL_URL_PATTERNS = [
55
+ ':11434', // Ollama default port
56
+ 'localhost',
57
+ '127.0.0.1',
58
+ '0.0.0.0',
59
+ /100\.\d+\.\d+\.\d+/, // Tailscale
60
+ /192\.168\.\d+\.\d+/, // Local network
61
+ /10\.\d+\.\d+\.\d+/, // Private network
62
+ ];
63
+
64
+ function isLocalProvider(providerId, providers = {}) {
54
65
  if (!providerId) return false;
55
66
  const lower = providerId.toLowerCase();
56
- return LOCAL_PROVIDERS.some(p => lower.includes(p));
67
+
68
+ // Check provider name
69
+ if (LOCAL_PROVIDER_NAMES.some(p => lower.includes(p))) {
70
+ return true;
71
+ }
72
+
73
+ // Check provider's baseUrl for local patterns
74
+ const provider = providers[providerId];
75
+ if (provider?.baseUrl) {
76
+ const url = provider.baseUrl.toLowerCase();
77
+ for (const pattern of LOCAL_URL_PATTERNS) {
78
+ if (pattern instanceof RegExp) {
79
+ if (pattern.test(url)) return true;
80
+ } else {
81
+ if (url.includes(pattern)) return true;
82
+ }
83
+ }
84
+ }
85
+
86
+ return false;
57
87
  }
58
88
 
59
89
  async function detectModelContextWindow(config) {
@@ -78,8 +108,8 @@ async function detectModelContextWindow(config) {
78
108
  const [providerName, ...modelParts] = modelId.split('/');
79
109
  const modelName = modelParts.join('/'); // e.g., "qwen2.5"
80
110
 
81
- // Check if this is a local provider
82
- if (isLocalProvider(providerName)) {
111
+ // Check if this is a local provider (by name or baseUrl)
112
+ if (isLocalProvider(providerName, providers)) {
83
113
  hasLocalModel = true;
84
114
 
85
115
  const provider = providers[providerName];
@@ -251,15 +281,6 @@ async function setup() {
251
281
  console.log(' Local models (Ollama, llama.cpp, MLX, LM Studio) don\'t report');
252
282
  console.log(' context overflow errors — they silently truncate or produce garbage.');
253
283
  console.log(' This plugin is HIGHLY recommended for your setup.');
254
- } else if (detectedInfo?.model) {
255
- // Cloud-only config
256
- const providerName = detectedInfo.model.split('/')[0] || '';
257
- if (['anthropic', 'openai', 'google'].includes(providerName.toLowerCase())) {
258
- console.log('');
259
- console.log(' ℹ️ Cloud-only config detected (no local models).');
260
- console.log(' Cloud APIs report context limits properly, so this plugin');
261
- console.log(' is less critical — but can still help with token costs.');
262
- }
263
284
  }
264
285
 
265
286
  if (detectedInfo && detectedInfo.tokens) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jasper-context-compactor",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Context compaction plugin for OpenClaw - works with local models (MLX, llama.cpp) that don't report token limits",
5
5
  "main": "index.ts",
6
6
  "bin": {