@opencompress/opencompress 1.6.0 → 1.6.1

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 +40 -1
  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/index.ts
9
- var VERSION = "1.6.0";
9
+ var VERSION = "1.6.1";
10
10
  var DEFAULT_BASE_URL = "https://www.opencompress.ai/api";
11
11
  function getApiKey(api) {
12
12
  const auth = api.config.auth;
@@ -197,6 +197,44 @@ function persistAgentAuthJson(apiKey) {
197
197
  } catch {
198
198
  }
199
199
  }
200
+ function injectModelsAllowlist(models) {
201
+ try {
202
+ const os = __require("os");
203
+ const fs = __require("fs");
204
+ const path = __require("path");
205
+ const configPath = path.join(os.homedir(), ".openclaw", "openclaw.json");
206
+ if (!fs.existsSync(configPath)) return;
207
+ const raw = fs.readFileSync(configPath, "utf-8");
208
+ let config;
209
+ try {
210
+ config = JSON.parse(raw);
211
+ } catch {
212
+ return;
213
+ }
214
+ if (!config.agents) config.agents = {};
215
+ const agents = config.agents;
216
+ if (!agents.defaults) agents.defaults = {};
217
+ const defaults = agents.defaults;
218
+ if (!defaults.models) defaults.models = {};
219
+ const allowlist = defaults.models;
220
+ const existingKeys = Object.keys(allowlist);
221
+ if (existingKeys.length === 0) return;
222
+ let changed = false;
223
+ for (const m of models) {
224
+ const fullId = `opencompress/${m.id}`;
225
+ if (!allowlist[fullId]) {
226
+ allowlist[fullId] = {};
227
+ changed = true;
228
+ }
229
+ }
230
+ if (changed) {
231
+ const tmpPath = `${configPath}.tmp.${process.pid}`;
232
+ fs.writeFileSync(tmpPath, JSON.stringify(config, null, 2) + "\n");
233
+ fs.renameSync(tmpPath, configPath);
234
+ }
235
+ } catch {
236
+ }
237
+ }
200
238
  function persistAuthProfile(apiKey) {
201
239
  try {
202
240
  const os = __require("os");
@@ -358,6 +396,7 @@ var plugin = {
358
396
  api.config.models.providers.opencompress = providerModels;
359
397
  persistModelsConfig(providerModels);
360
398
  persistAgentModelsJson(providerModels);
399
+ injectModelsAllowlist(providerModels.models);
361
400
  const apiKey = getApiKey(api);
362
401
  if (apiKey) {
363
402
  persistAuthProfile(apiKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencompress/opencompress",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "OpenCompress plugin for OpenClaw — automatic 5-layer prompt compression for any LLM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",