chore: import upstream snapshot with attribution
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

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import { searchTool } from './search'
export const googleSearchTool = searchTool
+199
View File
@@ -0,0 +1,199 @@
import type { GoogleSearchParams, GoogleSearchResponse } from '@/tools/google/types'
import {
GOOGLE_SEARCH_INFORMATION_OUTPUT_PROPERTIES,
GOOGLE_SEARCH_RESULT_OUTPUT_PROPERTIES,
} from '@/tools/google/types'
import type { ToolConfig } from '@/tools/types'
export const searchTool: ToolConfig<GoogleSearchParams, GoogleSearchResponse> = {
id: 'google_search',
name: 'Google Search',
description: 'Search the web with the Custom Search API',
version: '1.0.0',
params: {
query: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The search query to execute',
},
searchEngineId: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Custom Search Engine ID',
},
num: {
type: 'string', // Treated as string for compatibility with tool interfaces
required: false,
visibility: 'user-only',
description: 'Number of results to return (1-10, default 10)',
},
start: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description:
'Index of the first result (1-based, for pagination; start + num must be <= 100)',
},
dateRestrict: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Restrict results by recency: d[n] days, w[n] weeks, m[n] months, y[n] years',
},
fileType: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Restrict to a file extension (e.g., pdf, doc)',
},
safe: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'SafeSearch level: "active" or "off" (default off)',
},
searchType: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Set to "image" to perform an image search',
},
siteSearch: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'A site to include or exclude from results',
},
siteSearchFilter: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Whether to include ("i") or exclude ("e") the siteSearch site',
},
lr: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Restrict to a language, e.g. "lang_en"',
},
gl: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Two-letter country code to boost geographically relevant results',
},
sort: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Sort expression, e.g. "date"',
},
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Google API key',
},
},
request: {
url: (params: GoogleSearchParams) => {
const baseUrl = 'https://www.googleapis.com/customsearch/v1'
const searchParams = new URLSearchParams()
// Add required parameters
searchParams.append('key', params.apiKey)
searchParams.append('q', params.query)
searchParams.append('cx', params.searchEngineId)
// Add optional parameters
const num = Math.trunc(Number(params.num))
if (Number.isFinite(num) && num > 0) {
searchParams.append('num', Math.min(num, 10).toString())
}
const start = Math.trunc(Number(params.start))
if (Number.isFinite(start) && start > 0) {
searchParams.append('start', start.toString())
}
if (params.dateRestrict) {
searchParams.append('dateRestrict', params.dateRestrict)
}
if (params.fileType) {
searchParams.append('fileType', params.fileType)
}
if (params.safe) {
searchParams.append('safe', params.safe)
}
if (params.searchType) {
searchParams.append('searchType', params.searchType)
}
if (params.siteSearch) {
searchParams.append('siteSearch', params.siteSearch)
if (params.siteSearchFilter) {
searchParams.append('siteSearchFilter', params.siteSearchFilter)
}
}
if (params.lr) {
searchParams.append('lr', params.lr)
}
if (params.gl) {
searchParams.append('gl', params.gl)
}
if (params.sort) {
searchParams.append('sort', params.sort)
}
return `${baseUrl}?${searchParams.toString()}`
},
method: 'GET',
headers: () => ({
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok || data.error) {
throw new Error(`Google Search failed: ${data.error?.message || response.statusText}`)
}
return {
success: true,
output: {
items: data.items || [],
searchInformation: data.searchInformation || {
totalResults: '0',
searchTime: 0,
formattedSearchTime: '0',
formattedTotalResults: '0',
},
nextPageStartIndex: data.queries?.nextPage?.[0]?.startIndex ?? null,
},
}
},
outputs: {
items: {
type: 'array',
description: 'Array of search results from Google',
items: {
type: 'object',
properties: GOOGLE_SEARCH_RESULT_OUTPUT_PROPERTIES,
},
},
searchInformation: {
type: 'object',
description: 'Information about the search query and results',
properties: GOOGLE_SEARCH_INFORMATION_OUTPUT_PROPERTIES,
},
nextPageStartIndex: {
type: 'number',
description: 'Start index for the next page of results (null if no further results)',
optional: true,
},
},
}
+137
View File
@@ -0,0 +1,137 @@
import type { OutputProperty, ToolResponse } from '@/tools/types'
/**
* Output property definitions for Google Custom Search API responses.
* @see https://developers.google.com/custom-search/v1/reference/rest/v1/Search
*/
/**
* Output definition for search result item objects.
* @see https://developers.google.com/custom-search/v1/reference/rest/v1/Search#Result
*/
export const GOOGLE_SEARCH_RESULT_OUTPUT_PROPERTIES = {
title: { type: 'string', description: 'Title of the search result' },
htmlTitle: {
type: 'string',
description: 'Title of the search result with HTML markup',
optional: true,
},
link: { type: 'string', description: 'URL of the search result' },
displayLink: { type: 'string', description: 'Display URL (abbreviated form)', optional: true },
snippet: { type: 'string', description: 'Snippet or description of the search result' },
htmlSnippet: {
type: 'string',
description: 'Snippet of the search result with HTML markup',
optional: true,
},
formattedUrl: {
type: 'string',
description: 'Display URL shown beneath the result',
optional: true,
},
mime: { type: 'string', description: 'MIME type of the result', optional: true },
fileFormat: { type: 'string', description: 'File format of the result', optional: true },
cacheId: { type: 'string', description: "ID of Google's cached version", optional: true },
pagemap: {
type: 'object',
description: 'PageMap information for the result (structured data)',
optional: true,
},
image: {
type: 'object',
description: 'Image metadata (present when searchType is image)',
optional: true,
properties: {
contextLink: { type: 'string', description: 'URL of the page hosting the image' },
height: { type: 'number', description: 'Image height in pixels' },
width: { type: 'number', description: 'Image width in pixels' },
byteSize: { type: 'number', description: 'Image file size in bytes' },
thumbnailLink: { type: 'string', description: 'Thumbnail image URL' },
thumbnailHeight: { type: 'number', description: 'Thumbnail height in pixels' },
thumbnailWidth: { type: 'number', description: 'Thumbnail width in pixels' },
},
},
} as const satisfies Record<string, OutputProperty>
/**
* Complete search result item output definition
*/
export const GOOGLE_SEARCH_RESULT_OUTPUT: OutputProperty = {
type: 'object',
description: 'A single search result from Google Custom Search',
properties: GOOGLE_SEARCH_RESULT_OUTPUT_PROPERTIES,
}
/**
* Output definition for search information metadata.
* @see https://developers.google.com/custom-search/v1/reference/rest/v1/Search#SearchInformation
*/
export const GOOGLE_SEARCH_INFORMATION_OUTPUT_PROPERTIES = {
totalResults: { type: 'string', description: 'Total number of search results available' },
searchTime: { type: 'number', description: 'Time taken to perform the search in seconds' },
formattedSearchTime: { type: 'string', description: 'Formatted search time for display' },
formattedTotalResults: {
type: 'string',
description: 'Formatted total results count for display',
},
} as const satisfies Record<string, OutputProperty>
/**
* Complete search information output definition
*/
export const GOOGLE_SEARCH_INFORMATION_OUTPUT: OutputProperty = {
type: 'object',
description: 'Information about the search query and results',
properties: GOOGLE_SEARCH_INFORMATION_OUTPUT_PROPERTIES,
}
export interface GoogleSearchParams {
query: string
apiKey: string
searchEngineId: string
num?: number | string
start?: number | string
dateRestrict?: string
fileType?: string
safe?: string
searchType?: string
siteSearch?: string
siteSearchFilter?: string
lr?: string
gl?: string
sort?: string
}
export interface GoogleSearchResponse extends ToolResponse {
output: {
items: Array<{
title: string
htmlTitle?: string
link: string
displayLink?: string
snippet: string
htmlSnippet?: string
formattedUrl?: string
mime?: string
fileFormat?: string
cacheId?: string
pagemap?: Record<string, unknown>
image?: {
contextLink?: string
height?: number
width?: number
byteSize?: number
thumbnailLink?: string
thumbnailHeight?: number
thumbnailWidth?: number
}
}>
searchInformation: {
totalResults: string
searchTime: number
formattedSearchTime: string
formattedTotalResults: string
}
nextPageStartIndex: number | null
}
}