Files
simstudioai--sim/apps/sim/tools/polymarket/get_market.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

102 lines
3.4 KiB
TypeScript

import type { PolymarketMarket } from '@/tools/polymarket/types'
import { buildGammaUrl, handlePolymarketError } from '@/tools/polymarket/types'
import type { ToolConfig } from '@/tools/types'
export interface PolymarketGetMarketParams {
marketId?: string // Market ID
slug?: string // Market slug (alternative to ID)
}
export interface PolymarketGetMarketResponse {
success: boolean
output: {
market: PolymarketMarket
}
}
export const polymarketGetMarketTool: ToolConfig<
PolymarketGetMarketParams,
PolymarketGetMarketResponse
> = {
id: 'polymarket_get_market',
name: 'Get Market from Polymarket',
description: 'Retrieve details of a specific prediction market by ID or slug',
version: '1.0.0',
params: {
marketId: {
type: 'string',
required: false,
description:
'The numeric market ID (e.g., "253591"). Required if slug is not provided. Not the condition ID.',
visibility: 'user-or-llm',
},
slug: {
type: 'string',
required: false,
description:
'The market slug (e.g., "will-trump-win"). URL-friendly identifier. Required if marketId is not provided.',
visibility: 'user-or-llm',
},
},
request: {
url: (params) => {
if (params.slug) {
return buildGammaUrl(`/markets/slug/${params.slug.trim()}`)
}
return buildGammaUrl(`/markets/${params.marketId?.trim()}`)
},
method: 'GET',
headers: () => ({
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!response.ok) {
handlePolymarketError(data, response.status, 'get_market')
}
return {
success: true,
output: {
market: data,
},
}
},
outputs: {
market: {
type: 'object',
description: 'Market object with details',
properties: {
id: { type: 'string', description: 'Market ID' },
question: { type: 'string', description: 'Market question' },
conditionId: { type: 'string', description: 'Condition ID' },
slug: { type: 'string', description: 'Market slug' },
resolutionSource: { type: 'string', description: 'Resolution source' },
endDate: { type: 'string', description: 'End date' },
startDate: { type: 'string', description: 'Start date' },
image: { type: 'string', description: 'Market image URL' },
icon: { type: 'string', description: 'Market icon URL' },
description: { type: 'string', description: 'Market description' },
outcomes: { type: 'string', description: 'Outcomes JSON string' },
outcomePrices: { type: 'string', description: 'Outcome prices JSON string' },
volume: { type: 'string', description: 'Total volume' },
liquidity: { type: 'string', description: 'Total liquidity' },
active: { type: 'boolean', description: 'Whether market is active' },
closed: { type: 'boolean', description: 'Whether market is closed' },
archived: { type: 'boolean', description: 'Whether market is archived' },
volumeNum: { type: 'number', description: 'Volume as number' },
liquidityNum: { type: 'number', description: 'Liquidity as number' },
clobTokenIds: { type: 'array', description: 'CLOB token IDs' },
acceptingOrders: { type: 'boolean', description: 'Whether accepting orders' },
negRisk: { type: 'boolean', description: 'Whether negative risk' },
},
},
},
}