11import { db } from "@/lib/db" ;
22import { mainConfig } from "@/lib/config" ;
33import { eventsTable , type InsertEvent } from "@/lib/schema" ;
4+ import { getExpandedEventBySlug } from "@/lib/expanded-events" ;
45import { createLumaClient } from "@/lib/luma" ;
5- import { eq } from "drizzle-orm" ;
6+ import { desc , eq } from "drizzle-orm" ;
67import { createGateway , generateText , tool } from "ai" ;
78import { z } from "zod" ;
89
@@ -102,13 +103,29 @@ function normalizeUpdateData(
102103}
103104
104105async 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
114131async function updateEventBySlug (
@@ -135,8 +152,15 @@ async function updateEventBySlug(
135152
136153function 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