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,195 @@
|
||||
import type {
|
||||
GoogleMapsDistanceMatrixParams,
|
||||
GoogleMapsDistanceMatrixResponse,
|
||||
} from '@/tools/google_maps/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const googleMapsDistanceMatrixTool: ToolConfig<
|
||||
GoogleMapsDistanceMatrixParams,
|
||||
GoogleMapsDistanceMatrixResponse
|
||||
> = {
|
||||
id: 'google_maps_distance_matrix',
|
||||
name: 'Google Maps Distance Matrix',
|
||||
description: 'Calculate travel distance and time between multiple origins and destinations',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Google Maps API key',
|
||||
},
|
||||
origin: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Origin location (address or lat,lng)',
|
||||
},
|
||||
destinations: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Array of destination locations',
|
||||
},
|
||||
mode: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Travel mode: driving, walking, bicycling, or transit',
|
||||
},
|
||||
avoid: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Features to avoid: tolls, highways, or ferries',
|
||||
},
|
||||
units: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Unit system: metric or imperial',
|
||||
},
|
||||
language: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Language code for results (e.g., en, es, fr)',
|
||||
},
|
||||
},
|
||||
|
||||
hosting: {
|
||||
envKeyPrefix: 'GOOGLE_CLOUD_API_KEY',
|
||||
apiKeyParam: 'apiKey',
|
||||
byokProviderId: 'google_cloud',
|
||||
pricing: {
|
||||
type: 'per_request',
|
||||
cost: 0.005,
|
||||
},
|
||||
rateLimit: {
|
||||
mode: 'per_request',
|
||||
requestsPerMinute: 60,
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = new URL('https://maps.googleapis.com/maps/api/distancematrix/json')
|
||||
url.searchParams.set('origins', params.origin.trim())
|
||||
url.searchParams.set('destinations', params.destinations.join('|'))
|
||||
url.searchParams.set('key', params.apiKey.trim())
|
||||
|
||||
if (params.mode) {
|
||||
url.searchParams.set('mode', params.mode)
|
||||
}
|
||||
if (params.avoid) {
|
||||
url.searchParams.set('avoid', params.avoid)
|
||||
}
|
||||
if (params.units) {
|
||||
url.searchParams.set('units', params.units)
|
||||
}
|
||||
if (params.language) {
|
||||
url.searchParams.set('language', params.language.trim())
|
||||
}
|
||||
|
||||
return url.toString()
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
if (data.status !== 'OK') {
|
||||
throw new Error(
|
||||
`Distance matrix request failed: ${data.status} - ${data.error_message || 'Unknown error'}`
|
||||
)
|
||||
}
|
||||
|
||||
const rows = data.rows.map(
|
||||
(row: {
|
||||
elements: Array<{
|
||||
distance?: { text: string; value: number }
|
||||
duration?: { text: string; value: number }
|
||||
duration_in_traffic?: { text: string; value: number }
|
||||
status: string
|
||||
}>
|
||||
}) => ({
|
||||
elements: row.elements.map((element) => ({
|
||||
distanceText: element.distance?.text ?? 'N/A',
|
||||
distanceMeters: element.distance?.value ?? 0,
|
||||
durationText: element.duration?.text ?? 'N/A',
|
||||
durationSeconds: element.duration?.value ?? 0,
|
||||
durationInTrafficText: element.duration_in_traffic?.text ?? null,
|
||||
durationInTrafficSeconds: element.duration_in_traffic?.value ?? null,
|
||||
status: element.status,
|
||||
})),
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
originAddresses: data.origin_addresses ?? [],
|
||||
destinationAddresses: data.destination_addresses ?? [],
|
||||
rows,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
originAddresses: {
|
||||
type: 'array',
|
||||
description: 'Resolved origin addresses',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
destinationAddresses: {
|
||||
type: 'array',
|
||||
description: 'Resolved destination addresses',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
rows: {
|
||||
type: 'array',
|
||||
description: 'Distance matrix rows (one per origin)',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
elements: {
|
||||
type: 'array',
|
||||
description: 'Elements (one per destination)',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
distanceText: { type: 'string', description: 'Distance as text (e.g., "5.2 km")' },
|
||||
distanceMeters: { type: 'number', description: 'Distance in meters' },
|
||||
durationText: { type: 'string', description: 'Duration as text (e.g., "15 mins")' },
|
||||
durationSeconds: { type: 'number', description: 'Duration in seconds' },
|
||||
durationInTrafficText: {
|
||||
type: 'string',
|
||||
description: 'Duration in traffic as text',
|
||||
optional: true,
|
||||
},
|
||||
durationInTrafficSeconds: {
|
||||
type: 'number',
|
||||
description: 'Duration in traffic in seconds',
|
||||
optional: true,
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
description: 'Element status (OK, NOT_FOUND, ZERO_RESULTS)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user