Files
simstudioai--sim/apps/sim/tools/ashby/list_archive_reasons.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

96 lines
2.5 KiB
TypeScript

import { ashbyAuthHeaders, ashbyErrorMessage } from '@/tools/ashby/utils'
import type { ToolConfig, ToolResponse } from '@/tools/types'
interface AshbyListArchiveReasonsParams {
apiKey: string
includeArchived?: boolean
}
interface AshbyArchiveReason {
id: string
text: string
reasonType: string
isArchived: boolean
}
interface AshbyListArchiveReasonsResponse extends ToolResponse {
output: {
archiveReasons: AshbyArchiveReason[]
}
}
export const listArchiveReasonsTool: ToolConfig<
AshbyListArchiveReasonsParams,
AshbyListArchiveReasonsResponse
> = {
id: 'ashby_list_archive_reasons',
name: 'Ashby List Archive Reasons',
description: 'Lists all archive reasons configured in Ashby.',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Ashby API Key',
},
includeArchived: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Whether to include archived archive reasons in the response (default false)',
},
},
request: {
url: 'https://api.ashbyhq.com/archiveReason.list',
method: 'POST',
headers: (params) => ashbyAuthHeaders(params.apiKey),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.includeArchived !== undefined) body.includeArchived = params.includeArchived
return body
},
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!data.success) {
throw new Error(ashbyErrorMessage(data, 'Failed to list archive reasons'))
}
return {
success: true,
output: {
archiveReasons: (data.results ?? []).map((r: Record<string, unknown>) => ({
id: (r.id as string) ?? '',
text: (r.text as string) ?? '',
reasonType: (r.reasonType as string) ?? '',
isArchived: (r.isArchived as boolean) ?? false,
})),
},
}
},
outputs: {
archiveReasons: {
type: 'array',
description: 'List of archive reasons',
items: {
type: 'object',
properties: {
id: { type: 'string', description: 'Archive reason UUID' },
text: { type: 'string', description: 'Archive reason text' },
reasonType: {
type: 'string',
description: 'Reason type (RejectedByCandidate, RejectedByOrg, Other)',
},
isArchived: { type: 'boolean', description: 'Whether the reason is archived' },
},
},
},
},
}