Skip to content

Commit e82e703

Browse files
amrmelsayedmaxkorp
authored andcommitted
Replace crypto with UUID for cross platform compatibility
1 parent 9a47ff8 commit e82e703

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

typescript-sdk/integrations/vercel-ai-sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
ToolChoice,
2727
ToolSet,
2828
} from "ai";
29-
import { randomUUID } from "crypto";
29+
import { randomUUID } from "@ag-ui/client";
3030
import { z } from "zod";
3131

3232
type ProcessedEvent =

typescript-sdk/packages/client/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export * from "./transform";
44
export * from "./run";
55
export * from "./legacy";
66
export * from "./agent";
7+
export * from "./utils";
78
export * from "@ag-ui/core";
89
export * from "./chunks";

typescript-sdk/packages/client/src/utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const structuredClone_ = <T>(obj: T): T => {
1+
import { v4 as uuidv4 } from 'uuid';
2+
3+
export const structuredClone_ = (obj: any) => {
24
if (typeof structuredClone === "function") {
35
return structuredClone(obj);
46
}
@@ -9,3 +11,11 @@ export const structuredClone_ = <T>(obj: T): T => {
911
return { ...obj } as T;
1012
}
1113
};
14+
15+
/**
16+
* Generate a random UUID v4
17+
* Cross-platform compatible (Node.js, browsers, React Native)
18+
*/
19+
export function randomUUID(): string {
20+
return uuidv4();
21+
}

0 commit comments

Comments
 (0)