diff --git a/src/auth/antigravity/constants.test.ts b/src/auth/antigravity/constants.test.ts index 573e33219..30b5d1b2e 100644 --- a/src/auth/antigravity/constants.test.ts +++ b/src/auth/antigravity/constants.test.ts @@ -7,22 +7,22 @@ import { describe("Antigravity Constants", () => { describe("ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS", () => { - it("should be 50 minutes (3,000,000ms) to match CLIProxyAPI", () => { + it("should be 60 seconds (60,000ms) to refresh before expiry", () => { // #given - const FIFTY_MINUTES_MS = 50 * 60 * 1000 // 3,000,000 + const SIXTY_SECONDS_MS = 60 * 1000 // 60,000 // #when const actual = ANTIGRAVITY_TOKEN_REFRESH_BUFFER_MS // #then - expect(actual).toBe(FIFTY_MINUTES_MS) + expect(actual).toBe(SIXTY_SECONDS_MS) }) }) describe("ANTIGRAVITY_ENDPOINT_FALLBACKS", () => { - it("should have exactly 2 endpoints (daily → prod)", () => { + it("should have exactly 3 endpoints (sandbox → daily → prod)", () => { // #given - const expectedCount = 2 + const expectedCount = 3 // #when const actual = ANTIGRAVITY_ENDPOINT_FALLBACKS @@ -31,16 +31,23 @@ describe("Antigravity Constants", () => { expect(actual).toHaveLength(expectedCount) }) - it("should have daily endpoint first", () => { + it("should have sandbox endpoint first", () => { // #then expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[0]).toBe( "https://daily-cloudcode-pa.sandbox.googleapis.com" ) }) - it("should have prod endpoint second", () => { + it("should have daily endpoint second", () => { // #then expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[1]).toBe( + "https://daily-cloudcode-pa.googleapis.com" + ) + }) + + it("should have prod endpoint third", () => { + // #then + expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[2]).toBe( "https://cloudcode-pa.googleapis.com" ) }) diff --git a/src/auth/antigravity/token.test.ts b/src/auth/antigravity/token.test.ts index 7355dc6c4..75177434f 100644 --- a/src/auth/antigravity/token.test.ts +++ b/src/auth/antigravity/token.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from "bun:test" import { isTokenExpired } from "./token" import type { AntigravityTokens } from "./types" -describe("Token Expiry with 50-minute Buffer", () => { +describe("Token Expiry with 60-second Buffer", () => { const createToken = (expiresInSeconds: number): AntigravityTokens => ({ type: "antigravity", access_token: "test-access", @@ -11,10 +11,10 @@ describe("Token Expiry with 50-minute Buffer", () => { timestamp: Date.now(), }) - it("should NOT be expired if token expires in 51 minutes", () => { + it("should NOT be expired if token expires in 2 minutes", () => { // #given - const fiftyOneMinutes = 51 * 60 // 3060 seconds - const token = createToken(fiftyOneMinutes) + const twoMinutes = 2 * 60 + const token = createToken(twoMinutes) // #when const expired = isTokenExpired(token) @@ -23,10 +23,10 @@ describe("Token Expiry with 50-minute Buffer", () => { expect(expired).toBe(false) }) - it("should be expired if token expires in 49 minutes", () => { + it("should be expired if token expires in 30 seconds", () => { // #given - const fortyNineMinutes = 49 * 60 // 2940 seconds - const token = createToken(fortyNineMinutes) + const thirtySeconds = 30 + const token = createToken(thirtySeconds) // #when const expired = isTokenExpired(token) @@ -35,10 +35,10 @@ describe("Token Expiry with 50-minute Buffer", () => { expect(expired).toBe(true) }) - it("should be expired at exactly 50 minutes (boundary)", () => { + it("should be expired at exactly 60 seconds (boundary)", () => { // #given - const fiftyMinutes = 50 * 60 // 3000 seconds - const token = createToken(fiftyMinutes) + const sixtySeconds = 60 + const token = createToken(sixtySeconds) // #when const expired = isTokenExpired(token) @@ -53,8 +53,8 @@ describe("Token Expiry with 50-minute Buffer", () => { type: "antigravity", access_token: "test-access", refresh_token: "test-refresh", - expires_in: 3600, // 1 hour originally - timestamp: Date.now() - 4000 * 1000, // 4000 seconds ago + expires_in: 3600, + timestamp: Date.now() - 4000 * 1000, } // #when @@ -66,7 +66,7 @@ describe("Token Expiry with 50-minute Buffer", () => { it("should NOT be expired if token has plenty of time", () => { // #given - const twoHours = 2 * 60 * 60 // 7200 seconds + const twoHours = 2 * 60 * 60 const token = createToken(twoHours) // #when diff --git a/src/hooks/sisyphus-orchestrator/index.ts b/src/hooks/sisyphus-orchestrator/index.ts index 7495d2818..570a67472 100644 --- a/src/hooks/sisyphus-orchestrator/index.ts +++ b/src/hooks/sisyphus-orchestrator/index.ts @@ -586,10 +586,13 @@ export function createSisyphusOrchestratorHook( } if (WRITE_EDIT_TOOLS.includes(input.tool)) { - const filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined + let filePath = input.callID ? pendingFilePaths.get(input.callID) : undefined if (input.callID) { pendingFilePaths.delete(input.callID) } + if (!filePath) { + filePath = output.metadata?.filePath as string | undefined + } if (filePath && !filePath.includes(ALLOWED_PATH_PREFIX)) { output.output = (output.output || "") + DIRECT_WORK_REMINDER log(`[${HOOK_NAME}] Direct work reminder appended`, {