feat: Spotify integration (OAuth + voice tools)
Some checks failed
Deploy / deploy (push) Failing after 1m40s

This commit is contained in:
Cosmo
2026-05-01 11:02:11 +00:00
parent ae7edbe6ed
commit 9bea298687
6 changed files with 237 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import { tools as calendarTools } from './calendar'
import { tools as timerTools } from './timers'
import { tool as notes } from './notes'
import { tools as smartHomeTools } from './smart-home'
import { tools as spotifyTools } from './spotify'
const ALL_TOOLS: VoiceTool[] = [
weather,
@@ -21,6 +22,7 @@ const ALL_TOOLS: VoiceTool[] = [
...timerTools,
notes,
...smartHomeTools,
...spotifyTools,
]
export const TOOL_SCHEMAS = ALL_TOOLS.map((t) => t.schema)

59
lib/tools/spotify.ts Normal file
View File

@@ -0,0 +1,59 @@
import type { VoiceTool } from './_types'
import { tabletGet, tabletJson } from './_http'
const getNowPlaying: VoiceTool = {
schema: {
type: 'function',
function: {
name: 'get_now_playing',
description:
'Узнать что сейчас играет в Spotify: название трека, исполнитель, статус воспроизведения. ' +
'Используй для вопросов «что сейчас играет», «какая музыка», «кто поёт».',
parameters: { type: 'object', properties: {} },
},
},
async execute() {
return tabletGet('/api/voice/tools/spotify')
},
}
const controlSpotify: VoiceTool = {
schema: {
type: 'function',
function: {
name: 'control_spotify',
description:
'Управление Spotify: включить музыку (можно с поиском), поставить на паузу, следующий/предыдущий трек, громкость. ' +
'Используй для команд «включи музыку», «поставь паузу», «следующий трек», «громкость 50%», ' +
'«включи The Weeknd», «поставь джаз».',
parameters: {
type: 'object',
properties: {
action: {
type: 'string',
enum: ['play', 'pause', 'next', 'previous', 'volume'],
description: 'Действие: play, pause, next, previous, volume',
},
query: {
type: 'string',
description: 'Поисковый запрос для action=play: исполнитель, трек или жанр',
},
volume: {
type: 'number',
description: 'Громкость 0-100 для action=volume',
},
},
required: ['action'],
},
},
},
async execute(args) {
return tabletJson('POST', '/api/voice/tools/spotify', {
action: args.action,
query: args.query,
volume: args.volume,
})
},
}
export const tools: VoiceTool[] = [getNowPlaying, controlSpotify]