@chat-js/registry 0.1.2 → 0.2.0-beta.1
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 +60 -8
- package/dist/r/ai-titles.json +50 -0
- package/dist/r/akamai-storage.json +44 -0
- package/dist/r/alibaba-storage.json +44 -0
- package/dist/r/appwrite-storage.json +50 -0
- package/dist/r/archil-storage.json +52 -0
- package/dist/r/attachment-uploads.json +90 -0
- package/dist/r/azure-storage.json +51 -0
- package/dist/r/backblaze-b2-storage.json +44 -0
- package/dist/r/base/ai-titles.json +50 -0
- package/dist/r/base/akamai-storage.json +44 -0
- package/dist/r/base/alibaba-storage.json +44 -0
- package/dist/r/base/appwrite-storage.json +50 -0
- package/dist/r/base/archil-storage.json +52 -0
- package/dist/r/base/attachment-uploads.json +90 -0
- package/dist/r/base/azure-storage.json +51 -0
- package/dist/r/base/backblaze-b2-storage.json +44 -0
- package/dist/r/base/bunny-storage-storage.json +48 -0
- package/dist/r/base/cloudinary-storage.json +43 -0
- package/dist/r/base/code-documents.json +96 -0
- package/dist/r/base/code-execution-runtime.json +25 -0
- package/dist/r/base/code-execution-ui.json +32 -0
- package/dist/r/base/code-execution.json +69 -0
- package/dist/r/base/credits.json +103 -0
- package/dist/r/base/daytona-sandbox.json +55 -0
- package/dist/r/base/deep-research.json +224 -0
- package/dist/r/base/delete-document.json +58 -0
- package/dist/r/base/digitalocean-spaces-storage.json +44 -0
- package/dist/r/base/dropbox-storage.json +43 -0
- package/dist/r/base/exoscale-storage.json +44 -0
- package/dist/r/base/feedback.json +112 -0
- package/dist/r/base/filebase-storage.json +43 -0
- package/dist/r/base/firebase-storage-storage.json +52 -0
- package/dist/r/base/firecrawl-search.json +72 -0
- package/dist/r/base/followup-suggestions.json +152 -0
- package/dist/r/base/ftp-storage.json +54 -0
- package/dist/r/base/gcs-storage.json +33 -0
- package/dist/r/base/generate-image.json +101 -0
- package/dist/r/base/generate-video.json +70 -0
- package/dist/r/base/get-weather.json +52 -0
- package/dist/r/base/google-drive-storage.json +47 -0
- package/dist/r/base/hetzner-storage.json +44 -0
- package/dist/r/base/ibm-cos-storage.json +44 -0
- package/dist/r/base/idrive-e2-storage.json +44 -0
- package/dist/r/base/langfuse.json +63 -0
- package/dist/r/base/litellm-gateway.json +67 -0
- package/dist/r/base/mcp.json +320 -0
- package/dist/r/base/memory-storage.json +28 -0
- package/dist/r/base/minio-storage.json +44 -0
- package/dist/r/base/model-preferences.json +131 -0
- package/dist/r/base/neon-storage.json +44 -0
- package/dist/r/base/netlify-blobs-storage.json +31 -0
- package/dist/r/base/onedrive-storage.json +48 -0
- package/dist/r/base/openai-compatible-gateway.json +69 -0
- package/dist/r/base/openai-gateway.json +67 -0
- package/dist/r/base/openrouter-gateway.json +75 -0
- package/dist/r/base/oracle-cloud-storage.json +45 -0
- package/dist/r/base/ovhcloud-storage.json +44 -0
- package/dist/r/base/pocketbase-storage.json +50 -0
- package/dist/r/base/projects.json +275 -0
- package/dist/r/base/r2-storage.json +44 -0
- package/dist/r/base/read-document.json +34 -0
- package/dist/r/base/registry.json +4949 -0
- package/dist/r/base/retrieve-url.json +69 -0
- package/dist/r/base/s3-storage.json +44 -0
- package/dist/r/base/saved-code-execution.json +84 -0
- package/dist/r/base/scaleway-storage.json +44 -0
- package/dist/r/base/search.json +146 -0
- package/dist/r/base/sftp-storage.json +58 -0
- package/dist/r/base/sharepoint-storage.json +50 -0
- package/dist/r/base/sharing.json +144 -0
- package/dist/r/base/sheet-documents.json +94 -0
- package/dist/r/base/storj-storage.json +43 -0
- package/dist/r/base/supabase-storage.json +48 -0
- package/dist/r/base/tavily-search.json +72 -0
- package/dist/r/base/tencent-storage.json +44 -0
- package/dist/r/base/text-documents.json +117 -0
- package/dist/r/base/tigris-storage.json +43 -0
- package/dist/r/base/uploadthing-storage.json +38 -0
- package/dist/r/base/vercel-analytics.json +46 -0
- package/dist/r/base/vercel-blob-storage.json +42 -0
- package/dist/r/base/vercel-gateway.json +77 -0
- package/dist/r/base/vercel-sandbox.json +67 -0
- package/dist/r/base/vercel-speed-insights.json +46 -0
- package/dist/r/base/vultr-storage.json +44 -0
- package/dist/r/base/wasabi-storage.json +44 -0
- package/dist/r/base/webdav-storage.json +52 -0
- package/dist/r/base/word-count.json +51 -0
- package/dist/r/base/yandex-storage.json +43 -0
- package/dist/r/bunny-storage-storage.json +48 -0
- package/dist/r/cloudinary-storage.json +43 -0
- package/dist/r/code-documents.json +96 -0
- package/dist/r/code-execution-runtime.json +25 -0
- package/dist/r/code-execution-ui.json +32 -0
- package/dist/r/code-execution.json +69 -0
- package/dist/r/credits.json +103 -0
- package/dist/r/daytona-sandbox.json +55 -0
- package/dist/r/deep-research.json +224 -0
- package/dist/r/delete-document.json +58 -0
- package/dist/r/digitalocean-spaces-storage.json +44 -0
- package/dist/r/dropbox-storage.json +43 -0
- package/dist/r/exoscale-storage.json +44 -0
- package/dist/r/feedback.json +112 -0
- package/dist/r/filebase-storage.json +43 -0
- package/dist/r/firebase-storage-storage.json +52 -0
- package/dist/r/firecrawl-search.json +72 -0
- package/dist/r/followup-suggestions.json +152 -0
- package/dist/r/ftp-storage.json +54 -0
- package/dist/r/gcs-storage.json +33 -0
- package/dist/r/generate-image.json +101 -0
- package/dist/r/generate-video.json +70 -0
- package/dist/r/get-weather.json +52 -0
- package/dist/r/google-drive-storage.json +47 -0
- package/dist/r/hetzner-storage.json +44 -0
- package/dist/r/ibm-cos-storage.json +44 -0
- package/dist/r/idrive-e2-storage.json +44 -0
- package/dist/r/langfuse.json +63 -0
- package/dist/r/litellm-gateway.json +67 -0
- package/dist/r/mcp.json +320 -0
- package/dist/r/memory-storage.json +28 -0
- package/dist/r/minio-storage.json +44 -0
- package/dist/r/model-preferences.json +131 -0
- package/dist/r/neon-storage.json +44 -0
- package/dist/r/netlify-blobs-storage.json +31 -0
- package/dist/r/onedrive-storage.json +48 -0
- package/dist/r/openai-compatible-gateway.json +69 -0
- package/dist/r/openai-gateway.json +67 -0
- package/dist/r/openrouter-gateway.json +75 -0
- package/dist/r/oracle-cloud-storage.json +45 -0
- package/dist/r/ovhcloud-storage.json +44 -0
- package/dist/r/pocketbase-storage.json +50 -0
- package/dist/r/projects.json +275 -0
- package/dist/r/r2-storage.json +44 -0
- package/dist/r/radix/ai-titles.json +50 -0
- package/dist/r/radix/akamai-storage.json +44 -0
- package/dist/r/radix/alibaba-storage.json +44 -0
- package/dist/r/radix/appwrite-storage.json +50 -0
- package/dist/r/radix/archil-storage.json +52 -0
- package/dist/r/radix/attachment-uploads.json +90 -0
- package/dist/r/radix/azure-storage.json +51 -0
- package/dist/r/radix/backblaze-b2-storage.json +44 -0
- package/dist/r/radix/bunny-storage-storage.json +48 -0
- package/dist/r/radix/cloudinary-storage.json +43 -0
- package/dist/r/radix/code-documents.json +96 -0
- package/dist/r/radix/code-execution-runtime.json +25 -0
- package/dist/r/radix/code-execution-ui.json +32 -0
- package/dist/r/radix/code-execution.json +69 -0
- package/dist/r/radix/credits.json +103 -0
- package/dist/r/radix/daytona-sandbox.json +55 -0
- package/dist/r/radix/deep-research.json +224 -0
- package/dist/r/radix/delete-document.json +58 -0
- package/dist/r/radix/digitalocean-spaces-storage.json +44 -0
- package/dist/r/radix/dropbox-storage.json +43 -0
- package/dist/r/radix/exoscale-storage.json +44 -0
- package/dist/r/radix/feedback.json +112 -0
- package/dist/r/radix/filebase-storage.json +43 -0
- package/dist/r/radix/firebase-storage-storage.json +52 -0
- package/dist/r/radix/firecrawl-search.json +72 -0
- package/dist/r/radix/followup-suggestions.json +152 -0
- package/dist/r/radix/ftp-storage.json +54 -0
- package/dist/r/radix/gcs-storage.json +33 -0
- package/dist/r/radix/generate-image.json +101 -0
- package/dist/r/radix/generate-video.json +70 -0
- package/dist/r/radix/get-weather.json +52 -0
- package/dist/r/radix/google-drive-storage.json +47 -0
- package/dist/r/radix/hetzner-storage.json +44 -0
- package/dist/r/radix/ibm-cos-storage.json +44 -0
- package/dist/r/radix/idrive-e2-storage.json +44 -0
- package/dist/r/radix/langfuse.json +63 -0
- package/dist/r/radix/litellm-gateway.json +67 -0
- package/dist/r/radix/mcp.json +320 -0
- package/dist/r/radix/memory-storage.json +28 -0
- package/dist/r/radix/minio-storage.json +44 -0
- package/dist/r/radix/model-preferences.json +131 -0
- package/dist/r/radix/neon-storage.json +44 -0
- package/dist/r/radix/netlify-blobs-storage.json +31 -0
- package/dist/r/radix/onedrive-storage.json +48 -0
- package/dist/r/radix/openai-compatible-gateway.json +69 -0
- package/dist/r/radix/openai-gateway.json +67 -0
- package/dist/r/radix/openrouter-gateway.json +75 -0
- package/dist/r/radix/oracle-cloud-storage.json +45 -0
- package/dist/r/radix/ovhcloud-storage.json +44 -0
- package/dist/r/radix/pocketbase-storage.json +50 -0
- package/dist/r/radix/projects.json +275 -0
- package/dist/r/radix/r2-storage.json +44 -0
- package/dist/r/radix/read-document.json +34 -0
- package/dist/r/radix/registry.json +4949 -0
- package/dist/r/radix/retrieve-url.json +69 -0
- package/dist/r/radix/s3-storage.json +44 -0
- package/dist/r/radix/saved-code-execution.json +84 -0
- package/dist/r/radix/scaleway-storage.json +44 -0
- package/dist/r/radix/search.json +146 -0
- package/dist/r/radix/sftp-storage.json +58 -0
- package/dist/r/radix/sharepoint-storage.json +50 -0
- package/dist/r/radix/sharing.json +144 -0
- package/dist/r/radix/sheet-documents.json +94 -0
- package/dist/r/radix/storj-storage.json +43 -0
- package/dist/r/radix/supabase-storage.json +48 -0
- package/dist/r/radix/tavily-search.json +72 -0
- package/dist/r/radix/tencent-storage.json +44 -0
- package/dist/r/radix/text-documents.json +117 -0
- package/dist/r/radix/tigris-storage.json +43 -0
- package/dist/r/radix/uploadthing-storage.json +38 -0
- package/dist/r/radix/vercel-analytics.json +46 -0
- package/dist/r/radix/vercel-blob-storage.json +42 -0
- package/dist/r/radix/vercel-gateway.json +77 -0
- package/dist/r/radix/vercel-sandbox.json +67 -0
- package/dist/r/radix/vercel-speed-insights.json +46 -0
- package/dist/r/radix/vultr-storage.json +44 -0
- package/dist/r/radix/wasabi-storage.json +44 -0
- package/dist/r/radix/webdav-storage.json +52 -0
- package/dist/r/radix/word-count.json +51 -0
- package/dist/r/radix/yandex-storage.json +43 -0
- package/dist/r/read-document.json +34 -0
- package/dist/r/registry.json +4949 -0
- package/dist/r/retrieve-url.json +69 -0
- package/dist/r/s3-storage.json +44 -0
- package/dist/r/saved-code-execution.json +84 -0
- package/dist/r/scaleway-storage.json +44 -0
- package/dist/r/search.json +146 -0
- package/dist/r/sftp-storage.json +58 -0
- package/dist/r/sharepoint-storage.json +50 -0
- package/dist/r/sharing.json +144 -0
- package/dist/r/sheet-documents.json +94 -0
- package/dist/r/storj-storage.json +43 -0
- package/dist/r/supabase-storage.json +48 -0
- package/dist/r/tavily-search.json +72 -0
- package/dist/r/tencent-storage.json +44 -0
- package/dist/r/text-documents.json +117 -0
- package/dist/r/tigris-storage.json +43 -0
- package/dist/r/uploadthing-storage.json +38 -0
- package/dist/r/vercel-analytics.json +46 -0
- package/dist/r/vercel-blob-storage.json +42 -0
- package/dist/r/vercel-gateway.json +77 -0
- package/dist/r/vercel-sandbox.json +67 -0
- package/dist/r/vercel-speed-insights.json +46 -0
- package/dist/r/vultr-storage.json +44 -0
- package/dist/r/wasabi-storage.json +44 -0
- package/dist/r/webdav-storage.json +52 -0
- package/dist/r/word-count.json +51 -0
- package/dist/r/yandex-storage.json +43 -0
- package/package.json +113 -31
- package/index.d.ts +0 -4
- package/index.js +0 -1
- package/index.json +0 -19
- package/items/get-weather.json +0 -26
- package/items/retrieve-url.json +0 -35
- package/items/toolkit-renderer.json +0 -29
- package/items/word-count.json +0 -22
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "text-documents",
|
|
4
|
+
"description": "Create and edit text documents with their editor UI",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@lexical/code@^0.32.1",
|
|
7
|
+
"@lexical/link@^0.32.1",
|
|
8
|
+
"@lexical/list@^0.32.1",
|
|
9
|
+
"@lexical/markdown@^0.32.1",
|
|
10
|
+
"@lexical/react@^0.32.1",
|
|
11
|
+
"@lexical/rich-text@^0.32.1",
|
|
12
|
+
"lexical@^0.32.1",
|
|
13
|
+
"diff@^8.0.2",
|
|
14
|
+
"@tanstack/react-query@^5.104.1"
|
|
15
|
+
],
|
|
16
|
+
"registryDependencies": [
|
|
17
|
+
"@chatjs/read-document"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
{
|
|
21
|
+
"path": "src/tools/text-documents/tool.ts",
|
|
22
|
+
"content": "import {\n eveDocumentCreateInput,\n eveDocumentEditInput,\n eveDocumentWriteResult,\n} from \"@/lib/eve/document-contracts\";\nimport type { ToolContext } from \"eve/tools\";\nimport { defineTool } from \"eve/tools\";\nimport { executeEveDocumentTool } from \"@/lib/eve/document-tools\";\nimport { textGuidelines } from \"./guidelines\";\nimport type { z } from \"zod\";\n\ntype CreateTextDocumentInput = Readonly<\n Omit<z.infer<typeof eveDocumentCreateInput>, \"fileIds\"> & {\n fileIds: readonly string[];\n }\n>;\n\ntype EditTextDocumentInput = Readonly<\n Omit<z.infer<typeof eveDocumentEditInput>, \"fileIds\"> & {\n fileIds: readonly string[];\n }\n>;\n\ntype ReadonlyDocumentToolContext = Readonly<\n Pick<ToolContext, \"callId\" | \"session\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nconst createTextDocument = defineTool({\n description: `Create a new text document in this conversation. Supply the complete content and a descriptive title. ${textGuidelines}`,\n execute: async (\n input: CreateTextDocumentInput,\n context: ReadonlyDocumentToolContext\n ) =>\n eveDocumentWriteResult.parse(\n await executeEveDocumentTool(\"createTextDocument\", input, context)\n ),\n inputSchema: eveDocumentCreateInput,\n outputSchema: eveDocumentWriteResult,\n});\nconst editTextDocument = defineTool({\n description: `Edit an existing text document in this conversation. Read the document first and supply its revision ID. Supply the complete replacement content. ${textGuidelines}`,\n execute: async (\n input: EditTextDocumentInput,\n context: ReadonlyDocumentToolContext\n ) =>\n eveDocumentWriteResult.parse(\n await executeEveDocumentTool(\"editTextDocument\", input, context)\n ),\n inputSchema: eveDocumentEditInput,\n outputSchema: eveDocumentWriteResult,\n});\nexport { createTextDocument, editTextDocument };\n",
|
|
23
|
+
"type": "registry:file",
|
|
24
|
+
"target": "~/tools/chatjs/text-documents/tool.ts"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "src/tools/text-documents/guidelines.ts",
|
|
28
|
+
"content": "export const textGuidelines = `\nGuidelines:\n- Write clear, well-structured content about the given topic\n- Use markdown formatting effectively\n- Use headings (##, ###) to organize content where appropriate\n- Keep paragraphs focused and readable\n- Use lists, bold, and italics to enhance readability when suitable`;\n",
|
|
29
|
+
"type": "registry:file",
|
|
30
|
+
"target": "~/tools/chatjs/text-documents/guidelines.ts"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "src/tools/text-documents/configuration-schema.ts",
|
|
34
|
+
"content": "import { z } from \"zod\";\nimport { languageModelSchema, modelRoles } from \"@/lib/config-models\";\n\nconst configSchema = z\n .strictObject({ polish: languageModelSchema.default(modelRoles.balanced) })\n .prefault({});\nexport { configSchema };\n",
|
|
35
|
+
"type": "registry:file",
|
|
36
|
+
"target": "~/tools/chatjs/text-documents/configuration-schema.ts"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "src/tools/text-documents/assistant-actions.ts",
|
|
40
|
+
"content": "import type { DocumentAssistantAction } from \"@/lib/eve/document-contracts\";\nimport { config } from \"@/lib/config\";\n\nconst documentAssistantActions = (): DocumentAssistantAction[] => [\n {\n instruction:\n \"Add final polish, check grammar, add section titles for structure, and ensure the document reads smoothly.\",\n label: \"Add final polish\",\n modelId: config.ai.tools.text.polish,\n },\n];\nexport { documentAssistantActions };\n",
|
|
41
|
+
"type": "registry:file",
|
|
42
|
+
"target": "~/tools/chatjs/text-documents/assistant-actions.ts"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "src/tools/text-documents/document.tsx",
|
|
46
|
+
"content": "\"use client\";\nimport type { DocumentBodyProps, DocumentUi } from \"@/lib/eve/document-ui\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ScrollArea } from \"@/components/ui/scroll-area\";\nimport { EveDocumentComparison } from \"./comparison\";\nimport dynamic from \"next/dynamic\";\n\nconst Editor = dynamic(\n async () => {\n const { Editor: TextEditor } = await import(\"./editor\");\n return TextEditor;\n },\n {\n ssr: false,\n }\n);\n\nexport const documentUi: DocumentUi = {\n Body: ({\n inline,\n editorProps,\n comparison,\n }: ReadonlyNativeSurface<DocumentBodyProps>) => (\n <ScrollArea className=\"min-h-0 flex-1\">\n {comparison ? (\n <EveDocumentComparison {...comparison} />\n ) : (\n <div\n className={\n inline === true\n ? \"p-4 sm:px-14 sm:py-16\"\n : \"mx-auto max-w-3xl px-4 py-8\"\n }\n >\n <Editor {...editorProps} />\n </div>\n )}\n </ScrollArea>\n ),\n};\n",
|
|
47
|
+
"type": "registry:file",
|
|
48
|
+
"target": "~/tools/chatjs/text-documents/document.tsx"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"path": "src/tools/text-documents/editor.tsx",
|
|
52
|
+
"content": "\"use client\";\n\nimport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n TRANSFORMERS,\n} from \"@lexical/markdown\";\nimport React, { memo, useEffect, useRef } from \"react\";\nimport { createEditorConfig, handleEditorChange } from \"./editor-config\";\nimport { $getRoot } from \"lexical\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport type { EditorState } from \"lexical\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { ListPlugin } from \"@lexical/react/LexicalListPlugin\";\nimport { MarkdownShortcutPlugin } from \"@lexical/react/LexicalMarkdownShortcutPlugin\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\n\ninterface EditorProps {\n content: string;\n currentVersionIndex: number;\n isCurrentVersion: boolean;\n isReadonly?: boolean;\n onSaveContent: (updatedContent: string, debounce: boolean) => void;\n status: \"streaming\" | \"idle\";\n}\n\n// Content update plugin\nconst ContentUpdatePlugin = ({\n content,\n status,\n onSaveContent,\n isReadonly,\n}: ReadonlyNativeSurface<{\n content: string;\n status: \"streaming\" | \"idle\";\n onSaveContent: (content: string, debounce: boolean) => void;\n isReadonly?: boolean;\n}>): React.JSX.Element => {\n const [editor] = useLexicalComposerContext();\n const isProgrammaticUpdate = useRef(false);\n\n useEffect((): void => {\n editor.setEditable(!(isReadonly === true));\n }, [editor, isReadonly]);\n\n useEffect((): void => {\n let currentMarkdown = \"\";\n editor.getEditorState().read((): void => {\n currentMarkdown = $convertToMarkdownString(TRANSFORMERS);\n });\n if (status !== \"streaming\" && currentMarkdown.trim() === content.trim()) {\n return;\n }\n isProgrammaticUpdate.current = true;\n editor.update(\n (): void => {\n $getRoot().clear();\n $convertFromMarkdownString(content);\n },\n {\n discrete: true,\n onUpdate: (): void => {\n isProgrammaticUpdate.current = false;\n },\n }\n );\n }, [content, status, editor]);\n\n const handleChange = (\n editorState: Readonly<Pick<EditorState, \"read\">>\n ): void => {\n if (!(isReadonly === true || isProgrammaticUpdate.current)) {\n handleEditorChange({\n editor,\n editorState,\n onSaveContent,\n });\n }\n };\n\n return <OnChangePlugin onChange={handleChange} />;\n};\n\nconst PureEditor = ({\n content,\n onSaveContent,\n status,\n isReadonly,\n}: ReadonlyNativeSurface<EditorProps>): React.JSX.Element => {\n const initialConfig = createEditorConfig();\n\n const editorConfig = {\n ...initialConfig,\n editable: !(isReadonly === true),\n };\n\n return (\n <div className=\"prose dark:prose-invert relative text-left\">\n <LexicalComposer initialConfig={editorConfig}>\n <RichTextPlugin\n contentEditable={\n <ContentEditable className=\"lexical-editor text-left outline-hidden\" />\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={\n <div className=\"text-muted-foreground\">Start typing...</div>\n }\n />\n <HistoryPlugin />\n <ListPlugin />\n <MarkdownShortcutPlugin transformers={TRANSFORMERS} />\n <ContentUpdatePlugin\n content={content}\n isReadonly={isReadonly}\n onSaveContent={onSaveContent}\n status={status}\n />\n </LexicalComposer>\n </div>\n );\n};\n\nconst areEqual = (\n prevProps: ReadonlyNativeSurface<EditorProps>,\n nextProps: ReadonlyNativeSurface<EditorProps>\n): boolean =>\n prevProps.currentVersionIndex === nextProps.currentVersionIndex &&\n prevProps.isCurrentVersion === nextProps.isCurrentVersion &&\n !(prevProps.status === \"streaming\" && nextProps.status === \"streaming\") &&\n prevProps.content === nextProps.content &&\n prevProps.onSaveContent === nextProps.onSaveContent &&\n prevProps.isReadonly === nextProps.isReadonly;\n\nexport const Editor = memo(PureEditor, areEqual);\n",
|
|
53
|
+
"type": "registry:file",
|
|
54
|
+
"target": "~/tools/chatjs/text-documents/editor.tsx"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "src/tools/text-documents/comparison.tsx",
|
|
58
|
+
"content": "\"use client\";\nimport { Button } from \"@/components/ui/button\";\nimport { DocumentSkeleton } from \"@/components/document-skeleton\";\nimport React from \"react\";\nimport dynamic from \"next/dynamic\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useTRPC } from \"@/trpc/react\";\n\nconst DiffView = dynamic(\n async () => {\n const { DiffView: Comparison } = await import(\"./diffview\");\n return Comparison;\n },\n {\n loading: () => <DocumentSkeleton artifactKind=\"text\" />,\n ssr: false,\n }\n);\n\nexport const EveDocumentComparison = ({\n conversationId,\n documentId,\n previousRevisionId,\n content,\n version,\n}: {\n readonly conversationId: string;\n readonly documentId: string;\n readonly previousRevisionId: string;\n readonly content: string;\n readonly version: number;\n}): React.JSX.Element => {\n const trpc = useTRPC();\n const previous = useQuery(\n trpc.eve.document.queryOptions({\n conversationId,\n documentId,\n revisionId: previousRevisionId,\n })\n );\n return (\n <section\n aria-label=\"Document changes\"\n className=\"mx-auto max-w-3xl space-y-4 px-4 py-8\"\n >\n <p className=\"text-muted-foreground text-sm\">\n Changes from version {version - 1} to {version}\n </p>\n {previous.isPending && <DocumentSkeleton artifactKind=\"text\" />}\n {previous.isError && (\n <div className=\"space-y-2\" role=\"alert\">\n <p>The previous version could not be loaded.</p>\n {}\n <Button\n onClick={(): void => {\n void previous.refetch();\n }}\n variant=\"outline\"\n >\n Retry comparison\n </Button>\n </div>\n )}\n {previous.data && !previous.isError && (\n <DiffView\n newContent={content}\n oldContent={previous.data.revision.content}\n />\n )}\n </section>\n );\n};\n",
|
|
59
|
+
"type": "registry:file",
|
|
60
|
+
"target": "~/tools/chatjs/text-documents/comparison.tsx"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"path": "src/tools/text-documents/diffview.tsx",
|
|
64
|
+
"content": "import { $createParagraphNode, $getRoot, TextNode } from \"lexical\";\nimport type { EditorConfig, LexicalEditor, SerializedTextNode } from \"lexical\";\nimport React, { useEffect } from \"react\";\nimport type { ChangeObject } from \"diff\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { createEditorConfig } from \"./editor-config\";\nimport { diffWords } from \"diff\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\n\nconst DiffType = {\n Deleted: -1,\n Inserted: 1,\n Unchanged: 0,\n};\n\n// Define diff types\ntype DiffTypeValue = (typeof DiffType)[keyof typeof DiffType];\ntype SerializedDiffTextNode = SerializedTextNode & {\n diffType?: DiffTypeValue;\n type: \"diff-text\";\n version: 1;\n};\n\n// Custom diff text node that supports styling\nclass DiffTextNode extends TextNode {\n public __diffType?: DiffTypeValue;\n\n public static getType(): string {\n return \"diff-text\";\n }\n\n public static clone(\n node: Readonly<Pick<DiffTextNode, \"__text\" | \"__key\" | \"__diffType\">>\n ): DiffTextNode {\n const newNode = new DiffTextNode(node.__text, node.__key);\n newNode.__diffType = node.__diffType;\n return newNode;\n }\n\n public static importJSON(\n serializedNode: ReadonlyNativeSurface<SerializedDiffTextNode>\n ): DiffTextNode {\n const { text, diffType } = serializedNode;\n const node = new DiffTextNode(text);\n if (diffType !== undefined) {\n node.setDiffType(diffType);\n }\n return node;\n }\n\n public exportJSON(): SerializedDiffTextNode {\n return {\n ...super.exportJSON(),\n diffType: this.__diffType,\n type: \"diff-text\",\n version: 1,\n };\n }\n\n public setDiffType(diffType: DiffTypeValue): void {\n const writable = this.getWritable();\n writable.__diffType = diffType;\n }\n\n public getDiffType(): DiffTypeValue | undefined {\n return this.__diffType;\n }\n\n public createDOM(config: EditorConfig, editor?: LexicalEditor): HTMLElement {\n const element = super.createDOM(config, editor);\n const diffType = this.getDiffType();\n\n if (\n diffType !== null &&\n diffType !== undefined &&\n diffType !== 0 &&\n !Number.isNaN(diffType)\n ) {\n let className = \"\";\n switch (diffType) {\n case DiffType.Inserted: {\n className =\n \"bg-green-100 text-green-700 dark:bg-green-500/70 dark:text-green-300\";\n break;\n }\n case DiffType.Deleted: {\n className =\n \"bg-red-100 line-through text-red-600 dark:bg-red-500/70 dark:text-red-300\";\n break;\n }\n default: {\n className = \"\";\n }\n }\n element.className = className;\n }\n\n return element;\n }\n\n public updateDOM(\n prevNode: this,\n dom: HTMLElement,\n config: EditorConfig\n ): boolean {\n const prevDiffType = prevNode.getDiffType();\n const currentDiffType = this.getDiffType();\n\n if (prevDiffType !== currentDiffType) {\n // Update classes if diff type changed\n // Recreate the span when its diff styling changes.\n return true;\n }\n\n return super.updateDOM(prevNode, dom, config);\n }\n}\n\n// Proper diff computation using the diff library\nconst computeProperDiff = (\n oldText: string,\n newText: string\n): { text: string; type: number }[] => {\n const changes = diffWords(oldText, newText);\n\n return changes.map((change: Readonly<ChangeObject<string>>) => {\n let type: DiffTypeValue;\n if (change.added) {\n type = DiffType.Inserted;\n } else if (change.removed) {\n type = DiffType.Deleted;\n } else {\n type = DiffType.Unchanged;\n }\n\n return {\n text: change.value,\n type,\n };\n });\n};\n\nconst DiffContentPlugin = ({\n oldContent,\n newContent,\n}: ReadonlyNativeSurface<{\n oldContent: string;\n newContent: string;\n}>): null => {\n const [editor] = useLexicalComposerContext();\n\n useEffect((): void => {\n editor.update((): void => {\n const root = $getRoot();\n\n // Clear existing content\n const children = root.getChildren();\n for (const child of children) {\n child.remove();\n }\n\n // Compute proper diff using LCS algorithm\n const diffResult = computeProperDiff(oldContent, newContent);\n\n // Create a single paragraph with all diff nodes\n const paragraphNode = $createParagraphNode();\n\n for (const { text, type } of diffResult) {\n const textNode = new DiffTextNode(text);\n textNode.setDiffType(type);\n paragraphNode.append(textNode);\n }\n\n root.append(paragraphNode);\n });\n }, [oldContent, newContent, editor]);\n\n return null;\n};\n\ninterface DiffEditorProps {\n newContent: string;\n oldContent: string;\n}\n\nexport const DiffView = ({\n oldContent,\n newContent,\n}: ReadonlyNativeSurface<DiffEditorProps>): React.JSX.Element => {\n const initialConfig = {\n ...createEditorConfig(),\n editable: false,\n nodes: [DiffTextNode],\n };\n\n return (\n <div className=\"prose dark:prose-invert relative w-full text-left\">\n <LexicalComposer initialConfig={initialConfig}>\n <RichTextPlugin\n contentEditable={\n <ContentEditable className=\"lexical-editor text-left outline-hidden\" />\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <DiffContentPlugin newContent={newContent} oldContent={oldContent} />\n </LexicalComposer>\n </div>\n );\n};\n",
|
|
65
|
+
"type": "registry:file",
|
|
66
|
+
"target": "~/tools/chatjs/text-documents/diffview.tsx"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"path": "src/tools/text-documents/editor-config.ts",
|
|
70
|
+
"content": "import { $convertToMarkdownString, TRANSFORMERS } from \"@lexical/markdown\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport type { EditorState, LexicalEditor } from \"lexical\";\nimport { HeadingNode, QuoteNode } from \"@lexical/rich-text\";\nimport { ListItemNode, ListNode } from \"@lexical/list\";\nimport { LinkNode } from \"@lexical/link\";\n\nconst DOCUMENT_NODE_CLASSES = [\n HeadingNode,\n ListNode,\n ListItemNode,\n QuoteNode,\n CodeNode,\n CodeHighlightNode,\n LinkNode,\n];\ninterface DocumentEditorConfig {\n namespace: string;\n nodes: typeof DOCUMENT_NODE_CLASSES;\n onError: (error: Readonly<Error>) => void;\n}\n\n// Create initial editor configuration with a fresh node collection for each editor.\nconst createEditorConfig = (): DocumentEditorConfig => ({\n namespace: \"DocumentEditor\",\n nodes: [...DOCUMENT_NODE_CLASSES],\n onError: (error: Readonly<Error>): void => {\n console.error(\"Lexical error:\", error);\n },\n});\n\nconst handleEditorChange = ({\n editorState: _editorState,\n editor,\n onSaveContent,\n}: Readonly<{\n editorState: Readonly<Pick<EditorState, \"read\">>;\n editor: Readonly<Pick<LexicalEditor, \"getEditorState\">>;\n onSaveContent: (updatedContent: string, debounce: boolean) => void;\n}>): void => {\n let updatedContent = \"\";\n\n editor.getEditorState().read((): void => {\n updatedContent = $convertToMarkdownString(TRANSFORMERS);\n });\n\n // Check if this should be debounced (similar to ProseMirror's no-debounce meta)\n // Default to debounced saving\n const shouldDebounce = true;\n\n onSaveContent(updatedContent, shouldDebounce);\n};\nexport { createEditorConfig, handleEditorChange };\n",
|
|
71
|
+
"type": "registry:file",
|
|
72
|
+
"target": "~/tools/chatjs/text-documents/editor-config.ts"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"path": "dist/source/text-documents.json",
|
|
76
|
+
"content": "{\n \"config\": { \"key\": \"text\" },\n \"documentActions\": true,\n \"documentKind\": \"text\",\n \"envRequirements\": [],\n \"id\": \"text-documents\",\n \"kind\": \"tool\",\n \"requiresTools\": [\"readDocument\"],\n \"tools\": [\n {\n \"composer\": { \"icon\": \"Edit3\", \"name\": \"Canvas\", \"shortName\": \"Canvas\" },\n \"toolExport\": \"createTextDocument\"\n },\n {\n \"composer\": { \"icon\": \"Edit3\", \"name\": \"Canvas\", \"shortName\": \"Canvas\" },\n \"toolExport\": \"editTextDocument\"\n }\n ],\n \"contractVersion\": 2,\n \"uiBase\": \"base\"\n}\n",
|
|
77
|
+
"type": "registry:file",
|
|
78
|
+
"target": "~/tools/chatjs/text-documents/chatjs.json"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"meta": {
|
|
82
|
+
"chatjs": {
|
|
83
|
+
"config": {
|
|
84
|
+
"key": "text"
|
|
85
|
+
},
|
|
86
|
+
"documentActions": true,
|
|
87
|
+
"documentKind": "text",
|
|
88
|
+
"envRequirements": [],
|
|
89
|
+
"id": "text-documents",
|
|
90
|
+
"kind": "tool",
|
|
91
|
+
"requiresTools": [
|
|
92
|
+
"readDocument"
|
|
93
|
+
],
|
|
94
|
+
"tools": [
|
|
95
|
+
{
|
|
96
|
+
"composer": {
|
|
97
|
+
"icon": "Edit3",
|
|
98
|
+
"name": "Canvas",
|
|
99
|
+
"shortName": "Canvas"
|
|
100
|
+
},
|
|
101
|
+
"toolExport": "createTextDocument"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"composer": {
|
|
105
|
+
"icon": "Edit3",
|
|
106
|
+
"name": "Canvas",
|
|
107
|
+
"shortName": "Canvas"
|
|
108
|
+
},
|
|
109
|
+
"toolExport": "editTextDocument"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"contractVersion": 2,
|
|
113
|
+
"uiBase": "base"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"type": "registry:item"
|
|
117
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "tigris-storage",
|
|
4
|
+
"title": "Tigris",
|
|
5
|
+
"description": "Tigris globally-distributed object storage via the S3-compatible API. Fixed global endpoint, region defaults to auto.",
|
|
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/tigris/storage-provider.ts",
|
|
15
|
+
"content": "export { tigris as createStorageAdapter } from \"files-sdk/tigris\";\n",
|
|
16
|
+
"type": "registry:file",
|
|
17
|
+
"target": "~/lib/storage-provider.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket"
|
|
24
|
+
],
|
|
25
|
+
"contractVersion": 1,
|
|
26
|
+
"envRequirements": [
|
|
27
|
+
{
|
|
28
|
+
"description": "Tigris credentials",
|
|
29
|
+
"options": [
|
|
30
|
+
[
|
|
31
|
+
"TIGRIS_ACCESS_KEY_ID",
|
|
32
|
+
"TIGRIS_SECRET_ACCESS_KEY"
|
|
33
|
+
]
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"id": "tigris",
|
|
38
|
+
"kind": "storage",
|
|
39
|
+
"optionalEnv": []
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"type": "registry:item"
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "uploadthing-storage",
|
|
4
|
+
"title": "UploadThing",
|
|
5
|
+
"description": "UploadThing via uploadthing/server. Maps user-supplied keys onto UploadThing's customId.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"files-sdk@2.5.0",
|
|
8
|
+
"uploadthing@^7"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/storage/uploadthing/storage-provider.ts",
|
|
13
|
+
"content": "export { uploadthing as createStorageAdapter } from \"files-sdk/uploadthing\";\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/lib/storage-provider.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"chatjs": {
|
|
20
|
+
"configKeys": [],
|
|
21
|
+
"contractVersion": 1,
|
|
22
|
+
"envRequirements": [
|
|
23
|
+
{
|
|
24
|
+
"description": "UploadThing credentials",
|
|
25
|
+
"options": [
|
|
26
|
+
[
|
|
27
|
+
"UPLOADTHING_TOKEN"
|
|
28
|
+
]
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"id": "uploadthing",
|
|
33
|
+
"kind": "storage",
|
|
34
|
+
"optionalEnv": []
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"type": "registry:item"
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-analytics",
|
|
4
|
+
"description": "Vercel Web Analytics",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@vercel/analytics@^1.5.0"
|
|
7
|
+
],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/plugins/vercel-analytics/src/component.tsx",
|
|
11
|
+
"content": "import { Analytics } from \"@vercel/analytics/next\";\n\nimport type { InstalledLayoutComponent } from \"@/lib/installation-contracts\";\n\nexport const Component = Analytics satisfies InstalledLayoutComponent;\n",
|
|
12
|
+
"type": "registry:file",
|
|
13
|
+
"target": "~/plugins/vercel-analytics/component.tsx"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "src/plugins/vercel-analytics/src/client-plugin.ts",
|
|
17
|
+
"content": "import type { ChatClientPlugin } from \"@/lib/plugin-contracts\";\nimport { Component } from \"./component\";\n\nexport const vercelAnalyticsClient = () =>\n ({ id: \"vercel-analytics\", layout: Component }) satisfies ChatClientPlugin;\n",
|
|
18
|
+
"type": "registry:file",
|
|
19
|
+
"target": "~/plugins/vercel-analytics/client-plugin.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "dist/source/vercel-analytics.json",
|
|
23
|
+
"content": "{\n \"id\": \"vercel-analytics\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/vercel-analytics/component.tsx\",\n \"plugins/vercel-analytics/client-plugin.ts\"\n ],\n \"client\": {\n \"export\": \"vercelAnalyticsClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"layout\": true\n },\n \"contractVersion\": 1\n}\n",
|
|
24
|
+
"type": "registry:file",
|
|
25
|
+
"target": "~/plugins/vercel-analytics/chatjs.json"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"meta": {
|
|
29
|
+
"chatjs": {
|
|
30
|
+
"id": "vercel-analytics",
|
|
31
|
+
"kind": "plugin",
|
|
32
|
+
"files": [
|
|
33
|
+
"plugins/vercel-analytics/component.tsx",
|
|
34
|
+
"plugins/vercel-analytics/client-plugin.ts"
|
|
35
|
+
],
|
|
36
|
+
"client": {
|
|
37
|
+
"export": "vercelAnalyticsClient",
|
|
38
|
+
"composerControls": [],
|
|
39
|
+
"settingsItems": [],
|
|
40
|
+
"layout": true
|
|
41
|
+
},
|
|
42
|
+
"contractVersion": 1
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"type": "registry:item"
|
|
46
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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": "~/lib/storage-provider.ts"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"meta": {
|
|
19
|
+
"chatjs": {
|
|
20
|
+
"configKeys": [],
|
|
21
|
+
"contractVersion": 1,
|
|
22
|
+
"envRequirements": [
|
|
23
|
+
{
|
|
24
|
+
"description": "Vercel Blob credentials",
|
|
25
|
+
"options": [
|
|
26
|
+
[
|
|
27
|
+
"BLOB_READ_WRITE_TOKEN"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"VERCEL_OIDC_TOKEN",
|
|
31
|
+
"BLOB_STORE_ID"
|
|
32
|
+
]
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"id": "vercel-blob",
|
|
37
|
+
"kind": "storage",
|
|
38
|
+
"optionalEnv": []
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"type": "registry:item"
|
|
42
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-gateway",
|
|
4
|
+
"title": "VercelGateway",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@chat-js/gateways@0.2.0",
|
|
7
|
+
"@ai-sdk/gateway@4.0.110"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
{
|
|
11
|
+
"path": "src/gateways/vercel/gateway.ts",
|
|
12
|
+
"content": "import type {\n Experimental_VideoModelV4,\n LanguageModelV4,\n} from \"@ai-sdk/provider\";\nimport {\n aiGatewayModelDiscriminatorSchema,\n aiGatewayModelSchema,\n aiGatewayModelsEnvelopeSchema,\n isAiGatewayModelType,\n} from \"@chat-js/gateways/models\";\nimport type { AiGatewayModel } from \"@chat-js/gateways/models\";\nimport type { GatewayProvider } from \"@chat-js/gateways/gateway-provider\";\nimport { GatewayRuntime } from \"@chat-js/gateways/runtime\";\nimport type { ImageModel } from \"ai\";\n\nimport { createGateway } from \"@ai-sdk/gateway\";\nimport type { gateway } from \"@ai-sdk/gateway\";\n\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;\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 getApiKey(): string | undefined {\n const apiKey = this.env.AI_GATEWAY_API_KEY;\n\n if (typeof apiKey === \"string\" && apiKey !== \"\") {\n return apiKey;\n }\n return this.env.VERCEL_OIDC_TOKEN;\n }\n\n public async fetchModels(): Promise<AiGatewayModel[]> {\n const apiKey = this.getApiKey();\n\n if (!(typeof apiKey === \"string\" && apiKey !== \"\")) {\n this.log.warn(\"No AI gateway API key found, using fallback models\");\n return [...this.getFallbackModels(this.type)];\n }\n\n const url = \"https://ai-gateway.vercel.sh/v1/models\";\n this.log.debug({ url }, \"Fetching models from Vercel AI Gateway\");\n\n try {\n const response = await this.fetch(url, {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n },\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(`Failed to fetch models: ${response.statusText}`);\n }\n\n const bodyRaw: unknown = await response.json();\n const body = aiGatewayModelsEnvelopeSchema.parse(bodyRaw);\n const unsupportedTypes = new Set<string>();\n const models: AiGatewayModel[] = [];\n\n for (const candidate of body.data) {\n const { type } = aiGatewayModelDiscriminatorSchema.parse(candidate);\n if (isAiGatewayModelType(type)) {\n const model = aiGatewayModelSchema.parse(candidate);\n models.push({ ...model, type });\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 } catch (error) {\n this.log.error(\n { err: error, url },\n \"Error fetching models from Vercel AI Gateway, falling back to generated models\"\n );\n return [...this.getFallbackModels(this.type)];\n }\n }\n}\nexport { VercelGateway as Gateway, VercelGateway };\n",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"target": "~/lib/ai/gateway.ts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"meta": {
|
|
18
|
+
"chatjs": {
|
|
19
|
+
"capabilities": {
|
|
20
|
+
"image": true,
|
|
21
|
+
"video": true
|
|
22
|
+
},
|
|
23
|
+
"contractVersion": 1,
|
|
24
|
+
"defaults": {
|
|
25
|
+
"anonymousModels": [
|
|
26
|
+
"google/gemini-2.5-flash-lite",
|
|
27
|
+
"openai/gpt-5-nano"
|
|
28
|
+
],
|
|
29
|
+
"curatedDefaults": [
|
|
30
|
+
"openai/gpt-5-nano",
|
|
31
|
+
"openai/gpt-5-mini",
|
|
32
|
+
"openai/gpt-5.2",
|
|
33
|
+
"google/gemini-2.5-flash-lite",
|
|
34
|
+
"google/gemini-3-flash",
|
|
35
|
+
"google/gemini-3.1-pro-preview",
|
|
36
|
+
"anthropic/claude-sonnet-4.5",
|
|
37
|
+
"anthropic/claude-opus-4.5"
|
|
38
|
+
],
|
|
39
|
+
"disabledModels": [],
|
|
40
|
+
"providerOrder": [
|
|
41
|
+
"openai",
|
|
42
|
+
"google",
|
|
43
|
+
"anthropic"
|
|
44
|
+
],
|
|
45
|
+
"roles": {
|
|
46
|
+
"fast": "google/gemini-2.5-flash-lite",
|
|
47
|
+
"balanced": "openai/gpt-5-mini",
|
|
48
|
+
"smart": "google/gemini-3-flash",
|
|
49
|
+
"image": "google/gemini-3-pro-image",
|
|
50
|
+
"video": "xai/grok-imagine-video"
|
|
51
|
+
},
|
|
52
|
+
"workflows": {
|
|
53
|
+
"chat": "openai/gpt-5-mini",
|
|
54
|
+
"chatImageCompatible": "openai/gpt-4o-mini",
|
|
55
|
+
"pdf": "openai/gpt-5-mini",
|
|
56
|
+
"title": "openai/gpt-5-nano"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"envRequirements": [
|
|
60
|
+
{
|
|
61
|
+
"options": [
|
|
62
|
+
[
|
|
63
|
+
"AI_GATEWAY_API_KEY"
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"VERCEL_OIDC_TOKEN"
|
|
67
|
+
]
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"id": "vercel",
|
|
72
|
+
"kind": "gateway",
|
|
73
|
+
"optionalEnv": []
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"type": "registry:item"
|
|
77
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-sandbox",
|
|
4
|
+
"title": "Vercel Sandbox",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@chat-js/sandboxes@0.2.0",
|
|
7
|
+
"@vercel/sandbox@3.3.0",
|
|
8
|
+
"@vercel/oidc@3.2.0"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/sandboxes/vercel/provider.ts",
|
|
13
|
+
"content": "import { createPersistentProvider } from \"./persistent\";\nimport type { SandboxProvider } from \"@chat-js/sandboxes/provider\";\nimport {\n createCleanupSession,\n createSandbox,\n getSandboxImage,\n resolveSandboxAuth,\n} from \"./adapter\";\n\nexport const createSandboxProvider = (): SandboxProvider => {\n const auth = resolveSandboxAuth();\n const cleanup = createCleanupSession(auth);\n return {\n persistent: createPersistentProvider(auth),\n scope: {\n providerId: \"vercel\",\n accountId: auth.teamId,\n scopeId: auth.projectId,\n },\n create: async ({ name, runtime, signal }) =>\n await createSandbox(getSandboxImage(runtime), signal, name, auth),\n deleteAndConfirmAbsent: cleanup.deleteAndConfirmAbsent,\n };\n};\n\n/** Available without resolving provider credentials. */\nexport const supportsPersistentSandbox = true;\n",
|
|
14
|
+
"type": "registry:file",
|
|
15
|
+
"target": "~/lib/sandbox/provider.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "src/sandboxes/vercel/vercel-sandbox-env.ts",
|
|
19
|
+
"content": "import { z } from \"zod\";\n\nconst environmentSchema = z.object({\n VERCEL_TEAM_ID: z.string().optional(),\n VERCEL_PROJECT_ID: z.string().optional(),\n VERCEL_TOKEN: z.string().optional(),\n});\n\nconst readSandboxEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n) => environmentSchema.parse(environment);\n\nconst imageEnvironmentSchema = z.object({\n VERCEL_SANDBOX_IMAGE_JAVASCRIPT: z.string().nonempty().optional(),\n VERCEL_SANDBOX_IMAGE_PYTHON: z.string().nonempty().optional(),\n});\n\nconst readSandboxImageEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n) => imageEnvironmentSchema.parse(environment);\n\nexport { readSandboxEnvironment, readSandboxImageEnvironment };\n",
|
|
20
|
+
"type": "registry:file",
|
|
21
|
+
"target": "~/lib/sandbox/vercel-sandbox-env.ts"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "src/sandboxes/vercel/adapter.ts",
|
|
25
|
+
"content": "import type { SandboxProvider } from \"@chat-js/sandboxes/provider\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { getVercelOidcTokenSync } from \"@vercel/oidc\";\nimport { APIError, Sandbox } from \"@vercel/sandbox\";\nimport {\n readSandboxEnvironment,\n readSandboxImageEnvironment,\n} from \"./vercel-sandbox-env\";\nimport { createModuleLogger } from \"@/lib/logger\";\n\ntype SupportedExecutionLanguage = \"python\" | \"javascript\";\n\nconst JWT_PART_COUNT = 3;\nconst JWT_PAYLOAD_INDEX = 1;\nconst SANDBOX_VCPUS = 2;\nconst SANDBOX_TIMEOUT_MS = 300_000;\nconst CLEANUP_TIMEOUT_MS = 30_000;\nconst LOOKUP_TIMEOUT_MS = 15_000;\nconst NOT_FOUND_STATUS = 404;\n\ninterface SandboxAuth {\n projectId: string;\n teamId: string;\n token: string;\n}\n\nconst tokenClaims = (\n token: string\n): { projectId: string; teamId: string } | undefined => {\n const parts = token.split(\".\");\n if (parts.length !== JWT_PART_COUNT) {\n return undefined;\n }\n let payload: unknown;\n try {\n payload = JSON.parse(\n Buffer.from(parts[JWT_PAYLOAD_INDEX] ?? \"\", \"base64url\").toString(\"utf-8\")\n );\n } catch {\n throw new Error(\"Sandbox provider identity is unavailable.\");\n }\n if (\n !(\n payload !== null &&\n typeof payload === \"object\" &&\n \"owner_id\" in payload &&\n \"project_id\" in payload\n )\n ) {\n throw new Error(\"Sandbox provider identity is unavailable.\");\n }\n if (\n typeof payload.owner_id !== \"string\" ||\n !payload.owner_id ||\n typeof payload.project_id !== \"string\" ||\n !payload.project_id\n ) {\n throw new Error(\"Sandbox provider identity is unavailable.\");\n }\n return { projectId: payload.project_id, teamId: payload.owner_id };\n};\n\nconst getTokenAuth = (): Partial<SandboxAuth> => {\n const { VERCEL_TEAM_ID, VERCEL_PROJECT_ID, VERCEL_TOKEN } =\n readSandboxEnvironment();\n if (\n typeof VERCEL_TEAM_ID === \"string\" &&\n VERCEL_TEAM_ID !== \"\" &&\n typeof VERCEL_PROJECT_ID === \"string\" &&\n VERCEL_PROJECT_ID !== \"\" &&\n typeof VERCEL_TOKEN === \"string\" &&\n VERCEL_TOKEN !== \"\"\n ) {\n return {\n projectId: VERCEL_PROJECT_ID,\n teamId: VERCEL_TEAM_ID,\n token: VERCEL_TOKEN,\n };\n }\n return {};\n};\n\n/**\n * Resolve the exact provider scope before a durable allocation is reserved.\n * @returns {SandboxAuth} Provider credentials bound to one project and team.\n */\nconst resolveSandboxAuth = (): SandboxAuth => {\n const configured = getTokenAuth();\n if (\n typeof configured.projectId === \"string\" &&\n configured.projectId !== \"\" &&\n typeof configured.teamId === \"string\" &&\n configured.teamId !== \"\" &&\n typeof configured.token === \"string\" &&\n configured.token !== \"\"\n ) {\n const identity = tokenClaims(configured.token);\n if (\n identity &&\n (identity.projectId !== configured.projectId ||\n identity.teamId !== configured.teamId)\n ) {\n throw new Error(\n \"Sandbox token and configured provider scope do not match.\"\n );\n }\n return {\n projectId: configured.projectId,\n teamId: configured.teamId,\n token: configured.token,\n };\n }\n // Vercel supplies production tokens through the current request context.\n let token: string;\n try {\n token = getVercelOidcTokenSync();\n } catch {\n throw new Error(\"Sandbox provider identity is unavailable.\");\n }\n const identity = token ? tokenClaims(token) : undefined;\n if (!(identity && token)) {\n throw new Error(\"Sandbox provider identity is unavailable.\");\n }\n return { ...identity, token };\n};\n\nconst getSandboxImage = (language: SupportedExecutionLanguage): string => {\n const images = readSandboxImageEnvironment();\n if (language === \"javascript\") {\n return images.VERCEL_SANDBOX_IMAGE_JAVASCRIPT ?? \"vercel/sandbox/node:22\";\n }\n\n return images.VERCEL_SANDBOX_IMAGE_PYTHON ?? \"vercel/sandbox/python:3.14\";\n};\n\nconst createSandbox = async (\n image: string,\n signal?: ReadonlyNativeSurface<AbortSignal>,\n name?: string,\n auth?: Readonly<SandboxAuth>\n): Promise<Sandbox> =>\n await Sandbox.create({\n name,\n persistent: false,\n resources: { vcpus: SANDBOX_VCPUS },\n image,\n signal,\n timeout: SANDBOX_TIMEOUT_MS,\n ...(auth ?? getTokenAuth()),\n });\n\nconst cleanupSandbox = async (\n sandbox: Pick<Sandbox, \"delete\" | \"stop\"> | undefined,\n log: Pick<ReturnType<typeof createModuleLogger>, \"info\" | \"warn\">,\n requestId: string\n): Promise<void> => {\n if (!sandbox) {\n return;\n }\n try {\n try {\n await sandbox.stop({ signal: AbortSignal.timeout(CLEANUP_TIMEOUT_MS) });\n } finally {\n await sandbox.delete({\n deleteOrphanSnapshots: true,\n signal: AbortSignal.timeout(CLEANUP_TIMEOUT_MS),\n });\n }\n log.info({ requestId }, \"sandbox closed\");\n } catch (closeError) {\n log.warn({ closeError, requestId }, \"failed to close sandbox\");\n throw closeError;\n }\n};\n\nconst findSandboxForCleanup = async (\n name: string,\n auth: Readonly<SandboxAuth>\n): Promise<Sandbox | undefined> => {\n try {\n return await Sandbox.get({\n name,\n resume: false,\n signal: AbortSignal.timeout(LOOKUP_TIMEOUT_MS),\n ...auth,\n });\n } catch (error) {\n if (\n error instanceof APIError &&\n error.response.status === NOT_FOUND_STATUS\n ) {\n return undefined;\n }\n throw error;\n }\n};\n\nconst createCleanupSession = (\n auth: SandboxAuth = resolveSandboxAuth()\n): {\n deleteAndConfirmAbsent: SandboxProvider[\"deleteAndConfirmAbsent\"];\n provider: SandboxAuth;\n} => {\n const log = createModuleLogger(\"eve-code-sandbox-cleanup\");\n return {\n async deleteAndConfirmAbsent(name): Promise<void> {\n const sandbox = await findSandboxForCleanup(name, auth);\n if (sandbox) {\n if (sandbox.name !== name || sandbox.persistent) {\n throw new Error(\n \"Code sandbox identity or persistence needs reconciliation.\"\n );\n }\n await cleanupSandbox(sandbox, log, name);\n if (await findSandboxForCleanup(name, auth)) {\n throw new Error(\"Code sandbox remains available after deletion.\");\n }\n }\n },\n provider: auth,\n };\n};\n\nexport {\n cleanupSandbox,\n createCleanupSession,\n createSandbox,\n getSandboxImage,\n getTokenAuth,\n resolveSandboxAuth,\n};\nexport type { SandboxAuth };\n",
|
|
26
|
+
"type": "registry:file",
|
|
27
|
+
"target": "~/lib/sandbox/adapter.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "src/sandboxes/vercel/persistent.ts",
|
|
31
|
+
"content": "import type {\n PersistentSandbox,\n PersistentSandboxProvider,\n} from \"@chat-js/sandboxes/persistent\";\nimport { APIError, Sandbox } from \"@vercel/sandbox\";\nimport pathModule from \"node:path\";\nimport type { SandboxAuth } from \"./adapter\";\n\nconst { posix } = pathModule;\n\nconst OPERATION_TIMEOUT_MS = 30_000;\nconst SESSION_TIMEOUT_MS = 1_800_000;\nconst NOT_FOUND = 404;\nconst resolvePath = (path: string): string => posix.resolve(\"/workspace\", path);\nconst signal = (upstream?: AbortSignal): AbortSignal =>\n AbortSignal.any([\n AbortSignal.timeout(OPERATION_TIMEOUT_MS),\n ...(upstream ? [upstream] : []),\n ]);\n\nconst session = (sandbox: Sandbox): PersistentSandbox => {\n const read: PersistentSandbox[\"readBinaryFile\"] = async (options) =>\n await sandbox.readFileToBuffer(\n { path: resolvePath(options.path) },\n { signal: signal(options.abortSignal) }\n );\n const write: PersistentSandbox[\"writeBinaryFile\"] = async (options) => {\n const path = resolvePath(options.path);\n await sandbox.fs.mkdir(posix.dirname(path), {\n recursive: true,\n signal: signal(options.abortSignal),\n });\n await sandbox.writeFiles(\n [{ path, content: Buffer.from(options.content) }],\n { signal: signal(options.abortSignal) }\n );\n };\n return {\n name: sandbox.name,\n resolvePath,\n readBinaryFile: read,\n writeBinaryFile: write,\n async readFile(options) {\n const bytes = await read(options);\n return bytes === null\n ? null\n : new ReadableStream({\n start(controller) {\n controller.enqueue(bytes);\n controller.close();\n },\n });\n },\n async readTextFile(options) {\n const bytes = await read(options);\n if (bytes === null) {\n return null;\n }\n const text = new TextDecoder(options.encoding ?? \"utf-8\", {\n fatal: true,\n }).decode(bytes);\n if (options.startLine === undefined && options.endLine === undefined) {\n return text;\n }\n return text\n .split(\"\\n\")\n .slice(Math.max(0, (options.startLine ?? 1) - 1), options.endLine)\n .join(\"\\n\");\n },\n async writeFile(options) {\n const bytes = new Uint8Array(\n await new Response(options.content).arrayBuffer()\n );\n await write({ ...options, content: bytes });\n },\n async writeTextFile(options) {\n const encoding = options.encoding ?? \"utf-8\";\n if (!Buffer.isEncoding(encoding)) {\n throw new Error(\"Unsupported sandbox text encoding.\");\n }\n await write({\n ...options,\n content: Buffer.from(options.content, encoding),\n });\n },\n async removePath(options) {\n await sandbox.fs.rm(resolvePath(options.path), {\n force: options.force,\n recursive: options.recursive,\n signal: signal(options.abortSignal),\n });\n },\n async run(options) {\n const deadline = signal(options.abortSignal);\n const result = await sandbox.runCommand({\n cmd: \"bash\",\n args: [\"-lc\", options.command],\n cwd: resolvePath(options.workingDirectory ?? \".\"),\n env: options.env,\n signal: deadline,\n });\n const [stdout, stderr] = await Promise.all([\n result.stdout({ signal: deadline }),\n result.stderr({ signal: deadline }),\n ]);\n return { exitCode: result.exitCode, stdout, stderr };\n },\n async spawn(options) {\n const command = await sandbox.runCommand({\n cmd: \"bash\",\n args: [\"-lc\", options.command],\n cwd: resolvePath(options.workingDirectory ?? \".\"),\n env: options.env,\n signal: signal(options.abortSignal),\n detached: true,\n });\n // Read remote output only on consumer demand; the app fences every pull.\n const logs = command.logs({ signal: signal(options.abortSignal) });\n const iterator = logs[Symbol.asyncIterator]();\n const buffers: Record<\"stdout\" | \"stderr\", string[]> = {\n stdout: [],\n stderr: [],\n };\n const cancelled = { stdout: false, stderr: false };\n let done = false;\n let pending: Promise<void> | undefined;\n const advance = async (): Promise<void> => {\n pending ??= (async () => {\n const next = await iterator.next();\n if (next.done === true) {\n done = true;\n } else if (!cancelled[next.value.stream]) {\n buffers[next.value.stream].push(next.value.data);\n }\n })();\n const current = pending;\n try {\n await current;\n } finally {\n if (pending === current) {\n pending = undefined;\n }\n }\n };\n const encoder = new TextEncoder();\n const output = (\n target: \"stdout\" | \"stderr\"\n ): ReadableStream<Uint8Array> =>\n new ReadableStream(\n {\n async pull(controller) {\n while (buffers[target].length === 0) {\n if (done) {\n break;\n }\n // oxlint-disable-next-line eslint/no-await-in-loop -- Preserve multiplexed output order until this consumer has a chunk.\n await advance();\n }\n const chunk = buffers[target].shift();\n if (chunk === undefined) {\n controller.close();\n } else {\n controller.enqueue(encoder.encode(chunk));\n }\n },\n async cancel() {\n cancelled[target] = true;\n buffers[target] = [];\n if (cancelled.stdout && cancelled.stderr) {\n await iterator.return?.();\n }\n },\n },\n { highWaterMark: 0 }\n );\n const stdout = output(\"stdout\");\n const stderr = output(\"stderr\");\n return {\n stdout,\n stderr,\n async wait() {\n const result = await command.wait({\n signal: signal(options.abortSignal),\n });\n return { exitCode: result.exitCode };\n },\n async kill() {\n await command.kill(undefined, { abortSignal: signal() });\n },\n };\n },\n };\n};\n\n/** The original credential scope must be verified by the durable owner before use. */\nexport const createPersistentProvider = (\n auth: SandboxAuth\n): PersistentSandboxProvider => {\n const find = async (name: string): Promise<Sandbox | null> => {\n try {\n const sandbox = await Sandbox.get({\n name,\n resume: false,\n signal: signal(),\n ...auth,\n });\n if (sandbox.name !== name || !sandbox.persistent) {\n throw new Error(\"Persistent sandbox identity mismatch.\");\n }\n return sandbox;\n } catch (error) {\n if (error instanceof APIError && error.response.status === NOT_FOUND) {\n return null;\n }\n throw error;\n }\n };\n return {\n async create({ name, signal: abortSignal }) {\n const sandbox = await Sandbox.create({\n name,\n persistent: true,\n image: \"vcr.vercel.com/vercel/eve/base:0.80.1\",\n timeout: SESSION_TIMEOUT_MS,\n signal: signal(abortSignal),\n ...auth,\n });\n if (sandbox.name !== name || !sandbox.persistent) {\n throw new Error(\"Persistent sandbox identity mismatch.\");\n }\n return session(sandbox);\n },\n async open(name) {\n const sandbox = await find(name);\n if (sandbox === null) {\n throw new Error(\n \"Persistent sandbox is missing; replacement is forbidden.\"\n );\n }\n return session(sandbox);\n },\n async stop(name) {\n const sandbox = await find(name);\n if (sandbox !== null) {\n await sandbox.stop({ signal: signal() });\n }\n },\n async deleteAndConfirmAbsent(name) {\n const sandbox = await find(name);\n if (sandbox !== null) {\n await sandbox.delete({ deleteOrphanSnapshots: true, signal: signal() });\n }\n if (await find(name)) {\n throw new Error(\"Persistent sandbox deletion is unconfirmed.\");\n }\n },\n };\n};\n",
|
|
32
|
+
"type": "registry:file",
|
|
33
|
+
"target": "~/lib/sandbox/persistent.ts"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"meta": {
|
|
37
|
+
"chatjs": {
|
|
38
|
+
"contractVersion": 1,
|
|
39
|
+
"kind": "sandbox",
|
|
40
|
+
"id": "vercel",
|
|
41
|
+
"capabilities": {
|
|
42
|
+
"runtimes": [
|
|
43
|
+
"python",
|
|
44
|
+
"javascript"
|
|
45
|
+
],
|
|
46
|
+
"cleanup": "durable-allocation",
|
|
47
|
+
"cancellation": "terminate"
|
|
48
|
+
},
|
|
49
|
+
"envRequirements": [
|
|
50
|
+
{
|
|
51
|
+
"options": [
|
|
52
|
+
[
|
|
53
|
+
"VERCEL_OIDC_TOKEN"
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"VERCEL_TEAM_ID",
|
|
57
|
+
"VERCEL_PROJECT_ID",
|
|
58
|
+
"VERCEL_TOKEN"
|
|
59
|
+
]
|
|
60
|
+
],
|
|
61
|
+
"runtimeAuth": "vercel-oidc"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"type": "registry:item"
|
|
67
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "vercel-speed-insights",
|
|
4
|
+
"description": "Vercel Speed Insights",
|
|
5
|
+
"dependencies": [
|
|
6
|
+
"@vercel/speed-insights@^1.3.1"
|
|
7
|
+
],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/plugins/vercel-speed-insights/src/component.tsx",
|
|
11
|
+
"content": "import type { InstalledLayoutComponent } from \"@/lib/installation-contracts\";\nimport { SpeedInsights } from \"@vercel/speed-insights/next\";\n\nexport const Component = SpeedInsights satisfies InstalledLayoutComponent;\n",
|
|
12
|
+
"type": "registry:file",
|
|
13
|
+
"target": "~/plugins/vercel-speed-insights/component.tsx"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "src/plugins/vercel-speed-insights/src/client-plugin.ts",
|
|
17
|
+
"content": "import type { ChatClientPlugin } from \"@/lib/plugin-contracts\";\nimport { Component } from \"./component\";\n\nexport const vercelSpeedInsightsClient = () =>\n ({\n id: \"vercel-speed-insights\",\n layout: Component,\n }) satisfies ChatClientPlugin;\n",
|
|
18
|
+
"type": "registry:file",
|
|
19
|
+
"target": "~/plugins/vercel-speed-insights/client-plugin.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "dist/source/vercel-speed-insights.json",
|
|
23
|
+
"content": "{\n \"id\": \"vercel-speed-insights\",\n \"kind\": \"plugin\",\n \"files\": [\n \"plugins/vercel-speed-insights/component.tsx\",\n \"plugins/vercel-speed-insights/client-plugin.ts\"\n ],\n \"client\": {\n \"export\": \"vercelSpeedInsightsClient\",\n \"composerControls\": [],\n \"settingsItems\": [],\n \"layout\": true\n },\n \"contractVersion\": 1\n}\n",
|
|
24
|
+
"type": "registry:file",
|
|
25
|
+
"target": "~/plugins/vercel-speed-insights/chatjs.json"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"meta": {
|
|
29
|
+
"chatjs": {
|
|
30
|
+
"id": "vercel-speed-insights",
|
|
31
|
+
"kind": "plugin",
|
|
32
|
+
"files": [
|
|
33
|
+
"plugins/vercel-speed-insights/component.tsx",
|
|
34
|
+
"plugins/vercel-speed-insights/client-plugin.ts"
|
|
35
|
+
],
|
|
36
|
+
"client": {
|
|
37
|
+
"export": "vercelSpeedInsightsClient",
|
|
38
|
+
"composerControls": [],
|
|
39
|
+
"settingsItems": [],
|
|
40
|
+
"layout": true
|
|
41
|
+
},
|
|
42
|
+
"contractVersion": 1
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"type": "registry:item"
|
|
46
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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": "~/lib/storage-provider.ts"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"meta": {
|
|
21
|
+
"chatjs": {
|
|
22
|
+
"configKeys": [
|
|
23
|
+
"bucket",
|
|
24
|
+
"region"
|
|
25
|
+
],
|
|
26
|
+
"contractVersion": 1,
|
|
27
|
+
"envRequirements": [
|
|
28
|
+
{
|
|
29
|
+
"description": "Vultr Object Storage credentials",
|
|
30
|
+
"options": [
|
|
31
|
+
[
|
|
32
|
+
"VULTR_ACCESS_KEY_ID",
|
|
33
|
+
"VULTR_SECRET_ACCESS_KEY"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"id": "vultr",
|
|
39
|
+
"kind": "storage",
|
|
40
|
+
"optionalEnv": []
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"type": "registry:item"
|
|
44
|
+
}
|