Files
simstudioai--sim/apps/sim/tools/spotify/get_episode.ts
T
wehub-resource-sync d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

97 lines
2.8 KiB
TypeScript

import type { ToolConfig, ToolResponse } from '@/tools/types'
interface SpotifyGetEpisodeParams {
accessToken: string
episodeId: string
market?: string
}
interface SpotifyGetEpisodeResponse extends ToolResponse {
output: {
id: string
name: string
description: string
duration_ms: number
release_date: string
explicit: boolean
show: { id: string; name: string; publisher: string }
image_url: string | null
external_url: string
}
}
export const spotifyGetEpisodeTool: ToolConfig<SpotifyGetEpisodeParams, SpotifyGetEpisodeResponse> =
{
id: 'spotify_get_episode',
name: 'Spotify Get Episode',
description: 'Get details for a podcast episode.',
version: '1.0.0',
oauth: {
required: true,
provider: 'spotify',
requiredScopes: ['user-read-playback-position'],
},
params: {
episodeId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The Spotify episode ID',
},
market: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'ISO 3166-1 alpha-2 country code (e.g., "US", "GB")',
},
},
request: {
url: (params) => {
let url = `https://api.spotify.com/v1/episodes/${params.episodeId}`
if (params.market) url += `?market=${params.market}`
return url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.accessToken}`,
}),
},
transformResponse: async (response): Promise<SpotifyGetEpisodeResponse> => {
const ep = await response.json()
return {
success: true,
output: {
id: ep.id,
name: ep.name,
description: ep.description || '',
duration_ms: ep.duration_ms || 0,
release_date: ep.release_date || '',
explicit: ep.explicit || false,
show: {
id: ep.show?.id || '',
name: ep.show?.name || '',
publisher: ep.show?.publisher || '',
},
image_url: ep.images?.[0]?.url || null,
external_url: ep.external_urls?.spotify || '',
},
}
},
outputs: {
id: { type: 'string', description: 'Episode ID' },
name: { type: 'string', description: 'Episode name' },
description: { type: 'string', description: 'Episode description' },
duration_ms: { type: 'number', description: 'Duration in ms' },
release_date: { type: 'string', description: 'Release date' },
explicit: { type: 'boolean', description: 'Contains explicit content' },
show: { type: 'json', description: 'Parent show info' },
image_url: { type: 'string', description: 'Cover image URL' },
external_url: { type: 'string', description: 'Spotify URL' },
},
}