Files
simstudioai--sim/apps/sim/tools/greenhouse/list_offices.ts
T
wehub-resource-sync d25d482dc2
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
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

115 lines
3.5 KiB
TypeScript

import type {
GreenhouseListOfficesParams,
GreenhouseListOfficesResponse,
GreenhouseOffice,
} from '@/tools/greenhouse/types'
import type { ToolConfig } from '@/tools/types'
export const greenhouseListOfficesTool: ToolConfig<
GreenhouseListOfficesParams,
GreenhouseListOfficesResponse
> = {
id: 'greenhouse_list_offices',
name: 'Greenhouse List Offices',
description: 'Lists all offices configured in Greenhouse',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Greenhouse Harvest API key',
},
per_page: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Number of results per page (1-500, default 100)',
},
page: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Page number for pagination',
},
},
request: {
url: (params: GreenhouseListOfficesParams) => {
const url = new URL('https://harvest.greenhouse.io/v1/offices')
if (params.per_page) url.searchParams.append('per_page', String(params.per_page))
if (params.page) url.searchParams.append('page', String(params.page))
return url.toString()
},
method: 'GET',
headers: (params: GreenhouseListOfficesParams) => ({
Authorization: `Basic ${btoa(`${params.apiKey}:`)}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response): Promise<GreenhouseListOfficesResponse> => {
if (!response.ok) {
return {
success: false,
output: { offices: [], count: 0 },
error: `Greenhouse API error: ${response.status} ${response.statusText}`,
}
}
const data = await response.json()
const offices: GreenhouseOffice[] = (Array.isArray(data) ? data : []).map(
(o: Record<string, unknown>) => ({
id: (o.id as number) ?? 0,
name: (o.name as string) ?? null,
location: {
name: ((o.location as Record<string, unknown>)?.name as string) ?? null,
},
primary_contact_user_id: (o.primary_contact_user_id as number) ?? null,
parent_id: (o.parent_id as number) ?? null,
child_ids: (o.child_ids as number[]) ?? [],
external_id: (o.external_id as string) ?? null,
})
)
return {
success: true,
output: { offices, count: offices.length },
}
},
outputs: {
offices: {
type: 'array',
description: 'List of offices',
items: {
type: 'object',
properties: {
id: { type: 'number', description: 'Office ID' },
name: { type: 'string', description: 'Office name' },
location: {
type: 'object',
description: 'Office location',
properties: {
name: { type: 'string', description: 'Location name', optional: true },
},
},
primary_contact_user_id: {
type: 'number',
description: 'Primary contact user ID',
optional: true,
},
parent_id: { type: 'number', description: 'Parent office ID', optional: true },
child_ids: {
type: 'array',
description: 'Child office IDs',
items: { type: 'number', description: 'Office ID' },
},
external_id: { type: 'string', description: 'External system ID', optional: true },
},
},
},
count: { type: 'number', description: 'Number of offices returned' },
},
}