copilotkit 0.0.32 → 0.0.33

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.
Files changed (50) hide show
  1. package/README.md +7 -6
  2. package/dist/commands/base-command.js +2 -4
  3. package/dist/commands/base-command.js.map +1 -1
  4. package/dist/commands/dev.js +2 -4
  5. package/dist/commands/dev.js.map +1 -1
  6. package/dist/commands/init.d.ts +12 -10
  7. package/dist/commands/init.js +110 -67
  8. package/dist/commands/init.js.map +1 -1
  9. package/dist/commands/login.js +2 -4
  10. package/dist/commands/login.js.map +1 -1
  11. package/dist/commands/logout.js +2 -4
  12. package/dist/commands/logout.js.map +1 -1
  13. package/dist/lib/init/index.js +52 -48
  14. package/dist/lib/init/index.js.map +1 -1
  15. package/dist/lib/init/questions.js +24 -27
  16. package/dist/lib/init/questions.js.map +1 -1
  17. package/dist/lib/init/scaffold/agent.js +15 -5
  18. package/dist/lib/init/scaffold/agent.js.map +1 -1
  19. package/dist/lib/init/scaffold/crew-inputs.js.map +1 -1
  20. package/dist/lib/init/scaffold/env.js +11 -14
  21. package/dist/lib/init/scaffold/env.js.map +1 -1
  22. package/dist/lib/init/scaffold/github.js.map +1 -1
  23. package/dist/lib/init/scaffold/index.js +50 -46
  24. package/dist/lib/init/scaffold/index.js.map +1 -1
  25. package/dist/lib/init/scaffold/langgraph-assistants.js +11 -14
  26. package/dist/lib/init/scaffold/langgraph-assistants.js.map +1 -1
  27. package/dist/lib/init/scaffold/packages.js.map +1 -1
  28. package/dist/lib/init/scaffold/shadcn.d.ts +1 -1
  29. package/dist/lib/init/scaffold/shadcn.js +24 -27
  30. package/dist/lib/init/scaffold/shadcn.js.map +1 -1
  31. package/dist/lib/init/types/index.js +22 -25
  32. package/dist/lib/init/types/index.js.map +1 -1
  33. package/dist/lib/init/types/questions.d.ts +11 -10
  34. package/dist/lib/init/types/questions.js +12 -10
  35. package/dist/lib/init/types/questions.js.map +1 -1
  36. package/dist/lib/init/types/templates.d.ts +2 -2
  37. package/dist/lib/init/types/templates.js +10 -15
  38. package/dist/lib/init/types/templates.js.map +1 -1
  39. package/dist/lib/init/utils.d.ts +3 -0
  40. package/dist/lib/init/utils.js +8 -0
  41. package/dist/lib/init/utils.js.map +1 -0
  42. package/dist/services/analytics.service.js.map +1 -1
  43. package/dist/services/auth.service.js.map +1 -1
  44. package/dist/services/tunnel.service.js.map +1 -1
  45. package/dist/utils/detect-endpoint-type.utils.d.ts +1 -1
  46. package/dist/utils/version.d.ts +1 -1
  47. package/dist/utils/version.js +1 -1
  48. package/dist/utils/version.js.map +1 -1
  49. package/oclif.manifest.json +8 -1
  50. package/package.json +1 -1
@@ -222,7 +222,7 @@ import { Command } from "@oclif/core";
222
222
  import Sentry, { consoleIntegration } from "@sentry/node";
223
223
 
224
224
  // src/utils/version.ts
225
- var LIB_VERSION = "0.0.32";
225
+ var LIB_VERSION = "0.0.33";
226
226
 
227
227
  // src/commands/base-command.ts
228
228
  import chalk2 from "chalk";
@@ -234,9 +234,7 @@ var BaseCommand = class extends Command {
234
234
  }
235
235
  Sentry.init({
236
236
  dsn: process.env.SENTRY_DSN || "https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120",
237
- integrations: [
238
- consoleIntegration()
239
- ],
237
+ integrations: [consoleIntegration()],
240
238
  // Tracing
241
239
  tracesSampleRate: 1
242
240
  // Capture 100% of the transactions
@@ -275,6 +273,13 @@ var BaseCommand = class extends Command {
275
273
  // src/lib/init/types/questions.ts
276
274
  import { z } from "zod";
277
275
  import { Flags } from "@oclif/core";
276
+
277
+ // src/lib/init/utils.ts
278
+ var isLocalhost = (url) => {
279
+ return url.includes("localhost") || url.includes("127.0.0.1") || url.includes("0.0.0.0");
280
+ };
281
+
282
+ // src/lib/init/types/questions.ts
278
283
  var MODES = ["CrewAI", "LangGraph", "MCP", "Standard"];
279
284
  var CREW_TYPES = ["Crews", "Flows"];
280
285
  var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
@@ -313,18 +318,12 @@ var UrlSchema = z.preprocess(
313
318
  (val) => sanitizers.url(String(val)),
314
319
  z.string().url("Please enter a valid URL").min(1, "URL is required")
315
320
  );
316
- var TokenSchema = z.preprocess(
317
- (val) => sanitizers.trim(String(val)),
318
- z.string().min(1, "Token is required")
319
- );
321
+ var TokenSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Token is required"));
320
322
  var ApiKeySchema = z.preprocess(
321
323
  (val) => sanitizers.apiKey(String(val)),
322
324
  z.string().min(1, "API key is required")
323
325
  );
324
- var NameSchema = z.preprocess(
325
- (val) => sanitizers.trim(String(val)),
326
- z.string().min(1, "Name is required")
327
- );
326
+ var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
328
327
  var ConfigSchema = z.object({
329
328
  // Core fields
330
329
  copilotKitVersion: z.string().optional(),
@@ -334,7 +333,7 @@ var ConfigSchema = z.object({
334
333
  alreadyDeployed: YesNoSchema.optional(),
335
334
  fastApiEnabled: YesNoSchema.optional(),
336
335
  useCopilotCloud: YesNoSchema.optional(),
337
- // LangGraph specific fields
336
+ // LangGraph specific fields
338
337
  langGraphAgent: LangGraphAgentSchema.optional(),
339
338
  langGraphPlatform: YesNoSchema.optional(),
340
339
  langGraphPlatformUrl: UrlSchema.optional(),
@@ -363,7 +362,7 @@ var ConfigSchema = z.object({
363
362
  ).refine(
364
363
  (data) => {
365
364
  if (data.mode === "LangGraph" && data.alreadyDeployed === "Yes" && data.langGraphPlatform === "Yes") {
366
- return !!data.langGraphPlatformUrl && !!data.langSmithApiKey;
365
+ return !!data.langGraphPlatformUrl && !!data.langSmithApiKey || isLocalhost(data.langGraphPlatformUrl || "");
367
366
  }
368
367
  return true;
369
368
  },
@@ -373,6 +372,7 @@ var ConfigSchema = z.object({
373
372
  }
374
373
  );
375
374
  var ConfigFlags = {
375
+ booth: Flags.boolean({ description: "Use CopilotKit in booth mode", default: false, char: "b" }),
376
376
  mode: Flags.string({ description: "How you will be interacting with AI", options: MODES, char: "m" }),
377
377
  "copilotkit-version": Flags.string({ description: "CopilotKit version to use (e.g. 1.7.0)" }),
378
378
  "use-copilot-cloud": Flags.string({ description: "Use Copilot Cloud for production-ready hosting", options: YES_NO }),
@@ -390,29 +390,24 @@ var ConfigFlags = {
390
390
  var BASE_URL = "https://registry.copilotkit.ai/r";
391
391
  var templateMapping = {
392
392
  // Runtimes
393
- "RemoteEndpoint": `${BASE_URL}/remote-endpoint-starter.json`,
394
- "LangGraphPlatformRuntime": `${BASE_URL}/langgraph-platform-starter.json`,
393
+ RemoteEndpoint: `${BASE_URL}/remote-endpoint-starter.json`,
394
+ LangGraphPlatformRuntime: `${BASE_URL}/langgraph-platform-starter.json`,
395
395
  // CrewAI
396
- "CrewEnterprise": [
397
- `${BASE_URL}/coagents-crew-starter.json`
398
- ],
399
- "CrewFlowsStarter": [
396
+ CrewEnterprise: [`${BASE_URL}/coagents-crew-starter.json`],
397
+ CrewFlowsStarter: [
400
398
  `${BASE_URL}/coagents-starter-ui.json`,
401
399
  `${BASE_URL}/agent-layout.json`,
402
400
  `${BASE_URL}/remote-endpoint.json`
403
401
  ],
404
402
  // LangGraph
405
- "LangGraphGeneric": `${BASE_URL}/generic-lg-starter.json`,
406
- "LangGraphStarter": [
407
- `${BASE_URL}/langgraph-platform-starter.json`,
408
- `${BASE_URL}/coagents-starter-ui.json`
409
- ],
403
+ LangGraphGeneric: `${BASE_URL}/generic-lg-starter.json`,
404
+ LangGraphStarter: [`${BASE_URL}/langgraph-platform-starter.json`, `${BASE_URL}/coagents-starter-ui.json`],
410
405
  // No Agent
411
- "StandardStarter": `${BASE_URL}/standard-starter.json`,
412
- "StandardRuntime": `${BASE_URL}/standard-runtime.json`,
406
+ StandardStarter: `${BASE_URL}/standard-starter.json`,
407
+ StandardRuntime: `${BASE_URL}/standard-runtime.json`,
413
408
  // MCP
414
- "McpStarter": `${BASE_URL}/mcp-starter.json`,
415
- "McpRuntime": `${BASE_URL}/mcp-starter-runtime.json`
409
+ McpStarter: `${BASE_URL}/mcp-starter.json`,
410
+ McpRuntime: `${BASE_URL}/mcp-starter-runtime.json`
416
411
  };
417
412
 
418
413
  // src/lib/init/questions.ts
@@ -544,7 +539,7 @@ var questions = [
544
539
  type: "input",
545
540
  name: "langSmithApiKey",
546
541
  message: "\u{1F99C}\u{1F517} Enter your LangSmith API key (required by LangGraph Platform) :",
547
- when: (answers) => answers.mode === "LangGraph" && answers.langGraphPlatform === "Yes",
542
+ when: (answers) => answers.mode === "LangGraph" && answers.langGraphPlatform === "Yes" && !(answers.langGraphPlatformUrl && isLocalhost(answers.langGraphPlatformUrl)),
548
543
  sensitive: true,
549
544
  validate: validateRequired,
550
545
  sanitize: sanitizers.apiKey
@@ -555,7 +550,7 @@ var questions = [
555
550
  name: "useCopilotCloud",
556
551
  message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
557
552
  when: (answers) => answers.mode === "Standard" || answers.mode === "MCP" || answers.mode !== "CrewAI" && // Crews only cloud, flows are self-hosted
558
- answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No",
553
+ answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No" && !isLocalhost(answers.langGraphPlatformUrl || ""),
559
554
  validate: (input) => {
560
555
  try {
561
556
  YesNoSchema.parse(input);
@@ -578,12 +573,12 @@ var questions = [
578
573
 
579
574
  // src/lib/init/scaffold/shadcn.ts
580
575
  import spawn from "cross-spawn";
581
- async function scaffoldShadCN(userAnswers) {
576
+ async function scaffoldShadCN(flags, userAnswers) {
582
577
  try {
583
578
  const components = [];
584
579
  switch (userAnswers.mode) {
585
580
  case "LangGraph":
586
- if (userAnswers.langGraphAgent) {
581
+ if (userAnswers.langGraphAgent || flags.booth) {
587
582
  components.push(...templateMapping.LangGraphStarter);
588
583
  } else {
589
584
  components.push(templateMapping.LangGraphGeneric);
@@ -645,20 +640,17 @@ import fs from "fs";
645
640
  // src/lib/init/scaffold/langgraph-assistants.ts
646
641
  async function getLangGraphAgents(url, langSmithApiKey) {
647
642
  try {
648
- const response = await fetch(
649
- `${url.trim().replace(/\/$/, "")}/assistants/search`,
650
- {
651
- method: "POST",
652
- headers: {
653
- "Content-Type": "application/json",
654
- "X-Api-Key": langSmithApiKey
655
- },
656
- body: JSON.stringify({
657
- limit: 10,
658
- offset: 0
659
- })
660
- }
661
- );
643
+ const response = await fetch(`${url.trim().replace(/\/$/, "")}/assistants/search`, {
644
+ method: "POST",
645
+ headers: {
646
+ "Content-Type": "application/json",
647
+ "X-Api-Key": langSmithApiKey
648
+ },
649
+ body: JSON.stringify({
650
+ limit: 10,
651
+ offset: 0
652
+ })
653
+ });
662
654
  return await response.json();
663
655
  } catch (error) {
664
656
  throw new Error(`Failed to get LangGraph agents: ${error}`);
@@ -866,11 +858,7 @@ async function scaffoldAgent(userAnswers) {
866
858
  }
867
859
  const agentDir = path3.join(process.cwd(), "agent");
868
860
  try {
869
- await cloneGitHubSubdirectory(
870
- template,
871
- agentDir,
872
- spinner
873
- );
861
+ await cloneGitHubSubdirectory(template, agentDir, spinner);
874
862
  spinner.text = chalk5.cyan("Creating agent environment variables...");
875
863
  let envContent = "";
876
864
  if (userAnswers.llmToken) {
@@ -886,6 +874,20 @@ async function scaffoldAgent(userAnswers) {
886
874
  fs3.writeFileSync(agentEnvFile, envContent, "utf8");
887
875
  spinner.text = chalk5.cyan("Added API keys to agent .env file");
888
876
  }
877
+ if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
878
+ envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
879
+ `;
880
+ }
881
+ if (envContent) {
882
+ const agentEnvFile = path3.join(agentDir, ".env");
883
+ fs3.writeFileSync(agentEnvFile, envContent, "utf8");
884
+ spinner.text = chalk5.cyan("Added API keys to agent .env file");
885
+ }
886
+ if (envContent) {
887
+ const agentEnvFile = path3.join(agentDir, ".env");
888
+ fs3.writeFileSync(agentEnvFile, envContent, "utf8");
889
+ spinner.text = chalk5.cyan("Added API keys to agent .env file");
890
+ }
889
891
  } catch (error) {
890
892
  spinner.fail(chalk5.red("Failed to clone agent template"));
891
893
  throw error;
@@ -959,9 +961,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
959
961
  }
960
962
  trpcClient = null;
961
963
  static description = "Set up CopilotKit in your Next.js project";
962
- static examples = [
963
- "<%= config.bin %> init"
964
- ];
964
+ static examples = ["<%= config.bin %> init"];
965
965
  static flags = {
966
966
  ...BaseCommand.flags,
967
967
  ...ConfigFlags,
@@ -973,21 +973,59 @@ var CloudInit = class _CloudInit extends BaseCommand {
973
973
  const { flags } = await this.parse(_CloudInit);
974
974
  try {
975
975
  this.log(chalk6.magenta("\n\u{1FA81} Welcome to CopilotKit"));
976
- this.log(chalk6.gray("Let's power up your Next.js project with AI capabilities\n"));
976
+ if (flags.booth) {
977
+ this.log(chalk6.gray("Thanks for giving CopilotKit a try! Now, let's try to impress you \u{1F4AA}\n"));
978
+ } else {
979
+ this.log(chalk6.gray("Let's power up your Next.js project with AI capabilities\n"));
980
+ }
977
981
  this.validateProjectCompatibility(flags);
978
- const userAnswers = await this.getUserAnswers(flags);
982
+ let userAnswers;
983
+ if (flags.booth) {
984
+ userAnswers = await this.getBoothAnswers();
985
+ } else {
986
+ userAnswers = await this.getUserAnswers(flags);
987
+ }
979
988
  const needsCloudSetup = userAnswers.useCopilotCloud === "Yes" || userAnswers.mode === "CrewAI" && userAnswers.crewType === "Crews";
980
989
  if (needsCloudSetup) await this.setupCloud(flags, userAnswers);
981
990
  await scaffoldEnv(flags, userAnswers);
982
- await scaffoldShadCN(userAnswers);
983
- await scaffoldAgent(userAnswers);
991
+ await scaffoldShadCN(flags, userAnswers);
992
+ if (!flags.booth) await scaffoldAgent(userAnswers);
984
993
  if (userAnswers.crewType === "Crews" && userAnswers.crewUrl && userAnswers.crewBearerToken)
985
994
  await addCrewInputs(userAnswers.crewUrl, userAnswers.crewBearerToken);
986
- this.finalSummary(userAnswers);
995
+ if (flags.booth) {
996
+ this.log("\n-----\n");
997
+ this.log(chalk6.magenta("\u{1F389} Your CopilotKit setup is complete! \u{1F389}\n"));
998
+ this.log(chalk6.bold("\n\u{1F680} Next steps:"));
999
+ this.log(` - Start the Next.js app: ${chalk6.gray("$")} ${chalk6.cyan("npm run dev")}`);
1000
+ this.log(` - Navigate to ${chalk6.blue("http://localhost:3000/copilotkit")}`);
1001
+ this.log(` - Talk to your agent.`);
1002
+ this.log(chalk6.magenta("\nThanks for giving CopilotKit a try! \u{1FA81}\n"));
1003
+ } else {
1004
+ this.finalSummary(userAnswers);
1005
+ }
987
1006
  } catch (error) {
988
1007
  this.gracefulError(error.message);
989
1008
  }
990
1009
  }
1010
+ async getBoothAnswers() {
1011
+ const url = await inquirer3.prompt({
1012
+ type: "input",
1013
+ message: "\u{1F99C}\u{1F517} What is the LangGraph's agent URL?",
1014
+ name: "agentURL",
1015
+ validate: (value) => {
1016
+ if (!value) return "You need a URL to continue, it should be present on the screen. If you need help, feel free to ask!";
1017
+ if (!value.includes("http") || !value.includes("://")) return "Please provide a valid URL";
1018
+ return true;
1019
+ }
1020
+ });
1021
+ return {
1022
+ mode: "LangGraph",
1023
+ langGraphPlatformUrl: url.agentURL,
1024
+ useCopilotCloud: "No",
1025
+ alreadyDeployed: "Yes",
1026
+ langGraphPlatform: "Yes"
1027
+ };
1028
+ }
991
1029
  async getUserAnswers(flags) {
992
1030
  const initialAnswers = {};
993
1031
  Object.keys(flags).forEach((flagName) => {
@@ -1048,7 +1086,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
1048
1086
  const promptAnswers = await inquirer3.prompt(inquirerQuestions);
1049
1087
  const answers = { ...initialAnswers, ...promptAnswers };
1050
1088
  if (answers.langGraphPlatform === "No") {
1051
- this.log("\nCurrently the CLI only supports scaffolding LangGraph Platform agents. Use our quickstart guide to get started:\n");
1089
+ this.log(
1090
+ "\nCurrently the CLI only supports scaffolding LangGraph Platform agents. Use our quickstart guide to get started:\n"
1091
+ );
1052
1092
  this.log(chalk6.blue("https://docs.copilotkit.ai/coagents/quickstart/langgraph"));
1053
1093
  process.exit(0);
1054
1094
  }
@@ -1060,9 +1100,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
1060
1100
  } catch (error) {
1061
1101
  const spinner = ora5({ text: "Validation failed...", color: "red" }).start();
1062
1102
  if (error.errors) {
1063
- const formattedErrors = error.errors.map(
1064
- (err) => `- ${err.path.join(".")}: ${err.message}`
1065
- ).join("\n");
1103
+ const formattedErrors = error.errors.map((err) => `- ${err.path.join(".")}: ${err.message}`).join("\n");
1066
1104
  spinner.fail(chalk6.red("Configuration validation failed:"));
1067
1105
  console.error(chalk6.red(formattedErrors));
1068
1106
  process.exit(1);
@@ -1098,7 +1136,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
1098
1136
  ]);
1099
1137
  selectedProjectId = projectId;
1100
1138
  }
1101
- const copilotCloudPublicApiKey = await this.trpcClient.getCopilotCloudPublicApiKey.query({ projectId: selectedProjectId });
1139
+ const copilotCloudPublicApiKey = await this.trpcClient.getCopilotCloudPublicApiKey.query({
1140
+ projectId: selectedProjectId
1141
+ });
1102
1142
  try {
1103
1143
  const sanitizedConfig = {
1104
1144
  ...userAnswers,
@@ -1201,7 +1241,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
1201
1241
  const packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
1202
1242
  if (!packageJson.dependencies?.next && !packageJson.devDependencies?.next) {
1203
1243
  spinner.fail(`Not a Next.js project`);
1204
- throw new Error(`Directory ${projectPath} does not appear to be a Next.js project. Make sure it has next in dependencies.`);
1244
+ throw new Error(
1245
+ `Directory ${projectPath} does not appear to be a Next.js project. Make sure it has next in dependencies.`
1246
+ );
1205
1247
  }
1206
1248
  spinner.succeed(`\u{1F53C} Valid Next.js project detected at ${projectPath}`);
1207
1249
  return true;
@@ -1261,7 +1303,8 @@ var CloudInit = class _CloudInit extends BaseCommand {
1261
1303
  if (userAnswers.useCopilotCloud || userAnswers.crewType === "Crews") this.log(` - With Copilot Cloud.`);
1262
1304
  this.log(chalk6.bold("\n\u{1F680} Next steps:"));
1263
1305
  this.log(` - Start your Next.js app: ${chalk6.gray("$")} ${chalk6.cyan("npm run dev")}`);
1264
- if (agentDevInstructions) this.log(` - Start your agent: ${chalk6.gray("$")} ${chalk6.cyan(`cd agent && ${agentDevInstructions}`)}`);
1306
+ if (agentDevInstructions)
1307
+ this.log(` - Start your agent: ${chalk6.gray("$")} ${chalk6.cyan(`cd agent && ${agentDevInstructions}`)}`);
1265
1308
  this.log(` - Navigate to ${chalk6.blue("http://localhost:3000/copilotkit")}`);
1266
1309
  this.log(` - Talk to your agent.`);
1267
1310
  this.log(` - Read the docs: ${chalk6.blue("https://docs.copilotkit.ai")}`);