copilotkit 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/base-command.js +1 -1
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +220 -158
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/index.d.ts +3 -2
- package/dist/lib/init/index.js +181 -102
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +95 -50
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/agent.d.ts +19 -0
- package/dist/lib/init/scaffold/agent.js +161 -0
- package/dist/lib/init/scaffold/agent.js.map +1 -0
- package/dist/lib/init/scaffold/env.js +4 -2
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/github.d.ts +1 -4
- package/dist/lib/init/scaffold/github.js +1 -46
- package/dist/lib/init/scaffold/github.js.map +1 -1
- package/dist/lib/init/scaffold/index.d.ts +2 -1
- package/dist/lib/init/scaffold/index.js +96 -54
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +15 -6
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.d.ts +1 -1
- package/dist/lib/init/types/index.js +12 -2
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +7 -2
- package/dist/lib/init/types/questions.js +4 -1
- package/dist/lib/init/types/questions.js.map +1 -1
- package/dist/lib/init/types/templates.d.ts +11 -2
- package/dist/lib/init/types/templates.js +8 -1
- package/dist/lib/init/types/templates.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 +12 -1
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/commands/init.ts
|
|
2
2
|
import { Flags as Flags2 } from "@oclif/core";
|
|
3
3
|
import inquirer2 from "inquirer";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import path4 from "path";
|
|
5
|
+
import fs4 from "fs";
|
|
6
6
|
|
|
7
7
|
// src/services/auth.service.ts
|
|
8
8
|
import Conf2 from "conf";
|
|
@@ -221,7 +221,7 @@ import { Command } from "@oclif/core";
|
|
|
221
221
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
222
222
|
|
|
223
223
|
// src/utils/version.ts
|
|
224
|
-
var LIB_VERSION = "0.0.
|
|
224
|
+
var LIB_VERSION = "0.0.17";
|
|
225
225
|
|
|
226
226
|
// src/commands/base-command.ts
|
|
227
227
|
import chalk2 from "chalk";
|
|
@@ -289,6 +289,7 @@ var AGENT_FRAMEWORKS = ["CrewAI", "LangGraph", "None"];
|
|
|
289
289
|
var CREW_TYPES = ["Crews", "Flows"];
|
|
290
290
|
var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
|
|
291
291
|
var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter", "None"];
|
|
292
|
+
var CREW_FLOW_TEMPLATES = ["Starter", "None"];
|
|
292
293
|
var ConfigFlags = {
|
|
293
294
|
copilotKitVersion: Flags.string({ description: "CopilotKit version to use (e.g. 1.7.0)" }),
|
|
294
295
|
agentFramework: Flags.string({ description: "Agent framework to power your copilot", options: AGENT_FRAMEWORKS }),
|
|
@@ -301,7 +302,8 @@ var ConfigFlags = {
|
|
|
301
302
|
crewUrl: Flags.string({ description: "URL endpoint for your CrewAI agent" }),
|
|
302
303
|
crewBearerToken: Flags.string({ description: "Bearer token for CrewAI authentication" }),
|
|
303
304
|
langSmithApiKey: Flags.string({ description: "LangSmith API key for LangGraph observability" }),
|
|
304
|
-
llmToken: Flags.string({ description: "API key for your preferred LLM provider" })
|
|
305
|
+
llmToken: Flags.string({ description: "API key for your preferred LLM provider" }),
|
|
306
|
+
crewFlowAgent: Flags.string({ description: "CrewAI Flow template to use", options: CREW_FLOW_TEMPLATES })
|
|
305
307
|
};
|
|
306
308
|
|
|
307
309
|
// src/lib/init/types/templates.ts
|
|
@@ -309,7 +311,14 @@ var BASE_URL = "http://registry.copilotkit.ai/r";
|
|
|
309
311
|
var templateMapping = {
|
|
310
312
|
"LangGraphPlatform": `${BASE_URL}/langgraph-platform-starter.json`,
|
|
311
313
|
"RemoteEndpoint": `${BASE_URL}/remote-endpoint-starter.json`,
|
|
312
|
-
"CrewEnterprise":
|
|
314
|
+
"CrewEnterprise": [
|
|
315
|
+
`${BASE_URL}/coagents-crew-starter.json`
|
|
316
|
+
],
|
|
317
|
+
"CrewFlowsStarter": [
|
|
318
|
+
`${BASE_URL}/coagents-starter-ui.json`,
|
|
319
|
+
`${BASE_URL}/agent-layout.json`,
|
|
320
|
+
`${BASE_URL}/remote-endpoint.json`
|
|
321
|
+
],
|
|
313
322
|
"Standard": `${BASE_URL}/standard-starter.json`,
|
|
314
323
|
"CopilotChat": `${BASE_URL}/chat.json`,
|
|
315
324
|
"CopilotPopup": `${BASE_URL}/popup.json`,
|
|
@@ -329,87 +338,123 @@ var questions = [
|
|
|
329
338
|
{
|
|
330
339
|
type: "select",
|
|
331
340
|
name: "crewType",
|
|
332
|
-
message: "\u{
|
|
341
|
+
message: "\u{1F465} What kind of CrewAI implementation would you like to use?",
|
|
333
342
|
choices: Array.from(CREW_TYPES),
|
|
334
343
|
when: (answers) => answers.agentFramework === "CrewAI"
|
|
335
344
|
},
|
|
345
|
+
// CrewAI Crews specific questions - shown when CrewAI Crews selected
|
|
336
346
|
{
|
|
337
347
|
type: "input",
|
|
338
348
|
name: "crewName",
|
|
339
|
-
message: "\u{1F465} What would you like to name your crew?",
|
|
349
|
+
message: "\u{1F465} What would you like to name your crew? (can be anything)",
|
|
340
350
|
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Crews",
|
|
341
351
|
default: "MyCopilotCrew"
|
|
342
352
|
},
|
|
343
353
|
{
|
|
344
354
|
type: "input",
|
|
345
355
|
name: "crewUrl",
|
|
346
|
-
message: "\u{1F517} Enter your Crew
|
|
356
|
+
message: "\u{1F517} Enter your Crew's URL:",
|
|
347
357
|
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Crews"
|
|
348
358
|
},
|
|
349
359
|
{
|
|
350
360
|
type: "input",
|
|
351
361
|
name: "crewBearerToken",
|
|
352
|
-
message: "\u{1F511} Enter your Crew
|
|
353
|
-
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Crews"
|
|
354
|
-
|
|
355
|
-
// LangGraph specific questions - shown when LangGraph selected
|
|
356
|
-
{
|
|
357
|
-
type: "yes/no",
|
|
358
|
-
name: "alreadyDeployed",
|
|
359
|
-
message: "\u{1F680} Is your LangGraph agent already deployed?",
|
|
360
|
-
when: (answers) => answers.agentFramework === "LangGraph"
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
type: "yes/no",
|
|
364
|
-
name: "langGraphPlatform",
|
|
365
|
-
message: "\u{1F99C}\u{1F517} Is it hosted on LangGraph Platform?",
|
|
366
|
-
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes"
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
type: "input",
|
|
370
|
-
name: "langGraphPlatformUrl",
|
|
371
|
-
message: "\u{1F99C}\u{1F517} Enter your LangGraph platform URL:",
|
|
372
|
-
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform === "Yes"
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
type: "input",
|
|
376
|
-
name: "langGraphRemoteEndpointURL",
|
|
377
|
-
message: "\u{1F50C} Enter your LangGraph endpoint URL:",
|
|
378
|
-
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform === "No"
|
|
362
|
+
message: "\u{1F511} Enter your Crew's bearer token:",
|
|
363
|
+
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Crews",
|
|
364
|
+
sensitive: true
|
|
379
365
|
},
|
|
366
|
+
// CrewAI Flows specific questions - shown when CrewAI Flows selected
|
|
380
367
|
{
|
|
381
368
|
type: "select",
|
|
382
|
-
name: "
|
|
383
|
-
message: "\u{1F4E6} Choose a
|
|
384
|
-
choices: Array.from(
|
|
385
|
-
when: (answers) => answers.agentFramework === "
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
type: "input",
|
|
389
|
-
name: "langSmithApiKey",
|
|
390
|
-
message: "\u{1F99C}\u{1F517} Enter your LangSmith API key (required by LangGraph Platform) :",
|
|
391
|
-
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "No"
|
|
369
|
+
name: "crewFlowAgent",
|
|
370
|
+
message: "\u{1F4E6} Choose a CrewAI Flow Template",
|
|
371
|
+
choices: Array.from(CREW_FLOW_TEMPLATES),
|
|
372
|
+
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Flows"
|
|
392
373
|
},
|
|
374
|
+
// LangGraph specific questions - shown when LangGraph selected
|
|
375
|
+
// {
|
|
376
|
+
// type: 'yes/no',
|
|
377
|
+
// name: 'alreadyDeployed',
|
|
378
|
+
// message: '🚀 Is your LangGraph agent already deployed?',
|
|
379
|
+
// when: (answers) => answers.agentFramework === 'LangGraph',
|
|
380
|
+
// },
|
|
381
|
+
// {
|
|
382
|
+
// type: 'yes/no',
|
|
383
|
+
// name: 'langGraphPlatform',
|
|
384
|
+
// message: '🦜🔗 Is it hosted on LangGraph Platform?',
|
|
385
|
+
// when: (answers) =>
|
|
386
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
387
|
+
// answers.alreadyDeployed === 'Yes',
|
|
388
|
+
// },
|
|
389
|
+
// {
|
|
390
|
+
// type: 'input',
|
|
391
|
+
// name: 'langGraphPlatformUrl',
|
|
392
|
+
// message: '🦜🔗 Enter your LangGraph platform URL:',
|
|
393
|
+
// when: (answers) =>
|
|
394
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
395
|
+
// answers.alreadyDeployed === 'Yes' &&
|
|
396
|
+
// answers.langGraphPlatform === 'Yes',
|
|
397
|
+
// },
|
|
398
|
+
// {
|
|
399
|
+
// type: 'input',
|
|
400
|
+
// name: 'langGraphRemoteEndpointURL',
|
|
401
|
+
// message: '🔌 Enter your LangGraph endpoint URL:',
|
|
402
|
+
// when: (answers) =>
|
|
403
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
404
|
+
// answers.alreadyDeployed === 'Yes' &&
|
|
405
|
+
// answers.langGraphPlatform === 'No',
|
|
406
|
+
// },
|
|
407
|
+
// {
|
|
408
|
+
// type: 'select',
|
|
409
|
+
// name: 'langGraphAgent',
|
|
410
|
+
// message: '📦 Choose a LangGraph starter template:',
|
|
411
|
+
// choices: Array.from(LANGGRAPH_AGENTS),
|
|
412
|
+
// when: (answers) =>
|
|
413
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
414
|
+
// answers.alreadyDeployed === 'No',
|
|
415
|
+
// },
|
|
416
|
+
// {
|
|
417
|
+
// type: 'input',
|
|
418
|
+
// name: 'langSmithApiKey',
|
|
419
|
+
// message: '🦜🔗 Enter your LangSmith API key (required by LangGraph Platform) :',
|
|
420
|
+
// when: (answers) =>
|
|
421
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
422
|
+
// answers.alreadyDeployed === 'No',
|
|
423
|
+
// sensitive: true,
|
|
424
|
+
// },
|
|
393
425
|
// Deployment options
|
|
394
426
|
{
|
|
395
427
|
type: "yes/no",
|
|
396
428
|
name: "useCopilotCloud",
|
|
397
429
|
message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
|
|
398
|
-
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews")
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
type: "yes/no",
|
|
402
|
-
name: "fastApiEnabled",
|
|
403
|
-
message: "\u26A1 Set up a FastAPI server for local development?",
|
|
404
|
-
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "No" && answers.langGraphAgent === "Python Starter" && answers.useCopilotCloud !== "Yes"
|
|
430
|
+
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews") && answers.agentFramework !== "LangGraph" && answers.crewType !== "Flows"
|
|
405
431
|
},
|
|
432
|
+
// {
|
|
433
|
+
// type: 'yes/no',
|
|
434
|
+
// name: 'fastApiEnabled',
|
|
435
|
+
// message: '⚡ Set up a FastAPI server for local development?',
|
|
436
|
+
// when: (answers) =>
|
|
437
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
438
|
+
// answers.alreadyDeployed === 'No' &&
|
|
439
|
+
// answers.langGraphAgent === 'Python Starter' &&
|
|
440
|
+
// answers.useCopilotCloud !== 'Yes',
|
|
441
|
+
// },
|
|
406
442
|
// UI components - always shown last
|
|
407
443
|
{
|
|
408
444
|
type: "select",
|
|
409
445
|
name: "chatUi",
|
|
410
446
|
message: "\u{1F4AC} Select a UI component for your copilot:",
|
|
411
447
|
choices: Array.from(CHAT_COMPONENTS),
|
|
412
|
-
default: "CopilotChat"
|
|
448
|
+
default: "CopilotChat",
|
|
449
|
+
when: (answers) => answers.agentFramework === "None"
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
type: "input",
|
|
453
|
+
name: "llmToken",
|
|
454
|
+
message: "\u{1F511} Enter your OpenAI API key (required for agent functionality):",
|
|
455
|
+
when: (answers) => answers.agentFramework !== "LangGraph" && // (answers.agentFramework === 'LangGraph' && answers.alreadyDeployed === 'No') ||
|
|
456
|
+
(answers.agentFramework === "CrewAI" && answers.crewType === "Flows"),
|
|
457
|
+
sensitive: true
|
|
413
458
|
}
|
|
414
459
|
];
|
|
415
460
|
|
|
@@ -417,9 +462,7 @@ var questions = [
|
|
|
417
462
|
import spawn from "cross-spawn";
|
|
418
463
|
async function scaffoldShadCN(userAnswers) {
|
|
419
464
|
try {
|
|
420
|
-
const components = [
|
|
421
|
-
templateMapping[userAnswers.chatUi]
|
|
422
|
-
];
|
|
465
|
+
const components = [];
|
|
423
466
|
if (userAnswers.agentFramework !== "None") {
|
|
424
467
|
switch (userAnswers.agentFramework) {
|
|
425
468
|
case "LangGraph":
|
|
@@ -427,7 +470,9 @@ async function scaffoldShadCN(userAnswers) {
|
|
|
427
470
|
break;
|
|
428
471
|
case "CrewAI":
|
|
429
472
|
if (userAnswers.crewType === "Crews") {
|
|
430
|
-
components.push(templateMapping.CrewEnterprise);
|
|
473
|
+
components.push(...templateMapping.CrewEnterprise);
|
|
474
|
+
} else if (userAnswers.crewFlowAgent) {
|
|
475
|
+
components.push(...templateMapping.CrewFlowsStarter);
|
|
431
476
|
} else {
|
|
432
477
|
components.push(templateMapping.RemoteEndpoint);
|
|
433
478
|
}
|
|
@@ -481,7 +526,7 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
481
526
|
varsAdded = true;
|
|
482
527
|
}
|
|
483
528
|
if (userAnswers.langSmithApiKey) {
|
|
484
|
-
newEnvValues += `
|
|
529
|
+
newEnvValues += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
485
530
|
`;
|
|
486
531
|
spinner.text = chalk3.cyan("Adding LangSmith API key...");
|
|
487
532
|
varsAdded = true;
|
|
@@ -489,7 +534,9 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
489
534
|
if (userAnswers.llmToken) {
|
|
490
535
|
newEnvValues += `LLM_TOKEN=${userAnswers.llmToken}
|
|
491
536
|
`;
|
|
492
|
-
|
|
537
|
+
newEnvValues += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
538
|
+
`;
|
|
539
|
+
spinner.text = chalk3.cyan("Adding OpenAI API key...");
|
|
493
540
|
varsAdded = true;
|
|
494
541
|
}
|
|
495
542
|
if (userAnswers.crewName) {
|
|
@@ -525,50 +572,6 @@ import * as fs2 from "fs";
|
|
|
525
572
|
import * as path2 from "path";
|
|
526
573
|
import * as os from "os";
|
|
527
574
|
import chalk4 from "chalk";
|
|
528
|
-
import ora3 from "ora";
|
|
529
|
-
async function scaffoldAgent(userAnswers) {
|
|
530
|
-
if (userAnswers.agentFramework === "None" || userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Crews" || userAnswers.agentFramework === "LangGraph" && (!userAnswers.langGraphAgent || userAnswers.langGraphAgent === "None")) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
const spinner = ora3({
|
|
534
|
-
text: chalk4.cyan("Setting up AI agent..."),
|
|
535
|
-
color: "cyan"
|
|
536
|
-
}).start();
|
|
537
|
-
try {
|
|
538
|
-
if (userAnswers.agentFramework === "LangGraph") {
|
|
539
|
-
switch (userAnswers.langGraphAgent) {
|
|
540
|
-
case "Python Starter":
|
|
541
|
-
spinner.text = chalk4.cyan("Setting up Python LangGraph agent...");
|
|
542
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
543
|
-
await cloneGitHubSubdirectory(
|
|
544
|
-
"https://github.com/CopilotKit/CopilotKit/tree/main/examples/coagents-starter/agent-py",
|
|
545
|
-
path2.join(process.cwd(), "agent"),
|
|
546
|
-
spinner
|
|
547
|
-
);
|
|
548
|
-
break;
|
|
549
|
-
case "TypeScript Starter":
|
|
550
|
-
spinner.text = chalk4.cyan("Setting up TypeScript LangGraph agent...");
|
|
551
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
552
|
-
await cloneGitHubSubdirectory(
|
|
553
|
-
"https://github.com/CopilotKit/CopilotKit/tree/main/examples/coagents-starter/agent-js",
|
|
554
|
-
path2.join(process.cwd(), "agent"),
|
|
555
|
-
spinner
|
|
556
|
-
);
|
|
557
|
-
break;
|
|
558
|
-
default:
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
561
|
-
} else if (userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Flows") {
|
|
562
|
-
spinner.text = chalk4.cyan("Setting up CrewAI Flows agent...");
|
|
563
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
564
|
-
spinner.info(chalk4.yellow("CrewAI Flows support is coming soon..."));
|
|
565
|
-
}
|
|
566
|
-
spinner.succeed(chalk4.green("AI agent setup complete"));
|
|
567
|
-
} catch (error) {
|
|
568
|
-
spinner.fail(chalk4.red("Failed to set up AI agent"));
|
|
569
|
-
throw error;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
575
|
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
573
576
|
try {
|
|
574
577
|
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
@@ -647,10 +650,84 @@ function parseGitHubUrl(githubUrl) {
|
|
|
647
650
|
// src/lib/init/scaffold/packages.ts
|
|
648
651
|
import spawn2 from "cross-spawn";
|
|
649
652
|
import chalk5 from "chalk";
|
|
653
|
+
import ora3 from "ora";
|
|
654
|
+
|
|
655
|
+
// src/lib/init/scaffold/agent.ts
|
|
650
656
|
import ora4 from "ora";
|
|
657
|
+
import chalk6 from "chalk";
|
|
658
|
+
import path3 from "path";
|
|
659
|
+
import fs3 from "fs";
|
|
660
|
+
async function scaffoldAgent(userAnswers) {
|
|
661
|
+
if (userAnswers.agentFramework === "None" || userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Crews" || userAnswers.agentFramework === "LangGraph" && (!userAnswers.langGraphAgent || userAnswers.langGraphAgent === "None")) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
const spinner = ora4({
|
|
665
|
+
text: chalk6.cyan("Setting up AI agent..."),
|
|
666
|
+
color: "cyan"
|
|
667
|
+
}).start();
|
|
668
|
+
let template = "";
|
|
669
|
+
switch (userAnswers.agentFramework) {
|
|
670
|
+
case "LangGraph":
|
|
671
|
+
if (userAnswers.langGraphAgent === "Python Starter") {
|
|
672
|
+
template = AgentTemplates.LangGraph.Starter.Python;
|
|
673
|
+
} else {
|
|
674
|
+
template = AgentTemplates.LangGraph.Starter.TypeScript;
|
|
675
|
+
}
|
|
676
|
+
break;
|
|
677
|
+
case "CrewAI":
|
|
678
|
+
if (userAnswers.crewFlowAgent === "Starter") {
|
|
679
|
+
template = AgentTemplates.CrewAI.Flows.Starter;
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
if (!template) {
|
|
684
|
+
spinner.fail(chalk6.red("Failed to determine agent template"));
|
|
685
|
+
throw new Error("Failed to determine agent template");
|
|
686
|
+
}
|
|
687
|
+
const agentDir = path3.join(process.cwd(), "agent");
|
|
688
|
+
try {
|
|
689
|
+
await cloneGitHubSubdirectory(
|
|
690
|
+
template,
|
|
691
|
+
agentDir,
|
|
692
|
+
spinner
|
|
693
|
+
);
|
|
694
|
+
spinner.text = chalk6.cyan("Creating agent environment variables...");
|
|
695
|
+
let envContent = "";
|
|
696
|
+
if (userAnswers.llmToken) {
|
|
697
|
+
envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
698
|
+
`;
|
|
699
|
+
}
|
|
700
|
+
if (userAnswers.agentFramework === "LangGraph" && userAnswers.langSmithApiKey) {
|
|
701
|
+
envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
702
|
+
`;
|
|
703
|
+
}
|
|
704
|
+
if (envContent) {
|
|
705
|
+
const agentEnvFile = path3.join(agentDir, ".env");
|
|
706
|
+
fs3.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
707
|
+
spinner.text = chalk6.cyan("Added API keys to agent .env file");
|
|
708
|
+
}
|
|
709
|
+
} catch (error) {
|
|
710
|
+
spinner.fail(chalk6.red("Failed to clone agent template"));
|
|
711
|
+
throw error;
|
|
712
|
+
}
|
|
713
|
+
spinner.succeed(chalk6.green(`${userAnswers.agentFramework} agent cloned successfully`));
|
|
714
|
+
}
|
|
715
|
+
var AgentTemplates = {
|
|
716
|
+
LangGraph: {
|
|
717
|
+
Starter: {
|
|
718
|
+
Python: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/coagents-starter/agent-py",
|
|
719
|
+
TypeScript: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/coagents-starter/agent-js"
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
CrewAI: {
|
|
723
|
+
Flows: {
|
|
724
|
+
Starter: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/coagents-starter-crewai-flows/agent-py"
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
};
|
|
651
728
|
|
|
652
729
|
// src/commands/init.ts
|
|
653
|
-
import
|
|
730
|
+
import chalk7 from "chalk";
|
|
654
731
|
import ora5 from "ora";
|
|
655
732
|
var CloudInit = class _CloudInit extends BaseCommand {
|
|
656
733
|
constructor(argv, config, authService = new AuthService()) {
|
|
@@ -672,14 +749,18 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
672
749
|
async run() {
|
|
673
750
|
const { flags } = await this.parse(_CloudInit);
|
|
674
751
|
try {
|
|
675
|
-
this.log(
|
|
676
|
-
this.log(
|
|
752
|
+
this.log(chalk7.magenta("\n\u{1FA81} Welcome to CopilotKit"));
|
|
753
|
+
this.log(chalk7.gray("Let's power up your Next.js project with AI capabilities\n"));
|
|
677
754
|
this.validateProjectCompatibility(flags);
|
|
678
755
|
const userAnswers = await this.getUserAnswers();
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
756
|
+
if (userAnswers.agentFramework === "LangGraph") {
|
|
757
|
+
this.log(chalk7.cyan("\n\u{1F99C}\u{1F517} LangGraph Integration"));
|
|
758
|
+
this.log(chalk7.gray("For detailed LangGraph setup instructions, please refer to:"));
|
|
759
|
+
this.log(chalk7.blue("https://docs.copilotkit.ai/coagents\n"));
|
|
760
|
+
process.exit(0);
|
|
682
761
|
}
|
|
762
|
+
const needsCloudSetup = userAnswers.useCopilotCloud === "Yes" || userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Crews";
|
|
763
|
+
if (needsCloudSetup) await this.setupCloud(flags, userAnswers);
|
|
683
764
|
await scaffoldShadCN(userAnswers);
|
|
684
765
|
await scaffoldAgent(userAnswers);
|
|
685
766
|
await scaffoldEnv(flags, userAnswers);
|
|
@@ -713,12 +794,13 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
713
794
|
default:
|
|
714
795
|
return {
|
|
715
796
|
...baseQuestion,
|
|
716
|
-
type: "input"
|
|
797
|
+
type: q.sensitive ? "password" : "input",
|
|
798
|
+
mask: q.sensitive ? "*" : void 0
|
|
717
799
|
};
|
|
718
800
|
}
|
|
719
801
|
});
|
|
720
802
|
const answers = await inquirer2.prompt(inquirerQuestions);
|
|
721
|
-
return answers;
|
|
803
|
+
return { ...answers };
|
|
722
804
|
}
|
|
723
805
|
async setupCloud(flags, userAnswers) {
|
|
724
806
|
const { cliToken, organization, user } = await this.authService.requireLogin(this);
|
|
@@ -732,11 +814,11 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
732
814
|
let selectedProjectId;
|
|
733
815
|
if (flags.project) {
|
|
734
816
|
if (!availableProjects.some((project) => project.id === flags.project)) {
|
|
735
|
-
this.log(
|
|
817
|
+
this.log(chalk7.red(`\u{1F4C1} Project with ID ${flags.project} not found`));
|
|
736
818
|
process.exit(1);
|
|
737
819
|
}
|
|
738
820
|
selectedProjectId = flags.project;
|
|
739
|
-
this.log(
|
|
821
|
+
this.log(chalk7.green(`\u{1F4C1} Selected project ${selectedProjectId}`));
|
|
740
822
|
} else {
|
|
741
823
|
const { projectId } = await inquirer2.prompt([
|
|
742
824
|
{
|
|
@@ -755,7 +837,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
755
837
|
userAnswers.copilotCloudPublicApiKey = copilotCloudPublicApiKey?.key;
|
|
756
838
|
if (userAnswers.crewUrl && userAnswers.crewName && userAnswers.crewBearerToken) {
|
|
757
839
|
const crewSpinner = ora5({
|
|
758
|
-
text:
|
|
840
|
+
text: chalk7("\u{1F465} Adding Crew to Copilot Cloud..."),
|
|
759
841
|
color: "cyan"
|
|
760
842
|
}).start();
|
|
761
843
|
await this.trpcClient.createRemoteEndpoint.mutate({
|
|
@@ -769,26 +851,26 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
769
851
|
crewApiBearerToken: userAnswers.crewBearerToken
|
|
770
852
|
}
|
|
771
853
|
});
|
|
772
|
-
crewSpinner.succeed(
|
|
854
|
+
crewSpinner.succeed(chalk7("\u{1F465} Crew added to Copilot Cloud"));
|
|
773
855
|
}
|
|
774
856
|
}
|
|
775
857
|
validateProjectCompatibility(flags) {
|
|
776
|
-
const projectPath =
|
|
777
|
-
if (!
|
|
858
|
+
const projectPath = path4.resolve(process.cwd(), flags.dir);
|
|
859
|
+
if (!fs4.existsSync(projectPath)) {
|
|
778
860
|
this.gracefulError(`Directory ${flags.dir} does not exist. Please provide a valid Next.js project directory.`);
|
|
779
861
|
return;
|
|
780
862
|
}
|
|
781
|
-
const packageJsonPath =
|
|
782
|
-
if (!
|
|
863
|
+
const packageJsonPath = path4.join(projectPath, "package.json");
|
|
864
|
+
if (!fs4.existsSync(packageJsonPath)) {
|
|
783
865
|
this.gracefulError(`Directory ${projectPath} does not contain a package.json file. Please provide a valid Next.js project.`);
|
|
784
866
|
process.exit(1);
|
|
785
867
|
}
|
|
786
|
-
const packageJson = JSON.parse(
|
|
868
|
+
const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf8"));
|
|
787
869
|
if (!packageJson.dependencies?.next && !packageJson.devDependencies?.next) {
|
|
788
870
|
this.gracefulError(`Directory ${projectPath} does not appear to be a Next.js project. Make sure it has next in dependencies.`);
|
|
789
871
|
process.exit(1);
|
|
790
872
|
}
|
|
791
|
-
this.log(
|
|
873
|
+
this.log(chalk7.green(`Valid Next.js project detected
|
|
792
874
|
`));
|
|
793
875
|
return true;
|
|
794
876
|
}
|
|
@@ -797,49 +879,29 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
797
879
|
let agentType = "";
|
|
798
880
|
let agentSetupMessage = "";
|
|
799
881
|
if (userAnswers.agentFramework !== "None") {
|
|
800
|
-
if (userAnswers.agentFramework === "
|
|
801
|
-
agentType = "LangGraph agent";
|
|
802
|
-
if (userAnswers.alreadyDeployed === "Yes") {
|
|
803
|
-
agentSetupMessage = `Using your existing deployed agent.`;
|
|
804
|
-
} else if (userAnswers.langGraphAgent && userAnswers.langGraphAgent !== "None") {
|
|
805
|
-
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(userAnswers.langGraphAgent)} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
806
|
-
if (userAnswers.langGraphAgent === "Python Starter") {
|
|
807
|
-
if (userAnswers.fastApiEnabled === "Yes") {
|
|
808
|
-
agentDevInstructions = "poetry install && poetry run demo";
|
|
809
|
-
} else {
|
|
810
|
-
agentDevInstructions = "npx @langchain/langgraph-cli dev --port 8123";
|
|
811
|
-
}
|
|
812
|
-
} else if (userAnswers.langGraphAgent === "TypeScript Starter") {
|
|
813
|
-
agentDevInstructions = "npm i && npm run dev";
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
} else if (userAnswers.agentFramework === "CrewAI") {
|
|
882
|
+
if (userAnswers.agentFramework === "CrewAI") {
|
|
817
883
|
agentType = "CrewAI";
|
|
818
884
|
if (userAnswers.crewType === "Crews") {
|
|
819
|
-
agentSetupMessage = `Using your Crew from ${
|
|
885
|
+
agentSetupMessage = `Using your Crew from ${chalk7.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
820
886
|
} else if (userAnswers.crewType === "Flows") {
|
|
821
|
-
agentSetupMessage = "CrewAI
|
|
887
|
+
agentSetupMessage = `We've scaffolded a ${chalk7.cyan(userAnswers.crewFlowAgent || "CrewAI")} agent in the ${chalk7.cyan("./agent")} directory.`;
|
|
888
|
+
agentDevInstructions = "poetry install && poetry run python app.py";
|
|
822
889
|
}
|
|
823
890
|
}
|
|
824
891
|
}
|
|
825
|
-
this.log(
|
|
826
|
-
this.log(
|
|
827
|
-
this.log(
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
this.log(
|
|
834
|
-
this.log(` ${
|
|
835
|
-
this.log(`
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
this.log(` ${chalk6.gray("$")} ${chalk6.yellow(`cd agent && ${agentDevInstructions}`)}`);
|
|
839
|
-
}
|
|
840
|
-
this.log(chalk6.bold("\n\u{1F4DA} Documentation:"));
|
|
841
|
-
this.log(` ${chalk6.blue("https://docs.copilotkit.ai")}`);
|
|
842
|
-
this.log("");
|
|
892
|
+
this.log("\n-----\n");
|
|
893
|
+
this.log(chalk7.magenta("\u{1F389} Your CopilotKit setup is complete! \u{1F389}\n"));
|
|
894
|
+
this.log(chalk7.bold(`\u{1F4CB} Recap`));
|
|
895
|
+
this.log(` - CopilotKit has been added to your Next.js app.`);
|
|
896
|
+
if (agentSetupMessage) this.log(` - ${agentSetupMessage}`);
|
|
897
|
+
if (userAnswers.useCopilotCloud || userAnswers.crewType === "Crews") this.log(` - With Copilot Cloud.`);
|
|
898
|
+
this.log(chalk7.bold("\n\u{1F680} Next steps:"));
|
|
899
|
+
this.log(` - Start your Next.js app: ${chalk7.gray("$")} ${chalk7.cyan("npm run dev")}`);
|
|
900
|
+
if (agentDevInstructions) this.log(` - Start your agent: ${chalk7.gray("$")} ${chalk7.cyan(`cd agent && ${agentDevInstructions}`)}`);
|
|
901
|
+
this.log(` - Navigate to ${chalk7.blue("http://localhost:3000/copilotkit")}`);
|
|
902
|
+
this.log(` - Talk to your ${userAnswers.agentFramework !== "None" ? "agent" : "application"}.`);
|
|
903
|
+
this.log(` - Read the docs: ${chalk7.blue("https://docs.copilotkit.ai")}`);
|
|
904
|
+
this.log(chalk7.magenta("\nEnjoy building with CopilotKit \u{1FA81}\n"));
|
|
843
905
|
}
|
|
844
906
|
};
|
|
845
907
|
export {
|