@chat-js/registry 0.2.0-beta.3 → 0.2.0-beta.4

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.
Files changed (133) hide show
  1. package/README.md +1 -1
  2. package/dist/r/ai-titles.json +1 -1
  3. package/dist/r/attach-workspace-file.json +82 -0
  4. package/dist/r/attachment-uploads.json +1 -2
  5. package/dist/r/base/ai-titles.json +1 -1
  6. package/dist/r/base/attach-workspace-file.json +82 -0
  7. package/dist/r/base/attachment-uploads.json +1 -2
  8. package/dist/r/base/deep-research.json +46 -123
  9. package/dist/r/base/default-sandbox.json +35 -0
  10. package/dist/r/base/docker-sandbox.json +35 -0
  11. package/dist/r/base/generate-image.json +10 -4
  12. package/dist/r/base/generate-video.json +9 -3
  13. package/dist/r/base/guest-chat.json +2 -2
  14. package/dist/r/base/image-viewer.json +55 -0
  15. package/dist/r/base/just-bash-sandbox.json +32 -0
  16. package/dist/r/base/litellm-gateway.json +1 -1
  17. package/dist/r/base/mcp.json +1 -1
  18. package/dist/r/base/openai-compatible-gateway.json +1 -1
  19. package/dist/r/base/openai-gateway.json +1 -1
  20. package/dist/r/base/openrouter-gateway.json +1 -1
  21. package/dist/r/base/projects.json +3 -3
  22. package/dist/r/base/registry.json +965 -1746
  23. package/dist/r/base/search.json +6 -6
  24. package/dist/r/base/sharing.json +3 -3
  25. package/dist/r/base/spreadsheet-grid.json +20 -0
  26. package/dist/r/base/spreadsheet-viewer.json +68 -0
  27. package/dist/r/base/vercel-gateway.json +1 -1
  28. package/dist/r/base/vercel-sandbox.json +8 -26
  29. package/dist/r/base/video-viewer.json +48 -0
  30. package/dist/r/deep-research.json +46 -123
  31. package/dist/r/default-sandbox.json +35 -0
  32. package/dist/r/docker-sandbox.json +35 -0
  33. package/dist/r/eve/deep-research.json +47 -0
  34. package/dist/r/eve/registry.json +53 -0
  35. package/dist/r/generate-image.json +10 -4
  36. package/dist/r/generate-video.json +9 -3
  37. package/dist/r/guest-chat.json +2 -2
  38. package/dist/r/image-viewer.json +55 -0
  39. package/dist/r/just-bash-sandbox.json +32 -0
  40. package/dist/r/litellm-gateway.json +1 -1
  41. package/dist/r/mcp.json +1 -1
  42. package/dist/r/openai-compatible-gateway.json +1 -1
  43. package/dist/r/openai-gateway.json +1 -1
  44. package/dist/r/openrouter-gateway.json +1 -1
  45. package/dist/r/projects.json +3 -3
  46. package/dist/r/radix/ai-titles.json +1 -1
  47. package/dist/r/radix/attach-workspace-file.json +82 -0
  48. package/dist/r/radix/attachment-uploads.json +1 -2
  49. package/dist/r/radix/deep-research.json +46 -123
  50. package/dist/r/radix/default-sandbox.json +35 -0
  51. package/dist/r/radix/docker-sandbox.json +35 -0
  52. package/dist/r/radix/generate-image.json +10 -4
  53. package/dist/r/radix/generate-video.json +9 -3
  54. package/dist/r/radix/guest-chat.json +2 -2
  55. package/dist/r/radix/image-viewer.json +55 -0
  56. package/dist/r/radix/just-bash-sandbox.json +32 -0
  57. package/dist/r/radix/litellm-gateway.json +1 -1
  58. package/dist/r/radix/mcp.json +1 -1
  59. package/dist/r/radix/openai-compatible-gateway.json +1 -1
  60. package/dist/r/radix/openai-gateway.json +1 -1
  61. package/dist/r/radix/openrouter-gateway.json +1 -1
  62. package/dist/r/radix/projects.json +3 -3
  63. package/dist/r/radix/registry.json +968 -1749
  64. package/dist/r/radix/search.json +6 -6
  65. package/dist/r/radix/sharing.json +3 -3
  66. package/dist/r/radix/spreadsheet-grid.json +20 -0
  67. package/dist/r/radix/spreadsheet-viewer.json +68 -0
  68. package/dist/r/radix/vercel-gateway.json +1 -1
  69. package/dist/r/radix/vercel-sandbox.json +8 -26
  70. package/dist/r/radix/video-viewer.json +48 -0
  71. package/dist/r/registry.json +965 -1746
  72. package/dist/r/search.json +6 -6
  73. package/dist/r/sharing.json +3 -3
  74. package/dist/r/spreadsheet-grid.json +20 -0
  75. package/dist/r/spreadsheet-viewer.json +68 -0
  76. package/dist/r/vercel-gateway.json +1 -1
  77. package/dist/r/vercel-sandbox.json +8 -26
  78. package/dist/r/video-viewer.json +48 -0
  79. package/package.json +5 -26
  80. package/dist/r/base/code-documents.json +0 -101
  81. package/dist/r/base/code-execution-runtime.json +0 -25
  82. package/dist/r/base/code-execution-ui.json +0 -32
  83. package/dist/r/base/code-execution.json +0 -69
  84. package/dist/r/base/daytona-sandbox.json +0 -55
  85. package/dist/r/base/delete-document.json +0 -58
  86. package/dist/r/base/firecrawl-search.json +0 -72
  87. package/dist/r/base/get-weather.json +0 -59
  88. package/dist/r/base/langfuse.json +0 -63
  89. package/dist/r/base/read-document.json +0 -34
  90. package/dist/r/base/retrieve-url.json +0 -72
  91. package/dist/r/base/saved-code-execution.json +0 -84
  92. package/dist/r/base/sheet-documents.json +0 -99
  93. package/dist/r/base/tavily-search.json +0 -72
  94. package/dist/r/base/text-documents.json +0 -122
  95. package/dist/r/base/vercel-analytics.json +0 -46
  96. package/dist/r/base/vercel-speed-insights.json +0 -46
  97. package/dist/r/base/word-count.json +0 -58
  98. package/dist/r/code-documents.json +0 -101
  99. package/dist/r/code-execution-runtime.json +0 -25
  100. package/dist/r/code-execution-ui.json +0 -32
  101. package/dist/r/code-execution.json +0 -69
  102. package/dist/r/daytona-sandbox.json +0 -55
  103. package/dist/r/delete-document.json +0 -58
  104. package/dist/r/firecrawl-search.json +0 -72
  105. package/dist/r/get-weather.json +0 -59
  106. package/dist/r/langfuse.json +0 -63
  107. package/dist/r/radix/code-documents.json +0 -101
  108. package/dist/r/radix/code-execution-runtime.json +0 -25
  109. package/dist/r/radix/code-execution-ui.json +0 -32
  110. package/dist/r/radix/code-execution.json +0 -69
  111. package/dist/r/radix/daytona-sandbox.json +0 -55
  112. package/dist/r/radix/delete-document.json +0 -58
  113. package/dist/r/radix/firecrawl-search.json +0 -72
  114. package/dist/r/radix/get-weather.json +0 -59
  115. package/dist/r/radix/langfuse.json +0 -63
  116. package/dist/r/radix/read-document.json +0 -34
  117. package/dist/r/radix/retrieve-url.json +0 -72
  118. package/dist/r/radix/saved-code-execution.json +0 -84
  119. package/dist/r/radix/sheet-documents.json +0 -99
  120. package/dist/r/radix/tavily-search.json +0 -72
  121. package/dist/r/radix/text-documents.json +0 -122
  122. package/dist/r/radix/vercel-analytics.json +0 -46
  123. package/dist/r/radix/vercel-speed-insights.json +0 -46
  124. package/dist/r/radix/word-count.json +0 -58
  125. package/dist/r/read-document.json +0 -34
  126. package/dist/r/retrieve-url.json +0 -72
  127. package/dist/r/saved-code-execution.json +0 -84
  128. package/dist/r/sheet-documents.json +0 -99
  129. package/dist/r/tavily-search.json +0 -72
  130. package/dist/r/text-documents.json +0 -122
  131. package/dist/r/vercel-analytics.json +0 -46
  132. package/dist/r/vercel-speed-insights.json +0 -46
  133. package/dist/r/word-count.json +0 -58
@@ -1,32 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
- "name": "code-execution-ui",
4
- "description": "Shared chart renderer for installed code execution tools",
5
- "dependencies": [
6
- "echarts@6.0.0",
7
- "echarts-for-react@^3.0.2",
8
- "motion@^12.23.24",
9
- "next-themes@^0.4.6"
10
- ],
11
- "files": [
12
- {
13
- "path": "src/ui/code-execution/code-execution-chart.tsx",
14
- "content": "\"use client\";\nimport type { BaseChart } from \"./interactive-charts\";\nimport Image from \"next/image\";\nimport InteractiveChart from \"./interactive-charts\";\nimport React from \"react\";\nimport { z } from \"zod\";\n\nconst chartLabels = {\n title: z.string().default(\"\"),\n x_label: z.string().optional(),\n y_label: z.string().optional(),\n};\nconst series = z.array(\n z.object({\n label: z.string(),\n points: z.array(z.tuple([z.union([z.number(), z.string()]), z.number()])),\n })\n);\nconst chartSchema = z.discriminatedUnion(\"type\", [\n z.object({\n ...chartLabels,\n elements: series,\n type: z.literal(\"line\"),\n x_scale: z\n .literal(\"datetime\")\n .nullish()\n .transform((value) => value ?? undefined),\n }),\n z.object({\n ...chartLabels,\n elements: series,\n type: z.literal(\"scatter\"),\n x_scale: z\n .literal(\"datetime\")\n .nullish()\n .transform((value) => value ?? undefined),\n }),\n z.object({\n ...chartLabels,\n elements: z.array(\n z.object({ group: z.string(), label: z.string(), value: z.number() })\n ),\n type: z.literal(\"bar\"),\n }),\n]);\nconst MIN_PNG_BASE64_LENGTH = 1;\nconst pngSchema = z.object({\n base64: z.string().min(MIN_PNG_BASE64_LENGTH),\n format: z.literal(\"png\"),\n});\n\nexport const CodeExecutionChart = ({\n value,\n}: {\n readonly value: unknown;\n}): React.JSX.Element => {\n const parsedChart = chartSchema.safeParse(value);\n const chart: BaseChart | null = parsedChart.success ? parsedChart.data : null;\n const parsedPng = pngSchema.safeParse(value);\n const pngChart = parsedPng.success ? parsedPng.data : null;\n return (\n <>\n {chart && (\n <div className=\"pt-1\">\n <InteractiveChart chart={chart} />\n </div>\n )}\n\n {pngChart && (\n <div className=\"relative aspect-[4/3] w-full\">\n <Image\n alt=\"Chart output\"\n className=\"rounded-lg object-contain\"\n fill\n sizes=\"(max-width: 768px) 100vw, 768px\"\n src={`data:image/png;base64,${pngChart.base64}`}\n unoptimized\n />\n </div>\n )}\n </>\n );\n};\n",
15
- "type": "registry:file",
16
- "target": "~/chatjs/tools/_shared/code-execution/code-execution-chart.tsx"
17
- },
18
- {
19
- "path": "src/ui/code-execution/interactive-charts.tsx",
20
- "content": "import { Card } from \"@/components/ui/card\";\nimport React from \"react\";\nimport dynamic from \"next/dynamic\";\n\nconst ChartSkeleton = (): React.JSX.Element => (\n <Card className=\"border-border bg-card overflow-hidden\">\n <div className=\"flex h-[400px] items-center justify-center p-6\">\n <div className=\"bg-muted size-8 animate-pulse rounded-md\" />\n </div>\n </Card>\n);\n\nexport type { BaseChart } from \"./interactive-chart-impl\";\nexport default dynamic(\n async () => {\n const { default: InteractiveChart } =\n await import(\"./interactive-chart-impl\");\n return InteractiveChart;\n },\n {\n loading: () => <ChartSkeleton />,\n ssr: false,\n }\n);\n",
21
- "type": "registry:file",
22
- "target": "~/chatjs/tools/_shared/code-execution/interactive-charts.tsx"
23
- },
24
- {
25
- "path": "src/ui/code-execution/interactive-chart-impl.tsx",
26
- "content": "\"use client\";\nimport type {\n BarSeriesOption,\n EChartsOption,\n LineSeriesOption,\n ScatterSeriesOption,\n} from \"echarts\";\nimport { Card } from \"@/components/ui/card\";\nimport React from \"react\";\nimport ReactECharts from \"echarts-for-react/lib/index\";\nimport { motion } from \"motion/react\";\nimport { useTheme } from \"next-themes\";\n\nconst CHART_COLORS = [\n \"#22c55e\",\n \"#3b82f6\",\n \"#f59e0b\",\n \"#8b5cf6\",\n \"#ec4899\",\n \"#06b6d4\",\n \"#ef4444\",\n \"#84cc16\",\n];\n\ninterface LineScatterElement {\n readonly label: string;\n readonly points: readonly (readonly [number | string, number])[];\n}\n\ninterface BarElement {\n readonly group: string;\n readonly label: string;\n readonly value: number;\n}\n\ninterface BaseChartCommon {\n readonly title: string;\n readonly x_label?: string;\n readonly y_label?: string;\n}\n\ntype LineChart = BaseChartCommon & {\n readonly type: \"line\";\n readonly x_scale?: \"datetime\";\n readonly elements: readonly LineScatterElement[];\n};\n\ntype ScatterChart = BaseChartCommon & {\n readonly type: \"scatter\";\n readonly x_scale?: \"datetime\";\n readonly elements: readonly LineScatterElement[];\n};\n\ntype BarChart = BaseChartCommon & {\n readonly type: \"bar\";\n readonly x_scale?: undefined;\n readonly elements: readonly BarElement[];\n};\n\ntype BaseChart = LineChart | ScatterChart | BarChart;\n\nconst InteractiveChart = ({\n chart,\n}: {\n readonly chart: BaseChart;\n}): React.JSX.Element => {\n const { resolvedTheme } = useTheme();\n const isDark = resolvedTheme === \"dark\";\n const textColor = isDark ? \"#e5e5e5\" : \"#262626\";\n const gridColor = isDark ? \"rgba(255, 255, 255, 0.1)\" : \"rgba(0, 0, 0, 0.15)\";\n const tooltipBg = isDark ? \"#171717\" : \"#ffffff\";\n\n const sharedOptions: EChartsOption = {\n backgroundColor: \"transparent\",\n grid: {\n bottom: 32,\n containLabel: true,\n left: 32,\n right: 32,\n top: 50,\n },\n legend: {\n icon: \"circle\",\n itemGap: 16,\n itemHeight: 8,\n itemWidth: 8,\n textStyle: { color: textColor },\n top: 8,\n },\n tooltip: {\n backgroundColor: tooltipBg,\n borderWidth: 0,\n className: \"echarts-tooltip rounded-lg! border! border-border!\",\n padding: [6, 10],\n textStyle: {\n color: textColor,\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n fontSize: 13,\n },\n trigger: \"axis\",\n },\n };\n\n const getChartOptions = (): EChartsOption => {\n const defaultAxisOptions = {\n axisLabel: {\n color: textColor,\n fontSize: 11,\n hideOverlap: true,\n margin: 8,\n },\n axisLine: { lineStyle: { color: gridColor }, show: true },\n axisTick: { show: false },\n nameTextStyle: {\n color: textColor,\n fontSize: 13,\n padding: [0, 0, 0, 0],\n },\n splitLine: {\n lineStyle: { color: gridColor, type: \"dashed\" },\n show: true,\n },\n } satisfies NonNullable<EChartsOption[\"xAxis\"]>;\n\n if (chart.type === \"line\" || chart.type === \"scatter\") {\n const series = chart.elements.map(\n (element, index): LineSeriesOption | ScatterSeriesOption => ({\n areaStyle:\n chart.type === \"line\"\n ? {\n color: {\n colorStops: [\n {\n color: `${CHART_COLORS[index % CHART_COLORS.length]}15`,\n offset: 0,\n },\n { color: \"rgba(23, 23, 23, 0)\", offset: 1 },\n ],\n type: \"linear\",\n x: 0,\n x2: 0,\n y: 0,\n y2: 1,\n },\n }\n : undefined,\n data: element.points.map(\n (point: readonly [number | string, number]) => {\n const horizontalValue =\n chart.x_scale === \"datetime\"\n ? new Date(point[0]).getTime()\n : point[0];\n return [horizontalValue, point[1]];\n }\n ),\n itemStyle: {\n color: CHART_COLORS[index % CHART_COLORS.length],\n },\n lineStyle: {\n color: CHART_COLORS[index % CHART_COLORS.length],\n width: 2,\n },\n name: element.label,\n smooth: true,\n symbolSize: chart.type === \"scatter\" ? 10 : 0,\n type: chart.type,\n })\n );\n\n return {\n ...sharedOptions,\n series,\n xAxis: {\n name: chart.x_label,\n nameGap: 40,\n nameLocation: \"middle\",\n scale: true,\n type: chart.x_scale === \"datetime\" ? \"time\" : \"value\",\n ...defaultAxisOptions,\n axisLabel: {\n ...defaultAxisOptions.axisLabel,\n formatter:\n chart.x_scale === \"datetime\"\n ? (value: number): string => {\n const date = new Date(value);\n return date.toLocaleDateString(\"en-US\", {\n month: \"short\",\n year: \"numeric\",\n });\n }\n : undefined,\n },\n },\n yAxis: {\n name: chart.y_label,\n nameGap: 50,\n nameLocation: \"middle\",\n position: \"right\",\n scale: true,\n type: \"value\",\n ...defaultAxisOptions,\n },\n };\n }\n\n if (chart.type === \"bar\") {\n const data: Record<string, BarElement[]> = {};\n for (const item of chart.elements) {\n const existingGroup = data[item.group];\n if (existingGroup === undefined) {\n data[item.group] = [];\n }\n data[item.group].push(item);\n }\n\n const series = Object.entries(data).map(\n (\n [group, elements]: readonly [string, readonly BarElement[]],\n index\n ): BarSeriesOption => ({\n data: elements.map((element: Readonly<BarElement>) => [\n element.label,\n element.value,\n ]),\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowColor: \"rgba(0,0,0,0.3)\",\n },\n },\n itemStyle: {\n color: CHART_COLORS[index % CHART_COLORS.length],\n },\n name: group,\n stack: \"total\",\n type: \"bar\",\n })\n );\n\n return {\n ...sharedOptions,\n series,\n xAxis: {\n name: chart.x_label,\n nameGap: 40,\n nameLocation: \"middle\",\n type: \"category\",\n ...defaultAxisOptions,\n },\n yAxis: {\n name: chart.y_label,\n nameGap: 50,\n nameLocation: \"middle\",\n position: \"right\",\n type: \"value\",\n ...defaultAxisOptions,\n },\n };\n }\n\n return sharedOptions;\n };\n\n return (\n <motion.div\n animate={{ opacity: 1, y: 0 }}\n initial={{ opacity: 0, y: 20 }}\n transition={{ duration: 0.5 }}\n >\n <Card className=\"border-border bg-card overflow-hidden\">\n <div className=\"p-6\">\n {chart.title && (\n <h3 className=\"text-foreground mb-4 text-lg font-medium\">\n {chart.title}\n </h3>\n )}\n <ReactECharts\n notMerge\n option={getChartOptions()}\n style={{ height: \"400px\", width: \"100%\" }}\n theme={resolvedTheme === \"dark\" ? \"dark\" : undefined}\n />\n </div>\n </Card>\n </motion.div>\n );\n};\n\nexport type { BarChart, BaseChart, LineChart, ScatterChart };\nexport default InteractiveChart;\n",
27
- "type": "registry:file",
28
- "target": "~/chatjs/tools/_shared/code-execution/interactive-chart-impl.tsx"
29
- }
30
- ],
31
- "type": "registry:item"
32
- }
@@ -1,69 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
- "name": "code-execution",
4
- "description": "Execute Python and JavaScript with the selected sandbox provider",
5
- "dependencies": [
6
- "ai@7.0.137",
7
- "zod@4.5.4"
8
- ],
9
- "registryDependencies": [
10
- "@chatjs/code-execution-ui",
11
- "@chatjs/code-execution-runtime"
12
- ],
13
- "files": [
14
- {
15
- "path": "src/tools/code-execution/tool.ts",
16
- "content": "import type { CodeExecutor } from \"@/lib/eve/code-executor\";\nimport { codeExecutionInput, codeExecutionResult } from \"./schemas\";\nimport { defineTool } from \"eve/tools\";\nimport { eveCodeSandboxOwnership } from \"@/lib/eve/code-sandbox-ownership\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { executeJavaScriptInSandbox } from \"@/chatjs/tools/_shared/code-execution/javascript\";\nimport { executePythonInSandbox } from \"@/chatjs/tools/_shared/code-execution/python\";\nimport { executeWithToolUsage } from \"@/lib/eve/tool-usage\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport { getSandboxProvider } from \"@/lib/sandbox/runtime\";\nimport { withSandbox } from \"@chat-js/sandboxes/runtime\";\n\nconst EXECUTION_COST_USD = 0.05;\nconst executeCode: CodeExecutor = async (input, context) =>\n await executeWithToolUsage(context, async (usage) => {\n const log = createModuleLogger(\"code-execution\");\n usage.addCostUsd(0);\n try {\n const result = await withSandbox(\n getSandboxProvider(),\n {\n ownership: eveCodeSandboxOwnership(context),\n runtime: input.language,\n signal: context.abortSignal,\n },\n async (sandbox) => {\n const execution = {\n code: input.code,\n log,\n requestId: context.callId,\n sandbox,\n };\n return input.language === \"javascript\"\n ? await executeJavaScriptInSandbox(execution)\n : await executePythonInSandbox(execution);\n }\n );\n const output = codeExecutionResult.parse(result);\n usage.addCostUsd(EXECUTION_COST_USD);\n return output;\n } catch (error) {\n log.error({ error, callId: context.callId }, \"code execution failed\");\n return usage.fail();\n }\n });\n\nconst codeExecution = defineTool({\n description: `Sandboxed code execution for Python and JavaScript.\n\nUse for:\n- Execute Python for calculations, data analysis, and visualisations\n- Execute JavaScript for scripting, transformations, async fetches, and general runtime checks\n\nPython support:\n- matplotlib, pandas, numpy, sympy, yfinance pre-installed — do NOT reinstall them\n- Produce interactive line / scatter / bar charts OR matplotlib PNG charts\n- Install extra libs by adding lines like: '!pip install <pkg> [<pkg2> ...]' (we auto-install and strip these lines; pre-installed packages are ignored)\n\nJavaScript support:\n- Runs in a sandboxed Node.js runtime, never in the browser thread\n- Use console.log(...) to print output\n- You can also assign 'result' or 'results', or return a value from the snippet\n\nChart output — Python only:\n1. Interactive chart (preferred for line/scatter/bar): assign a 'chart' variable matching this schema:\n chart = {\n \"type\": \"line\" | \"scatter\" | \"bar\",\n \"title\": \"My Chart\",\n \"x_label\": \"X\", # optional\n \"y_label\": \"Y\", # optional\n \"x_scale\": \"datetime\" | None, # optional, for time-series x axes\n \"elements\": [\n # for line/scatter: {\"label\": \"Series A\", \"points\": [[x1,y1],[x2,y2],...]}\n # for bar: {\"label\": \"Category\", \"group\": \"Group A\", \"value\": 42}\n ]\n }\n2. Matplotlib PNG: use plt.plot()/plt.savefig() normally (no need to call plt.show())\n\nRestrictions:\n- No images in the assistant response; don't embed them\n- Interactive chart: only line / scatter / bar types\n\nOutput rules:\n- Set language to 'python' or 'javascript'\n- Python charts: assign 'chart' dict for interactive charts (takes priority over matplotlib PNG)\n- Python values: assign 'result' or 'results', or print explicitly\n- JavaScript values: assign 'result' or 'results', return a value, or print explicitly\n- Don't rely on implicit REPL last-expression output`,\n execute: executeCode,\n inputSchema: codeExecutionInput,\n toModelOutput: toolResultToModelOutput,\n});\nexport { codeExecution, executeCode };\n",
17
- "type": "registry:file",
18
- "target": "~/chatjs/tools/code-execution/tool.ts"
19
- },
20
- {
21
- "path": "src/tools/code-execution/renderer.tsx",
22
- "content": "\"use client\";\nimport { codeExecutionInput, codeExecutionResult } from \"./schemas\";\nimport { CodeExecutionChart } from \"@/chatjs/tools/_shared/code-execution/code-execution-chart\";\nimport React from \"react\";\n// Preserve the exact TSX target: shadcn otherwise confuses it with subagent sandbox.ts files.\nimport { SandboxComposed } from \"@/components/sandbox.tsx\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\n\ntype CodeExecutionTool = ToolRendererProps<\n typeof codeExecutionInput,\n typeof codeExecutionResult\n>[\"tool\"];\n\ntype CodeExecutionViewTool = Readonly<{\n state: CodeExecutionTool[\"state\"];\n input?: Readonly<{\n code?: string;\n language?: string;\n title?: string;\n }>;\n output?: Readonly<{\n chart: unknown;\n message: string;\n }>;\n}>;\n\nconst CodeExecutionView = ({\n tool,\n}: Readonly<{ tool: CodeExecutionViewTool }>): React.JSX.Element => {\n const args = tool.input ?? {\n code: \"\",\n icon: \"default\",\n language: \"python\",\n title: \"\",\n };\n const result = tool.state === \"output-available\" ? tool.output : null;\n const code = typeof args.code === \"string\" ? args.code : \"\";\n const title = typeof args.title === \"string\" ? args.title : \"\";\n const language = args.language === \"javascript\" ? \"javascript\" : \"python\";\n return (\n <div className=\"space-y-6\">\n <SandboxComposed\n code={code}\n language={language}\n output={result?.message}\n state={tool.state}\n title={title}\n />\n\n <CodeExecutionChart value={result?.chart} />\n </div>\n );\n};\n\nconst CodeExecution = defineToolRenderer({\n inputSchema: codeExecutionInput,\n outputSchema: codeExecutionResult,\n render: CodeExecutionView,\n streamingInputSchema: codeExecutionInput.partial().extend({\n // oxlint-disable-next-line promise/prefer-await-to-then, unicorn/no-useless-undefined -- oxc-project/oxc#22161: synchronous Zod fallback preserves streamed code on invalid language. Zod requires the undefined fallback argument.\n language: codeExecutionInput.shape.language.optional().catch(undefined),\n // oxlint-disable-next-line promise/prefer-await-to-then, unicorn/no-useless-undefined -- oxc-project/oxc#22161: synchronous Zod fallback preserves streamed code on invalid title. Zod requires the undefined fallback argument.\n title: codeExecutionInput.shape.title.optional().catch(undefined),\n }),\n});\nexport { CodeExecution };\nexport type { CodeExecutionTool };\n",
23
- "type": "registry:file",
24
- "target": "~/chatjs/tools/code-execution/renderer.tsx"
25
- },
26
- {
27
- "path": "src/tools/code-execution/schemas.ts",
28
- "content": "import { supportedExecutionLanguages } from \"@/chatjs/tools/_shared/code-execution/types\";\nimport { z } from \"zod\";\n\nconst codeExecutionInput = z.object({\n code: z\n .string()\n .describe(\n \"The code to execute in the selected sandbox language. Print anything you want to return, or assign to 'result'/'results'.\"\n ),\n language: z\n .enum(supportedExecutionLanguages)\n .default(\"python\")\n .describe(\"The language to execute: 'python' or 'javascript'.\"),\n title: z.string().describe(\"The title of the code snippet.\"),\n});\n\nconst encodedChart = z.object({ base64: z.string(), format: z.string() });\nconst chartRecord = z.record(z.string(), z.json());\nconst codeExecutionResult = z.object({\n message: z.string(),\n chart: z.union([z.string(), encodedChart, chartRecord]),\n});\nexport { codeExecutionInput, codeExecutionResult };\n",
29
- "type": "registry:file",
30
- "target": "~/chatjs/tools/code-execution/schemas.ts"
31
- },
32
- {
33
- "path": "dist/source/code-execution.json",
34
- "content": "{\n \"codeExecutionCapabilities\": {\n \"cancellation\": \"terminate\",\n \"cleanup\": \"durable-allocation\",\n \"files\": \"ephemeral\",\n \"languages\": [\"python\", \"javascript\"],\n \"timeout\": \"bounded\",\n \"usage\": \"single-receipt\"\n },\n \"codeExecutorExport\": \"executeCode\",\n \"envRequirements\": [],\n \"id\": \"code-execution\",\n \"kind\": \"tool\",\n \"requiresSandbox\": true,\n \"requiresTools\": [],\n \"slot\": \"codeExecution\",\n \"tools\": [\n { \"rendererExport\": \"CodeExecution\", \"toolExport\": \"codeExecution\" }\n ],\n \"contractVersion\": 1\n}\n",
35
- "type": "registry:file",
36
- "target": "~/chatjs/tools/code-execution/chatjs.json"
37
- }
38
- ],
39
- "meta": {
40
- "chatjs": {
41
- "codeExecutionCapabilities": {
42
- "cancellation": "terminate",
43
- "cleanup": "durable-allocation",
44
- "files": "ephemeral",
45
- "languages": [
46
- "python",
47
- "javascript"
48
- ],
49
- "timeout": "bounded",
50
- "usage": "single-receipt"
51
- },
52
- "codeExecutorExport": "executeCode",
53
- "envRequirements": [],
54
- "id": "code-execution",
55
- "kind": "tool",
56
- "requiresSandbox": true,
57
- "requiresTools": [],
58
- "slot": "codeExecution",
59
- "tools": [
60
- {
61
- "rendererExport": "CodeExecution",
62
- "toolExport": "codeExecution"
63
- }
64
- ],
65
- "contractVersion": 1
66
- }
67
- },
68
- "type": "registry:item"
69
- }
@@ -1,55 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
- "name": "daytona-sandbox",
4
- "title": "Daytona",
5
- "dependencies": [
6
- "@chat-js/sandboxes@0.2.0",
7
- "@daytona/sdk@0.220.0"
8
- ],
9
- "files": [
10
- {
11
- "path": "src/sandboxes/daytona/provider.ts",
12
- "content": "import type { DaytonaProvider } from \"./adapter\";\nimport type { SandboxProvider } from \"@chat-js/sandboxes/provider\";\nimport { readSandboxEnvironment } from \"./daytona-sandbox-env\";\nimport { commandSandbox, createDaytonaProvider } from \"./adapter\";\n\n// Reuse the SDK event connection within each worker process.\nlet client: DaytonaProvider | undefined;\n\nexport const createSandboxProvider = (): SandboxProvider => {\n const env = readSandboxEnvironment();\n client ??= createDaytonaProvider({\n apiKey: env.DAYTONA_API_KEY ?? \"\",\n organizationId: env.DAYTONA_ORGANIZATION_ID ?? \"\",\n });\n const provider = client;\n return {\n scope: provider.cleanup.scope,\n async create({ name, runtime, signal }) {\n const resource = await provider.create(name, runtime);\n return { name: resource.name, ...commandSandbox(resource, signal) };\n },\n deleteAndConfirmAbsent: provider.cleanup.deleteAndConfirmAbsent,\n };\n};\n\n/** Available without resolving provider credentials. */\nexport const supportsPersistentSandbox = false;\n",
13
- "type": "registry:file",
14
- "target": "~/chatjs/providers/sandbox/provider.ts"
15
- },
16
- {
17
- "path": "src/sandboxes/daytona/daytona-sandbox-env.ts",
18
- "content": "import { z } from \"zod\";\n\nconst environmentSchema = z.object({\n DAYTONA_API_KEY: z.string().optional(),\n DAYTONA_ORGANIZATION_ID: z.string().optional(),\n});\n\nconst readSandboxEnvironment = (\n environment: Readonly<NodeJS.ProcessEnv> = process.env\n) => environmentSchema.parse(environment);\n\nexport { readSandboxEnvironment };\n",
19
- "type": "registry:file",
20
- "target": "~/chatjs/providers/sandbox/daytona-sandbox-env.ts"
21
- },
22
- {
23
- "path": "src/sandboxes/daytona/adapter.ts",
24
- "content": "import type { CreateSandboxFromSnapshotParams, Sandbox } from \"@daytona/sdk\";\nimport { Daytona, DaytonaNotFoundError } from \"@daytona/sdk\";\nimport type {\n SandboxProvider,\n SandboxScope,\n Sandbox as ExecutionSandboxResource,\n} from \"@chat-js/sandboxes/provider\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { createHash } from \"node:crypto\";\n\ninterface CodeSandboxCleanupSession {\n deleteAndConfirmAbsent: SandboxProvider[\"deleteAndConfirmAbsent\"];\n scope: SandboxScope;\n}\ntype ExecutionSandbox = Pick<ExecutionSandboxResource, \"runCommand\">;\n\nconst API_URL = \"https://app.daytona.io/api\";\nconst REQUEST_TIMEOUT_MS = 30_000;\nconst OPERATION_TIMEOUT_SECONDS = 60;\nconst EXECUTION_TIMEOUT_SECONDS = 300;\nconst LIFETIME_MINUTES = 10;\n\ninterface DaytonaResource {\n readonly name: string;\n readonly organizationId: string;\n readonly state?: Sandbox[\"state\"];\n readonly process: Readonly<Pick<Sandbox[\"process\"], \"executeCommand\">>;\n readonly delete: Sandbox[\"delete\"];\n}\ninterface DaytonaClient {\n readonly create: (\n params: ReadonlyNativeSurface<\n Pick<\n CreateSandboxFromSnapshotParams,\n | \"autoStopInterval\"\n | \"ephemeral\"\n | \"labels\"\n | \"language\"\n | \"name\"\n | \"public\"\n | \"ttlMinutes\"\n >\n >,\n options?: Readonly<{ timeout?: number }>\n ) => Promise<DaytonaResource>;\n readonly get: (name: string) => Promise<DaytonaResource>;\n}\ninterface DaytonaProvider {\n readonly cleanup: CodeSandboxCleanupSession;\n readonly create: (\n name: string,\n language: \"python\" | \"javascript\"\n ) => Promise<DaytonaResource>;\n}\ntype Credentials = Readonly<{ apiKey: string; organizationId: string }>;\n\nconst shellArgument = (value: string): string =>\n `'${value.replaceAll(\"'\", String.raw`'\\''`)}'`;\n\nconst waitForCommand = async <Result>(\n operation: Readonly<Promise<Result>>,\n signal: ReadonlyNativeSurface<AbortSignal>\n): Promise<Result> => {\n const cancelled = Promise.withResolvers<never>();\n const stop = (): void => {\n cancelled.reject(new Error(\"Daytona command cancelled\"));\n };\n signal.addEventListener(\"abort\", stop, { once: true });\n if (signal.aborted) {\n stop();\n }\n try {\n return await Promise.race([operation, cancelled.promise]);\n } finally {\n signal.removeEventListener(\"abort\", stop);\n }\n};\nconst commandSandbox = (\n resource: DaytonaResource,\n signal: ReadonlyNativeSurface<AbortSignal>\n): ExecutionSandbox => ({\n async runCommand({\n cmd,\n args,\n }: Readonly<{ cmd: string; args: readonly string[] }>) {\n signal.throwIfAborted();\n const result = await waitForCommand(\n resource.process.executeCommand(\n [cmd, ...args].map((argument) => shellArgument(argument)).join(\" \"),\n \"/tmp\",\n {},\n EXECUTION_TIMEOUT_SECONDS\n ),\n signal\n );\n signal.throwIfAborted();\n // Daytona exposes combined command output; keep it once in stdout.\n return {\n exitCode: result.exitCode,\n stderr: async () => await Promise.resolve(\"\"),\n stdout: async () => await Promise.resolve(result.result),\n };\n },\n});\n\nconst assertIdentity = (\n resource: DaytonaResource,\n name: string,\n organizationId: string\n): void => {\n if (resource.name !== name || resource.organizationId !== organizationId) {\n throw new Error(\n \"Daytona sandbox identity does not match its allocation intent.\"\n );\n }\n};\n\nconst findResource = async (\n client: DaytonaClient,\n identity: Readonly<{ name: string; organizationId: string }>\n): Promise<DaytonaResource | null> => {\n try {\n const resource = await client.get(identity.name);\n assertIdentity(resource, identity.name, identity.organizationId);\n return resource;\n } catch (error) {\n if (error instanceof DaytonaNotFoundError) {\n return null;\n }\n throw error;\n }\n};\nconst cleanupSession = (\n client: DaytonaClient,\n credentials: Credentials\n): CodeSandboxCleanupSession => ({\n async deleteAndConfirmAbsent(name) {\n const identity = { name, organizationId: credentials.organizationId };\n const resource = await findResource(client, identity);\n if (resource === null || resource.state === \"destroyed\") {\n return;\n }\n await resource.delete(OPERATION_TIMEOUT_SECONDS, true);\n const remaining = await findResource(client, identity);\n if (remaining !== null && remaining.state !== \"destroyed\") {\n throw new Error(\"Daytona sandbox remains available after deletion.\");\n }\n },\n scope: {\n providerId: \"daytona\",\n // API-key auth ignores organizationId in the SDK. Pin the credential scope\n // so replacing it cannot turn a foreign 404 into proof of prior deletion.\n scopeId: `${API_URL}#${createHash(\"sha256\").update(credentials.apiKey).digest(\"hex\")}`,\n accountId: `daytona:${credentials.organizationId}`,\n },\n});\n\nconst createDaytonaProvider = (\n credentials: Credentials,\n client?: DaytonaClient\n): DaytonaProvider => {\n if (\n credentials.apiKey.trim() === \"\" ||\n credentials.organizationId.trim() === \"\"\n ) {\n throw new Error(\n \"DAYTONA_API_KEY and DAYTONA_ORGANIZATION_ID are required.\"\n );\n }\n const selectedClient =\n client ??\n new Daytona({\n apiKey: credentials.apiKey,\n apiUrl: API_URL,\n organizationId: credentials.organizationId,\n otelEnabled: false,\n requestTimeoutMs: REQUEST_TIMEOUT_MS,\n });\n return {\n cleanup: cleanupSession(selectedClient, credentials),\n async create(name, language): Promise<DaytonaResource> {\n const resource = await selectedClient.create(\n {\n autoStopInterval: LIFETIME_MINUTES,\n ephemeral: true,\n labels: { \"chatjs-allocation\": name },\n language,\n name,\n public: false,\n ttlMinutes: LIFETIME_MINUTES,\n },\n { timeout: OPERATION_TIMEOUT_SECONDS }\n );\n assertIdentity(resource, name, credentials.organizationId);\n return resource;\n },\n };\n};\n\nexport { commandSandbox, createDaytonaProvider };\nexport type { DaytonaProvider, DaytonaResource };\n",
25
- "type": "registry:file",
26
- "target": "~/chatjs/providers/sandbox/adapter.ts"
27
- }
28
- ],
29
- "meta": {
30
- "chatjs": {
31
- "contractVersion": 1,
32
- "kind": "sandbox",
33
- "id": "daytona",
34
- "capabilities": {
35
- "runtimes": [
36
- "python",
37
- "javascript"
38
- ],
39
- "cleanup": "durable-allocation",
40
- "cancellation": "terminate"
41
- },
42
- "envRequirements": [
43
- {
44
- "options": [
45
- [
46
- "DAYTONA_API_KEY",
47
- "DAYTONA_ORGANIZATION_ID"
48
- ]
49
- ]
50
- }
51
- ]
52
- }
53
- },
54
- "type": "registry:item"
55
- }
@@ -1,58 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
- "name": "delete-document",
4
- "description": "Remove a document from this conversation with explicit owner approval",
5
- "registryDependencies": [
6
- "@chatjs/read-document"
7
- ],
8
- "files": [
9
- {
10
- "path": "src/tools/delete-document/tool.ts",
11
- "content": "import type { ApprovalResponseContext } from \"eve/tools/approval\";\nimport type { ToolContext } from \"eve/tools\";\nimport { defineTool } from \"eve/tools\";\nimport { executeDocumentDeletion, requestDocumentDeletion } from \"./execute\";\nimport { deleteDocumentInput } from \"./schemas\";\nimport type { z } from \"zod\";\n\ntype DeleteDocumentInput = z.infer<typeof deleteDocumentInput>;\ntype DeleteDocumentRequestContext = Readonly<\n Pick<ToolContext, \"callId\" | \"session\"> & {\n abortSignal: Readonly<AbortSignal>;\n toolInput?: Readonly<DeleteDocumentInput>;\n }\n>;\ntype DeleteDocumentPrincipal = Readonly<\n Pick<\n ApprovalResponseContext<DeleteDocumentInput>[\"response\"][\"principal\"],\n \"principalId\"\n >\n>;\ntype DeleteDocumentResponseContext = Readonly<\n Pick<ApprovalResponseContext<DeleteDocumentInput>, \"response\"> & {\n session: Readonly<{\n initiator: DeleteDocumentPrincipal | null;\n }>;\n }\n>;\n\nexport const deleteDocument = defineTool({\n approval: {\n request: async (context: DeleteDocumentRequestContext) =>\n await requestDocumentDeletion(context.toolInput, context),\n response: ({ response, session }: DeleteDocumentResponseContext) => {\n if (\n response.principal.principalId === (session.initiator ?? {}).principalId\n ) {\n return { status: \"allowed\" };\n }\n return {\n reason: \"Only the document owner may approve deletion.\",\n status: \"rejected\",\n };\n },\n },\n description:\n \"Request owner approval to remove a document from this conversation. Read it first and supply its exact title and revision. Call this tool to display the approval controls; do not ask for confirmation in a chat message. Execution waits for approval. Historical snapshots and other branches retain their copies; this does not permanently erase their content.\",\n execute: executeDocumentDeletion,\n inputSchema: deleteDocumentInput,\n});\n",
12
- "type": "registry:file",
13
- "target": "~/chatjs/tools/delete-document/tool.ts"
14
- },
15
- {
16
- "path": "src/tools/delete-document/execute.ts",
17
- "content": "import {\n getEveDocumentRevision,\n removeEveDocumentFromConversation,\n} from \"@/lib/db/eve-documents\";\nimport type { ToolContext } from \"eve/tools\";\nimport { deleteDocumentAvailable } from \"./availability\";\nimport { deleteDocumentInput } from \"./schemas\";\nimport { installedDocumentKinds } from \"@/integrations/tools/catalog\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport type { z } from \"zod\";\n\ntype Context = Readonly<\n Pick<ToolContext, \"session\" | \"callId\" | \"approval\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nconst scopeFor = async (\n context: Context\n): ReturnType<typeof resolveEveConversationScope> => {\n if (!deleteDocumentAvailable(context.session)) {\n throw new Error(\"Document deletion is unavailable.\");\n }\n return await resolveEveConversationScope(\n (context.session.auth.initiator ?? {}).principalId,\n context.session.id,\n context.abortSignal\n );\n};\nconst requestDocumentDeletion = async (\n value: unknown,\n context: Context\n): Promise<\"user-approval\"> => {\n const input = deleteDocumentInput.parse(value);\n const scope = await scopeFor(context);\n const revision = await getEveDocumentRevision(\n scope.ownerId,\n scope.conversationId,\n input.documentId\n );\n if (!revision || !installedDocumentKinds.has(revision.kind)) {\n throw new Error(\"Document not found.\");\n }\n if (\n revision.id !== input.expectedRevisionId ||\n revision.title !== input.title\n ) {\n throw new Error(\n \"Document changed. Read it again before requesting deletion.\"\n );\n }\n context.abortSignal.throwIfAborted();\n return \"user-approval\" as const;\n};\nconst executeDocumentDeletion = async (\n input: Readonly<z.infer<typeof deleteDocumentInput>>,\n context: Context\n): ReturnType<typeof removeEveDocumentFromConversation> => {\n const scope = await scopeFor(context);\n const { approval } = context;\n if (!approval || approval.responder.principalId !== scope.ownerId) {\n throw new Error(\"Document deletion requires the owner's approval.\");\n }\n const revision = await getEveDocumentRevision(\n scope.ownerId,\n scope.conversationId,\n input.documentId\n );\n if (revision && !installedDocumentKinds.has(revision.kind)) {\n throw new Error(\"Document tools are disabled for this kind.\");\n }\n return await removeEveDocumentFromConversation(\n input,\n scope,\n context.abortSignal\n );\n};\nexport { executeDocumentDeletion, requestDocumentDeletion };\n",
18
- "type": "registry:file",
19
- "target": "~/chatjs/tools/delete-document/execute.ts"
20
- },
21
- {
22
- "path": "src/tools/delete-document/schemas.ts",
23
- "content": "import { z } from \"zod\";\n\nconst MINIMUM_DOCUMENT_TITLE_LENGTH = 1;\nconst MAXIMUM_DOCUMENT_TITLE_LENGTH = 1000;\n\nexport const deleteDocumentInput = z.object({\n documentId: z.uuid(),\n expectedRevisionId: z\n .uuid()\n .describe(\"Current revision ID returned by readDocument.\"),\n title: z\n .string()\n .min(MINIMUM_DOCUMENT_TITLE_LENGTH)\n .max(MAXIMUM_DOCUMENT_TITLE_LENGTH)\n .describe(\n \"Exact current title returned by readDocument, shown for approval.\"\n ),\n});\n",
24
- "type": "registry:file",
25
- "target": "~/chatjs/tools/delete-document/schemas.ts"
26
- },
27
- {
28
- "path": "src/tools/delete-document/availability.ts",
29
- "content": "import { isAccountSession } from \"@/lib/eve/session-identity\";\nimport type { ToolContext } from \"eve/tools\";\n\nimport { installedDocumentKinds } from \"@/integrations/tools/catalog\";\n\nconst EMPTY_DOCUMENT_KIND_COUNT = 0;\n\nexport const deleteDocumentAvailable = (\n session: Pick<ToolContext[\"session\"], \"auth\" | \"parent\">\n): boolean =>\n isAccountSession(session) &&\n !session.parent &&\n installedDocumentKinds.size > EMPTY_DOCUMENT_KIND_COUNT;\n",
30
- "type": "registry:file",
31
- "target": "~/chatjs/tools/delete-document/availability.ts"
32
- },
33
- {
34
- "path": "dist/source/delete-document.json",
35
- "content": "{\n \"availabilityExport\": \"deleteDocumentAvailable\",\n \"envRequirements\": [],\n \"id\": \"delete-document\",\n \"kind\": \"tool\",\n \"requiresTools\": [\"readDocument\"],\n \"tools\": [{ \"toolExport\": \"deleteDocument\" }],\n \"contractVersion\": 1\n}\n",
36
- "type": "registry:file",
37
- "target": "~/chatjs/tools/delete-document/chatjs.json"
38
- }
39
- ],
40
- "meta": {
41
- "chatjs": {
42
- "availabilityExport": "deleteDocumentAvailable",
43
- "envRequirements": [],
44
- "id": "delete-document",
45
- "kind": "tool",
46
- "requiresTools": [
47
- "readDocument"
48
- ],
49
- "tools": [
50
- {
51
- "toolExport": "deleteDocument"
52
- }
53
- ],
54
- "contractVersion": 1
55
- }
56
- },
57
- "type": "registry:item"
58
- }
@@ -1,72 +0,0 @@
1
- {
2
- "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
- "name": "firecrawl-search",
4
- "description": "Use firecrawl-search for chat and deep research",
5
- "dependencies": [
6
- "ai@7.0.137",
7
- "zod@4.5.4",
8
- "@mendable/firecrawl-js@1.29.1"
9
- ],
10
- "files": [
11
- {
12
- "path": "src/tools/firecrawl-search/firecrawl-search-env.ts",
13
- "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",
14
- "type": "registry:file",
15
- "target": "~/chatjs/tools/firecrawl-search/firecrawl-search-env.ts"
16
- },
17
- {
18
- "path": "src/tools/firecrawl-search/tool.ts",
19
- "content": "import FirecrawlApp from \"@mendable/firecrawl-js\";\nimport type { ToolProgressWriter } from \"@/lib/ai/tool-context\";\nimport { defineTool } from \"eve/tools\";\nimport { readToolEnvironment } from \"./firecrawl-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 FIRECRAWL_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}>;\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 FIRECRAWL_SEARCH_TIMEOUT_MS = 15_000;\nconst searchFirecrawl = async ({\n query,\n maxResults,\n}: Readonly<{ query: string; maxResults: number }>): Promise<\n { content: string; title: string; url: string }[]\n> => {\n const env = readToolEnvironment();\n if (\n !(typeof env.FIRECRAWL_API_KEY === \"string\" && env.FIRECRAWL_API_KEY !== \"\")\n ) {\n throw new Error(\"Set FIRECRAWL_API_KEY to enable Firecrawl search.\");\n }\n const response = await new FirecrawlApp({\n apiKey: env.FIRECRAWL_API_KEY,\n }).search(query, {\n limit: maxResults,\n scrapeOptions: { formats: [\"markdown\"] },\n timeout: FIRECRAWL_SEARCH_TIMEOUT_MS,\n });\n return response.data.map(\n (item: Readonly<{ markdown?: string; title?: string; url?: string }>) => ({\n content: item.markdown ?? \"\",\n title: item.title ?? \"\",\n url: item.url ?? \"\",\n })\n );\n};\nexport const webSearch = defineTool({\n description: `Multi-query web search using Firecrawl for enhanced content extraction. Always cite sources inline.\n\nUse for:\n- General information gathering via web search with detailed content extraction\n- When you need high-quality markdown content from web pages\n\nAvoid:\n- Pulling content from a single known URL (use retrieveUrl instead)`,\n execute: (\n { search_queries }: 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({ queriesCount: search_queries.length }, \"webSearch.execute\");\n const result = await executeMultiQuerySearch({\n completeTitle: \"Firecrawl search complete\",\n dataStream,\n search: searchFirecrawl,\n search_queries: search_queries.map((query) => ({\n maxResults: query.maxResults ?? DEFAULT_MAX_RESULTS,\n query: query.query,\n })),\n title: \"Searching with Firecrawl\",\n toolCallId,\n writeTopLevelUpdates: true,\n });\n\n // Report API cost\n usage.addCostUsd(FIRECRAWL_COST_CENTS / CENTS_PER_USD);\n\n return result;\n },\n webSearchResult\n ),\n inputSchema: webSearchInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
20
- "type": "registry:file",
21
- "target": "~/chatjs/tools/firecrawl-search/tool.ts"
22
- },
23
- {
24
- "path": "src/tools/firecrawl-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/firecrawl-search/renderer.tsx"
28
- },
29
- {
30
- "path": "src/tools/firecrawl-search/schemas.ts",
31
- "content": "import { searchQueriesSchema } from \"@/tools/platform/search-presentation\";\nimport { z } from \"zod\";\n\nconst webSearchInput = z.object({\n search_queries: searchQueriesSchema,\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/firecrawl-search/schemas.ts"
34
- },
35
- {
36
- "path": "dist/source/firecrawl-search.json",
37
- "content": "{\n \"envRequirements\": [{ \"options\": [[\"FIRECRAWL_API_KEY\"]] }],\n \"id\": \"firecrawl-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/firecrawl-search/chatjs.json"
40
- }
41
- ],
42
- "meta": {
43
- "chatjs": {
44
- "envRequirements": [
45
- {
46
- "options": [
47
- [
48
- "FIRECRAWL_API_KEY"
49
- ]
50
- ]
51
- }
52
- ],
53
- "id": "firecrawl-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
- }
@@ -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}&current=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
- }