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

94 lines
2.7 KiB
TypeScript

import type { ToolConfig } from '@/tools/types'
import {
WORDPRESS_COM_API_BASE,
type WordPressGetUserParams,
type WordPressGetUserResponse,
} from '@/tools/wordpress/types'
export const getUserTool: ToolConfig<WordPressGetUserParams, WordPressGetUserResponse> = {
id: 'wordpress_get_user',
name: 'WordPress Get User',
description: 'Get a specific user from WordPress.com by ID',
version: '1.0.0',
oauth: {
required: true,
provider: 'wordpress',
requiredScopes: ['global'],
},
params: {
siteId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'WordPress.com site ID or domain (e.g., 12345678 or mysite.wordpress.com)',
},
userId: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'The ID of the user to retrieve',
},
},
request: {
url: (params) => `${WORDPRESS_COM_API_BASE}/${params.siteId}/users/${params.userId}`,
method: 'GET',
headers: (params) => ({
'Content-Type': 'application/json',
Authorization: `Bearer ${params.accessToken}`,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const error = await response.json().catch(() => ({}))
throw new Error(error.message || `WordPress API error: ${response.status}`)
}
const data = await response.json()
return {
success: true,
output: {
user: {
id: data.id,
username: data.username,
name: data.name,
first_name: data.first_name,
last_name: data.last_name,
email: data.email,
url: data.url,
description: data.description,
link: data.link,
slug: data.slug,
roles: data.roles || [],
avatar_urls: data.avatar_urls,
},
},
}
},
outputs: {
user: {
type: 'object',
description: 'The retrieved user',
properties: {
id: { type: 'number', description: 'User ID' },
username: { type: 'string', description: 'Username' },
name: { type: 'string', description: 'Display name' },
first_name: { type: 'string', description: 'First name' },
last_name: { type: 'string', description: 'Last name' },
email: { type: 'string', description: 'Email address' },
url: { type: 'string', description: 'User website URL' },
description: { type: 'string', description: 'User bio' },
link: { type: 'string', description: 'Author archive URL' },
slug: { type: 'string', description: 'User slug' },
roles: { type: 'array', description: 'User roles' },
avatar_urls: { type: 'object', description: 'Avatar URLs at different sizes' },
},
},
},
}