@chat-js/registry 0.2.0-beta.3 → 0.2.0-beta.5
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 +1 -1
- package/dist/r/ai-titles.json +1 -1
- package/dist/r/attach-workspace-file.json +82 -0
- package/dist/r/attachment-uploads.json +1 -2
- package/dist/r/base/ai-titles.json +1 -1
- package/dist/r/base/attach-workspace-file.json +82 -0
- package/dist/r/base/attachment-uploads.json +1 -2
- package/dist/r/base/deep-research.json +46 -123
- package/dist/r/base/default-sandbox.json +35 -0
- package/dist/r/base/docker-sandbox.json +35 -0
- package/dist/r/base/generate-image.json +10 -4
- package/dist/r/base/generate-video.json +9 -3
- package/dist/r/base/guest-chat.json +2 -2
- package/dist/r/base/image-viewer.json +55 -0
- package/dist/r/base/just-bash-sandbox.json +32 -0
- package/dist/r/base/litellm-gateway.json +2 -2
- package/dist/r/base/mcp.json +1 -1
- package/dist/r/base/openai-compatible-gateway.json +2 -2
- package/dist/r/base/openai-gateway.json +2 -2
- package/dist/r/base/openrouter-gateway.json +2 -2
- package/dist/r/base/projects.json +3 -3
- package/dist/r/base/registry.json +970 -1751
- package/dist/r/base/search.json +6 -6
- package/dist/r/base/sharing.json +3 -3
- package/dist/r/base/spreadsheet-grid.json +20 -0
- package/dist/r/base/spreadsheet-viewer.json +68 -0
- package/dist/r/base/vercel-gateway.json +2 -2
- package/dist/r/base/vercel-sandbox.json +8 -26
- package/dist/r/base/video-viewer.json +48 -0
- package/dist/r/deep-research.json +46 -123
- package/dist/r/default-sandbox.json +35 -0
- package/dist/r/docker-sandbox.json +35 -0
- package/dist/r/eve/deep-research.json +47 -0
- package/dist/r/eve/registry.json +53 -0
- package/dist/r/generate-image.json +10 -4
- package/dist/r/generate-video.json +9 -3
- package/dist/r/guest-chat.json +2 -2
- package/dist/r/image-viewer.json +55 -0
- package/dist/r/just-bash-sandbox.json +32 -0
- package/dist/r/litellm-gateway.json +2 -2
- package/dist/r/mcp.json +1 -1
- package/dist/r/openai-compatible-gateway.json +2 -2
- package/dist/r/openai-gateway.json +2 -2
- package/dist/r/openrouter-gateway.json +2 -2
- package/dist/r/projects.json +3 -3
- package/dist/r/radix/ai-titles.json +1 -1
- package/dist/r/radix/attach-workspace-file.json +82 -0
- package/dist/r/radix/attachment-uploads.json +1 -2
- package/dist/r/radix/deep-research.json +46 -123
- package/dist/r/radix/default-sandbox.json +35 -0
- package/dist/r/radix/docker-sandbox.json +35 -0
- package/dist/r/radix/generate-image.json +10 -4
- package/dist/r/radix/generate-video.json +9 -3
- package/dist/r/radix/guest-chat.json +2 -2
- package/dist/r/radix/image-viewer.json +55 -0
- package/dist/r/radix/just-bash-sandbox.json +32 -0
- package/dist/r/radix/litellm-gateway.json +2 -2
- package/dist/r/radix/mcp.json +1 -1
- package/dist/r/radix/openai-compatible-gateway.json +2 -2
- package/dist/r/radix/openai-gateway.json +2 -2
- package/dist/r/radix/openrouter-gateway.json +2 -2
- package/dist/r/radix/projects.json +3 -3
- package/dist/r/radix/registry.json +973 -1754
- package/dist/r/radix/search.json +6 -6
- package/dist/r/radix/sharing.json +3 -3
- package/dist/r/radix/spreadsheet-grid.json +20 -0
- package/dist/r/radix/spreadsheet-viewer.json +68 -0
- package/dist/r/radix/vercel-gateway.json +2 -2
- package/dist/r/radix/vercel-sandbox.json +8 -26
- package/dist/r/radix/video-viewer.json +48 -0
- package/dist/r/registry.json +970 -1751
- package/dist/r/search.json +6 -6
- package/dist/r/sharing.json +3 -3
- package/dist/r/spreadsheet-grid.json +20 -0
- package/dist/r/spreadsheet-viewer.json +68 -0
- package/dist/r/vercel-gateway.json +2 -2
- package/dist/r/vercel-sandbox.json +8 -26
- package/dist/r/video-viewer.json +48 -0
- package/package.json +5 -26
- package/dist/r/base/code-documents.json +0 -101
- package/dist/r/base/code-execution-runtime.json +0 -25
- package/dist/r/base/code-execution-ui.json +0 -32
- package/dist/r/base/code-execution.json +0 -69
- package/dist/r/base/daytona-sandbox.json +0 -55
- package/dist/r/base/delete-document.json +0 -58
- package/dist/r/base/firecrawl-search.json +0 -72
- package/dist/r/base/get-weather.json +0 -59
- package/dist/r/base/langfuse.json +0 -63
- package/dist/r/base/read-document.json +0 -34
- package/dist/r/base/retrieve-url.json +0 -72
- package/dist/r/base/saved-code-execution.json +0 -84
- package/dist/r/base/sheet-documents.json +0 -99
- package/dist/r/base/tavily-search.json +0 -72
- package/dist/r/base/text-documents.json +0 -122
- package/dist/r/base/vercel-analytics.json +0 -46
- package/dist/r/base/vercel-speed-insights.json +0 -46
- package/dist/r/base/word-count.json +0 -58
- package/dist/r/code-documents.json +0 -101
- package/dist/r/code-execution-runtime.json +0 -25
- package/dist/r/code-execution-ui.json +0 -32
- 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 -59
- package/dist/r/langfuse.json +0 -63
- package/dist/r/radix/code-documents.json +0 -101
- package/dist/r/radix/code-execution-runtime.json +0 -25
- package/dist/r/radix/code-execution-ui.json +0 -32
- package/dist/r/radix/code-execution.json +0 -69
- package/dist/r/radix/daytona-sandbox.json +0 -55
- package/dist/r/radix/delete-document.json +0 -58
- package/dist/r/radix/firecrawl-search.json +0 -72
- package/dist/r/radix/get-weather.json +0 -59
- package/dist/r/radix/langfuse.json +0 -63
- package/dist/r/radix/read-document.json +0 -34
- package/dist/r/radix/retrieve-url.json +0 -72
- package/dist/r/radix/saved-code-execution.json +0 -84
- package/dist/r/radix/sheet-documents.json +0 -99
- package/dist/r/radix/tavily-search.json +0 -72
- package/dist/r/radix/text-documents.json +0 -122
- package/dist/r/radix/vercel-analytics.json +0 -46
- package/dist/r/radix/vercel-speed-insights.json +0 -46
- package/dist/r/radix/word-count.json +0 -58
- package/dist/r/read-document.json +0 -34
- package/dist/r/retrieve-url.json +0 -72
- package/dist/r/saved-code-execution.json +0 -84
- package/dist/r/sheet-documents.json +0 -99
- package/dist/r/tavily-search.json +0 -72
- package/dist/r/text-documents.json +0 -122
- package/dist/r/vercel-analytics.json +0 -46
- package/dist/r/vercel-speed-insights.json +0 -46
- package/dist/r/word-count.json +0 -58
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "get-weather",
|
|
4
|
-
"description": "Get the current weather at a location",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"ai@7.0.137",
|
|
7
|
-
"zod@4.5.4",
|
|
8
|
-
"date-fns@^4.1.0"
|
|
9
|
-
],
|
|
10
|
-
"files": [
|
|
11
|
-
{
|
|
12
|
-
"path": "src/tools/get-weather/definition.ts",
|
|
13
|
-
"content": "import type { ToolDefinition } from \"@/chatjs/core/tools/tool-definition\";\nimport { weatherInput, weatherResult } from \"./schemas\";\n\nexport const toolDefinition = {\n name: \"getWeather\",\n description: \"Get the current weather at a location\",\n inputSchema: weatherInput,\n outputSchema: weatherResult,\n display: { name: \"Weather\", shortName: \"Weather\" },\n} as const satisfies ToolDefinition;\n",
|
|
14
|
-
"type": "registry:file",
|
|
15
|
-
"target": "~/chatjs/tools/get-weather/definition.ts"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"path": "src/tools/get-weather/tool.ts",
|
|
19
|
-
"content": "import { toolDefinition } from \"./definition\";\nimport type { weatherInput } from \"./schemas\";\nimport { weatherResult } from \"./schemas\";\nimport type { ToolUsage } from \"@/lib/eve/tool-usage\";\nimport { defineTool } from \"eve/tools\";\nimport { executeWithToolUsage } from \"@/lib/eve/tool-usage\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport type { z } from \"zod\";\n\nconst UNBILLED_TOOL_COST_USD = 0;\n\nexport const getWeather = defineTool({\n description: toolDefinition.description,\n execute: async (\n { latitude, longitude }: Readonly<z.infer<typeof weatherInput>>,\n context: Readonly<{ abortSignal: Readonly<AbortSignal> }>\n ) =>\n await executeWithToolUsage(\n context,\n async (usage: Readonly<Pick<ToolUsage, \"addCostUsd\">>) => {\n const response = await fetch(\n `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m&hourly=temperature_2m&daily=sunrise,sunset&timezone=auto`,\n { signal: context.abortSignal }\n );\n if (!response.ok) {\n throw new Error(\"Weather request failed.\");\n }\n usage.addCostUsd(UNBILLED_TOOL_COST_USD);\n return weatherResult.parse(await response.json());\n }\n ),\n inputSchema: toolDefinition.inputSchema,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
20
|
-
"type": "registry:file",
|
|
21
|
-
"target": "~/chatjs/tools/get-weather/tool.ts"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "src/tools/get-weather/renderer.tsx",
|
|
25
|
-
"content": "\"use client\";\n\nimport { toolDefinition } from \"./definition\";\nimport { format, isWithinInterval } from \"date-fns\";\nimport type { weatherInput, weatherResult } from \"./schemas\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { cn } from \"@/lib/utils\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\nimport { useIsMobile } from \"@/hooks/use-mobile\";\nimport type { z } from \"zod\";\n\ntype WeatherAtLocation = z.output<typeof weatherResult>;\n\ntype GetWeatherRendererTool = ToolRendererProps<\n typeof weatherInput,\n typeof weatherResult\n>[\"tool\"];\n\nconst SAMPLE = {\n current: { interval: 900, temperature_2m: 29.3, time: \"2024-10-07T19:30\" },\n current_units: { interval: \"seconds\", temperature_2m: \"°C\", time: \"iso8601\" },\n daily: {\n sunrise: [\n \"2024-10-07T07:15\",\n \"2024-10-08T07:16\",\n \"2024-10-09T07:17\",\n \"2024-10-10T07:18\",\n \"2024-10-11T07:19\",\n ],\n sunset: [\n \"2024-10-07T19:00\",\n \"2024-10-08T18:58\",\n \"2024-10-09T18:57\",\n \"2024-10-10T18:55\",\n \"2024-10-11T18:54\",\n ],\n time: [\n \"2024-10-07\",\n \"2024-10-08\",\n \"2024-10-09\",\n \"2024-10-10\",\n \"2024-10-11\",\n ],\n },\n daily_units: {\n sunrise: \"iso8601\",\n sunset: \"iso8601\",\n time: \"iso8601\",\n },\n elevation: 18,\n generationtime_ms: Number(\"0.027894973754882812\"),\n hourly: {\n temperature_2m: [\n 36.6, 32.8, 29.5, 28.6, 29.2, 28.2, 27.5, 26.6, 26.5, 26, 25, 23.5, 23.9,\n 24.2, 22.9, 21, 24, 28.1, 31.4, 33.9, 32.1, 28.9, 26.9, 25.2, 23, 21.1,\n 19.6, 18.6, 17.7, 16.8, 16.2, 15.5, 14.9, 14.4, 14.2, 13.7, 13.3, 12.9,\n 12.5, 13.5, 15.8, 17.7, 19.6, 21, 21.9, 22.3, 22, 20.7, 18.9, 17.9, 17.3,\n 17, 16.7, 16.2, 15.6, 15.2, 15, 15, 15.1, 14.8, 14.8, 14.9, 14.7, 14.8,\n 15.3, 16.2, 17.9, 19.6, 20.5, 21.6, 21, 20.7, 19.3, 18.7, 18.4, 17.9,\n 17.3, 17, 17, 16.8, 16.4, 16.2, 16, 15.8, 15.7, 15.4, 15.4, 16.1, 16.7,\n 17, 18.6, 19, 19.5, 19.4, 18.5, 17.9, 17.5, 16.7, 16.3, 16.1,\n ],\n time: [\n \"2024-10-07T00:00\",\n \"2024-10-07T01:00\",\n \"2024-10-07T02:00\",\n \"2024-10-07T03:00\",\n \"2024-10-07T04:00\",\n \"2024-10-07T05:00\",\n \"2024-10-07T06:00\",\n \"2024-10-07T07:00\",\n \"2024-10-07T08:00\",\n \"2024-10-07T09:00\",\n \"2024-10-07T10:00\",\n \"2024-10-07T11:00\",\n \"2024-10-07T12:00\",\n \"2024-10-07T13:00\",\n \"2024-10-07T14:00\",\n \"2024-10-07T15:00\",\n \"2024-10-07T16:00\",\n \"2024-10-07T17:00\",\n \"2024-10-07T18:00\",\n \"2024-10-07T19:00\",\n \"2024-10-07T20:00\",\n \"2024-10-07T21:00\",\n \"2024-10-07T22:00\",\n \"2024-10-07T23:00\",\n \"2024-10-08T00:00\",\n \"2024-10-08T01:00\",\n \"2024-10-08T02:00\",\n \"2024-10-08T03:00\",\n \"2024-10-08T04:00\",\n \"2024-10-08T05:00\",\n \"2024-10-08T06:00\",\n \"2024-10-08T07:00\",\n \"2024-10-08T08:00\",\n \"2024-10-08T09:00\",\n \"2024-10-08T10:00\",\n \"2024-10-08T11:00\",\n \"2024-10-08T12:00\",\n \"2024-10-08T13:00\",\n \"2024-10-08T14:00\",\n \"2024-10-08T15:00\",\n \"2024-10-08T16:00\",\n \"2024-10-08T17:00\",\n \"2024-10-08T18:00\",\n \"2024-10-08T19:00\",\n \"2024-10-08T20:00\",\n \"2024-10-08T21:00\",\n \"2024-10-08T22:00\",\n \"2024-10-08T23:00\",\n \"2024-10-09T00:00\",\n \"2024-10-09T01:00\",\n \"2024-10-09T02:00\",\n \"2024-10-09T03:00\",\n \"2024-10-09T04:00\",\n \"2024-10-09T05:00\",\n \"2024-10-09T06:00\",\n \"2024-10-09T07:00\",\n \"2024-10-09T08:00\",\n \"2024-10-09T09:00\",\n \"2024-10-09T10:00\",\n \"2024-10-09T11:00\",\n \"2024-10-09T12:00\",\n \"2024-10-09T13:00\",\n \"2024-10-09T14:00\",\n \"2024-10-09T15:00\",\n \"2024-10-09T16:00\",\n \"2024-10-09T17:00\",\n \"2024-10-09T18:00\",\n \"2024-10-09T19:00\",\n \"2024-10-09T20:00\",\n \"2024-10-09T21:00\",\n \"2024-10-09T22:00\",\n \"2024-10-09T23:00\",\n \"2024-10-10T00:00\",\n \"2024-10-10T01:00\",\n \"2024-10-10T02:00\",\n \"2024-10-10T03:00\",\n \"2024-10-10T04:00\",\n \"2024-10-10T05:00\",\n \"2024-10-10T06:00\",\n \"2024-10-10T07:00\",\n \"2024-10-10T08:00\",\n \"2024-10-10T09:00\",\n \"2024-10-10T10:00\",\n \"2024-10-10T11:00\",\n \"2024-10-10T12:00\",\n \"2024-10-10T13:00\",\n \"2024-10-10T14:00\",\n \"2024-10-10T15:00\",\n \"2024-10-10T16:00\",\n \"2024-10-10T17:00\",\n \"2024-10-10T18:00\",\n \"2024-10-10T19:00\",\n \"2024-10-10T20:00\",\n \"2024-10-10T21:00\",\n \"2024-10-10T22:00\",\n \"2024-10-10T23:00\",\n \"2024-10-11T00:00\",\n \"2024-10-11T01:00\",\n \"2024-10-11T02:00\",\n \"2024-10-11T03:00\",\n ],\n },\n hourly_units: { temperature_2m: \"°C\", time: \"iso8601\" },\n latitude: 37.763283,\n longitude: -122.41286,\n timezone: \"GMT\",\n timezone_abbreviation: \"GMT\",\n utc_offset_seconds: 0,\n};\n\nconst roundUp = (num: number): number => Math.ceil(num);\n\nconst WeatherCard = ({\n weatherAtLocation,\n}: ReadonlyNativeSurface<{\n weatherAtLocation: WeatherAtLocation;\n}>): React.JSX.Element => {\n const currentHigh = Math.max(\n ...weatherAtLocation.hourly.temperature_2m.slice(0, 24)\n );\n const currentLow = Math.min(\n ...weatherAtLocation.hourly.temperature_2m.slice(0, 24)\n );\n\n const isDay = isWithinInterval(new Date(weatherAtLocation.current.time), {\n end: new Date(weatherAtLocation.daily.sunset[0]),\n start: new Date(weatherAtLocation.daily.sunrise[0]),\n });\n\n const isMobile = useIsMobile();\n const hoursToShow = isMobile ? 5 : 6;\n const currentTimeIndex = weatherAtLocation.hourly.time.findIndex(\n (time): boolean =>\n new Date(time) >= new Date(weatherAtLocation.current.time)\n );\n const displayStartIndex =\n currentTimeIndex === -1\n ? Math.max(0, weatherAtLocation.hourly.time.length - hoursToShow)\n : currentTimeIndex;\n const displayTimes = weatherAtLocation.hourly.time.slice(\n displayStartIndex,\n displayStartIndex + hoursToShow\n );\n const displayTemperatures = weatherAtLocation.hourly.temperature_2m.slice(\n displayStartIndex,\n displayStartIndex + hoursToShow\n );\n\n return (\n <div\n className={cn(\n \"skeleton-bg flex max-w-[500px] flex-col gap-4 rounded-2xl p-4\",\n { \"bg-blue-400\": isDay },\n { \"bg-indigo-900\": !isDay }\n )}\n >\n <div className=\"flex flex-row items-center justify-between\">\n <div className=\"flex flex-row items-center gap-2\">\n <div\n className={cn(\n \"skeleton-div size-10 rounded-full\",\n { \"bg-yellow-300\": isDay },\n { \"bg-indigo-100\": !isDay }\n )}\n />\n <div className=\"text-4xl font-medium text-blue-50\">\n {roundUp(weatherAtLocation.current.temperature_2m)}\n {weatherAtLocation.current_units.temperature_2m}\n </div>\n </div>\n\n <div className=\"text-blue-50\">{`H:${roundUp(currentHigh)}° L:${roundUp(currentLow)}°`}</div>\n </div>\n\n <div className=\"flex flex-row justify-between\">\n {displayTimes.map((time, index) => (\n <div className=\"flex flex-col items-center gap-1\" key={time}>\n <div className=\"text-xs text-blue-100\">\n {format(new Date(time), \"ha\")}\n </div>\n <div\n className={cn(\n \"skeleton-div size-6 rounded-full\",\n { \"bg-yellow-300\": isDay },\n { \"bg-indigo-200\": !isDay }\n )}\n />\n <div className=\"text-sm text-blue-50\">\n {roundUp(displayTemperatures[index])}\n {weatherAtLocation.hourly_units.temperature_2m}\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n};\n\nconst GetWeatherView = ({\n tool,\n}: ReadonlyNativeSurface<{\n tool: GetWeatherRendererTool;\n messageId: string;\n isReadonly: boolean;\n}>): React.JSX.Element => {\n if (tool.state !== \"output-available\") {\n return (\n <div className=\"skeleton\" key={tool.toolCallId}>\n <WeatherCard weatherAtLocation={SAMPLE} />\n </div>\n );\n }\n\n if (tool.output === undefined) {\n return <WeatherCard weatherAtLocation={SAMPLE} />;\n }\n\n return <WeatherCard weatherAtLocation={tool.output} />;\n};\n\nexport const GetWeatherRenderer = defineToolRenderer({\n inputSchema: toolDefinition.inputSchema,\n outputSchema: toolDefinition.outputSchema,\n render: GetWeatherView,\n});\n",
|
|
26
|
-
"type": "registry:file",
|
|
27
|
-
"target": "~/chatjs/tools/get-weather/renderer.tsx"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"path": "src/tools/get-weather/schemas.ts",
|
|
31
|
-
"content": "import { z } from \"zod\";\n\nconst weatherInput = z.object({\n latitude: z.number(),\n longitude: z.number(),\n});\n\nconst MINIMUM_FORECAST_SAMPLE_COUNT = 1;\nconst sunriseSeries = z.array(z.string()).min(MINIMUM_FORECAST_SAMPLE_COUNT);\nconst sunsetSeries = z.array(z.string()).min(MINIMUM_FORECAST_SAMPLE_COUNT);\nconst hourlyTemperatures = z\n .array(z.number())\n .min(MINIMUM_FORECAST_SAMPLE_COUNT);\nconst dailyForecast = z.object({\n sunrise: sunriseSeries,\n sunset: sunsetSeries,\n time: z.array(z.string()),\n});\nconst hourlyForecast = z.object({\n temperature_2m: hourlyTemperatures,\n time: z.array(z.string()),\n});\n\nconst weatherResult = z.object({\n current: z.object({\n interval: z.number(),\n temperature_2m: z.number(),\n time: z.iso.datetime({ local: true }),\n }),\n current_units: z.object({\n interval: z.string(),\n temperature_2m: z.string(),\n time: z.string(),\n }),\n daily: dailyForecast,\n daily_units: z.object({\n sunrise: z.string(),\n sunset: z.string(),\n time: z.string(),\n }),\n elevation: z.number(),\n generationtime_ms: z.number(),\n hourly: hourlyForecast,\n hourly_units: z.object({ temperature_2m: z.string(), time: z.string() }),\n latitude: z.number(),\n longitude: z.number(),\n timezone: z.string(),\n timezone_abbreviation: z.string(),\n utc_offset_seconds: z.number(),\n});\nexport { weatherInput, weatherResult };\n",
|
|
32
|
-
"type": "registry:file",
|
|
33
|
-
"target": "~/chatjs/tools/get-weather/schemas.ts"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "dist/source/get-weather.json",
|
|
37
|
-
"content": "{\n \"envRequirements\": [],\n \"id\": \"get-weather\",\n \"kind\": \"tool\",\n \"requiresTools\": [],\n \"tools\": [\n {\n \"rendererExport\": \"GetWeatherRenderer\",\n \"definitionExport\": \"toolDefinition\",\n \"toolExport\": \"getWeather\"\n }\n ],\n \"contractVersion\": 1\n}\n",
|
|
38
|
-
"type": "registry:file",
|
|
39
|
-
"target": "~/chatjs/tools/get-weather/chatjs.json"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"meta": {
|
|
43
|
-
"chatjs": {
|
|
44
|
-
"envRequirements": [],
|
|
45
|
-
"id": "get-weather",
|
|
46
|
-
"kind": "tool",
|
|
47
|
-
"requiresTools": [],
|
|
48
|
-
"tools": [
|
|
49
|
-
{
|
|
50
|
-
"rendererExport": "GetWeatherRenderer",
|
|
51
|
-
"definitionExport": "toolDefinition",
|
|
52
|
-
"toolExport": "getWeather"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"contractVersion": 1
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"type": "registry:item"
|
|
59
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "langfuse",
|
|
4
|
-
"description": "Langfuse tracing through Vercel OpenTelemetry",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"@vercel/otel@^2.1.0",
|
|
7
|
-
"langfuse-vercel@^3.37.0"
|
|
8
|
-
],
|
|
9
|
-
"files": [
|
|
10
|
-
{
|
|
11
|
-
"path": "src/plugins/langfuse/src/instrumentation.ts",
|
|
12
|
-
"content": "import type { InstrumentationRegistration } from \"@/chatjs/core/installation/contracts\";\nimport { getLangfuseEnvironment } from \"./credentials\";\nimport { isPlaywrightTestEnvironment } from \"@/lib/playwright-test-environment\";\n\nexport const register: InstrumentationRegistration = async ({\n appPrefix,\n runtime,\n}: Readonly<{ appPrefix: string; runtime: string | undefined }>) => {\n // Browser fixtures deliberately omit optional service credentials and exports.\n if (runtime !== \"nodejs\" || isPlaywrightTestEnvironment()) {\n return;\n }\n const environment = getLangfuseEnvironment();\n const [{ registerOTel }, { LangfuseExporter }] = await Promise.all([\n import(\"@vercel/otel\"),\n import(\"langfuse-vercel\"),\n ]);\n registerOTel({\n serviceName: appPrefix,\n traceExporter: new LangfuseExporter(environment),\n });\n};\n",
|
|
13
|
-
"type": "registry:file",
|
|
14
|
-
"target": "~/chatjs/plugins/langfuse/instrumentation.ts"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"path": "src/plugins/langfuse/src/credentials.ts",
|
|
18
|
-
"content": "import descriptor from \"@/chatjs/plugins/langfuse/chatjs.json\";\nimport { requireCredentials } from \"@/lib/required-credentials\";\n\n// Read at registration time so an omitted integration never validates credentials.\nexport const getLangfuseEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n): {\n baseUrl: string | undefined;\n debug: boolean;\n publicKey: string | undefined;\n secretKey: string | undefined;\n} => {\n requireCredentials(\"langfuse\", descriptor.envRequirements, environment);\n const baseUrl = environment.LANGFUSE_BASE_URL;\n const hasBaseUrl = Boolean(baseUrl);\n return {\n baseUrl: hasBaseUrl ? baseUrl : undefined,\n debug: environment.LANGFUSE_DEBUG === \"true\",\n publicKey: environment.LANGFUSE_PUBLIC_KEY,\n secretKey: environment.LANGFUSE_SECRET_KEY,\n };\n};\n",
|
|
19
|
-
"type": "registry:file",
|
|
20
|
-
"target": "~/chatjs/plugins/langfuse/credentials.ts"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"path": "src/plugins/langfuse/src/server-plugin.ts",
|
|
24
|
-
"content": "import type { ChatPlugin } from \"@/chatjs/core/installation/plugin\";\nimport { register } from \"./instrumentation\";\n\nexport const langfuse = () =>\n ({ id: \"langfuse\", instrumentation: register }) satisfies ChatPlugin;\n",
|
|
25
|
-
"type": "registry:file",
|
|
26
|
-
"target": "~/chatjs/plugins/langfuse/server-plugin.ts"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "dist/source/langfuse.json",
|
|
30
|
-
"content": "{\n \"id\": \"langfuse\",\n \"kind\": \"plugin\",\n \"files\": [\n \"chatjs/plugins/langfuse/instrumentation.ts\",\n \"chatjs/plugins/langfuse/credentials.ts\",\n \"chatjs/plugins/langfuse/server-plugin.ts\"\n ],\n \"envRequirements\": [\n { \"options\": [[\"LANGFUSE_PUBLIC_KEY\", \"LANGFUSE_SECRET_KEY\"]] }\n ],\n \"server\": { \"export\": \"langfuse\", \"routers\": [], \"instrumentation\": true },\n \"contractVersion\": 1\n}\n",
|
|
31
|
-
"type": "registry:file",
|
|
32
|
-
"target": "~/chatjs/plugins/langfuse/chatjs.json"
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
"meta": {
|
|
36
|
-
"chatjs": {
|
|
37
|
-
"id": "langfuse",
|
|
38
|
-
"kind": "plugin",
|
|
39
|
-
"files": [
|
|
40
|
-
"chatjs/plugins/langfuse/instrumentation.ts",
|
|
41
|
-
"chatjs/plugins/langfuse/credentials.ts",
|
|
42
|
-
"chatjs/plugins/langfuse/server-plugin.ts"
|
|
43
|
-
],
|
|
44
|
-
"envRequirements": [
|
|
45
|
-
{
|
|
46
|
-
"options": [
|
|
47
|
-
[
|
|
48
|
-
"LANGFUSE_PUBLIC_KEY",
|
|
49
|
-
"LANGFUSE_SECRET_KEY"
|
|
50
|
-
]
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
"server": {
|
|
55
|
-
"export": "langfuse",
|
|
56
|
-
"routers": [],
|
|
57
|
-
"instrumentation": true
|
|
58
|
-
},
|
|
59
|
-
"contractVersion": 1
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"type": "registry:item"
|
|
63
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "read-document",
|
|
4
|
-
"description": "Read an owned document and its current revision before editing",
|
|
5
|
-
"files": [
|
|
6
|
-
{
|
|
7
|
-
"path": "src/tools/read-document/tool.ts",
|
|
8
|
-
"content": "import {\n eveDocumentReadInput,\n eveDocumentReadResult,\n} from \"@/chatjs/core/documents/contracts\";\nimport type { ToolContext } from \"eve/tools\";\nimport { defineTool } from \"eve/tools\";\nimport { executeEveDocumentTool } from \"@/lib/eve/document-tools\";\nimport type { z } from \"zod\";\n\ntype ReadonlyReadInput = Readonly<z.infer<typeof eveDocumentReadInput>>;\n\ntype ReadonlyReadContext = Readonly<\n Pick<ToolContext, \"callId\" | \"session\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nexport const readDocument = defineTool({\n description:\n \"Read the latest document content and revision ID in this conversation before editing it.\",\n execute: async (input: ReadonlyReadInput, context: ReadonlyReadContext) =>\n eveDocumentReadResult.parse(\n await executeEveDocumentTool(\"readDocument\", input, context)\n ),\n inputSchema: eveDocumentReadInput,\n outputSchema: eveDocumentReadResult,\n});\n",
|
|
9
|
-
"type": "registry:file",
|
|
10
|
-
"target": "~/chatjs/tools/read-document/tool.ts"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "dist/source/read-document.json",
|
|
14
|
-
"content": "{\n \"envRequirements\": [],\n \"id\": \"read-document\",\n \"kind\": \"tool\",\n \"requiresTools\": [],\n \"tools\": [{ \"toolExport\": \"readDocument\" }],\n \"contractVersion\": 1\n}\n",
|
|
15
|
-
"type": "registry:file",
|
|
16
|
-
"target": "~/chatjs/tools/read-document/chatjs.json"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"meta": {
|
|
20
|
-
"chatjs": {
|
|
21
|
-
"envRequirements": [],
|
|
22
|
-
"id": "read-document",
|
|
23
|
-
"kind": "tool",
|
|
24
|
-
"requiresTools": [],
|
|
25
|
-
"tools": [
|
|
26
|
-
{
|
|
27
|
-
"toolExport": "readDocument"
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
"contractVersion": 1
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"type": "registry:item"
|
|
34
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "retrieve-url",
|
|
4
|
-
"description": "Fetch structured information from a single URL",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"ai@7.0.137",
|
|
7
|
-
"zod@4.5.4",
|
|
8
|
-
"@mendable/firecrawl-js@1.29.1",
|
|
9
|
-
"lucide-react@0.553.0",
|
|
10
|
-
"react-markdown@^10.1.0"
|
|
11
|
-
],
|
|
12
|
-
"registryDependencies": [
|
|
13
|
-
"alert"
|
|
14
|
-
],
|
|
15
|
-
"files": [
|
|
16
|
-
{
|
|
17
|
-
"path": "src/tools/retrieve-url/retrieve-url-env.ts",
|
|
18
|
-
"content": "import { z } from \"zod\";\n\nconst environmentSchema = z.object({\n FIRECRAWL_API_KEY: z.string().optional(),\n});\n\nconst readToolEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n) => environmentSchema.parse(environment);\n\nexport { readToolEnvironment };\n",
|
|
19
|
-
"type": "registry:file",
|
|
20
|
-
"target": "~/chatjs/tools/retrieve-url/retrieve-url-env.ts"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"path": "src/tools/retrieve-url/tool.ts",
|
|
24
|
-
"content": "import { validateToolOutput } from \"@/chatjs/core/tools/validate-output\";\nimport FirecrawlApp from \"@mendable/firecrawl-js\";\nimport { defineTool } from \"eve/tools\";\nimport { readToolEnvironment } from \"./retrieve-url-env\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { executeWithToolUsage } from \"@/lib/eve/tool-usage\";\nimport { retrievedInput, retrievedResult } from \"./schemas\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport { z } from \"zod\";\n\ntype RetrieveUrlInput = Readonly<z.infer<typeof retrievedInput>>;\ntype RetrieveUrlContext = Readonly<{\n abortSignal: Readonly<AbortSignal>;\n}>;\ntype RetrieveUrlUsage = Readonly<{\n addCostUsd: (cost: number) => void;\n markUnknown: () => void;\n}>;\n\nconst hasNonEmptyValue = (value: string | null | undefined): value is string =>\n typeof value === \"string\" && value !== \"\";\n\nconst UNBILLED_TOOL_COST_USD = 0;\nconst log = createModuleLogger(\"tools/retrieve-url\");\nconst extractedPage = z.object({\n content: z.string(),\n description: z.string(),\n title: z.string(),\n});\nconst extractedText = z.preprocess(\n (value) => (typeof value === \"string\" ? value : \"\"),\n z.string()\n);\nconst extractedPageFallback = z.object({\n content: extractedText,\n description: extractedText,\n title: extractedText,\n});\n\nconst createClient = (): FirecrawlApp | null => {\n const env = readToolEnvironment();\n return hasNonEmptyValue(env.FIRECRAWL_API_KEY)\n ? new FirecrawlApp({ apiKey: env.FIRECRAWL_API_KEY })\n : null;\n};\n\nconst parseUrl = (url: string): URL | null => {\n try {\n const parsed = new URL(url);\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n};\n\nconst redactUrl = (url: Readonly<Pick<URL, \"origin\" | \"pathname\">>): string =>\n `${url.origin}${url.pathname}`;\n\nconst retrieveContent = async (url: string, usage: RetrieveUrlUsage) => {\n usage.addCostUsd(UNBILLED_TOOL_COST_USD);\n try {\n const app = createClient();\n if (!app) {\n return {\n error:\n \"Firecrawl is not configured. Set FIRECRAWL_API_KEY to enable retrieval.\",\n };\n }\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n return {\n error: \"Please provide a valid http:// or https:// URL.\",\n };\n }\n\n const redactedUrl = redactUrl(parsedUrl);\n const normalizedUrl = parsedUrl.toString();\n // Firecrawl does not return a monetary receipt for scrape/extract.\n usage.markUnknown();\n const content = await app.scrapeUrl(normalizedUrl);\n if (!(content.success && content.metadata)) {\n return {\n results: [\n {\n error: content.error,\n },\n ],\n };\n }\n\n const { metadata } = content;\n let { description, title } = metadata;\n let extractedContent = content.markdown;\n\n if (\n !(\n hasNonEmptyValue(title) &&\n hasNonEmptyValue(description) &&\n hasNonEmptyValue(extractedContent)\n )\n ) {\n const extractResult = await app.extract([normalizedUrl], {\n prompt:\n \"Extract the page title, main content, and a brief description.\",\n schema: extractedPage,\n });\n\n if (\n extractResult.success &&\n extractResult.data !== undefined &&\n extractResult.data !== null\n ) {\n const extracted = extractedPageFallback.safeParse(extractResult.data);\n if (extracted.success) {\n title = hasNonEmptyValue(title) ? title : extracted.data.title;\n description = hasNonEmptyValue(description)\n ? description\n : extracted.data.description;\n extractedContent = hasNonEmptyValue(extractedContent)\n ? extractedContent\n : extracted.data.content;\n }\n }\n }\n\n return {\n results: [\n {\n content: extractedContent ?? \"\",\n description: description ?? \"\",\n language: metadata.language,\n title: hasNonEmptyValue(title) ? title : \"Untitled\",\n url: redactedUrl,\n },\n ],\n };\n } catch (error) {\n const parsedUrl = parseUrl(url);\n log.error(\n {\n err: error,\n url: parsedUrl ? redactUrl(parsedUrl) : \"<invalid-url>\",\n },\n \"Firecrawl API error in retrieveUrl tool\"\n );\n return {\n error: \"Failed to retrieve content\",\n };\n }\n};\n\nexport const retrieveUrl = defineTool({\n description: `Fetch structured information from a single URL via Firecrawl.\n\nUse for:\n- Extract content from a specific URL supplied by the user\n\nAvoid:\n- General-purpose web searches`,\n execute: async ({ url }: RetrieveUrlInput, context: RetrieveUrlContext) =>\n await executeWithToolUsage(context, async (usage: RetrieveUrlUsage) =>\n validateToolOutput(retrievedResult, await retrieveContent(url, usage))\n ),\n inputSchema: retrievedInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
25
|
-
"type": "registry:file",
|
|
26
|
-
"target": "~/chatjs/tools/retrieve-url/tool.ts"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "src/tools/retrieve-url/renderer.tsx",
|
|
30
|
-
"content": "\"use client\";\nimport { ChevronDown, ExternalLink, Globe, TextIcon } from \"lucide-react\";\nimport { Alert, AlertTitle, AlertDescription } from \"@/components/ui/alert\";\nimport { retrievedInput, retrievedResult } from \"./schemas\";\nimport React from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\n\ntype RetrieveUrlRendererTool = ToolRendererProps<\n typeof retrievedInput,\n typeof retrievedResult\n>[\"tool\"];\n\nconst LoadingState = (): React.JSX.Element => (\n <div className=\"border-border bg-card my-4 rounded-xl border p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"relative h-10 w-10\">\n <div className=\"bg-primary/10 absolute inset-0 animate-pulse rounded-full\" />\n <Globe className=\"text-primary/70 absolute inset-0 m-auto h-5 w-5\" />\n </div>\n <div className=\"flex-1 space-y-2\">\n <div className=\"bg-muted-foreground/20 h-4 w-36 animate-pulse rounded-md\" />\n <div className=\"space-y-1.5\">\n <div className=\"bg-muted-foreground/15 h-3 w-full animate-pulse rounded-md\" />\n <div className=\"bg-muted-foreground/15 h-3 w-2/3 animate-pulse rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n);\n\nconst ErrorState = ({\n errorMessage,\n}: Readonly<{ errorMessage: string | undefined }>): React.JSX.Element => (\n <Alert variant=\"destructive\" className=\"my-4\">\n <Globe />\n <AlertTitle>Error retrieving content</AlertTitle>\n <AlertDescription>{errorMessage}</AlertDescription>\n </Alert>\n);\n\nconst getItemProperty = (\n item: unknown,\n property: string,\n defaultValue: string\n): string => {\n if (item !== null && typeof item === \"object\" && property in item) {\n const value: unknown = Reflect.get(item, property);\n return typeof value === \"string\" ? value : defaultValue;\n }\n return defaultValue;\n};\n\nconst RetrievedContentHeader = ({\n firstItem,\n}: Readonly<{ firstItem: unknown }>): React.JSX.Element => {\n const url = getItemProperty(firstItem, \"url\", \"\");\n const title = getItemProperty(firstItem, \"title\", \"Retrieved Content\");\n const description = getItemProperty(\n firstItem,\n \"description\",\n \"No description available\"\n );\n const language = getItemProperty(firstItem, \"language\", \"Unknown\");\n\n return (\n <div className=\"p-4\">\n <div className=\"flex items-start gap-4\">\n <div className=\"relative h-10 w-10 shrink-0\">\n <div className=\"from-primary/10 absolute inset-0 rounded-lg bg-linear-to-br to-transparent\" />\n <Globe className=\"text-primary/70 absolute inset-0 m-auto h-5 w-5\" />\n </div>\n <div className=\"min-w-0 flex-1 space-y-2\">\n <h2 className=\"text-foreground truncate text-lg font-semibold tracking-tight\">\n {title}\n </h2>\n <p className=\"text-muted-foreground line-clamp-2 text-sm\">\n {description}\n </p>\n <div className=\"flex items-center gap-3\">\n <span className=\"bg-primary/10 text-primary rounded-full px-2.5 py-0.5 text-xs font-medium\">\n {language}\n </span>\n <a\n className=\"text-muted-foreground hover:text-primary inline-flex items-center gap-1.5 text-xs transition-colors\"\n href={url || \"#\"}\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n View source\n </a>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nconst RetrievedContentDetails = ({\n firstItem,\n}: Readonly<{ firstItem: unknown }>): React.JSX.Element => {\n const content = getItemProperty(firstItem, \"content\", \"No content available\");\n\n return (\n <div className=\"border-border border-t\">\n <details className=\"group\">\n <summary className=\"text-muted-foreground hover:bg-muted flex w-full cursor-pointer items-center justify-between px-4 py-2 text-sm transition-colors\">\n <div className=\"flex items-center gap-2\">\n <TextIcon className=\"text-muted-foreground h-4 w-4\" />\n <span>View content</span>\n </div>\n <ChevronDown className=\"h-4 w-4 transition-transform duration-200 group-open:rotate-180\" />\n </summary>\n <div className=\"bg-muted/50 max-h-[50vh] overflow-y-auto p-4\">\n <div className=\"prose prose-neutral dark:prose-invert prose-sm max-w-none\">\n <ReactMarkdown>{content}</ReactMarkdown>\n </div>\n </div>\n </details>\n </div>\n );\n};\n\nconst getFirstItem = (result: unknown): unknown => {\n if (\n result !== null &&\n typeof result === \"object\" &&\n \"results\" in result &&\n Array.isArray(result.results)\n ) {\n return result.results[0];\n }\n return undefined;\n};\n\nconst getErrorMessage = (\n result: unknown,\n firstItem: unknown\n): string | null => {\n const topLevelError =\n result !== null &&\n typeof result === \"object\" &&\n \"error\" in result &&\n typeof result.error === \"string\"\n ? result.error\n : undefined;\n const firstItemError =\n firstItem !== null &&\n typeof firstItem === \"object\" &&\n \"error\" in firstItem &&\n typeof firstItem.error === \"string\"\n ? firstItem.error\n : undefined;\n\n return topLevelError ?? firstItemError ?? null;\n};\n\nconst RetrieveUrlView = ({\n tool,\n}: ReadonlyNativeSurface<{\n tool: RetrieveUrlRendererTool;\n messageId: string;\n isReadonly: boolean;\n}>): React.JSX.Element | null => {\n if (tool.state === \"input-available\" || tool.state === \"input-streaming\") {\n return <LoadingState />;\n }\n\n if (tool.state !== \"output-available\") {\n return null;\n }\n\n if (tool.output === undefined) {\n return null;\n }\n\n const { output: result } = tool;\n const firstItem = getFirstItem(result);\n const errorMessage = getErrorMessage(result, firstItem);\n\n if (typeof errorMessage === \"string\" && errorMessage !== \"\") {\n return <ErrorState errorMessage={errorMessage} />;\n }\n\n return (\n <div className=\"border-border bg-card my-4 overflow-hidden rounded-xl border\">\n <RetrievedContentHeader firstItem={firstItem} />\n <RetrievedContentDetails firstItem={firstItem} />\n </div>\n );\n};\n\nexport const RetrieveUrlRenderer = defineToolRenderer({\n inputSchema: retrievedInput,\n outputSchema: retrievedResult,\n render: RetrieveUrlView,\n});\n",
|
|
31
|
-
"type": "registry:file",
|
|
32
|
-
"target": "~/chatjs/tools/retrieve-url/renderer.tsx"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "src/tools/retrieve-url/schemas.ts",
|
|
36
|
-
"content": "import { z } from \"zod\";\n\nconst retrievedInput = z.object({\n url: z.string().describe(\"The URL to retrieve the information from.\"),\n});\n\nconst retrievedContent = z\n .object({\n content: z.string(),\n description: z.string(),\n language: z.string().optional(),\n title: z.string(),\n url: z.string(),\n })\n .transform((item) => ({ ...item, language: item.language }));\nconst retrievalFailure = z\n .strictObject({ error: z.string().optional() })\n .transform((item) => ({ error: item.error }));\nconst retrievedResult = z.union([\n z.object({ error: z.string() }),\n z.object({ results: z.array(retrievedContent) }),\n z.object({ results: z.array(retrievalFailure) }),\n]);\nexport { retrievedInput, retrievedResult };\n",
|
|
37
|
-
"type": "registry:file",
|
|
38
|
-
"target": "~/chatjs/tools/retrieve-url/schemas.ts"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"path": "dist/source/retrieve-url.json",
|
|
42
|
-
"content": "{\n \"envRequirements\": [{ \"options\": [[\"FIRECRAWL_API_KEY\"]] }],\n \"id\": \"retrieve-url\",\n \"kind\": \"tool\",\n \"requiresTools\": [],\n \"slot\": \"retrieveUrl\",\n \"tools\": [\n { \"rendererExport\": \"RetrieveUrlRenderer\", \"toolExport\": \"retrieveUrl\" }\n ],\n \"contractVersion\": 1\n}\n",
|
|
43
|
-
"type": "registry:file",
|
|
44
|
-
"target": "~/chatjs/tools/retrieve-url/chatjs.json"
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"meta": {
|
|
48
|
-
"chatjs": {
|
|
49
|
-
"envRequirements": [
|
|
50
|
-
{
|
|
51
|
-
"options": [
|
|
52
|
-
[
|
|
53
|
-
"FIRECRAWL_API_KEY"
|
|
54
|
-
]
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"id": "retrieve-url",
|
|
59
|
-
"kind": "tool",
|
|
60
|
-
"requiresTools": [],
|
|
61
|
-
"slot": "retrieveUrl",
|
|
62
|
-
"tools": [
|
|
63
|
-
{
|
|
64
|
-
"rendererExport": "RetrieveUrlRenderer",
|
|
65
|
-
"toolExport": "retrieveUrl"
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
"contractVersion": 1
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"type": "registry:item"
|
|
72
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "saved-code-execution",
|
|
4
|
-
"description": "Run saved code revisions with a compatible installed executor",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"lucide-react@0.553.0"
|
|
7
|
-
],
|
|
8
|
-
"registryDependencies": [
|
|
9
|
-
"@chatjs/code-documents",
|
|
10
|
-
"@chatjs/code-execution-ui"
|
|
11
|
-
],
|
|
12
|
-
"files": [
|
|
13
|
-
{
|
|
14
|
-
"path": "src/tools/saved-code-execution/tool.ts",
|
|
15
|
-
"content": "import { defineTool } from \"eve/tools\";\nimport { documentExecutionInput } from \"./schemas\";\nimport { executeEveCodeDocument } from \"./execute\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\n\nexport const runCodeDocument = defineTool({\n description:\n \"Run the exact saved Python or JavaScript code document revision in this conversation. Supply its document and revision IDs. Do not copy, rewrite, or substitute its source code.\",\n execute: executeEveCodeDocument,\n inputSchema: documentExecutionInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
16
|
-
"type": "registry:file",
|
|
17
|
-
"target": "~/chatjs/tools/saved-code-execution/tool.ts"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"path": "src/tools/saved-code-execution/execute.ts",
|
|
21
|
-
"content": "import { validateToolOutput } from \"@/chatjs/core/tools/validate-output\";\nimport type { z } from \"zod\";\nimport {\n documentExecutionInput,\n documentExecutionResult,\n documentExecutionLanguage,\n eveCodeExecutionResult,\n} from \"./schemas\";\nimport {\n installedDocumentKinds,\n installedToolNames,\n} from \"@/integrations/tools/catalog\";\nimport type { ToolContext } from \"eve/tools\";\nimport { getEveDocumentRevision } from \"@/lib/db/eve-documents\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport { eveTurnAccount } from \"@/lib/eve/turn-tools\";\nimport { codeExecutor } from \"@/integrations/tools/code-executor\";\n\ntype ReadonlyCodeExecutionContext = Readonly<\n Pick<ToolContext, \"callId\" | \"session\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\ntype CodeResult = Awaited<ReturnType<NonNullable<typeof codeExecutor>>>;\ntype SuccessfulCodeResult = Extract<CodeResult, { status: \"success\" }>;\ntype DocumentExecutionSource = Readonly<{\n code: string;\n language: \"python\" | \"javascript\";\n title: string;\n}>;\ntype DocumentExecutionResult = {\n -readonly [\n Key in keyof Omit<SuccessfulCodeResult, \"output\">\n ]: SuccessfulCodeResult[Key];\n} & {\n output: z.output<typeof documentExecutionResult> & DocumentExecutionSource;\n};\n\ntype DocumentExecutionStream = AsyncGenerator<\n Extract<CodeResult, { status: \"error\" }> | DocumentExecutionResult,\n void,\n unknown\n>;\n\nconst documentResult = (\n result: Readonly<\n Omit<SuccessfulCodeResult, \"output\"> & {\n output: Readonly<SuccessfulCodeResult[\"output\"]>;\n }\n >,\n source: DocumentExecutionSource,\n revision: Readonly<{ documentId: string; id: string }>\n): DocumentExecutionResult => {\n const output = eveCodeExecutionResult.safeParse(result.output);\n return {\n ...result,\n output: {\n ...validateToolOutput(documentExecutionResult, {\n ...(output.success\n ? output.data\n : {\n chart: \"\",\n message:\n \"Execution finished, but its output has an unsupported format.\",\n }),\n documentId: revision.documentId,\n revisionId: revision.id,\n }),\n ...source,\n },\n };\n};\n\n/**\n * Execute saved source, never model-supplied replacement code.\n * @param {unknown} value Untrusted tool input validated against the shared execution schema.\n * @param {ToolContext} context Native tool context supplying session scope, call metadata, and cancellation.\n * @yields {unknown} Native EVE platform result snapshots with document identity.\n */\nexport const executeEveCodeDocument = async function* executeEveCodeDocument(\n value: unknown,\n context: ReadonlyCodeExecutionContext\n): DocumentExecutionStream {\n if (\n !(\n installedDocumentKinds.has(\"code\") &&\n installedToolNames.has(\"runCodeDocument\")\n )\n ) {\n throw new Error(\"Document execution is disabled.\");\n }\n const input = documentExecutionInput.parse(value);\n const scope = await resolveEveConversationScope(\n (context.session.auth.initiator ?? {}).principalId,\n context.session.id,\n context.abortSignal\n );\n const revision = await getEveDocumentRevision(\n scope.ownerId,\n scope.conversationId,\n input.documentId,\n input.revisionId\n );\n if (!revision || revision.kind !== \"code\") {\n throw new Error(\"Code document not found.\");\n }\n const language = documentExecutionLanguage(revision.title);\n if (!language) {\n throw new Error(\"Only Python and JavaScript documents can be run.\");\n }\n context.abortSignal.throwIfAborted();\n const source = { code: revision.content, language, title: revision.title };\n if (!codeExecutor || !eveTurnAccount.get()) {\n throw new Error(\"Installed code executor is unavailable.\");\n }\n const result = await codeExecutor(source, {\n abortSignal: context.abortSignal,\n callId: context.callId,\n session: context.session,\n });\n if (result.status === \"error\") {\n yield result;\n return;\n }\n yield documentResult(result, source, revision);\n};\n",
|
|
22
|
-
"type": "registry:file",
|
|
23
|
-
"target": "~/chatjs/tools/saved-code-execution/execute.ts"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"path": "src/tools/saved-code-execution/schemas.ts",
|
|
27
|
-
"content": "import { z } from \"zod\";\n\nconst documentExecutionInput = z.object({\n documentId: z.uuid(),\n revisionId: z.uuid(),\n});\n\nconst chartLabels = {\n title: z.string(),\n x_label: z.string().optional(),\n y_label: z.string().optional(),\n};\nconst point = z.tuple([z.union([z.number(), z.string()]), z.number()]);\nconst series = z.object({\n label: z.string(),\n points: z.array(point),\n});\nconst barElement = z.object({\n group: z.string(),\n label: z.string(),\n value: z.number(),\n});\nconst lineChart = z.object({\n ...chartLabels,\n elements: z.array(series),\n type: z.literal(\"line\"),\n x_scale: z.literal(\"datetime\").nullish(),\n});\nconst scatterChart = z.object({\n ...chartLabels,\n elements: z.array(series),\n type: z.literal(\"scatter\"),\n x_scale: z.literal(\"datetime\").nullish(),\n});\nconst barChart = z.object({\n ...chartLabels,\n elements: z.array(barElement),\n type: z.literal(\"bar\"),\n});\nconst chart = z.discriminatedUnion(\"type\", [lineChart, scatterChart, barChart]);\nconst encodedChart = z.object({ base64: z.string(), format: z.string() });\n\n/** The saved-code runner owns its output contract independently of installed renderers. */\nconst eveCodeExecutionResult = z.object({\n chart: z.union([z.string(), encodedChart, chart]),\n message: z.string(),\n});\n\nconst documentExecutionResult = eveCodeExecutionResult.extend(\n documentExecutionInput.shape\n);\n\nconst LAST_EXTENSION_INDEX = -1;\nconst executionLanguageByExtension: ReadonlyMap<\n string,\n \"python\" | \"javascript\"\n> = new Map([\n [\"py\", \"python\"],\n [\"js\", \"javascript\"],\n [\"mjs\", \"javascript\"],\n [\"cjs\", \"javascript\"],\n]);\nconst documentExecutionLanguage = (\n title: string\n): \"python\" | \"javascript\" | undefined => {\n if (!title.includes(\".\")) {\n return \"python\";\n }\n const extension = (\n title.split(\".\").at(LAST_EXTENSION_INDEX) ?? \"\"\n ).toLowerCase();\n if (!(typeof extension === \"string\" && extension !== \"\")) {\n return \"python\";\n }\n return executionLanguageByExtension.get(extension);\n};\nexport {\n documentExecutionInput,\n documentExecutionResult,\n documentExecutionLanguage,\n eveCodeExecutionResult,\n};\n",
|
|
28
|
-
"type": "registry:file",
|
|
29
|
-
"target": "~/chatjs/tools/saved-code-execution/schemas.ts"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "src/tools/saved-code-execution/document.tsx",
|
|
33
|
-
"content": "\"use client\";\nimport { Hint } from \"@/components/hint\";\nimport {\n installedDocumentKinds,\n installedToolNames,\n} from \"@/integrations/tools/catalog\";\nimport { Button } from \"@/components/ui/button\";\nimport type { DocumentRunProps } from \"@/chatjs/core/documents/ui\";\nimport { EveDocumentRunResult } from \"./result\";\nimport { Play } from \"lucide-react\";\nimport React from \"react\";\nimport { config } from \"@/lib/config\";\nimport { documentExecutionLanguage } from \"./schemas\";\nimport { latestDocumentRun } from \"./document-runs\";\n\nexport const EveDocumentRun = ({\n documentId,\n revisionId,\n title,\n kind,\n messages,\n disabled,\n onAction,\n buttonOnly = false,\n resultOnly = false,\n}: DocumentRunProps): React.JSX.Element | null => {\n const [, startEventAction] = React.useTransition();\n const run = latestDocumentRun(messages, documentId, revisionId);\n const canRun =\n onAction !== undefined &&\n installedDocumentKinds.has(\"code\") &&\n installedToolNames.has(\"runCodeDocument\") &&\n documentExecutionLanguage(title) !== undefined;\n if (\n kind !== \"code\" ||\n !(canRun || run) ||\n (resultOnly && !run) ||\n (buttonOnly && !canRun)\n ) {\n return null;\n }\n return (\n <div\n className={buttonOnly ? \"shrink-0\" : \"shrink-0 space-y-2 border-t p-2\"}\n >\n {canRun && !resultOnly && (\n <Hint\n trigger={\n <Button\n className=\"hover:bg-accent h-fit px-2 py-1.5 [&_svg]:size-[18px]\"\n disabled={disabled}\n\n onClick={() => {\n startEventAction(async () => {\n await onAction({\n message: `Run the saved code using runCodeDocument with documentId \"${documentId}\" and revisionId \"${revisionId}\". Execute exactly this revision once. Do not edit the document or substitute codeExecution. Report the result briefly.`,\n modelId: config.ai.tools.code.edits,\n });\n });\n }}\n size=\"sm\"\n variant=\"outline\"\n >\n <Play size={18} /> Run\n </Button>\n }\n >\n Execute code\n </Hint>\n )}\n {run && !buttonOnly && (\n <details key={run.part.callId} open>\n <summary className=\"cursor-pointer text-sm\">Execution result</summary>\n <div\n className=\"max-h-64 overflow-auto pt-2\"\n data-testid=\"document-run-result\"\n >\n <EveDocumentRunResult part={run.part} />\n </div>\n </details>\n )}\n </div>\n );\n};\n",
|
|
34
|
-
"type": "registry:file",
|
|
35
|
-
"target": "~/chatjs/tools/saved-code-execution/document.tsx"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"path": "src/tools/saved-code-execution/document-runs.ts",
|
|
39
|
-
"content": "import type { EveToolPart, EveMessage } from \"eve/client\";\n\nimport { documentExecutionInput } from \"./schemas\";\n\n/** Project the latest execution of this revision from the native transcript.\n * @param {readonly Pick<EveMessage, \"id\" | \"parts\">[]} messages Transcript identifiers and parts read newest-first without changing the matched part reference.\n * @param {string} documentId Document identity accepted by the execution tool.\n * @param {string} revisionId Revision identity required to match that run.\n * @returns {{ messageId: string; part: EveToolPart } | undefined} The newest matching tool part by original reference, or no result when that revision has not run.\n */\nexport const latestDocumentRun = (\n messages: readonly Pick<EveMessage, \"id\" | \"parts\">[],\n documentId: string,\n revisionId: string\n): { messageId: string; part: EveToolPart } | undefined => {\n for (const message of messages.toReversed()) {\n for (const part of message.parts.toReversed()) {\n if (part.type === \"tool\" && part.name === \"runCodeDocument\") {\n const input = documentExecutionInput.safeParse(part.input);\n if (\n input.success &&\n input.data.documentId === documentId &&\n input.data.revisionId === revisionId\n ) {\n return { messageId: message.id, part };\n }\n }\n }\n }\n return undefined;\n};\n",
|
|
40
|
-
"type": "registry:file",
|
|
41
|
-
"target": "~/chatjs/tools/saved-code-execution/document-runs.ts"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"path": "src/tools/saved-code-execution/renderer.tsx",
|
|
45
|
-
"content": "\"use client\";\nimport { documentExecutionInput, documentExecutionResult } from \"./schemas\";\nimport { CodeExecutionChart } from \"@/chatjs/tools/_shared/code-execution/code-execution-chart\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\n\ntype SavedCodeRenderProps = ReadonlyNativeSurface<\n ToolRendererProps<\n typeof documentExecutionInput,\n typeof documentExecutionResult\n >\n>;\n\nexport const SavedCodeRenderer = defineToolRenderer({\n inputSchema: documentExecutionInput,\n outputSchema: documentExecutionResult,\n render: ({ tool }: SavedCodeRenderProps) => {\n if (tool.state === \"output-available\") {\n return (\n <div className=\"space-y-3\">\n <p>{tool.output.message}</p>\n <CodeExecutionChart value={tool.output.chart} />\n </div>\n );\n }\n return <output>Running saved code…</output>;\n },\n});\n",
|
|
46
|
-
"type": "registry:file",
|
|
47
|
-
"target": "~/chatjs/tools/saved-code-execution/renderer.tsx"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"path": "src/tools/saved-code-execution/result.tsx",
|
|
51
|
-
"content": "\"use client\";\nimport type { EveMessagePart } from \"eve/client\";\nimport React from \"react\";\nimport { eveCodeExecutionResult } from \"./schemas\";\nimport { toolOutputSchema } from \"@/lib/eve/tool-result\";\nimport { CodeExecutionChart } from \"@/chatjs/tools/_shared/code-execution/code-execution-chart\";\n\nexport const EveDocumentRunResult = ({\n part,\n}: Readonly<{\n part: Extract<EveMessagePart, { type: \"tool\" }>;\n}>): React.JSX.Element => {\n if (part.state === \"failed\") {\n return <p role=\"alert\">{part.error?.message ?? \"Tool failed\"}</p>;\n }\n if (part.state === \"cancelled\") {\n return <p>Document execution stopped.</p>;\n }\n if (part.state === \"rejected\") {\n return <p>Document execution declined.</p>;\n }\n if (part.state !== \"completed\") {\n return <output>Running saved code…</output>;\n }\n const result = toolOutputSchema.safeParse(part.output);\n if (!result.success) {\n return <p role=\"alert\">This tool result could not be displayed.</p>;\n }\n if (result.data.status === \"error\") {\n return <p role=\"alert\">{result.data.error}</p>;\n }\n const output = eveCodeExecutionResult.safeParse(result.data.output);\n if (output.success) {\n return (\n <div className=\"space-y-3\">\n <p>{output.data.message}</p>\n <CodeExecutionChart value={output.data.chart} />\n </div>\n );\n }\n return <p role=\"alert\">This saved-code result could not be displayed.</p>;\n};\n",
|
|
52
|
-
"type": "registry:file",
|
|
53
|
-
"target": "~/chatjs/tools/saved-code-execution/result.tsx"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"path": "dist/source/saved-code-execution.json",
|
|
57
|
-
"content": "{\n \"documentRunExport\": \"EveDocumentRun\",\n \"envRequirements\": [],\n \"id\": \"saved-code-execution\",\n \"kind\": \"tool\",\n \"requiresTools\": [\n \"createCodeDocument\",\n \"readDocument\",\n \"codeExecution\"\n ],\n \"tools\": [\n {\n \"rendererExport\": \"SavedCodeRenderer\",\n \"toolExport\": \"runCodeDocument\"\n }\n ],\n \"contractVersion\": 2,\n \"uiBase\": \"radix\"\n}\n",
|
|
58
|
-
"type": "registry:file",
|
|
59
|
-
"target": "~/chatjs/tools/saved-code-execution/chatjs.json"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
"meta": {
|
|
63
|
-
"chatjs": {
|
|
64
|
-
"documentRunExport": "EveDocumentRun",
|
|
65
|
-
"envRequirements": [],
|
|
66
|
-
"id": "saved-code-execution",
|
|
67
|
-
"kind": "tool",
|
|
68
|
-
"requiresTools": [
|
|
69
|
-
"createCodeDocument",
|
|
70
|
-
"readDocument",
|
|
71
|
-
"codeExecution"
|
|
72
|
-
],
|
|
73
|
-
"tools": [
|
|
74
|
-
{
|
|
75
|
-
"rendererExport": "SavedCodeRenderer",
|
|
76
|
-
"toolExport": "runCodeDocument"
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
"contractVersion": 2,
|
|
80
|
-
"uiBase": "radix"
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"type": "registry:item"
|
|
84
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "sheet-documents",
|
|
4
|
-
"description": "Create and edit sheet documents with their editor UI",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"papaparse@^5.5.2",
|
|
7
|
-
"@types/papaparse@^5.3.15",
|
|
8
|
-
"react-data-grid@7.0.0-beta.47",
|
|
9
|
-
"next-themes@^0.4.6"
|
|
10
|
-
],
|
|
11
|
-
"registryDependencies": [
|
|
12
|
-
"@chatjs/read-document"
|
|
13
|
-
],
|
|
14
|
-
"files": [
|
|
15
|
-
{
|
|
16
|
-
"path": "src/tools/sheet-documents/tool.ts",
|
|
17
|
-
"content": "import {\n eveDocumentCreateInput,\n eveDocumentEditInput,\n eveDocumentWriteResult,\n} from \"@/chatjs/core/documents/contracts\";\nimport type { ToolContext } from \"eve/tools\";\nimport { defineTool } from \"eve/tools\";\nimport { executeEveDocumentTool } from \"@/lib/eve/document-tools\";\nimport { sheetGuidelines } from \"./guidelines\";\nimport type { z } from \"zod\";\n\ntype CreateSheetDocumentInput = Readonly<\n Omit<z.infer<typeof eveDocumentCreateInput>, \"fileIds\"> & {\n fileIds: readonly string[];\n }\n>;\n\ntype EditSheetDocumentInput = 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 createSheetDocument = defineTool({\n description: `Create a new sheet document in this conversation. Supply the complete content and a descriptive title. ${sheetGuidelines}`,\n execute: async (\n input: CreateSheetDocumentInput,\n context: ReadonlyDocumentToolContext\n ) =>\n eveDocumentWriteResult.parse(\n await executeEveDocumentTool(\"createSheetDocument\", input, context)\n ),\n inputSchema: eveDocumentCreateInput,\n outputSchema: eveDocumentWriteResult,\n});\nconst editSheetDocument = defineTool({\n description: `Edit an existing sheet document in this conversation. Read the document first and supply its revision ID. Supply the complete replacement content. ${sheetGuidelines}`,\n execute: async (\n input: EditSheetDocumentInput,\n context: ReadonlyDocumentToolContext\n ) =>\n eveDocumentWriteResult.parse(\n await executeEveDocumentTool(\"editSheetDocument\", input, context)\n ),\n inputSchema: eveDocumentEditInput,\n outputSchema: eveDocumentWriteResult,\n});\nexport { createSheetDocument, editSheetDocument };\n",
|
|
18
|
-
"type": "registry:file",
|
|
19
|
-
"target": "~/chatjs/tools/sheet-documents/tool.ts"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "src/tools/sheet-documents/definition.ts",
|
|
23
|
-
"content": "import { z } from \"zod\";\nimport type { DocumentDefinition } from \"@/chatjs/core/documents/document-definition\";\n\nexport const documentDefinition = {\n kind: \"sheet\",\n contentSchema: z.string().max(2_000_000),\n createTool: \"createSheetDocument\",\n editTool: \"editSheetDocument\",\n} as const satisfies DocumentDefinition;\n",
|
|
24
|
-
"type": "registry:file",
|
|
25
|
-
"target": "~/chatjs/tools/sheet-documents/definition.ts"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"path": "src/tools/sheet-documents/guidelines.ts",
|
|
29
|
-
"content": "export const sheetGuidelines = `\nIMPORTANT CSV FORMATTING RULES:\n- NEVER use commas (,) within cell contents as they will break the CSV format\n- For numbers over 999, do not use any thousand separators (write as: 10000 not 10,000)\n- Use semicolons (;) or spaces to separate multiple items in a cell`;\n",
|
|
30
|
-
"type": "registry:file",
|
|
31
|
-
"target": "~/chatjs/tools/sheet-documents/guidelines.ts"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"path": "src/tools/sheet-documents/configuration-schema.ts",
|
|
35
|
-
"content": "import { z } from \"zod\";\nimport { languageModelSchema, modelRoles } from \"@/lib/config-models\";\n\nconst configSchema = z\n .strictObject({\n analyze: languageModelSchema.default(modelRoles.balanced),\n format: languageModelSchema.default(modelRoles.balanced),\n })\n .prefault({});\nexport { configSchema };\n",
|
|
36
|
-
"type": "registry:file",
|
|
37
|
-
"target": "~/chatjs/tools/sheet-documents/configuration-schema.ts"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"path": "src/tools/sheet-documents/assistant-actions.ts",
|
|
41
|
-
"content": "import type { DocumentAssistantAction } from \"@/chatjs/core/documents/contracts\";\nimport { config } from \"@/lib/config\";\nimport { installedDocumentKinds } from \"@/integrations/tools/catalog\";\n\nconst documentAssistantActions = (): DocumentAssistantAction[] => [\n {\n instruction: \"Format and clean the spreadsheet data.\",\n label: \"Format and clean data\",\n modelId: config.ai.tools.sheet.format,\n },\n ...(installedDocumentKinds.has(\"code\")\n ? [\n {\n instruction:\n \"Analyze and visualize the spreadsheet data by creating a new Python code document.\",\n label: \"Analyze and visualize data\",\n modelId: config.ai.tools.sheet.analyze,\n },\n ]\n : []),\n];\nexport { documentAssistantActions };\n",
|
|
42
|
-
"type": "registry:file",
|
|
43
|
-
"target": "~/chatjs/tools/sheet-documents/assistant-actions.ts"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"path": "src/tools/sheet-documents/document.tsx",
|
|
47
|
-
"content": "\"use client\";\nimport type { DocumentBodyProps, DocumentUi } from \"@/chatjs/core/documents/ui\";\nimport { parse, unparse } from \"papaparse\";\nimport { documentDefinition } from \"./definition\";\nimport { documentAssistantActions } from \"./assistant-actions\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport dynamic from \"next/dynamic\";\n\nconst SpreadsheetEditor = dynamic(\n async () => {\n const { SpreadsheetEditor: Editor } = await import(\"./editor\");\n return Editor;\n },\n { ssr: false }\n);\n\nexport const documentUi: DocumentUi = {\n copyLabel: \"Copy as .csv\",\n copySuccessMessage: \"Copied csv to clipboard!\",\n copyIconSize: 16,\n copyButtonClassName: \"hover:bg-accent h-fit p-2\",\n definition: documentDefinition,\n assistantActions: documentAssistantActions,\n Body: ({ editorProps }: ReadonlyNativeSurface<DocumentBodyProps>) => (\n <div className=\"min-h-0 flex-1 overflow-hidden\">\n <SpreadsheetEditor\n {...editorProps}\n saveContent={editorProps.onSaveContent}\n />\n </div>\n ),\n copyContent: (content) => {\n const parsed = parse<string[]>(content, { skipEmptyLines: true });\n return unparse(\n parsed.data.filter((row: readonly string[]) =>\n row.some((cell) => cell.trim() !== \"\")\n )\n );\n },\n};\n",
|
|
48
|
-
"type": "registry:file",
|
|
49
|
-
"target": "~/chatjs/tools/sheet-documents/document.tsx"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"path": "src/tools/sheet-documents/editor.tsx",
|
|
53
|
-
"content": "\"use client\";\n\nimport \"react-data-grid/lib/styles.css\";\nimport React, { memo, useMemo, useState } from \"react\";\nimport { parse, unparse } from \"papaparse\";\nimport type { CellClickArgs, CellMouseEvent } from \"react-data-grid\";\nimport DataGrid, { textEditor } from \"react-data-grid\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { cn } from \"@/lib/utils\";\nimport { useTheme } from \"next-themes\";\n\ninterface SheetEditorProps {\n content: string;\n currentVersionIndex: number;\n isCurrentVersion: boolean;\n isReadonly?: boolean;\n saveContent: (content: string, isCurrentVersion: boolean) => void;\n status: string;\n}\n\nconst MIN_ROWS = 50;\nconst MIN_COLS = 26;\n\nconst PureSpreadsheetEditor = ({\n content,\n saveContent,\n status: _status,\n isCurrentVersion: _isCurrentVersion,\n isReadonly,\n}: ReadonlyNativeSurface<SheetEditorProps>): React.JSX.Element => {\n const { resolvedTheme } = useTheme();\n\n const parseData = useMemo(() => {\n if (!content) {\n return Array.from({ length: MIN_ROWS }, () =>\n Array.from({ length: MIN_COLS }, (): string => \"\")\n );\n }\n const result = parse<string[]>(content, { skipEmptyLines: true });\n\n const paddedData = result.data.map(\n (row: ReadonlyNativeSurface<string[]>): string[] => {\n const paddedRow = [...row];\n while (paddedRow.length < MIN_COLS) {\n paddedRow.push(\"\");\n }\n return paddedRow;\n }\n );\n\n while (paddedData.length < MIN_ROWS) {\n paddedData.push(Array.from({ length: MIN_COLS }, (): string => \"\"));\n }\n\n return paddedData;\n }, [content]);\n\n const columns = useMemo(() => {\n const rowNumberColumn = {\n cellClass: \"border-t border-r bg-background text-foreground\",\n frozen: true,\n headerCellClass: \"border-t border-r bg-muted text-foreground\",\n key: \"rowNumber\",\n name: \"\",\n renderCell: ({ rowIdx }: Readonly<{ rowIdx: number }>): number =>\n rowIdx + 1,\n width: 50,\n };\n\n const dataColumns = Array.from({ length: MIN_COLS }, (_, i) => ({\n cellClass: cn(\"bg-background text-foreground border-t\", {\n \"border-l\": i !== 0,\n }),\n headerCellClass: cn(\"bg-muted text-foreground border-t\", {\n \"border-l\": i !== 0,\n }),\n key: i.toString(),\n name: String.fromCodePoint(65 + i),\n renderEditCell: isReadonly === true ? undefined : textEditor,\n width: 120,\n }));\n\n return [rowNumberColumn, ...dataColumns];\n }, [isReadonly]);\n\n const initialRows = useMemo(\n () =>\n parseData.map(\n (row: ReadonlyNativeSurface<string[]>, rowIndex: number) => {\n const rowData: Record<string, string | number> = {\n id: rowIndex,\n rowNumber: rowIndex + 1,\n };\n\n for (const [colIndex, col] of columns.slice(1).entries()) {\n rowData[col.key] = row[colIndex] || \"\";\n }\n\n return rowData;\n }\n ),\n [parseData, columns]\n );\n\n const [localRows, setLocalRows] =\n useState<ReadonlyNativeSurface<Record<string, string | number>[]>>(\n initialRows\n );\n\n const [previousRows, setPreviousRows] = useState(initialRows);\n if (previousRows !== initialRows) {\n setPreviousRows(initialRows);\n setLocalRows(initialRows);\n }\n\n const handleRowsChange = (\n newRows: ReadonlyNativeSurface<Record<string, string | number>[]>\n ): void => {\n if (isReadonly === true) {\n return;\n }\n\n setLocalRows(newRows);\n\n const updatedData = newRows.map(\n (row: ReadonlyNativeSurface<Record<string, string | number>>) =>\n columns\n .slice(1)\n .map((col: ReadonlyNativeSurface<(typeof columns)[number]>) => {\n const value = row[col.key];\n if (typeof value === \"number\") {\n return value === 0 || Number.isNaN(value) ? \"\" : value;\n }\n return value ?? \"\";\n })\n );\n\n const newCsvContent = unparse(updatedData);\n saveContent(newCsvContent, true);\n };\n\n return (\n <DataGrid\n className={resolvedTheme === \"dark\" ? \"rdg-dark\" : \"rdg-light\"}\n columns={columns}\n defaultColumnOptions={{\n resizable: true,\n sortable: true,\n }}\n enableVirtualization\n onCellClick={(\n args: ReadonlyNativeSurface<\n CellClickArgs<Record<string, string | number>>\n >,\n event: Readonly<Pick<CellMouseEvent, \"preventGridDefault\">>\n ): void => {\n if (args.column.key !== \"rowNumber\" && !(isReadonly === true)) {\n event.preventGridDefault();\n args.selectCell(true);\n }\n }}\n onRowsChange={isReadonly === true ? undefined : handleRowsChange}\n rows={localRows}\n style={{ height: \"100%\" }}\n />\n );\n};\n\nconst areEqual = (\n prevProps: ReadonlyNativeSurface<SheetEditorProps>,\n nextProps: ReadonlyNativeSurface<SheetEditorProps>\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.saveContent === nextProps.saveContent &&\n prevProps.isReadonly === nextProps.isReadonly;\n\nexport const SpreadsheetEditor = memo(PureSpreadsheetEditor, areEqual);\n",
|
|
54
|
-
"type": "registry:file",
|
|
55
|
-
"target": "~/chatjs/tools/sheet-documents/editor.tsx"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"path": "dist/source/sheet-documents.json",
|
|
59
|
-
"content": "{\n \"config\": {\n \"key\": \"sheet\"\n },\n \"documentKind\": \"sheet\",\n \"envRequirements\": [],\n \"id\": \"sheet-documents\",\n \"kind\": \"tool\",\n \"requiresTools\": [\n \"readDocument\"\n ],\n \"tools\": [\n {\n \"composer\": {\n \"icon\": \"Edit3\",\n \"name\": \"Canvas\",\n \"shortName\": \"Canvas\"\n },\n \"toolExport\": \"createSheetDocument\"\n },\n {\n \"composer\": {\n \"icon\": \"Edit3\",\n \"name\": \"Canvas\",\n \"shortName\": \"Canvas\"\n },\n \"toolExport\": \"editSheetDocument\"\n }\n ],\n \"contractVersion\": 2,\n \"uiBase\": \"radix\"\n}\n",
|
|
60
|
-
"type": "registry:file",
|
|
61
|
-
"target": "~/chatjs/tools/sheet-documents/chatjs.json"
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"meta": {
|
|
65
|
-
"chatjs": {
|
|
66
|
-
"config": {
|
|
67
|
-
"key": "sheet"
|
|
68
|
-
},
|
|
69
|
-
"documentKind": "sheet",
|
|
70
|
-
"envRequirements": [],
|
|
71
|
-
"id": "sheet-documents",
|
|
72
|
-
"kind": "tool",
|
|
73
|
-
"requiresTools": [
|
|
74
|
-
"readDocument"
|
|
75
|
-
],
|
|
76
|
-
"tools": [
|
|
77
|
-
{
|
|
78
|
-
"composer": {
|
|
79
|
-
"icon": "Edit3",
|
|
80
|
-
"name": "Canvas",
|
|
81
|
-
"shortName": "Canvas"
|
|
82
|
-
},
|
|
83
|
-
"toolExport": "createSheetDocument"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"composer": {
|
|
87
|
-
"icon": "Edit3",
|
|
88
|
-
"name": "Canvas",
|
|
89
|
-
"shortName": "Canvas"
|
|
90
|
-
},
|
|
91
|
-
"toolExport": "editSheetDocument"
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
"contractVersion": 2,
|
|
95
|
-
"uiBase": "radix"
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
"type": "registry:item"
|
|
99
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
-
"name": "tavily-search",
|
|
4
|
-
"description": "Use tavily-search for chat and deep research",
|
|
5
|
-
"dependencies": [
|
|
6
|
-
"ai@7.0.137",
|
|
7
|
-
"zod@4.5.4",
|
|
8
|
-
"@tavily/core@^0.3.3"
|
|
9
|
-
],
|
|
10
|
-
"files": [
|
|
11
|
-
{
|
|
12
|
-
"path": "src/tools/tavily-search/tavily-search-env.ts",
|
|
13
|
-
"content": "import { z } from \"zod\";\n\nconst environmentSchema = z.object({\n TAVILY_API_KEY: z.string().optional(),\n});\n\nconst readToolEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n) => environmentSchema.parse(environment);\n\nexport { readToolEnvironment };\n",
|
|
14
|
-
"type": "registry:file",
|
|
15
|
-
"target": "~/chatjs/tools/tavily-search/tavily-search-env.ts"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"path": "src/tools/tavily-search/tool.ts",
|
|
19
|
-
"content": "import type { ToolProgressWriter } from \"@/lib/ai/tool-context\";\nimport { tavily } from \"@tavily/core\";\nimport { defineTool } from \"eve/tools\";\nimport { readToolEnvironment } from \"./tavily-search-env\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { executeWithResearchProgress } from \"@/lib/eve/research-progress\";\nimport {\n DEFAULT_MAX_RESULTS,\n executeMultiQuerySearch,\n} from \"@/tools/platform/search-presentation\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport { webSearchInput, webSearchResult } from \"./schemas\";\nimport type { z } from \"zod\";\n\nconst TAVILY_COST_CENTS = 5;\nconst CENTS_PER_USD = 100;\ntype SearchInput = z.infer<typeof webSearchInput>;\ntype ReadonlySearchInput = Readonly<{\n search_queries: readonly Readonly<SearchInput[\"search_queries\"][number]>[];\n exclude_domains: Readonly<SearchInput[\"exclude_domains\"]>;\n searchDepth: SearchInput[\"searchDepth\"];\n topics: Readonly<SearchInput[\"topics\"]>;\n}>;\ntype ExecutionContext = Readonly<{\n abortSignal: Readonly<AbortSignal>;\n callId: string;\n}>;\ntype ResearchExecution = Readonly<{\n abortSignal: Readonly<AbortSignal>;\n dataStream: Readonly<ToolProgressWriter>;\n usage: Readonly<{ addCostUsd: (cost: number) => void }>;\n}>;\n\nconst FIRST_TOPIC_INDEX = 0;\nconst NEWS_LOOKBACK_DAYS = 7;\nconst createTavilySearch =\n (\n options: Readonly<{\n topics: Readonly<NonNullable<SearchInput[\"topics\"]>>;\n excludeDomains: readonly string[];\n searchDepth: NonNullable<SearchInput[\"searchDepth\"]>;\n }>\n ): ((\n query: Readonly<{ query: string; maxResults: number }>,\n index: number\n ) => Promise<{ content: string; title: string; url: string }[]>) =>\n async ({ query, maxResults }, index) => {\n const env = readToolEnvironment();\n if (\n !(typeof env.TAVILY_API_KEY === \"string\" && env.TAVILY_API_KEY !== \"\")\n ) {\n throw new Error(\"Set TAVILY_API_KEY to enable Tavily search.\");\n }\n const topic =\n options.topics[index] ?? options.topics[FIRST_TOPIC_INDEX] ?? \"general\";\n const response = await tavily({ apiKey: env.TAVILY_API_KEY }).search(\n query,\n {\n days: topic === \"news\" ? NEWS_LOOKBACK_DAYS : undefined,\n excludeDomains: [...options.excludeDomains],\n includeAnswer: true,\n maxResults,\n searchDepth: options.searchDepth,\n topic,\n }\n );\n return response.results.map(\n ({\n title,\n url,\n content,\n }: Readonly<{ title: string; url: string; content: string }>) => ({\n content,\n title,\n url,\n })\n );\n };\nexport const webSearch = defineTool({\n description: `Multi-query web search (supports depth, topic & result limits). Always cite sources inline.\n\nUse for:\n- General information gathering via web search\n\nAvoid:\n- Pulling content from a single known URL (use retrieveUrl instead)`,\n execute: (\n {\n search_queries,\n topics,\n searchDepth,\n exclude_domains,\n }: ReadonlySearchInput,\n context: ExecutionContext\n ) =>\n executeWithResearchProgress(\n context,\n async ({ dataStream, usage, abortSignal }: ResearchExecution) => {\n const toolCallId = context.callId;\n abortSignal.throwIfAborted();\n const log = createModuleLogger(\"tools/web-search\");\n log.debug(\n {\n exclude_domains,\n queriesCount: search_queries.length,\n searchDepth,\n topics,\n },\n \"webSearch.execute\"\n );\n // Handle nullable arrays with defaults\n const safeTopics: Readonly<NonNullable<SearchInput[\"topics\"]>> =\n topics ?? [\"general\"];\n const safeSearchDepth = searchDepth ?? \"basic\";\n const safeExcludeDomains = exclude_domains ?? [];\n const result = await executeMultiQuerySearch({\n completeTitle: \"Search complete\",\n dataStream,\n search: createTavilySearch({\n excludeDomains: safeExcludeDomains,\n searchDepth: safeSearchDepth,\n topics: safeTopics,\n }),\n search_queries: search_queries.map((query) => ({\n maxResults: query.maxResults ?? DEFAULT_MAX_RESULTS,\n query: query.query,\n })),\n title: \"Searching\",\n toolCallId,\n writeTopLevelUpdates: true,\n });\n\n // Report API cost\n usage.addCostUsd(TAVILY_COST_CENTS / CENTS_PER_USD);\n\n return result;\n },\n webSearchResult\n ),\n // Keep defaultable fields required and nullable for strict tool calling.\n inputSchema: webSearchInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
20
|
-
"type": "registry:file",
|
|
21
|
-
"target": "~/chatjs/tools/tavily-search/tool.ts"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"path": "src/tools/tavily-search/renderer.tsx",
|
|
25
|
-
"content": "\"use client\";\nimport { webSearchInput, webSearchResult } from \"./schemas\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { WebSearch } from \"@/components/part/web-search\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\n\nconst WebSearchView = ({\n tool,\n messageId,\n}: ReadonlyNativeSurface<{\n tool: ToolRendererProps<\n typeof webSearchInput,\n typeof webSearchResult\n >[\"tool\"];\n messageId: string;\n isReadonly: boolean;\n}>): React.JSX.Element => <WebSearch messageId={messageId} part={tool} />;\n\nexport const WebSearchRenderer = defineToolRenderer({\n inputSchema: webSearchInput,\n outputSchema: webSearchResult,\n render: WebSearchView,\n});\n",
|
|
26
|
-
"type": "registry:file",
|
|
27
|
-
"target": "~/chatjs/tools/tavily-search/renderer.tsx"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"path": "src/tools/tavily-search/schemas.ts",
|
|
31
|
-
"content": "import { searchQueriesSchema } from \"@/tools/platform/search-presentation\";\nimport { z } from \"zod\";\n\nconst webSearchInput = z.object({\n exclude_domains: z\n .array(z.string())\n .describe(\n \"Domains to exclude from all results. Pass null for no exclusions.\"\n )\n .nullable(),\n searchDepth: z\n .enum([\"basic\", \"advanced\"])\n .describe('Search depth to use. Pass null for \"basic\".')\n .nullable(),\n search_queries: searchQueriesSchema,\n topics: z\n .array(z.enum([\"general\", \"news\"]))\n .describe(\n \"Array of topic types to search for. Pass null for general search.\"\n )\n .nullable(),\n});\n\nconst searchResult = z.object({\n content: z.string(),\n title: z.string(),\n url: z.string(),\n});\n\nconst searchQuery = z.object({ maxResults: z.number(), query: z.string() });\nconst queryResults = z.object({\n query: searchQuery,\n results: z.array(searchResult),\n});\nconst webSearchResult = z.object({\n error: z.string().optional(),\n searches: z.array(queryResults),\n});\nexport { webSearchInput, webSearchResult };\n",
|
|
32
|
-
"type": "registry:file",
|
|
33
|
-
"target": "~/chatjs/tools/tavily-search/schemas.ts"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "dist/source/tavily-search.json",
|
|
37
|
-
"content": "{\n \"envRequirements\": [{ \"options\": [[\"TAVILY_API_KEY\"]] }],\n \"id\": \"tavily-search\",\n \"kind\": \"tool\",\n \"requiresTools\": [],\n \"slot\": \"webSearch\",\n \"tools\": [\n {\n \"composer\": {\n \"icon\": \"Globe\",\n \"name\": \"Web Search\",\n \"shortName\": \"Search\"\n },\n \"rendererExport\": \"WebSearchRenderer\",\n \"toolExport\": \"webSearch\"\n }\n ],\n \"contractVersion\": 1\n}\n",
|
|
38
|
-
"type": "registry:file",
|
|
39
|
-
"target": "~/chatjs/tools/tavily-search/chatjs.json"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"meta": {
|
|
43
|
-
"chatjs": {
|
|
44
|
-
"envRequirements": [
|
|
45
|
-
{
|
|
46
|
-
"options": [
|
|
47
|
-
[
|
|
48
|
-
"TAVILY_API_KEY"
|
|
49
|
-
]
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"id": "tavily-search",
|
|
54
|
-
"kind": "tool",
|
|
55
|
-
"requiresTools": [],
|
|
56
|
-
"slot": "webSearch",
|
|
57
|
-
"tools": [
|
|
58
|
-
{
|
|
59
|
-
"composer": {
|
|
60
|
-
"icon": "Globe",
|
|
61
|
-
"name": "Web Search",
|
|
62
|
-
"shortName": "Search"
|
|
63
|
-
},
|
|
64
|
-
"rendererExport": "WebSearchRenderer",
|
|
65
|
-
"toolExport": "webSearch"
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
"contractVersion": 1
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"type": "registry:item"
|
|
72
|
-
}
|