omp-config-crypt 0.9.12 → 0.9.14
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/README.md +1 -1
- package/bin/omp-sync.js +0 -0
- package/index.js +16 -1
- package/package.json +1 -1
- package/src/provider-store.js +1 -2
package/README.md
CHANGED
package/bin/omp-sync.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -583,13 +583,28 @@ export function giteeToken() {
|
|
|
583
583
|
const ompHome = process.env.OMP_HOME || path.join(os.homedir(), ".omp");
|
|
584
584
|
for (const file of [path.join(ompHome, "gitee-token"), path.join(os.homedir(), ".omp", "gitee-token")]) {
|
|
585
585
|
try {
|
|
586
|
-
const value = fs.readFileSync(file
|
|
586
|
+
const value = decodeTokenFile(fs.readFileSync(file));
|
|
587
587
|
if (value) return value;
|
|
588
588
|
} catch { /* keep looking */ }
|
|
589
589
|
}
|
|
590
590
|
return null;
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
+
/**
|
|
594
|
+
* Decodes a token file written by any editor. PowerShell's default
|
|
595
|
+
* `Set-Content -Value` emits UTF-16LE with a BOM, which would otherwise be read
|
|
596
|
+
* as NUL-injected garbage and rejected as 401 by the API.
|
|
597
|
+
*/
|
|
598
|
+
function decodeTokenFile(buffer) {
|
|
599
|
+
let text;
|
|
600
|
+
if (buffer[0] === 0xff && buffer[1] === 0xfe) text = buffer.subarray(2).toString("utf16le");
|
|
601
|
+
else if (buffer[0] === 0xfe && buffer[1] === 0xff) text = Buffer.from(buffer.subarray(2)).swap16().toString("utf16le");
|
|
602
|
+
else if (buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf) text = buffer.subarray(3).toString("utf8");
|
|
603
|
+
else if (buffer.includes(0)) text = buffer.toString("utf16le");
|
|
604
|
+
else text = buffer.toString("utf8");
|
|
605
|
+
return text.replace(/\uFEFF/g, "").trim();
|
|
606
|
+
}
|
|
607
|
+
|
|
593
608
|
async function askToken(ctx, title, required) {
|
|
594
609
|
const fromEnv = envToken();
|
|
595
610
|
if (fromEnv) return fromEnv;
|
package/package.json
CHANGED
package/src/provider-store.js
CHANGED
|
@@ -358,7 +358,6 @@ export function formatYamlModels(providers) {
|
|
|
358
358
|
out += ` models:\n`;
|
|
359
359
|
for (const m of cfg.models) {
|
|
360
360
|
out += ` - id: ${m.id}\n`;
|
|
361
|
-
if (m.api) out += ` api: ${m.api}\n`;
|
|
362
361
|
if (m.name) out += ` name: ${m.name}\n`;
|
|
363
362
|
if (m.reasoning !== undefined) out += ` reasoning: ${m.reasoning}\n`;
|
|
364
363
|
if (m.input) {
|
|
@@ -531,7 +530,7 @@ export function getProvider(name, { agentDir = getAgentDir() } = {}) {
|
|
|
531
530
|
}
|
|
532
531
|
|
|
533
532
|
const PROVIDER_FIELDS = new Set(["private", "baseUrl", "api", "apiKey", "authHeader", "models"]);
|
|
534
|
-
const MODEL_FIELDS = new Set(["id", "
|
|
533
|
+
const MODEL_FIELDS = new Set(["id", "name", "reasoning", "input", "contextWindow", "maxTokens", "compat"]);
|
|
535
534
|
function unsupported(field) {
|
|
536
535
|
throw new Error(`公开 YAML 格式不支持字段或结构 ${field};未写入`);
|
|
537
536
|
}
|