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
127 lines
4.0 KiB
TypeScript
127 lines
4.0 KiB
TypeScript
import type {
|
|
RedditGetSubredditInfoParams,
|
|
RedditSubredditInfoResponse,
|
|
} from '@/tools/reddit/types'
|
|
import { normalizeSubreddit } from '@/tools/reddit/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const getSubredditInfoTool: ToolConfig<
|
|
RedditGetSubredditInfoParams,
|
|
RedditSubredditInfoResponse
|
|
> = {
|
|
id: 'reddit_get_subreddit_info',
|
|
name: 'Get Subreddit Info',
|
|
description: 'Get metadata and information about a subreddit',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'reddit',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'Access token for Reddit API',
|
|
},
|
|
subreddit: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'The subreddit to get info about (e.g., "technology", "programming", "news")',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params: RedditGetSubredditInfoParams) => {
|
|
const subreddit = normalizeSubreddit(params.subreddit)
|
|
return `https://oauth.reddit.com/r/${subreddit}/about?raw_json=1`
|
|
},
|
|
method: 'GET',
|
|
headers: (params: RedditGetSubredditInfoParams) => {
|
|
if (!params.accessToken) {
|
|
throw new Error('Access token is required for Reddit API')
|
|
}
|
|
|
|
return {
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
'User-Agent': 'sim-studio/1.0 (https://github.com/simstudioai/sim)',
|
|
Accept: 'application/json',
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
output: {
|
|
id: '',
|
|
name: '',
|
|
display_name: '',
|
|
title: '',
|
|
description: '',
|
|
public_description: '',
|
|
subscribers: 0,
|
|
accounts_active: 0,
|
|
created_utc: 0,
|
|
over18: false,
|
|
lang: '',
|
|
subreddit_type: '',
|
|
url: '',
|
|
icon_img: null,
|
|
banner_img: null,
|
|
},
|
|
}
|
|
}
|
|
|
|
const sub = data.data || data
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
id: sub.id ?? '',
|
|
name: sub.name ?? '',
|
|
display_name: sub.display_name ?? '',
|
|
title: sub.title ?? '',
|
|
description: sub.description ?? '',
|
|
public_description: sub.public_description ?? '',
|
|
subscribers: sub.subscribers ?? 0,
|
|
accounts_active: sub.active_user_count ?? sub.accounts_active ?? 0,
|
|
created_utc: sub.created_utc ?? 0,
|
|
over18: sub.over18 ?? false,
|
|
lang: sub.lang ?? '',
|
|
subreddit_type: sub.subreddit_type ?? '',
|
|
url: sub.url ?? '',
|
|
icon_img: sub.icon_img ?? null,
|
|
banner_img: sub.banner_img ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
id: { type: 'string', description: 'Subreddit ID' },
|
|
name: { type: 'string', description: 'Subreddit fullname (t5_xxxxx)' },
|
|
display_name: { type: 'string', description: 'Subreddit name without prefix' },
|
|
title: { type: 'string', description: 'Subreddit title' },
|
|
description: { type: 'string', description: 'Full subreddit description (markdown)' },
|
|
public_description: { type: 'string', description: 'Short public description' },
|
|
subscribers: { type: 'number', description: 'Number of subscribers' },
|
|
accounts_active: { type: 'number', description: 'Number of currently active users' },
|
|
created_utc: { type: 'number', description: 'Creation time in UTC epoch seconds' },
|
|
over18: { type: 'boolean', description: 'Whether the subreddit is NSFW' },
|
|
lang: { type: 'string', description: 'Primary language of the subreddit' },
|
|
subreddit_type: {
|
|
type: 'string',
|
|
description: 'Subreddit type: public, private, restricted, etc.',
|
|
},
|
|
url: { type: 'string', description: 'Subreddit URL path (e.g., /r/technology/)' },
|
|
icon_img: { type: 'string', description: 'Subreddit icon URL', optional: true },
|
|
banner_img: { type: 'string', description: 'Subreddit banner URL', optional: true },
|
|
},
|
|
}
|