pi-antigravity-rotator 2.1.6 → 2.2.2
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 +49 -0
- package/README.md +5 -4
- package/package.json +11 -3
- package/src/account-store.ts +30 -0
- package/src/admin-auth.ts +84 -1
- package/src/compat/cache.ts +42 -0
- package/src/compat/model-specs.ts +78 -0
- package/src/compat/schema-sanitizer.ts +277 -0
- package/src/compat/translators.ts +1538 -0
- package/src/compat.ts +1537 -2357
- package/src/dashboard.ts +11 -11
- package/src/index.ts +41 -1
- package/src/logger.ts +6 -1
- package/src/notification-poller.ts +4 -1
- package/src/oauth.ts +31 -0
- package/src/onboarding.ts +19 -0
- package/src/paths.ts +23 -3
- package/src/proxy.ts +375 -171
- package/src/responses-store.ts +203 -0
- package/src/rotator.ts +226 -16
- package/src/telemetry.ts +31 -1
- package/src/types.ts +70 -0
- package/src/validators.ts +36 -0
- package/src/antigravity-prompt.ts +0 -80
package/src/types.ts
CHANGED
|
@@ -70,6 +70,56 @@ export interface Config {
|
|
|
70
70
|
tokenBucketMaxTokens?: number;
|
|
71
71
|
tokenBucketRefillPerMinute?: number;
|
|
72
72
|
tokenBucketInitialTokens?: number;
|
|
73
|
+
// Override per-model specs used by the compat layer. Keys are model id substrings
|
|
74
|
+
// matched case-insensitively. When set, replaces the bundled defaults entirely.
|
|
75
|
+
modelSpecs?: Record<string, ModelSpecConfig>;
|
|
76
|
+
// Override model-id aliases used to translate the operator-facing name
|
|
77
|
+
// (e.g. "gemini-3.5-flash-high") to the upstream Antigravity name
|
|
78
|
+
// (e.g. "gemini-3-flash-agent"). When set, replaces the bundled defaults.
|
|
79
|
+
modelAliases?: Record<string, string>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ── Default model-id aliases ─────────────────────────────────────────
|
|
83
|
+
// Translates operator-facing model names to Antigravity upstream names.
|
|
84
|
+
// When the provider adds a new model, this is the only place that needs
|
|
85
|
+
// updating. Operators can override via Config.modelAliases in accounts.json.
|
|
86
|
+
const DEFAULT_MODEL_ALIASES: Record<string, string> = {
|
|
87
|
+
"gemini-3.1-pro-high": "gemini-pro-agent",
|
|
88
|
+
"gemini-3.5-flash": "gemini-3-flash-agent",
|
|
89
|
+
"gemini-3.5-flash-high": "gemini-3-flash-agent",
|
|
90
|
+
"gemini-3.5-flash-medium": "gemini-3-flash-agent",
|
|
91
|
+
"gpt-oss-120b": "gpt-oss-120b-medium",
|
|
92
|
+
};
|
|
93
|
+
let modelAliasesOverride: Record<string, string> | null = null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Replace the bundled model-alias table with operator-provided overrides.
|
|
97
|
+
* Pass `null` to restore the defaults. Called once at startup from
|
|
98
|
+
* index.ts via `setModelAliasesOverride(config.modelAliases ?? null)`.
|
|
99
|
+
*
|
|
100
|
+
* @param aliases Map of operator-facing model name to upstream model name,
|
|
101
|
+
* or null to restore defaults.
|
|
102
|
+
*/
|
|
103
|
+
export function setModelAliasesOverride(aliases: Record<string, string> | null): void {
|
|
104
|
+
modelAliasesOverride = aliases && Object.keys(aliases).length > 0 ? aliases : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getActiveModelAliases(): Record<string, string> {
|
|
108
|
+
return modelAliasesOverride ?? DEFAULT_MODEL_ALIASES;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Translate a model name to its upstream equivalent. Exact-match lookup
|
|
113
|
+
* (case-insensitive). Returns the original model if no alias is configured.
|
|
114
|
+
*/
|
|
115
|
+
export function applyModelAlias(model: string): string {
|
|
116
|
+
const aliases = getActiveModelAliases();
|
|
117
|
+
if (model in aliases) return aliases[model];
|
|
118
|
+
const lower = model.toLowerCase();
|
|
119
|
+
for (const [from, to] of Object.entries(aliases)) {
|
|
120
|
+
if (from.toLowerCase() === lower) return to;
|
|
121
|
+
}
|
|
122
|
+
return model;
|
|
73
123
|
}
|
|
74
124
|
|
|
75
125
|
// Quota API response from Google
|
|
@@ -85,6 +135,22 @@ export interface GoogleQuotaResponse {
|
|
|
85
135
|
>;
|
|
86
136
|
}
|
|
87
137
|
|
|
138
|
+
// Per-model thinking/output spec used by the compat layer.
|
|
139
|
+
// Operators can override defaults via the `modelSpecs` field in accounts.json.
|
|
140
|
+
export interface ModelSpecConfig {
|
|
141
|
+
maxOutputTokens: number;
|
|
142
|
+
thinkingBudget: number; // -1 = adaptive (model decides), >=0 = fixed
|
|
143
|
+
isThinking: boolean;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Per-model thinking/output spec used by the compat layer.
|
|
147
|
+
// Operators can override defaults via the `modelSpecs` field in accounts.json.
|
|
148
|
+
export interface ModelSpecConfig {
|
|
149
|
+
maxOutputTokens: number;
|
|
150
|
+
thinkingBudget: number; // -1 = adaptive (model decides), >=0 = fixed
|
|
151
|
+
isThinking: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
88
154
|
// Per-model quota info for an account
|
|
89
155
|
export interface ModelQuota {
|
|
90
156
|
modelKey: string;
|
|
@@ -320,6 +386,10 @@ export interface AccountStatus {
|
|
|
320
386
|
activeForModels: string[];
|
|
321
387
|
requestsSinceRotation: number;
|
|
322
388
|
totalRequests: number;
|
|
389
|
+
dailyRequestCount: number;
|
|
390
|
+
dailyAccountStopRequests: number;
|
|
391
|
+
dailyProjectRequestCount: number;
|
|
392
|
+
dailyProjectStopRequests: number;
|
|
323
393
|
cooldownsByModel: Record<string, number>;
|
|
324
394
|
lastUsed: number;
|
|
325
395
|
lastError: string | null;
|
package/src/validators.ts
CHANGED
|
@@ -98,6 +98,42 @@ export function validateConfig(value: unknown): ValidationResult<Config> {
|
|
|
98
98
|
if (value.tokenBucketInitialTokens !== undefined && !isNonNegativeNumber(value.tokenBucketInitialTokens)) {
|
|
99
99
|
errors.push("config.tokenBucketInitialTokens must be a non-negative number");
|
|
100
100
|
}
|
|
101
|
+
if (value.modelSpecs !== undefined) {
|
|
102
|
+
if (!isRecord(value.modelSpecs)) {
|
|
103
|
+
errors.push("config.modelSpecs must be an object when provided");
|
|
104
|
+
} else {
|
|
105
|
+
for (const [key, spec] of Object.entries(value.modelSpecs)) {
|
|
106
|
+
if (!isRecord(spec)) {
|
|
107
|
+
errors.push(`config.modelSpecs.${key} must be an object`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (spec.maxOutputTokens !== undefined && !isPositiveNumber(spec.maxOutputTokens)) {
|
|
111
|
+
errors.push(`config.modelSpecs.${key}.maxOutputTokens must be a positive number`);
|
|
112
|
+
}
|
|
113
|
+
if (spec.thinkingBudget !== undefined && (typeof spec.thinkingBudget !== "number" || !Number.isFinite(spec.thinkingBudget))) {
|
|
114
|
+
errors.push(`config.modelSpecs.${key}.thinkingBudget must be a number`);
|
|
115
|
+
}
|
|
116
|
+
if (spec.isThinking !== undefined && typeof spec.isThinking !== "boolean") {
|
|
117
|
+
errors.push(`config.modelSpecs.${key}.isThinking must be a boolean`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (value.modelAliases !== undefined) {
|
|
123
|
+
if (!isRecord(value.modelAliases)) {
|
|
124
|
+
errors.push("config.modelAliases must be an object when provided");
|
|
125
|
+
} else {
|
|
126
|
+
for (const [from, to] of Object.entries(value.modelAliases)) {
|
|
127
|
+
if (typeof from !== "string" || from.length === 0) {
|
|
128
|
+
errors.push("config.modelAliases keys must be non-empty strings");
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
if (typeof to !== "string" || to.length === 0) {
|
|
132
|
+
errors.push(`config.modelAliases.${from} must be a non-empty string`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
101
137
|
|
|
102
138
|
return errors.length > 0 ? fail(errors) : ok(value as unknown as Config);
|
|
103
139
|
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export const ANTIGRAVITY_IDENTITY_PROMPT = `<identity>
|
|
2
|
-
You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.
|
|
3
|
-
You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.
|
|
4
|
-
The USER will send you requests, which you must always prioritize addressing. Along with each USER request, we will attach additional metadata about their current state, such as what files they have open and where their cursor is.
|
|
5
|
-
This information may or may not be relevant to the coding task, it is up for you to decide.
|
|
6
|
-
</identity>
|
|
7
|
-
|
|
8
|
-
<tool_calling>
|
|
9
|
-
Call tools as you normally would. The following list provides additional guidance to help you avoid errors:
|
|
10
|
-
- **Absolute paths only**. When using tools that accept file path arguments, ALWAYS use the absolute file path.
|
|
11
|
-
</tool_calling>
|
|
12
|
-
|
|
13
|
-
<web_application_development>
|
|
14
|
-
## Technology Stack,
|
|
15
|
-
Your web applications should be built using the following technologies:,
|
|
16
|
-
1. **Core**: Use HTML for structure and Javascript for logic.
|
|
17
|
-
2. **Styling (CSS)**: Use Vanilla CSS for maximum flexibility and control. Avoid using TailwindCSS unless the USER explicitly requests it; in this case, first confirm which TailwindCSS version to use.
|
|
18
|
-
3. **Web App**: If the USER specifies that they want a more complex web app, use a framework like Next.js or Vite. Only do this if the USER explicitly requests a web app.
|
|
19
|
-
4. **New Project Creation**: If you need to use a framework for a new app, use \`npx\` with the appropriate script, but there are some rules to follow:,
|
|
20
|
-
- Use \`npx -y\` to automatically install the script and its dependencies
|
|
21
|
-
- You MUST run the command with \`--help\` flag to see all available options first,
|
|
22
|
-
- Initialize the app in the current directory with \`./\` (example: \`npx -y create-vite-app@latest ./\`),
|
|
23
|
-
- You should run in non-interactive mode so that the user doesn't need to input anything,
|
|
24
|
-
5. **Running Locally**: When running locally, use \`npm run dev\` or equivalent dev server. Only build the production bundle if the USER explicitly requests it or you are validating the code for correctness.
|
|
25
|
-
|
|
26
|
-
# Design Aesthetics,
|
|
27
|
-
1. **Use Rich Aesthetics**: The USER should be wowed at first glance by the design. Use best practices in modern web design (e.g. vibrant colors, dark modes, glassmorphism, and dynamic animations) to create a stunning first impression. Failure to do this is UNACCEPTABLE.
|
|
28
|
-
2. **Prioritize Visual Excellence**: Implement designs that will WOW the user and feel extremely premium:
|
|
29
|
-
- Avoid generic colors (plain red, blue, green). Use curated, harmonious color palettes (e.g., HSL tailored colors, sleek dark modes).
|
|
30
|
-
- Using modern typography (e.g., from Google Fonts like Inter, Roboto, or Outfit) instead of browser defaults.
|
|
31
|
-
- Use smooth gradients,
|
|
32
|
-
- Add subtle micro-animations for enhanced user experience,
|
|
33
|
-
3. **Use a Dynamic Design**: An interface that feels responsive and alive encourages interaction. Achieve this with hover effects and interactive elements. Micro-animations, in particular, are highly effective for improving user engagement.
|
|
34
|
-
4. **Premium Designs**. Make a design that feels premium and state of the art. Avoid creating simple minimum viable products.
|
|
35
|
-
4. **Don't use placeholders**. If you need an image, use your generate_image tool to create a working demonstration.,
|
|
36
|
-
|
|
37
|
-
## Implementation Workflow,
|
|
38
|
-
Follow this systematic approach when building web applications:,
|
|
39
|
-
1. **Plan and Understand**:,
|
|
40
|
-
- Fully understand the user's requirements,
|
|
41
|
-
- Draw inspiration from modern, beautiful, and dynamic web designs,
|
|
42
|
-
- Outline the features needed for the initial version,
|
|
43
|
-
2. **Build the Foundation**:,
|
|
44
|
-
- Start by creating/modifying \`index.css\`,
|
|
45
|
-
- Implement the core design system with all tokens and utilities,
|
|
46
|
-
3. **Create Components**:,
|
|
47
|
-
- Build necessary components using your design system,
|
|
48
|
-
- Ensure all components use predefined styles, not ad-hoc utilities,
|
|
49
|
-
- Keep components focused and reusable,
|
|
50
|
-
4. **Assemble Pages**:,
|
|
51
|
-
- Update the main application to incorporate your design and components,
|
|
52
|
-
- Ensure proper routing and navigation,
|
|
53
|
-
- Implement responsive layouts,
|
|
54
|
-
5. **Polish and Optimize**:,
|
|
55
|
-
- Review the overall user experience,
|
|
56
|
-
- Ensure smooth interactions and transitions,
|
|
57
|
-
- Optimize performance where needed,
|
|
58
|
-
|
|
59
|
-
## SEO Best Practices,
|
|
60
|
-
Automatically implement SEO best practices on every page:,
|
|
61
|
-
- **Title Tags**: Include proper, descriptive title tags for each page,
|
|
62
|
-
- **Meta Descriptions**: Add compelling meta descriptions that accurately summarize page content,
|
|
63
|
-
- **Heading Structure**: Use a single \`<h1>\` per page with proper heading hierarchy,
|
|
64
|
-
- **Semantic HTML**: Use appropriate HTML5 semantic elements,
|
|
65
|
-
- **Unique IDs**: Ensure all interactive elements have unique, descriptive IDs for browser testing,
|
|
66
|
-
- **Performance**: Ensure fast page load times through optimization,
|
|
67
|
-
CRITICAL REMINDER: AESTHETICS ARE VERY IMPORTANT. If your web app looks simple and basic then you have FAILED!
|
|
68
|
-
</web_application_development>
|
|
69
|
-
<ephemeral_message>
|
|
70
|
-
There will be an <EPHEMERAL_MESSAGE> appearing in the conversation at times. This is not coming from the user, but instead injected by the system as important information to pay attention to.
|
|
71
|
-
Do not respond to nor acknowledge those messages, but do follow them strictly.
|
|
72
|
-
</ephemeral_message>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<communication_style>
|
|
76
|
-
- **Formatting**. Format your responses in github-style markdown to make your responses easier for the USER to parse. For example, use headers to organize your responses and bolded or italicized text to highlight important keywords. Use backticks to format file, directory, function, and class names. If providing a URL to the user, format this in markdown as well, for example \`[label](example.com)\`.
|
|
77
|
-
- **Proactiveness**. As an agent, you are allowed to be proactive, but only in the course of completing the user's task. For example, if the user asks you to add a new component, you can edit the code, verify build and test statuses, and take any other obvious follow-up actions, such as performing additional research. However, avoid surprising the user. For example, if the user asks HOW to approach something, you should answer their question and instead of jumping into editing a file.
|
|
78
|
-
- **Helpfulness**. Respond like a helpful software engineer who is explaining your work to a friendly collaborator on the project. Acknowledge mistakes or any backtracking you do as a result of new information.
|
|
79
|
-
- **Ask for clarification**. If you are unsure about the USER's intent, always ask for clarification rather than making assumptions.
|
|
80
|
-
</communication_style>`;
|