@heyhuynhgiabuu/pi-oauth-antigravity 0.1.1 → 0.1.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 +9 -0
- package/README.md +1 -1
- package/dist/stream/stream.d.ts +5 -5
- package/dist/stream/stream.js +15 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.2] - 2026-09-20
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Updated the Pi dependencies to 0.86.0 and migrated the provider to normalized `TranscriptContext` prompts and tool declarations.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Gemini 3 tool schemas now use Pi's strict-prefer contract** before `VALIDATED` tool calling, preserving nullable optional arguments and rejecting unknown properties at the model boundary.
|
|
15
|
+
- **Gemini 3 tool-call replay now preserves matching sanitized IDs** in both function calls and function responses, reducing malformed or unexpected function-call failures.
|
|
16
|
+
|
|
8
17
|
## [0.1.1] - 2026-09-15
|
|
9
18
|
|
|
10
19
|
### Fixed
|
package/README.md
CHANGED
package/dist/stream/stream.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Api, type AssistantMessage, type AssistantMessageEventStream, type
|
|
1
|
+
import { type Api, type AssistantMessage, type AssistantMessageEventStream, type Model, type TranscriptContext, type Tool } from "@earendil-works/pi-ai";
|
|
2
2
|
import { StopReason } from "../types/enums.js";
|
|
3
3
|
import { ANTIGRAVITY_API, type AntigravityGenerateRequest, type AntigravityStreamOptions, type GeminiContent, type GeminiFunctionDeclaration } from "../types/types.js";
|
|
4
4
|
import { type AntigravitySessionState } from "../utils/util.js";
|
|
@@ -6,21 +6,21 @@ export { ANTIGRAVITY_API };
|
|
|
6
6
|
/** Plan quota is deterministic; everything else on a 429 is a transient throttle. */
|
|
7
7
|
export declare function isPlanQuotaError(status: number | undefined, text: string): boolean;
|
|
8
8
|
/** Exported for unit tests. */
|
|
9
|
-
export declare function convertMessages(model: Model<Api>, context:
|
|
9
|
+
export declare function convertMessages(model: Model<Api>, context: TranscriptContext, runtimeModel: string): GeminiContent[];
|
|
10
10
|
/**
|
|
11
11
|
* Gemini accepts JSON Schema through parametersJsonSchema. Claude and GPT-OSS
|
|
12
12
|
* use Cloud Code Assist's custom-tool bridge, which requires a compatible
|
|
13
13
|
* Draft 2020-12 subset in the legacy parameters field.
|
|
14
14
|
*/
|
|
15
|
-
export declare function convertTools(tools: Tool[] | undefined, useLegacyParameters?: boolean): {
|
|
15
|
+
export declare function convertTools(tools: Tool[] | undefined, useLegacyParameters?: boolean, supportsStrictMode?: boolean): {
|
|
16
16
|
functionDeclarations: GeminiFunctionDeclaration[];
|
|
17
17
|
}[] | undefined;
|
|
18
18
|
/** Exported for unit tests. */
|
|
19
|
-
export declare function buildRequest(model: Model<Api>, context:
|
|
19
|
+
export declare function buildRequest(model: Model<Api>, context: TranscriptContext, projectId: string, options: AntigravityStreamOptions, runtimeModel: string, sessionState?: AntigravitySessionState): AntigravityGenerateRequest;
|
|
20
20
|
/** Exported for unit tests. */
|
|
21
21
|
export declare function mapStopReason(reason: string | undefined): StopReason;
|
|
22
22
|
/** Exported for unit tests. */
|
|
23
23
|
export declare function friendlyAntigravityError(status: number | undefined, text: string): string;
|
|
24
24
|
/** Exported for unit tests. */
|
|
25
25
|
export declare function streamResponse(response: Response, stream: AssistantMessageEventStream, output: AssistantMessage, model?: Model<Api>, sessionState?: AntigravitySessionState): Promise<boolean>;
|
|
26
|
-
export declare function streamAntigravity(model: Model<Api>, context:
|
|
26
|
+
export declare function streamAntigravity(model: Model<Api>, context: TranscriptContext, options?: AntigravityStreamOptions): AssistantMessageEventStream;
|
package/dist/stream/stream.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { calculateCost, createAssistantMessageEventStream, } from "@earendil-works/pi-ai";
|
|
2
|
+
import { getJsonSchemaToolParameters, resolveJsonSchemaStrictSampling } from "@earendil-works/pi-ai/api/constrained-sampling";
|
|
3
|
+
import { requiresToolCallId, supportsGoogleStrictToolSampling } from "@earendil-works/pi-ai/api/google-shared";
|
|
4
|
+
import { getCurrentSystemPrompt, getCurrentTools } from "@earendil-works/pi-ai/utils/transcript";
|
|
2
5
|
import { antigravityHeaders, endpointCandidates, fetchAvailableRuntimeModel, formatRequestDiagnostics, jsonOrTextError, loadCodeAssist, parseApiKey, resolveProjectId, } from "../client/client.js";
|
|
3
6
|
import { getCurrentEndpoint, runWithDiagnostics, setLastEndpoint, setLastError, setLastLatencyMs, setLastProjectId, setLastResolvedRuntimeModel, setLastStatus, } from "../diagnostics/diagnostics.js";
|
|
4
7
|
import { AntigravityRequestType, AntigravityUserAgent, GeminiRole, GeminiToolCallingMode, StopReason, ToolChoice, } from "../types/enums.js";
|
|
@@ -63,10 +66,7 @@ function sanitizeToolCallId(id, fallbackName) {
|
|
|
63
66
|
return capped || `${fallbackName || "tool"}_${++toolCallCounter}`;
|
|
64
67
|
}
|
|
65
68
|
function toolCallIdNeeded(modelId, runtimeModel) {
|
|
66
|
-
return (modelId
|
|
67
|
-
modelId.startsWith("gpt-oss-") ||
|
|
68
|
-
runtimeModel.startsWith("claude-") ||
|
|
69
|
-
runtimeModel.startsWith("gpt-oss-"));
|
|
69
|
+
return requiresToolCallId(modelId) || requiresToolCallId(runtimeModel);
|
|
70
70
|
}
|
|
71
71
|
const base64SignaturePattern = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
72
72
|
function isValidThoughtSignature(signature) {
|
|
@@ -154,6 +154,7 @@ function appendTurn(contents, role, parts) {
|
|
|
154
154
|
export function convertMessages(model, context, runtimeModel) {
|
|
155
155
|
const contents = [];
|
|
156
156
|
const requiresSig = geminiRequiresThoughtSignature(runtimeModel);
|
|
157
|
+
const includeToolCallId = toolCallIdNeeded(model.id, runtimeModel);
|
|
157
158
|
const droppedToolCallIds = new Map();
|
|
158
159
|
for (const msg of context.messages) {
|
|
159
160
|
if (msg.role === "user") {
|
|
@@ -216,7 +217,7 @@ export function convertMessages(model, context, runtimeModel) {
|
|
|
216
217
|
functionCall: {
|
|
217
218
|
name: block.name,
|
|
218
219
|
args: block.arguments ?? {},
|
|
219
|
-
...(
|
|
220
|
+
...(includeToolCallId
|
|
220
221
|
? { id: sanitizeToolCallId(block.id || "", block.name) }
|
|
221
222
|
: {}),
|
|
222
223
|
},
|
|
@@ -235,9 +236,7 @@ export function convertMessages(model, context, runtimeModel) {
|
|
|
235
236
|
const responseText = text || (msg.isError ? "Tool failed" : "");
|
|
236
237
|
const imageParts = asImageParts(msg.content);
|
|
237
238
|
const rawId = msg.toolCallId || "";
|
|
238
|
-
const sanitizedId =
|
|
239
|
-
? sanitizeToolCallId(rawId, msg.toolName)
|
|
240
|
-
: rawId;
|
|
239
|
+
const sanitizedId = includeToolCallId ? sanitizeToolCallId(rawId, msg.toolName) : rawId;
|
|
241
240
|
const droppedArgs = requiresSig
|
|
242
241
|
? (droppedToolCallIds.get(rawId) ??
|
|
243
242
|
droppedToolCallIds.get(sanitizedId) ??
|
|
@@ -255,7 +254,7 @@ export function convertMessages(model, context, runtimeModel) {
|
|
|
255
254
|
functionResponse: {
|
|
256
255
|
name: msg.toolName,
|
|
257
256
|
response: msg.isError ? { error: responseText } : { output: responseText },
|
|
258
|
-
...(
|
|
257
|
+
...(includeToolCallId
|
|
259
258
|
? { id: sanitizeToolCallId(msg.toolCallId || "", msg.toolName) }
|
|
260
259
|
: {}),
|
|
261
260
|
},
|
|
@@ -401,13 +400,14 @@ function normalizeCustomToolSchema(schema) {
|
|
|
401
400
|
* use Cloud Code Assist's custom-tool bridge, which requires a compatible
|
|
402
401
|
* Draft 2020-12 subset in the legacy parameters field.
|
|
403
402
|
*/
|
|
404
|
-
export function convertTools(tools, useLegacyParameters = false) {
|
|
403
|
+
export function convertTools(tools, useLegacyParameters = false, supportsStrictMode = false) {
|
|
405
404
|
if (!tools?.length)
|
|
406
405
|
return undefined;
|
|
407
406
|
return [
|
|
408
407
|
{
|
|
409
408
|
functionDeclarations: tools.map((tool) => {
|
|
410
|
-
const
|
|
409
|
+
const parameters = getJsonSchemaToolParameters(tool, resolveJsonSchemaStrictSampling(tool, supportsStrictMode));
|
|
410
|
+
const dereferenced = dereferenceSchema(parameters);
|
|
411
411
|
const rootObject = ensureRootObjectSchema(dereferenced);
|
|
412
412
|
const schema = stripMetaSchema(rootObject);
|
|
413
413
|
return {
|
|
@@ -430,12 +430,13 @@ function mapToolChoiceMode(toolChoice) {
|
|
|
430
430
|
}
|
|
431
431
|
/** Exported for unit tests. */
|
|
432
432
|
export function buildRequest(model, context, projectId, options, runtimeModel, sessionState) {
|
|
433
|
+
const systemPrompt = getCurrentSystemPrompt(context.messages);
|
|
433
434
|
const request = {
|
|
434
435
|
contents: convertMessages(model, context, runtimeModel),
|
|
435
436
|
systemInstruction: {
|
|
436
437
|
role: GeminiRole.User,
|
|
437
|
-
parts:
|
|
438
|
-
? [{ text: sanitizeText(
|
|
438
|
+
parts: systemPrompt
|
|
439
|
+
? [{ text: sanitizeText(systemPrompt) }]
|
|
439
440
|
: [{ text: ANTIGRAVITY_SYSTEM_INSTRUCTION }, { text: ANTIGRAVITY_NO_PREAMBLE_INSTRUCTION }],
|
|
440
441
|
},
|
|
441
442
|
};
|
|
@@ -455,7 +456,7 @@ export function buildRequest(model, context, projectId, options, runtimeModel, s
|
|
|
455
456
|
if (Object.keys(generationConfig).length)
|
|
456
457
|
request.generationConfig = generationConfig;
|
|
457
458
|
const isClaude = model.id.startsWith("claude-") || runtimeModel.startsWith("claude-");
|
|
458
|
-
const tools = convertTools(context.
|
|
459
|
+
const tools = convertTools(getCurrentTools(context.messages), isClaude || model.id.startsWith("gpt-oss-"), supportsGoogleStrictToolSampling(model.id));
|
|
459
460
|
if (tools) {
|
|
460
461
|
request.tools = tools;
|
|
461
462
|
request.toolConfig = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyhuynhgiabuu/pi-oauth-antigravity",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Google Antigravity OAuth provider extension for Pi with Gemini 3.8, prompt cache session affinity, and trajectory chaining.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"undici": "^8.10.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@earendil-works/pi-ai": "^0.
|
|
63
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
64
|
-
"@earendil-works/pi-server": "^0.
|
|
62
|
+
"@earendil-works/pi-ai": "^0.86.0",
|
|
63
|
+
"@earendil-works/pi-coding-agent": "^0.86.0",
|
|
64
|
+
"@earendil-works/pi-server": "^0.86.0",
|
|
65
65
|
"@types/node": "^22.20.1",
|
|
66
66
|
"tsx": "^4.20.6",
|
|
67
67
|
"typescript": "^5.9.3"
|