omp-antigravity-acp-provider 0.3.3 → 0.3.4
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/extension/index.ts
CHANGED
|
@@ -822,7 +822,15 @@ export async function registerOmpAdapter(pi: OmpHostApi, stateDir: string,
|
|
|
822
822
|
const plan = selectedLaunchPlan ?? await inspectRuntimeLaunchPlan(stateDir, { signal }).catch(() => undefined);
|
|
823
823
|
const source = plan ? quotaSourceForPlan(plan) : undefined;
|
|
824
824
|
if (!plan || !source) return undefined;
|
|
825
|
-
if (source.kind === "cli")
|
|
825
|
+
if (source.kind === "cli") {
|
|
826
|
+
// The probe runs agy against the isolated antigravity-acp profile. A
|
|
827
|
+
// CLI-only login reaches that profile only through this token sync, which
|
|
828
|
+
// prepareRuntime runs after an ACP login check or during sign-in; without
|
|
829
|
+
// it here, every probe would start agy's interactive sign-in instead of
|
|
830
|
+
// reporting quota.
|
|
831
|
+
syncAntigravityOAuthToken();
|
|
832
|
+
return fetchCliQuota(source.cliPath, signal);
|
|
833
|
+
}
|
|
826
834
|
// Quota keeps the local-login credential route: OMP's usage provider has no
|
|
827
835
|
// credential parameter, so an OMP-stored API key is not forwarded here.
|
|
828
836
|
if (!(await authReady())) return undefined;
|
|
@@ -498,10 +498,10 @@ function wrapperCommand(file: string, platform: NodeJS.Platform, args: readonly
|
|
|
498
498
|
return { command: process.env.ComSpec ?? "cmd.exe", args: ["/d", "/s", "/e:on", "/v:off", "/c", `call "${file}"`, ...args] };
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
// The wrapper only launches the CLI. Credential sync happens
|
|
502
|
-
//
|
|
503
|
-
// known; a shell copy here would hardcode $HOME and could
|
|
504
|
-
// token with an older CLI one.
|
|
501
|
+
// The wrapper only launches the CLI. Credential sync happens in prepareRuntime()
|
|
502
|
+
// and before CLI quota probes, where GEMINI_HOME and an atomic, newer-than
|
|
503
|
+
// replacement are known; a shell copy here would hardcode $HOME and could
|
|
504
|
+
// overwrite a newer ACP token with an older CLI one.
|
|
505
505
|
function cliWrapperScript(agyPath: string, platform: NodeJS.Platform = process.platform): string {
|
|
506
506
|
if (platform === "win32") {
|
|
507
507
|
const escaped = agyPath.replace(/%/g, "%%");
|
package/extension/runtime.mjs
CHANGED
|
@@ -32146,7 +32146,7 @@ var ClientSideConnection = class {
|
|
|
32146
32146
|
// package.json
|
|
32147
32147
|
var package_default = {
|
|
32148
32148
|
name: "omp-antigravity-acp-provider",
|
|
32149
|
-
version: "0.3.
|
|
32149
|
+
version: "0.3.4",
|
|
32150
32150
|
ompAcpBundle: 1,
|
|
32151
32151
|
description: "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
|
|
32152
32152
|
type: "module",
|
|
@@ -33262,7 +33262,7 @@ function structuredErrorDetail(data) {
|
|
|
33262
33262
|
}
|
|
33263
33263
|
|
|
33264
33264
|
// extension/usage-accounting.ts
|
|
33265
|
-
import { execFile as execFile2 } from "node:child_process";
|
|
33265
|
+
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
33266
33266
|
import { promisify as promisify2 } from "node:util";
|
|
33267
33267
|
|
|
33268
33268
|
// extension/runtime/launch.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
3
|
import { AcpFailure } from "./acp-errors.ts";
|
|
4
4
|
import { resolveCommandProbe } from "./runtime/launch.ts";
|
|
@@ -162,15 +162,83 @@ function parseCliResetTime(value: string): string | undefined {
|
|
|
162
162
|
|
|
163
163
|
export async function fetchCliQuota(cliPath: string, signal?: AbortSignal): Promise<AntigravityQuotaSnapshot> {
|
|
164
164
|
const launch = resolveCommandProbe(cliPath, ["--app_data_dir=antigravity-acp", "-p", "/usage"]);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
if (process.platform === "win32") {
|
|
166
|
+
const { stdout } = await execFileAsync(launch.command, launch.args, {
|
|
167
|
+
encoding: "utf8",
|
|
168
|
+
timeout: 30_000,
|
|
169
|
+
maxBuffer: 1024 * 1024,
|
|
170
|
+
windowsHide: true,
|
|
171
|
+
windowsVerbatimArguments: true,
|
|
172
|
+
...(signal ? { signal } : {}),
|
|
173
|
+
});
|
|
174
|
+
return parseCliUsageQuota(stdout);
|
|
175
|
+
}
|
|
176
|
+
return parseCliUsageQuota(await runWithoutTerminal(launch.command, launch.args, 30_000, 1024 * 1024, signal));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The usage probe runs in the background of an interactive OMP session. When its agy profile has no login,
|
|
180
|
+
// `-p /usage` opens /dev/tty and waits for a pasted authorization code, reading the user's keystrokes and the
|
|
181
|
+
// terminal's replies meant for OMP. A detached child starts a new session without a controlling terminal, so
|
|
182
|
+
// that open fails. Bun 1.4's execFile ignores `detached` (Node's honors it); spawn honors it in both.
|
|
183
|
+
function runWithoutTerminal(command: string, args: readonly string[], timeoutMs: number, maxBuffer: number, signal?: AbortSignal): Promise<string> {
|
|
184
|
+
const { promise, resolve, reject } = Promise.withResolvers<string>();
|
|
185
|
+
if (signal?.aborted) {
|
|
186
|
+
reject(signal.reason instanceof Error ? signal.reason : new Error("aborted"));
|
|
187
|
+
return promise;
|
|
188
|
+
}
|
|
189
|
+
const child = spawn(command, args, { detached: true, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
190
|
+
let stdout = "";
|
|
191
|
+
let stderr = "";
|
|
192
|
+
let failure: Error | undefined;
|
|
193
|
+
let killTimer: NodeJS.Timeout | undefined;
|
|
194
|
+
const signalGroup = (name: NodeJS.Signals) => {
|
|
195
|
+
try {
|
|
196
|
+
process.kill(-child.pid!, name);
|
|
197
|
+
} catch {
|
|
198
|
+
child.kill(name);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
const stop = (error: Error) => {
|
|
202
|
+
failure ??= error;
|
|
203
|
+
if (killTimer) return;
|
|
204
|
+
signalGroup("SIGTERM");
|
|
205
|
+
killTimer = setTimeout(() => signalGroup("SIGKILL"), 2_000);
|
|
206
|
+
};
|
|
207
|
+
const timer = setTimeout(() => stop(new Error(`${command} timed out after ${timeoutMs} ms`)), timeoutMs);
|
|
208
|
+
const onAbort = () => stop(signal?.reason instanceof Error ? signal.reason : new Error("aborted"));
|
|
209
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
210
|
+
child.stdout.setEncoding("utf8");
|
|
211
|
+
child.stderr.setEncoding("utf8");
|
|
212
|
+
child.stdout.on("data", (chunk: string) => {
|
|
213
|
+
stdout += chunk;
|
|
214
|
+
if (stdout.length > maxBuffer) stop(new Error(`${command} stdout exceeded ${maxBuffer} bytes`));
|
|
215
|
+
});
|
|
216
|
+
child.stderr.on("data", (chunk: string) => {
|
|
217
|
+
stderr = (stderr + chunk).slice(-4096);
|
|
218
|
+
});
|
|
219
|
+
child.once("error", (error) => {
|
|
220
|
+
if (child.pid !== undefined) {
|
|
221
|
+
stop(error);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
// The process never started, so no "close" event follows.
|
|
225
|
+
clearTimeout(timer);
|
|
226
|
+
signal?.removeEventListener("abort", onAbort);
|
|
227
|
+
reject(error);
|
|
228
|
+
});
|
|
229
|
+
child.once("close", (code, closeSignal) => {
|
|
230
|
+
clearTimeout(timer);
|
|
231
|
+
if (killTimer) {
|
|
232
|
+
// The leader exited after SIGTERM; a member that ignored it must not outlive the probe.
|
|
233
|
+
clearTimeout(killTimer);
|
|
234
|
+
signalGroup("SIGKILL");
|
|
235
|
+
}
|
|
236
|
+
signal?.removeEventListener("abort", onAbort);
|
|
237
|
+
if (failure) reject(failure);
|
|
238
|
+
else if (code !== 0) reject(new Error(`${command} exited with ${code ?? closeSignal}: ${stderr.trim() || stdout.trim()}`.slice(0, 2000)));
|
|
239
|
+
else resolve(stdout);
|
|
172
240
|
});
|
|
173
|
-
return
|
|
241
|
+
return promise;
|
|
174
242
|
}
|
|
175
243
|
|
|
176
244
|
export function quotaExhaustion(text: string, now = Date.now()): { resetAt?: string } | undefined {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omp-antigravity-acp-provider",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"ompAcpBundle": 1,
|
|
5
5
|
"description": "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
|
|
6
6
|
"type": "module",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"acp",
|
|
89
89
|
"gemini"
|
|
90
90
|
],
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "8bebd650a29571adb22030a604b8fdc363754200"
|
|
92
92
|
}
|