paseo-acp-agy 1.2.1 → 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.
@@ -37,13 +37,23 @@ export function resolveDefaultAgyBinary(force = false) {
37
37
  const programFiles = process.env.ProgramFiles || "C:\\Program Files";
38
38
  const programFilesX86 = process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)";
39
39
  const exeCandidates = [
40
+ path.join(localAppData, "agy", "bin", "agy.exe"),
41
+ path.join(localAppData, "agy", "agy.exe"),
42
+ path.join(home, ".agy", "bin", "agy.exe"),
43
+ path.join(home, ".agy", "agy.exe"),
40
44
  path.join(localAppData, "Programs", "Antigravity", "bin", "agy.exe"),
41
45
  path.join(localAppData, "Programs", "antigravity", "agy.exe"),
42
46
  path.join(localAppData, "Programs", "Antigravity", "agy.exe"),
47
+ path.join(localAppData, "Programs", "agy", "bin", "agy.exe"),
48
+ path.join(localAppData, "Programs", "agy", "agy.exe"),
43
49
  path.join(programFiles, "Antigravity", "bin", "agy.exe"),
50
+ path.join(programFiles, "agy", "bin", "agy.exe"),
44
51
  path.join(programFilesX86, "Antigravity", "bin", "agy.exe"),
52
+ path.join(programFilesX86, "agy", "bin", "agy.exe"),
45
53
  path.join(localAppData, "Google", "Antigravity", "agy.exe"),
46
54
  path.join(localAppData, "Google", "Antigravity", "bin", "agy.exe"),
55
+ path.join(localAppData, "Google", "agy", "bin", "agy.exe"),
56
+ path.join(localAppData, "Google", "agy", "agy.exe"),
47
57
  path.join(home, ".antigravity", "bin", "agy.exe"),
48
58
  path.join(home, ".antigravity", "agy.exe"),
49
59
  path.join(home, ".gemini", "antigravity-cli", "bin", "agy.exe"),
@@ -81,11 +91,16 @@ export function resolveDefaultAgyBinary(force = false) {
81
91
  }
82
92
  if (resolved === "agy") {
83
93
  const batchCandidates = [
94
+ path.join(localAppData, "agy", "bin", "agy.cmd"),
95
+ path.join(localAppData, "agy", "agy.cmd"),
96
+ path.join(home, ".agy", "bin", "agy.cmd"),
84
97
  path.join(appData, "npm", "agy.cmd"),
85
98
  path.join(localAppData, "npm", "agy.cmd"),
86
99
  path.join(home, ".local", "bin", "agy.cmd"),
87
100
  path.join(home, ".antigravity", "bin", "agy.cmd"),
88
101
  path.join(home, ".gemini", "antigravity-cli", "bin", "agy.cmd"),
102
+ path.join(localAppData, "agy", "bin", "agy.bat"),
103
+ path.join(localAppData, "agy", "agy.bat"),
89
104
  path.join(appData, "npm", "agy.bat"),
90
105
  path.join(localAppData, "npm", "agy.bat"),
91
106
  path.join(home, ".local", "bin", "agy.bat"),
@@ -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)) {
@@ -209,13 +241,23 @@ function resolveAgyBinary() {
209
241
 
210
242
  // Prioritize .exe candidates over .cmd / .bat
211
243
  const exeCandidates = [
244
+ path.join(localAppData, "agy", "bin", "agy.exe"),
245
+ path.join(localAppData, "agy", "agy.exe"),
246
+ path.join(home, ".agy", "bin", "agy.exe"),
247
+ path.join(home, ".agy", "agy.exe"),
212
248
  path.join(localAppData, "Programs", "Antigravity", "bin", "agy.exe"),
213
249
  path.join(localAppData, "Programs", "antigravity", "agy.exe"),
214
250
  path.join(localAppData, "Programs", "Antigravity", "agy.exe"),
251
+ path.join(localAppData, "Programs", "agy", "bin", "agy.exe"),
252
+ path.join(localAppData, "Programs", "agy", "agy.exe"),
215
253
  path.join(programFiles, "Antigravity", "bin", "agy.exe"),
254
+ path.join(programFiles, "agy", "bin", "agy.exe"),
216
255
  path.join(programFilesX86, "Antigravity", "bin", "agy.exe"),
256
+ path.join(programFilesX86, "agy", "bin", "agy.exe"),
217
257
  path.join(localAppData, "Google", "Antigravity", "agy.exe"),
218
258
  path.join(localAppData, "Google", "Antigravity", "bin", "agy.exe"),
259
+ path.join(localAppData, "Google", "agy", "bin", "agy.exe"),
260
+ path.join(localAppData, "Google", "agy", "agy.exe"),
219
261
  path.join(home, ".antigravity", "bin", "agy.exe"),
220
262
  path.join(home, ".antigravity", "agy.exe"),
221
263
  path.join(home, ".gemini", "antigravity-cli", "bin", "agy.exe"),
@@ -249,11 +291,16 @@ function resolveAgyBinary() {
249
291
  // Fallback to batch scripts (.cmd / .bat) if no .exe found
250
292
  if (resolved === "agy") {
251
293
  const batchCandidates = [
294
+ path.join(localAppData, "agy", "bin", "agy.cmd"),
295
+ path.join(localAppData, "agy", "agy.cmd"),
296
+ path.join(home, ".agy", "bin", "agy.cmd"),
252
297
  path.join(appData, "npm", "agy.cmd"),
253
298
  path.join(localAppData, "npm", "agy.cmd"),
254
299
  path.join(home, ".local", "bin", "agy.cmd"),
255
300
  path.join(home, ".antigravity", "bin", "agy.cmd"),
256
301
  path.join(home, ".gemini", "antigravity-cli", "bin", "agy.cmd"),
302
+ path.join(localAppData, "agy", "bin", "agy.bat"),
303
+ path.join(localAppData, "agy", "agy.bat"),
257
304
  path.join(appData, "npm", "agy.bat"),
258
305
  path.join(localAppData, "npm", "agy.bat"),
259
306
  path.join(home, ".local", "bin", "agy.bat"),
@@ -311,14 +358,26 @@ export class AntigravityQuotaProvider {
311
358
  const programFilesX86 = process.env["ProgramFiles(x86)"] || "C:\\\\Program Files (x86)";
312
359
 
313
360
  const extraPaths = isWin ? [
314
- path.join(appData, "npm"),
315
- path.join(localAppData, "npm"),
316
- path.join(programFiles, "nodejs"),
317
- path.join(programFilesX86, "nodejs"),
361
+ path.join(localAppData, "agy", "bin"),
362
+ path.join(localAppData, "agy"),
363
+ path.join(home, ".agy", "bin"),
318
364
  path.join(localAppData, "Programs", "Antigravity", "bin"),
319
365
  path.join(localAppData, "Programs", "antigravity"),
366
+ path.join(localAppData, "Programs", "agy", "bin"),
367
+ path.join(localAppData, "Google", "Antigravity", "bin"),
368
+ path.join(localAppData, "Google", "agy", "bin"),
320
369
  path.join(home, ".antigravity", "bin"),
370
+ path.join(home, ".gemini", "antigravity-cli", "bin"),
321
371
  path.join(home, ".local", "bin"),
372
+ path.join(appData, "npm"),
373
+ path.join(localAppData, "npm"),
374
+ path.join(localAppData, "Microsoft", "WindowsApps"),
375
+ path.join(programFiles, "nodejs"),
376
+ path.join(programFilesX86, "nodejs"),
377
+ path.join(programFiles, "Antigravity", "bin"),
378
+ path.join(programFiles, "agy", "bin"),
379
+ path.join(programFilesX86, "Antigravity", "bin"),
380
+ path.join(programFilesX86, "agy", "bin"),
322
381
  ].filter(p => fs.existsSync(p)) : [];
323
382
 
324
383
  const env = { ...process.env };
@@ -591,39 +650,43 @@ export function patchPaseoServer(serverDir) {
591
650
  }
592
651
  }
593
652
  // Patch handleUsageUpdate
594
- if (acpCode.includes("handleUsageUpdate") && (!acpCode.includes("this.deliverTranslatedEvents") || acpCode.includes("this.notifySubscribers"))) {
595
- const startIdx = acpCode.search(/\bhandleUsageUpdate\s*\(/);
596
- if (startIdx !== -1) {
597
- const openBrace = acpCode.indexOf("{", startIdx);
598
- if (openBrace !== -1) {
599
- let depth = 1;
600
- let i = openBrace + 1;
601
- while (i < acpCode.length && depth > 0) {
602
- if (acpCode[i] === "{")
603
- depth++;
604
- else if (acpCode[i] === "}")
605
- depth--;
606
- i++;
607
- }
608
- if (depth === 0) {
609
- const newHandler = `handleUsageUpdate(update) {
610
- if (!update) return;
611
- const usage = mapACPUsage(update);
612
- if (usage) {
613
- this.currentTurnUsage = { ...this.currentTurnUsage, ...usage };
614
- const event = {
615
- type: "usage_updated",
616
- provider: this.provider,
617
- usage: this.currentTurnUsage,
618
- ...(this.activeForegroundTurnId ? { turnId: this.activeForegroundTurnId } : {}),
619
- };
620
- if (typeof this.deliverTranslatedEvents === "function") {
621
- this.deliverTranslatedEvents([event]);
622
- } else if (typeof this.pushEvent === "function") {
623
- this.pushEvent(event);
624
- }
625
- }
626
- }`;
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}}`;
627
690
  acpCode = acpCode.slice(0, startIdx) + newHandler + acpCode.slice(i);
628
691
  acpModified = true;
629
692
  }
@@ -887,6 +950,7 @@ export function isPaseoServerPatched(serverDir) {
887
950
  try {
888
951
  if (!fs.existsSync(serverDir))
889
952
  return false;
953
+ // 1. Antigravity quota provider file
890
954
  const antigravityJsCandidates = [
891
955
  path.join(serverDir, "dist", "server", "services", "quota-fetcher", "providers", "antigravity.js"),
892
956
  path.join(serverDir, "dist", "services", "quota-fetcher", "providers", "antigravity.js"),
@@ -913,20 +977,80 @@ export function isPaseoServerPatched(serverDir) {
913
977
  };
914
978
  hasProvider = checkRecursive(path.join(serverDir, "dist"));
915
979
  }
916
- if (hasProvider)
917
- return true;
980
+ if (!hasProvider)
981
+ return false;
982
+ // 2. Manifest check
918
983
  const manifestCandidates = [
919
984
  path.join(serverDir, "dist", "server", "services", "quota-fetcher", "manifest.js"),
920
985
  path.join(serverDir, "dist", "services", "quota-fetcher", "manifest.js"),
921
986
  ];
922
- for (const cand of manifestCandidates) {
923
- if (fs.existsSync(cand)) {
924
- const content = fs.readFileSync(cand, "utf-8");
925
- if (content.includes('providerId: "antigravity"'))
926
- return true;
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;
927
1015
  }
928
1016
  }
929
- return false;
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;
930
1054
  }
931
1055
  catch {
932
1056
  return false;
@@ -940,7 +1064,7 @@ export async function isPaseoAsarPatched(asarPath) {
940
1064
  if (!fs.existsSync(asarPath))
941
1065
  return false;
942
1066
  const files = listPackage(asarPath);
943
- return files.some((f) => f.includes("antigravity.js"));
1067
+ return files.some((f) => f.replace(/\\/g, "/").includes("quota-fetcher/providers/antigravity.js"));
944
1068
  }
945
1069
  catch {
946
1070
  return false;
package/dist/version.js CHANGED
@@ -16,7 +16,7 @@ function getPackageVersion() {
16
16
  catch {
17
17
  // ignore
18
18
  }
19
- return "1.2.1";
19
+ return "1.2.2";
20
20
  }
21
21
  export const SEMVER_VERSION = getPackageVersion();
22
22
  let cachedBuildMetadata = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-acp-agy",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "ACP (Agent Client Protocol) provider for Google Antigravity in Paseo and Zed",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",