feat: integrate new AI tools and enhance API functionality

- Added '@nuxtjs/mdc' module to nuxt.config.ts for improved UI components.
- Configured MDC settings to disable anchor links for headings.
- Updated API proxy settings to include '/api/uses' and a general '/api/' endpoint.
- Introduced new dependencies for AI SDKs and tools in package.json.
- Created a new chat API endpoint to handle AI interactions with various tools.
- Implemented utility functions for activity tracking, resource reading, resume retrieval, statistics, status monitoring, and categorized tool usage.
- Updated social links in types/index.ts to redirect through a custom domain.
- Updated worker configuration to include AI binding for Cloudflare.
This commit is contained in:
2025-12-19 17:57:43 +01:00
parent 929899722b
commit 6e28fdd17a
16 changed files with 717 additions and 328 deletions

6
shared/utils/index.ts Normal file
View File

@@ -0,0 +1,6 @@
export * from './tools/activity'
export * from './tools/read-resources'
export * from './tools/read-resume'
export * from './tools/stats'
export * from './tools/status-page'
export * from './tools/uses-by-category'

View File

@@ -0,0 +1,12 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
import type { Activity } from '~~/types'
export type ActivityUIToolInvocation = UIToolInvocation<typeof activityTool>
export const activityTool = tool({
description: 'Real-time current activity and status of Arthur Danjou, including what he\'s currently working on',
execute: async () => {
return await $fetch<Activity>('/api/activity')
}
})

View File

@@ -0,0 +1,25 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
import { z } from 'zod'
export type resourceUIToolInvocation = UIToolInvocation<typeof resourceTool>
export const resourceTool = tool({
description: 'Read a resource from the server API',
inputSchema: z.object({
resource: z.enum([
'contact',
'education',
'experiences',
'hobbies',
'languages',
'profile',
'projects',
'skills',
'uses'
]).describe('resource name')
}),
execute: async ({ resource }) => {
return await $fetch(`/api/${resource}`)
}
})

View File

@@ -0,0 +1,15 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
import { z } from 'zod'
export type ResumesUIToolInvocation = UIToolInvocation<typeof resumesTool>
export const resumesTool = tool({
description: 'Retrieves a direct download link to Arthur Danjou\'s professional resume in the specified language. Supports both English and French versions.',
inputSchema: z.object({
lang: z.enum(['en', 'fr']).describe('The language for the resume: \'en\' for English or \'fr\' for French.')
}),
execute: async ({ lang }) => {
return `/api/resumes/${lang}`
}
})

View File

@@ -0,0 +1,12 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
import type { Stats } from '~~/types'
export type StatsUIToolInvocation = UIToolInvocation<typeof statsTool>
export const statsTool = tool({
description: 'Detailed coding statistics and analytics from WakaTime, including programming languages, time spent coding, and productivity metrics',
execute: async () => {
return await $fetch<Stats>('/api/stats')
}
})

View File

@@ -0,0 +1,11 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
export type StatusPageUIToolInvocation = UIToolInvocation<typeof statusPageTool>
export const statusPageTool = tool({
description: 'Real-time status, uptime monitoring, and incident reports for Arthur Danjou\'s homelab infrastructure, powered by UptimeKuma',
execute: async () => {
return await $fetch('/api/status-page')
}
})

View File

@@ -0,0 +1,17 @@
import type { UIToolInvocation } from 'ai'
import { tool } from 'ai'
import { z } from 'zod'
export type UsesByCategoryUIToolInvocation = UIToolInvocation<typeof usesByCategoryTool>
export const usesByCategoryTool = tool({
description: 'Retrieves a filtered list of tools, software, and hardware used by Arthur Danjou based on a specific category. Available categories: homelab, IDE, hardware, and software.',
inputSchema: z.object({
categoryName: z.enum(['homelab', 'ide', 'hardware', 'software']).describe('The category to filter by: \'homelab\', \'ide\', \'hardware\', or \'software\'.')
}),
execute: async ({ categoryName }: { categoryName: 'homelab' | 'ide' | 'hardware' | 'software' }) => {
const uses = await $fetch<{ category: string }[]>('/api/uses')
return uses.filter(use => use.category === categoryName)
}
})