jasper-context-compactor 0.3.3 → 0.3.4

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 +21 -14
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -51,19 +51,22 @@ async function detectModelContextWindow(config) {
51
51
  const modelId = config?.agents?.defaults?.model?.primary;
52
52
  if (!modelId) return null;
53
53
 
54
- // Parse provider/model from the model ID (e.g., "anthropic/claude-opus-4-5")
54
+ // Parse provider/model from the model ID (e.g., "ollama/qwen2.5")
55
55
  const [providerName, ...modelParts] = modelId.split('/');
56
- const modelName = modelParts.join('/');
56
+ const modelName = modelParts.join('/'); // e.g., "qwen2.5"
57
57
 
58
58
  // Look up in config's models.providers
59
59
  const providers = config?.models?.providers || {};
60
60
  const provider = providers[providerName];
61
61
 
62
62
  if (provider?.models) {
63
- // Find the model in the provider's models array
64
- const modelConfig = provider.models.find(m =>
65
- m.id === modelName || m.id === modelId
66
- );
63
+ // Find the model - compare against just the model name (without provider prefix)
64
+ // e.g., config has id:"qwen2.5", we're looking for "ollama/qwen2.5"
65
+ const modelConfig = provider.models.find(m => {
66
+ if (!m.id) return false;
67
+ // Match: exact ID, or model name matches, or ID matches without provider prefix
68
+ return m.id === modelId || m.id === modelName || modelName.includes(m.id) || m.id.includes(modelName);
69
+ });
67
70
 
68
71
  if (modelConfig?.contextWindow) {
69
72
  return {
@@ -75,17 +78,21 @@ async function detectModelContextWindow(config) {
75
78
  }
76
79
  }
77
80
 
78
- // Fallback: check for ollama models with contextWindow in the config
81
+ // Fallback: check ALL providers for a matching model ID
79
82
  for (const [pName, pConfig] of Object.entries(providers)) {
80
83
  if (pConfig?.models) {
81
84
  for (const m of pConfig.models) {
82
- if (m.id && modelId.includes(m.id) && m.contextWindow) {
83
- return {
84
- model: modelId,
85
- tokens: m.contextWindow,
86
- source: 'config',
87
- maxTokens: m.maxTokens
88
- };
85
+ if (!m.id) continue;
86
+ // Flexible matching: model ID contains or is contained by what we're looking for
87
+ if (m.id === modelName || modelName.includes(m.id) || m.id.includes(modelName)) {
88
+ if (m.contextWindow) {
89
+ return {
90
+ model: modelId,
91
+ tokens: m.contextWindow,
92
+ source: 'config',
93
+ maxTokens: m.maxTokens
94
+ };
95
+ }
89
96
  }
90
97
  }
91
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jasper-context-compactor",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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": {