Skip to content

Update crypto imports to support React Native #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/langgraph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Config,
Interrupt,
} from "@langchain/langgraph-sdk";
import { randomUUID } from "node:crypto";
import { randomUUID } from "@ag-ui/client";
import { RemoveMessage } from "@langchain/core/messages";
import {
LangGraphPlatformMessage,
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/mastra/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { registerApiRoute } from "@mastra/core/server";
import type { Agent as LocalMastraAgent } from "@mastra/core/agent";
import type { Context } from "hono";
import { RuntimeContext } from "@mastra/core/runtime-context";
import { randomUUID } from "crypto";
import { randomUUID } from "@ag-ui/client";
import { Observable } from "rxjs";
import { MastraClient } from "@mastra/client-js";
type RemoteMastraAgent = ReturnType<MastraClient["getAgent"]>;
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/vercel-ai-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
ToolChoice,
ToolSet,
} from "ai";
import { randomUUID } from "crypto";
import { randomUUID } from "@ag-ui/client";
import { z } from "zod";

type ProcessedEvent =
Expand Down
1 change: 1 addition & 0 deletions typescript-sdk/packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from "./transform";
export * from "./run";
export * from "./legacy";
export * from "./agent";
export * from "./utils";
export * from "@ag-ui/core";
10 changes: 10 additions & 0 deletions typescript-sdk/packages/client/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { v4 as uuidv4 } from 'uuid';

export const structuredClone_ = (obj: any) => {
if (typeof structuredClone === "function") {
return structuredClone(obj);
Expand All @@ -9,3 +11,11 @@ export const structuredClone_ = (obj: any) => {
return { ...obj };
}
};

/**
* Generate a random UUID v4
* Cross-platform compatible (Node.js, browsers, React Native)
*/
export function randomUUID(): string {
return uuidv4();
}