copilotkit 0.0.57 → 0.0.59
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/LICENSE +21 -0
- package/dist/commands/base-command.js +9 -6
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +234 -59
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dev.js +94 -35
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +0 -20
- package/dist/commands/init.js +243 -209
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +44 -20
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +44 -20
- package/dist/commands/logout.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/init/ide-docs.d.ts +1 -1
- package/dist/lib/init/ide-docs.js +19 -5
- package/dist/lib/init/ide-docs.js.map +1 -1
- package/dist/lib/init/index.js +171 -67
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.d.ts +1 -1
- package/dist/lib/init/questions.js +77 -18
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/agent.js +30 -23
- package/dist/lib/init/scaffold/agent.js.map +1 -1
- package/dist/lib/init/scaffold/crew-inputs.js +17 -4
- package/dist/lib/init/scaffold/crew-inputs.js.map +1 -1
- package/dist/lib/init/scaffold/env.js +14 -11
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/github.js +27 -6
- package/dist/lib/init/scaffold/github.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +152 -62
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/langgraph-assistants.js +14 -11
- package/dist/lib/init/scaffold/langgraph-assistants.js.map +1 -1
- package/dist/lib/init/scaffold/packages.js +3 -1
- package/dist/lib/init/scaffold/packages.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +88 -23
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.js +77 -18
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +19 -19
- package/dist/lib/init/types/questions.js +73 -17
- package/dist/lib/init/types/questions.js.map +1 -1
- package/dist/lib/init/types/templates.d.ts +2 -2
- package/dist/lib/init/types/templates.js +4 -1
- package/dist/lib/init/types/templates.js.map +1 -1
- package/dist/lib/init/utils.js.map +1 -1
- package/dist/services/analytics.service.d.ts +1 -1
- package/dist/services/analytics.service.js +4 -1
- package/dist/services/analytics.service.js.map +1 -1
- package/dist/services/auth.service.d.ts +1 -1
- package/dist/services/auth.service.js +35 -14
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/events.d.ts +33 -33
- package/dist/services/tunnel.service.js.map +1 -1
- package/dist/utils/detect-endpoint-type.utils.d.ts +1 -1
- package/dist/utils/detect-endpoint-type.utils.js +11 -4
- package/dist/utils/detect-endpoint-type.utils.js.map +1 -1
- package/dist/utils/trpc.js.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/oclif.manifest.json +6 -163
- package/package.json +8 -4
package/dist/commands/init.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
// src/commands/init.ts
|
|
2
|
-
import { Flags as Flags3 } from "@oclif/core";
|
|
3
|
-
|
|
4
1
|
// src/commands/base-command.ts
|
|
5
2
|
import { Command } from "@oclif/core";
|
|
6
3
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
7
4
|
|
|
8
5
|
// src/utils/version.ts
|
|
9
|
-
var LIB_VERSION = "0.0.
|
|
6
|
+
var LIB_VERSION = "0.0.59";
|
|
10
7
|
|
|
11
8
|
// src/utils/trpc.ts
|
|
12
9
|
import { createTRPCClient as trpcClient, httpBatchLink } from "@trpc/client";
|
|
@@ -47,11 +44,14 @@ var BaseCommand = class extends Command {
|
|
|
47
44
|
async run() {
|
|
48
45
|
}
|
|
49
46
|
async checkCLIVersion() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`);
|
|
49
|
+
const data = await response.json();
|
|
50
|
+
const cloudVersion = data.cliVersion;
|
|
51
|
+
if (!cloudVersion || cloudVersion === LIB_VERSION) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async gracefulError(message) {
|
|
@@ -63,40 +63,153 @@ var BaseCommand = class extends Command {
|
|
|
63
63
|
// src/commands/create.ts
|
|
64
64
|
import { Flags, Args } from "@oclif/core";
|
|
65
65
|
import inquirer from "inquirer";
|
|
66
|
-
import
|
|
67
|
-
import
|
|
68
|
-
import
|
|
66
|
+
import chalk3 from "chalk";
|
|
67
|
+
import fs2 from "fs-extra";
|
|
68
|
+
import path2 from "path";
|
|
69
69
|
import { promisify } from "util";
|
|
70
70
|
import { pipeline } from "stream";
|
|
71
71
|
import { createWriteStream } from "fs";
|
|
72
72
|
import { extract } from "tar";
|
|
73
73
|
import ora from "ora";
|
|
74
|
+
|
|
75
|
+
// src/lib/init/scaffold/github.ts
|
|
76
|
+
import { execSync } from "child_process";
|
|
77
|
+
import * as fs from "fs";
|
|
78
|
+
import * as path from "path";
|
|
79
|
+
import * as os from "os";
|
|
80
|
+
import chalk2 from "chalk";
|
|
81
|
+
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
82
|
+
try {
|
|
83
|
+
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
84
|
+
spinner.text = chalk2.cyan(`Cloning from ${owner}/${repo}...`);
|
|
85
|
+
return await sparseCheckout(
|
|
86
|
+
owner,
|
|
87
|
+
repo,
|
|
88
|
+
branch,
|
|
89
|
+
subdirectoryPath,
|
|
90
|
+
destinationPath,
|
|
91
|
+
spinner
|
|
92
|
+
);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
spinner.text = chalk2.red(`Failed to clone from GitHub: ${error}`);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
99
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
100
|
+
try {
|
|
101
|
+
spinner.text = chalk2.cyan("Creating temporary workspace...");
|
|
102
|
+
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
103
|
+
spinner.text = chalk2.cyan("Connecting to repository...");
|
|
104
|
+
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
|
|
105
|
+
cwd: tempDir,
|
|
106
|
+
stdio: "pipe"
|
|
107
|
+
});
|
|
108
|
+
execSync("git config core.sparseCheckout true", {
|
|
109
|
+
cwd: tempDir,
|
|
110
|
+
stdio: "pipe"
|
|
111
|
+
});
|
|
112
|
+
fs.writeFileSync(
|
|
113
|
+
path.join(tempDir, ".git/info/sparse-checkout"),
|
|
114
|
+
subdirectoryPath
|
|
115
|
+
);
|
|
116
|
+
spinner.text = chalk2.cyan("Downloading agent files...");
|
|
117
|
+
execSync(`git pull origin ${branch} --depth=1`, {
|
|
118
|
+
cwd: tempDir,
|
|
119
|
+
stdio: "pipe"
|
|
120
|
+
});
|
|
121
|
+
const sourcePath = path.join(tempDir, subdirectoryPath);
|
|
122
|
+
if (!fs.existsSync(sourcePath)) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`Subdirectory '${subdirectoryPath}' not found in the repository.`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
fs.mkdirSync(destinationPath, { recursive: true });
|
|
128
|
+
spinner.text = chalk2.cyan("Installing agent files...");
|
|
129
|
+
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
130
|
+
return true;
|
|
131
|
+
} finally {
|
|
132
|
+
try {
|
|
133
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.warn(`Failed to clean up temporary directory: ${error}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function copyDirectoryAsync(source, destination) {
|
|
140
|
+
if (!fs.existsSync(destination)) {
|
|
141
|
+
fs.mkdirSync(destination, { recursive: true });
|
|
142
|
+
}
|
|
143
|
+
const entries = fs.readdirSync(source, { withFileTypes: true });
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
const srcPath = path.join(source, entry.name);
|
|
146
|
+
const destPath = path.join(destination, entry.name);
|
|
147
|
+
if (entry.isDirectory()) {
|
|
148
|
+
await copyDirectoryAsync(srcPath, destPath);
|
|
149
|
+
} else {
|
|
150
|
+
fs.copyFileSync(srcPath, destPath);
|
|
151
|
+
}
|
|
152
|
+
if (entries.length > 10) {
|
|
153
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function parseGitHubUrl(githubUrl) {
|
|
158
|
+
const url = new URL(githubUrl);
|
|
159
|
+
if (url.hostname !== "github.com") {
|
|
160
|
+
throw new Error("Only GitHub URLs are supported");
|
|
161
|
+
}
|
|
162
|
+
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
163
|
+
if (pathParts.length < 2) {
|
|
164
|
+
throw new Error("Invalid GitHub URL format");
|
|
165
|
+
}
|
|
166
|
+
const owner = pathParts[0];
|
|
167
|
+
const repo = pathParts[1];
|
|
168
|
+
let branch = "main";
|
|
169
|
+
let subdirectoryPath = "";
|
|
170
|
+
if (pathParts.length > 3 && (pathParts[2] === "tree" || pathParts[2] === "blob")) {
|
|
171
|
+
branch = pathParts[3];
|
|
172
|
+
subdirectoryPath = pathParts.slice(4).join("/");
|
|
173
|
+
}
|
|
174
|
+
return { owner, repo, branch, subdirectoryPath };
|
|
175
|
+
}
|
|
176
|
+
function isValidGitHubUrl(url) {
|
|
177
|
+
try {
|
|
178
|
+
const parsedUrl = new URL(url);
|
|
179
|
+
return parsedUrl.hostname === "github.com" && parsedUrl.pathname.split("/").filter(Boolean).length >= 2;
|
|
180
|
+
} catch {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/commands/create.ts
|
|
74
186
|
var streamPipeline = promisify(pipeline);
|
|
75
187
|
var theme = {
|
|
76
|
-
primary:
|
|
77
|
-
secondary:
|
|
78
|
-
tertiary:
|
|
79
|
-
error:
|
|
80
|
-
command:
|
|
81
|
-
success:
|
|
82
|
-
warning:
|
|
83
|
-
divider:
|
|
188
|
+
primary: chalk3.magenta,
|
|
189
|
+
secondary: chalk3.gray,
|
|
190
|
+
tertiary: chalk3.gray,
|
|
191
|
+
error: chalk3.red,
|
|
192
|
+
command: chalk3.blue,
|
|
193
|
+
success: chalk3.green,
|
|
194
|
+
warning: chalk3.yellow,
|
|
195
|
+
divider: chalk3.gray("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),
|
|
84
196
|
bottomPadding: ""
|
|
85
197
|
};
|
|
86
198
|
var TEMPLATE_REPOS = {
|
|
87
|
-
"langgraph-py": "
|
|
88
|
-
"langgraph-js": "
|
|
89
|
-
mastra: "
|
|
90
|
-
flows: "
|
|
91
|
-
llamaindex: "
|
|
92
|
-
agno: "
|
|
93
|
-
"pydantic-ai": "
|
|
199
|
+
"langgraph-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-python",
|
|
200
|
+
"langgraph-js": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-js",
|
|
201
|
+
mastra: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/mastra",
|
|
202
|
+
flows: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/crewai-flows",
|
|
203
|
+
llamaindex: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/llamaindex",
|
|
204
|
+
agno: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/agno",
|
|
205
|
+
"pydantic-ai": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/pydantic-ai",
|
|
94
206
|
ag2: "ag2ai/ag2-copilotkit-starter",
|
|
95
|
-
adk: "
|
|
96
|
-
"aws-strands-py": "
|
|
97
|
-
a2a: "
|
|
98
|
-
"microsoft-agent-framework-dotnet": "
|
|
99
|
-
"microsoft-agent-framework-py": "
|
|
207
|
+
adk: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/adk",
|
|
208
|
+
"aws-strands-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/strands-python",
|
|
209
|
+
a2a: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/a2a-middleware",
|
|
210
|
+
"microsoft-agent-framework-dotnet": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/ms-agent-framework-dotnet",
|
|
211
|
+
"microsoft-agent-framework-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/ms-agent-framework-python",
|
|
212
|
+
"mcp-apps": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/mcp-apps"
|
|
100
213
|
};
|
|
101
214
|
var FRAMEWORK_DOCUMENTATION = {
|
|
102
215
|
"langgraph-py": "https://langchain-ai.github.io/langgraph/concepts/why-langgraph",
|
|
@@ -111,7 +224,8 @@ var FRAMEWORK_DOCUMENTATION = {
|
|
|
111
224
|
"aws-strands-py": "https://strandsagents.com/latest/documentation/docs/",
|
|
112
225
|
a2a: "https://a2a-protocol.org/latest/",
|
|
113
226
|
"microsoft-agent-framework-dotnet": "https://learn.microsoft.com/en-us/agent-framework/",
|
|
114
|
-
"microsoft-agent-framework-py": "https://learn.microsoft.com/en-us/agent-framework/"
|
|
227
|
+
"microsoft-agent-framework-py": "https://learn.microsoft.com/en-us/agent-framework/",
|
|
228
|
+
"mcp-apps": "https://modelcontextprotocol.github.io/ext-apps"
|
|
115
229
|
};
|
|
116
230
|
var FRAMEWORK_EMOJI = {
|
|
117
231
|
"langgraph-js": "\u{1F99C}",
|
|
@@ -126,7 +240,8 @@ var FRAMEWORK_EMOJI = {
|
|
|
126
240
|
a2a: "\u{1F916}",
|
|
127
241
|
"aws-strands-py": "\u{1F9EC}",
|
|
128
242
|
"microsoft-agent-framework-dotnet": "\u{1F7E6}",
|
|
129
|
-
"microsoft-agent-framework-py": "\u{1F7E6}"
|
|
243
|
+
"microsoft-agent-framework-py": "\u{1F7E6}",
|
|
244
|
+
"mcp-apps": "\u264D"
|
|
130
245
|
};
|
|
131
246
|
var KITE = `
|
|
132
247
|
\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
|
|
@@ -190,30 +305,42 @@ var Create = class _Create extends BaseCommand {
|
|
|
190
305
|
this.log(theme.primary(KITE));
|
|
191
306
|
this.log(theme.primary("~ Welcome to CopilotKit! ~\n"));
|
|
192
307
|
this.log(theme.divider);
|
|
193
|
-
if (
|
|
194
|
-
this.log(
|
|
308
|
+
if (!flags.name && !args.projectName && !flags.framework) {
|
|
309
|
+
this.log(
|
|
310
|
+
"\n" + theme.secondary("Just a few questions to get started!\n")
|
|
311
|
+
);
|
|
195
312
|
}
|
|
196
313
|
}
|
|
197
314
|
const projectNameInput = flags.name || args.projectName || await this.promptProjectName();
|
|
198
315
|
const projectName = projectNameInput.trim();
|
|
199
316
|
const usingCurrentDir = projectName === "." || projectName === "./";
|
|
200
317
|
const agentFramework = flags.framework || await this.promptAgentFramework();
|
|
201
|
-
const projectDir = usingCurrentDir ? process.cwd() :
|
|
318
|
+
const projectDir = usingCurrentDir ? process.cwd() : path2.resolve(process.cwd(), projectName);
|
|
202
319
|
if (usingCurrentDir) {
|
|
203
320
|
const allowedEntries = /* @__PURE__ */ new Set([".git", ".gitignore", ".DS_Store"]);
|
|
204
|
-
const existingEntries = await
|
|
205
|
-
const blockingEntries = existingEntries.filter(
|
|
321
|
+
const existingEntries = await fs2.readdir(projectDir);
|
|
322
|
+
const blockingEntries = existingEntries.filter(
|
|
323
|
+
(entry) => !allowedEntries.has(entry)
|
|
324
|
+
);
|
|
206
325
|
if (blockingEntries.length > 0) {
|
|
207
326
|
this.log(theme.error("\nCurrent directory is not empty."));
|
|
208
|
-
this.log(
|
|
327
|
+
this.log(
|
|
328
|
+
theme.secondary(
|
|
329
|
+
"\nPlease run create in an empty directory or specify a new project name."
|
|
330
|
+
)
|
|
331
|
+
);
|
|
209
332
|
this.exit(1);
|
|
210
333
|
}
|
|
211
|
-
} else if (await
|
|
334
|
+
} else if (await fs2.pathExists(projectDir)) {
|
|
212
335
|
this.log(theme.error(`
|
|
213
336
|
Directory "${projectName}" already exists.`));
|
|
214
337
|
this.log(theme.secondary("\nYou can:"));
|
|
215
338
|
this.log(theme.secondary(" 1. Choose a different project name"));
|
|
216
|
-
this.log(
|
|
339
|
+
this.log(
|
|
340
|
+
theme.secondary(
|
|
341
|
+
" 2. Remove the existing directory manually if you want to use this name\n"
|
|
342
|
+
)
|
|
343
|
+
);
|
|
217
344
|
this.exit(1);
|
|
218
345
|
}
|
|
219
346
|
const options = {
|
|
@@ -226,11 +353,13 @@ Directory "${projectName}" already exists.`));
|
|
|
226
353
|
spinner: "dots"
|
|
227
354
|
}).start();
|
|
228
355
|
try {
|
|
229
|
-
await
|
|
356
|
+
await fs2.ensureDir(projectDir);
|
|
230
357
|
spinner.text = theme.secondary.bold("Downloading template...");
|
|
231
|
-
await this.downloadTemplate(projectDir, options.agentFramework);
|
|
358
|
+
await this.downloadTemplate(projectDir, options.agentFramework, spinner);
|
|
232
359
|
const displayName = usingCurrentDir ? "current directory" : `"${projectName}"`;
|
|
233
|
-
spinner.succeed(
|
|
360
|
+
spinner.succeed(
|
|
361
|
+
theme.secondary.bold(`Project ${displayName} created successfully!`)
|
|
362
|
+
);
|
|
234
363
|
} catch (error) {
|
|
235
364
|
spinner.fail(theme.error(`Failed to create project: ${error.message}`));
|
|
236
365
|
this.exit(1);
|
|
@@ -245,14 +374,24 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
245
374
|
);
|
|
246
375
|
this.log("\n" + theme.secondary("Next steps:"));
|
|
247
376
|
if (usingCurrentDir) {
|
|
248
|
-
this.log(
|
|
377
|
+
this.log(
|
|
378
|
+
theme.secondary(
|
|
379
|
+
" \u2022 You are already inside your new project directory"
|
|
380
|
+
)
|
|
381
|
+
);
|
|
249
382
|
} else {
|
|
250
383
|
this.log(theme.secondary(` \u2022 ${theme.command(`cd ${projectName}`)}`));
|
|
251
384
|
}
|
|
252
|
-
this.log(
|
|
385
|
+
this.log(
|
|
386
|
+
theme.secondary(" \u2022 Follow the setup instructions in the README.md")
|
|
387
|
+
);
|
|
253
388
|
this.log("\n" + theme.secondary("Documentation:"));
|
|
254
|
-
this.log(
|
|
255
|
-
|
|
389
|
+
this.log(
|
|
390
|
+
theme.secondary(" \u2022 ") + theme.command("https://docs.copilotkit.ai")
|
|
391
|
+
);
|
|
392
|
+
this.log(
|
|
393
|
+
theme.secondary(" \u2022 ") + theme.command(FRAMEWORK_DOCUMENTATION[options.agentFramework])
|
|
394
|
+
);
|
|
256
395
|
this.log(theme.bottomPadding);
|
|
257
396
|
}
|
|
258
397
|
async promptProjectName() {
|
|
@@ -264,7 +403,9 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
264
403
|
validate: (input) => {
|
|
265
404
|
if (!input) return theme.error("Project name is required");
|
|
266
405
|
if (!/^[a-z0-9-]+$/.test(input)) {
|
|
267
|
-
return theme.error(
|
|
406
|
+
return theme.error(
|
|
407
|
+
"Project name can only contain lowercase letters, numbers, and hyphens"
|
|
408
|
+
);
|
|
268
409
|
}
|
|
269
410
|
if (input.length > 30) {
|
|
270
411
|
return theme.error("Project name must be less than 30 characters");
|
|
@@ -280,13 +421,27 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
280
421
|
{
|
|
281
422
|
type: "list",
|
|
282
423
|
name: "framework",
|
|
283
|
-
message: theme.secondary(
|
|
424
|
+
message: theme.secondary(
|
|
425
|
+
"Which agent framework would you like to use?"
|
|
426
|
+
),
|
|
284
427
|
choices: [
|
|
285
|
-
{
|
|
286
|
-
|
|
428
|
+
{
|
|
429
|
+
name: `${FRAMEWORK_EMOJI["langgraph-py"]} LangGraph (Python)`,
|
|
430
|
+
value: "langgraph-py"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: `${FRAMEWORK_EMOJI["langgraph-js"]} LangGraph (JavaScript)`,
|
|
434
|
+
value: "langgraph-js"
|
|
435
|
+
},
|
|
287
436
|
{ name: `${FRAMEWORK_EMOJI.mastra} Mastra`, value: "mastra" },
|
|
288
|
-
{
|
|
289
|
-
|
|
437
|
+
{
|
|
438
|
+
name: `${FRAMEWORK_EMOJI["pydantic-ai"]} Pydantic AI`,
|
|
439
|
+
value: "pydantic-ai"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: `${FRAMEWORK_EMOJI["aws-strands-py"]} AWS Strands (Python)`,
|
|
443
|
+
value: "aws-strands-py"
|
|
444
|
+
},
|
|
290
445
|
{ name: `${FRAMEWORK_EMOJI.adk} ADK`, value: "adk" },
|
|
291
446
|
{
|
|
292
447
|
name: `${FRAMEWORK_EMOJI["microsoft-agent-framework-dotnet"]} Microsoft Agent Framework (.NET)`,
|
|
@@ -296,8 +451,15 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
296
451
|
name: `${FRAMEWORK_EMOJI["microsoft-agent-framework-py"]} Microsoft Agent Framework (Python)`,
|
|
297
452
|
value: "microsoft-agent-framework-py"
|
|
298
453
|
},
|
|
454
|
+
{
|
|
455
|
+
name: `${FRAMEWORK_EMOJI["mcp-apps"]} MCP Apps`,
|
|
456
|
+
value: "mcp-apps"
|
|
457
|
+
},
|
|
299
458
|
{ name: `${FRAMEWORK_EMOJI.flows} CrewAI Flows`, value: "flows" },
|
|
300
|
-
{
|
|
459
|
+
{
|
|
460
|
+
name: `${FRAMEWORK_EMOJI.llamaindex} LlamaIndex`,
|
|
461
|
+
value: "llamaindex"
|
|
462
|
+
},
|
|
301
463
|
{ name: `${FRAMEWORK_EMOJI.agno} Agno`, value: "agno" },
|
|
302
464
|
{ name: `${FRAMEWORK_EMOJI.ag2} AG2`, value: "ag2" },
|
|
303
465
|
{ name: `${FRAMEWORK_EMOJI.a2a} A2A`, value: "a2a" }
|
|
@@ -306,13 +468,25 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
306
468
|
]);
|
|
307
469
|
return framework;
|
|
308
470
|
}
|
|
309
|
-
async downloadTemplate(projectDir, framework) {
|
|
310
|
-
const
|
|
311
|
-
|
|
471
|
+
async downloadTemplate(projectDir, framework, spinner) {
|
|
472
|
+
const templateRef = TEMPLATE_REPOS[framework];
|
|
473
|
+
if (isValidGitHubUrl(templateRef)) {
|
|
474
|
+
const success = await cloneGitHubSubdirectory(
|
|
475
|
+
templateRef,
|
|
476
|
+
projectDir,
|
|
477
|
+
spinner
|
|
478
|
+
);
|
|
479
|
+
if (!success) {
|
|
480
|
+
throw new Error(`Failed to clone template from ${templateRef}`);
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const url = `https://github.com/${templateRef}/archive/refs/heads/main.tar.gz`;
|
|
312
485
|
try {
|
|
313
486
|
const response = await fetch(url);
|
|
314
|
-
if (!response.ok)
|
|
315
|
-
|
|
487
|
+
if (!response.ok)
|
|
488
|
+
throw new Error(`Failed to download template: ${response.statusText}`);
|
|
489
|
+
const tempFile = path2.join(projectDir, "template.tar.gz");
|
|
316
490
|
const fileStream = createWriteStream(tempFile);
|
|
317
491
|
if (!response.body) throw new Error("Failed to get response body");
|
|
318
492
|
await streamPipeline(response.body, fileStream);
|
|
@@ -321,165 +495,25 @@ Your project is ready to explore CopilotKit locally.`
|
|
|
321
495
|
cwd: projectDir,
|
|
322
496
|
strip: 1
|
|
323
497
|
});
|
|
324
|
-
await
|
|
498
|
+
await fs2.remove(tempFile);
|
|
325
499
|
} catch (error) {
|
|
326
500
|
throw new Error(`Failed to download template: ${error.message}`);
|
|
327
501
|
}
|
|
328
502
|
}
|
|
329
503
|
};
|
|
330
504
|
|
|
331
|
-
// src/lib/init/types/questions.ts
|
|
332
|
-
import { z } from "zod";
|
|
333
|
-
import { Flags as Flags2 } from "@oclif/core";
|
|
334
|
-
|
|
335
|
-
// src/lib/init/utils.ts
|
|
336
|
-
var isLocalhost = (url) => {
|
|
337
|
-
return url.includes("localhost") || url.includes("127.0.0.1") || url.includes("0.0.0.0");
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// src/lib/init/types/questions.ts
|
|
341
|
-
var MODES = ["LangGraph", "CrewAI", "Mastra", "LlamaIndex", "Agno", "AG2", "MCP", "Standard"];
|
|
342
|
-
var CREW_TYPES = ["Crews", "Flows"];
|
|
343
|
-
var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
|
|
344
|
-
var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter"];
|
|
345
|
-
var CREW_FLOW_TEMPLATES = ["Starter"];
|
|
346
|
-
var YES_NO = ["Yes", "No"];
|
|
347
|
-
var DEPLOYMENT_CHOICES = ["Copilot Cloud", "Self-hosted"];
|
|
348
|
-
var sanitizers = {
|
|
349
|
-
// Remove trailing slash from URLs
|
|
350
|
-
url: (value) => {
|
|
351
|
-
if (!value) return value;
|
|
352
|
-
return value.trim().replace(/\/+$/, "");
|
|
353
|
-
},
|
|
354
|
-
// Trim whitespace from strings
|
|
355
|
-
trim: (value) => {
|
|
356
|
-
if (!value) return value;
|
|
357
|
-
return value.trim();
|
|
358
|
-
},
|
|
359
|
-
// Lowercase strings
|
|
360
|
-
lowercase: (value) => {
|
|
361
|
-
if (!value) return value;
|
|
362
|
-
return value.toLowerCase().trim();
|
|
363
|
-
},
|
|
364
|
-
// Clean API keys (remove whitespace)
|
|
365
|
-
apiKey: (value) => {
|
|
366
|
-
if (!value) return value;
|
|
367
|
-
return value.trim().replace(/\s/g, "");
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
var ModeSchema = z.enum(MODES);
|
|
371
|
-
var CrewTypeSchema = z.enum(CREW_TYPES);
|
|
372
|
-
var ChatComponentSchema = z.enum(CHAT_COMPONENTS);
|
|
373
|
-
var LangGraphAgentSchema = z.enum(LANGGRAPH_AGENTS);
|
|
374
|
-
var CrewFlowTemplateSchema = z.enum(CREW_FLOW_TEMPLATES);
|
|
375
|
-
var YesNoSchema = z.enum(YES_NO);
|
|
376
|
-
var DeploymentChoiceSchema = z.enum(DEPLOYMENT_CHOICES);
|
|
377
|
-
var UrlSchema = z.preprocess(
|
|
378
|
-
(val) => sanitizers.url(String(val)),
|
|
379
|
-
z.string().url("Please enter a valid URL").min(1, "URL is required")
|
|
380
|
-
);
|
|
381
|
-
var TokenSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Token is required"));
|
|
382
|
-
var ApiKeySchema = z.preprocess(
|
|
383
|
-
(val) => sanitizers.apiKey(String(val)),
|
|
384
|
-
z.string().min(1, "API key is required")
|
|
385
|
-
);
|
|
386
|
-
var LLMApiKeySchema = z.preprocess((val) => sanitizers.apiKey(String(val)), z.string().optional());
|
|
387
|
-
var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
|
|
388
|
-
var ConfigSchema = z.object({
|
|
389
|
-
// Core fields
|
|
390
|
-
copilotKitVersion: z.string().optional(),
|
|
391
|
-
mode: ModeSchema,
|
|
392
|
-
chatUi: ChatComponentSchema.optional(),
|
|
393
|
-
// Yes/No fields
|
|
394
|
-
alreadyDeployed: YesNoSchema.optional(),
|
|
395
|
-
fastApiEnabled: YesNoSchema.optional(),
|
|
396
|
-
// DEPRECATED: useCopilotCloud - consolidated with signupForCopilotCloud
|
|
397
|
-
useCopilotCloud: YesNoSchema.optional(),
|
|
398
|
-
// LangGraph specific fields
|
|
399
|
-
langGraphAgent: LangGraphAgentSchema.optional(),
|
|
400
|
-
langGraphPlatform: YesNoSchema.optional(),
|
|
401
|
-
langGraphPlatformUrl: UrlSchema.optional(),
|
|
402
|
-
langGraphRemoteEndpointURL: UrlSchema.optional(),
|
|
403
|
-
// CrewAI specific fields
|
|
404
|
-
crewType: CrewTypeSchema.optional(),
|
|
405
|
-
crewName: NameSchema.optional(),
|
|
406
|
-
crewUrl: UrlSchema.optional(),
|
|
407
|
-
crewBearerToken: TokenSchema.optional(),
|
|
408
|
-
// API keys and tokens
|
|
409
|
-
copilotCloudPublicApiKey: z.string().optional(),
|
|
410
|
-
langSmithApiKey: ApiKeySchema.optional(),
|
|
411
|
-
llmToken: LLMApiKeySchema.optional(),
|
|
412
|
-
// IDE Documentation setup fields
|
|
413
|
-
setupIDEDocs: YesNoSchema.optional(),
|
|
414
|
-
selectedIDE: z.union([z.enum(["cursor", "windsurf"]), z.literal("skip")]).optional(),
|
|
415
|
-
// NEW: A/B/C test fields
|
|
416
|
-
deploymentChoice: DeploymentChoiceSchema.optional()
|
|
417
|
-
// For branch B only (Cloud vs Self-hosted)
|
|
418
|
-
}).refine(
|
|
419
|
-
(data) => {
|
|
420
|
-
if (data.mode === "CrewAI") {
|
|
421
|
-
return !!data.crewUrl && !!data.crewBearerToken;
|
|
422
|
-
}
|
|
423
|
-
return true;
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
message: "Crew URL and bearer token are required for CrewAI",
|
|
427
|
-
path: ["crewUrl", "crewBearerToken"]
|
|
428
|
-
}
|
|
429
|
-
).refine(
|
|
430
|
-
(data) => {
|
|
431
|
-
if (data.mode === "LangGraph" && data.alreadyDeployed === "Yes" && data.langGraphPlatform === "Yes") {
|
|
432
|
-
return !!data.langGraphPlatformUrl && !!data.langSmithApiKey || isLocalhost(data.langGraphPlatformUrl || "");
|
|
433
|
-
}
|
|
434
|
-
return true;
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
message: "LangGraph Platform URL and LangSmith API key are required",
|
|
438
|
-
path: ["langGraphPlatformUrl", "langSmithApiKey"]
|
|
439
|
-
}
|
|
440
|
-
);
|
|
441
|
-
var ConfigFlags = {
|
|
442
|
-
booth: Flags2.boolean({ description: "Use CopilotKit in booth mode", default: false, char: "b" }),
|
|
443
|
-
mode: Flags2.string({ description: "How you will be interacting with AI", options: MODES, char: "m" }),
|
|
444
|
-
"copilotkit-version": Flags2.string({ description: "CopilotKit version to use (e.g. 1.7.0)" }),
|
|
445
|
-
"use-copilot-cloud": Flags2.string({ description: "Use Copilot Cloud for production-ready hosting", options: YES_NO }),
|
|
446
|
-
"langgraph-agent": Flags2.string({ description: "LangGraph agent template to use", options: LANGGRAPH_AGENTS }),
|
|
447
|
-
"crew-type": Flags2.string({ description: "CrewAI implementation type", options: CREW_TYPES }),
|
|
448
|
-
"crew-name": Flags2.string({ description: "Name for your CrewAI agent" }),
|
|
449
|
-
"crew-url": Flags2.string({ description: "URL endpoint for your CrewAI agent" }),
|
|
450
|
-
"crew-bearer-token": Flags2.string({ description: "Bearer token for CrewAI authentication" }),
|
|
451
|
-
"langsmith-api-key": Flags2.string({ description: "LangSmith API key for LangGraph observability" }),
|
|
452
|
-
"llm-token": Flags2.string({ description: "API key for your preferred LLM provider" }),
|
|
453
|
-
"setup-ide-docs": Flags2.string({ description: "Setup IDE documentation rules for AI assistance", options: YES_NO }),
|
|
454
|
-
"selected-ide": Flags2.string({
|
|
455
|
-
description: "IDE to configure with documentation rules",
|
|
456
|
-
options: ["cursor", "windsurf", "skip"]
|
|
457
|
-
}),
|
|
458
|
-
// NEW: A/B/C test flags
|
|
459
|
-
"deployment-choice": Flags2.string({
|
|
460
|
-
description: "Choose between Copilot Cloud or Self-hosted deployment",
|
|
461
|
-
options: DEPLOYMENT_CHOICES
|
|
462
|
-
})
|
|
463
|
-
};
|
|
464
|
-
|
|
465
505
|
// src/commands/init.ts
|
|
466
|
-
var CloudInit = class
|
|
467
|
-
static description = "
|
|
468
|
-
static examples = ["<%= config.bin %>
|
|
469
|
-
static flags = {
|
|
470
|
-
...BaseCommand.flags,
|
|
471
|
-
...ConfigFlags,
|
|
472
|
-
runtimeUrl: Flags3.string({ description: "runtime URL" }),
|
|
473
|
-
project: Flags3.string({ description: "project ID (can be found in the Copilot Cloud dashboard)" }),
|
|
474
|
-
dir: Flags3.string({ description: "directory of the Next.js project", default: "." })
|
|
475
|
-
};
|
|
506
|
+
var CloudInit = class extends BaseCommand {
|
|
507
|
+
static description = "`init` is deprecated \u2014 use `create` instead.";
|
|
508
|
+
static examples = ["<%= config.bin %> create"];
|
|
476
509
|
constructor(argv, config) {
|
|
477
510
|
super(argv, config);
|
|
478
511
|
}
|
|
479
512
|
async run() {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
513
|
+
this.log(
|
|
514
|
+
"`copilotkit init` is deprecated. Redirecting to `copilotkit create`..."
|
|
515
|
+
);
|
|
516
|
+
const createCommand = new Create(this.argv, this.config);
|
|
483
517
|
await createCommand.run();
|
|
484
518
|
}
|
|
485
519
|
};
|