@chat-js/cli 0.6.1 → 0.6.2
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/dist/index.js +16938 -16786
- package/package.json +1 -1
- package/templates/chat-app/app/(auth)/login/page.tsx +3 -3
- package/templates/chat-app/app/(chat)/api/chat/route.ts +4 -60
- package/templates/chat-app/app/not-found.tsx +2 -2
- package/templates/chat-app/chat.config.ts +3 -0
- package/templates/chat-app/components/ai-elements/actions.tsx +44 -44
- package/templates/chat-app/components/ai-elements/artifact.tsx +92 -92
- package/templates/chat-app/components/ai-elements/code-block.tsx +143 -143
- package/templates/chat-app/components/ai-elements/context.tsx +313 -313
- package/templates/chat-app/components/ai-elements/conversation.tsx +65 -65
- package/templates/chat-app/components/ai-elements/extra/conversation-content-scroll-area.tsx +29 -29
- package/templates/chat-app/components/ai-elements/extra/mcp-tool-header.tsx +27 -27
- package/templates/chat-app/components/ai-elements/message.tsx +341 -344
- package/templates/chat-app/components/ai-elements/parseIncompleteMarkdown.tsx +122 -122
- package/templates/chat-app/components/ai-elements/prompt-input.tsx +1059 -1059
- package/templates/chat-app/components/ai-elements/reasoning.tsx +131 -131
- package/templates/chat-app/components/ai-elements/response.tsx +15 -12
- package/templates/chat-app/components/ai-elements/sandbox.tsx +84 -84
- package/templates/chat-app/components/ai-elements/shimmer.tsx +47 -47
- package/templates/chat-app/components/ai-elements/suggestion.tsx +33 -33
- package/templates/chat-app/components/ai-elements/tool.tsx +118 -118
- package/templates/chat-app/components/app-sidebar-history-conditional.tsx +3 -3
- package/templates/chat-app/components/app-sidebar.tsx +3 -3
- package/templates/chat-app/components/connectors-dropdown.tsx +6 -3
- package/templates/chat-app/components/deep-research-progress.tsx +1 -1
- package/templates/chat-app/components/header-breadcrumb.tsx +14 -11
- package/templates/chat-app/components/internal-link.tsx +73 -0
- package/templates/chat-app/components/login-form.tsx +5 -5
- package/templates/chat-app/components/message-parts.tsx +1 -71
- package/templates/chat-app/components/model-selector.tsx +3 -3
- package/templates/chat-app/components/new-chat-button.tsx +4 -4
- package/templates/chat-app/components/part/document-common.tsx +3 -3
- package/templates/chat-app/components/part/document-tool.tsx +3 -3
- package/templates/chat-app/components/part/message-annotations.tsx +2 -2
- package/templates/chat-app/components/part/tool-part.tsx +92 -0
- package/templates/chat-app/components/project-chat-item.tsx +2 -2
- package/templates/chat-app/components/research-progress.tsx +2 -2
- package/templates/chat-app/components/research-task.tsx +1 -1
- package/templates/chat-app/components/research-tasks.tsx +1 -1
- package/templates/chat-app/components/settings/connectors-settings.tsx +4 -4
- package/templates/chat-app/components/settings/mcp-details-page.tsx +5 -5
- package/templates/chat-app/components/settings/settings-nav.tsx +3 -3
- package/templates/chat-app/components/sidebar-chat-item.tsx +4 -12
- package/templates/chat-app/components/sidebar-project-item.tsx +4 -11
- package/templates/chat-app/components/sidebar-top-row.tsx +7 -7
- package/templates/chat-app/components/sidebar-user-nav.tsx +3 -3
- package/templates/chat-app/components/signup-form.tsx +8 -5
- package/templates/chat-app/components/source-badge.tsx +3 -9
- package/templates/chat-app/components/sources.tsx +1 -1
- package/templates/chat-app/components/ui/accordion.tsx +32 -32
- package/templates/chat-app/components/ui/alert-dialog.tsx +103 -103
- package/templates/chat-app/components/ui/alert.tsx +36 -36
- package/templates/chat-app/components/ui/avatar.tsx +28 -28
- package/templates/chat-app/components/ui/badge.tsx +22 -22
- package/templates/chat-app/components/ui/breadcrumb.tsx +72 -72
- package/templates/chat-app/components/ui/button-group.tsx +58 -58
- package/templates/chat-app/components/ui/button.tsx +45 -45
- package/templates/chat-app/components/ui/card.tsx +65 -65
- package/templates/chat-app/components/ui/checkbox.tsx +16 -16
- package/templates/chat-app/components/ui/collapsible.tsx +1 -1
- package/templates/chat-app/components/ui/command.tsx +137 -137
- package/templates/chat-app/components/ui/dialog.tsx +94 -94
- package/templates/chat-app/components/ui/drawer.tsx +68 -68
- package/templates/chat-app/components/ui/dropdown-menu.tsx +184 -184
- package/templates/chat-app/components/ui/empty.tsx +76 -76
- package/templates/chat-app/components/ui/extra/action-container.tsx +3 -3
- package/templates/chat-app/components/ui/extra/scroll-area-viewport-ref.tsx +24 -24
- package/templates/chat-app/components/ui/form.tsx +112 -112
- package/templates/chat-app/components/ui/hover-card.tsx +25 -25
- package/templates/chat-app/components/ui/input-group.tsx +126 -126
- package/templates/chat-app/components/ui/input.tsx +13 -13
- package/templates/chat-app/components/ui/label.tsx +12 -12
- package/templates/chat-app/components/ui/popover.tsx +25 -25
- package/templates/chat-app/components/ui/progress.tsx +19 -19
- package/templates/chat-app/components/ui/resizable.tsx +27 -27
- package/templates/chat-app/components/ui/scroll-area.tsx +30 -30
- package/templates/chat-app/components/ui/select.tsx +108 -108
- package/templates/chat-app/components/ui/separator.tsx +16 -16
- package/templates/chat-app/components/ui/sheet.tsx +91 -91
- package/templates/chat-app/components/ui/sidebar.tsx +615 -615
- package/templates/chat-app/components/ui/skeleton.tsx +7 -7
- package/templates/chat-app/components/ui/slider.tsx +50 -50
- package/templates/chat-app/components/ui/spinner.tsx +8 -8
- package/templates/chat-app/components/ui/switch.tsx +16 -16
- package/templates/chat-app/components/ui/table.tsx +71 -71
- package/templates/chat-app/components/ui/tabs.tsx +31 -31
- package/templates/chat-app/components/ui/textarea.tsx +10 -10
- package/templates/chat-app/components/ui/toggle.tsx +31 -31
- package/templates/chat-app/components/ui/tooltip.tsx +48 -48
- package/templates/chat-app/components/upgrade-cta/limit-display.tsx +7 -7
- package/templates/chat-app/components/upgrade-cta/login-cta-banner.tsx +3 -3
- package/templates/chat-app/components/upgrade-cta/login-prompt.tsx +3 -3
- package/templates/chat-app/hooks/use-mobile.ts +13 -13
- package/templates/chat-app/lib/ai/core-chat-agent.ts +25 -14
- package/templates/chat-app/lib/ai/eval-agent.ts +4 -5
- package/templates/chat-app/lib/ai/installed-tools.ts +12 -0
- package/templates/chat-app/lib/ai/mcp/mcp-client.ts +2 -2
- package/templates/chat-app/lib/ai/models.generated.ts +4236 -4585
- package/templates/chat-app/lib/ai/tool-renderer-registry.ts +31 -0
- package/templates/chat-app/lib/ai/types.ts +15 -20
- package/templates/chat-app/lib/config-requirements.ts +11 -6
- package/templates/chat-app/lib/config-schema.ts +13 -0
- package/templates/chat-app/lib/stores/hooks-message-parts.ts +1 -1
- package/templates/chat-app/lib/utils.ts +157 -157
- package/templates/chat-app/package.json +1 -1
- package/templates/chat-app/scripts/check-env.ts +229 -2
- package/templates/chat-app/tools/chatjs/_shared/lib/tool-part.ts +5 -0
- package/templates/chat-app/{components/part/weather.tsx → tools/chatjs/get-weather/renderer.tsx} +24 -38
- package/templates/chat-app/{components/part/retrieve-url.tsx → tools/chatjs/retrieve-url/renderer.tsx} +20 -15
- package/templates/chat-app/{lib/ai/tools/retrieve-url.ts → tools/chatjs/retrieve-url/tool.ts} +46 -7
- package/templates/chat-app/tools/chatjs/tools.ts +16 -0
- package/templates/chat-app/tools/chatjs/ui.ts +17 -0
- package/templates/chat-app/tools/chatjs/word-count/renderer.tsx +50 -0
- package/templates/chat-app/tools/chatjs/word-count/tool.ts +30 -0
- package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.ts +3 -5
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/deep-research.ts +2 -3
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/pipeline.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/types.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/utils.ts +7 -7
- package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/types.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-video.ts +4 -6
- package/templates/chat-app/{lib/ai/tools → tools/platform}/read-document.ts +2 -2
- package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/multi-query-web-search.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/web-search.ts +1 -1
- package/templates/chat-app/{lib/ai/tools → tools/platform}/tools.ts +20 -20
- package/templates/chat-app/{lib/ai/tools → tools/platform}/web-search.ts +7 -5
- package/templates/electron/CHANGELOG.md +7 -1
- package/templates/electron/package.json +1 -1
- package/templates/chat-app/lib/ai/tools/tools-definitions.ts +0 -83
- /package/templates/chat-app/{lib/ai/tools/get-weather.ts → tools/chatjs/get-weather/tool.ts} +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.javascript.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.python.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.test.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.shared.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/code-execution.types.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/configuration.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/prompts.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/researcher-agent.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/supervisor-agent.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/code-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-code-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-sheet-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-text-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-code-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-sheet-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-text-document.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/sheet-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/text-guidelines.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/generate-image.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/research-updates-schema.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/steps/search-utils.ts +0 -0
- /package/templates/chat-app/{lib/ai/tools → tools/platform}/types.ts +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type ModelMessage, tool } from "ai";
|
|
2
2
|
import { Langfuse } from "langfuse";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
import type { ToolSession } from "@/lib/ai/tools/types";
|
|
4
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
6
5
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
7
6
|
import { generateUUID } from "@/lib/utils";
|
|
8
|
-
import type {
|
|
7
|
+
import type { ToolSession } from "../types";
|
|
9
8
|
import { getDeepResearchConfig } from "./configuration";
|
|
10
9
|
import { runDeepResearchPipeline } from "./pipeline";
|
|
11
10
|
|
|
@@ -3,10 +3,10 @@ import type { z } from "zod";
|
|
|
3
3
|
import type { AppModelId, ModelId } from "@/lib/ai/app-models";
|
|
4
4
|
import { getLanguageModel } from "@/lib/ai/providers";
|
|
5
5
|
import { truncateMessages } from "@/lib/ai/token-utils";
|
|
6
|
-
import type { ToolSession } from "@/lib/ai/tools/types";
|
|
7
6
|
import { generateUUID, getTextContentFromModelMessage } from "@/lib/utils";
|
|
8
7
|
import { createTextDocumentTool } from "../documents/create-text-document";
|
|
9
8
|
import type { DocumentToolResult } from "../documents/types";
|
|
9
|
+
import type { ToolSession } from "../types";
|
|
10
10
|
import type { DeepResearchRuntimeConfig } from "./configuration";
|
|
11
11
|
import {
|
|
12
12
|
clarifyWithUserInstructions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage } from "ai";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
3
4
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
4
|
-
import type { StreamWriter } from "../../types";
|
|
5
5
|
import type { DocumentToolResult } from "../documents/types";
|
|
6
6
|
import type { DeepResearchRuntimeConfig } from "./configuration";
|
|
7
7
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { experimental_createMCPClient } from "@ai-sdk/mcp";
|
|
2
|
+
import type { ToolSet } from "ai";
|
|
2
3
|
import type { ModelId } from "@/lib/ai/app-models";
|
|
4
|
+
import { getAppModelDefinition } from "@/lib/ai/app-models";
|
|
3
5
|
import type { StreamWriter } from "@/lib/ai/types";
|
|
4
|
-
import { getAppModelDefinition } from "../../app-models";
|
|
5
6
|
import { firecrawlWebSearch, tavilyWebSearch } from "../web-search";
|
|
6
7
|
import type { DeepResearchRuntimeConfig, SearchAPI } from "./configuration";
|
|
7
8
|
|
|
8
9
|
// MCP Utils
|
|
9
10
|
|
|
10
11
|
type McpClient = Awaited<ReturnType<typeof experimental_createMCPClient>>;
|
|
11
|
-
type McpToolSet = Awaited<ReturnType<McpClient["tools"]>>;
|
|
12
12
|
|
|
13
13
|
async function loadMcpTools(
|
|
14
14
|
config: DeepResearchRuntimeConfig,
|
|
15
15
|
existingToolNames: Set<string>
|
|
16
|
-
) {
|
|
16
|
+
): Promise<ToolSet> {
|
|
17
17
|
if (!config.mcp_config?.url) {
|
|
18
18
|
return {};
|
|
19
19
|
}
|
|
@@ -30,10 +30,10 @@ async function loadMcpTools(
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
// Get all available tools from the MCP server
|
|
33
|
-
const tools = await client.tools();
|
|
33
|
+
const tools = (await client.tools()) as ToolSet;
|
|
34
34
|
|
|
35
35
|
// Filter tools based on configuration and existing tools
|
|
36
|
-
const filteredTools:
|
|
36
|
+
const filteredTools: ToolSet = {};
|
|
37
37
|
|
|
38
38
|
for (const [toolName, tool] of Object.entries(tools)) {
|
|
39
39
|
// Skip if tool already exists
|
|
@@ -80,7 +80,7 @@ function getSearchTool(
|
|
|
80
80
|
_config: DeepResearchRuntimeConfig,
|
|
81
81
|
dataStream: StreamWriter,
|
|
82
82
|
parentToolCallId?: string
|
|
83
|
-
) {
|
|
83
|
+
): ToolSet {
|
|
84
84
|
if (searchApi === "tavily") {
|
|
85
85
|
return {
|
|
86
86
|
webSearch: tavilyWebSearch({
|
|
@@ -106,7 +106,7 @@ export async function getAllTools(
|
|
|
106
106
|
config: DeepResearchRuntimeConfig,
|
|
107
107
|
dataStream: StreamWriter,
|
|
108
108
|
id?: string
|
|
109
|
-
) {
|
|
109
|
+
): Promise<ToolSet> {
|
|
110
110
|
if (config.search_api === "none") {
|
|
111
111
|
const mcpTools = await loadMcpTools(config, new Set<string>());
|
|
112
112
|
return mcpTools;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ModelId } from "@/lib/ai/app-models";
|
|
1
2
|
import type { ArtifactKind } from "@/lib/artifacts/artifact-kind";
|
|
2
3
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
3
|
-
import type { ModelId } from "../../app-models";
|
|
4
4
|
import type { ToolSession } from "../types";
|
|
5
5
|
|
|
6
6
|
export type DocumentToolResult =
|
|
@@ -6,7 +6,8 @@ import { uploadFile } from "@/lib/blob";
|
|
|
6
6
|
import { config } from "@/lib/config";
|
|
7
7
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
8
8
|
import { createModuleLogger } from "@/lib/logger";
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
const COST_CENTS = 50; // Fixed estimate — not yet available from provider API
|
|
10
11
|
|
|
11
12
|
interface GenerateVideoProps {
|
|
12
13
|
costAccumulator?: CostAccumulator;
|
|
@@ -55,8 +56,8 @@ async function resolveVideoModel(selectedModel?: string): Promise<string> {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export const generateVideoTool = ({
|
|
58
|
-
selectedModel,
|
|
59
59
|
costAccumulator,
|
|
60
|
+
selectedModel,
|
|
60
61
|
}: GenerateVideoProps = {}) =>
|
|
61
62
|
tool({
|
|
62
63
|
description:
|
|
@@ -124,10 +125,7 @@ export const generateVideoTool = ({
|
|
|
124
125
|
const filename = `generated-video-${timestamp}.${ext}`;
|
|
125
126
|
const uploaded = await uploadFile(filename, buffer);
|
|
126
127
|
|
|
127
|
-
costAccumulator?.addAPICost(
|
|
128
|
-
"generateVideo",
|
|
129
|
-
toolsDefinitions.generateVideo.cost
|
|
130
|
-
);
|
|
128
|
+
costAccumulator?.addAPICost("generateVideo", COST_CENTS);
|
|
131
129
|
|
|
132
130
|
log.info(
|
|
133
131
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { tool } from "ai";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type {
|
|
3
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
4
4
|
import { getDocumentById } from "@/lib/db/queries";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ToolSession } from "./types";
|
|
6
6
|
|
|
7
7
|
interface ReadDocumentProps {
|
|
8
8
|
dataStream: StreamWriter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
1
2
|
import { generateUUID } from "@/lib/utils";
|
|
2
|
-
import type { StreamWriter } from "../../types";
|
|
3
3
|
import { deduplicateByDomainAndUrl } from "./search-utils";
|
|
4
4
|
import type { SearchProviderOptions } from "./web-search";
|
|
5
5
|
import { webSearchStep } from "./web-search";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import FirecrawlApp, { type SearchParams } from "@mendable/firecrawl-js";
|
|
2
2
|
import { type TavilySearchOptions, tavily } from "@tavily/core";
|
|
3
3
|
import { env } from "@/lib/env";
|
|
4
|
-
import { createModuleLogger } from "
|
|
4
|
+
import { createModuleLogger } from "@/lib/logger";
|
|
5
5
|
|
|
6
6
|
export type SearchProviderOptions =
|
|
7
7
|
| ({
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import type { FileUIPart, ModelMessage, Tool } from "ai";
|
|
2
2
|
import type { ModelId } from "@/lib/ai/app-models";
|
|
3
|
+
import { installedTools } from "@/lib/ai/installed-tools";
|
|
3
4
|
import { getOrCreateMcpClient, type MCPClient } from "@/lib/ai/mcp/mcp-client";
|
|
4
5
|
import { createToolId } from "@/lib/ai/mcp-name-id";
|
|
5
|
-
import {
|
|
6
|
-
import { createCodeDocumentTool } from "@/lib/ai/tools/documents/create-code-document";
|
|
7
|
-
import { createSheetDocumentTool } from "@/lib/ai/tools/documents/create-sheet-document";
|
|
8
|
-
import { createTextDocumentTool } from "@/lib/ai/tools/documents/create-text-document";
|
|
9
|
-
import { editCodeDocumentTool } from "@/lib/ai/tools/documents/edit-code-document";
|
|
10
|
-
import { editSheetDocumentTool } from "@/lib/ai/tools/documents/edit-sheet-document";
|
|
11
|
-
import { editTextDocumentTool } from "@/lib/ai/tools/documents/edit-text-document";
|
|
12
|
-
import { generateImageTool } from "@/lib/ai/tools/generate-image";
|
|
13
|
-
import { generateVideoTool } from "@/lib/ai/tools/generate-video";
|
|
14
|
-
import { getWeather } from "@/lib/ai/tools/get-weather";
|
|
15
|
-
import { readDocument } from "@/lib/ai/tools/read-document";
|
|
16
|
-
import { retrieveUrl } from "@/lib/ai/tools/retrieve-url";
|
|
17
|
-
import { tavilyWebSearch } from "@/lib/ai/tools/web-search";
|
|
6
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
18
7
|
import { config } from "@/lib/config";
|
|
19
8
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
20
9
|
import type { McpConnector } from "@/lib/db/schema";
|
|
21
10
|
import { createModuleLogger } from "@/lib/logger";
|
|
22
|
-
import
|
|
11
|
+
import { codeExecution } from "./code-execution";
|
|
23
12
|
import { deepResearch } from "./deep-research/deep-research";
|
|
13
|
+
import { createCodeDocumentTool } from "./documents/create-code-document";
|
|
14
|
+
import { createSheetDocumentTool } from "./documents/create-sheet-document";
|
|
15
|
+
import { createTextDocumentTool } from "./documents/create-text-document";
|
|
16
|
+
import { editCodeDocumentTool } from "./documents/edit-code-document";
|
|
17
|
+
import { editSheetDocumentTool } from "./documents/edit-sheet-document";
|
|
18
|
+
import { editTextDocumentTool } from "./documents/edit-text-document";
|
|
19
|
+
import { generateImageTool } from "./generate-image";
|
|
20
|
+
import { generateVideoTool } from "./generate-video";
|
|
21
|
+
import { readDocument } from "./read-document";
|
|
24
22
|
import type { ToolSession } from "./types";
|
|
23
|
+
import { tavilyWebSearch } from "./web-search";
|
|
25
24
|
|
|
26
25
|
const log = createModuleLogger("tools:mcp");
|
|
27
26
|
|
|
@@ -50,9 +49,13 @@ export function getTools({
|
|
|
50
49
|
selectedModel,
|
|
51
50
|
costAccumulator,
|
|
52
51
|
};
|
|
52
|
+
const enabledInstalledTools = Object.fromEntries(
|
|
53
|
+
Object.entries(installedTools).filter(
|
|
54
|
+
([name]) => name !== "retrieveUrl" || config.ai.tools.urlRetrieval.enabled
|
|
55
|
+
)
|
|
56
|
+
);
|
|
53
57
|
|
|
54
58
|
return {
|
|
55
|
-
getWeather,
|
|
56
59
|
createTextDocument: createTextDocumentTool(documentToolProps),
|
|
57
60
|
createCodeDocument: createCodeDocumentTool(documentToolProps),
|
|
58
61
|
createSheetDocument: createSheetDocumentTool(documentToolProps),
|
|
@@ -63,7 +66,6 @@ export function getTools({
|
|
|
63
66
|
session,
|
|
64
67
|
dataStream,
|
|
65
68
|
}),
|
|
66
|
-
...(config.ai.tools.urlRetrieval.enabled ? { retrieveUrl } : {}),
|
|
67
69
|
...(config.ai.tools.webSearch.enabled
|
|
68
70
|
? {
|
|
69
71
|
webSearch: tavilyWebSearch({
|
|
@@ -100,12 +102,10 @@ export function getTools({
|
|
|
100
102
|
: {}),
|
|
101
103
|
...(config.ai.tools.video.enabled
|
|
102
104
|
? {
|
|
103
|
-
generateVideo: generateVideoTool({
|
|
104
|
-
selectedModel,
|
|
105
|
-
costAccumulator,
|
|
106
|
-
}),
|
|
105
|
+
generateVideo: generateVideoTool({ selectedModel, costAccumulator }),
|
|
107
106
|
}
|
|
108
107
|
: {}),
|
|
108
|
+
...enabledInstalledTools,
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { tool } from "ai";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import type { StreamWriter } from "@/lib/ai/types";
|
|
3
4
|
import type { CostAccumulator } from "@/lib/credits/cost-accumulator";
|
|
4
|
-
import { createModuleLogger } from "
|
|
5
|
-
import type { StreamWriter } from "../types";
|
|
5
|
+
import { createModuleLogger } from "@/lib/logger";
|
|
6
6
|
import {
|
|
7
7
|
type MultiQuerySearchOptions,
|
|
8
8
|
multiQueryWebSearchStep,
|
|
9
9
|
} from "./steps/multi-query-web-search";
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const TAVILY_COST_CENTS = 5;
|
|
12
|
+
const FIRECRAWL_COST_CENTS = 5;
|
|
11
13
|
|
|
12
14
|
const DEFAULT_MAX_RESULTS = 5;
|
|
13
15
|
|
|
@@ -184,7 +186,7 @@ Avoid:
|
|
|
184
186
|
});
|
|
185
187
|
|
|
186
188
|
// Report API cost
|
|
187
|
-
costAccumulator?.addAPICost("webSearch",
|
|
189
|
+
costAccumulator?.addAPICost("webSearch", TAVILY_COST_CENTS);
|
|
188
190
|
|
|
189
191
|
return result;
|
|
190
192
|
},
|
|
@@ -245,7 +247,7 @@ Avoid:
|
|
|
245
247
|
});
|
|
246
248
|
|
|
247
249
|
// Report API cost
|
|
248
|
-
costAccumulator?.addAPICost("webSearch",
|
|
250
|
+
costAccumulator?.addAPICost("webSearch", FIRECRAWL_COST_CENTS);
|
|
249
251
|
|
|
250
252
|
return result;
|
|
251
253
|
},
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# @chatjs/electron
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Test patch release generation across all releasable packages.
|
|
8
|
+
|
|
3
9
|
## 0.3.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
6
12
|
|
|
7
|
-
- [#136](https://github.com/FranciscoMoretti/chat-js/pull/136) [`6b1458c`](https://github.com/FranciscoMoretti/chat-js/commit/6b1458cb071fe4e67bca99fa86ff55bfb4852c64) Thanks [@FranciscoMoretti](https://github.com/FranciscoMoretti)! - Add a
|
|
13
|
+
- [#136](https://github.com/FranciscoMoretti/chat-js/pull/136) [`6b1458c`](https://github.com/FranciscoMoretti/chat-js/commit/6b1458cb071fe4e67bca99fa86ff55bfb4852c64) Thanks [@FranciscoMoretti](https://github.com/FranciscoMoretti)! - Add a Changesets-driven desktop release flow for the Electron app. Desktop artifacts are versioned through the shared version PR flow, then published to GitHub Releases for the ChatJS reference app.
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { type ToolName, toolNameSchema } from "../types";
|
|
2
|
-
|
|
3
|
-
// Tool costs in CENTS (external API fees only)
|
|
4
|
-
// LLM costs are calculated separately from token usage
|
|
5
|
-
export const toolsDefinitions: Record<ToolName, ToolDefinition> = {
|
|
6
|
-
getWeather: {
|
|
7
|
-
name: "getWeather",
|
|
8
|
-
description: "Get the weather in a specific location",
|
|
9
|
-
cost: 0, // internal
|
|
10
|
-
},
|
|
11
|
-
createTextDocument: {
|
|
12
|
-
name: "createTextDocument",
|
|
13
|
-
description: "Create a text document",
|
|
14
|
-
cost: 0, // internal
|
|
15
|
-
},
|
|
16
|
-
createCodeDocument: {
|
|
17
|
-
name: "createCodeDocument",
|
|
18
|
-
description: "Create a code document",
|
|
19
|
-
cost: 0, // internal
|
|
20
|
-
},
|
|
21
|
-
createSheetDocument: {
|
|
22
|
-
name: "createSheetDocument",
|
|
23
|
-
description: "Create a spreadsheet",
|
|
24
|
-
cost: 0, // internal
|
|
25
|
-
},
|
|
26
|
-
editTextDocument: {
|
|
27
|
-
name: "editTextDocument",
|
|
28
|
-
description: "Edit a text document",
|
|
29
|
-
cost: 0, // internal
|
|
30
|
-
},
|
|
31
|
-
editCodeDocument: {
|
|
32
|
-
name: "editCodeDocument",
|
|
33
|
-
description: "Edit a code document",
|
|
34
|
-
cost: 0, // internal
|
|
35
|
-
},
|
|
36
|
-
editSheetDocument: {
|
|
37
|
-
name: "editSheetDocument",
|
|
38
|
-
description: "Edit a spreadsheet",
|
|
39
|
-
cost: 0, // internal
|
|
40
|
-
},
|
|
41
|
-
readDocument: {
|
|
42
|
-
name: "readDocument",
|
|
43
|
-
description: "Read the content of a document",
|
|
44
|
-
cost: 0, // internal
|
|
45
|
-
},
|
|
46
|
-
retrieveUrl: {
|
|
47
|
-
name: "retrieveUrl",
|
|
48
|
-
description: "Retrieve information from a URL",
|
|
49
|
-
cost: 0, // internal
|
|
50
|
-
},
|
|
51
|
-
webSearch: {
|
|
52
|
-
name: "webSearch",
|
|
53
|
-
description: "Search the web",
|
|
54
|
-
cost: 5, // Tavily API ~5¢
|
|
55
|
-
},
|
|
56
|
-
codeExecution: {
|
|
57
|
-
name: "codeExecution",
|
|
58
|
-
description: "Execute code in a virtual environment",
|
|
59
|
-
cost: 5, // Vercel Sandbox execution ~5¢
|
|
60
|
-
},
|
|
61
|
-
generateImage: {
|
|
62
|
-
name: "generateImage",
|
|
63
|
-
description: "Generate images from text descriptions",
|
|
64
|
-
cost: 0, // LLM cost tracked via token usage
|
|
65
|
-
},
|
|
66
|
-
generateVideo: {
|
|
67
|
-
name: "generateVideo",
|
|
68
|
-
description: "Generate video clips from text descriptions",
|
|
69
|
-
cost: 0, // LLM cost tracked via token usage
|
|
70
|
-
},
|
|
71
|
-
deepResearch: {
|
|
72
|
-
name: "deepResearch",
|
|
73
|
-
description: "Research a topic",
|
|
74
|
-
cost: 0, // LLM calls tracked via usage, Tavily calls counted separately
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export const allTools = toolNameSchema.options;
|
|
79
|
-
interface ToolDefinition {
|
|
80
|
-
cost: number;
|
|
81
|
-
description: string;
|
|
82
|
-
name: string;
|
|
83
|
-
}
|
/package/templates/chat-app/{lib/ai/tools/get-weather.ts → tools/chatjs/get-weather/tool.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/researcher-agent.ts
RENAMED
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/deep-research/supervisor-agent.ts
RENAMED
|
File without changes
|
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-code-document.ts
RENAMED
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-sheet-document.ts
RENAMED
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/create-text-document.ts
RENAMED
|
File without changes
|
|
File without changes
|
/package/templates/chat-app/{lib/ai/tools → tools/platform}/documents/edit-sheet-document.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|