Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/cloudAgent/baseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export abstract class CloudAgentBase {
}

protected generateTaskId(): string {
return `task_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
return `task_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Node.js environments, crypto is not available as a global variable (unlike Math). Using crypto.randomUUID() directly will result in a ReferenceError at runtime. To fix this, you should either use globalThis.crypto.randomUUID() (available in Node.js 19+) or import the crypto module from node:crypto at the top of the file.

Suggested change
return `task_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;
return `task_${Date.now()}_${globalThis.crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;

}

protected generateActivityId(): string {
return `act_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
return `act_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the generateTaskId method, crypto is not a global variable in Node.js. Please use globalThis.crypto or add the appropriate import to avoid a ReferenceError.

Suggested change
return `act_${Date.now()}_${crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;
return `act_${Date.now()}_${globalThis.crypto.randomUUID().replace(/-/g, "").substring(0, 9)}`;

}
Comment on lines 88 to 94

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide (Rule 9), production code changes must include corresponding tests. The current PR modifies baseAgent.ts, but the test plan only covers antigravity-discovery-bootstrap.test.ts, which does not exercise the CloudAgentBase logic. Please ensure that unit tests for the agent ID generation are added or updated.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

}
2 changes: 1 addition & 1 deletion tests/unit/antigravity-discovery-bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe("ensureAntigravityProjectAssigned", () => {

const mockFetch = async (url: string, _init?: RequestInit): Promise<Response> => {
hitUrls.push(url);
if (url.includes("daily-cloudcode-pa.googleapis.com")) {
if (new URL(url).hostname === "daily-cloudcode-pa.googleapis.com") {
// First URL fails
return new Response("not found", { status: 404 });
}
Expand Down