paseo-acp-agy 1.2.2 → 1.2.3
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/dist/paseo-patcher.js +139 -42
- package/package.json +1 -1
package/dist/paseo-patcher.js
CHANGED
|
@@ -129,7 +129,7 @@ export function findPaseoServerInstallations() {
|
|
|
129
129
|
"/Applications/Paseo.app/Contents/Resources/app/node_modules/@getpaseo/server",
|
|
130
130
|
];
|
|
131
131
|
if (home) {
|
|
132
|
-
posixLocations.push(path.join(home, ".local", "share", "pnpm", "global", "5", "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"), path.join(home, ".bun", "install", "global", "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"));
|
|
132
|
+
posixLocations.push(path.join(home, ".local", "lib", "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"), path.join(home, ".local", "lib", "node_modules", "@getpaseo", "server"), path.join(home, ".local", "share", "pnpm", "global", "5", "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"), path.join(home, ".bun", "install", "global", "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"));
|
|
133
133
|
// Check nvm paths if available
|
|
134
134
|
const nvmDir = path.join(home, ".nvm", "versions", "node");
|
|
135
135
|
if (fs.existsSync(nvmDir)) {
|
|
@@ -146,6 +146,38 @@ export function findPaseoServerInstallations() {
|
|
|
146
146
|
if (fs.existsSync(loc))
|
|
147
147
|
candidates.add(path.resolve(loc));
|
|
148
148
|
}
|
|
149
|
+
// Inspect which paseo on POSIX
|
|
150
|
+
try {
|
|
151
|
+
const whichOut = execFileSync("which", ["paseo"], {
|
|
152
|
+
encoding: "utf-8",
|
|
153
|
+
timeout: 3000,
|
|
154
|
+
}).trim();
|
|
155
|
+
for (const line of whichOut.split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) {
|
|
156
|
+
let realLine = line;
|
|
157
|
+
try {
|
|
158
|
+
realLine = fs.realpathSync(line);
|
|
159
|
+
}
|
|
160
|
+
catch { }
|
|
161
|
+
const dirs = [path.dirname(line), path.dirname(realLine)];
|
|
162
|
+
for (const dir of dirs) {
|
|
163
|
+
const checks = [
|
|
164
|
+
path.join(dir, "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"),
|
|
165
|
+
path.join(dir, "node_modules", "@getpaseo", "server"),
|
|
166
|
+
path.join(path.dirname(dir), "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"),
|
|
167
|
+
path.join(path.dirname(dir), "node_modules", "@getpaseo", "server"),
|
|
168
|
+
path.join(path.dirname(path.dirname(dir)), "node_modules", "@getpaseo", "cli", "node_modules", "@getpaseo", "server"),
|
|
169
|
+
path.join(path.dirname(path.dirname(dir)), "node_modules", "@getpaseo", "server"),
|
|
170
|
+
path.join(dir, "resources", "app.asar.unpacked", "node_modules", "@getpaseo", "server"),
|
|
171
|
+
path.join(path.dirname(dir), "resources", "app.asar.unpacked", "node_modules", "@getpaseo", "server"),
|
|
172
|
+
];
|
|
173
|
+
for (const c of checks) {
|
|
174
|
+
if (fs.existsSync(c))
|
|
175
|
+
candidates.add(path.resolve(c));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch { }
|
|
149
181
|
try {
|
|
150
182
|
const npmRoot = execFileSync("npm", ["root", "-g"], { encoding: "utf-8", timeout: 2000 }).trim();
|
|
151
183
|
if (npmRoot && fs.existsSync(npmRoot)) {
|
|
@@ -618,39 +650,43 @@ export function patchPaseoServer(serverDir) {
|
|
|
618
650
|
}
|
|
619
651
|
}
|
|
620
652
|
// Patch handleUsageUpdate
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
653
|
+
const methodMatch = acpCode.match(/(?:^|\n)([ \t]*)handleUsageUpdate\s*\([^)]*\)\s*\{/);
|
|
654
|
+
if (methodMatch && methodMatch.index !== undefined) {
|
|
655
|
+
const startIdx = methodMatch.index + (methodMatch[0].startsWith("\n") ? 1 : 0);
|
|
656
|
+
const openBrace = acpCode.indexOf("{", startIdx);
|
|
657
|
+
if (openBrace !== -1) {
|
|
658
|
+
let depth = 1;
|
|
659
|
+
let i = openBrace + 1;
|
|
660
|
+
while (i < acpCode.length && depth > 0) {
|
|
661
|
+
if (acpCode[i] === "{")
|
|
662
|
+
depth++;
|
|
663
|
+
else if (acpCode[i] === "}")
|
|
664
|
+
depth--;
|
|
665
|
+
i++;
|
|
666
|
+
}
|
|
667
|
+
if (depth === 0) {
|
|
668
|
+
const currentMethodBody = acpCode.slice(startIdx, i);
|
|
669
|
+
const needsPatch = !currentMethodBody.includes('type: "usage_updated"') || currentMethodBody.includes("this.notifySubscribers");
|
|
670
|
+
if (needsPatch) {
|
|
671
|
+
const indent = methodMatch[1] || " ";
|
|
672
|
+
const newHandler = `${indent}handleUsageUpdate(update) {
|
|
673
|
+
${indent} if (!update) return;
|
|
674
|
+
${indent} const usage = mapACPUsage(update);
|
|
675
|
+
${indent} if (usage) {
|
|
676
|
+
${indent} this.currentTurnUsage = { ...this.currentTurnUsage, ...usage };
|
|
677
|
+
${indent} const event = {
|
|
678
|
+
${indent} type: "usage_updated",
|
|
679
|
+
${indent} provider: this.provider,
|
|
680
|
+
${indent} usage: this.currentTurnUsage,
|
|
681
|
+
${indent} ...(this.activeForegroundTurnId ? { turnId: this.activeForegroundTurnId } : {}),
|
|
682
|
+
${indent} };
|
|
683
|
+
${indent} if (typeof this.pushEvent === "function") {
|
|
684
|
+
${indent} this.pushEvent(event);
|
|
685
|
+
${indent} } else if (typeof this.deliverTranslatedEvents === "function") {
|
|
686
|
+
${indent} this.deliverTranslatedEvents([event]);
|
|
687
|
+
${indent} }
|
|
688
|
+
${indent} }
|
|
689
|
+
${indent}}`;
|
|
654
690
|
acpCode = acpCode.slice(0, startIdx) + newHandler + acpCode.slice(i);
|
|
655
691
|
acpModified = true;
|
|
656
692
|
}
|
|
@@ -914,6 +950,7 @@ export function isPaseoServerPatched(serverDir) {
|
|
|
914
950
|
try {
|
|
915
951
|
if (!fs.existsSync(serverDir))
|
|
916
952
|
return false;
|
|
953
|
+
// 1. Antigravity quota provider file
|
|
917
954
|
const antigravityJsCandidates = [
|
|
918
955
|
path.join(serverDir, "dist", "server", "services", "quota-fetcher", "providers", "antigravity.js"),
|
|
919
956
|
path.join(serverDir, "dist", "services", "quota-fetcher", "providers", "antigravity.js"),
|
|
@@ -940,20 +977,80 @@ export function isPaseoServerPatched(serverDir) {
|
|
|
940
977
|
};
|
|
941
978
|
hasProvider = checkRecursive(path.join(serverDir, "dist"));
|
|
942
979
|
}
|
|
943
|
-
if (hasProvider)
|
|
944
|
-
return
|
|
980
|
+
if (!hasProvider)
|
|
981
|
+
return false;
|
|
982
|
+
// 2. Manifest check
|
|
945
983
|
const manifestCandidates = [
|
|
946
984
|
path.join(serverDir, "dist", "server", "services", "quota-fetcher", "manifest.js"),
|
|
947
985
|
path.join(serverDir, "dist", "services", "quota-fetcher", "manifest.js"),
|
|
948
986
|
];
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
if (
|
|
953
|
-
return
|
|
987
|
+
let manifestFile = manifestCandidates.find((f) => fs.existsSync(f));
|
|
988
|
+
if (!manifestFile && fs.existsSync(path.join(serverDir, "dist"))) {
|
|
989
|
+
const findManifest = (dir, depth = 0) => {
|
|
990
|
+
if (depth > 5)
|
|
991
|
+
return null;
|
|
992
|
+
try {
|
|
993
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
994
|
+
for (const e of entries) {
|
|
995
|
+
const full = path.join(dir, e.name);
|
|
996
|
+
if (e.isDirectory() && e.name !== "node_modules") {
|
|
997
|
+
const found = findManifest(full, depth + 1);
|
|
998
|
+
if (found)
|
|
999
|
+
return found;
|
|
1000
|
+
}
|
|
1001
|
+
else if (e.isFile() && e.name === "manifest.js" && dir.replace(/\\/g, "/").includes("quota-fetcher")) {
|
|
1002
|
+
return full;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
catch { }
|
|
1007
|
+
return null;
|
|
1008
|
+
};
|
|
1009
|
+
manifestFile = findManifest(path.join(serverDir, "dist")) || undefined;
|
|
1010
|
+
}
|
|
1011
|
+
if (manifestFile) {
|
|
1012
|
+
const content = fs.readFileSync(manifestFile, "utf-8");
|
|
1013
|
+
if (!content.includes('providerId: "antigravity"')) {
|
|
1014
|
+
return false;
|
|
954
1015
|
}
|
|
955
1016
|
}
|
|
956
|
-
|
|
1017
|
+
// 3. ACP Agent check (context window telemetry & usage updates)
|
|
1018
|
+
const acpCandidates = [
|
|
1019
|
+
path.join(serverDir, "dist", "server", "server", "agent", "providers", "acp-agent.js"),
|
|
1020
|
+
path.join(serverDir, "dist", "server", "agent", "providers", "acp-agent.js"),
|
|
1021
|
+
path.join(serverDir, "dist", "agent", "providers", "acp-agent.js"),
|
|
1022
|
+
];
|
|
1023
|
+
let acpFile = acpCandidates.find((f) => fs.existsSync(f));
|
|
1024
|
+
if (!acpFile && fs.existsSync(path.join(serverDir, "dist"))) {
|
|
1025
|
+
const findAcp = (dir, depth = 0) => {
|
|
1026
|
+
if (depth > 5)
|
|
1027
|
+
return null;
|
|
1028
|
+
try {
|
|
1029
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
1030
|
+
for (const e of entries) {
|
|
1031
|
+
const full = path.join(dir, e.name);
|
|
1032
|
+
if (e.isDirectory() && e.name !== "node_modules") {
|
|
1033
|
+
const found = findAcp(full, depth + 1);
|
|
1034
|
+
if (found)
|
|
1035
|
+
return found;
|
|
1036
|
+
}
|
|
1037
|
+
else if (e.isFile() && e.name === "acp-agent.js") {
|
|
1038
|
+
return full;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
catch { }
|
|
1043
|
+
return null;
|
|
1044
|
+
};
|
|
1045
|
+
acpFile = findAcp(path.join(serverDir, "dist")) || undefined;
|
|
1046
|
+
}
|
|
1047
|
+
if (acpFile) {
|
|
1048
|
+
const content = fs.readFileSync(acpFile, "utf-8");
|
|
1049
|
+
if (!content.includes('type: "usage_updated"') || !content.includes("contextWindowMaxTokens")) {
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
return true;
|
|
957
1054
|
}
|
|
958
1055
|
catch {
|
|
959
1056
|
return false;
|