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
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import type {
|
|
ConvexDocumentDeltasApiResponse,
|
|
ConvexDocumentDeltasParams,
|
|
ConvexDocumentDeltasResponse,
|
|
} from '@/tools/convex/types'
|
|
import { convexApiUrl, convexAuthHeaders, parseConvexResponse } from '@/tools/convex/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const documentDeltasTool: ToolConfig<
|
|
ConvexDocumentDeltasParams,
|
|
ConvexDocumentDeltasResponse
|
|
> = {
|
|
id: 'convex_document_deltas',
|
|
name: 'Convex Document Deltas',
|
|
description:
|
|
'List documents that changed after a snapshot or previous delta cursor. Deleted documents are returned with a _deleted flag. 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',
|
|
},
|
|
cursor: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Timestamp cursor to read deltas after. Use the snapshot value from List Documents or the cursor from a previous Document Deltas page.',
|
|
},
|
|
tableName: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Table to read deltas from. Omit to read deltas from all tables.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const cursor = String(params.cursor ?? '').trim()
|
|
if (!cursor) {
|
|
throw new Error(
|
|
'Cursor is required: pass the snapshot value from List Documents or the cursor from a previous Document Deltas page'
|
|
)
|
|
}
|
|
const query = new URLSearchParams({ format: 'json', cursor })
|
|
if (params.tableName?.trim()) query.set('tableName', params.tableName.trim())
|
|
return convexApiUrl(params.deploymentUrl, `/api/document_deltas?${query.toString()}`)
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => convexAuthHeaders(params.deployKey),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = (await parseConvexResponse(response)) as ConvexDocumentDeltasApiResponse
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
documents: data.values ?? [],
|
|
hasMore: data.hasMore ?? false,
|
|
cursor: data.cursor !== undefined && data.cursor !== null ? String(data.cursor) : null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
documents: {
|
|
type: 'array',
|
|
description: 'Changed documents, each including _table and _ts fields',
|
|
items: { type: 'object' },
|
|
},
|
|
hasMore: {
|
|
type: 'boolean',
|
|
description: 'Whether more delta pages remain',
|
|
},
|
|
cursor: {
|
|
type: 'string',
|
|
description: 'Cursor to pass back in when fetching the next page of deltas',
|
|
optional: true,
|
|
},
|
|
},
|
|
}
|