@herbertgao/pi-extensions 2026.11.18 → 2026.11.19
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/CHANGELOG.md +12 -0
- package/README.md +3 -3
- package/THIRD_PARTY_NOTICES.md +2 -23
- package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +956 -0
- package/node_modules/{pi-antigravity → @estebanforge/pi-antigravity-bridge}/LICENSE +1 -1
- package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +240 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +2117 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +61 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/connection.ts +644 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/driver.ts +1043 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/events.ts +323 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/home.ts +145 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/jsonrpc.ts +243 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/setup.ts +107 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/usage-estimate.ts +61 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agents.ts +64 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-install.ts +93 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-paths.ts +30 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-setup.ts +81 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-version.ts +289 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-detect.ts +161 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-gate.ts +233 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-hook.ts +325 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts-ui.ts +88 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts.ts +144 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/ask-tool.ts +1221 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/background-watch.ts +225 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/bridge-catalog.ts +197 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +523 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/daily-log.ts +196 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/dialog-lock.ts +48 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/diff-render.ts +207 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver-types.ts +168 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver.ts +907 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/engine-picker.ts +160 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/frame-guard.ts +38 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/handoff-toast.ts +21 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-registration.ts +376 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-server.ts +618 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/models.ts +404 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/native-tools.ts +104 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/parked-turn.ts +125 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/patch-cleanup.ts +523 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/poll-fold.ts +55 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/prompt-images.ts +92 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +2214 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/queued-messages.ts +152 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/quota-notice.ts +40 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/redact.ts +27 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/sessions.ts +197 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/skills.ts +207 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-events.ts +161 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-sanitizer.ts +180 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/subagent-roster.ts +245 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/sysprompt-agent.ts +130 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks-ui.ts +90 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks.ts +174 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/usage.ts +174 -0
- package/node_modules/@estebanforge/pi-antigravity-bridge/src/web-tools.ts +320 -0
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +3 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +1 -1
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +317 -105
- package/node_modules/@herbertgao/pi-subagents/SECURITY.md +2 -2
- package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +240 -36
- package/node_modules/@herbertgao/pi-subagents/docs/translations.md +63 -0
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +2 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +89 -6
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +6 -2
- package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +20 -11
- package/node_modules/@herbertgao/pi-subagents/src/cache-retention.ts +39 -0
- package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +5 -0
- package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +185 -44
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +7 -0
- package/node_modules/@herbertgao/pi-subagents/src/group-join.ts +9 -0
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +126 -116
- package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +3 -2
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +21 -0
- package/node_modules/@herbertgao/pi-subagents/src/subagent-info.ts +115 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +11 -7
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -3
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +2 -2
- package/node_modules/@herbertgao/pi-subagents/src/workflow-info.ts +184 -0
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +10 -0
- package/node_modules/pi-commandcode-provider/README.md +3 -2
- package/node_modules/pi-commandcode-provider/index.ts +120 -13
- package/node_modules/pi-commandcode-provider/package.json +4 -3
- package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +11 -2
- package/node_modules/pi-commandcode-provider/src/pricing.ts +17 -1
- package/node_modules/pi-commandcode-provider/src/quota-command.ts +3 -2
- package/node_modules/pi-commandcode-provider/src/zdr.ts +163 -0
- package/package.json +11 -14
- package/node_modules/pi-antigravity/README.md +0 -298
- package/node_modules/pi-antigravity/docs/reader-guarantees.md +0 -35
- package/node_modules/pi-antigravity/package.json +0 -87
- package/node_modules/pi-antigravity/src/auth/accounts.ts +0 -327
- package/node_modules/pi-antigravity/src/auth/index.ts +0 -23
- package/node_modules/pi-antigravity/src/auth/oauth.ts +0 -445
- package/node_modules/pi-antigravity/src/client/client.ts +0 -602
- package/node_modules/pi-antigravity/src/client/enterprise.ts +0 -150
- package/node_modules/pi-antigravity/src/client/index.ts +0 -2
- package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +0 -104
- package/node_modules/pi-antigravity/src/diagnostics/index.ts +0 -1
- package/node_modules/pi-antigravity/src/features/generate-image.ts +0 -132
- package/node_modules/pi-antigravity/src/features/google-search.ts +0 -72
- package/node_modules/pi-antigravity/src/features/read-url-content.ts +0 -124
- package/node_modules/pi-antigravity/src/image/image.ts +0 -427
- package/node_modules/pi-antigravity/src/image/index.ts +0 -1
- package/node_modules/pi-antigravity/src/image/native.ts +0 -69
- package/node_modules/pi-antigravity/src/index.ts +0 -547
- package/node_modules/pi-antigravity/src/models/discovery.ts +0 -176
- package/node_modules/pi-antigravity/src/models/grouping.ts +0 -487
- package/node_modules/pi-antigravity/src/models/index.ts +0 -3
- package/node_modules/pi-antigravity/src/models/models.ts +0 -647
- package/node_modules/pi-antigravity/src/search/index.ts +0 -1
- package/node_modules/pi-antigravity/src/search/search.ts +0 -967
- package/node_modules/pi-antigravity/src/stream/index.ts +0 -1
- package/node_modules/pi-antigravity/src/stream/stream.ts +0 -1961
- package/node_modules/pi-antigravity/src/types/enums.ts +0 -52
- package/node_modules/pi-antigravity/src/types/index.ts +0 -2
- package/node_modules/pi-antigravity/src/types/types.ts +0 -329
- package/node_modules/pi-antigravity/src/usage/index.ts +0 -1
- package/node_modules/pi-antigravity/src/usage/usage.ts +0 -437
- package/node_modules/pi-antigravity/src/utils/address.ts +0 -180
- package/node_modules/pi-antigravity/src/utils/credits.ts +0 -149
- package/node_modules/pi-antigravity/src/utils/html.ts +0 -31
- package/node_modules/pi-antigravity/src/utils/http.ts +0 -96
- package/node_modules/pi-antigravity/src/utils/index.ts +0 -5
- package/node_modules/pi-antigravity/src/utils/security.ts +0 -278
- package/node_modules/pi-antigravity/src/utils/text.ts +0 -66
- package/node_modules/pi-antigravity/src/utils/util.ts +0 -217
- package/node_modules/pi-antigravity/src/web-fetch/document.ts +0 -83
- package/node_modules/pi-antigravity/src/web-fetch/fences.ts +0 -24
- package/node_modules/pi-antigravity/src/web-fetch/header.ts +0 -97
- package/node_modules/pi-antigravity/src/web-fetch/index.ts +0 -3
- package/node_modules/pi-antigravity/src/web-fetch/inspect.ts +0 -328
- package/node_modules/pi-antigravity/src/web-fetch/limits.ts +0 -4
- package/node_modules/pi-antigravity/src/web-fetch/markdown.ts +0 -744
- package/node_modules/pi-antigravity/src/web-fetch/mdn.ts +0 -164
- package/node_modules/pi-antigravity/src/web-fetch/media.ts +0 -11
- package/node_modules/pi-antigravity/src/web-fetch/metadata.ts +0 -9
- package/node_modules/pi-antigravity/src/web-fetch/representation.ts +0 -93
- package/node_modules/pi-antigravity/src/web-fetch/save.ts +0 -71
- package/node_modules/pi-antigravity/src/web-fetch/sites.ts +0 -138
- package/node_modules/pi-antigravity/src/web-fetch/vendor.d.ts +0 -9
- package/node_modules/pi-antigravity/src/web-fetch/web-fetch.ts +0 -957
- package/node_modules/pi-antigravity/tsconfig.json +0 -21
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
3
|
-
ANTIGRAVITY_IMAGE_API,
|
|
4
|
-
ANTIGRAVITY_IMAGE_MODELS,
|
|
5
|
-
generateAntigravityImages,
|
|
6
|
-
} from "./image/native.js";
|
|
7
|
-
|
|
8
|
-
// Namespace import: Oh My Pi rewrites this specifier onto bundled pi-ai, which
|
|
9
|
-
// does not export registerApiProvider. A static named import fails plugin load.
|
|
10
|
-
import * as piAiCompat from "@earendil-works/pi-ai/compat";
|
|
11
|
-
import {
|
|
12
|
-
activateAccount,
|
|
13
|
-
getApiKey,
|
|
14
|
-
listAccounts,
|
|
15
|
-
loginAntigravity,
|
|
16
|
-
rememberAccount,
|
|
17
|
-
refreshAntigravityToken,
|
|
18
|
-
removeAccount,
|
|
19
|
-
updateRememberedAccount,
|
|
20
|
-
} from "./auth/index.js";
|
|
21
|
-
import { DEFAULT_ENDPOINT } from "./client/index.js";
|
|
22
|
-
import { getLastDiagnostics, runWithDiagnostics } from "./diagnostics/index.js";
|
|
23
|
-
import { generateAntigravityImage, parseImageCommandArgs } from "./image/index.js";
|
|
24
|
-
import { executeAntigravitySearch, parseSearchCommandArgs } from "./search/index.js";
|
|
25
|
-
import {
|
|
26
|
-
executeAntigravityWebFetch,
|
|
27
|
-
discardSavedPage,
|
|
28
|
-
formatWebFetchHeader,
|
|
29
|
-
formatWebFetchResult,
|
|
30
|
-
looksLikeHtml,
|
|
31
|
-
parseFetchCommandArgs,
|
|
32
|
-
savePage,
|
|
33
|
-
savedPageNote,
|
|
34
|
-
type SavedPage,
|
|
35
|
-
withSavedCopy,
|
|
36
|
-
validateFetchTarget,
|
|
37
|
-
} from "./web-fetch/index.js";
|
|
38
|
-
import {
|
|
39
|
-
applyAntigravityCatalog,
|
|
40
|
-
discoverAntigravityModels,
|
|
41
|
-
getCurrentAntigravityCatalog,
|
|
42
|
-
PROVIDER_ID,
|
|
43
|
-
PROVIDER_NAME,
|
|
44
|
-
refreshAntigravityModels,
|
|
45
|
-
resolvedCatalog,
|
|
46
|
-
} from "./models/index.js";
|
|
47
|
-
import { ANTIGRAVITY_API, streamAntigravity } from "./stream/index.js";
|
|
48
|
-
import {
|
|
49
|
-
fetchAccountUsage,
|
|
50
|
-
fetchRemainingCredits,
|
|
51
|
-
formatModelsList,
|
|
52
|
-
formatUsageSummary,
|
|
53
|
-
resolveApiKeyFromContext,
|
|
54
|
-
} from "./usage/index.js";
|
|
55
|
-
import {
|
|
56
|
-
getCreditsStatus,
|
|
57
|
-
isCreditsEnabled,
|
|
58
|
-
setCreditsEnabled,
|
|
59
|
-
redactSecrets,
|
|
60
|
-
maskEmail,
|
|
61
|
-
} from "./utils/index.js";
|
|
62
|
-
import { describeEnterpriseRouting } from "./client/enterprise.js";
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Pi's interactive `notify` writes into the chat transcript. `console.log` in that
|
|
66
|
-
* mode prints to the raw terminal and paints over the TUI. Use one channel only.
|
|
67
|
-
*/
|
|
68
|
-
function emitCommandOutput(
|
|
69
|
-
ctx: ExtensionCommandContext,
|
|
70
|
-
text: string,
|
|
71
|
-
type: "info" | "warning" | "error" = "info",
|
|
72
|
-
): void {
|
|
73
|
-
if (ctx.hasUI) {
|
|
74
|
-
ctx.ui.notify(text, type);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (type === "warning" || type === "error") console.error(text);
|
|
78
|
-
else console.log(text);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function loginAndRemember(
|
|
82
|
-
callbacks: Parameters<typeof loginAntigravity>[0],
|
|
83
|
-
): ReturnType<typeof loginAntigravity> {
|
|
84
|
-
const credentials = await loginAntigravity(callbacks);
|
|
85
|
-
rememberAccount(credentials);
|
|
86
|
-
return credentials;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function refreshAndRemember(
|
|
90
|
-
credentials: Parameters<typeof refreshAntigravityToken>[0],
|
|
91
|
-
): ReturnType<typeof refreshAntigravityToken> {
|
|
92
|
-
const refreshed = await refreshAntigravityToken(credentials);
|
|
93
|
-
updateRememberedAccount(credentials, refreshed);
|
|
94
|
-
return refreshed;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function withUsage(
|
|
98
|
-
ctx: ExtensionCommandContext,
|
|
99
|
-
fn: (usage: Awaited<ReturnType<typeof fetchAccountUsage>>) => string,
|
|
100
|
-
): Promise<void> {
|
|
101
|
-
try {
|
|
102
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
103
|
-
if (!apiKey) {
|
|
104
|
-
emitCommandOutput(
|
|
105
|
-
ctx,
|
|
106
|
-
"No Antigravity credentials. Run /login antigravity first.",
|
|
107
|
-
"warning",
|
|
108
|
-
);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (ctx.hasUI) ctx.ui.notify("Fetching Antigravity usage…", "info");
|
|
112
|
-
const usage = await runWithDiagnostics(() => fetchAccountUsage(apiKey));
|
|
113
|
-
emitCommandOutput(ctx, fn(usage));
|
|
114
|
-
} catch (error) {
|
|
115
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
116
|
-
emitCommandOutput(ctx, `Antigravity usage failed: ${msg}`, "warning");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
type CompatApiProviderRegistrar = (provider: {
|
|
121
|
-
api: typeof ANTIGRAVITY_API;
|
|
122
|
-
stream: typeof streamAntigravity;
|
|
123
|
-
streamSimple: typeof streamAntigravity;
|
|
124
|
-
}) => void;
|
|
125
|
-
|
|
126
|
-
type CompatImagesProviderRegistrar = (provider: {
|
|
127
|
-
api: typeof ANTIGRAVITY_IMAGE_API;
|
|
128
|
-
generateImages: typeof generateAntigravityImages;
|
|
129
|
-
}) => void;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Pi dispatches custom APIs through the compat registry. Oh My Pi does not
|
|
133
|
-
* export `registerApiProvider` and registers the stream inside `registerProvider`.
|
|
134
|
-
*/
|
|
135
|
-
function registerCompatApiProvider(): void {
|
|
136
|
-
const register = (piAiCompat as { registerApiProvider?: CompatApiProviderRegistrar })
|
|
137
|
-
.registerApiProvider;
|
|
138
|
-
if (typeof register === "function") {
|
|
139
|
-
register({
|
|
140
|
-
api: ANTIGRAVITY_API,
|
|
141
|
-
stream: streamAntigravity,
|
|
142
|
-
streamSimple: streamAntigravity,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
const registerImages = (
|
|
146
|
-
piAiCompat as unknown as {
|
|
147
|
-
registerImagesApiProvider?: CompatImagesProviderRegistrar;
|
|
148
|
-
}
|
|
149
|
-
).registerImagesApiProvider;
|
|
150
|
-
if (typeof registerImages === "function") {
|
|
151
|
-
registerImages({
|
|
152
|
-
api: ANTIGRAVITY_IMAGE_API,
|
|
153
|
-
generateImages: generateAntigravityImages,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export default function (pi: ExtensionAPI): void {
|
|
159
|
-
registerCompatApiProvider();
|
|
160
|
-
|
|
161
|
-
// Print and RPC modes do not refresh catalogs before resolving --model. Refresh on
|
|
162
|
-
// session start so a stale 1.2.x cache is replaced before the prompt, and so the next
|
|
163
|
-
// headless process hydrates Gemini 4 from the persisted store (#93).
|
|
164
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
165
|
-
if (process.env.PI_OFFLINE !== undefined) return;
|
|
166
|
-
if (typeof ctx.modelRegistry?.refresh !== "function") return;
|
|
167
|
-
try {
|
|
168
|
-
const refresh = ctx.modelRegistry.refresh({ providers: [PROVIDER_ID] });
|
|
169
|
-
if (ctx.hasUI) void refresh.catch(() => {});
|
|
170
|
-
else await refresh;
|
|
171
|
-
} catch {
|
|
172
|
-
// Last-known-good catalog stays in place. Forced refreshes still report via the command.
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const initialCatalog = getCurrentAntigravityCatalog();
|
|
177
|
-
|
|
178
|
-
const providerConfig = {
|
|
179
|
-
name: PROVIDER_NAME,
|
|
180
|
-
baseUrl: DEFAULT_ENDPOINT,
|
|
181
|
-
api: ANTIGRAVITY_API,
|
|
182
|
-
models: [...initialCatalog.models, ...ANTIGRAVITY_IMAGE_MODELS],
|
|
183
|
-
refreshModels: async (context: Parameters<typeof refreshAntigravityModels>[0]) => {
|
|
184
|
-
const refreshed = await refreshAntigravityModels(context);
|
|
185
|
-
return [...refreshed, ...ANTIGRAVITY_IMAGE_MODELS];
|
|
186
|
-
},
|
|
187
|
-
oauth: {
|
|
188
|
-
name: PROVIDER_NAME,
|
|
189
|
-
// Antigravity access is quota-backed by the Google account, not metered per token.
|
|
190
|
-
// Pi uses this for the footer's (sub) marker and subscription-aware cost display.
|
|
191
|
-
isSubscription: true,
|
|
192
|
-
login: loginAndRemember,
|
|
193
|
-
refreshToken: refreshAndRemember,
|
|
194
|
-
getApiKey,
|
|
195
|
-
},
|
|
196
|
-
streamSimple: streamAntigravity,
|
|
197
|
-
images: {
|
|
198
|
-
[ANTIGRAVITY_IMAGE_API]: {
|
|
199
|
-
generateImages: generateAntigravityImages,
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// Pi 0.86 types are chat-only; newer Pi accepts mixed-operation models and images.
|
|
205
|
-
pi.registerProvider(
|
|
206
|
-
PROVIDER_ID,
|
|
207
|
-
providerConfig as unknown as Parameters<typeof pi.registerProvider>[1],
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
pi.registerCommand("antigravity.usage", {
|
|
211
|
-
description: "Show Antigravity shared quota pools (Gemini / Claude+GPT, 5h + weekly)",
|
|
212
|
-
handler: async (_args, ctx) => {
|
|
213
|
-
await withUsage(ctx, formatUsageSummary);
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
pi.registerCommand("antigravity.models", {
|
|
218
|
-
description: "List Antigravity runtime models + remaining pool fraction",
|
|
219
|
-
handler: async (args, ctx) => {
|
|
220
|
-
const all = /\ball\b/i.test(args || "");
|
|
221
|
-
await withUsage(ctx, (usage) => formatModelsList(usage, { all }));
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
pi.registerCommand("antigravity.accounts", {
|
|
226
|
-
description: "List, switch, or remove linked Antigravity Google accounts",
|
|
227
|
-
handler: async (args, ctx) => {
|
|
228
|
-
const command = args.trim();
|
|
229
|
-
try {
|
|
230
|
-
if (command.startsWith("switch ")) {
|
|
231
|
-
const account = await activateAccount(command.slice("switch ".length));
|
|
232
|
-
emitCommandOutput(
|
|
233
|
-
ctx,
|
|
234
|
-
`Active Antigravity account: ${account.email || account.accountId}`,
|
|
235
|
-
);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (command.startsWith("remove ")) {
|
|
239
|
-
const remaining = await removeAccount(command.slice("remove ".length));
|
|
240
|
-
const next = remaining
|
|
241
|
-
? ` Active account is now ${remaining.email || remaining.accountId}.`
|
|
242
|
-
: "";
|
|
243
|
-
emitCommandOutput(ctx, `Antigravity account removed.${next}`);
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const accounts = listAccounts();
|
|
247
|
-
if (accounts.length === 0) {
|
|
248
|
-
emitCommandOutput(
|
|
249
|
-
ctx,
|
|
250
|
-
"No linked Antigravity accounts. Run /login antigravity to add one.",
|
|
251
|
-
"warning",
|
|
252
|
-
);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const lines = accounts.map(
|
|
256
|
-
(account, index) =>
|
|
257
|
-
`${account.active ? "* " : " "}${index + 1}. ${account.email || account.accountId}`,
|
|
258
|
-
);
|
|
259
|
-
emitCommandOutput(
|
|
260
|
-
ctx,
|
|
261
|
-
`${lines.join("\n")}\nUse /antigravity.accounts switch <index|email> or /antigravity.accounts remove <index|email>.`,
|
|
262
|
-
);
|
|
263
|
-
} catch (error) {
|
|
264
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
265
|
-
emitCommandOutput(ctx, msg, "error");
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
pi.registerCommand("antigravity.credits", {
|
|
271
|
-
description: "Check remaining AI credits or toggle overages (/antigravity.credits [on|off])",
|
|
272
|
-
handler: async (args, ctx) => {
|
|
273
|
-
const mode = args.trim().toLowerCase();
|
|
274
|
-
try {
|
|
275
|
-
if (mode === "on" || mode === "enable" || mode === "true" || mode === "1") {
|
|
276
|
-
setCreditsEnabled(true);
|
|
277
|
-
emitCommandOutput(
|
|
278
|
-
ctx,
|
|
279
|
-
"Antigravity AI credit overages: ENABLED.\nRequests will supply enabledCreditTypes: ['GOOGLE_ONE_AI'] to use credit balance when standard quota is exhausted.",
|
|
280
|
-
"info",
|
|
281
|
-
);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (mode === "off" || mode === "disable" || mode === "false" || mode === "0") {
|
|
285
|
-
setCreditsEnabled(false);
|
|
286
|
-
emitCommandOutput(
|
|
287
|
-
ctx,
|
|
288
|
-
"Antigravity AI credit overages: DISABLED.\nRequests will not tap into AI credits.",
|
|
289
|
-
"info",
|
|
290
|
-
);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
295
|
-
const status = getCreditsStatus();
|
|
296
|
-
|
|
297
|
-
let creditsInfo: Awaited<ReturnType<typeof fetchRemainingCredits>> | undefined;
|
|
298
|
-
if (apiKey) {
|
|
299
|
-
try {
|
|
300
|
-
creditsInfo = await fetchRemainingCredits(apiKey);
|
|
301
|
-
} catch {
|
|
302
|
-
// best effort
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const lines: string[] = [];
|
|
307
|
-
if (creditsInfo?.planLabel) {
|
|
308
|
-
lines.push(creditsInfo.planLabel);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (creditsInfo?.availableCredits && creditsInfo.availableCredits.length > 0) {
|
|
312
|
-
for (const c of creditsInfo.availableCredits) {
|
|
313
|
-
const amt = c.creditAmount !== undefined ? c.creditAmount.toLocaleString() : "0";
|
|
314
|
-
const typ = c.creditType || "GOOGLE_ONE_AI";
|
|
315
|
-
lines.push(`Remaining AI Credits: ${amt} (${typ})`);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
lines.push("Remaining AI Credits: 0 (or not reported by subscription)");
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
lines.push(`AI Credit Overages: ${status.enabled ? "ENABLED" : "DISABLED"}`);
|
|
322
|
-
lines.push("");
|
|
323
|
-
lines.push("Usage:");
|
|
324
|
-
lines.push(" /antigravity.credits on - Enable AI credits overage on quota exhaustion");
|
|
325
|
-
lines.push(" /antigravity.credits off - Disable AI credits overage");
|
|
326
|
-
|
|
327
|
-
emitCommandOutput(ctx, lines.join("\n"), "info");
|
|
328
|
-
} catch (error) {
|
|
329
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
330
|
-
emitCommandOutput(ctx, `Failed to query or update credit settings: ${msg}`, "error");
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
pi.registerCommand("antigravity.refresh", {
|
|
336
|
-
description: "Force refresh Antigravity dynamic model catalog",
|
|
337
|
-
handler: async (_args, ctx) => {
|
|
338
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
339
|
-
if (!apiKey) {
|
|
340
|
-
emitCommandOutput(
|
|
341
|
-
ctx,
|
|
342
|
-
"No Antigravity credentials. Run /login antigravity first.",
|
|
343
|
-
"warning",
|
|
344
|
-
);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (ctx.hasUI) ctx.ui.notify("Refreshing Antigravity models…", "info");
|
|
348
|
-
try {
|
|
349
|
-
if (typeof ctx.modelRegistry?.refresh === "function") {
|
|
350
|
-
const result = await ctx.modelRegistry.refresh({
|
|
351
|
-
force: true,
|
|
352
|
-
providers: [PROVIDER_ID],
|
|
353
|
-
});
|
|
354
|
-
if (result?.errors?.has(PROVIDER_ID)) {
|
|
355
|
-
throw result.errors.get(PROVIDER_ID)!;
|
|
356
|
-
}
|
|
357
|
-
} else {
|
|
358
|
-
const discovered = await discoverAntigravityModels(apiKey);
|
|
359
|
-
const next = resolvedCatalog(discovered, getCurrentAntigravityCatalog());
|
|
360
|
-
if (discovered.models.length > 0) {
|
|
361
|
-
applyAntigravityCatalog(next);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
const catalog = getCurrentAntigravityCatalog();
|
|
365
|
-
const count = catalog.models.length;
|
|
366
|
-
const sample = catalog.models
|
|
367
|
-
.slice(0, 4)
|
|
368
|
-
.map((m) => m.name || m.id)
|
|
369
|
-
.join(", ");
|
|
370
|
-
emitCommandOutput(
|
|
371
|
-
ctx,
|
|
372
|
-
`Antigravity models refreshed (${count} available: ${sample}${count > 4 ? ", …" : ""})`,
|
|
373
|
-
"info",
|
|
374
|
-
);
|
|
375
|
-
} catch (error) {
|
|
376
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
377
|
-
emitCommandOutput(ctx, `Antigravity model refresh failed: ${redactSecrets(msg)}`, "error");
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
pi.registerCommand("antigravity.doctor", {
|
|
383
|
-
description: "Show sanitized Antigravity provider diagnostics",
|
|
384
|
-
handler: async (_args, ctx) => {
|
|
385
|
-
const d = getLastDiagnostics();
|
|
386
|
-
const accounts = listAccounts();
|
|
387
|
-
const active = accounts.find((account) => account.active);
|
|
388
|
-
const activeLabel = active
|
|
389
|
-
? maskEmail(active.email) ||
|
|
390
|
-
(active.accountId.includes("@") ? maskEmail(active.accountId) : active.accountId)
|
|
391
|
-
: "none";
|
|
392
|
-
const lines = [
|
|
393
|
-
`provider=${PROVIDER_ID}`,
|
|
394
|
-
`lastResolvedRuntimeModel=${d.resolvedRuntimeModel || "none"}`,
|
|
395
|
-
`availableModels=${d.availableModels || "none"}`,
|
|
396
|
-
`matchedModel=${d.matchedModelDebug || "none"}`,
|
|
397
|
-
`lastEndpoint=${d.endpoint || "none"}`,
|
|
398
|
-
`lastStatus=${d.status ?? "none"}`,
|
|
399
|
-
`lastProjectId=${d.projectId || "none"}`,
|
|
400
|
-
`linkedAccounts=${accounts.length || "none"}`,
|
|
401
|
-
`activeAccount=${activeLabel || "none"}`,
|
|
402
|
-
`aiCreditOverages=${isCreditsEnabled() ? "enabled" : "disabled"}`,
|
|
403
|
-
`routing=${describeEnterpriseRouting()}`,
|
|
404
|
-
...(d.latencyMs !== undefined ? [`lastLatencyMs=${d.latencyMs}`] : []),
|
|
405
|
-
`toolSchemaWarnings=${d.toolSchemaWarnings || "none"}`,
|
|
406
|
-
...(d.fetchTrace ? [`lastFetch=${d.fetchTrace}`] : []),
|
|
407
|
-
`lastError=${d.error ? redactSecrets(d.error) : "none"}`,
|
|
408
|
-
"transport=native-streamSimple",
|
|
409
|
-
"runtimeCli=not-used",
|
|
410
|
-
"commands=/antigravity.usage /antigravity.models /antigravity.accounts /antigravity.credits /antigravity.refresh /antigravity.doctor /antigravity.image /antigravity.search /antigravity.fetch",
|
|
411
|
-
];
|
|
412
|
-
emitCommandOutput(ctx, `Antigravity doctor\n${lines.join("\n")}`);
|
|
413
|
-
},
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
pi.registerCommand("antigravity.image", {
|
|
417
|
-
description:
|
|
418
|
-
"Generate an image via Antigravity (usage: /antigravity.image [--ratio 16:9] <prompt>)",
|
|
419
|
-
handler: async (args, ctx) => {
|
|
420
|
-
const parsed = parseImageCommandArgs(args || "");
|
|
421
|
-
if (!parsed.prompt) {
|
|
422
|
-
emitCommandOutput(
|
|
423
|
-
ctx,
|
|
424
|
-
"Usage: /antigravity.image [--ratio 16:9] [--model gemini-3-pro-image] [--path file.png] <prompt>",
|
|
425
|
-
"warning",
|
|
426
|
-
);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
try {
|
|
430
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
431
|
-
if (!apiKey) {
|
|
432
|
-
emitCommandOutput(
|
|
433
|
-
ctx,
|
|
434
|
-
"No Antigravity credentials. Run /login antigravity first.",
|
|
435
|
-
"warning",
|
|
436
|
-
);
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
if (ctx.hasUI) ctx.ui.notify("Generating Antigravity image…", "info");
|
|
440
|
-
const result = await generateAntigravityImage({
|
|
441
|
-
apiKey,
|
|
442
|
-
cwd: ctx.cwd,
|
|
443
|
-
prompt: parsed.prompt,
|
|
444
|
-
aspectRatio: parsed.aspectRatio,
|
|
445
|
-
model: parsed.model,
|
|
446
|
-
path: parsed.path,
|
|
447
|
-
});
|
|
448
|
-
emitCommandOutput(ctx, `Saved image to ${result.savedPaths.join(", ")}`);
|
|
449
|
-
} catch (error) {
|
|
450
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
451
|
-
emitCommandOutput(ctx, `Antigravity image failed: ${redactSecrets(msg)}`, "warning");
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
pi.registerCommand("antigravity.search", {
|
|
457
|
-
description:
|
|
458
|
-
"Search the web via Antigravity Grounding (usage: /antigravity.search [--thinking] [--url <url>] <query>)",
|
|
459
|
-
handler: async (args, ctx) => {
|
|
460
|
-
const parsed = parseSearchCommandArgs(args || "");
|
|
461
|
-
if (!parsed.query) {
|
|
462
|
-
emitCommandOutput(
|
|
463
|
-
ctx,
|
|
464
|
-
"Usage: /antigravity.search [--thinking] [--url <url>] <query>",
|
|
465
|
-
"warning",
|
|
466
|
-
);
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
try {
|
|
470
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
471
|
-
if (!apiKey) {
|
|
472
|
-
emitCommandOutput(
|
|
473
|
-
ctx,
|
|
474
|
-
"No Antigravity credentials. Run /login antigravity first.",
|
|
475
|
-
"warning",
|
|
476
|
-
);
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
if (ctx.hasUI) ctx.ui.notify("Searching Google via Antigravity Grounding…", "info");
|
|
480
|
-
const result = await executeAntigravitySearch({
|
|
481
|
-
apiKey,
|
|
482
|
-
query: parsed.query,
|
|
483
|
-
urls: parsed.urls,
|
|
484
|
-
thinking: parsed.thinking,
|
|
485
|
-
});
|
|
486
|
-
emitCommandOutput(ctx, result);
|
|
487
|
-
} catch (error) {
|
|
488
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
489
|
-
emitCommandOutput(ctx, `Antigravity search failed: ${redactSecrets(msg)}`, "warning");
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
pi.registerCommand("antigravity.fetch", {
|
|
495
|
-
description:
|
|
496
|
-
"Read a public web page via the Antigravity crawler (usage: /antigravity.fetch [--raw] <url>)",
|
|
497
|
-
handler: async (args, ctx) => {
|
|
498
|
-
const parsed = parseFetchCommandArgs(args || "");
|
|
499
|
-
if (!parsed.url) {
|
|
500
|
-
emitCommandOutput(ctx, "Usage: /antigravity.fetch [--raw] <url>", "warning");
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
try {
|
|
504
|
-
const url = validateFetchTarget(parsed.url);
|
|
505
|
-
const apiKey = await resolveApiKeyFromContext(ctx);
|
|
506
|
-
if (!apiKey) {
|
|
507
|
-
emitCommandOutput(
|
|
508
|
-
ctx,
|
|
509
|
-
"No Antigravity credentials. Run /login antigravity first.",
|
|
510
|
-
"warning",
|
|
511
|
-
);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
if (ctx.hasUI) ctx.ui.notify("Reading page via Antigravity…", "info");
|
|
515
|
-
const result = await executeAntigravityWebFetch({
|
|
516
|
-
apiKey,
|
|
517
|
-
url,
|
|
518
|
-
raw: parsed.raw,
|
|
519
|
-
});
|
|
520
|
-
const whole = result.content;
|
|
521
|
-
let footer = "";
|
|
522
|
-
let saved: SavedPage | undefined;
|
|
523
|
-
if (formatWebFetchHeader(result).length + whole.length > (result.maxChars ?? 0)) {
|
|
524
|
-
// Raw output is the crawled source itself; converted output keeps its provenance.
|
|
525
|
-
saved = parsed.raw
|
|
526
|
-
? await savePage(whole, looksLikeHtml(whole) ? "html" : "txt")
|
|
527
|
-
: await savePage(formatWebFetchHeader(result) + whole, "md");
|
|
528
|
-
footer = savedPageNote(saved, whole.length, "Open it to read the rest.");
|
|
529
|
-
}
|
|
530
|
-
try {
|
|
531
|
-
emitCommandOutput(ctx, formatWebFetchResult(result, footer));
|
|
532
|
-
} catch (error) {
|
|
533
|
-
if (saved) await discardSavedPage(saved);
|
|
534
|
-
throw error;
|
|
535
|
-
}
|
|
536
|
-
} catch (caught) {
|
|
537
|
-
const error = await withSavedCopy(caught);
|
|
538
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
539
|
-
const guidance = msg.replace(
|
|
540
|
-
"Do not retry this URL with read_url_content. If permitted, use an available download tool or terminal to download it directly, then read the local file with a PDF reader.",
|
|
541
|
-
"If you have permission, download the URL directly and open the local file with a PDF reader.",
|
|
542
|
-
);
|
|
543
|
-
emitCommandOutput(ctx, redactSecrets(guidance), "warning");
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
}
|