chore: import upstream snapshot with attribution
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
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
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type {
|
||||
WikipediaPageContentParams,
|
||||
WikipediaPageContentResponse,
|
||||
} from '@/tools/wikipedia/types'
|
||||
import { WIKIPEDIA_PAGE_CONTENT_OUTPUT_PROPERTIES } from '@/tools/wikipedia/types'
|
||||
|
||||
export const pageContentTool: ToolConfig<WikipediaPageContentParams, WikipediaPageContentResponse> =
|
||||
{
|
||||
id: 'wikipedia_content',
|
||||
name: 'Wikipedia Page Content',
|
||||
description: 'Get the full HTML content of a Wikipedia page.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
pageTitle: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Title of the Wikipedia page to get content for',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: WikipediaPageContentParams) => {
|
||||
const encodedTitle = encodeURIComponent(params.pageTitle.replace(/ /g, '_'))
|
||||
return `https://en.wikipedia.org/api/rest_v1/page/html/${encodedTitle}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'User-Agent': 'Sim/1.0 (https://sim.ai)',
|
||||
Accept:
|
||||
'text/html; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/HTML/2.1.0"',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const html = await response.text()
|
||||
|
||||
// Extract metadata from response headers
|
||||
const revision = response.headers.get('etag')?.match(/^"(\d+)/)?.[1] || '0'
|
||||
const timestamp = response.headers.get('last-modified') || new Date().toISOString()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: {
|
||||
title: '', // Will be filled by the calling code
|
||||
pageid: 0, // Not available from this endpoint
|
||||
html: html,
|
||||
revision: Number.parseInt(revision, 10),
|
||||
tid: response.headers.get('etag') || '',
|
||||
timestamp: timestamp,
|
||||
content_model: 'wikitext',
|
||||
content_format: 'text/html',
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
content: {
|
||||
type: 'object',
|
||||
description: 'Full HTML content and metadata of the Wikipedia page',
|
||||
properties: WIKIPEDIA_PAGE_CONTENT_OUTPUT_PROPERTIES,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { pageContentTool } from '@/tools/wikipedia/content'
|
||||
import { randomPageTool } from '@/tools/wikipedia/random'
|
||||
import { searchTool } from '@/tools/wikipedia/search'
|
||||
import { pageSummaryTool } from '@/tools/wikipedia/summary'
|
||||
|
||||
export const wikipediaPageSummaryTool = pageSummaryTool
|
||||
export const wikipediaSearchTool = searchTool
|
||||
export const wikipediaPageContentTool = pageContentTool
|
||||
export const wikipediaRandomPageTool = randomPageTool
|
||||
@@ -0,0 +1,53 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WikipediaRandomPageResponse } from '@/tools/wikipedia/types'
|
||||
import { WIKIPEDIA_RANDOM_PAGE_OUTPUT_PROPERTIES } from '@/tools/wikipedia/types'
|
||||
|
||||
export const randomPageTool: ToolConfig<Record<string, never>, WikipediaRandomPageResponse> = {
|
||||
id: 'wikipedia_random',
|
||||
name: 'Wikipedia Random Page',
|
||||
description: 'Get a random Wikipedia page.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {},
|
||||
|
||||
request: {
|
||||
url: () => {
|
||||
return 'https://en.wikipedia.org/api/rest_v1/page/random/summary'
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'User-Agent': 'Sim/1.0 (https://sim.ai)',
|
||||
Accept: 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
randomPage: {
|
||||
type: data.type || '',
|
||||
title: data.title || '',
|
||||
displaytitle: data.displaytitle || data.title || '',
|
||||
description: data.description,
|
||||
extract: data.extract || '',
|
||||
thumbnail: data.thumbnail,
|
||||
content_urls: data.content_urls || { desktop: { page: '' }, mobile: { page: '' } },
|
||||
lang: data.lang || '',
|
||||
timestamp: data.timestamp || '',
|
||||
pageid: data.pageid || 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
randomPage: {
|
||||
type: 'object',
|
||||
description: 'Random Wikipedia page data',
|
||||
properties: WIKIPEDIA_RANDOM_PAGE_OUTPUT_PROPERTIES,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WikipediaSearchParams, WikipediaSearchResponse } from '@/tools/wikipedia/types'
|
||||
import { WIKIPEDIA_SEARCH_RESULT_OUTPUT_PROPERTIES } from '@/tools/wikipedia/types'
|
||||
|
||||
export const searchTool: ToolConfig<WikipediaSearchParams, WikipediaSearchResponse> = {
|
||||
id: 'wikipedia_search',
|
||||
name: 'Wikipedia Search',
|
||||
description: 'Search for Wikipedia pages by title or content.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
query: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Search query to find Wikipedia pages',
|
||||
},
|
||||
searchLimit: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Maximum number of results to return (default: 10, max: 50)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: WikipediaSearchParams) => {
|
||||
const baseUrl = 'https://en.wikipedia.org/w/api.php'
|
||||
const searchParams = new URLSearchParams()
|
||||
|
||||
searchParams.append('action', 'opensearch')
|
||||
searchParams.append('search', params.query)
|
||||
searchParams.append('format', 'json')
|
||||
searchParams.append('namespace', '0')
|
||||
if (params.searchLimit) {
|
||||
searchParams.append('limit', Math.min(Number(params.searchLimit), 50).toString())
|
||||
} else {
|
||||
searchParams.append('limit', '10')
|
||||
}
|
||||
|
||||
return `${baseUrl}?${searchParams.toString()}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'User-Agent': 'Sim/1.0 (https://sim.ai)',
|
||||
Accept: 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
const [searchTerm, titles, descriptions, urls] = data
|
||||
const searchResults = titles.map((title: string, index: number) => ({
|
||||
id: index,
|
||||
key: title.replace(/ /g, '_'),
|
||||
title: title,
|
||||
excerpt: descriptions[index] || '',
|
||||
matched_title: title,
|
||||
description: descriptions[index] || '',
|
||||
thumbnail: undefined, // OpenSearch doesn't provide thumbnails
|
||||
url: urls[index] || '',
|
||||
}))
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
searchResults,
|
||||
totalHits: titles.length,
|
||||
query: searchTerm,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
searchResults: {
|
||||
type: 'array',
|
||||
description: 'Array of matching Wikipedia pages',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: WIKIPEDIA_SEARCH_RESULT_OUTPUT_PROPERTIES,
|
||||
},
|
||||
},
|
||||
totalHits: {
|
||||
type: 'number',
|
||||
description: 'Total number of search results found',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
description: 'The search query that was executed',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type {
|
||||
WikipediaPageSummaryParams,
|
||||
WikipediaPageSummaryResponse,
|
||||
} from '@/tools/wikipedia/types'
|
||||
import { WIKIPEDIA_PAGE_SUMMARY_OUTPUT_PROPERTIES } from '@/tools/wikipedia/types'
|
||||
|
||||
export const pageSummaryTool: ToolConfig<WikipediaPageSummaryParams, WikipediaPageSummaryResponse> =
|
||||
{
|
||||
id: 'wikipedia_summary',
|
||||
name: 'Wikipedia Page Summary',
|
||||
description: 'Get a summary and metadata for a specific Wikipedia page.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
pageTitle: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Title of the Wikipedia page to get summary for',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: WikipediaPageSummaryParams) => {
|
||||
const encodedTitle = encodeURIComponent(params.pageTitle.replace(/ /g, '_'))
|
||||
return `https://en.wikipedia.org/api/rest_v1/page/summary/${encodedTitle}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'User-Agent': 'Sim/1.0 (https://sim.ai)',
|
||||
Accept: 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
summary: {
|
||||
type: data.type || '',
|
||||
title: data.title || '',
|
||||
displaytitle: data.displaytitle || data.title || '',
|
||||
description: data.description,
|
||||
extract: data.extract || '',
|
||||
extract_html: data.extract_html,
|
||||
thumbnail: data.thumbnail,
|
||||
originalimage: data.originalimage,
|
||||
content_urls: data.content_urls || {
|
||||
desktop: { page: '', revisions: '', edit: '', talk: '' },
|
||||
mobile: { page: '', revisions: '', edit: '', talk: '' },
|
||||
},
|
||||
lang: data.lang || '',
|
||||
dir: data.dir || 'ltr',
|
||||
timestamp: data.timestamp || '',
|
||||
pageid: data.pageid || 0,
|
||||
wikibase_item: data.wikibase_item,
|
||||
coordinates: data.coordinates,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
summary: {
|
||||
type: 'object',
|
||||
description: 'Wikipedia page summary and metadata',
|
||||
properties: WIKIPEDIA_PAGE_SUMMARY_OUTPUT_PROPERTIES,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
// Common types for Wikipedia tools
|
||||
import type { OutputProperty, ToolResponse } from '@/tools/types'
|
||||
|
||||
/**
|
||||
* Shared output property definitions for Wikipedia API responses.
|
||||
* Based on MediaWiki REST API documentation: https://www.mediawiki.org/wiki/API:REST_API/Reference
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output definition for thumbnail image objects
|
||||
*/
|
||||
export const WIKIPEDIA_THUMBNAIL_OUTPUT_PROPERTIES = {
|
||||
source: { type: 'string', description: 'Thumbnail image URL' },
|
||||
width: { type: 'number', description: 'Thumbnail width in pixels' },
|
||||
height: { type: 'number', description: 'Thumbnail height in pixels' },
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete thumbnail output definition
|
||||
*/
|
||||
export const WIKIPEDIA_THUMBNAIL_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'Thumbnail image data',
|
||||
optional: true,
|
||||
properties: WIKIPEDIA_THUMBNAIL_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Output definition for content URL objects (desktop/mobile)
|
||||
*/
|
||||
export const WIKIPEDIA_CONTENT_URL_OUTPUT_PROPERTIES = {
|
||||
page: { type: 'string', description: 'Page URL' },
|
||||
revisions: { type: 'string', description: 'Revisions URL', optional: true },
|
||||
edit: { type: 'string', description: 'Edit URL', optional: true },
|
||||
talk: { type: 'string', description: 'Talk page URL', optional: true },
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete content URLs output definition
|
||||
*/
|
||||
export const WIKIPEDIA_CONTENT_URLS_OUTPUT_PROPERTIES = {
|
||||
desktop: {
|
||||
type: 'object',
|
||||
description: 'Desktop URLs',
|
||||
properties: WIKIPEDIA_CONTENT_URL_OUTPUT_PROPERTIES,
|
||||
},
|
||||
mobile: {
|
||||
type: 'object',
|
||||
description: 'Mobile URLs',
|
||||
properties: WIKIPEDIA_CONTENT_URL_OUTPUT_PROPERTIES,
|
||||
},
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete content URLs output definition
|
||||
*/
|
||||
export const WIKIPEDIA_CONTENT_URLS_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'URLs to access the page',
|
||||
properties: WIKIPEDIA_CONTENT_URLS_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Output definition for page summary objects
|
||||
*/
|
||||
export const WIKIPEDIA_PAGE_SUMMARY_OUTPUT_PROPERTIES = {
|
||||
type: { type: 'string', description: 'Page type (standard, disambiguation, etc.)' },
|
||||
title: { type: 'string', description: 'Page title' },
|
||||
displaytitle: { type: 'string', description: 'Display title with formatting' },
|
||||
description: { type: 'string', description: 'Short page description', optional: true },
|
||||
extract: { type: 'string', description: 'Page extract/summary text' },
|
||||
extract_html: { type: 'string', description: 'Extract in HTML format', optional: true },
|
||||
thumbnail: WIKIPEDIA_THUMBNAIL_OUTPUT,
|
||||
originalimage: {
|
||||
type: 'object',
|
||||
description: 'Original image data',
|
||||
optional: true,
|
||||
properties: WIKIPEDIA_THUMBNAIL_OUTPUT_PROPERTIES,
|
||||
},
|
||||
content_urls: WIKIPEDIA_CONTENT_URLS_OUTPUT,
|
||||
lang: { type: 'string', description: 'Page language code' },
|
||||
dir: { type: 'string', description: 'Text direction (ltr or rtl)' },
|
||||
timestamp: { type: 'string', description: 'Last modification timestamp' },
|
||||
pageid: { type: 'number', description: 'Wikipedia page ID' },
|
||||
wikibase_item: { type: 'string', description: 'Wikidata item ID', optional: true },
|
||||
coordinates: {
|
||||
type: 'object',
|
||||
description: 'Geographic coordinates',
|
||||
optional: true,
|
||||
properties: {
|
||||
lat: { type: 'number', description: 'Latitude' },
|
||||
lon: { type: 'number', description: 'Longitude' },
|
||||
},
|
||||
},
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete page summary output definition
|
||||
*/
|
||||
export const WIKIPEDIA_PAGE_SUMMARY_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'Wikipedia page summary and metadata',
|
||||
properties: WIKIPEDIA_PAGE_SUMMARY_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Output definition for search result items
|
||||
*/
|
||||
export const WIKIPEDIA_SEARCH_RESULT_OUTPUT_PROPERTIES = {
|
||||
id: { type: 'number', description: 'Result index' },
|
||||
key: { type: 'string', description: 'URL-friendly page key' },
|
||||
title: { type: 'string', description: 'Page title' },
|
||||
excerpt: { type: 'string', description: 'Search result excerpt' },
|
||||
matched_title: { type: 'string', description: 'Matched title variant', optional: true },
|
||||
description: { type: 'string', description: 'Page description', optional: true },
|
||||
thumbnail: {
|
||||
type: 'object',
|
||||
description: 'Thumbnail data',
|
||||
optional: true,
|
||||
properties: {
|
||||
mimetype: { type: 'string', description: 'Image MIME type' },
|
||||
size: { type: 'number', description: 'File size in bytes', optional: true },
|
||||
width: { type: 'number', description: 'Width in pixels' },
|
||||
height: { type: 'number', description: 'Height in pixels' },
|
||||
duration: { type: 'number', description: 'Duration for video', optional: true },
|
||||
url: { type: 'string', description: 'Thumbnail URL' },
|
||||
},
|
||||
},
|
||||
url: { type: 'string', description: 'Page URL' },
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete search result output definition
|
||||
*/
|
||||
export const WIKIPEDIA_SEARCH_RESULT_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'Wikipedia search result',
|
||||
properties: WIKIPEDIA_SEARCH_RESULT_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Output definition for page content objects
|
||||
*/
|
||||
export const WIKIPEDIA_PAGE_CONTENT_OUTPUT_PROPERTIES = {
|
||||
title: { type: 'string', description: 'Page title' },
|
||||
pageid: { type: 'number', description: 'Wikipedia page ID' },
|
||||
html: { type: 'string', description: 'Full HTML content of the page' },
|
||||
revision: { type: 'number', description: 'Page revision number' },
|
||||
tid: { type: 'string', description: 'Transaction ID (ETag)' },
|
||||
timestamp: { type: 'string', description: 'Last modified timestamp' },
|
||||
content_model: { type: 'string', description: 'Content model (wikitext)' },
|
||||
content_format: { type: 'string', description: 'Content format (text/html)' },
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete page content output definition
|
||||
*/
|
||||
export const WIKIPEDIA_PAGE_CONTENT_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'Full HTML content and metadata of the Wikipedia page',
|
||||
properties: WIKIPEDIA_PAGE_CONTENT_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
/**
|
||||
* Output definition for random page objects (subset of summary)
|
||||
*/
|
||||
export const WIKIPEDIA_RANDOM_PAGE_OUTPUT_PROPERTIES = {
|
||||
type: { type: 'string', description: 'Page type' },
|
||||
title: { type: 'string', description: 'Page title' },
|
||||
displaytitle: { type: 'string', description: 'Display title' },
|
||||
description: { type: 'string', description: 'Page description', optional: true },
|
||||
extract: { type: 'string', description: 'Page extract/summary' },
|
||||
thumbnail: WIKIPEDIA_THUMBNAIL_OUTPUT,
|
||||
content_urls: {
|
||||
type: 'object',
|
||||
description: 'URLs to access the page',
|
||||
properties: {
|
||||
desktop: {
|
||||
type: 'object',
|
||||
description: 'Desktop URL',
|
||||
properties: { page: { type: 'string', description: 'Page URL' } },
|
||||
},
|
||||
mobile: {
|
||||
type: 'object',
|
||||
description: 'Mobile URL',
|
||||
properties: { page: { type: 'string', description: 'Page URL' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
lang: { type: 'string', description: 'Language code' },
|
||||
timestamp: { type: 'string', description: 'Timestamp' },
|
||||
pageid: { type: 'number', description: 'Page ID' },
|
||||
} as const satisfies Record<string, OutputProperty>
|
||||
|
||||
/**
|
||||
* Complete random page output definition
|
||||
*/
|
||||
export const WIKIPEDIA_RANDOM_PAGE_OUTPUT: OutputProperty = {
|
||||
type: 'object',
|
||||
description: 'Random Wikipedia page data',
|
||||
properties: WIKIPEDIA_RANDOM_PAGE_OUTPUT_PROPERTIES,
|
||||
}
|
||||
|
||||
// Page Summary tool types
|
||||
export interface WikipediaPageSummaryParams {
|
||||
pageTitle: string
|
||||
}
|
||||
|
||||
interface WikipediaPageSummary {
|
||||
type: string
|
||||
title: string
|
||||
displaytitle: string
|
||||
description?: string
|
||||
extract: string
|
||||
extract_html?: string
|
||||
thumbnail?: {
|
||||
source: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
originalimage?: {
|
||||
source: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
content_urls: {
|
||||
desktop: {
|
||||
page: string
|
||||
revisions: string
|
||||
edit: string
|
||||
talk: string
|
||||
}
|
||||
mobile: {
|
||||
page: string
|
||||
revisions: string
|
||||
edit: string
|
||||
talk: string
|
||||
}
|
||||
}
|
||||
lang: string
|
||||
dir: string
|
||||
timestamp: string
|
||||
pageid: number
|
||||
wikibase_item?: string
|
||||
coordinates?: {
|
||||
lat: number
|
||||
lon: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface WikipediaPageSummaryResponse extends ToolResponse {
|
||||
output: {
|
||||
summary: WikipediaPageSummary
|
||||
}
|
||||
}
|
||||
|
||||
// Search Pages tool types
|
||||
export interface WikipediaSearchParams {
|
||||
query: string
|
||||
searchLimit?: number
|
||||
}
|
||||
|
||||
interface WikipediaSearchResult {
|
||||
id: number
|
||||
key: string
|
||||
title: string
|
||||
excerpt: string
|
||||
matched_title?: string
|
||||
description?: string
|
||||
thumbnail?: {
|
||||
mimetype: string
|
||||
size?: number
|
||||
width: number
|
||||
height: number
|
||||
duration?: number
|
||||
url: string
|
||||
}
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface WikipediaSearchResponse extends ToolResponse {
|
||||
output: {
|
||||
searchResults: WikipediaSearchResult[]
|
||||
totalHits: number
|
||||
query: string
|
||||
}
|
||||
}
|
||||
|
||||
// Get Page Content tool types
|
||||
export interface WikipediaPageContentParams {
|
||||
pageTitle: string
|
||||
}
|
||||
|
||||
interface WikipediaPageContent {
|
||||
title: string
|
||||
pageid: number
|
||||
html: string
|
||||
revision: number
|
||||
tid: string
|
||||
timestamp: string
|
||||
content_model: string
|
||||
content_format: string
|
||||
}
|
||||
|
||||
export interface WikipediaPageContentResponse extends ToolResponse {
|
||||
output: {
|
||||
content: WikipediaPageContent
|
||||
}
|
||||
}
|
||||
|
||||
// Random Page tool types
|
||||
interface WikipediaRandomPage {
|
||||
type: string
|
||||
title: string
|
||||
displaytitle: string
|
||||
description?: string
|
||||
extract: string
|
||||
thumbnail?: {
|
||||
source: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
content_urls: {
|
||||
desktop: {
|
||||
page: string
|
||||
}
|
||||
mobile: {
|
||||
page: string
|
||||
}
|
||||
}
|
||||
lang: string
|
||||
timestamp: string
|
||||
pageid: number
|
||||
}
|
||||
|
||||
export interface WikipediaRandomPageResponse extends ToolResponse {
|
||||
output: {
|
||||
randomPage: WikipediaRandomPage
|
||||
}
|
||||
}
|
||||
|
||||
export type WikipediaResponse =
|
||||
| WikipediaPageSummaryResponse
|
||||
| WikipediaSearchResponse
|
||||
| WikipediaPageContentResponse
|
||||
| WikipediaRandomPageResponse
|
||||
Reference in New Issue
Block a user