Skip to content

Commit 99d4214

Browse files
committed
Add Discord agent event list and expanded event lookup.
This adds a list_events tool with name/date/location/slug summaries and upgrades get_event_by_slug to return expanded event details including talks, speakers, and sponsors.
1 parent 7f603fb commit 99d4214

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

app/src/lib/discord/prompt-agent.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { db } from "@/lib/db";
22
import { mainConfig } from "@/lib/config";
33
import { eventsTable, type InsertEvent } from "@/lib/schema";
4+
import { getExpandedEventBySlug } from "@/lib/expanded-events";
45
import { createLumaClient } from "@/lib/luma";
5-
import { eq } from "drizzle-orm";
6+
import { desc, eq } from "drizzle-orm";
67
import { createGateway, generateText, tool } from "ai";
78
import { z } from "zod";
89

@@ -102,13 +103,29 @@ function normalizeUpdateData(
102103
}
103104

104105
async function getEventBySlug(slug: string) {
105-
const [event] = await db
106-
.select()
107-
.from(eventsTable)
108-
.where(eq(eventsTable.slug, slug))
109-
.limit(1);
106+
return getExpandedEventBySlug(slug);
107+
}
110108

111-
return event ?? null;
109+
async function listEventsSummary() {
110+
const events = await db
111+
.select({
112+
name: eventsTable.name,
113+
slug: eventsTable.slug,
114+
startDate: eventsTable.startDate,
115+
endDate: eventsTable.endDate,
116+
shortLocation: eventsTable.shortLocation,
117+
fullAddress: eventsTable.fullAddress,
118+
})
119+
.from(eventsTable)
120+
.orderBy(desc(eventsTable.startDate));
121+
122+
return events.map((event) => ({
123+
name: event.name,
124+
slug: event.slug,
125+
date: event.startDate.toISOString(),
126+
endDate: event.endDate.toISOString(),
127+
location: event.shortLocation ?? event.fullAddress ?? null,
128+
}));
112129
}
113130

114131
async function updateEventBySlug(
@@ -135,8 +152,15 @@ async function updateEventBySlug(
135152

136153
function buildTools() {
137154
return {
155+
list_events: tool({
156+
description:
157+
"List AllThingsWeb events with summary fields: name, date, location, and slug.",
158+
inputSchema: z.object({}),
159+
execute: async () => listEventsSummary(),
160+
}),
138161
get_event_by_slug: tool({
139-
description: "Fetch an AllThingsWeb event by slug.",
162+
description:
163+
"Fetch a full AllThingsWeb event by slug, including speakers, sponsors, and talks.",
140164
inputSchema: z.object({
141165
slug: z.string().min(1),
142166
}),

0 commit comments

Comments
 (0)