ai-site-pilot 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +295 -0
- package/dist/api/index.d.mts +78 -0
- package/dist/api/index.d.ts +78 -0
- package/dist/api/index.js +142 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +137 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +69 -0
- package/dist/hooks/index.d.ts +69 -0
- package/dist/hooks/index.js +240 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +237 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +597 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +238 -0
- package/dist/tools/index.d.mts +71 -0
- package/dist/tools/index.d.ts +71 -0
- package/dist/tools/index.js +124 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/index.mjs +119 -0
- package/dist/tools/index.mjs.map +1 -0
- package/dist/types--7jDyUM6.d.mts +32 -0
- package/dist/types--7jDyUM6.d.ts +32 -0
- package/dist/types-DAvVRuXd.d.mts +71 -0
- package/dist/types-DAvVRuXd.d.ts +71 -0
- package/package.json +81 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/tools/registry.ts
|
|
2
|
+
function defineTool(config) {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
function defineSimpleTool(name, description, handler) {
|
|
6
|
+
return {
|
|
7
|
+
name,
|
|
8
|
+
description,
|
|
9
|
+
parameters: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {},
|
|
12
|
+
required: []
|
|
13
|
+
},
|
|
14
|
+
handler
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var ToolRegistry = class {
|
|
18
|
+
constructor(tools = []) {
|
|
19
|
+
this.tools = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const tool of tools) {
|
|
21
|
+
this.register(tool);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Register a tool
|
|
26
|
+
*/
|
|
27
|
+
register(tool) {
|
|
28
|
+
this.tools.set(tool.name, tool);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Unregister a tool
|
|
32
|
+
*/
|
|
33
|
+
unregister(name) {
|
|
34
|
+
this.tools.delete(name);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get a tool by name
|
|
38
|
+
*/
|
|
39
|
+
get(name) {
|
|
40
|
+
return this.tools.get(name);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get all tools
|
|
44
|
+
*/
|
|
45
|
+
getAll() {
|
|
46
|
+
return Array.from(this.tools.values());
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Execute a tool by name with given arguments
|
|
50
|
+
*/
|
|
51
|
+
async execute(execution) {
|
|
52
|
+
const tool = this.tools.get(execution.name);
|
|
53
|
+
if (!tool) {
|
|
54
|
+
console.warn(`Tool not found: ${execution.name}`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (tool.handler) {
|
|
58
|
+
await tool.handler(execution.args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute multiple tools in sequence
|
|
63
|
+
*/
|
|
64
|
+
async executeAll(executions, delayMs = 300) {
|
|
65
|
+
for (const execution of executions) {
|
|
66
|
+
await this.execute(execution);
|
|
67
|
+
if (delayMs > 0 && executions.indexOf(execution) < executions.length - 1) {
|
|
68
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert to Vercel AI SDK tool format
|
|
74
|
+
*/
|
|
75
|
+
toVercelAITools() {
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const tool of this.tools.values()) {
|
|
78
|
+
result[tool.name] = {
|
|
79
|
+
description: tool.description,
|
|
80
|
+
parameters: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: tool.parameters.properties,
|
|
83
|
+
required: tool.parameters.required
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convert to Gemini function declarations format
|
|
91
|
+
*/
|
|
92
|
+
toGeminiFunctionDeclarations() {
|
|
93
|
+
return this.getAll().map((tool) => ({
|
|
94
|
+
name: tool.name,
|
|
95
|
+
description: tool.description,
|
|
96
|
+
parameters: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: Object.fromEntries(
|
|
99
|
+
Object.entries(tool.parameters.properties).map(([key, value]) => [
|
|
100
|
+
key,
|
|
101
|
+
{
|
|
102
|
+
type: value.type,
|
|
103
|
+
description: value.description,
|
|
104
|
+
enum: value.enum
|
|
105
|
+
}
|
|
106
|
+
])
|
|
107
|
+
),
|
|
108
|
+
required: tool.parameters.required
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function createToolRegistry(tools) {
|
|
114
|
+
return new ToolRegistry(tools);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { ToolRegistry, createToolRegistry, defineSimpleTool, defineTool };
|
|
118
|
+
//# sourceMappingURL=index.mjs.map
|
|
119
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tools/registry.ts"],"names":[],"mappings":";AASO,SAAS,WACd,MAAA,EACyB;AACzB,EAAA,OAAO,MAAA;AACT;AAKO,SAAS,gBAAA,CACd,IAAA,EACA,WAAA,EACA,OAAA,EACgB;AAChB,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA,EAAY;AAAA,MACV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,CAAQ,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AAAA,YAC/D,GAAA;AAAA,YACA;AAAA,cACE,MAAM,KAAA,CAAM,IAAA;AAAA,cACZ,aAAa,KAAA,CAAM,WAAA;AAAA,cACnB,MAAM,KAAA,CAAM;AAAA;AACd,WACD;AAAA,SACH;AAAA,QACA,QAAA,EAAU,KAAK,UAAA,CAAW;AAAA;AAC5B,KACF,CAAE,CAAA;AAAA,EACJ;AACF;AAKO,SAAS,mBAAmB,KAAA,EAAuC;AACxE,EAAA,OAAO,IAAI,aAAa,KAAK,CAAA;AAC/B","file":"index.mjs","sourcesContent":["/**\n * Tool registry for managing and converting tool definitions\n */\n\nimport type { ToolDefinition, ToolParameters, ToolExecution } from './types';\n\n/**\n * Helper function to define a tool with type safety\n */\nexport function defineTool<TParams extends Record<string, unknown>>(\n config: ToolDefinition<TParams>\n): ToolDefinition<TParams> {\n return config;\n}\n\n/**\n * Create a simple tool with no parameters\n */\nexport function defineSimpleTool(\n name: string,\n description: string,\n handler?: () => void | Promise<void>\n): ToolDefinition {\n return {\n name,\n description,\n parameters: {\n type: 'object',\n properties: {},\n required: [],\n },\n handler,\n };\n}\n\n/**\n * Tool registry for managing multiple tools\n */\nexport class ToolRegistry {\n private tools: Map<string, ToolDefinition> = new Map();\n\n constructor(tools: ToolDefinition[] = []) {\n for (const tool of tools) {\n this.register(tool);\n }\n }\n\n /**\n * Register a tool\n */\n register(tool: ToolDefinition): void {\n this.tools.set(tool.name, tool);\n }\n\n /**\n * Unregister a tool\n */\n unregister(name: string): void {\n this.tools.delete(name);\n }\n\n /**\n * Get a tool by name\n */\n get(name: string): ToolDefinition | undefined {\n return this.tools.get(name);\n }\n\n /**\n * Get all tools\n */\n getAll(): ToolDefinition[] {\n return Array.from(this.tools.values());\n }\n\n /**\n * Execute a tool by name with given arguments\n */\n async execute(execution: ToolExecution): Promise<void> {\n const tool = this.tools.get(execution.name);\n if (!tool) {\n console.warn(`Tool not found: ${execution.name}`);\n return;\n }\n if (tool.handler) {\n await tool.handler(execution.args);\n }\n }\n\n /**\n * Execute multiple tools in sequence\n */\n async executeAll(executions: ToolExecution[], delayMs = 300): Promise<void> {\n for (const execution of executions) {\n await this.execute(execution);\n if (delayMs > 0 && executions.indexOf(execution) < executions.length - 1) {\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n }\n\n /**\n * Convert to Vercel AI SDK tool format\n */\n toVercelAITools(): Record<string, { description: string; parameters: unknown }> {\n const result: Record<string, { description: string; parameters: unknown }> = {};\n\n for (const tool of this.tools.values()) {\n result[tool.name] = {\n description: tool.description,\n parameters: {\n type: 'object',\n properties: tool.parameters.properties,\n required: tool.parameters.required,\n },\n };\n }\n\n return result;\n }\n\n /**\n * Convert to Gemini function declarations format\n */\n toGeminiFunctionDeclarations(): Array<{\n name: string;\n description: string;\n parameters: {\n type: 'object';\n properties: Record<string, unknown>;\n required: string[];\n };\n }> {\n return this.getAll().map(tool => ({\n name: tool.name,\n description: tool.description,\n parameters: {\n type: 'object' as const,\n properties: Object.fromEntries(\n Object.entries(tool.parameters.properties).map(([key, value]) => [\n key,\n {\n type: value.type,\n description: value.description,\n enum: value.enum,\n },\n ])\n ),\n required: tool.parameters.required,\n },\n }));\n }\n}\n\n/**\n * Create a tool registry from an array of tools\n */\nexport function createToolRegistry(tools: ToolDefinition[]): ToolRegistry {\n return new ToolRegistry(tools);\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool system types
|
|
3
|
+
*/
|
|
4
|
+
interface ToolParameterProperty {
|
|
5
|
+
type: 'string' | 'number' | 'boolean' | 'array';
|
|
6
|
+
description: string;
|
|
7
|
+
enum?: string[];
|
|
8
|
+
items?: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ToolParameters {
|
|
13
|
+
type: 'object';
|
|
14
|
+
properties: Record<string, ToolParameterProperty>;
|
|
15
|
+
required: string[];
|
|
16
|
+
}
|
|
17
|
+
interface ToolDefinition<TParams extends Record<string, unknown> = Record<string, unknown>> {
|
|
18
|
+
/** Unique name for the tool */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Description shown to the AI - be specific about when to use it */
|
|
21
|
+
description: string;
|
|
22
|
+
/** Parameter schema */
|
|
23
|
+
parameters: ToolParameters;
|
|
24
|
+
/** Handler function executed when the AI calls this tool */
|
|
25
|
+
handler?: (params: TParams) => void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface ToolExecution {
|
|
28
|
+
name: string;
|
|
29
|
+
args: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { ToolDefinition as T, ToolExecution as a, ToolParameters as b, ToolParameterProperty as c };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool system types
|
|
3
|
+
*/
|
|
4
|
+
interface ToolParameterProperty {
|
|
5
|
+
type: 'string' | 'number' | 'boolean' | 'array';
|
|
6
|
+
description: string;
|
|
7
|
+
enum?: string[];
|
|
8
|
+
items?: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ToolParameters {
|
|
13
|
+
type: 'object';
|
|
14
|
+
properties: Record<string, ToolParameterProperty>;
|
|
15
|
+
required: string[];
|
|
16
|
+
}
|
|
17
|
+
interface ToolDefinition<TParams extends Record<string, unknown> = Record<string, unknown>> {
|
|
18
|
+
/** Unique name for the tool */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Description shown to the AI - be specific about when to use it */
|
|
21
|
+
description: string;
|
|
22
|
+
/** Parameter schema */
|
|
23
|
+
parameters: ToolParameters;
|
|
24
|
+
/** Handler function executed when the AI calls this tool */
|
|
25
|
+
handler?: (params: TParams) => void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface ToolExecution {
|
|
28
|
+
name: string;
|
|
29
|
+
args: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { ToolDefinition as T, ToolExecution as a, ToolParameters as b, ToolParameterProperty as c };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for ai-site-pilot
|
|
3
|
+
*/
|
|
4
|
+
interface ChatMessage {
|
|
5
|
+
id: string;
|
|
6
|
+
role: 'user' | 'assistant';
|
|
7
|
+
content: string;
|
|
8
|
+
timestamp: Date;
|
|
9
|
+
toolCalls?: ToolExecution[];
|
|
10
|
+
}
|
|
11
|
+
interface ToolExecution {
|
|
12
|
+
name: string;
|
|
13
|
+
args: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
type StreamEvent = {
|
|
16
|
+
type: 'text';
|
|
17
|
+
content: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'tool';
|
|
20
|
+
name: string;
|
|
21
|
+
args: Record<string, unknown>;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'done';
|
|
24
|
+
} | {
|
|
25
|
+
type: 'error';
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
interface Suggestion {
|
|
29
|
+
text: string;
|
|
30
|
+
icon?: string;
|
|
31
|
+
}
|
|
32
|
+
interface SitePilotTheme {
|
|
33
|
+
/** Accent color name (e.g., 'amber', 'blue', 'green') or CSS color */
|
|
34
|
+
accent?: string;
|
|
35
|
+
/** Position of the chat panel */
|
|
36
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
37
|
+
/** Border radius in pixels */
|
|
38
|
+
borderRadius?: number;
|
|
39
|
+
}
|
|
40
|
+
interface SitePilotFeatures {
|
|
41
|
+
/** Enable speech recognition input */
|
|
42
|
+
speech?: boolean;
|
|
43
|
+
/** Enable text-to-speech for responses */
|
|
44
|
+
tts?: boolean;
|
|
45
|
+
/** Enable fullscreen mode toggle */
|
|
46
|
+
fullscreen?: boolean;
|
|
47
|
+
/** Show suggestion chips */
|
|
48
|
+
suggestions?: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface SitePilotProps {
|
|
51
|
+
/** API endpoint for chat (e.g., '/api/chat') */
|
|
52
|
+
apiEndpoint: string;
|
|
53
|
+
/** Theme configuration */
|
|
54
|
+
theme?: SitePilotTheme;
|
|
55
|
+
/** Suggestion prompts to show */
|
|
56
|
+
suggestions?: Suggestion[];
|
|
57
|
+
/** Feature toggles */
|
|
58
|
+
features?: SitePilotFeatures;
|
|
59
|
+
/** Callback when a tool is called by the AI */
|
|
60
|
+
onToolCall?: (toolName: string, args: Record<string, unknown>) => void | Promise<void>;
|
|
61
|
+
/** Initial open state */
|
|
62
|
+
defaultOpen?: boolean;
|
|
63
|
+
/** Placeholder text for input */
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
/** Welcome message shown before first interaction */
|
|
66
|
+
welcomeMessage?: string;
|
|
67
|
+
/** Custom class name for the container */
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { ChatMessage as C, StreamEvent as S, ToolExecution as T, SitePilotProps as a, Suggestion as b, SitePilotTheme as c, SitePilotFeatures as d };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for ai-site-pilot
|
|
3
|
+
*/
|
|
4
|
+
interface ChatMessage {
|
|
5
|
+
id: string;
|
|
6
|
+
role: 'user' | 'assistant';
|
|
7
|
+
content: string;
|
|
8
|
+
timestamp: Date;
|
|
9
|
+
toolCalls?: ToolExecution[];
|
|
10
|
+
}
|
|
11
|
+
interface ToolExecution {
|
|
12
|
+
name: string;
|
|
13
|
+
args: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
type StreamEvent = {
|
|
16
|
+
type: 'text';
|
|
17
|
+
content: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'tool';
|
|
20
|
+
name: string;
|
|
21
|
+
args: Record<string, unknown>;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'done';
|
|
24
|
+
} | {
|
|
25
|
+
type: 'error';
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
interface Suggestion {
|
|
29
|
+
text: string;
|
|
30
|
+
icon?: string;
|
|
31
|
+
}
|
|
32
|
+
interface SitePilotTheme {
|
|
33
|
+
/** Accent color name (e.g., 'amber', 'blue', 'green') or CSS color */
|
|
34
|
+
accent?: string;
|
|
35
|
+
/** Position of the chat panel */
|
|
36
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
37
|
+
/** Border radius in pixels */
|
|
38
|
+
borderRadius?: number;
|
|
39
|
+
}
|
|
40
|
+
interface SitePilotFeatures {
|
|
41
|
+
/** Enable speech recognition input */
|
|
42
|
+
speech?: boolean;
|
|
43
|
+
/** Enable text-to-speech for responses */
|
|
44
|
+
tts?: boolean;
|
|
45
|
+
/** Enable fullscreen mode toggle */
|
|
46
|
+
fullscreen?: boolean;
|
|
47
|
+
/** Show suggestion chips */
|
|
48
|
+
suggestions?: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface SitePilotProps {
|
|
51
|
+
/** API endpoint for chat (e.g., '/api/chat') */
|
|
52
|
+
apiEndpoint: string;
|
|
53
|
+
/** Theme configuration */
|
|
54
|
+
theme?: SitePilotTheme;
|
|
55
|
+
/** Suggestion prompts to show */
|
|
56
|
+
suggestions?: Suggestion[];
|
|
57
|
+
/** Feature toggles */
|
|
58
|
+
features?: SitePilotFeatures;
|
|
59
|
+
/** Callback when a tool is called by the AI */
|
|
60
|
+
onToolCall?: (toolName: string, args: Record<string, unknown>) => void | Promise<void>;
|
|
61
|
+
/** Initial open state */
|
|
62
|
+
defaultOpen?: boolean;
|
|
63
|
+
/** Placeholder text for input */
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
/** Welcome message shown before first interaction */
|
|
66
|
+
welcomeMessage?: string;
|
|
67
|
+
/** Custom class name for the container */
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { ChatMessage as C, StreamEvent as S, ToolExecution as T, SitePilotProps as a, Suggestion as b, SitePilotTheme as c, SitePilotFeatures as d };
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-site-pilot",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI chat widget that can control and navigate your website. Full-stack solution with streaming, tool system, and polished UI.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./api": {
|
|
15
|
+
"types": "./dist/api/index.d.ts",
|
|
16
|
+
"import": "./dist/api/index.mjs",
|
|
17
|
+
"require": "./dist/api/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./tools": {
|
|
20
|
+
"types": "./dist/tools/index.d.ts",
|
|
21
|
+
"import": "./dist/tools/index.mjs",
|
|
22
|
+
"require": "./dist/tools/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./hooks": {
|
|
25
|
+
"types": "./dist/hooks/index.d.ts",
|
|
26
|
+
"import": "./dist/hooks/index.mjs",
|
|
27
|
+
"require": "./dist/hooks/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./styles.css": "./dist/styles.css"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup && cp src/styles.css dist/styles.css",
|
|
37
|
+
"dev": "tsup --watch",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"ai",
|
|
43
|
+
"chat",
|
|
44
|
+
"chatbot",
|
|
45
|
+
"site-pilot",
|
|
46
|
+
"navigation",
|
|
47
|
+
"react",
|
|
48
|
+
"nextjs",
|
|
49
|
+
"vercel-ai-sdk",
|
|
50
|
+
"streaming",
|
|
51
|
+
"tools",
|
|
52
|
+
"function-calling"
|
|
53
|
+
],
|
|
54
|
+
"author": "Ben.Builds",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/xBenJamminx/ai-site-pilot"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/xBenJamminx/ai-site-pilot#readme",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/xBenJamminx/ai-site-pilot/issues"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
66
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"ai": "^4.0.0",
|
|
70
|
+
"framer-motion": "^11.0.0",
|
|
71
|
+
"lucide-react": "^0.400.0",
|
|
72
|
+
"react-markdown": "^9.0.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/node": "^20.0.0",
|
|
76
|
+
"@types/react": "^18.0.0",
|
|
77
|
+
"@types/react-dom": "^18.0.0",
|
|
78
|
+
"tsup": "^8.0.0",
|
|
79
|
+
"typescript": "^5.0.0"
|
|
80
|
+
}
|
|
81
|
+
}
|