@opencompress/openclaw 3.0.6 → 3.0.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/dist/index.js +42 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  });
7
7
 
8
8
  // src/config.ts
9
- var VERSION = "3.0.6";
9
+ var VERSION = "3.0.7";
10
10
  var PROXY_PORT = 8401;
11
11
  var PROXY_HOST = "127.0.0.1";
12
12
  var OCC_API = "https://www.opencompress.ai/api";
@@ -491,38 +491,54 @@ function injectConfig(api) {
491
491
  if (!fs.existsSync(configPath)) return;
492
492
  const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
493
493
  let changed = false;
494
+ if (!cfg.agents) cfg.agents = {};
495
+ if (!cfg.agents.defaults) cfg.agents.defaults = {};
496
+ if (!cfg.agents.defaults.models) cfg.agents.defaults.models = {};
494
497
  if (!cfg.models) cfg.models = {};
495
498
  if (!cfg.models.providers) cfg.models.providers = {};
496
- const providers = getProviders(api);
497
- const models = generateModelCatalog(providers);
498
- const firstProvider = Object.values(providers).find((p) => p.api);
499
- const primaryApi = firstProvider?.api || "anthropic-messages";
499
+ const existingModels = Object.keys(cfg.agents.defaults.models).filter((id) => !id.startsWith("opencompress/"));
500
500
  const occKey = getApiKey(api) || "auto-provision-pending";
501
- if (!cfg.models.providers.opencompress || cfg.models.providers.opencompress.baseUrl !== `http://${PROXY_HOST}:${PROXY_PORT}/v1`) {
502
- cfg.models.providers.opencompress = {
503
- baseUrl: `http://${PROXY_HOST}:${PROXY_PORT}/v1`,
501
+ const hasAnthropic = existingModels.some((m) => m.startsWith("anthropic/"));
502
+ const hasOpenAI = existingModels.some((m) => m.startsWith("openai/"));
503
+ const primaryApi = hasAnthropic ? "anthropic-messages" : "openai-completions";
504
+ const compressedModels = [
505
+ {
506
+ id: "opencompress/auto",
507
+ name: "OpenCompress Auto (compressed)",
504
508
  api: primaryApi,
505
- apiKey: occKey,
506
- models: models.map((m) => ({
507
- id: m.id,
508
- name: m.name,
509
- api: primaryApi,
510
- reasoning: m.reasoning ?? false,
511
- input: m.input || ["text"],
512
- cost: m.cost || { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
513
- contextWindow: m.contextWindow || 2e5,
514
- maxTokens: m.maxTokens || 8192
515
- }))
516
- };
517
- changed = true;
509
+ reasoning: false,
510
+ input: ["text", "image"],
511
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
512
+ contextWindow: 2e5,
513
+ maxTokens: 8192
514
+ }
515
+ ];
516
+ for (const modelId of existingModels) {
517
+ const compressedId = `opencompress/${modelId}`;
518
+ const provider = modelId.split("/")[0];
519
+ const modelApi = provider === "anthropic" ? "anthropic-messages" : "openai-completions";
520
+ const modelName = modelId.split("/").slice(1).join("/");
521
+ compressedModels.push({
522
+ id: compressedId,
523
+ name: `${modelName} (compressed)`,
524
+ api: modelApi,
525
+ reasoning: modelId.includes("opus") || modelId.includes("o1") || modelId.includes("o3"),
526
+ input: ["text", "image"],
527
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
528
+ contextWindow: 2e5,
529
+ maxTokens: 8192
530
+ });
518
531
  }
519
- if (!cfg.agents) cfg.agents = {};
520
- if (!cfg.agents.defaults) cfg.agents.defaults = {};
521
- if (!cfg.agents.defaults.models) cfg.agents.defaults.models = {};
522
- for (const m of models) {
532
+ cfg.models.providers.opencompress = {
533
+ baseUrl: `http://${PROXY_HOST}:${PROXY_PORT}/v1`,
534
+ api: primaryApi,
535
+ apiKey: occKey,
536
+ models: compressedModels
537
+ };
538
+ changed = true;
539
+ for (const m of compressedModels) {
523
540
  if (!cfg.agents.defaults.models[m.id]) {
524
541
  cfg.agents.defaults.models[m.id] = {};
525
- changed = true;
526
542
  }
527
543
  }
528
544
  if (!cfg.plugins) cfg.plugins = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencompress/openclaw",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "OpenCompress for OpenClaw — save tokens and sharpen quality on any LLM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",