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,126 @@
|
||||
import {
|
||||
DOWNDETECTOR_API_BASE,
|
||||
type DowndetectorGetSiteCompaniesParams,
|
||||
type DowndetectorGetSiteCompaniesResponse,
|
||||
} from '@/tools/downdetector/types'
|
||||
import {
|
||||
downdetectorHeaders,
|
||||
downdetectorNextPageOutput,
|
||||
encodePathParam,
|
||||
extractDowndetectorError,
|
||||
nextPageFromResponse,
|
||||
} from '@/tools/downdetector/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
const DEFAULT_FIELDS = 'id,name,slug,url,status,country_iso,category_id'
|
||||
|
||||
interface RawSiteCompany {
|
||||
id?: number
|
||||
name?: string
|
||||
slug?: string
|
||||
url?: string
|
||||
status?: string
|
||||
country_iso?: string
|
||||
category_id?: number
|
||||
}
|
||||
|
||||
export const getSiteCompaniesTool: ToolConfig<
|
||||
DowndetectorGetSiteCompaniesParams,
|
||||
DowndetectorGetSiteCompaniesResponse
|
||||
> = {
|
||||
id: 'downdetector_get_site_companies',
|
||||
name: 'Downdetector Get Site Companies',
|
||||
description:
|
||||
'List the companies monitored on a Downdetector site, including each company’s current status. Useful for discovering the companies available on a regional status page.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
siteId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The Downdetector site id',
|
||||
},
|
||||
fields: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Comma-separated company fields to return (defaults to id, name, slug, status)',
|
||||
},
|
||||
page: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Opaque page token from a previous response (X-Page-Next) for the next page',
|
||||
},
|
||||
pageSize: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Number of results per page, between 10 and 100',
|
||||
},
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Downdetector API Bearer token',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = new URL(
|
||||
`${DOWNDETECTOR_API_BASE}/sites/${encodePathParam(params.siteId, 'Site ID')}/companies`
|
||||
)
|
||||
url.searchParams.set('fields', params.fields || DEFAULT_FIELDS)
|
||||
if (params.page) url.searchParams.set('page', params.page)
|
||||
if (params.pageSize !== undefined) url.searchParams.set('page_size', String(params.pageSize))
|
||||
return url.toString()
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => downdetectorHeaders(params.apiKey),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
if (!response.ok) {
|
||||
throw new Error(extractDowndetectorError(data, 'Failed to get site companies'))
|
||||
}
|
||||
|
||||
const rows: RawSiteCompany[] = Array.isArray(data) ? data : []
|
||||
const companies = rows.map((company) => ({
|
||||
id: company.id ?? null,
|
||||
name: company.name ?? null,
|
||||
slug: company.slug ?? null,
|
||||
url: company.url ?? null,
|
||||
status: company.status ?? null,
|
||||
countryIso: company.country_iso ?? null,
|
||||
categoryId: company.category_id ?? null,
|
||||
}))
|
||||
|
||||
return { success: true, output: { companies, nextPage: nextPageFromResponse(response) } }
|
||||
},
|
||||
|
||||
outputs: {
|
||||
companies: {
|
||||
type: 'array',
|
||||
description: 'List of companies on the site',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'number', description: 'Company id' },
|
||||
name: { type: 'string', description: 'Company name' },
|
||||
slug: { type: 'string', description: 'Company slug' },
|
||||
url: { type: 'string', description: 'Company status page URL' },
|
||||
status: {
|
||||
type: 'string',
|
||||
description: 'Cached current status (success, warning, or danger)',
|
||||
},
|
||||
countryIso: { type: 'string', description: 'ISO-2 country code' },
|
||||
categoryId: { type: 'number', description: 'Category id' },
|
||||
},
|
||||
},
|
||||
},
|
||||
nextPage: downdetectorNextPageOutput,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user