@chat-js/registry 0.2.0-beta.0 → 0.2.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/dist/r/ai-titles.json +17 -17
- package/dist/r/akamai-storage.json +13 -1
- package/dist/r/alibaba-storage.json +13 -1
- package/dist/r/appwrite-storage.json +8 -1
- package/dist/r/archil-storage.json +8 -1
- package/dist/r/attach-workspace-file.json +82 -0
- package/dist/r/attachment-uploads.json +26 -34
- package/dist/r/azure-storage.json +8 -1
- package/dist/r/backblaze-b2-storage.json +13 -1
- package/dist/r/base/ai-titles.json +47 -0
- package/dist/r/base/akamai-storage.json +56 -0
- package/dist/r/base/alibaba-storage.json +56 -0
- package/dist/r/base/appwrite-storage.json +57 -0
- package/dist/r/base/archil-storage.json +59 -0
- package/dist/r/base/attach-workspace-file.json +82 -0
- package/dist/r/base/attachment-uploads.json +79 -0
- package/dist/r/base/azure-storage.json +58 -0
- package/dist/r/base/backblaze-b2-storage.json +56 -0
- package/dist/r/base/bunny-storage-storage.json +49 -0
- package/dist/r/base/cloudinary-storage.json +44 -0
- package/dist/r/base/credits.json +81 -0
- package/dist/r/base/deep-research.json +138 -0
- package/dist/r/base/default-sandbox.json +35 -0
- package/dist/r/base/desktop.json +129 -0
- package/dist/r/base/digitalocean-spaces-storage.json +56 -0
- package/dist/r/base/docker-sandbox.json +35 -0
- package/dist/r/base/dropbox-storage.json +44 -0
- package/dist/r/base/exoscale-storage.json +56 -0
- package/dist/r/base/feedback.json +90 -0
- package/dist/r/base/filebase-storage.json +50 -0
- package/dist/r/base/firebase-storage-storage.json +53 -0
- package/dist/r/base/followup-suggestions.json +130 -0
- package/dist/r/base/ftp-storage.json +71 -0
- package/dist/r/base/gcs-storage.json +40 -0
- package/dist/r/base/generate-image.json +107 -0
- package/dist/r/base/generate-video.json +76 -0
- package/dist/r/base/google-drive-storage.json +48 -0
- package/dist/r/base/guest-chat.json +166 -0
- package/dist/r/base/hetzner-storage.json +56 -0
- package/dist/r/base/ibm-cos-storage.json +56 -0
- package/dist/r/base/idrive-e2-storage.json +56 -0
- package/dist/r/base/image-viewer.json +49 -0
- package/dist/r/base/just-bash-sandbox.json +32 -0
- package/dist/r/base/litellm-gateway.json +64 -0
- package/dist/r/base/mcp.json +327 -0
- package/dist/r/base/memory-storage.json +30 -0
- package/dist/r/base/minio-storage.json +56 -0
- package/dist/r/base/model-preferences.json +117 -0
- package/dist/r/base/neon-storage.json +51 -0
- package/dist/r/base/netlify-blobs-storage.json +39 -0
- package/dist/r/base/onedrive-storage.json +49 -0
- package/dist/r/base/openai-compatible-gateway.json +66 -0
- package/dist/r/base/openai-gateway.json +64 -0
- package/dist/r/base/openrouter-gateway.json +71 -0
- package/dist/r/base/oracle-cloud-storage.json +62 -0
- package/dist/r/base/ovhcloud-storage.json +56 -0
- package/dist/r/base/pocketbase-storage.json +51 -0
- package/dist/r/base/projects.json +274 -0
- package/dist/r/base/r2-storage.json +52 -0
- package/dist/r/base/registry.json +4734 -0
- package/dist/r/base/s3-storage.json +58 -0
- package/dist/r/base/scaleway-storage.json +56 -0
- package/dist/r/base/search.json +154 -0
- package/dist/r/base/sftp-storage.json +75 -0
- package/dist/r/base/sharepoint-storage.json +51 -0
- package/dist/r/base/sharing.json +138 -0
- package/dist/r/base/spreadsheet-grid.json +20 -0
- package/dist/r/base/spreadsheet-viewer.json +62 -0
- package/dist/r/base/storj-storage.json +50 -0
- package/dist/r/base/streamdown-math.json +35 -0
- package/dist/r/base/streamdown-mermaid.json +34 -0
- package/dist/r/base/supabase-storage.json +55 -0
- package/dist/r/base/tencent-storage.json +56 -0
- package/dist/r/base/tigris-storage.json +50 -0
- package/dist/r/base/uploadthing-storage.json +39 -0
- package/dist/r/base/vercel-blob-storage.json +44 -0
- package/dist/r/base/vercel-gateway.json +75 -0
- package/dist/r/base/vercel-sandbox.json +49 -0
- package/dist/r/base/video-viewer.json +42 -0
- package/dist/r/base/vultr-storage.json +56 -0
- package/dist/r/base/wasabi-storage.json +56 -0
- package/dist/r/base/webdav-storage.json +64 -0
- package/dist/r/base/yandex-storage.json +50 -0
- package/dist/r/bunny-storage-storage.json +2 -1
- package/dist/r/cloudinary-storage.json +2 -1
- package/dist/r/credits.json +29 -46
- package/dist/r/deep-research.json +56 -138
- package/dist/r/default-sandbox.json +35 -0
- package/dist/r/desktop.json +129 -0
- package/dist/r/digitalocean-spaces-storage.json +13 -1
- package/dist/r/docker-sandbox.json +35 -0
- package/dist/r/dropbox-storage.json +2 -1
- package/dist/r/eve/deep-research.json +47 -0
- package/dist/r/eve/registry.json +53 -0
- package/dist/r/exoscale-storage.json +13 -1
- package/dist/r/feedback.json +38 -53
- package/dist/r/filebase-storage.json +8 -1
- package/dist/r/firebase-storage-storage.json +2 -1
- package/dist/r/followup-suggestions.json +49 -66
- package/dist/r/ftp-storage.json +18 -1
- package/dist/r/gcs-storage.json +8 -1
- package/dist/r/generate-image.json +24 -18
- package/dist/r/generate-video.json +17 -11
- package/dist/r/google-drive-storage.json +2 -1
- package/dist/r/guest-chat.json +166 -0
- package/dist/r/hetzner-storage.json +13 -1
- package/dist/r/ibm-cos-storage.json +13 -1
- package/dist/r/idrive-e2-storage.json +13 -1
- package/dist/r/image-viewer.json +49 -0
- package/dist/r/just-bash-sandbox.json +32 -0
- package/dist/r/litellm-gateway.json +5 -8
- package/dist/r/mcp.json +143 -120
- package/dist/r/memory-storage.json +5 -3
- package/dist/r/minio-storage.json +13 -1
- package/dist/r/model-preferences.json +47 -55
- package/dist/r/neon-storage.json +8 -1
- package/dist/r/netlify-blobs-storage.json +10 -2
- package/dist/r/onedrive-storage.json +2 -1
- package/dist/r/openai-compatible-gateway.json +6 -9
- package/dist/r/openai-gateway.json +6 -9
- package/dist/r/openrouter-gateway.json +5 -9
- package/dist/r/oracle-cloud-storage.json +18 -1
- package/dist/r/ovhcloud-storage.json +13 -1
- package/dist/r/pocketbase-storage.json +2 -1
- package/dist/r/projects.json +116 -108
- package/dist/r/r2-storage.json +9 -1
- package/dist/r/radix/ai-titles.json +47 -0
- package/dist/r/radix/akamai-storage.json +56 -0
- package/dist/r/radix/alibaba-storage.json +56 -0
- package/dist/r/radix/appwrite-storage.json +57 -0
- package/dist/r/radix/archil-storage.json +59 -0
- package/dist/r/radix/attach-workspace-file.json +82 -0
- package/dist/r/radix/attachment-uploads.json +79 -0
- package/dist/r/radix/azure-storage.json +58 -0
- package/dist/r/radix/backblaze-b2-storage.json +56 -0
- package/dist/r/radix/bunny-storage-storage.json +49 -0
- package/dist/r/radix/cloudinary-storage.json +44 -0
- package/dist/r/radix/credits.json +81 -0
- package/dist/r/radix/deep-research.json +138 -0
- package/dist/r/radix/default-sandbox.json +35 -0
- package/dist/r/radix/desktop.json +129 -0
- package/dist/r/radix/digitalocean-spaces-storage.json +56 -0
- package/dist/r/radix/docker-sandbox.json +35 -0
- package/dist/r/radix/dropbox-storage.json +44 -0
- package/dist/r/radix/exoscale-storage.json +56 -0
- package/dist/r/radix/feedback.json +90 -0
- package/dist/r/radix/filebase-storage.json +50 -0
- package/dist/r/radix/firebase-storage-storage.json +53 -0
- package/dist/r/radix/followup-suggestions.json +130 -0
- package/dist/r/radix/ftp-storage.json +71 -0
- package/dist/r/radix/gcs-storage.json +40 -0
- package/dist/r/radix/generate-image.json +107 -0
- package/dist/r/radix/generate-video.json +76 -0
- package/dist/r/radix/google-drive-storage.json +48 -0
- package/dist/r/radix/guest-chat.json +166 -0
- package/dist/r/radix/hetzner-storage.json +56 -0
- package/dist/r/radix/ibm-cos-storage.json +56 -0
- package/dist/r/radix/idrive-e2-storage.json +56 -0
- package/dist/r/radix/image-viewer.json +49 -0
- package/dist/r/radix/just-bash-sandbox.json +32 -0
- package/dist/r/radix/litellm-gateway.json +64 -0
- package/dist/r/radix/mcp.json +327 -0
- package/dist/r/radix/memory-storage.json +30 -0
- package/dist/r/radix/minio-storage.json +56 -0
- package/dist/r/radix/model-preferences.json +117 -0
- package/dist/r/radix/neon-storage.json +51 -0
- package/dist/r/radix/netlify-blobs-storage.json +39 -0
- package/dist/r/radix/onedrive-storage.json +49 -0
- package/dist/r/radix/openai-compatible-gateway.json +66 -0
- package/dist/r/radix/openai-gateway.json +64 -0
- package/dist/r/radix/openrouter-gateway.json +71 -0
- package/dist/r/radix/oracle-cloud-storage.json +62 -0
- package/dist/r/radix/ovhcloud-storage.json +56 -0
- package/dist/r/radix/pocketbase-storage.json +51 -0
- package/dist/r/radix/projects.json +274 -0
- package/dist/r/radix/r2-storage.json +52 -0
- package/dist/r/radix/registry.json +4734 -0
- package/dist/r/radix/s3-storage.json +58 -0
- package/dist/r/radix/scaleway-storage.json +56 -0
- package/dist/r/radix/search.json +154 -0
- package/dist/r/radix/sftp-storage.json +75 -0
- package/dist/r/radix/sharepoint-storage.json +51 -0
- package/dist/r/radix/sharing.json +138 -0
- package/dist/r/radix/spreadsheet-grid.json +20 -0
- package/dist/r/radix/spreadsheet-viewer.json +62 -0
- package/dist/r/radix/storj-storage.json +50 -0
- package/dist/r/radix/streamdown-math.json +35 -0
- package/dist/r/radix/streamdown-mermaid.json +34 -0
- package/dist/r/radix/supabase-storage.json +55 -0
- package/dist/r/radix/tencent-storage.json +56 -0
- package/dist/r/radix/tigris-storage.json +50 -0
- package/dist/r/radix/uploadthing-storage.json +39 -0
- package/dist/r/radix/vercel-blob-storage.json +44 -0
- package/dist/r/radix/vercel-gateway.json +75 -0
- package/dist/r/radix/vercel-sandbox.json +49 -0
- package/dist/r/radix/video-viewer.json +42 -0
- package/dist/r/radix/vultr-storage.json +56 -0
- package/dist/r/radix/wasabi-storage.json +56 -0
- package/dist/r/radix/webdav-storage.json +64 -0
- package/dist/r/radix/yandex-storage.json +50 -0
- package/dist/r/registry.json +2006 -2142
- package/dist/r/s3-storage.json +15 -1
- package/dist/r/scaleway-storage.json +13 -1
- package/dist/r/search.json +80 -66
- package/dist/r/sftp-storage.json +18 -1
- package/dist/r/sharepoint-storage.json +2 -1
- package/dist/r/sharing.json +65 -64
- package/dist/r/spreadsheet-grid.json +20 -0
- package/dist/r/spreadsheet-viewer.json +62 -0
- package/dist/r/storj-storage.json +8 -1
- package/dist/r/streamdown-math.json +35 -0
- package/dist/r/streamdown-mermaid.json +34 -0
- package/dist/r/supabase-storage.json +8 -1
- package/dist/r/tencent-storage.json +13 -1
- package/dist/r/tigris-storage.json +8 -1
- package/dist/r/uploadthing-storage.json +2 -1
- package/dist/r/vercel-blob-storage.json +3 -1
- package/dist/r/vercel-gateway.json +7 -9
- package/dist/r/vercel-sandbox.json +8 -26
- package/dist/r/video-viewer.json +42 -0
- package/dist/r/vultr-storage.json +13 -1
- package/dist/r/wasabi-storage.json +13 -1
- package/dist/r/webdav-storage.json +13 -1
- package/dist/r/yandex-storage.json +8 -1
- package/package.json +20 -38
- package/dist/r/code-documents.json +0 -96
- package/dist/r/code-execution-runtime.json +0 -25
- package/dist/r/code-execution-ui.json +0 -31
- package/dist/r/code-execution.json +0 -69
- package/dist/r/daytona-sandbox.json +0 -55
- package/dist/r/delete-document.json +0 -58
- package/dist/r/firecrawl-search.json +0 -72
- package/dist/r/get-weather.json +0 -52
- package/dist/r/langfuse.json +0 -63
- package/dist/r/read-document.json +0 -34
- package/dist/r/retrieve-url.json +0 -67
- package/dist/r/saved-code-execution.json +0 -81
- package/dist/r/sheet-documents.json +0 -93
- package/dist/r/tavily-search.json +0 -72
- package/dist/r/text-documents.json +0 -116
- package/dist/r/vercel-analytics.json +0 -46
- package/dist/r/vercel-speed-insights.json +0 -46
- package/dist/r/word-count.json +0 -51
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-blob-storage",
|
|
4
|
+
"title": "Vercel Blob",
|
|
5
|
+
"description": "Vercel Blob. Prefers Vercel OIDC (VERCEL_OIDC_TOKEN + BLOB_STORE_ID, auto-rotating) and falls back to BLOB_READ_WRITE_TOKEN; pass token, oidcToken, or storeId manually for local dev or other hosts.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@vercel/blob@^2.4.0"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/storage/vercel-blob/storage-provider.ts",
|
|
13
|
+
"content": "import type { VercelBlobAdapterOptions } from \"files-sdk/vercel-blob\";\nimport { vercelBlob } from \"files-sdk/vercel-blob\";\n\nconst privateDownloadExpirySeconds = 300;\n\nexport const createStorageAdapter = (\n options: Readonly<VercelBlobAdapterOptions> = {}\n): ReturnType<typeof vercelBlob> =>\n vercelBlob({\n ...options,\n access: \"private\",\n defaultUrlExpiresIn: privateDownloadExpirySeconds,\n });\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"icon": "setup/vercel",
|
|
20
|
+
"chatjs": {
|
|
21
|
+
"configKeys": [],
|
|
22
|
+
"configFields": [],
|
|
23
|
+
"contractVersion": 1,
|
|
24
|
+
"envRequirements": [
|
|
25
|
+
{
|
|
26
|
+
"description": "Vercel Blob credentials",
|
|
27
|
+
"options": [
|
|
28
|
+
[
|
|
29
|
+
"BLOB_READ_WRITE_TOKEN"
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
"VERCEL_OIDC_TOKEN",
|
|
33
|
+
"BLOB_STORE_ID"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"id": "vercel-blob",
|
|
39
|
+
"kind": "storage",
|
|
40
|
+
"optionalEnv": []
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"type": "registry:item"
|
|
44
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-gateway",
|
|
4
|
+
"title": "Vercel AI Gateway",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@ai-sdk/gateway@4.0.145",
|
|
7
|
+
"@vercel/oidc@3.2.0",
|
|
8
|
+
"zod@4.5.4"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/gateways/vercel/gateway.ts",
|
|
13
|
+
"content": "import type {\n Experimental_VideoModelV4,\n LanguageModelV4,\n} from \"@ai-sdk/provider\";\nimport {\n aiGatewayModelSchema,\n isAiGatewayModelType,\n} from \"@/chatjs/core/gateway/models\";\nimport type { AiGatewayModel } from \"@/chatjs/core/gateway/models\";\nimport type { GatewayProvider } from \"@/chatjs/core/gateway/gateway-provider\";\nimport { GatewayRuntime } from \"@/chatjs/core/gateway/runtime\";\nimport type { ImageModel } from \"ai\";\n\nimport { createGateway } from \"@ai-sdk/gateway\";\nimport type { gateway } from \"@ai-sdk/gateway\";\nimport { getVercelOidcToken } from \"@vercel/oidc\";\nimport { z } from \"zod\";\n\nconst MODEL_DISCOVERY_TIMEOUT_MS = 10_000;\nconst MODEL_ID_PARAMETER_INDEX = 0;\ntype VercelImageModelId = Parameters<\n (typeof gateway)[\"imageModel\"]\n>[typeof MODEL_ID_PARAMETER_INDEX];\ntype VercelVideoModelId = Parameters<\n (typeof gateway)[\"videoModel\"]\n>[typeof MODEL_ID_PARAMETER_INDEX];\n\nconst EMPTY_MODEL_TYPE_COUNT = 0;\nconst modelDiscriminatorSchema = z.object({ type: z.string() });\nconst modelsEnvelopeSchema = z.object({\n data: z.array(z.unknown()),\n object: z.literal(\"list\"),\n});\nconst modelAvailability = z.object({\n model_eligibility: z\n .object({\n status: z.string(),\n category: z.string().optional(),\n })\n .optional(),\n});\n\nclass VercelGateway\n extends GatewayRuntime\n implements GatewayProvider<\"vercel\">\n{\n public readonly type = \"vercel\" as const;\n\n public createLanguageModel(\n modelId: Parameters<\n (typeof gateway)[\"languageModel\"]\n >[typeof MODEL_ID_PARAMETER_INDEX]\n ): LanguageModelV4 {\n return this.getProvider()(modelId);\n }\n\n public createImageModel(modelId: VercelImageModelId): ImageModel {\n return this.getProvider().imageModel(modelId);\n }\n\n public createVideoModel(\n modelId: VercelVideoModelId\n ): Experimental_VideoModelV4 {\n return this.getProvider().videoModel(modelId);\n }\n\n private provider?: ReturnType<typeof createGateway>;\n\n private getProvider(): ReturnType<typeof createGateway> {\n this.provider ??= createGateway({ apiKey: this.env.AI_GATEWAY_API_KEY });\n return this.provider;\n }\n\n private async getApiKey(): Promise<string | null> {\n const apiKey = this.env.AI_GATEWAY_API_KEY;\n\n if (typeof apiKey === \"string\" && apiKey !== \"\") {\n return apiKey;\n }\n const oidcToken = this.env.VERCEL_OIDC_TOKEN;\n if (typeof oidcToken === \"string\" && oidcToken !== \"\") {\n return oidcToken;\n }\n return await getVercelOidcToken().catch(() => null);\n }\n\n public async fetchModels(): Promise<AiGatewayModel[]> {\n const apiKey = await this.getApiKey();\n const catalogUrl = \"https://ai-gateway.vercel.sh/v1/models\";\n const url =\n apiKey === null ? catalogUrl : `${catalogUrl}?include_availability`;\n this.log.debug({ url }, \"Fetching models from Vercel AI Gateway\");\n\n const response = await this.fetch(url, {\n headers:\n apiKey === null ? undefined : { Authorization: `Bearer ${apiKey}` },\n signal: AbortSignal.timeout(MODEL_DISCOVERY_TIMEOUT_MS),\n });\n\n if (!response.ok) {\n this.log.error(\n { status: response.status, statusText: response.statusText, url },\n \"Vercel AI Gateway returned non-OK response\"\n );\n throw new Error(\n `Failed to fetch models: ${response.status} ${response.statusText}`\n );\n }\n\n const bodyRaw: unknown = await response.json();\n const body = modelsEnvelopeSchema.parse(bodyRaw);\n const unsupportedTypes = new Set<string>();\n const models: AiGatewayModel[] = [];\n\n for (const candidate of body.data) {\n const { type } = modelDiscriminatorSchema.parse(candidate);\n if (isAiGatewayModelType(type)) {\n const availability = modelAvailability.safeParse(candidate);\n const eligibility = availability.data?.model_eligibility;\n if (\n eligibility?.status === \"ineligible\" &&\n (eligibility.category === \"policy\" ||\n eligibility.category === \"configuration\")\n ) {\n continue;\n }\n models.push(aiGatewayModelSchema.parse(candidate));\n } else {\n unsupportedTypes.add(type);\n }\n }\n\n if (unsupportedTypes.size > EMPTY_MODEL_TYPE_COUNT) {\n this.log.warn(\n {\n modelCount: body.data.length,\n skippedModelCount: body.data.length - models.length,\n unsupportedTypes: [...unsupportedTypes],\n },\n \"Skipping models with unsupported types from Vercel AI Gateway\"\n );\n }\n\n this.log.info(\n { modelCount: models.length },\n \"Successfully fetched models from Vercel AI Gateway\"\n );\n return models;\n }\n}\nexport { VercelGateway as Gateway, VercelGateway };\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/chatjs/providers/gateway.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"icon": "setup/vercel",
|
|
20
|
+
"chatjs": {
|
|
21
|
+
"capabilities": {
|
|
22
|
+
"image": true,
|
|
23
|
+
"video": true
|
|
24
|
+
},
|
|
25
|
+
"contractVersion": 1,
|
|
26
|
+
"defaults": {
|
|
27
|
+
"curatedDefaults": [
|
|
28
|
+
"openai/gpt-5-nano",
|
|
29
|
+
"openai/gpt-5-mini",
|
|
30
|
+
"openai/gpt-5.2",
|
|
31
|
+
"google/gemini-2.5-flash-lite",
|
|
32
|
+
"google/gemini-3-flash",
|
|
33
|
+
"google/gemini-3.1-pro-preview",
|
|
34
|
+
"anthropic/claude-sonnet-4.5",
|
|
35
|
+
"anthropic/claude-opus-4.5"
|
|
36
|
+
],
|
|
37
|
+
"disabledModels": [],
|
|
38
|
+
"providerOrder": [
|
|
39
|
+
"openai",
|
|
40
|
+
"google",
|
|
41
|
+
"anthropic"
|
|
42
|
+
],
|
|
43
|
+
"roles": {
|
|
44
|
+
"fast": "google/gemini-2.5-flash-lite",
|
|
45
|
+
"balanced": "openai/gpt-5-mini",
|
|
46
|
+
"smart": "google/gemini-3-flash",
|
|
47
|
+
"image": "google/gemini-3-pro-image",
|
|
48
|
+
"video": "xai/grok-imagine-video"
|
|
49
|
+
},
|
|
50
|
+
"workflows": {
|
|
51
|
+
"chat": "openai/gpt-5-mini",
|
|
52
|
+
"chatImageCompatible": "openai/gpt-4o-mini",
|
|
53
|
+
"pdf": "openai/gpt-5-mini",
|
|
54
|
+
"title": "openai/gpt-5-nano"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"envRequirements": [
|
|
58
|
+
{
|
|
59
|
+
"options": [
|
|
60
|
+
[
|
|
61
|
+
"AI_GATEWAY_API_KEY"
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"VERCEL_OIDC_TOKEN"
|
|
65
|
+
]
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"id": "vercel",
|
|
70
|
+
"kind": "gateway",
|
|
71
|
+
"optionalEnv": []
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"type": "registry:item"
|
|
75
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-sandbox",
|
|
4
|
+
"title": "Vercel Sandbox",
|
|
5
|
+
"description": "Hosted sandbox with native Python and Node processes.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "src/sandboxes/vercel/sandbox.ts",
|
|
12
|
+
"content": "import { defineSandbox } from \"eve/sandbox\";\nimport { VercelSandbox } from \"eve/sandbox/vercel\";\n\nexport const environment = VercelSandbox.environment();\nexport default defineSandbox(async () => await environment.open());\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/agent/sandbox.ts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"meta": {
|
|
18
|
+
"chatjs": {
|
|
19
|
+
"contractVersion": 1,
|
|
20
|
+
"kind": "sandbox",
|
|
21
|
+
"id": "vercel",
|
|
22
|
+
"capabilities": {
|
|
23
|
+
"persistent": true,
|
|
24
|
+
"runtimes": [
|
|
25
|
+
"python",
|
|
26
|
+
"javascript"
|
|
27
|
+
],
|
|
28
|
+
"cleanup": "eve-session",
|
|
29
|
+
"cancellation": "eve"
|
|
30
|
+
},
|
|
31
|
+
"envRequirements": [
|
|
32
|
+
{
|
|
33
|
+
"options": [
|
|
34
|
+
[
|
|
35
|
+
"VERCEL_OIDC_TOKEN"
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
"VERCEL_TEAM_ID",
|
|
39
|
+
"VERCEL_PROJECT_ID",
|
|
40
|
+
"VERCEL_TOKEN"
|
|
41
|
+
]
|
|
42
|
+
],
|
|
43
|
+
"runtimeAuth": "vercel-oidc"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"type": "registry:item"
|
|
49
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "video-viewer",
|
|
4
|
+
"title": "Video viewer",
|
|
5
|
+
"description": "Open video artifacts in a larger player. Optional for video generation.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"lucide-react@0.553.0"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "src/plugins/video-viewer/src/chat-ui.ts",
|
|
12
|
+
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { ArtifactViewerActions } from \"@/components/artifact-actions\";\nimport { VideoViewerAction } from \"./viewer-action\";\n\nexport const chatUi = definePlugin({\n id: \"video-viewer\",\n slots: [slot(ArtifactViewerActions, VideoViewerAction)],\n});\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/chatjs/plugins/video-viewer/chat-ui.ts"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/plugins/video-viewer/src/viewer-action.tsx",
|
|
18
|
+
"content": "\"use client\";\n\nimport { ExpandIcon } from \"lucide-react\";\nimport { useState } from \"react\";\nimport type { ArtifactReference } from \"@/components/artifact-actions\";\nimport { ArtifactDownloadAction } from \"@/components/artifact-download-action\";\nimport { VideoPlayer } from \"@/components/video-player\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogTitle,\n} from \"@/components/ui/dialog\";\n\nexport const VideoViewerAction = ({\n artifact,\n onOpen,\n}: {\n readonly artifact: ArtifactReference;\n readonly onOpen?: () => void;\n}) => {\n const [open, setOpen] = useState(false);\n if (!artifact.mediaType.startsWith(\"video/\")) {\n return null;\n }\n return (\n <>\n <Button\n aria-label=\"Open video\"\n title=\"Open video\"\n size=\"icon-sm\"\n variant=\"ghost\"\n onClick={() => {\n onOpen?.();\n setOpen(true);\n }}\n >\n <ExpandIcon size={16} />\n </Button>\n {open && (\n <Dialog open onOpenChange={setOpen}>\n <DialogContent className=\"w-[calc(100%-2rem)] max-w-5xl sm:max-w-5xl\">\n <DialogTitle className=\"pe-8\">Video preview</DialogTitle>\n <DialogDescription className=\"line-clamp-2\">\n {artifact.name}\n </DialogDescription>\n <VideoPlayer\n src={artifact.url}\n name={artifact.name}\n className=\"rounded-md\"\n />\n <div className=\"flex justify-end\">\n <ArtifactDownloadAction\n artifact={artifact}\n label=\"Download video\"\n />\n </div>\n </DialogContent>\n </Dialog>\n )}\n </>\n );\n};\n",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"target": "~/chatjs/plugins/video-viewer/viewer-action.tsx"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"path": "dist/source/video-viewer.json",
|
|
24
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"video-viewer\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/video-viewer/chat-ui.ts\",\n \"chatjs/plugins/video-viewer/viewer-action.tsx\"\n ]\n}\n",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"target": "~/chatjs/plugins/video-viewer/plugin.json"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"meta": {
|
|
30
|
+
"chatjs": {
|
|
31
|
+
"contractVersion": 3,
|
|
32
|
+
"uiBase": "base",
|
|
33
|
+
"id": "video-viewer",
|
|
34
|
+
"kind": "plugin",
|
|
35
|
+
"files": [
|
|
36
|
+
"chatjs/plugins/video-viewer/chat-ui.ts",
|
|
37
|
+
"chatjs/plugins/video-viewer/viewer-action.tsx"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"type": "registry:item"
|
|
42
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vultr-storage",
|
|
4
|
+
"title": "Vultr Object Storage",
|
|
5
|
+
"description": "Vultr Object Storage via the S3-compatible API. Endpoint derived from the region code (ewr, sjc, ams, blr, ...).",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/vultr/storage-provider.ts",
|
|
15
|
+
"content": "export { vultr as createStorageAdapter } from \"files-sdk/vultr\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket",
|
|
24
|
+
"region"
|
|
25
|
+
],
|
|
26
|
+
"configFields": [
|
|
27
|
+
{
|
|
28
|
+
"key": "bucket",
|
|
29
|
+
"label": "bucket",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"key": "region",
|
|
34
|
+
"label": "region",
|
|
35
|
+
"type": "text"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"contractVersion": 1,
|
|
39
|
+
"envRequirements": [
|
|
40
|
+
{
|
|
41
|
+
"description": "Vultr Object Storage credentials",
|
|
42
|
+
"options": [
|
|
43
|
+
[
|
|
44
|
+
"VULTR_ACCESS_KEY_ID",
|
|
45
|
+
"VULTR_SECRET_ACCESS_KEY"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"id": "vultr",
|
|
51
|
+
"kind": "storage",
|
|
52
|
+
"optionalEnv": []
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"type": "registry:item"
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "wasabi-storage",
|
|
4
|
+
"title": "Wasabi",
|
|
5
|
+
"description": "Wasabi Hot Cloud Storage via the S3-compatible API. AWS-style region names, Wasabi's own endpoints.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/wasabi/storage-provider.ts",
|
|
15
|
+
"content": "export { wasabi as createStorageAdapter } from \"files-sdk/wasabi\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket",
|
|
24
|
+
"region"
|
|
25
|
+
],
|
|
26
|
+
"configFields": [
|
|
27
|
+
{
|
|
28
|
+
"key": "bucket",
|
|
29
|
+
"label": "bucket",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"key": "region",
|
|
34
|
+
"label": "region",
|
|
35
|
+
"type": "text"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"contractVersion": 1,
|
|
39
|
+
"envRequirements": [
|
|
40
|
+
{
|
|
41
|
+
"description": "Wasabi credentials",
|
|
42
|
+
"options": [
|
|
43
|
+
[
|
|
44
|
+
"WASABI_ACCESS_KEY_ID",
|
|
45
|
+
"WASABI_SECRET_ACCESS_KEY"
|
|
46
|
+
]
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"id": "wasabi",
|
|
51
|
+
"kind": "storage",
|
|
52
|
+
"optionalEnv": []
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"type": "registry:item"
|
|
56
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "webdav-storage",
|
|
4
|
+
"title": "WebDAV",
|
|
5
|
+
"description": "WebDAV (Nextcloud, ownCloud, Apache mod_dav, …) via the webdav client. HTTP-based, with native server-side copy/move; url() needs an HTTP front (publicBaseUrl).",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"webdav@^5.10.0"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/storage/webdav/storage-provider.ts",
|
|
13
|
+
"content": "export { webdav as createStorageAdapter } from \"files-sdk/webdav\";\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"chatjs": {
|
|
20
|
+
"configKeys": [
|
|
21
|
+
"baseUrl",
|
|
22
|
+
"root"
|
|
23
|
+
],
|
|
24
|
+
"configFields": [
|
|
25
|
+
{
|
|
26
|
+
"key": "baseUrl",
|
|
27
|
+
"label": "baseUrl",
|
|
28
|
+
"type": "text"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"key": "root",
|
|
32
|
+
"label": "root",
|
|
33
|
+
"type": "text"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"contractVersion": 1,
|
|
37
|
+
"envRequirements": [
|
|
38
|
+
{
|
|
39
|
+
"description": "WebDAV configuration",
|
|
40
|
+
"options": [
|
|
41
|
+
[
|
|
42
|
+
"WEBDAV_URL"
|
|
43
|
+
]
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"description": "WebDAV credentials",
|
|
48
|
+
"options": [
|
|
49
|
+
[
|
|
50
|
+
"WEBDAV_USERNAME",
|
|
51
|
+
"WEBDAV_PASSWORD"
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"id": "webdav",
|
|
57
|
+
"kind": "storage",
|
|
58
|
+
"optionalEnv": [
|
|
59
|
+
"WEBDAV_AUTH_TYPE"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"type": "registry:item"
|
|
64
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "yandex-storage",
|
|
4
|
+
"title": "Yandex Object Storage",
|
|
5
|
+
"description": "Yandex Object Storage via the S3-compatible API. Fixed global endpoint, region defaults to ru-central1.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"@aws-sdk/client-s3@^3.1079.0",
|
|
9
|
+
"@aws-sdk/s3-presigned-post@^3.700.0",
|
|
10
|
+
"@aws-sdk/s3-request-presigner@^3.700.0"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/storage/yandex/storage-provider.ts",
|
|
15
|
+
"content": "export { yandex as createStorageAdapter } from \"files-sdk/yandex\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket"
|
|
24
|
+
],
|
|
25
|
+
"configFields": [
|
|
26
|
+
{
|
|
27
|
+
"key": "bucket",
|
|
28
|
+
"label": "bucket",
|
|
29
|
+
"type": "text"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"contractVersion": 1,
|
|
33
|
+
"envRequirements": [
|
|
34
|
+
{
|
|
35
|
+
"description": "Yandex Object Storage credentials",
|
|
36
|
+
"options": [
|
|
37
|
+
[
|
|
38
|
+
"YANDEX_ACCESS_KEY_ID",
|
|
39
|
+
"YANDEX_SECRET_ACCESS_KEY"
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"id": "yandex",
|
|
45
|
+
"kind": "storage",
|
|
46
|
+
"optionalEnv": []
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"type": "registry:item"
|
|
50
|
+
}
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"path": "src/storage/bunny-storage/storage-provider.ts",
|
|
13
13
|
"content": "export { bunnyStorage as createStorageAdapter } from \"files-sdk/bunny-storage\";\n",
|
|
14
14
|
"type": "registry:file",
|
|
15
|
-
"target": "~/
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"meta": {
|
|
19
19
|
"chatjs": {
|
|
20
20
|
"configKeys": [],
|
|
21
|
+
"configFields": [],
|
|
21
22
|
"contractVersion": 1,
|
|
22
23
|
"envRequirements": [
|
|
23
24
|
{
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"path": "src/storage/cloudinary/storage-provider.ts",
|
|
13
13
|
"content": "export { cloudinary as createStorageAdapter } from \"files-sdk/cloudinary\";\n",
|
|
14
14
|
"type": "registry:file",
|
|
15
|
-
"target": "~/
|
|
15
|
+
"target": "~/chatjs/providers/storage.ts"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"meta": {
|
|
19
19
|
"chatjs": {
|
|
20
20
|
"configKeys": [],
|
|
21
|
+
"configFields": [],
|
|
21
22
|
"contractVersion": 1,
|
|
22
23
|
"envRequirements": [
|
|
23
24
|
{
|
package/dist/r/credits.json
CHANGED
|
@@ -2,96 +2,79 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "credits",
|
|
4
4
|
"description": "Credit balances, spending admission, and atomic usage debits",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@tanstack/react-query@^5.104.1",
|
|
7
|
+
"drizzle-orm@^0.45.1",
|
|
8
|
+
"lucide-react@0.553.0"
|
|
9
|
+
],
|
|
5
10
|
"files": [
|
|
6
11
|
{
|
|
7
12
|
"path": "src/plugins/credits/src/balance.tsx",
|
|
8
13
|
"content": "\"use client\";\n\nimport { DollarSign } from \"lucide-react\";\nimport { useGetCredits } from \"./use-credits\";\n\nconst CENTS_PER_DOLLAR = 100;\nconst DISPLAY_DECIMALS = 2;\n\nexport const CreditBalance = () => {\n const { balanceCents, isError } = useGetCredits();\n if (isError) {\n return <span className=\"truncate text-xs\">Balance unavailable</span>;\n }\n if (balanceCents === undefined) {\n return <span className=\"truncate text-xs\">Loading balance…</span>;\n }\n return (\n <span className=\"flex items-center gap-1 truncate text-xs\">\n <DollarSign aria-hidden=\"true\" className=\"size-3\" />\n {(balanceCents / CENTS_PER_DOLLAR).toFixed(DISPLAY_DECIMALS)}\n </span>\n );\n};\n",
|
|
9
14
|
"type": "registry:file",
|
|
10
|
-
"target": "~/plugins/credits/balance.tsx"
|
|
15
|
+
"target": "~/chatjs/plugins/credits/balance.tsx"
|
|
11
16
|
},
|
|
12
17
|
{
|
|
13
18
|
"path": "src/plugins/credits/src/billing.ts",
|
|
14
|
-
"content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/
|
|
19
|
+
"content": "import { eq, sql } from \"drizzle-orm\";\nimport type { UsageBilling } from \"@/chatjs/core/billing/contracts\";\nimport { getBalanceCents } from \"./credits-queries\";\nimport { userCredit } from \"./credits-schema\";\n\n/** Core supplies its usage transaction, with the registered owner already locked. */\nconst creditsBilling = {\n canSpend: async (ownerId) => (await getBalanceCents(ownerId)) > 0,\n debit: async (tx, { ownerId, cents }) => {\n await tx\n .insert(userCredit)\n .values({ userId: ownerId })\n .onConflictDoNothing();\n await tx\n .update(userCredit)\n .set({ balanceCents: sql`${userCredit.balanceCents} - ${cents}` })\n .where(eq(userCredit.userId, ownerId));\n },\n} satisfies UsageBilling;\n\nexport default creditsBilling;\n",
|
|
15
20
|
"type": "registry:file",
|
|
16
|
-
"target": "~/plugins/credits/billing.ts"
|
|
21
|
+
"target": "~/chatjs/plugins/credits/billing.ts"
|
|
17
22
|
},
|
|
18
23
|
{
|
|
19
|
-
"path": "src/plugins/credits/src/
|
|
20
|
-
"content": "
|
|
24
|
+
"path": "src/plugins/credits/src/chat-ui.ts",
|
|
25
|
+
"content": "\"use client\";\nimport { definePlugin, slot } from \"@/chatjs/core/ui/slots\";\nimport { AccountSummary } from \"@/components/chat-slots\";\nimport { CreditBalance } from \"./balance\";\n\nexport const chatUi = definePlugin({\n id: \"credits\",\n slots: [slot(AccountSummary, CreditBalance)],\n});\n",
|
|
21
26
|
"type": "registry:file",
|
|
22
|
-
"target": "~/plugins/credits/
|
|
27
|
+
"target": "~/chatjs/plugins/credits/chat-ui.ts"
|
|
23
28
|
},
|
|
24
29
|
{
|
|
25
30
|
"path": "src/plugins/credits/src/credits-queries.ts",
|
|
26
31
|
"content": "import { eq } from \"drizzle-orm\";\n\nimport { db } from \"@/lib/db/client\";\nimport { userCredit } from \"./credits-schema\";\n\nconst NO_CREDITS = 0;\nconst FIRST_CREDIT_ROW_INDEX = 0;\nconst SINGLE_CREDIT_ROW_LIMIT = 1;\n\nconst ensureUserCreditRow = async (userId: string): Promise<void> => {\n await db.insert(userCredit).values({ userId }).onConflictDoNothing();\n};\n/**\n * Get user's current credit balance (in cents).\n * @param {string} userId - User whose balance is read; a missing credit row is created with the database defaults.\n * @returns {Promise<number>} Stored balance in cents, or zero if the retry still has no balance; database failures reject.\n */\nconst getBalanceCents = async (userId: string): Promise<number> => {\n let rows = await db\n .select({ balanceCents: userCredit.balanceCents })\n .from(userCredit)\n .where(eq(userCredit.userId, userId))\n .limit(SINGLE_CREDIT_ROW_LIMIT);\n\n if (rows.length === NO_CREDITS) {\n await ensureUserCreditRow(userId);\n rows = await db\n .select({ balanceCents: userCredit.balanceCents })\n .from(userCredit)\n .where(eq(userCredit.userId, userId))\n .limit(SINGLE_CREDIT_ROW_LIMIT);\n }\n\n return rows[FIRST_CREDIT_ROW_INDEX]?.balanceCents ?? NO_CREDITS;\n};\n\nexport { getBalanceCents };\n",
|
|
27
32
|
"type": "registry:file",
|
|
28
|
-
"target": "~/plugins/credits/credits-queries.ts"
|
|
33
|
+
"target": "~/chatjs/plugins/credits/credits-queries.ts"
|
|
29
34
|
},
|
|
30
35
|
{
|
|
31
36
|
"path": "src/plugins/credits/src/credits-schema.ts",
|
|
32
37
|
"content": "import { integer, pgTable, text } from \"drizzle-orm/pg-core\";\nimport { user } from \"@/lib/db/schema\";\n\nconst INITIAL_USER_CREDIT_BALANCE_CENTS = 50;\n\nconst userCredit = pgTable(\"UserCredit\", {\n /** Balance in cents. Default = $0.50 */\n balanceCents: integer(\"credits\")\n .notNull()\n .default(INITIAL_USER_CREDIT_BALANCE_CENTS),\n userId: text(\"userId\")\n .primaryKey()\n .notNull()\n .references(() => user.id, { onDelete: \"cascade\" }),\n});\n\nexport { userCredit };\n",
|
|
33
38
|
"type": "registry:file",
|
|
34
|
-
"target": "~/plugins/credits/credits-schema.ts"
|
|
39
|
+
"target": "~/chatjs/plugins/credits/credits-schema.ts"
|
|
35
40
|
},
|
|
36
41
|
{
|
|
37
42
|
"path": "src/plugins/credits/src/router.ts",
|
|
38
|
-
"content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\
|
|
43
|
+
"content": "import { getBalanceCents } from \"./credits-queries\";\nimport { createTRPCRouter, protectedProcedure } from \"@/trpc/init\";\n\nconst creditsProcedures = {\n getAvailableCredits: protectedProcedure.query(\n async ({\n ctx,\n }: {\n readonly ctx: { readonly user: { readonly id: string } };\n }) => {\n const balanceCents = await getBalanceCents(ctx.user.id);\n return { balanceCents };\n }\n ),\n};\n\nexport const router = createTRPCRouter({ credits: creditsProcedures });\n",
|
|
39
44
|
"type": "registry:file",
|
|
40
|
-
"target": "~/plugins/credits/router.ts"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"path": "src/plugins/credits/src/server-plugin.ts",
|
|
44
|
-
"content": "import type { ChatPlugin } from \"@/lib/plugin-contracts\";\nimport { creditsRouter } from \"./router\";\n\nexport const credits = () =>\n ({ id: \"credits\", routers: { credits: creditsRouter } }) satisfies ChatPlugin;\n",
|
|
45
|
-
"type": "registry:file",
|
|
46
|
-
"target": "~/plugins/credits/server-plugin.ts"
|
|
45
|
+
"target": "~/chatjs/plugins/credits/router.ts"
|
|
47
46
|
},
|
|
48
47
|
{
|
|
49
48
|
"path": "src/plugins/credits/src/use-credits.ts",
|
|
50
49
|
"content": "\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\n\nimport { useSession } from \"@/providers/session-provider\";\nimport { useTRPC } from \"@/trpc/react\";\n\nexport const useGetCredits = (): {\n balanceCents: number | undefined;\n isError: boolean;\n} => {\n const { data: session } = useSession();\n const isAuthenticated = Boolean(session?.user);\n const trpc = useTRPC();\n\n const { data: creditsData, isError } = useQuery({\n ...trpc.credits.getAvailableCredits.queryOptions(),\n enabled: isAuthenticated,\n meta: { refreshOnTurnEnd: true },\n });\n\n return {\n balanceCents: creditsData?.balanceCents,\n isError,\n };\n};\n",
|
|
51
50
|
"type": "registry:file",
|
|
52
|
-
"target": "~/plugins/credits/use-credits.ts"
|
|
51
|
+
"target": "~/chatjs/plugins/credits/use-credits.ts"
|
|
53
52
|
},
|
|
54
53
|
{
|
|
55
54
|
"path": "dist/source/credits.json",
|
|
56
|
-
"content": "{\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/credits/balance.tsx\",\n \"plugins/credits/billing.ts\",\n \"plugins/credits/
|
|
55
|
+
"content": "{\n \"contractVersion\": 3,\n \"uiBase\": \"base\",\n \"id\": \"credits\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/credits/balance.tsx\",\n \"chatjs/plugins/credits/billing.ts\",\n \"chatjs/plugins/credits/chat-ui.ts\",\n \"chatjs/plugins/credits/credits-queries.ts\",\n \"chatjs/plugins/credits/credits-schema.ts\",\n \"chatjs/plugins/credits/router.ts\",\n \"chatjs/plugins/credits/use-credits.ts\"\n ],\n \"databaseSchemas\": [\"chatjs/plugins/credits/credits-schema.ts\"]\n}\n",
|
|
57
56
|
"type": "registry:file",
|
|
58
|
-
"target": "~/plugins/credits/
|
|
57
|
+
"target": "~/chatjs/plugins/credits/plugin.json"
|
|
59
58
|
}
|
|
60
59
|
],
|
|
61
60
|
"meta": {
|
|
62
61
|
"chatjs": {
|
|
62
|
+
"contractVersion": 3,
|
|
63
|
+
"uiBase": "base",
|
|
63
64
|
"id": "credits",
|
|
64
65
|
"kind": "plugin",
|
|
65
66
|
"files": [
|
|
66
|
-
"plugins/credits/balance.tsx",
|
|
67
|
-
"plugins/credits/billing.ts",
|
|
68
|
-
"plugins/credits/
|
|
69
|
-
"plugins/credits/credits-queries.ts",
|
|
70
|
-
"plugins/credits/credits-schema.ts",
|
|
71
|
-
"plugins/credits/router.ts",
|
|
72
|
-
"plugins/credits/
|
|
73
|
-
"plugins/credits/use-credits.ts"
|
|
67
|
+
"chatjs/plugins/credits/balance.tsx",
|
|
68
|
+
"chatjs/plugins/credits/billing.ts",
|
|
69
|
+
"chatjs/plugins/credits/chat-ui.ts",
|
|
70
|
+
"chatjs/plugins/credits/credits-queries.ts",
|
|
71
|
+
"chatjs/plugins/credits/credits-schema.ts",
|
|
72
|
+
"chatjs/plugins/credits/router.ts",
|
|
73
|
+
"chatjs/plugins/credits/use-credits.ts"
|
|
74
74
|
],
|
|
75
75
|
"databaseSchemas": [
|
|
76
|
-
"plugins/credits/credits-schema.ts"
|
|
77
|
-
]
|
|
78
|
-
"billing": {
|
|
79
|
-
"export": "creditsBilling"
|
|
80
|
-
},
|
|
81
|
-
"server": {
|
|
82
|
-
"export": "credits",
|
|
83
|
-
"routers": [
|
|
84
|
-
"credits"
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
"client": {
|
|
88
|
-
"export": "creditsClient",
|
|
89
|
-
"composerControls": [],
|
|
90
|
-
"settingsItems": [],
|
|
91
|
-
"accountSummary": true
|
|
92
|
-
},
|
|
93
|
-
"contractVersion": 2,
|
|
94
|
-
"uiBase": "base"
|
|
76
|
+
"chatjs/plugins/credits/credits-schema.ts"
|
|
77
|
+
]
|
|
95
78
|
}
|
|
96
79
|
},
|
|
97
80
|
"type": "registry:item"
|