@heyhuynhgiabuu/pi-oauth-antigravity 0.1.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +91 -0
  4. package/dist/auth/index.d.ts +2 -0
  5. package/dist/auth/index.js +1 -0
  6. package/dist/auth/oauth.d.ts +18 -0
  7. package/dist/auth/oauth.js +374 -0
  8. package/dist/client/client.d.ts +35 -0
  9. package/dist/client/client.js +448 -0
  10. package/dist/client/index.d.ts +1 -0
  11. package/dist/client/index.js +1 -0
  12. package/dist/diagnostics/diagnostics.d.ts +31 -0
  13. package/dist/diagnostics/diagnostics.js +68 -0
  14. package/dist/diagnostics/index.d.ts +1 -0
  15. package/dist/diagnostics/index.js +1 -0
  16. package/dist/image/image.d.ts +62 -0
  17. package/dist/image/image.js +244 -0
  18. package/dist/image/index.d.ts +1 -0
  19. package/dist/image/index.js +1 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.js +182 -0
  22. package/dist/models/index.d.ts +1 -0
  23. package/dist/models/index.js +1 -0
  24. package/dist/models/models.d.ts +44 -0
  25. package/dist/models/models.js +377 -0
  26. package/dist/stream/index.d.ts +1 -0
  27. package/dist/stream/index.js +1 -0
  28. package/dist/stream/stream.d.ts +24 -0
  29. package/dist/stream/stream.js +879 -0
  30. package/dist/types/enums.d.ts +41 -0
  31. package/dist/types/enums.js +49 -0
  32. package/dist/types/index.d.ts +2 -0
  33. package/dist/types/index.js +2 -0
  34. package/dist/types/types.d.ts +259 -0
  35. package/dist/types/types.js +2 -0
  36. package/dist/usage/index.d.ts +1 -0
  37. package/dist/usage/index.js +1 -0
  38. package/dist/usage/usage.d.ts +8 -0
  39. package/dist/usage/usage.js +388 -0
  40. package/dist/utils/http.d.ts +7 -0
  41. package/dist/utils/http.js +81 -0
  42. package/dist/utils/index.d.ts +3 -0
  43. package/dist/utils/index.js +3 -0
  44. package/dist/utils/security.d.ts +8 -0
  45. package/dist/utils/security.js +60 -0
  46. package/dist/utils/util.d.ts +40 -0
  47. package/dist/utils/util.js +176 -0
  48. package/package.json +73 -0
@@ -0,0 +1,41 @@
1
+ export declare enum ThinkingEffort {
2
+ Off = "off",
3
+ Minimal = "minimal",
4
+ Low = "low",
5
+ Medium = "medium",
6
+ High = "high",
7
+ Xhigh = "xhigh"
8
+ }
9
+ export declare enum Platform {
10
+ Macos = "MACOS",
11
+ Windows = "WINDOWS",
12
+ Linux = "LINUX"
13
+ }
14
+ export declare enum ToolChoice {
15
+ Auto = "auto",
16
+ None = "none",
17
+ Any = "any",
18
+ Required = "required"
19
+ }
20
+ export declare enum GeminiToolCallingMode {
21
+ None = "NONE",
22
+ Any = "ANY",
23
+ Auto = "AUTO",
24
+ Validated = "VALIDATED"
25
+ }
26
+ export declare enum GeminiRole {
27
+ User = "user",
28
+ Model = "model"
29
+ }
30
+ export declare enum AntigravityRequestType {
31
+ Agent = "agent"
32
+ }
33
+ export declare enum AntigravityUserAgent {
34
+ Antigravity = "antigravity"
35
+ }
36
+ export declare enum StopReason {
37
+ Stop = "stop",
38
+ Length = "length",
39
+ ToolUse = "toolUse",
40
+ Error = "error"
41
+ }
@@ -0,0 +1,49 @@
1
+ export var ThinkingEffort;
2
+ (function (ThinkingEffort) {
3
+ ThinkingEffort["Off"] = "off";
4
+ ThinkingEffort["Minimal"] = "minimal";
5
+ ThinkingEffort["Low"] = "low";
6
+ ThinkingEffort["Medium"] = "medium";
7
+ ThinkingEffort["High"] = "high";
8
+ ThinkingEffort["Xhigh"] = "xhigh";
9
+ })(ThinkingEffort || (ThinkingEffort = {}));
10
+ export var Platform;
11
+ (function (Platform) {
12
+ Platform["Macos"] = "MACOS";
13
+ Platform["Windows"] = "WINDOWS";
14
+ Platform["Linux"] = "LINUX";
15
+ })(Platform || (Platform = {}));
16
+ export var ToolChoice;
17
+ (function (ToolChoice) {
18
+ ToolChoice["Auto"] = "auto";
19
+ ToolChoice["None"] = "none";
20
+ ToolChoice["Any"] = "any";
21
+ ToolChoice["Required"] = "required";
22
+ })(ToolChoice || (ToolChoice = {}));
23
+ export var GeminiToolCallingMode;
24
+ (function (GeminiToolCallingMode) {
25
+ GeminiToolCallingMode["None"] = "NONE";
26
+ GeminiToolCallingMode["Any"] = "ANY";
27
+ GeminiToolCallingMode["Auto"] = "AUTO";
28
+ GeminiToolCallingMode["Validated"] = "VALIDATED";
29
+ })(GeminiToolCallingMode || (GeminiToolCallingMode = {}));
30
+ export var GeminiRole;
31
+ (function (GeminiRole) {
32
+ GeminiRole["User"] = "user";
33
+ GeminiRole["Model"] = "model";
34
+ })(GeminiRole || (GeminiRole = {}));
35
+ export var AntigravityRequestType;
36
+ (function (AntigravityRequestType) {
37
+ AntigravityRequestType["Agent"] = "agent";
38
+ })(AntigravityRequestType || (AntigravityRequestType = {}));
39
+ export var AntigravityUserAgent;
40
+ (function (AntigravityUserAgent) {
41
+ AntigravityUserAgent["Antigravity"] = "antigravity";
42
+ })(AntigravityUserAgent || (AntigravityUserAgent = {}));
43
+ export var StopReason;
44
+ (function (StopReason) {
45
+ StopReason["Stop"] = "stop";
46
+ StopReason["Length"] = "length";
47
+ StopReason["ToolUse"] = "toolUse";
48
+ StopReason["Error"] = "error";
49
+ })(StopReason || (StopReason = {}));
@@ -0,0 +1,2 @@
1
+ export * from "./enums.js";
2
+ export * from "./types.js";
@@ -0,0 +1,2 @@
1
+ export * from "./enums.js";
2
+ export * from "./types.js";
@@ -0,0 +1,259 @@
1
+ import type { Server } from "node:http";
2
+ import type { OAuthCredentials, SimpleStreamOptions, TextContent, ThinkingContent, ToolCall } from "@earendil-works/pi-ai";
3
+ import type { AntigravityRequestType, AntigravityUserAgent, GeminiRole, GeminiToolCallingMode, ThinkingEffort, ToolChoice } from "./enums.js";
4
+ export type AntigravityOAuthCredentials = OAuthCredentials & {
5
+ projectId?: string;
6
+ email?: string;
7
+ };
8
+ export type AntigravityApiKey = {
9
+ token: string;
10
+ projectId: string;
11
+ };
12
+ export type DynamicModelInfo = {
13
+ id: string;
14
+ experiments?: string[];
15
+ apiProvider?: string;
16
+ modelProvider?: string;
17
+ };
18
+ export type CallbackServer = {
19
+ server: Server;
20
+ waitForCode: () => Promise<{
21
+ code: string;
22
+ state: string;
23
+ }>;
24
+ cleanup: () => void;
25
+ };
26
+ export type AntigravityRouting = {
27
+ off?: string;
28
+ routing?: Partial<Record<ThinkingEffort, string>>;
29
+ defaultRequestId?: string;
30
+ };
31
+ export declare const ANTIGRAVITY_API: "antigravity-api";
32
+ export type AntigravityApi = typeof ANTIGRAVITY_API;
33
+ export type AntigravityStreamOptions = Omit<SimpleStreamOptions, "toolChoice"> & {
34
+ toolChoice?: ToolChoice | "auto" | "none";
35
+ };
36
+ export type GeminiTextPart = {
37
+ text: string;
38
+ thoughtSignature?: string;
39
+ };
40
+ export type GeminiInlineDataPart = {
41
+ inlineData: {
42
+ mimeType: string;
43
+ data: string;
44
+ };
45
+ };
46
+ export type GeminiThoughtPart = {
47
+ thought: true;
48
+ text: string;
49
+ thoughtSignature?: string;
50
+ };
51
+ export type GeminiFunctionCallPart = {
52
+ functionCall: {
53
+ name: string;
54
+ args: Record<string, unknown>;
55
+ id?: string;
56
+ };
57
+ thoughtSignature?: string;
58
+ };
59
+ export type GeminiFunctionResponsePart = {
60
+ functionResponse: {
61
+ name: string;
62
+ response: {
63
+ error: string;
64
+ } | {
65
+ output: string;
66
+ };
67
+ id?: string;
68
+ };
69
+ };
70
+ export type GeminiPart = GeminiTextPart | GeminiInlineDataPart | GeminiThoughtPart | GeminiFunctionCallPart | GeminiFunctionResponsePart;
71
+ export type GeminiContent = {
72
+ role: GeminiRole;
73
+ parts: GeminiPart[];
74
+ };
75
+ export type GeminiFunctionDeclaration = {
76
+ name: string;
77
+ description: string;
78
+ parameters?: unknown;
79
+ parametersJsonSchema?: unknown;
80
+ };
81
+ export type GeminiToolConfig = {
82
+ functionCallingConfig: {
83
+ mode: GeminiToolCallingMode;
84
+ };
85
+ };
86
+ export type GeminiGenerationConfig = {
87
+ temperature?: number;
88
+ maxOutputTokens?: number;
89
+ thinkingConfig?: {
90
+ includeThoughts?: boolean;
91
+ thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
92
+ thinkingBudget?: number;
93
+ };
94
+ };
95
+ export type GeminiRequestBody = {
96
+ contents: GeminiContent[];
97
+ systemInstruction: {
98
+ role: GeminiRole.User;
99
+ parts: GeminiTextPart[];
100
+ };
101
+ generationConfig?: GeminiGenerationConfig;
102
+ tools?: {
103
+ functionDeclarations: GeminiFunctionDeclaration[];
104
+ }[];
105
+ toolConfig?: GeminiToolConfig;
106
+ sessionId?: string;
107
+ labels?: Record<string, string>;
108
+ };
109
+ export type AntigravityGenerateRequest = {
110
+ project: string;
111
+ model: string;
112
+ request: GeminiRequestBody;
113
+ requestType: AntigravityRequestType.Agent;
114
+ userAgent: AntigravityUserAgent.Antigravity;
115
+ requestId: string;
116
+ };
117
+ export type StreamPart = {
118
+ text?: string;
119
+ thought?: boolean;
120
+ thoughtSignature?: string;
121
+ functionCall?: {
122
+ id?: string;
123
+ name?: string;
124
+ args?: Record<string, unknown>;
125
+ };
126
+ };
127
+ export type StreamUsageMetadata = {
128
+ promptTokenCount?: number;
129
+ cachedContentTokenCount?: number;
130
+ candidatesTokenCount?: number;
131
+ thoughtsTokenCount?: number;
132
+ totalTokenCount?: number;
133
+ };
134
+ export type StreamCandidate = {
135
+ content?: {
136
+ parts?: StreamPart[];
137
+ };
138
+ finishReason?: string;
139
+ };
140
+ export type StreamResponseData = {
141
+ candidates?: StreamCandidate[];
142
+ usageMetadata?: StreamUsageMetadata;
143
+ responseId?: string;
144
+ };
145
+ export type StreamChunk = StreamResponseData & {
146
+ error?: {
147
+ message?: string;
148
+ };
149
+ response?: StreamResponseData;
150
+ };
151
+ export type LooseImageBlock = {
152
+ type: "image";
153
+ data?: string;
154
+ mimeType?: string;
155
+ mediaType?: string;
156
+ source?: {
157
+ data?: string;
158
+ mediaType?: string;
159
+ };
160
+ };
161
+ export type ContentBlock = TextContent | ThinkingContent | ToolCall | LooseImageBlock;
162
+ export type ActiveTextBlock = TextContent;
163
+ export type ActiveThinkingBlock = ThinkingContent;
164
+ export type ActiveBlock = ActiveTextBlock | ActiveThinkingBlock;
165
+ export type QuotaBucket = {
166
+ bucketId: string;
167
+ displayName: string;
168
+ window?: string;
169
+ resetTime?: string;
170
+ description?: string;
171
+ remainingFraction: number;
172
+ };
173
+ export type QuotaGroup = {
174
+ displayName: string;
175
+ description?: string;
176
+ buckets: QuotaBucket[];
177
+ };
178
+ export type ModelQuotaRow = {
179
+ modelId: string;
180
+ displayName?: string;
181
+ remainingFraction?: number;
182
+ resetTime?: string;
183
+ modelProvider?: string;
184
+ supportsThinking?: boolean;
185
+ supportsImages?: boolean;
186
+ recommended?: boolean;
187
+ };
188
+ export type TierInfo = {
189
+ id?: string;
190
+ name?: string;
191
+ description?: string;
192
+ };
193
+ export type AccountUsage = {
194
+ projectId: string;
195
+ endpoint: string;
196
+ email?: string;
197
+ productTier?: TierInfo;
198
+ paidTier?: TierInfo;
199
+ planLabel?: string;
200
+ groups: QuotaGroup[];
201
+ groupDescription?: string;
202
+ /** Set when the (subscription-gated) quota-summary RPC was unavailable, e.g. free-tier SUBSCRIPTION_REQUIRED. */
203
+ quotaSummaryError?: string;
204
+ models: ModelQuotaRow[];
205
+ defaultAgentModelId?: string;
206
+ fetchedAt: number;
207
+ };
208
+ export type ApiErrorBody = {
209
+ error?: {
210
+ message?: string;
211
+ };
212
+ raw?: string;
213
+ };
214
+ export type QuotaBucketRaw = {
215
+ bucketId?: unknown;
216
+ displayName?: unknown;
217
+ window?: unknown;
218
+ resetTime?: unknown;
219
+ description?: unknown;
220
+ remainingFraction?: unknown;
221
+ };
222
+ export type QuotaGroupRaw = {
223
+ displayName?: unknown;
224
+ description?: unknown;
225
+ buckets?: QuotaBucketRaw[];
226
+ };
227
+ export type QuotaSummaryRaw = {
228
+ description?: unknown;
229
+ groups?: QuotaGroupRaw[];
230
+ };
231
+ export type ModelInfoRaw = {
232
+ isInternal?: unknown;
233
+ displayName?: unknown;
234
+ label?: unknown;
235
+ modelName?: unknown;
236
+ modelProvider?: unknown;
237
+ apiProvider?: unknown;
238
+ supportsThinking?: unknown;
239
+ supportsImages?: unknown;
240
+ recommended?: unknown;
241
+ quotaInfo?: {
242
+ remainingFraction?: unknown;
243
+ resetTime?: unknown;
244
+ };
245
+ };
246
+ export type AvailableModelsRaw = {
247
+ models?: Record<string, ModelInfoRaw>;
248
+ defaultAgentModelId?: unknown;
249
+ defaultAgentModel?: unknown;
250
+ };
251
+ export type TierRaw = {
252
+ id?: unknown;
253
+ name?: unknown;
254
+ description?: unknown;
255
+ };
256
+ export type LoadCodeAssistRaw = {
257
+ currentTier?: TierRaw;
258
+ paidTier?: TierRaw;
259
+ };
@@ -0,0 +1,2 @@
1
+ // Stream & API Types
2
+ export const ANTIGRAVITY_API = "antigravity-api";
@@ -0,0 +1 @@
1
+ export * from "./usage.js";
@@ -0,0 +1 @@
1
+ export * from "./usage.js";
@@ -0,0 +1,8 @@
1
+ import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
+ import type { AccountUsage } from "../types/types.js";
3
+ export declare function fetchAccountUsage(apiKeyRaw?: string): Promise<AccountUsage>;
4
+ export declare function formatUsageSummary(usage: AccountUsage): string;
5
+ export declare function formatModelsList(usage: AccountUsage, opts?: {
6
+ all?: boolean;
7
+ }): string;
8
+ export declare function resolveApiKeyFromContext(ctx: ExtensionCommandContext): Promise<string | undefined>;