Skip to content

Commit 0e27290

Browse files
committed
add styling for scheduled messages, update readme to reflect scheduling capabilities
1 parent 2a93286 commit 0e27290

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ A starter template for building AI-powered chat agents using Cloudflare's Agent
88

99
- 💬 Interactive chat interface with AI
1010
- 🛠️ Built-in tool system with human-in-the-loop confirmation
11+
- 📅 Advanced task scheduling (one-time, delayed, and recurring via cron)
1112
- 🌓 Dark/Light theme support
1213
- ⚡️ Real-time streaming responses
1314
- 🔄 State management and chat history
@@ -86,6 +87,20 @@ const getCurrentTime = tool({
8687
parameters: z.object({}),
8788
execute: async () => new Date().toISOString(),
8889
});
90+
91+
// Scheduling tool implementation
92+
const scheduleTask = tool({
93+
description:
94+
"schedule a task to be executed at a later time. 'when' can be a date, a delay in seconds, or a cron pattern.",
95+
parameters: z.object({
96+
type: z.enum(["scheduled", "delayed", "cron"]),
97+
when: z.union([z.number(), z.string()]),
98+
payload: z.string(),
99+
}),
100+
execute: async ({ type, when, payload }) => {
101+
// ... see the implementation in tools.ts
102+
},
103+
});
89104
```
90105

91106
To handle tool confirmations, add execution functions to the `executions` object:
@@ -148,12 +163,22 @@ The chat interface is built with React and can be customized in `app.tsx`:
148163
- Report generation
149164

150165
4. **Personal Productivity Assistant**
166+
151167
- Implement tools for:
152-
- Calendar management
153-
- Task tracking
168+
- Task scheduling with flexible timing options
169+
- One-time, delayed, and recurring task management
170+
- Task tracking with reminders
154171
- Email drafting
155172
- Note taking
156173

174+
5. **Scheduling Assistant**
175+
- Build tools for:
176+
- One-time event scheduling using specific dates
177+
- Delayed task execution (e.g., "remind me in 30 minutes")
178+
- Recurring tasks using cron patterns
179+
- Task payload management
180+
- Flexible scheduling patterns
181+
157182
Each use case can be implemented by:
158183

159184
1. Adding relevant tools in `tools.ts`

src/app.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,15 @@ export default function Chat() {
114114
switch (part.type) {
115115
case "text":
116116
return (
117-
<div key={i} className="message-content">
118-
{part.text}
117+
<div
118+
key={i}
119+
className={`message-content ${
120+
part.text.startsWith("scheduled message")
121+
? "scheduled-message"
122+
: ""
123+
}`}
124+
>
125+
{part.text.replace(/^scheduled message: /, "")}
119126
</div>
120127
);
121128
case "tool-invocation":

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Chat extends AIChatAgent<Env> {
7979
{
8080
id: generateId(),
8181
role: "user",
82-
content: description,
82+
content: `scheduled message: ${description}`,
8383
},
8484
]);
8585
}

src/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ body {
230230
font-weight: 450;
231231
}
232232

233+
.message-content.scheduled-message {
234+
color: var(--cf-orange);
235+
font-weight: 600;
236+
font-family: var(--font-sans);
237+
}
238+
233239
/* Tool invocation styles */
234240
.tool-invocation {
235241
margin-top: 1rem;

0 commit comments

Comments
 (0)