droid-patch 0.13.5 → 0.14.0
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 +4 -5
- package/README.zh-CN.md +4 -5
- package/dist/{alias-DTf8YAYU.mjs → alias-jucBZXia.mjs} +12 -12
- package/dist/{alias-DTf8YAYU.mjs.map → alias-jucBZXia.mjs.map} +1 -1
- package/dist/cli.mjs +42 -42
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +18 -18
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as removeAlias, d as listAllMetadata, f as loadAliasMetadata, i as listAliases, l as createMetadata, m as patchDroid, n as createAlias, o as removeAliasesByFilter, p as saveAliasMetadata, r as createAliasForWrapper, t as clearAllAliases, u as formatPatches } from "./alias-
|
|
2
|
+
import { a as removeAlias, d as listAllMetadata, f as loadAliasMetadata, i as listAliases, l as createMetadata, m as patchDroid, n as createAlias, o as removeAliasesByFilter, p as saveAliasMetadata, r as createAliasForWrapper, t as clearAllAliases, u as formatPatches } from "./alias-jucBZXia.mjs";
|
|
3
3
|
import bin from "tiny-bin";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -1086,18 +1086,18 @@ function findDefaultDroidPath() {
|
|
|
1086
1086
|
for (const p of paths) if (existsSync(p)) return p;
|
|
1087
1087
|
return join(home, ".droid", "bin", "droid");
|
|
1088
1088
|
}
|
|
1089
|
-
bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
1089
|
+
bin("droid-patch", "CLI tool to patch droid binary with various modifications").option("--is-custom", "Patch isCustom:!0 to isCustom:!1 (enable context compression for custom models)").option("--skip-login", "Inject a fake FACTORY_API_KEY to bypass login requirement (no real key needed)").option("--api-base <url>", "Replace API URL (standalone: binary patch, max 22 chars; with --websearch: proxy forward target, no limit)").option("--websearch", "Enable local WebSearch proxy with external providers (Smithery, Google PSE, etc.)").option("--websearch-proxy", "Enable native provider websearch (requires proxy plugin, reads ~/.factory/settings.json)").option("--standalone", "Standalone mode: mock non-LLM Factory APIs (use with --websearch)").option("--reasoning-effort", "Enable reasoning effort for custom models (default high; UI options: \"high\",\"max\",\"xhigh\")").option("--disable-telemetry", "Disable telemetry and Sentry error reporting (block data uploads)").option("--dry-run", "Verify patches without actually modifying the binary").option("-p, --path <path>", "Path to the droid binary").option("-o, --output <dir>", "Output directory for patched binary").option("--no-backup", "Do not create backup of original binary").option("-v, --verbose", "Enable verbose output").argument("[alias]", "Alias name for the patched binary").action(async (options, args) => {
|
|
1090
1090
|
const alias = args?.[0];
|
|
1091
|
-
const isCustom = options
|
|
1092
|
-
const skipLogin = options
|
|
1093
|
-
const apiBase = options
|
|
1094
|
-
const websearch = options
|
|
1095
|
-
const websearchProxy = options
|
|
1096
|
-
const standalone = options
|
|
1091
|
+
const isCustom = !!options.isCustom;
|
|
1092
|
+
const skipLogin = !!options.skipLogin;
|
|
1093
|
+
const apiBase = options.apiBase;
|
|
1094
|
+
const websearch = !!options.websearch;
|
|
1095
|
+
const websearchProxy = !!options.websearchProxy;
|
|
1096
|
+
const standalone = !!options.standalone;
|
|
1097
1097
|
const websearchTarget = websearch ? apiBase || "https://api.factory.ai" : void 0;
|
|
1098
|
-
const reasoningEffort = options
|
|
1099
|
-
const noTelemetry = options
|
|
1100
|
-
const dryRun = options
|
|
1098
|
+
const reasoningEffort = !!options.reasoningEffort;
|
|
1099
|
+
const noTelemetry = !!options.disableTelemetry;
|
|
1100
|
+
const dryRun = !!options.dryRun;
|
|
1101
1101
|
const path = options.path || findDefaultDroidPath();
|
|
1102
1102
|
const outputDir = options.output;
|
|
1103
1103
|
const backup = options.backup !== false;
|
|
@@ -1239,7 +1239,7 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1239
1239
|
if (apiBase && !websearch) {
|
|
1240
1240
|
const originalUrl = "https://api.factory.ai";
|
|
1241
1241
|
const originalLength = 22;
|
|
1242
|
-
|
|
1242
|
+
const normalizedUrl = apiBase.replace(/\/+$/, "");
|
|
1243
1243
|
if (normalizedUrl.length > originalLength) {
|
|
1244
1244
|
console.log(styleText("red", `Error: API base URL must be ${originalLength} characters or less`));
|
|
1245
1245
|
console.log(styleText("gray", ` Your URL: "${normalizedUrl}" (${normalizedUrl.length} chars)`));
|
|
@@ -1262,21 +1262,21 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1262
1262
|
if (reasoningEffort) {
|
|
1263
1263
|
patches.push({
|
|
1264
1264
|
name: "reasoningEffortSupportedXHighList",
|
|
1265
|
-
description: "Enable [\"
|
|
1265
|
+
description: "Enable [\"high\",\"max\",\"xhigh\"] in UI for custom model list",
|
|
1266
1266
|
pattern: Buffer.from(""),
|
|
1267
1267
|
replacement: Buffer.from(""),
|
|
1268
|
-
regexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.(?:displayName|id),modelProvider:\1\.provider\s*,supportedReasoningEfforts:\["(?:none|high)"(?:,"xhigh")
|
|
1269
|
-
regexReplacement: "id:$1.id,displayName:$1.displayName,shortDisplayName:$1.displayName,modelProvider:$1.provider,supportedReasoningEfforts:[\"
|
|
1270
|
-
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.displayName,modelProvider:\1\.provider,supportedReasoningEfforts:\["
|
|
1268
|
+
regexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.(?:displayName|id),modelProvider:\1\.provider\s*,supportedReasoningEfforts:\[(?:"(?:none|high)"(?:,"xhigh")?|"low","high","xhigh")\],defaultReasoningEffort:"(?:none|high)",isCustom:!([01]),noImageSupport:(?:\1\.noImageSupport|!1)/g,
|
|
1269
|
+
regexReplacement: "id:$1.id,displayName:$1.displayName,shortDisplayName:$1.displayName,modelProvider:$1.provider,supportedReasoningEfforts:[\"high\",\"max\",\"xhigh\"],defaultReasoningEffort:\"high\",isCustom:!$2,noImageSupport:!1",
|
|
1270
|
+
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.displayName,modelProvider:\1\.provider,supportedReasoningEfforts:\["high","max","xhigh"\],defaultReasoningEffort:"high",isCustom:!([01]),noImageSupport:!1/g
|
|
1271
1271
|
});
|
|
1272
1272
|
patches.push({
|
|
1273
1273
|
name: "reasoningEffortSupportedXHighResolver",
|
|
1274
|
-
description: "Enable [\"
|
|
1274
|
+
description: "Enable [\"high\",\"max\",\"xhigh\"] in UI for custom model config resolver",
|
|
1275
1275
|
pattern: Buffer.from(""),
|
|
1276
1276
|
replacement: Buffer.from(""),
|
|
1277
|
-
regexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider\s*,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["(?:none|high)"(?:,"xhigh")
|
|
1278
|
-
regexReplacement: "id:$1.model,modelProvider:$1.provider,displayName:$2,shortDisplayName:$2,supportedReasoningEfforts:[\"
|
|
1279
|
-
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["
|
|
1277
|
+
regexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider\s*,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\[(?:"(?:none|high)"(?:,"xhigh")?|"low","high","xhigh")\],defaultReasoningEffort:"(?:none|high)",isCustom:!([01]),noImageSupport:(?:\1\.noImageSupport|!1)/g,
|
|
1278
|
+
regexReplacement: "id:$1.model,modelProvider:$1.provider,displayName:$2,shortDisplayName:$2,supportedReasoningEfforts:[\"high\",\"max\",\"xhigh\"],defaultReasoningEffort:\"high\",isCustom:!$3,noImageSupport:!1",
|
|
1279
|
+
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["high","max","xhigh"\],defaultReasoningEffort:"high",isCustom:!([01]),noImageSupport:!1/g
|
|
1280
1280
|
});
|
|
1281
1281
|
patches.push({
|
|
1282
1282
|
name: "reasoningEffortSupported",
|
|
@@ -1412,8 +1412,8 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1412
1412
|
await listAliases();
|
|
1413
1413
|
}).command("remove", "Remove alias(es) by name or filter").argument("[alias-or-path]", "Alias name or file path to remove").option("--patch-version <version>", "Remove aliases created by this droid-patch version").option("--droid-version <version>", "Remove aliases for this droid version").option("--flag <flag>", "Remove aliases with this flag (is-custom, skip-login, websearch, api-base, reasoning-effort, disable-telemetry, standalone)").action(async (options, args) => {
|
|
1414
1414
|
const target = args?.[0];
|
|
1415
|
-
const patchVersion = options
|
|
1416
|
-
const droidVersion = options
|
|
1415
|
+
const patchVersion = options.patchVersion;
|
|
1416
|
+
const droidVersion = options.droidVersion;
|
|
1417
1417
|
const flagRaw = options.flag;
|
|
1418
1418
|
let flag;
|
|
1419
1419
|
if (flagRaw) {
|
|
@@ -1446,9 +1446,9 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1446
1446
|
process.exit(1);
|
|
1447
1447
|
}
|
|
1448
1448
|
if (target.includes("/") || existsSync(target)) {
|
|
1449
|
-
const { unlink
|
|
1449
|
+
const { unlink } = await import("node:fs/promises");
|
|
1450
1450
|
try {
|
|
1451
|
-
await unlink
|
|
1451
|
+
await unlink(target);
|
|
1452
1452
|
console.log(styleText("green", `[*] Removed: ${target}`));
|
|
1453
1453
|
} catch (error) {
|
|
1454
1454
|
console.error(styleText("red", `Error: ${error.message}`));
|
|
@@ -1461,9 +1461,9 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1461
1461
|
await clearAllAliases();
|
|
1462
1462
|
}).command("update", "Update aliases with latest droid binary").argument("[alias]", "Specific alias to update (optional, updates all if not specified)").option("--dry-run", "Preview without making changes").option("-p, --path <path>", "Path to new droid binary").option("-v, --verbose", "Enable verbose output").action(async (options, args) => {
|
|
1463
1463
|
const aliasName = args?.[0];
|
|
1464
|
-
const dryRun = options
|
|
1464
|
+
const dryRun = !!options.dryRun;
|
|
1465
1465
|
const newBinaryPath = options.path || findDefaultDroidPath();
|
|
1466
|
-
const verbose = options.verbose;
|
|
1466
|
+
const verbose = !!options.verbose;
|
|
1467
1467
|
console.log(styleText("cyan", "═".repeat(60)));
|
|
1468
1468
|
console.log(styleText(["cyan", "bold"], " Droid-Patch Update"));
|
|
1469
1469
|
console.log(styleText("cyan", "═".repeat(60)));
|
|
@@ -1534,21 +1534,21 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1534
1534
|
if (meta.patches.reasoningEffort) {
|
|
1535
1535
|
patches.push({
|
|
1536
1536
|
name: "reasoningEffortSupportedXHighList",
|
|
1537
|
-
description: "Enable [\"
|
|
1537
|
+
description: "Enable [\"high\",\"max\",\"xhigh\"] in UI for custom model list",
|
|
1538
1538
|
pattern: Buffer.from(""),
|
|
1539
1539
|
replacement: Buffer.from(""),
|
|
1540
|
-
regexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.(?:displayName|id),modelProvider:\1\.provider\s*,supportedReasoningEfforts:\["(?:none|high)"(?:,"xhigh")
|
|
1541
|
-
regexReplacement: "id:$1.id,displayName:$1.displayName,shortDisplayName:$1.displayName,modelProvider:$1.provider,supportedReasoningEfforts:[\"
|
|
1542
|
-
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.displayName,modelProvider:\1\.provider,supportedReasoningEfforts:\["
|
|
1540
|
+
regexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.(?:displayName|id),modelProvider:\1\.provider\s*,supportedReasoningEfforts:\[(?:"(?:none|high)"(?:,"xhigh")?|"low","high","xhigh")\],defaultReasoningEffort:"(?:none|high)",isCustom:!([01]),noImageSupport:(?:\1\.noImageSupport|!1)/g,
|
|
1541
|
+
regexReplacement: "id:$1.id,displayName:$1.displayName,shortDisplayName:$1.displayName,modelProvider:$1.provider,supportedReasoningEfforts:[\"high\",\"max\",\"xhigh\"],defaultReasoningEffort:\"high\",isCustom:!$2,noImageSupport:!1",
|
|
1542
|
+
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.id,displayName:\1\.displayName,shortDisplayName:\1\.displayName,modelProvider:\1\.provider,supportedReasoningEfforts:\["high","max","xhigh"\],defaultReasoningEffort:"high",isCustom:!([01]),noImageSupport:!1/g
|
|
1543
1543
|
});
|
|
1544
1544
|
patches.push({
|
|
1545
1545
|
name: "reasoningEffortSupportedXHighResolver",
|
|
1546
|
-
description: "Enable [\"
|
|
1546
|
+
description: "Enable [\"high\",\"max\",\"xhigh\"] in UI for custom model config resolver",
|
|
1547
1547
|
pattern: Buffer.from(""),
|
|
1548
1548
|
replacement: Buffer.from(""),
|
|
1549
|
-
regexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider\s*,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["(?:none|high)"(?:,"xhigh")
|
|
1550
|
-
regexReplacement: "id:$1.model,modelProvider:$1.provider,displayName:$2,shortDisplayName:$2,supportedReasoningEfforts:[\"
|
|
1551
|
-
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["
|
|
1549
|
+
regexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider\s*,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\[(?:"(?:none|high)"(?:,"xhigh")?|"low","high","xhigh")\],defaultReasoningEffort:"(?:none|high)",isCustom:!([01]),noImageSupport:(?:\1\.noImageSupport|!1)/g,
|
|
1550
|
+
regexReplacement: "id:$1.model,modelProvider:$1.provider,displayName:$2,shortDisplayName:$2,supportedReasoningEfforts:[\"high\",\"max\",\"xhigh\"],defaultReasoningEffort:\"high\",isCustom:!$3,noImageSupport:!1",
|
|
1551
|
+
alreadyPatchedRegexPattern: /id:([A-Za-z$_])\.model,modelProvider:\1\.provider,displayName:([A-Za-z$_]),shortDisplayName:\2,supportedReasoningEfforts:\["high","max","xhigh"\],defaultReasoningEffort:"high",isCustom:!([01]),noImageSupport:!1/g
|
|
1552
1552
|
});
|
|
1553
1553
|
patches.push({
|
|
1554
1554
|
name: "reasoningEffortSupported",
|
|
@@ -1619,8 +1619,8 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1619
1619
|
continue;
|
|
1620
1620
|
}
|
|
1621
1621
|
if (process.platform === "darwin") try {
|
|
1622
|
-
const { execSync
|
|
1623
|
-
execSync
|
|
1622
|
+
const { execSync } = await import("node:child_process");
|
|
1623
|
+
execSync(`codesign --force --deep --sign - "${outputPath}"`, { stdio: "pipe" });
|
|
1624
1624
|
if (verbose) console.log(styleText("gray", ` Re-signed binary`));
|
|
1625
1625
|
} catch {
|
|
1626
1626
|
console.log(styleText("yellow", ` [!] Could not re-sign binary`));
|
|
@@ -1643,7 +1643,7 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1643
1643
|
}
|
|
1644
1644
|
delete meta.patches.statusline;
|
|
1645
1645
|
delete meta.patches.sessions;
|
|
1646
|
-
const { symlink
|
|
1646
|
+
const { symlink, unlink, readlink, lstat } = await import("node:fs/promises");
|
|
1647
1647
|
let aliasPath = meta.aliasPath;
|
|
1648
1648
|
if (!aliasPath) {
|
|
1649
1649
|
const commonPathDirs = [
|
|
@@ -1658,7 +1658,7 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1658
1658
|
const possiblePath = join(dir, meta.name);
|
|
1659
1659
|
if (existsSync(possiblePath)) try {
|
|
1660
1660
|
if ((await lstat(possiblePath)).isSymbolicLink()) {
|
|
1661
|
-
const target = await readlink
|
|
1661
|
+
const target = await readlink(possiblePath);
|
|
1662
1662
|
if (target.includes(".droid-patch/bins") || target.includes(".droid-patch/proxy") || target.includes(".droid-patch/statusline")) {
|
|
1663
1663
|
aliasPath = possiblePath;
|
|
1664
1664
|
if (verbose) console.log(styleText("gray", ` Found existing symlink: ${aliasPath}`));
|
|
@@ -1670,13 +1670,13 @@ bin("droid-patch", "CLI tool to patch droid binary with various modifications").
|
|
|
1670
1670
|
}
|
|
1671
1671
|
if (aliasPath) try {
|
|
1672
1672
|
if (existsSync(aliasPath)) {
|
|
1673
|
-
if (await readlink
|
|
1674
|
-
await unlink
|
|
1675
|
-
await symlink
|
|
1673
|
+
if (await readlink(aliasPath) !== execTargetPath) {
|
|
1674
|
+
await unlink(aliasPath);
|
|
1675
|
+
await symlink(execTargetPath, aliasPath);
|
|
1676
1676
|
if (verbose) console.log(styleText("gray", ` Updated symlink: ${aliasPath}`));
|
|
1677
1677
|
}
|
|
1678
1678
|
} else {
|
|
1679
|
-
await symlink
|
|
1679
|
+
await symlink(execTargetPath, aliasPath);
|
|
1680
1680
|
if (verbose) console.log(styleText("gray", ` Recreated symlink: ${aliasPath}`));
|
|
1681
1681
|
}
|
|
1682
1682
|
meta.aliasPath = aliasPath;
|