Files
simstudioai--sim/apps/sim/tools/convex/list_documents.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

104 lines
3.5 KiB
TypeScript

import type {
ConvexListDocumentsParams,
ConvexListDocumentsResponse,
ConvexListSnapshotApiResponse,
} from '@/tools/convex/types'
import { convexApiUrl, convexAuthHeaders, parseConvexResponse } from '@/tools/convex/utils'
import type { ToolConfig } from '@/tools/types'
export const listDocumentsTool: ToolConfig<ConvexListDocumentsParams, ConvexListDocumentsResponse> =
{
id: 'convex_list_documents',
name: 'Convex List Documents',
description:
'List documents from a Convex table via a paginated snapshot. Pass the returned snapshot and page cursor back in to fetch the next page. Requires streaming export, available on Convex paid plans.',
version: '1.0.0',
params: {
deploymentUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Convex deployment URL (e.g., https://your-deployment.convex.cloud)',
},
deployKey: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Convex deploy key from the dashboard Settings page',
},
tableName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Table to list documents from. Omit to list documents from all tables.',
},
snapshot: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Snapshot timestamp from a previous page. Omit on the first request to start a new snapshot.',
},
pageCursor: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Page cursor from a previous page of the same snapshot. Omit on the first request.',
},
},
request: {
url: (params) => {
const query = new URLSearchParams({ format: 'json' })
if (params.tableName?.trim()) query.set('tableName', params.tableName.trim())
const snapshot = String(params.snapshot ?? '').trim()
if (snapshot) query.set('snapshot', snapshot)
const pageCursor = String(params.pageCursor ?? '').trim()
if (pageCursor) query.set('cursor', pageCursor)
return convexApiUrl(params.deploymentUrl, `/api/list_snapshot?${query.toString()}`)
},
method: 'GET',
headers: (params) => convexAuthHeaders(params.deployKey),
},
transformResponse: async (response: Response) => {
const data = (await parseConvexResponse(response)) as ConvexListSnapshotApiResponse
return {
success: true,
output: {
documents: data.values ?? [],
hasMore: data.hasMore ?? false,
snapshot:
data.snapshot !== undefined && data.snapshot !== null ? String(data.snapshot) : null,
pageCursor:
data.cursor !== undefined && data.cursor !== null ? String(data.cursor) : null,
},
}
},
outputs: {
documents: {
type: 'array',
description: 'Documents in this page of the snapshot',
items: { type: 'object' },
},
hasMore: {
type: 'boolean',
description: 'Whether more pages remain in the snapshot',
},
snapshot: {
type: 'string',
description: 'Snapshot timestamp to pass back in when fetching the next page',
optional: true,
},
pageCursor: {
type: 'string',
description: 'Page cursor to pass back in when fetching the next page',
optional: true,
},
},
}