@heyhuynhgiabuu/pi-oauth-antigravity 0.1.2 → 0.1.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/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ 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.4] - 2026-09-20
9
+
10
+ ### Fixed
11
+ - Kept Antigravity tool declarations on the plain JSON-schema compatibility path while retaining `VALIDATED` tool calling, so optional arguments are not rewritten as required by Pi's strict-prefer schema helper.
12
+
13
+ ## [0.1.3] - 2026-09-20
14
+
15
+ ### Fixed
16
+ - Avoided loading `@earendil-works/pi-ai/utils/transcript` at runtime so the provider remains loadable with Pi installations that expose transcript support differently; legacy prompt/tool contexts are adapted locally.
17
+
8
18
  ## [0.1.2] - 2026-09-20
9
19
 
10
20
  ### Changed
@@ -1,7 +1,7 @@
1
1
  import { calculateCost, createAssistantMessageEventStream, } from "@earendil-works/pi-ai";
2
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";
3
+ import { requiresToolCallId } from "@earendil-works/pi-ai/api/google-shared";
4
+ import { getCurrentSystemPrompt, getCurrentTools } from "./transcript.js";
5
5
  import { antigravityHeaders, endpointCandidates, fetchAvailableRuntimeModel, formatRequestDiagnostics, jsonOrTextError, loadCodeAssist, parseApiKey, resolveProjectId, } from "../client/client.js";
6
6
  import { getCurrentEndpoint, runWithDiagnostics, setLastEndpoint, setLastError, setLastLatencyMs, setLastProjectId, setLastResolvedRuntimeModel, setLastStatus, } from "../diagnostics/diagnostics.js";
7
7
  import { AntigravityRequestType, AntigravityUserAgent, GeminiRole, GeminiToolCallingMode, StopReason, ToolChoice, } from "../types/enums.js";
@@ -430,7 +430,7 @@ 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
+ const systemPrompt = getCurrentSystemPrompt(context);
434
434
  const request = {
435
435
  contents: convertMessages(model, context, runtimeModel),
436
436
  systemInstruction: {
@@ -456,7 +456,9 @@ export function buildRequest(model, context, projectId, options, runtimeModel, s
456
456
  if (Object.keys(generationConfig).length)
457
457
  request.generationConfig = generationConfig;
458
458
  const isClaude = model.id.startsWith("claude-") || runtimeModel.startsWith("claude-");
459
- const tools = convertTools(getCurrentTools(context.messages), isClaude || model.id.startsWith("gpt-oss-"), supportsGoogleStrictToolSampling(model.id));
459
+ const tools = convertTools(getCurrentTools(context), isClaude || model.id.startsWith("gpt-oss-"),
460
+ // Keep Antigravity on the plain-schema compatibility path with VALIDATED calls.
461
+ false);
460
462
  if (tools) {
461
463
  request.tools = tools;
462
464
  request.toolConfig = {
@@ -0,0 +1,17 @@
1
+ import type { Message, Tool } from "@earendil-works/pi-ai";
2
+ /**
3
+ * The provider receives normalized transcript messages on newer Pi releases, but
4
+ * older releases still pass the prompt and tools as top-level context fields.
5
+ * Keep this adapter local so loading the provider does not require a newer
6
+ * pi-ai subpath at runtime.
7
+ */
8
+ type TranscriptInput = {
9
+ messages: readonly Message[];
10
+ systemPrompt?: string;
11
+ tools?: readonly Tool[];
12
+ };
13
+ /** Render the current system prompt from either normalized or legacy Pi context. */
14
+ export declare function getCurrentSystemPrompt(context: TranscriptInput): string;
15
+ /** Resolve the tools available after applying transcript tool deltas. */
16
+ export declare function getCurrentTools(context: TranscriptInput): Tool[];
17
+ export {};
@@ -0,0 +1,57 @@
1
+ function isSystemMessage(message) {
2
+ return message.role === "system";
3
+ }
4
+ function contentText(content) {
5
+ return typeof content === "string" ? content : content.map((block) => block.text).join("\n");
6
+ }
7
+ function replayMessages(context) {
8
+ if (context.messages.some(isSystemMessage))
9
+ return context.messages;
10
+ const systemPrompt = context.systemPrompt ?? "";
11
+ const tools = context.tools ?? [];
12
+ if (systemPrompt.length === 0 && tools.length === 0)
13
+ return context.messages;
14
+ return [
15
+ {
16
+ role: "system",
17
+ content: systemPrompt,
18
+ ...(tools.length > 0 ? { toolsAdded: [...tools] } : {}),
19
+ timestamp: 0,
20
+ },
21
+ ...context.messages,
22
+ ];
23
+ }
24
+ /** Render the current system prompt from either normalized or legacy Pi context. */
25
+ export function getCurrentSystemPrompt(context) {
26
+ const content = [];
27
+ const sections = new Map();
28
+ for (const message of replayMessages(context)) {
29
+ if (!isSystemMessage(message))
30
+ continue;
31
+ const text = contentText(message.content);
32
+ if (text.length > 0)
33
+ content.push(text);
34
+ for (const [name, value] of Object.entries(message.sections ?? {})) {
35
+ if (value === null)
36
+ sections.delete(name);
37
+ else
38
+ sections.set(name, value);
39
+ }
40
+ }
41
+ return [content.join("\n\n"), ...sections.values()]
42
+ .filter((part) => part.length > 0)
43
+ .join("\n\n");
44
+ }
45
+ /** Resolve the tools available after applying transcript tool deltas. */
46
+ export function getCurrentTools(context) {
47
+ const tools = new Map();
48
+ for (const message of replayMessages(context)) {
49
+ if (!isSystemMessage(message))
50
+ continue;
51
+ for (const tool of message.toolsRemoved ?? [])
52
+ tools.delete(tool.name);
53
+ for (const tool of message.toolsAdded ?? [])
54
+ tools.set(tool.name, tool);
55
+ }
56
+ return [...tools.values()];
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyhuynhgiabuu/pi-oauth-antigravity",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",