omp-config-crypt 0.5.4 → 0.5.6

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/bin/omp-sync.js CHANGED
@@ -226,6 +226,9 @@ async function main() {
226
226
  `[rehydrate] Plugins processed: ${res.rehydration.rehydrated} rehydrated (installed: ${res.rehydration.npmInstalled.length}, links: ${res.rehydration.linksRepaired.length}).`
227
227
  );
228
228
  }
229
+ if (res.purged && res.purged.length > 0) {
230
+ console.log(`[cleanup] Automatically purged ${res.purged.length} obsolete file(s) (e.g. legacy agy.js).`);
231
+ }
229
232
  }
230
233
  break;
231
234
  }
@@ -279,6 +282,9 @@ async function main() {
279
282
  `[rehydrate] Plugins processed: ${res.rehydration.rehydrated} rehydrated (installed: ${res.rehydration.npmInstalled.length}, links: ${res.rehydration.linksRepaired.length}).`
280
283
  );
281
284
  }
285
+ if (res.purged && res.purged.length > 0) {
286
+ console.log(`[cleanup] Automatically purged ${res.purged.length} obsolete file(s) (e.g. legacy agy.js).`);
287
+ }
282
288
  }
283
289
  break;
284
290
  }
package/index.js CHANGED
@@ -36,6 +36,8 @@ import {
36
36
  readPrivateProviders,
37
37
  writePrivateProviders,
38
38
  ensureLocalExtension,
39
+ parseYamlModels,
40
+ formatYamlModels,
39
41
  } from "./src/provider-store.js";
40
42
  import { getRoles, setRole, VALID_ROLES } from "./src/role-manager.js";
41
43
 
@@ -241,8 +243,22 @@ export function buildArchive(pass, root = configRoot()) {
241
243
  const homePosix = home.replace(/\\/g, "/");
242
244
 
243
245
  const files = items.map(({ rel, abs }) => {
244
- const raw = fs.readFileSync(abs);
246
+ let raw = fs.readFileSync(abs);
245
247
  const mode = fs.statSync(abs).mode & 0o777;
248
+
249
+ // Sanitize private providers from models.yml so they are never exported to cloud
250
+ if (rel === "models.yml" || rel === "models.yaml") {
251
+ try {
252
+ const providers = parseYamlModels(raw.toString("utf8"));
253
+ const publicProviders = {};
254
+ for (const [name, cfg] of Object.entries(providers)) {
255
+ if (!cfg.private) {
256
+ publicProviders[name] = cfg;
257
+ }
258
+ }
259
+ raw = Buffer.from(formatYamlModels(publicProviders), "utf8");
260
+ } catch {}
261
+ }
246
262
  let data;
247
263
  if (isText(raw)) {
248
264
  let str = raw.toString("utf8");
@@ -337,8 +353,26 @@ export function restoreArchive(blob, pass, root = configRoot(), options = {}) {
337
353
  buf = Buffer.from(str, "utf8");
338
354
  }
339
355
  }
340
-
341
356
  const exists = fs.existsSync(dst);
357
+
358
+ // Intelligently merge existing local private providers in models.yml so they are never overwritten
359
+ if ((rel === "models.yml" || rel === "models.yaml") && exists) {
360
+ try {
361
+ const existingRaw = fs.readFileSync(dst, "utf8");
362
+ const existingProviders = parseYamlModels(existingRaw);
363
+ const privateProviders = {};
364
+ for (const [name, cfg] of Object.entries(existingProviders)) {
365
+ if (cfg.private) {
366
+ privateProviders[name] = cfg;
367
+ }
368
+ }
369
+ if (Object.keys(privateProviders).length > 0) {
370
+ const incomingProviders = parseYamlModels(buf.toString("utf8"));
371
+ const merged = { ...incomingProviders, ...privateProviders };
372
+ buf = Buffer.from(formatYamlModels(merged), "utf8");
373
+ }
374
+ } catch {}
375
+ }
342
376
  actions.push({ path: rel, dest: dst, exists, remapped });
343
377
 
344
378
  if (!dryRun) {
@@ -361,10 +395,28 @@ export function restoreArchive(blob, pass, root = configRoot(), options = {}) {
361
395
  }
362
396
  }
363
397
 
398
+ const purged = [];
399
+ if (!dryRun) {
400
+ const obsoleteCandidates = [
401
+ path.join(ompHome(root), "extensions", "agy.js"),
402
+ path.join(ompHome(root), "extensions", "local-models.js"),
403
+ path.join(root, "models.local.json"),
404
+ ];
405
+ for (const p of obsoleteCandidates) {
406
+ if (fs.existsSync(p)) {
407
+ try {
408
+ fs.rmSync(p, { force: true });
409
+ purged.push(p);
410
+ } catch {}
411
+ }
412
+ }
413
+ }
414
+
364
415
  return {
365
416
  files: restored,
366
417
  dryRun,
367
418
  actions,
419
+ purged,
368
420
  backupDir: !dryRun && fs.existsSync(backupDir) ? backupDir : null,
369
421
  rehydration,
370
422
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-config-crypt",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Universal cross-platform encrypted portability for omp config, extensions, and instructions",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -165,6 +165,7 @@ export function formatYamlModels(providers) {
165
165
  let out = "providers:\n";
166
166
  for (const [name, cfg] of Object.entries(providers || {})) {
167
167
  out += ` ${name}:\n`;
168
+ if (cfg.private) out += ` private: true\n`;
168
169
  if (cfg.baseUrl) out += ` baseUrl: ${cfg.baseUrl}\n`;
169
170
  if (cfg.api) out += ` api: ${cfg.api}\n`;
170
171
  if (cfg.apiKey) out += ` apiKey: ${cfg.apiKey}\n`;
@@ -257,6 +258,7 @@ export function saveProvider({
257
258
  }
258
259
 
259
260
  const cleanConfig = {
261
+ private: Boolean(isPrivate),
260
262
  baseUrl: providerConfig.baseUrl,
261
263
  api: providerConfig.api || "openai-completions",
262
264
  apiKey: providerConfig.apiKey || "",
@@ -264,26 +266,18 @@ export function saveProvider({
264
266
  models: Array.isArray(providerConfig.models) ? providerConfig.models : [],
265
267
  };
266
268
 
267
- const ompDir = getOmpDir(agentDir);
269
+ // Always save to models.yml so OMP /model natively sees and uses it
270
+ const pub = readPublicProviders(agentDir);
271
+ pub[name] = cleanConfig;
272
+ writePublicProviders(agentDir, pub);
268
273
 
274
+ // Also record in models.local.json for redundancy
269
275
  if (isPrivate) {
270
276
  const priv = readPrivateProviders(agentDir);
271
277
  priv[name] = cleanConfig;
272
278
  writePrivateProviders(agentDir, priv);
273
- ensureLocalExtension(ompDir);
274
-
275
- // If it existed in public, remove from public to prevent duplicate
276
- const pub = readPublicProviders(agentDir);
277
- if (pub[name]) {
278
- delete pub[name];
279
- writePublicProviders(agentDir, pub);
280
- }
279
+ ensureLocalExtension(getOmpDir(agentDir));
281
280
  } else {
282
- const pub = readPublicProviders(agentDir);
283
- pub[name] = cleanConfig;
284
- writePublicProviders(agentDir, pub);
285
-
286
- // If it existed in private, remove from private
287
281
  const priv = readPrivateProviders(agentDir);
288
282
  if (priv[name]) {
289
283
  delete priv[name];
@@ -323,22 +317,13 @@ export function removeProvider({ name, agentDir = getAgentDir() }) {
323
317
  export function listProviders({ agentDir = getAgentDir() } = {}) {
324
318
  const pub = readPublicProviders(agentDir);
325
319
  const priv = readPrivateProviders(agentDir);
320
+ const merged = { ...priv, ...pub };
326
321
 
327
322
  const list = [];
328
- for (const [name, cfg] of Object.entries(pub)) {
329
- list.push({
330
- name,
331
- isPrivate: false,
332
- baseUrl: cfg.baseUrl,
333
- api: cfg.api,
334
- apiKey: cfg.apiKey,
335
- models: cfg.models || [],
336
- });
337
- }
338
- for (const [name, cfg] of Object.entries(priv)) {
323
+ for (const [name, cfg] of Object.entries(merged)) {
339
324
  list.push({
340
325
  name,
341
- isPrivate: true,
326
+ isPrivate: Boolean(cfg.private || priv[name]),
342
327
  baseUrl: cfg.baseUrl,
343
328
  api: cfg.api,
344
329
  apiKey: cfg.apiKey,