copilotkit 1.54.0 → 2.0.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/index.js +89779 -0
- package/package.json +4 -114
- package/src/commands/docs.d.ts +17 -0
- package/src/commands/docs.d.ts.map +1 -0
- package/src/commands/init.d.ts +103 -0
- package/src/commands/init.d.ts.map +1 -0
- package/src/commands/kite.d.ts +8 -0
- package/src/commands/kite.d.ts.map +1 -0
- package/src/commands/license.d.ts +17 -0
- package/src/commands/license.d.ts.map +1 -0
- package/src/commands/login.d.ts +13 -0
- package/src/commands/login.d.ts.map +1 -0
- package/src/commands/logs.d.ts +32 -0
- package/src/commands/logs.d.ts.map +1 -0
- package/src/commands/version.d.ts +8 -0
- package/src/commands/version.d.ts.map +1 -0
- package/src/config.d.ts +31 -0
- package/src/config.d.ts.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.d.ts.map +1 -0
- package/src/services/api-client.d.ts +106 -0
- package/src/services/api-client.d.ts.map +1 -0
- package/src/services/auth.service.d.ts +107 -0
- package/src/services/auth.service.d.ts.map +1 -0
- package/src/services/cli-auth-diagnostics.d.ts +71 -0
- package/src/services/cli-auth-diagnostics.d.ts.map +1 -0
- package/src/services/cli-logs.d.ts +45 -0
- package/src/services/cli-logs.d.ts.map +1 -0
- package/src/services/config.service.d.ts +53 -0
- package/src/services/config.service.d.ts.map +1 -0
- package/src/services/feature-flags.d.ts +14 -0
- package/src/services/feature-flags.d.ts.map +1 -0
- package/src/services/kite-game-engine.d.ts +99 -0
- package/src/services/kite-game-engine.d.ts.map +1 -0
- package/src/services/kite-game-score.d.ts +33 -0
- package/src/services/kite-game-score.d.ts.map +1 -0
- package/src/services/project-scaffold.d.ts +49 -0
- package/src/services/project-scaffold.d.ts.map +1 -0
- package/src/types.d.ts +205 -0
- package/src/types.d.ts.map +1 -0
- package/src/ui/banner.d.ts +3 -0
- package/src/ui/banner.d.ts.map +1 -0
- package/src/ui/browser-login.d.ts +71 -0
- package/src/ui/browser-login.d.ts.map +1 -0
- package/src/ui/init-flow.d.ts +35 -0
- package/src/ui/init-flow.d.ts.map +1 -0
- package/src/ui/kite-game.d.ts +26 -0
- package/src/ui/kite-game.d.ts.map +1 -0
- package/src/ui/login-flow.d.ts +22 -0
- package/src/ui/login-flow.d.ts.map +1 -0
- package/src/ui/spinner.d.ts +9 -0
- package/src/ui/spinner.d.ts.map +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -83
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -8
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -17
- package/dist/commands/base-command.d.ts +0 -12
- package/dist/commands/base-command.js +0 -65
- package/dist/commands/base-command.js.map +0 -1
- package/dist/commands/create.d.ts +0 -24
- package/dist/commands/create.js +0 -507
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -25
- package/dist/commands/dev.js +0 -776
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/init.d.ts +0 -11
- package/dist/commands/init.js +0 -523
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/login.d.ts +0 -13
- package/dist/commands/login.js +0 -374
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -13
- package/dist/commands/logout.js +0 -375
- package/dist/commands/logout.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/lib/init/ide-docs.d.ts +0 -25
- package/dist/lib/init/ide-docs.js +0 -170
- package/dist/lib/init/ide-docs.js.map +0 -1
- package/dist/lib/init/index.d.ts +0 -14
- package/dist/lib/init/index.js +0 -1104
- package/dist/lib/init/index.js.map +0 -1
- package/dist/lib/init/questions.d.ts +0 -9
- package/dist/lib/init/questions.js +0 -508
- package/dist/lib/init/questions.js.map +0 -1
- package/dist/lib/init/scaffold/agent.d.ts +0 -20
- package/dist/lib/init/scaffold/agent.js +0 -173
- package/dist/lib/init/scaffold/agent.js.map +0 -1
- package/dist/lib/init/scaffold/crew-inputs.d.ts +0 -3
- package/dist/lib/init/scaffold/crew-inputs.js +0 -59
- package/dist/lib/init/scaffold/crew-inputs.js.map +0 -1
- package/dist/lib/init/scaffold/env.d.ts +0 -7
- package/dist/lib/init/scaffold/env.js +0 -124
- package/dist/lib/init/scaffold/env.js.map +0 -1
- package/dist/lib/init/scaffold/github.d.ts +0 -17
- package/dist/lib/init/scaffold/github.js +0 -114
- package/dist/lib/init/scaffold/github.js.map +0 -1
- package/dist/lib/init/scaffold/index.d.ts +0 -10
- package/dist/lib/init/scaffold/index.js +0 -690
- package/dist/lib/init/scaffold/index.js.map +0 -1
- package/dist/lib/init/scaffold/langgraph-assistants.d.ts +0 -18
- package/dist/lib/init/scaffold/langgraph-assistants.js +0 -26
- package/dist/lib/init/scaffold/langgraph-assistants.js.map +0 -1
- package/dist/lib/init/scaffold/packages.d.ts +0 -7
- package/dist/lib/init/scaffold/packages.js +0 -62
- package/dist/lib/init/scaffold/packages.js.map +0 -1
- package/dist/lib/init/scaffold/shadcn.d.ts +0 -7
- package/dist/lib/init/scaffold/shadcn.js +0 -279
- package/dist/lib/init/scaffold/shadcn.js.map +0 -1
- package/dist/lib/init/types/index.d.ts +0 -4
- package/dist/lib/init/types/index.js +0 -238
- package/dist/lib/init/types/index.js.map +0 -1
- package/dist/lib/init/types/questions.d.ts +0 -209
- package/dist/lib/init/types/questions.js +0 -214
- package/dist/lib/init/types/questions.js.map +0 -1
- package/dist/lib/init/types/templates.d.ts +0 -17
- package/dist/lib/init/types/templates.js +0 -26
- package/dist/lib/init/types/templates.js.map +0 -1
- package/dist/lib/init/utils.d.ts +0 -3
- package/dist/lib/init/utils.js +0 -8
- package/dist/lib/init/utils.js.map +0 -1
- package/dist/services/analytics.service.d.ts +0 -38
- package/dist/services/analytics.service.js +0 -134
- package/dist/services/analytics.service.js.map +0 -1
- package/dist/services/auth.service.d.ts +0 -26
- package/dist/services/auth.service.js +0 -299
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/events.d.ts +0 -119
- package/dist/services/events.js +0 -1
- package/dist/services/events.js.map +0 -1
- package/dist/services/tunnel.service.d.ts +0 -15
- package/dist/services/tunnel.service.js +0 -21
- package/dist/services/tunnel.service.js.map +0 -1
- package/dist/utils/detect-endpoint-type.utils.d.ts +0 -15
- package/dist/utils/detect-endpoint-type.utils.js +0 -157
- package/dist/utils/detect-endpoint-type.utils.js.map +0 -1
- package/dist/utils/trpc.d.ts +0 -4
- package/dist/utils/trpc.js +0 -25
- package/dist/utils/trpc.js.map +0 -1
- package/dist/utils/version.d.ts +0 -3
- package/dist/utils/version.js +0 -6
- package/dist/utils/version.js.map +0 -1
- package/oclif.manifest.json +0 -208
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// src/lib/init/scaffold/agent.ts
|
|
2
|
-
import ora from "ora";
|
|
3
|
-
import chalk2 from "chalk";
|
|
4
|
-
|
|
5
|
-
// src/lib/init/scaffold/github.ts
|
|
6
|
-
import { execSync } from "child_process";
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
import * as os from "os";
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
12
|
-
try {
|
|
13
|
-
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
14
|
-
spinner.text = chalk.cyan(`Cloning from ${owner}/${repo}...`);
|
|
15
|
-
return await sparseCheckout(
|
|
16
|
-
owner,
|
|
17
|
-
repo,
|
|
18
|
-
branch,
|
|
19
|
-
subdirectoryPath,
|
|
20
|
-
destinationPath,
|
|
21
|
-
spinner
|
|
22
|
-
);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
spinner.text = chalk.red(`Failed to clone from GitHub: ${error}`);
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
29
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
30
|
-
try {
|
|
31
|
-
spinner.text = chalk.cyan("Creating temporary workspace...");
|
|
32
|
-
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
33
|
-
spinner.text = chalk.cyan("Connecting to repository...");
|
|
34
|
-
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
|
|
35
|
-
cwd: tempDir,
|
|
36
|
-
stdio: "pipe"
|
|
37
|
-
});
|
|
38
|
-
execSync("git config core.sparseCheckout true", {
|
|
39
|
-
cwd: tempDir,
|
|
40
|
-
stdio: "pipe"
|
|
41
|
-
});
|
|
42
|
-
fs.writeFileSync(
|
|
43
|
-
path.join(tempDir, ".git/info/sparse-checkout"),
|
|
44
|
-
subdirectoryPath
|
|
45
|
-
);
|
|
46
|
-
spinner.text = chalk.cyan("Downloading agent files...");
|
|
47
|
-
execSync(`git pull origin ${branch} --depth=1`, {
|
|
48
|
-
cwd: tempDir,
|
|
49
|
-
stdio: "pipe"
|
|
50
|
-
});
|
|
51
|
-
const sourcePath = path.join(tempDir, subdirectoryPath);
|
|
52
|
-
if (!fs.existsSync(sourcePath)) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
`Subdirectory '${subdirectoryPath}' not found in the repository.`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
fs.mkdirSync(destinationPath, { recursive: true });
|
|
58
|
-
spinner.text = chalk.cyan("Installing agent files...");
|
|
59
|
-
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
60
|
-
return true;
|
|
61
|
-
} finally {
|
|
62
|
-
try {
|
|
63
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.warn(`Failed to clean up temporary directory: ${error}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async function copyDirectoryAsync(source, destination) {
|
|
70
|
-
if (!fs.existsSync(destination)) {
|
|
71
|
-
fs.mkdirSync(destination, { recursive: true });
|
|
72
|
-
}
|
|
73
|
-
const entries = fs.readdirSync(source, { withFileTypes: true });
|
|
74
|
-
for (const entry of entries) {
|
|
75
|
-
const srcPath = path.join(source, entry.name);
|
|
76
|
-
const destPath = path.join(destination, entry.name);
|
|
77
|
-
if (entry.isDirectory()) {
|
|
78
|
-
await copyDirectoryAsync(srcPath, destPath);
|
|
79
|
-
} else {
|
|
80
|
-
fs.copyFileSync(srcPath, destPath);
|
|
81
|
-
}
|
|
82
|
-
if (entries.length > 10) {
|
|
83
|
-
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function parseGitHubUrl(githubUrl) {
|
|
88
|
-
const url = new URL(githubUrl);
|
|
89
|
-
if (url.hostname !== "github.com") {
|
|
90
|
-
throw new Error("Only GitHub URLs are supported");
|
|
91
|
-
}
|
|
92
|
-
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
93
|
-
if (pathParts.length < 2) {
|
|
94
|
-
throw new Error("Invalid GitHub URL format");
|
|
95
|
-
}
|
|
96
|
-
const owner = pathParts[0];
|
|
97
|
-
const repo = pathParts[1];
|
|
98
|
-
let branch = "main";
|
|
99
|
-
let subdirectoryPath = "";
|
|
100
|
-
if (pathParts.length > 3 && (pathParts[2] === "tree" || pathParts[2] === "blob")) {
|
|
101
|
-
branch = pathParts[3];
|
|
102
|
-
subdirectoryPath = pathParts.slice(4).join("/");
|
|
103
|
-
}
|
|
104
|
-
return { owner, repo, branch, subdirectoryPath };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// src/lib/init/scaffold/agent.ts
|
|
108
|
-
import path2 from "path";
|
|
109
|
-
import fs2 from "fs";
|
|
110
|
-
async function scaffoldAgent(userAnswers) {
|
|
111
|
-
if (userAnswers.mode === "CrewAI" || userAnswers.mode === "LangGraph" && !userAnswers.langGraphAgent || userAnswers.mode === "Standard" || userAnswers.mode === "MCP") {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const spinner = ora({
|
|
115
|
-
text: chalk2.cyan("Setting up AI agent..."),
|
|
116
|
-
color: "cyan"
|
|
117
|
-
}).start();
|
|
118
|
-
let template = "";
|
|
119
|
-
switch (userAnswers.mode) {
|
|
120
|
-
case "LangGraph":
|
|
121
|
-
if (userAnswers.langGraphAgent === "Python Starter") {
|
|
122
|
-
template = AgentTemplates.LangGraph.Starter.Python;
|
|
123
|
-
} else {
|
|
124
|
-
template = AgentTemplates.LangGraph.Starter.TypeScript;
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
if (!template) {
|
|
129
|
-
spinner.fail(chalk2.red("Failed to determine agent template"));
|
|
130
|
-
throw new Error("Failed to determine agent template");
|
|
131
|
-
}
|
|
132
|
-
const agentDir = path2.join(process.cwd(), "agent");
|
|
133
|
-
try {
|
|
134
|
-
await cloneGitHubSubdirectory(template, agentDir, spinner);
|
|
135
|
-
spinner.text = chalk2.cyan("Creating agent environment variables...");
|
|
136
|
-
let envContent = "";
|
|
137
|
-
if (userAnswers.llmToken) {
|
|
138
|
-
envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
|
|
142
|
-
envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
if (envContent) {
|
|
146
|
-
const agentEnvFile = path2.join(agentDir, ".env");
|
|
147
|
-
fs2.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
148
|
-
spinner.text = chalk2.cyan("Added API keys to agent .env file");
|
|
149
|
-
}
|
|
150
|
-
} catch (error) {
|
|
151
|
-
spinner.fail(chalk2.red("Failed to clone agent template"));
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
spinner.succeed(`${userAnswers.mode} agent cloned successfully`);
|
|
155
|
-
}
|
|
156
|
-
var AgentTemplates = {
|
|
157
|
-
LangGraph: {
|
|
158
|
-
Starter: {
|
|
159
|
-
Python: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-py",
|
|
160
|
-
TypeScript: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-js"
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
CrewAI: {
|
|
164
|
-
Flows: {
|
|
165
|
-
Starter: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-crewai-flows/agent-py"
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
export {
|
|
170
|
-
AgentTemplates,
|
|
171
|
-
scaffoldAgent
|
|
172
|
-
};
|
|
173
|
-
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/init/scaffold/agent.ts","../../../../src/lib/init/scaffold/github.ts"],"sourcesContent":["import ora from \"ora\";\nimport chalk from \"chalk\";\nimport { cloneGitHubSubdirectory } from \"./github.js\";\nimport { Config } from \"../types/index.js\";\nimport path from \"path\";\nimport fs from \"fs\";\n\nexport async function scaffoldAgent(userAnswers: Config) {\n if (\n userAnswers.mode === \"CrewAI\" ||\n (userAnswers.mode === \"LangGraph\" && !userAnswers.langGraphAgent) ||\n userAnswers.mode === \"Standard\" ||\n userAnswers.mode === \"MCP\"\n ) {\n return;\n }\n\n const spinner = ora({\n text: chalk.cyan(\"Setting up AI agent...\"),\n color: \"cyan\",\n }).start();\n\n let template = \"\";\n switch (userAnswers.mode) {\n case \"LangGraph\":\n if (userAnswers.langGraphAgent === \"Python Starter\") {\n template = AgentTemplates.LangGraph.Starter.Python;\n } else {\n template = AgentTemplates.LangGraph.Starter.TypeScript;\n }\n break;\n }\n\n if (!template) {\n spinner.fail(chalk.red(\"Failed to determine agent template\"));\n throw new Error(\"Failed to determine agent template\");\n }\n\n const agentDir = path.join(process.cwd(), \"agent\");\n\n try {\n await cloneGitHubSubdirectory(template, agentDir, spinner);\n\n // Create .env file in the agent directory\n spinner.text = chalk.cyan(\"Creating agent environment variables...\");\n\n let envContent = \"\";\n\n // Add OpenAI API key if provided\n if (userAnswers.llmToken) {\n envContent += `OPENAI_API_KEY=${userAnswers.llmToken}\\n`;\n }\n\n // Add LangSmith API key for LangGraph\n if (userAnswers.mode === \"LangGraph\" && userAnswers.langSmithApiKey) {\n envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}\\n`;\n }\n\n if (envContent) {\n const agentEnvFile = path.join(agentDir, \".env\");\n fs.writeFileSync(agentEnvFile, envContent, \"utf8\");\n spinner.text = chalk.cyan(\"Added API keys to agent .env file\");\n }\n } catch (error) {\n spinner.fail(chalk.red(\"Failed to clone agent template\"));\n throw error;\n }\n\n spinner.succeed(`${userAnswers.mode} agent cloned successfully`);\n}\n\nexport const AgentTemplates = {\n LangGraph: {\n Starter: {\n Python:\n \"https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-py\",\n TypeScript:\n \"https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-js\",\n },\n },\n CrewAI: {\n Flows: {\n Starter:\n \"https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-crewai-flows/agent-py\",\n },\n },\n};\n","import { execSync } from \"child_process\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as os from \"os\";\nimport { Config } from \"../types/index.js\";\nimport chalk from \"chalk\";\nimport ora, { Ora } from \"ora\";\n\n/**\n * Clones a specific subdirectory from a GitHub repository\n *\n * @param githubUrl - The GitHub URL to the repository or subdirectory\n * @param destinationPath - The local path where the content should be copied\n * @param spinner - The spinner to update with progress information\n * @returns A boolean indicating success or failure\n */\nexport async function cloneGitHubSubdirectory(\n githubUrl: string,\n destinationPath: string,\n spinner: Ora,\n): Promise<boolean> {\n try {\n // Parse the GitHub URL to extract repo info\n const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);\n\n spinner.text = chalk.cyan(`Cloning from ${owner}/${repo}...`);\n\n // Method 1: Use sparse checkout (more efficient than full clone)\n return await sparseCheckout(\n owner,\n repo,\n branch,\n subdirectoryPath,\n destinationPath,\n spinner,\n );\n } catch (error) {\n spinner.text = chalk.red(`Failed to clone from GitHub: ${error}`);\n return false;\n }\n}\n\n/**\n * Uses Git sparse-checkout to efficiently download only the needed subdirectory\n */\nasync function sparseCheckout(\n owner: string,\n repo: string,\n branch: string,\n subdirectoryPath: string,\n destinationPath: string,\n spinner: Ora,\n): Promise<boolean> {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"copilotkit-sparse-\"));\n\n try {\n spinner.text = chalk.cyan(\"Creating temporary workspace...\");\n\n // Initialize git repo\n execSync(\"git init\", { cwd: tempDir, stdio: \"pipe\" });\n\n spinner.text = chalk.cyan(\"Connecting to repository...\");\n\n // Add remote\n execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Enable sparse checkout\n execSync(\"git config core.sparseCheckout true\", {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Specify which subdirectory to checkout\n fs.writeFileSync(\n path.join(tempDir, \".git/info/sparse-checkout\"),\n subdirectoryPath,\n );\n\n spinner.text = chalk.cyan(\"Downloading agent files...\");\n\n // Pull only the specified branch\n execSync(`git pull origin ${branch} --depth=1`, {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Copy the subdirectory to the destination\n const sourcePath = path.join(tempDir, subdirectoryPath);\n if (!fs.existsSync(sourcePath)) {\n throw new Error(\n `Subdirectory '${subdirectoryPath}' not found in the repository.`,\n );\n }\n\n // Ensure destination directory exists\n fs.mkdirSync(destinationPath, { recursive: true });\n\n spinner.text = chalk.cyan(\"Installing agent files...\");\n\n // Copy the subdirectory to the destination\n await copyDirectoryAsync(sourcePath, destinationPath);\n\n return true;\n } finally {\n // Clean up the temporary directory\n try {\n fs.rmSync(tempDir, { recursive: true, force: true });\n } catch (error) {\n console.warn(`Failed to clean up temporary directory: ${error}`);\n }\n }\n}\n\n/**\n * Recursively copies a directory with async pauses\n */\nasync function copyDirectoryAsync(\n source: string,\n destination: string,\n): Promise<void> {\n // Create destination directory if it doesn't exist\n if (!fs.existsSync(destination)) {\n fs.mkdirSync(destination, { recursive: true });\n }\n\n // Read all files/directories from source\n const entries = fs.readdirSync(source, { withFileTypes: true });\n\n for (const entry of entries) {\n const srcPath = path.join(source, entry.name);\n const destPath = path.join(destination, entry.name);\n\n if (entry.isDirectory()) {\n // Recursively copy subdirectories\n await copyDirectoryAsync(srcPath, destPath);\n } else {\n // Copy files\n fs.copyFileSync(srcPath, destPath);\n }\n\n // For large directories, add small pauses\n if (entries.length > 10) {\n await new Promise((resolve) => setTimeout(resolve, 1));\n }\n }\n}\n\n/**\n * Parses a GitHub URL to extract owner, repo, branch and subdirectory path\n */\nfunction parseGitHubUrl(githubUrl: string): {\n owner: string;\n repo: string;\n branch: string;\n subdirectoryPath: string;\n} {\n const url = new URL(githubUrl);\n\n if (url.hostname !== \"github.com\") {\n throw new Error(\"Only GitHub URLs are supported\");\n }\n\n const pathParts = url.pathname.split(\"/\").filter(Boolean);\n\n if (pathParts.length < 2) {\n throw new Error(\"Invalid GitHub URL format\");\n }\n\n const owner = pathParts[0];\n const repo = pathParts[1];\n let branch = \"main\"; // Default branch\n let subdirectoryPath = \"\";\n\n if (\n pathParts.length > 3 &&\n (pathParts[2] === \"tree\" || pathParts[2] === \"blob\")\n ) {\n branch = pathParts[3];\n subdirectoryPath = pathParts.slice(4).join(\"/\");\n }\n\n return { owner, repo, branch, subdirectoryPath };\n}\n\n/**\n * Validates if a string is a valid GitHub URL\n */\nexport function isValidGitHubUrl(url: string): boolean {\n try {\n const parsedUrl = new URL(url);\n return (\n parsedUrl.hostname === \"github.com\" &&\n parsedUrl.pathname.split(\"/\").filter(Boolean).length >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AqB,YAAY,eAAe;AAAA;AAAA,IAChE;AAEA,QAAI,YAAY;AACd,YAAM,eAAeF,MAAK,KAAK,UAAU,MAAM;AAC/C,MAAAC,IAAG,cAAc,cAAc,YAAY,MAAM;AACjD,cAAQ,OAAOC,OAAM,KAAK,mCAAmC;AAAA,IAC/D;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,KAAKA,OAAM,IAAI,gCAAgC,CAAC;AACxD,UAAM;AAAA,EACR;AAEA,UAAQ,QAAQ,GAAG,YAAY,IAAI,4BAA4B;AACjE;AAEO,IAAM,iBAAiB;AAAA,EAC5B,WAAW;AAAA,IACT,SAAS;AAAA,MACP,QACE;AAAA,MACF,YACE;AAAA,IACJ;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,MACL,SACE;AAAA,IACJ;AAAA,EACF;AACF;","names":["chalk","path","fs","chalk"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/lib/init/scaffold/crew-inputs.ts
|
|
2
|
-
import * as fs from "fs/promises";
|
|
3
|
-
import ora from "ora";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
async function addCrewInputs(url, token) {
|
|
6
|
-
try {
|
|
7
|
-
const spinner = ora("Analyzing crew inputs...").start();
|
|
8
|
-
const inputs = await getCrewInputs(url, token);
|
|
9
|
-
spinner.text = "Adding inputs to app/copilotkit/page.tsx...";
|
|
10
|
-
let filePath = path.join(process.cwd(), "app", "copilotkit", "page.tsx");
|
|
11
|
-
try {
|
|
12
|
-
await fs.access(filePath);
|
|
13
|
-
} catch {
|
|
14
|
-
filePath = path.join(
|
|
15
|
-
process.cwd(),
|
|
16
|
-
"src",
|
|
17
|
-
"app",
|
|
18
|
-
"copilotkit",
|
|
19
|
-
"page.tsx"
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
await fs.access(filePath);
|
|
24
|
-
} catch {
|
|
25
|
-
throw new Error(
|
|
26
|
-
"app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
let fileContent = await fs.readFile(filePath, "utf8");
|
|
30
|
-
const inputsString = JSON.stringify(inputs);
|
|
31
|
-
fileContent = fileContent.replace(
|
|
32
|
-
/\[["']YOUR_INPUTS_HERE["']\]/g,
|
|
33
|
-
inputsString
|
|
34
|
-
);
|
|
35
|
-
await fs.writeFile(filePath, fileContent, "utf8");
|
|
36
|
-
spinner.succeed(
|
|
37
|
-
"Successfully added crew inputs to app/copilotkit/page.tsx"
|
|
38
|
-
);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error("Error updating crew inputs:", error);
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function getCrewInputs(url, token) {
|
|
45
|
-
const response = await fetch(`${url.trim()}/inputs`, {
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: `Bearer ${token}`
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`Failed to fetch inputs: ${response.statusText}`);
|
|
52
|
-
}
|
|
53
|
-
const data = await response.json();
|
|
54
|
-
return data.inputs;
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
addCrewInputs
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=crew-inputs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/init/scaffold/crew-inputs.ts"],"sourcesContent":["import * as fs from \"fs/promises\";\nimport ora from \"ora\";\nimport * as path from \"path\";\n\nexport async function addCrewInputs(url: string, token: string) {\n try {\n const spinner = ora(\"Analyzing crew inputs...\").start();\n // Get inputs from the crew API\n const inputs = await getCrewInputs(url, token);\n spinner.text = \"Adding inputs to app/copilotkit/page.tsx...\";\n\n // Path to the file we need to modify\n let filePath = path.join(process.cwd(), \"app\", \"copilotkit\", \"page.tsx\");\n\n // check if non-src file exists\n try {\n await fs.access(filePath);\n } catch {\n filePath = path.join(\n process.cwd(),\n \"src\",\n \"app\",\n \"copilotkit\",\n \"page.tsx\",\n );\n }\n\n // check if src file exists\n try {\n await fs.access(filePath);\n } catch {\n throw new Error(\n \"app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found\",\n );\n }\n\n // Read the file content\n let fileContent = await fs.readFile(filePath, \"utf8\");\n\n // Replace all instances of \"YOUR_INPUTS_HERE\" with the inputs array as a string\n const inputsString = JSON.stringify(inputs);\n fileContent = fileContent.replace(\n /\\[[\"']YOUR_INPUTS_HERE[\"']\\]/g,\n inputsString,\n );\n\n // Write the updated content back to the file\n await fs.writeFile(filePath, fileContent, \"utf8\");\n\n spinner.succeed(\n \"Successfully added crew inputs to app/copilotkit/page.tsx\",\n );\n } catch (error) {\n console.error(\"Error updating crew inputs:\", error);\n throw error;\n }\n}\n\nasync function getCrewInputs(url: string, token: string): Promise<string[]> {\n const response = await fetch(`${url.trim()}/inputs`, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch inputs: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { inputs: string[] };\n return data.inputs;\n}\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,OAAO,SAAS;AAChB,YAAY,UAAU;AAEtB,eAAsB,cAAc,KAAa,OAAe;AAC9D,MAAI;AACF,UAAM,UAAU,IAAI,0BAA0B,EAAE,MAAM;AAEtD,UAAM,SAAS,MAAM,cAAc,KAAK,KAAK;AAC7C,YAAQ,OAAO;AAGf,QAAI,WAAgB,UAAK,QAAQ,IAAI,GAAG,OAAO,cAAc,UAAU;AAGvE,QAAI;AACF,YAAS,UAAO,QAAQ;AAAA,IAC1B,QAAQ;AACN,iBAAgB;AAAA,QACd,QAAQ,IAAI;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,QAAI;AACF,YAAS,UAAO,QAAQ;AAAA,IAC1B,QAAQ;AACN,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAGA,QAAI,cAAc,MAAS,YAAS,UAAU,MAAM;AAGpD,UAAM,eAAe,KAAK,UAAU,MAAM;AAC1C,kBAAc,YAAY;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AAGA,UAAS,aAAU,UAAU,aAAa,MAAM;AAEhD,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,+BAA+B,KAAK;AAClD,UAAM;AAAA,EACR;AACF;AAEA,eAAe,cAAc,KAAa,OAAkC;AAC1E,QAAM,WAAW,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,WAAW;AAAA,IACnD,SAAS;AAAA,MACP,eAAe,UAAU,KAAK;AAAA,IAChC;AAAA,EACF,CAAC;AAED,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI,MAAM,2BAA2B,SAAS,UAAU,EAAE;AAAA,EAClE;AAEA,QAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,SAAO,KAAK;AACd;","names":[]}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// src/lib/init/scaffold/env.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
|
|
5
|
-
// src/lib/init/scaffold/langgraph-assistants.ts
|
|
6
|
-
async function getLangGraphAgents(url, langSmithApiKey) {
|
|
7
|
-
try {
|
|
8
|
-
const response = await fetch(
|
|
9
|
-
`${url.trim().replace(/\/$/, "")}/assistants/search`,
|
|
10
|
-
{
|
|
11
|
-
method: "POST",
|
|
12
|
-
headers: {
|
|
13
|
-
"Content-Type": "application/json",
|
|
14
|
-
"X-Api-Key": langSmithApiKey
|
|
15
|
-
},
|
|
16
|
-
body: JSON.stringify({
|
|
17
|
-
limit: 10,
|
|
18
|
-
offset: 0
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
return await response.json();
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw new Error(`Failed to get LangGraph agents: ${error}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/lib/init/scaffold/env.ts
|
|
29
|
-
import inquirer from "inquirer";
|
|
30
|
-
|
|
31
|
-
// src/lib/init/utils.ts
|
|
32
|
-
var isLocalhost = (url) => {
|
|
33
|
-
return url.includes("localhost") || url.includes("127.0.0.1") || url.includes("0.0.0.0");
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/lib/init/scaffold/env.ts
|
|
37
|
-
function needsCloudDeployment(userAnswers) {
|
|
38
|
-
return userAnswers.deploymentChoice === "Copilot Cloud" || // Branch B choice
|
|
39
|
-
userAnswers.useCopilotCloud === "Yes" || // Branch C choice
|
|
40
|
-
userAnswers.mode === "CrewAI" || // CrewAI always needs cloud
|
|
41
|
-
!userAnswers.deploymentChoice && !userAnswers.useCopilotCloud;
|
|
42
|
-
}
|
|
43
|
-
async function scaffoldEnv(flags, userAnswers) {
|
|
44
|
-
try {
|
|
45
|
-
const envFile = path.join(process.cwd(), ".env");
|
|
46
|
-
if (!fs.existsSync(envFile)) {
|
|
47
|
-
fs.writeFileSync(envFile, "", "utf8");
|
|
48
|
-
} else {
|
|
49
|
-
}
|
|
50
|
-
let newEnvValues = "";
|
|
51
|
-
const isCloudDeployment = needsCloudDeployment(userAnswers);
|
|
52
|
-
if (userAnswers.copilotCloudPublicApiKey) {
|
|
53
|
-
newEnvValues += `NEXT_PUBLIC_COPILOT_API_KEY=${userAnswers.copilotCloudPublicApiKey}
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
if (userAnswers.langSmithApiKey) {
|
|
57
|
-
newEnvValues += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
if (userAnswers.llmToken) {
|
|
61
|
-
newEnvValues += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
if (userAnswers.crewName) {
|
|
65
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${userAnswers.crewName}
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
if (userAnswers.langGraphAgent) {
|
|
69
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
|
|
70
|
-
`;
|
|
71
|
-
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123
|
|
72
|
-
`;
|
|
73
|
-
} else if (userAnswers.langGraphPlatform === "Yes" && !isCloudDeployment) {
|
|
74
|
-
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}
|
|
75
|
-
`;
|
|
76
|
-
} else if (userAnswers.langGraphRemoteEndpointURL) {
|
|
77
|
-
newEnvValues += `COPILOTKIT_REMOTE_ENDPOINT=${userAnswers.langGraphRemoteEndpointURL}
|
|
78
|
-
`;
|
|
79
|
-
}
|
|
80
|
-
if (flags.runtimeUrl) {
|
|
81
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=${flags.runtimeUrl}
|
|
82
|
-
`;
|
|
83
|
-
} else if (!isCloudDeployment && userAnswers.crewType !== "Crews" && userAnswers.crewType !== "Flows") {
|
|
84
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit
|
|
85
|
-
`;
|
|
86
|
-
}
|
|
87
|
-
if (userAnswers.langGraphPlatformUrl && (userAnswers.langSmithApiKey || isLocalhost(userAnswers.langGraphPlatformUrl))) {
|
|
88
|
-
const langGraphAgents = await getLangGraphAgents(
|
|
89
|
-
userAnswers.langGraphPlatformUrl,
|
|
90
|
-
userAnswers.langSmithApiKey || ""
|
|
91
|
-
);
|
|
92
|
-
let langGraphAgent = "";
|
|
93
|
-
if (langGraphAgents.length > 1) {
|
|
94
|
-
const { langGraphAgentChoice } = await inquirer.prompt([
|
|
95
|
-
{
|
|
96
|
-
type: "list",
|
|
97
|
-
name: "langGraphAgentChoice",
|
|
98
|
-
message: "\u{1F99C}\u{1F517} Which agent from your graph would you like to use?",
|
|
99
|
-
choices: langGraphAgents.map((agent) => ({
|
|
100
|
-
name: agent.graph_id,
|
|
101
|
-
value: agent.graph_id
|
|
102
|
-
}))
|
|
103
|
-
}
|
|
104
|
-
]);
|
|
105
|
-
langGraphAgent = langGraphAgentChoice;
|
|
106
|
-
} else if (langGraphAgents.length === 1) {
|
|
107
|
-
langGraphAgent = langGraphAgents[0].graph_id;
|
|
108
|
-
} else {
|
|
109
|
-
throw new Error("No agents found in your LangGraph endpoint");
|
|
110
|
-
}
|
|
111
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${langGraphAgent}
|
|
112
|
-
`;
|
|
113
|
-
}
|
|
114
|
-
if (newEnvValues) {
|
|
115
|
-
fs.appendFileSync(envFile, newEnvValues);
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
scaffoldEnv
|
|
123
|
-
};
|
|
124
|
-
//# sourceMappingURL=env.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/init/scaffold/env.ts","../../../../src/lib/init/scaffold/langgraph-assistants.ts","../../../../src/lib/init/utils.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { Config } from \"../types/index.js\";\nimport { getLangGraphAgents } from \"./langgraph-assistants.js\";\nimport inquirer from \"inquirer\";\nimport { isLocalhost } from \"../utils.js\";\n\n/**\n * Determines if cloud deployment is needed based on user answers\n * Uses the same logic as the main init flow to ensure consistency\n */\nfunction needsCloudDeployment(userAnswers: Config): boolean {\n return (\n userAnswers.deploymentChoice === \"Copilot Cloud\" || // Branch B choice\n userAnswers.useCopilotCloud === \"Yes\" || // Branch C choice\n userAnswers.mode === \"CrewAI\" || // CrewAI always needs cloud\n (!userAnswers.deploymentChoice && !userAnswers.useCopilotCloud) // Branch A default (no questions = cloud)\n );\n}\n\nexport async function scaffoldEnv(flags: any, userAnswers: Config) {\n try {\n // Define the env file path\n const envFile = path.join(process.cwd(), \".env\");\n\n // Create the env file if it doesn't exist\n if (!fs.existsSync(envFile)) {\n fs.writeFileSync(envFile, \"\", \"utf8\");\n } else {\n }\n\n // Build environment variables based on user selections\n let newEnvValues = \"\";\n\n // Check if cloud deployment is needed\n const isCloudDeployment = needsCloudDeployment(userAnswers);\n\n // Copilot Cloud API key\n if (userAnswers.copilotCloudPublicApiKey) {\n newEnvValues += `NEXT_PUBLIC_COPILOT_API_KEY=${userAnswers.copilotCloudPublicApiKey}\\n`;\n }\n\n // LangSmith API key (for LangGraph)\n if (userAnswers.langSmithApiKey) {\n // Add both formats for compatibility\n newEnvValues += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}\\n`;\n }\n\n // LLM API key - set as both LLM_TOKEN and OPENAI_API_KEY for compatibility\n if (userAnswers.llmToken) {\n newEnvValues += `OPENAI_API_KEY=${userAnswers.llmToken}\\n`;\n }\n\n // CrewAI name\n if (userAnswers.crewName) {\n newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${userAnswers.crewName}\\n`;\n }\n\n if (userAnswers.langGraphAgent) {\n newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent\\n`;\n newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123\\n`;\n } else if (userAnswers.langGraphPlatform === \"Yes\" && !isCloudDeployment) {\n newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}\\n`;\n } else if (userAnswers.langGraphRemoteEndpointURL) {\n newEnvValues += `COPILOTKIT_REMOTE_ENDPOINT=${userAnswers.langGraphRemoteEndpointURL}\\n`;\n }\n\n // Runtime URL if provided via flags\n if (flags.runtimeUrl) {\n newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=${flags.runtimeUrl}\\n`;\n } else if (\n !isCloudDeployment &&\n userAnswers.crewType !== \"Crews\" &&\n userAnswers.crewType !== \"Flows\"\n ) {\n newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit\\n`;\n }\n\n if (\n userAnswers.langGraphPlatformUrl &&\n (userAnswers.langSmithApiKey ||\n isLocalhost(userAnswers.langGraphPlatformUrl))\n ) {\n const langGraphAgents = await getLangGraphAgents(\n userAnswers.langGraphPlatformUrl,\n userAnswers.langSmithApiKey || \"\",\n );\n let langGraphAgent = \"\";\n if (langGraphAgents.length > 1) {\n const { langGraphAgentChoice } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"langGraphAgentChoice\",\n message: \"🦜🔗 Which agent from your graph would you like to use?\",\n choices: langGraphAgents.map((agent: any) => ({\n name: agent.graph_id,\n value: agent.graph_id,\n })),\n },\n ]);\n langGraphAgent = langGraphAgentChoice;\n } else if (langGraphAgents.length === 1) {\n langGraphAgent = langGraphAgents[0].graph_id;\n } else {\n throw new Error(\"No agents found in your LangGraph endpoint\");\n }\n\n newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${langGraphAgent}\\n`;\n }\n\n // Append the variables to the .env file\n if (newEnvValues) {\n fs.appendFileSync(envFile, newEnvValues);\n }\n } catch (error) {\n throw error;\n }\n}\n","export type LangGraphAgent = {\n assistant_id: string;\n graph_id: string;\n config: {\n tags: string[];\n recursion_limit: number;\n configurable: Record<string, any>;\n };\n created_at: string;\n updated_at: string;\n metadata: Record<string, any>;\n version: number;\n name: string;\n description: string;\n};\n\nexport async function getLangGraphAgents(url: string, langSmithApiKey: string) {\n try {\n const response = await fetch(\n `${url.trim().replace(/\\/$/, \"\")}/assistants/search`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-Api-Key\": langSmithApiKey,\n },\n body: JSON.stringify({\n limit: 10,\n offset: 0,\n }),\n },\n );\n\n return (await response.json()) as LangGraphAgent[];\n } catch (error) {\n throw new Error(`Failed to get LangGraph agents: ${error}`);\n }\n}\n","export const isLocalhost = (url: string): boolean => {\n return (\n url.includes(\"localhost\") ||\n url.includes(\"127.0.0.1\") ||\n url.includes(\"0.0.0.0\")\n );\n};\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;;;ACef,eAAsB,mBAAmB,KAAa,iBAAyB;AAC7E,MAAI;AACF,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,IAAI,KAAK,EAAE,QAAQ,OAAO,EAAE,CAAC;AAAA,MAChC;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,aAAa;AAAA,QACf;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,OAAO;AAAA,UACP,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAAA,IACF;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAC9B,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,mCAAmC,KAAK,EAAE;AAAA,EAC5D;AACF;;;ADjCA,OAAO,cAAc;;;AEJd,IAAM,cAAc,CAAC,QAAyB;AACnD,SACE,IAAI,SAAS,WAAW,KACxB,IAAI,SAAS,WAAW,KACxB,IAAI,SAAS,SAAS;AAE1B;;;AFKA,SAAS,qBAAqB,aAA8B;AAC1D,SACE,YAAY,qBAAqB;AAAA,EACjC,YAAY,oBAAoB;AAAA,EAChC,YAAY,SAAS;AAAA,EACpB,CAAC,YAAY,oBAAoB,CAAC,YAAY;AAEnD;AAEA,eAAsB,YAAY,OAAY,aAAqB;AACjE,MAAI;AAEF,UAAM,UAAU,KAAK,KAAK,QAAQ,IAAI,GAAG,MAAM;AAG/C,QAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AAC3B,SAAG,cAAc,SAAS,IAAI,MAAM;AAAA,IACtC,OAAO;AAAA,IACP;AAGA,QAAI,eAAe;AAGnB,UAAM,oBAAoB,qBAA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AgB,WAAW,GAAG;AACvC,yBAAiB,gBAAgB,CAAC,EAAE;AAAA,MACtC,OAAO;AACL,cAAM,IAAI,MAAM,4CAA4C;AAAA,MAC9D;AAEA,sBAAgB,qCAAqC,cAAc;AAAA;AAAA,IACrE;AAGA,QAAI,cAAc;AAChB,SAAG,eAAe,SAAS,YAAY;AAAA,IACzC;AAAA,EACF,SAAS,OAAO;AACd,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Ora } from 'ora';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Clones a specific subdirectory from a GitHub repository
|
|
5
|
-
*
|
|
6
|
-
* @param githubUrl - The GitHub URL to the repository or subdirectory
|
|
7
|
-
* @param destinationPath - The local path where the content should be copied
|
|
8
|
-
* @param spinner - The spinner to update with progress information
|
|
9
|
-
* @returns A boolean indicating success or failure
|
|
10
|
-
*/
|
|
11
|
-
declare function cloneGitHubSubdirectory(githubUrl: string, destinationPath: string, spinner: Ora): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Validates if a string is a valid GitHub URL
|
|
14
|
-
*/
|
|
15
|
-
declare function isValidGitHubUrl(url: string): boolean;
|
|
16
|
-
|
|
17
|
-
export { cloneGitHubSubdirectory, isValidGitHubUrl };
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// src/lib/init/scaffold/github.ts
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import * as os from "os";
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
8
|
-
try {
|
|
9
|
-
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
10
|
-
spinner.text = chalk.cyan(`Cloning from ${owner}/${repo}...`);
|
|
11
|
-
return await sparseCheckout(
|
|
12
|
-
owner,
|
|
13
|
-
repo,
|
|
14
|
-
branch,
|
|
15
|
-
subdirectoryPath,
|
|
16
|
-
destinationPath,
|
|
17
|
-
spinner
|
|
18
|
-
);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
spinner.text = chalk.red(`Failed to clone from GitHub: ${error}`);
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
25
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
26
|
-
try {
|
|
27
|
-
spinner.text = chalk.cyan("Creating temporary workspace...");
|
|
28
|
-
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
29
|
-
spinner.text = chalk.cyan("Connecting to repository...");
|
|
30
|
-
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
|
|
31
|
-
cwd: tempDir,
|
|
32
|
-
stdio: "pipe"
|
|
33
|
-
});
|
|
34
|
-
execSync("git config core.sparseCheckout true", {
|
|
35
|
-
cwd: tempDir,
|
|
36
|
-
stdio: "pipe"
|
|
37
|
-
});
|
|
38
|
-
fs.writeFileSync(
|
|
39
|
-
path.join(tempDir, ".git/info/sparse-checkout"),
|
|
40
|
-
subdirectoryPath
|
|
41
|
-
);
|
|
42
|
-
spinner.text = chalk.cyan("Downloading agent files...");
|
|
43
|
-
execSync(`git pull origin ${branch} --depth=1`, {
|
|
44
|
-
cwd: tempDir,
|
|
45
|
-
stdio: "pipe"
|
|
46
|
-
});
|
|
47
|
-
const sourcePath = path.join(tempDir, subdirectoryPath);
|
|
48
|
-
if (!fs.existsSync(sourcePath)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`Subdirectory '${subdirectoryPath}' not found in the repository.`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
fs.mkdirSync(destinationPath, { recursive: true });
|
|
54
|
-
spinner.text = chalk.cyan("Installing agent files...");
|
|
55
|
-
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
56
|
-
return true;
|
|
57
|
-
} finally {
|
|
58
|
-
try {
|
|
59
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.warn(`Failed to clean up temporary directory: ${error}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async function copyDirectoryAsync(source, destination) {
|
|
66
|
-
if (!fs.existsSync(destination)) {
|
|
67
|
-
fs.mkdirSync(destination, { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
const entries = fs.readdirSync(source, { withFileTypes: true });
|
|
70
|
-
for (const entry of entries) {
|
|
71
|
-
const srcPath = path.join(source, entry.name);
|
|
72
|
-
const destPath = path.join(destination, entry.name);
|
|
73
|
-
if (entry.isDirectory()) {
|
|
74
|
-
await copyDirectoryAsync(srcPath, destPath);
|
|
75
|
-
} else {
|
|
76
|
-
fs.copyFileSync(srcPath, destPath);
|
|
77
|
-
}
|
|
78
|
-
if (entries.length > 10) {
|
|
79
|
-
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function parseGitHubUrl(githubUrl) {
|
|
84
|
-
const url = new URL(githubUrl);
|
|
85
|
-
if (url.hostname !== "github.com") {
|
|
86
|
-
throw new Error("Only GitHub URLs are supported");
|
|
87
|
-
}
|
|
88
|
-
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
89
|
-
if (pathParts.length < 2) {
|
|
90
|
-
throw new Error("Invalid GitHub URL format");
|
|
91
|
-
}
|
|
92
|
-
const owner = pathParts[0];
|
|
93
|
-
const repo = pathParts[1];
|
|
94
|
-
let branch = "main";
|
|
95
|
-
let subdirectoryPath = "";
|
|
96
|
-
if (pathParts.length > 3 && (pathParts[2] === "tree" || pathParts[2] === "blob")) {
|
|
97
|
-
branch = pathParts[3];
|
|
98
|
-
subdirectoryPath = pathParts.slice(4).join("/");
|
|
99
|
-
}
|
|
100
|
-
return { owner, repo, branch, subdirectoryPath };
|
|
101
|
-
}
|
|
102
|
-
function isValidGitHubUrl(url) {
|
|
103
|
-
try {
|
|
104
|
-
const parsedUrl = new URL(url);
|
|
105
|
-
return parsedUrl.hostname === "github.com" && parsedUrl.pathname.split("/").filter(Boolean).length >= 2;
|
|
106
|
-
} catch {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
cloneGitHubSubdirectory,
|
|
112
|
-
isValidGitHubUrl
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=github.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/init/scaffold/github.ts"],"sourcesContent":["import { execSync } from \"child_process\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as os from \"os\";\nimport { Config } from \"../types/index.js\";\nimport chalk from \"chalk\";\nimport ora, { Ora } from \"ora\";\n\n/**\n * Clones a specific subdirectory from a GitHub repository\n *\n * @param githubUrl - The GitHub URL to the repository or subdirectory\n * @param destinationPath - The local path where the content should be copied\n * @param spinner - The spinner to update with progress information\n * @returns A boolean indicating success or failure\n */\nexport async function cloneGitHubSubdirectory(\n githubUrl: string,\n destinationPath: string,\n spinner: Ora,\n): Promise<boolean> {\n try {\n // Parse the GitHub URL to extract repo info\n const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);\n\n spinner.text = chalk.cyan(`Cloning from ${owner}/${repo}...`);\n\n // Method 1: Use sparse checkout (more efficient than full clone)\n return await sparseCheckout(\n owner,\n repo,\n branch,\n subdirectoryPath,\n destinationPath,\n spinner,\n );\n } catch (error) {\n spinner.text = chalk.red(`Failed to clone from GitHub: ${error}`);\n return false;\n }\n}\n\n/**\n * Uses Git sparse-checkout to efficiently download only the needed subdirectory\n */\nasync function sparseCheckout(\n owner: string,\n repo: string,\n branch: string,\n subdirectoryPath: string,\n destinationPath: string,\n spinner: Ora,\n): Promise<boolean> {\n const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"copilotkit-sparse-\"));\n\n try {\n spinner.text = chalk.cyan(\"Creating temporary workspace...\");\n\n // Initialize git repo\n execSync(\"git init\", { cwd: tempDir, stdio: \"pipe\" });\n\n spinner.text = chalk.cyan(\"Connecting to repository...\");\n\n // Add remote\n execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Enable sparse checkout\n execSync(\"git config core.sparseCheckout true\", {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Specify which subdirectory to checkout\n fs.writeFileSync(\n path.join(tempDir, \".git/info/sparse-checkout\"),\n subdirectoryPath,\n );\n\n spinner.text = chalk.cyan(\"Downloading agent files...\");\n\n // Pull only the specified branch\n execSync(`git pull origin ${branch} --depth=1`, {\n cwd: tempDir,\n stdio: \"pipe\",\n });\n\n // Copy the subdirectory to the destination\n const sourcePath = path.join(tempDir, subdirectoryPath);\n if (!fs.existsSync(sourcePath)) {\n throw new Error(\n `Subdirectory '${subdirectoryPath}' not found in the repository.`,\n );\n }\n\n // Ensure destination directory exists\n fs.mkdirSync(destinationPath, { recursive: true });\n\n spinner.text = chalk.cyan(\"Installing agent files...\");\n\n // Copy the subdirectory to the destination\n await copyDirectoryAsync(sourcePath, destinationPath);\n\n return true;\n } finally {\n // Clean up the temporary directory\n try {\n fs.rmSync(tempDir, { recursive: true, force: true });\n } catch (error) {\n console.warn(`Failed to clean up temporary directory: ${error}`);\n }\n }\n}\n\n/**\n * Recursively copies a directory with async pauses\n */\nasync function copyDirectoryAsync(\n source: string,\n destination: string,\n): Promise<void> {\n // Create destination directory if it doesn't exist\n if (!fs.existsSync(destination)) {\n fs.mkdirSync(destination, { recursive: true });\n }\n\n // Read all files/directories from source\n const entries = fs.readdirSync(source, { withFileTypes: true });\n\n for (const entry of entries) {\n const srcPath = path.join(source, entry.name);\n const destPath = path.join(destination, entry.name);\n\n if (entry.isDirectory()) {\n // Recursively copy subdirectories\n await copyDirectoryAsync(srcPath, destPath);\n } else {\n // Copy files\n fs.copyFileSync(srcPath, destPath);\n }\n\n // For large directories, add small pauses\n if (entries.length > 10) {\n await new Promise((resolve) => setTimeout(resolve, 1));\n }\n }\n}\n\n/**\n * Parses a GitHub URL to extract owner, repo, branch and subdirectory path\n */\nfunction parseGitHubUrl(githubUrl: string): {\n owner: string;\n repo: string;\n branch: string;\n subdirectoryPath: string;\n} {\n const url = new URL(githubUrl);\n\n if (url.hostname !== \"github.com\") {\n throw new Error(\"Only GitHub URLs are supported\");\n }\n\n const pathParts = url.pathname.split(\"/\").filter(Boolean);\n\n if (pathParts.length < 2) {\n throw new Error(\"Invalid GitHub URL format\");\n }\n\n const owner = pathParts[0];\n const repo = pathParts[1];\n let branch = \"main\"; // Default branch\n let subdirectoryPath = \"\";\n\n if (\n pathParts.length > 3 &&\n (pathParts[2] === \"tree\" || pathParts[2] === \"blob\")\n ) {\n branch = pathParts[3];\n subdirectoryPath = pathParts.slice(4).join(\"/\");\n }\n\n return { owner, repo, branch, subdirectoryPath };\n}\n\n/**\n * Validates if a string is a valid GitHub URL\n */\nexport function isValidGitHubUrl(url: string): boolean {\n try {\n const parsedUrl = new URL(url);\n return (\n parsedUrl.hostname === \"github.com\" &&\n parsedUrl.pathname.split(\"/\").filter(Boolean).length >= 2\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,QAAQ;AAEpB,OAAO,WAAW;AAWlB,eAAsB,wBACpB,WACA,iBACA,SACkB;AAClB,MAAI;AAEF,UAAM,EAAE,OAAO,MAAM,QAAQ,iBAAiB,IAAI,eAAe,SAAS;AAE1E,YAAQ,OAAO,MAAM,KAAK,gBAAgB,KAAK,IAAI,IAAI,KAAK;AAG5D,WAAO,MAAM;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;A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EAAE,UAAU;AAAA,EAE5D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { scaffoldShadCN } from './shadcn.js';
|
|
2
|
-
export { scaffoldEnv } from './env.js';
|
|
3
|
-
export { cloneGitHubSubdirectory, isValidGitHubUrl } from './github.js';
|
|
4
|
-
export { scaffoldPackages } from './packages.js';
|
|
5
|
-
export { AgentTemplates, scaffoldAgent } from './agent.js';
|
|
6
|
-
export { addCrewInputs } from './crew-inputs.js';
|
|
7
|
-
import '../types/questions.js';
|
|
8
|
-
import '@oclif/core/interfaces';
|
|
9
|
-
import 'zod';
|
|
10
|
-
import 'ora';
|