@zhexin/pi-agy 0.0.3 → 0.0.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/README.md +1 -1
- package/package.json +1 -1
- package/src/index.ts +23 -35
- package/src/usage.ts +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ pi auth login agy
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Install [`@zhexin/pi-usage`](../usage/README.md) and run `/usage agy` to show remaining 5-hour and weekly quota, with reset times.
|
|
16
16
|
|
|
17
17
|
## License
|
|
18
18
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,42 +6,30 @@ import { oauth } from "./auth.ts";
|
|
|
6
6
|
import { agyCredential, fetchModels } from "./ccpa.ts";
|
|
7
7
|
import { usage } from "./usage.ts";
|
|
8
8
|
|
|
9
|
-
const commands: Record<
|
|
10
|
-
string,
|
|
11
|
-
{
|
|
12
|
-
description: string;
|
|
13
|
-
handler: (args: string, ctx: ExtensionCommandContext) => Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
> = {
|
|
16
|
-
usage: { description: "Show remaining quota", handler: usage },
|
|
17
|
-
};
|
|
18
|
-
|
|
19
9
|
export default function (pi: ExtensionAPI): void {
|
|
20
|
-
pi.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else console.log(help);
|
|
44
|
-
},
|
|
10
|
+
pi.events.on("pi-usage:discover", (data) => {
|
|
11
|
+
const discovery = data as {
|
|
12
|
+
add: (provider: { id: string; label: string; authHint: string }) => void;
|
|
13
|
+
};
|
|
14
|
+
if (typeof discovery?.add !== "function") return;
|
|
15
|
+
discovery.add({
|
|
16
|
+
id: "agy",
|
|
17
|
+
label: "Antigravity",
|
|
18
|
+
authHint: "Run /login agy to authenticate.",
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
pi.events.on("pi-usage:request", async (data) => {
|
|
23
|
+
const request = data as { provider: string; ctx: ExtensionCommandContext } | undefined;
|
|
24
|
+
if (request?.provider !== "agy" || !request.ctx) return;
|
|
25
|
+
const { ctx } = request;
|
|
26
|
+
try {
|
|
27
|
+
await usage(ctx);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
const message = `Antigravity quota query failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
30
|
+
if (ctx.hasUI) ctx.ui.notify(message, "error");
|
|
31
|
+
else console.error(message);
|
|
32
|
+
}
|
|
45
33
|
});
|
|
46
34
|
|
|
47
35
|
pi.on("before_agent_start", async (event, ctx) => {
|
package/src/usage.ts
CHANGED
|
@@ -28,7 +28,7 @@ function resetLabel(resetTime: string | undefined, now: number): string {
|
|
|
28
28
|
return ` · resets in ${remaining}`;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export async function usage(
|
|
31
|
+
export async function usage(ctx: ExtensionCommandContext): Promise<void> {
|
|
32
32
|
const output = (text: string) => {
|
|
33
33
|
if (ctx.hasUI) ctx.ui.notify(text);
|
|
34
34
|
else console.log(text);
|