Skip to content
Closed
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 docs/quickstart/clients.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const agent = new MastraAgent({
agent: new Agent({
name: "AG-UI Assistant",
instructions: `
You are a helpful AI assistant. Be friendly, conversational, and helpful.
You are a helpful AI assistant. Be friendly, conversational, and helpful.
Answer questions to the best of your ability and engage in natural conversation.
`,
model: openai("gpt-4o"),
Expand Down Expand Up @@ -175,7 +175,7 @@ Now let's create the interactive chat interface. Create `src/index.ts`:
```typescript
import * as readline from "readline"
import { agent } from "./agent"
import { randomUUID } from "node:crypto"
import { randomUUID } from "@ag-ui/client"

const rl = readline.createInterface({
input: process.stdin,
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/apps/client-cli-example/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as readline from "readline";
import { agent } from "./agent";
import { randomUUID } from "node:crypto";
import { randomUUID } from "@ag-ui/client";

const rl = readline.createInterface({
input: process.stdin,
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/a2a-middleware/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { A2AClient } from "@a2a-js/sdk/client";
import { AgentCard, SendMessageResponse, SendMessageSuccessResponse } from "@a2a-js/sdk";
import { Observable, Subscriber, tap } from "rxjs";
import { createSystemPrompt, sendMessageToA2AAgentTool } from "./utils";
import { randomUUID } from "crypto";
import { randomUUID } from "@ag-ui/client";

export interface A2AAgentConfig extends AgentConfig {
agentUrls: string[];
Expand Down
4 changes: 2 additions & 2 deletions typescript-sdk/integrations/langgraph/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Interrupt,
Thread,
} from "@langchain/langgraph-sdk";
import { randomUUID } from "node:crypto";
import { randomUUID } from "@ag-ui/client";
import {
LangGraphPlatformMessage,
CustomEventNames,
Expand Down Expand Up @@ -960,7 +960,7 @@ export class LangGraphAgent extends AbstractAgent {
if (!retrievedAssistant) {
console.error(`
No agent found with graph ID ${this.graphId} found..\n

These are the available agents: [${assistants.map((a) => `${a.graph_id} (ID: ${a.assistant_id})`).join(", ")}]
`);
throw new Error("No agent id found");
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/integrations/mastra/src/mastra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { AbstractAgent, EventType } from "@ag-ui/client";
import type { StorageThreadType } from "@mastra/core";
import { Agent as LocalMastraAgent } from "@mastra/core/agent";
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,5 +4,6 @@ export * from "./transform";
export * from "./run";
export * from "./legacy";
export * from "./agent";
export * from "./utils";
export * from "@ag-ui/core";
export * from "./chunks";
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_ = <T>(obj: T): T => {
if (typeof structuredClone === "function") {
return structuredClone(obj);
Expand All @@ -9,3 +11,11 @@ export const structuredClone_ = <T>(obj: T): T => {
return { ...obj } as T;
}
};

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