Skip to content

Commit 3ac8ec3

Browse files
Merge pull request #138 from cloudflare/update-deps
update deps
2 parents 17dc411 + f71b4f2 commit 3ac8ec3

File tree

6 files changed

+74
-72
lines changed

6 files changed

+74
-72
lines changed

package-lock.json

Lines changed: 51 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@
4040
"wrangler": "4.56.0"
4141
},
4242
"dependencies": {
43-
"@ai-sdk/openai": "^2.0.88",
44-
"@ai-sdk/react": "^2.0.118",
43+
"@ai-sdk/openai": "^3.0.0",
44+
"@ai-sdk/react": "^3.0.1",
4545
"@phosphor-icons/react": "^2.1.10",
4646
"@radix-ui/react-avatar": "^1.1.11",
4747
"@radix-ui/react-dropdown-menu": "^2.1.16",
4848
"@radix-ui/react-slot": "^1.2.4",
4949
"@radix-ui/react-switch": "^1.2.6",
50-
"agents": "^0.2.35",
51-
"ai": "^5.0.116",
50+
"agents": "^0.3.0",
51+
"ai": "^6.0.1",
5252
"class-variance-authority": "^0.7.1",
5353
"clsx": "^2.1.1",
5454
"marked": "^17.0.1",
5555
"react": "^19.2.3",
5656
"react-dom": "^19.2.3",
5757
"streamdown": "^1.6.10",
5858
"tailwind-merge": "^3.4.0",
59-
"workers-ai-provider": "^2.0.0"
59+
"workers-ai-provider": "^3.0.0"
6060
}
6161
}

src/app.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** biome-ignore-all lint/correctness/useUniqueElementIds: it's alright */
22
import { useEffect, useState, useRef, useCallback, use } from "react";
33
import { useAgent } from "agents/react";
4-
import { isToolUIPart } from "ai";
4+
import { isStaticToolUIPart } from "ai";
55
import { useAgentChat } from "agents/ai-react";
66
import type { UIMessage } from "@ai-sdk/react";
77
import type { tools } from "./tools";
@@ -122,7 +122,7 @@ export default function Chat() {
122122
const pendingToolCallConfirmation = agentMessages.some((m: UIMessage) =>
123123
m.parts?.some(
124124
(part) =>
125-
isToolUIPart(part) &&
125+
isStaticToolUIPart(part) &&
126126
part.state === "input-available" &&
127127
// Manual check inside the component
128128
toolsRequiringConfirmation.includes(
@@ -136,7 +136,7 @@ export default function Chat() {
136136
};
137137

138138
return (
139-
<div className="h-[100vh] w-full p-4 flex justify-center items-center bg-fixed overflow-hidden">
139+
<div className="h-screen w-full p-4 flex justify-center items-center bg-fixed overflow-hidden">
140140
<HasOpenAIKey />
141141
<div className="h-[calc(100vh-2rem)] w-full mx-auto max-w-lg flex flex-col shadow-xl rounded-md overflow-hidden relative border border-neutral-300 dark:border-neutral-800">
142142
<div className="px-4 py-3 border-b border-neutral-300 dark:border-neutral-800 flex items-center gap-3 sticky top-0 z-10">
@@ -242,7 +242,7 @@ export default function Chat() {
242242
}`}
243243
>
244244
{showAvatar && !isUser ? (
245-
<Avatar username={"AI"} className="flex-shrink-0" />
245+
<Avatar username={"AI"} className="shrink-0" />
246246
) : (
247247
!isUser && <div className="w-8" />
248248
)}
@@ -295,7 +295,10 @@ export default function Chat() {
295295
);
296296
}
297297

298-
if (isToolUIPart(part) && m.role === "assistant") {
298+
if (
299+
isStaticToolUIPart(part) &&
300+
m.role === "assistant"
301+
) {
299302
const toolCallId = part.toolCallId;
300303
const toolName = part.type.replace("tool-", "");
301304
const needsConfirmation =
@@ -361,7 +364,7 @@ export default function Chat() {
361364
? "Please respond to the tool confirmation above..."
362365
: "Send a message..."
363366
}
364-
className="flex w-full border border-neutral-200 dark:border-neutral-700 px-3 py-2 ring-offset-background placeholder:text-neutral-500 dark:placeholder:text-neutral-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300 dark:focus-visible:ring-neutral-700 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-neutral-900 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm min-h-[24px] max-h-[calc(75dvh)] overflow-hidden resize-none rounded-2xl !text-base pb-10 dark:bg-neutral-900"
367+
className="flex w-full border border-neutral-200 dark:border-neutral-700 px-3 py-2 ring-offset-background placeholder:text-neutral-500 dark:placeholder:text-neutral-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300 dark:focus-visible:ring-neutral-700 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-neutral-900 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm min-h-[24px] max-h-[calc(75dvh)] overflow-hidden resize-none rounded-2xl text-base! pb-10 dark:bg-neutral-900"
365368
value={agentInput}
366369
onChange={(e) => {
367370
handleAgentInputChange(e);

src/components/tool-invocation-card/ToolInvocationCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function ToolInvocationCard({
5151
className="w-full flex items-center gap-2 cursor-pointer"
5252
>
5353
<div
54-
className={`${needsConfirmation ? "bg-[#F48120]/10" : "bg-[#F48120]/5"} p-1.5 rounded-full flex-shrink-0`}
54+
className={`${needsConfirmation ? "bg-[#F48120]/10" : "bg-[#F48120]/5"} p-1.5 rounded-full shrink-0`}
5555
>
5656
<RobotIcon size={16} className="text-[#F48120]" />
5757
</div>
@@ -78,7 +78,7 @@ export function ToolInvocationCard({
7878
<h5 className="text-xs font-medium mb-1 text-muted-foreground">
7979
Arguments:
8080
</h5>
81-
<pre className="bg-background/80 p-2 rounded-md text-xs overflow-auto whitespace-pre-wrap break-words max-w-[450px]">
81+
<pre className="bg-background/80 p-2 rounded-md text-xs overflow-auto whitespace-pre-wrap wrap-break-word max-w-[450px]">
8282
{JSON.stringify(toolUIPart.input, null, 2)}
8383
</pre>
8484
</div>
@@ -107,7 +107,7 @@ export function ToolInvocationCard({
107107
<h5 className="text-xs font-medium mb-1 text-muted-foreground">
108108
Result:
109109
</h5>
110-
<pre className="bg-background/80 p-2 rounded-md text-xs overflow-auto whitespace-pre-wrap break-words max-w-[450px]">
110+
<pre className="bg-background/80 p-2 rounded-md text-xs overflow-auto whitespace-pre-wrap wrap-break-word max-w-[450px]">
111111
{(() => {
112112
const result = toolUIPart.output;
113113
if (isToolResultWithContent(result)) {

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ${getSchedulePrompt({ date: new Date() })}
6868
If the user asks to schedule a task, use the schedule tool to schedule the task.
6969
`,
7070

71-
messages: convertToModelMessages(processedMessages),
71+
messages: await convertToModelMessages(processedMessages),
7272
model,
7373
tools: allTools,
7474
// Type boundary: streamText expects specific tool types, but base class uses ToolSet

src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
ToolSet,
77
ToolCallOptions
88
} from "ai";
9-
import { convertToModelMessages, isToolUIPart } from "ai";
9+
import { convertToModelMessages, isStaticToolUIPart } from "ai";
1010
import { APPROVAL } from "./shared";
1111

1212
function isValidToolName<K extends PropertyKey, T extends object>(
@@ -41,8 +41,8 @@ export async function processToolCalls<Tools extends ToolSet>({
4141

4242
const processedParts = await Promise.all(
4343
parts.map(async (part) => {
44-
// Only process tool UI parts
45-
if (!isToolUIPart(part)) return part;
44+
// Only process static tool UI parts (dynamic tools handled separately)
45+
if (!isStaticToolUIPart(part)) return part;
4646

4747
const toolName = part.type.replace(
4848
"tool-",
@@ -64,7 +64,7 @@ export async function processToolCalls<Tools extends ToolSet>({
6464
const toolInstance = executions[toolName];
6565
if (toolInstance) {
6666
result = await toolInstance(part.input, {
67-
messages: convertToModelMessages(messages),
67+
messages: await convertToModelMessages(messages),
6868
toolCallId: part.toolCallId
6969
});
7070
} else {
@@ -109,7 +109,7 @@ export function cleanupMessages(messages: UIMessage[]): UIMessage[] {
109109

110110
// Filter out messages with incomplete tool calls
111111
const hasIncompleteToolCall = message.parts.some((part) => {
112-
if (!isToolUIPart(part)) return false;
112+
if (!isStaticToolUIPart(part)) return false;
113113
// Remove tool calls that are still streaming or awaiting input without results
114114
return (
115115
part.state === "input-streaming" ||

0 commit comments

Comments
 (0)