copilotkit 0.0.41 → 0.0.42-alpha.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/dist/commands/base-command.js +1 -1
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/dev.js +51 -11
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +14 -0
- package/dist/commands/init.js +356 -27
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +50 -10
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +50 -10
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/index.js +21 -1
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +21 -1
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +6 -0
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +6 -0
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.js +6 -0
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +14 -6
- package/dist/lib/init/types/questions.js +6 -0
- package/dist/lib/init/types/questions.js.map +1 -1
- package/dist/services/analytics.service.d.ts +9 -0
- package/dist/services/analytics.service.js +33 -0
- package/dist/services/analytics.service.js.map +1 -1
- package/dist/services/auth.service.d.ts +1 -1
- package/dist/services/auth.service.js +49 -9
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/events.d.ts +43 -0
- 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 +2 -1
package/dist/commands/init.js
CHANGED
|
@@ -38,6 +38,7 @@ function createTRPCClient(cliToken) {
|
|
|
38
38
|
|
|
39
39
|
// src/services/analytics.service.ts
|
|
40
40
|
import { Analytics } from "@segment/analytics-node";
|
|
41
|
+
import { PostHog } from "posthog-node";
|
|
41
42
|
import Conf from "conf";
|
|
42
43
|
var AnalyticsService = class {
|
|
43
44
|
constructor(authData) {
|
|
@@ -63,12 +64,20 @@ var AnalyticsService = class {
|
|
|
63
64
|
writeKey: segmentWriteKey,
|
|
64
65
|
disable: process.env.SEGMENT_DISABLE === "true"
|
|
65
66
|
});
|
|
67
|
+
if (process.env.POSTHOG_DISABLED !== "true") {
|
|
68
|
+
const posthogKey = process.env.POSTHOG_KEY || "phc_XZdymVYjrph9Mi0xZYGNyCKexxgblXRR1jMENCtdz5Q";
|
|
69
|
+
const posthogHost = process.env.POSTHOG_HOST || "https://eu.i.posthog.com";
|
|
70
|
+
this.posthog = new PostHog(posthogKey, {
|
|
71
|
+
host: posthogHost
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
const config = new Conf({ projectName: "CopilotKitCLI" });
|
|
67
75
|
if (!config.get("anonymousId")) {
|
|
68
76
|
config.set("anonymousId", crypto.randomUUID());
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
segment;
|
|
80
|
+
posthog;
|
|
72
81
|
globalProperties = {};
|
|
73
82
|
userId;
|
|
74
83
|
email;
|
|
@@ -113,6 +122,30 @@ var AnalyticsService = class {
|
|
|
113
122
|
});
|
|
114
123
|
});
|
|
115
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Check if a feature flag is enabled
|
|
127
|
+
*/
|
|
128
|
+
async isFeatureEnabled(flagKey) {
|
|
129
|
+
if (!this.posthog) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const distinctId = this.userId || this.getAnonymousId();
|
|
134
|
+
const flag = await this.posthog.isFeatureEnabled(flagKey, distinctId);
|
|
135
|
+
return Boolean(flag);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.warn(`Failed to check feature flag ${flagKey}:`, error);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Shutdown analytics services
|
|
143
|
+
*/
|
|
144
|
+
async shutdown() {
|
|
145
|
+
if (this.posthog) {
|
|
146
|
+
await this.posthog.shutdown();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
116
149
|
};
|
|
117
150
|
|
|
118
151
|
// src/services/auth.service.ts
|
|
@@ -129,19 +162,26 @@ var AuthService = class {
|
|
|
129
162
|
async logout(cmd) {
|
|
130
163
|
this.config.delete("cliToken");
|
|
131
164
|
}
|
|
132
|
-
async requireLogin(cmd) {
|
|
165
|
+
async requireLogin(cmd, context) {
|
|
133
166
|
let cliToken = this.getCLIToken();
|
|
134
167
|
if (!cliToken) {
|
|
135
168
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
169
|
+
let shouldLogin = true;
|
|
170
|
+
if (context !== "cloud-features") {
|
|
171
|
+
const response = await inquirer.prompt([
|
|
172
|
+
{
|
|
173
|
+
name: "shouldLogin",
|
|
174
|
+
type: "confirm",
|
|
175
|
+
message: "\u{1FA81} You are not yet authenticated. Authenticate with Copilot Cloud? (press Enter to confirm)",
|
|
176
|
+
default: true
|
|
177
|
+
}
|
|
178
|
+
]);
|
|
179
|
+
shouldLogin = response.shouldLogin;
|
|
180
|
+
}
|
|
144
181
|
if (shouldLogin) {
|
|
182
|
+
if (context === "cloud-features") {
|
|
183
|
+
cmd.log(chalk.cyan("\n\u{1F680} Setting up Copilot Cloud authentication for your selected features...\n"));
|
|
184
|
+
}
|
|
145
185
|
const loginResult = await this.login({ exitAfterLogin: false });
|
|
146
186
|
cliToken = loginResult.cliToken;
|
|
147
187
|
return loginResult;
|
|
@@ -222,7 +262,7 @@ import { Command } from "@oclif/core";
|
|
|
222
262
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
223
263
|
|
|
224
264
|
// src/utils/version.ts
|
|
225
|
-
var LIB_VERSION = "0.0.
|
|
265
|
+
var LIB_VERSION = "0.0.42-alpha.0";
|
|
226
266
|
|
|
227
267
|
// src/commands/base-command.ts
|
|
228
268
|
import chalk2 from "chalk";
|
|
@@ -326,6 +366,8 @@ var ApiKeySchema = z.preprocess(
|
|
|
326
366
|
var LLMApiKeySchema = z.preprocess((val) => sanitizers.apiKey(String(val)), z.string().optional());
|
|
327
367
|
var NameSchema = z.preprocess((val) => sanitizers.trim(String(val)), z.string().min(1, "Name is required"));
|
|
328
368
|
var ConfigSchema = z.object({
|
|
369
|
+
// NEW: Early signup field
|
|
370
|
+
signupForCopilotCloud: YesNoSchema.optional(),
|
|
329
371
|
// Core fields
|
|
330
372
|
copilotKitVersion: z.string().optional(),
|
|
331
373
|
mode: ModeSchema,
|
|
@@ -376,6 +418,10 @@ var ConfigSchema = z.object({
|
|
|
376
418
|
);
|
|
377
419
|
var ConfigFlags = {
|
|
378
420
|
booth: Flags.boolean({ description: "Use CopilotKit in booth mode", default: false, char: "b" }),
|
|
421
|
+
"signup-for-copilot-cloud": Flags.string({
|
|
422
|
+
description: "Sign up for Copilot Cloud for error tracking and debugging insights",
|
|
423
|
+
options: YES_NO
|
|
424
|
+
}),
|
|
379
425
|
mode: Flags.string({ description: "How you will be interacting with AI", options: MODES, char: "m" }),
|
|
380
426
|
"copilotkit-version": Flags.string({ description: "CopilotKit version to use (e.g. 1.7.0)" }),
|
|
381
427
|
"use-copilot-cloud": Flags.string({ description: "Use Copilot Cloud for production-ready hosting", options: YES_NO }),
|
|
@@ -579,7 +625,21 @@ var validateRequired = (input) => {
|
|
|
579
625
|
return sanitizers.trim(input) ? true : "This field is required";
|
|
580
626
|
};
|
|
581
627
|
var questions = [
|
|
582
|
-
//
|
|
628
|
+
// NEW: Early signup question - first question for maximum visibility
|
|
629
|
+
{
|
|
630
|
+
type: "yes/no",
|
|
631
|
+
name: "signupForCopilotCloud",
|
|
632
|
+
message: "\u{1FA81} Sign up for Copilot Cloud to enable error tracking and get production-ready hosting? (Recommended)",
|
|
633
|
+
validate: (input) => {
|
|
634
|
+
try {
|
|
635
|
+
YesNoSchema.parse(input);
|
|
636
|
+
return true;
|
|
637
|
+
} catch (error) {
|
|
638
|
+
return "Please select Yes or No";
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
// Core setup questions - always shown after signup
|
|
583
643
|
{
|
|
584
644
|
type: "select",
|
|
585
645
|
name: "mode",
|
|
@@ -1128,6 +1188,9 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1128
1188
|
this.authService = authService;
|
|
1129
1189
|
}
|
|
1130
1190
|
trpcClient = null;
|
|
1191
|
+
analytics = null;
|
|
1192
|
+
startTime = Date.now();
|
|
1193
|
+
analyticsQueue = [];
|
|
1131
1194
|
static description = "Set up CopilotKit in your Next.js project";
|
|
1132
1195
|
static examples = ["<%= config.bin %> init"];
|
|
1133
1196
|
static flags = {
|
|
@@ -1140,19 +1203,31 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1140
1203
|
async run() {
|
|
1141
1204
|
const { flags } = await this.parse(_CloudInit);
|
|
1142
1205
|
try {
|
|
1206
|
+
this.analytics = new AnalyticsService();
|
|
1143
1207
|
this.log(chalk7.magenta("\n\u{1FA81} Welcome to CopilotKit"));
|
|
1144
1208
|
if (flags.booth) {
|
|
1145
1209
|
this.log(chalk7.gray("Thanks for giving CopilotKit a try! Now, let's try to impress you \u{1F4AA}\n"));
|
|
1146
1210
|
} else {
|
|
1147
1211
|
this.log(chalk7.gray("Let's power up your Next.js project with AI capabilities\n"));
|
|
1148
1212
|
}
|
|
1149
|
-
this.validateProjectCompatibility(flags);
|
|
1213
|
+
const projectValidated = this.validateProjectCompatibility(flags);
|
|
1214
|
+
this.queueAnalytics("cli.init.started", {
|
|
1215
|
+
nextjs_detected: projectValidated,
|
|
1216
|
+
flags_used: Object.keys(flags).filter((key) => flags[key] !== void 0 && key !== "help")
|
|
1217
|
+
});
|
|
1150
1218
|
let userAnswers;
|
|
1219
|
+
let cloudSetupInfo = null;
|
|
1151
1220
|
if (flags.booth) {
|
|
1152
1221
|
userAnswers = await this.getBoothAnswers();
|
|
1153
1222
|
} else {
|
|
1154
|
-
|
|
1223
|
+
const result = await this.getUserAnswers(flags);
|
|
1224
|
+
userAnswers = result.config;
|
|
1225
|
+
cloudSetupInfo = result.cloudSetupInfo;
|
|
1155
1226
|
}
|
|
1227
|
+
this.queueAnalytics("cli.init.mode_selected", {
|
|
1228
|
+
mode: userAnswers.mode,
|
|
1229
|
+
early_signup_completed: !!cloudSetupInfo
|
|
1230
|
+
});
|
|
1156
1231
|
if (userAnswers.mode === "Mastra") {
|
|
1157
1232
|
this.log(chalk7.magenta(`
|
|
1158
1233
|
\u{1F517} Please go to https://docs.copilotkit.ai/mastra/quickstart to get started.`));
|
|
@@ -1170,11 +1245,28 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1170
1245
|
\u{1F517} Please go to https://docs.copilotkit.ai/llamaindex/quickstart to get started.`));
|
|
1171
1246
|
process.exit(0);
|
|
1172
1247
|
}
|
|
1173
|
-
const
|
|
1174
|
-
if (
|
|
1248
|
+
const needsCloudDeployment = userAnswers.useCopilotCloud === "Yes" || userAnswers.mode === "CrewAI";
|
|
1249
|
+
if (userAnswers.useCopilotCloud) {
|
|
1250
|
+
this.queueAnalytics("cli.init.cloud_deployment_selected", {
|
|
1251
|
+
choice: userAnswers.useCopilotCloud,
|
|
1252
|
+
mode: userAnswers.mode,
|
|
1253
|
+
early_signup_completed: !!cloudSetupInfo
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
if (needsCloudDeployment) {
|
|
1257
|
+
if (cloudSetupInfo) {
|
|
1258
|
+
await this.completeCloudDeploymentSetup(flags, userAnswers, cloudSetupInfo);
|
|
1259
|
+
} else {
|
|
1260
|
+
await this.setupCloud(flags, userAnswers);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1175
1263
|
await scaffoldEnv(flags, userAnswers);
|
|
1176
1264
|
await scaffoldShadCN(flags, userAnswers);
|
|
1177
|
-
|
|
1265
|
+
let agentScaffolded = false;
|
|
1266
|
+
if (!flags.booth) {
|
|
1267
|
+
await scaffoldAgent(userAnswers);
|
|
1268
|
+
agentScaffolded = true;
|
|
1269
|
+
}
|
|
1178
1270
|
if (userAnswers.crewUrl && userAnswers.crewBearerToken)
|
|
1179
1271
|
await addCrewInputs(userAnswers.crewUrl, userAnswers.crewBearerToken);
|
|
1180
1272
|
if (userAnswers.setupIDEDocs === "Yes" && userAnswers.selectedIDE !== "skip") {
|
|
@@ -1188,6 +1280,15 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1188
1280
|
ideDocsSpinner.fail("IDE documentation setup failed, but you can configure it manually later");
|
|
1189
1281
|
}
|
|
1190
1282
|
}
|
|
1283
|
+
this.queueAnalytics("cli.init.completed", {
|
|
1284
|
+
mode: userAnswers.mode,
|
|
1285
|
+
early_signup_completed: !!cloudSetupInfo,
|
|
1286
|
+
cloud_deployment: needsCloudDeployment,
|
|
1287
|
+
agent_scaffolded: agentScaffolded,
|
|
1288
|
+
api_key_in_env: !!userAnswers.copilotCloudPublicApiKey,
|
|
1289
|
+
duration_ms: Date.now() - this.startTime
|
|
1290
|
+
});
|
|
1291
|
+
await this.flushAnalytics();
|
|
1191
1292
|
if (flags.booth) {
|
|
1192
1293
|
this.log("\n-----\n");
|
|
1193
1294
|
this.log(chalk7.magenta("\u{1F389} Your CopilotKit setup is complete! \u{1F389}\n"));
|
|
@@ -1200,9 +1301,39 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1200
1301
|
this.finalSummary(userAnswers);
|
|
1201
1302
|
}
|
|
1202
1303
|
} catch (error) {
|
|
1304
|
+
this.queueAnalytics("cli.init.failed", {
|
|
1305
|
+
error: error.message,
|
|
1306
|
+
step: "unknown",
|
|
1307
|
+
duration_ms: Date.now() - this.startTime
|
|
1308
|
+
});
|
|
1309
|
+
await this.flushAnalytics();
|
|
1203
1310
|
this.gracefulError(error.message);
|
|
1204
1311
|
}
|
|
1205
1312
|
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Queue an analytics event to be sent later (non-blocking)
|
|
1315
|
+
*/
|
|
1316
|
+
queueAnalytics(event, properties) {
|
|
1317
|
+
this.analyticsQueue.push({ event, properties });
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Send all queued analytics events in fire-and-forget manner
|
|
1321
|
+
*/
|
|
1322
|
+
async flushAnalytics() {
|
|
1323
|
+
if (!this.analytics || this.analyticsQueue.length === 0) {
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
const promises = this.analyticsQueue.map(
|
|
1327
|
+
({ event, properties }) => this.analytics.track({ event, properties }).catch(() => {
|
|
1328
|
+
})
|
|
1329
|
+
);
|
|
1330
|
+
Promise.all(promises).catch(() => {
|
|
1331
|
+
});
|
|
1332
|
+
if (this.analytics) {
|
|
1333
|
+
this.analytics.shutdown().catch(() => {
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1206
1337
|
async getBoothAnswers() {
|
|
1207
1338
|
const url = await inquirer3.prompt({
|
|
1208
1339
|
type: "input",
|
|
@@ -1235,14 +1366,72 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1235
1366
|
}
|
|
1236
1367
|
}
|
|
1237
1368
|
});
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1369
|
+
let signupAnswer = initialAnswers.signupForCopilotCloud;
|
|
1370
|
+
let isCloudByDefault = false;
|
|
1371
|
+
try {
|
|
1372
|
+
isCloudByDefault = await this.analytics.isFeatureEnabled("cloud-by-default");
|
|
1373
|
+
} catch {
|
|
1374
|
+
}
|
|
1375
|
+
if (!signupAnswer) {
|
|
1376
|
+
if (isCloudByDefault) {
|
|
1377
|
+
this.queueAnalytics("cli.init.early_signup_prompt_shown", {});
|
|
1378
|
+
const signupResult = await inquirer3.prompt([
|
|
1379
|
+
{
|
|
1380
|
+
type: "list",
|
|
1381
|
+
name: "signupForCopilotCloud",
|
|
1382
|
+
message: "\u{1FA81} Sign up for Copilot Cloud to enable error tracking and get production-ready hosting? (Recommended)",
|
|
1383
|
+
choices: ["Yes", "No"]
|
|
1384
|
+
}
|
|
1385
|
+
]);
|
|
1386
|
+
signupAnswer = signupResult.signupForCopilotCloud;
|
|
1387
|
+
} else {
|
|
1388
|
+
signupAnswer = "No";
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
if (isCloudByDefault || initialAnswers.signupForCopilotCloud) {
|
|
1392
|
+
this.queueAnalytics("cli.init.early_signup_selected", {
|
|
1393
|
+
choice: signupAnswer,
|
|
1394
|
+
cloud_by_default_enabled: isCloudByDefault
|
|
1242
1395
|
});
|
|
1243
|
-
this.log("");
|
|
1244
1396
|
}
|
|
1245
|
-
|
|
1397
|
+
let cloudSetupInfo = null;
|
|
1398
|
+
let earlyApiKey;
|
|
1399
|
+
if (signupAnswer === "Yes") {
|
|
1400
|
+
try {
|
|
1401
|
+
const tempConfig = { ...initialAnswers, signupForCopilotCloud: signupAnswer };
|
|
1402
|
+
const earlySignupResult = await this.handleEarlyCloudSignup(flags, tempConfig);
|
|
1403
|
+
cloudSetupInfo = earlySignupResult;
|
|
1404
|
+
earlyApiKey = earlySignupResult.apiKey;
|
|
1405
|
+
if (this.analytics && cloudSetupInfo.cliToken) {
|
|
1406
|
+
const trpcClient2 = createTRPCClient(cloudSetupInfo.cliToken);
|
|
1407
|
+
const me = await trpcClient2.me.query();
|
|
1408
|
+
if (me.user && me.organization) {
|
|
1409
|
+
this.analytics = new AnalyticsService({
|
|
1410
|
+
userId: me.user.id,
|
|
1411
|
+
organizationId: me.organization.id,
|
|
1412
|
+
email: me.user.email
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
this.queueAnalytics("cli.init.early_signup_completed", {
|
|
1417
|
+
userId: cloudSetupInfo.organization?.id || "unknown",
|
|
1418
|
+
organizationId: cloudSetupInfo.organization?.id || "unknown",
|
|
1419
|
+
email: "unknown",
|
|
1420
|
+
// Will be updated when we get user info
|
|
1421
|
+
projectId: cloudSetupInfo.selectedProjectId || "unknown",
|
|
1422
|
+
api_key_retrieved: !!earlyApiKey
|
|
1423
|
+
});
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
this.queueAnalytics("cli.init.early_signup_failed", {
|
|
1426
|
+
error: error.message,
|
|
1427
|
+
step: "auth"
|
|
1428
|
+
// Could be more specific based on where it failed
|
|
1429
|
+
});
|
|
1430
|
+
throw error;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
const remainingQuestions = questions.slice(1);
|
|
1434
|
+
const inquirerQuestions = remainingQuestions.map((q) => {
|
|
1246
1435
|
if (initialAnswers[q.name] !== void 0) {
|
|
1247
1436
|
return null;
|
|
1248
1437
|
}
|
|
@@ -1250,7 +1439,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1250
1439
|
name: q.name,
|
|
1251
1440
|
message: q.message,
|
|
1252
1441
|
when: (answers2) => {
|
|
1253
|
-
const combinedAnswers = { ...initialAnswers, ...answers2 };
|
|
1442
|
+
const combinedAnswers = { ...initialAnswers, signupForCopilotCloud: signupAnswer, ...answers2 };
|
|
1254
1443
|
return q.when ? q.when(combinedAnswers) : true;
|
|
1255
1444
|
},
|
|
1256
1445
|
default: q.default,
|
|
@@ -1281,7 +1470,13 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1281
1470
|
}
|
|
1282
1471
|
}).filter((q) => q !== null);
|
|
1283
1472
|
const promptAnswers = await inquirer3.prompt(inquirerQuestions);
|
|
1284
|
-
const answers = {
|
|
1473
|
+
const answers = {
|
|
1474
|
+
...initialAnswers,
|
|
1475
|
+
signupForCopilotCloud: signupAnswer,
|
|
1476
|
+
...promptAnswers,
|
|
1477
|
+
...earlyApiKey && { copilotCloudPublicApiKey: earlyApiKey }
|
|
1478
|
+
// Add API key if we got one from early signup
|
|
1479
|
+
};
|
|
1285
1480
|
if (answers.langGraphPlatform === "No") {
|
|
1286
1481
|
this.log(
|
|
1287
1482
|
"\nCurrently the CLI only supports scaffolding LangGraph Platform agents. Use our quickstart guide to get started:\n"
|
|
@@ -1293,7 +1488,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1293
1488
|
const spinner = ora5({ text: "Validating configuration...", color: "green" }).start();
|
|
1294
1489
|
const validatedConfig = ConfigSchema.parse(answers);
|
|
1295
1490
|
spinner.succeed(`\u{1F50D} Configuration validated successfully`);
|
|
1296
|
-
return validatedConfig;
|
|
1491
|
+
return { config: validatedConfig, cloudSetupInfo };
|
|
1297
1492
|
} catch (error) {
|
|
1298
1493
|
const spinner = ora5({ text: "Validation failed...", color: "red" }).start();
|
|
1299
1494
|
if (error.errors) {
|
|
@@ -1308,7 +1503,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1308
1503
|
}
|
|
1309
1504
|
}
|
|
1310
1505
|
async setupCloud(flags, userAnswers) {
|
|
1311
|
-
const { cliToken, organization } = await this.authService.requireLogin(this);
|
|
1506
|
+
const { cliToken, organization } = await this.authService.requireLogin(this, "cloud-features");
|
|
1312
1507
|
this.trpcClient = createTRPCClient(cliToken);
|
|
1313
1508
|
const availableProjects = await this.trpcClient.listOrgProjects.query({ orgId: organization.id });
|
|
1314
1509
|
let selectedProjectId;
|
|
@@ -1423,6 +1618,129 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1423
1618
|
}
|
|
1424
1619
|
}
|
|
1425
1620
|
}
|
|
1621
|
+
async handleEarlyCloudSignup(flags, userAnswers) {
|
|
1622
|
+
this.log(chalk7.cyan("\n\u{1F680} Great choice! Let's get you set up with Copilot Cloud...\n"));
|
|
1623
|
+
const { cliToken, organization } = await this.authService.requireLogin(this, "cloud-features");
|
|
1624
|
+
this.trpcClient = createTRPCClient(cliToken);
|
|
1625
|
+
const availableProjects = await this.trpcClient.listOrgProjects.query({ orgId: organization.id });
|
|
1626
|
+
let selectedProjectId;
|
|
1627
|
+
if (flags.project) {
|
|
1628
|
+
if (!availableProjects.some((project) => project.id === flags.project)) {
|
|
1629
|
+
this.log(chalk7.red(`\u{1F4C1} Project with ID ${flags.project} not found`));
|
|
1630
|
+
process.exit(1);
|
|
1631
|
+
}
|
|
1632
|
+
selectedProjectId = flags.project;
|
|
1633
|
+
this.log(chalk7.green(`\u{1F4C1} Selected project ${selectedProjectId}`));
|
|
1634
|
+
} else if (availableProjects.length === 1) {
|
|
1635
|
+
selectedProjectId = availableProjects[0].id;
|
|
1636
|
+
this.log(chalk7.green(`\u{1F4C1} Auto-selected project ${selectedProjectId}`));
|
|
1637
|
+
} else {
|
|
1638
|
+
const { projectId } = await inquirer3.prompt([
|
|
1639
|
+
{
|
|
1640
|
+
name: "projectId",
|
|
1641
|
+
type: "list",
|
|
1642
|
+
message: "\u{1F4C1} Choose a project:",
|
|
1643
|
+
choices: availableProjects.map((project) => ({
|
|
1644
|
+
value: project.id,
|
|
1645
|
+
name: `${project.name} (ID: ${project.id})`
|
|
1646
|
+
}))
|
|
1647
|
+
}
|
|
1648
|
+
]);
|
|
1649
|
+
selectedProjectId = projectId;
|
|
1650
|
+
}
|
|
1651
|
+
let apiKey;
|
|
1652
|
+
if (selectedProjectId) {
|
|
1653
|
+
const spinner = ora5({
|
|
1654
|
+
text: "Setting up error tracking and debugging insights...",
|
|
1655
|
+
color: "cyan"
|
|
1656
|
+
}).start();
|
|
1657
|
+
try {
|
|
1658
|
+
const copilotCloudPublicApiKey = await this.trpcClient.getCopilotCloudPublicApiKey.query({
|
|
1659
|
+
projectId: selectedProjectId
|
|
1660
|
+
});
|
|
1661
|
+
apiKey = copilotCloudPublicApiKey?.key;
|
|
1662
|
+
spinner.succeed("\u2705 Error tracking and debugging insights enabled");
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
spinner.fail("Failed to set up error tracking, but continuing with setup");
|
|
1665
|
+
console.error(error);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
this.log(chalk7.green("\u2705 Copilot Cloud setup complete! Error tracking enabled for better debugging.\n"));
|
|
1669
|
+
return { cliToken, organization, selectedProjectId, apiKey };
|
|
1670
|
+
}
|
|
1671
|
+
async completeCloudDeploymentSetup(flags, userAnswers, cloudSetupInfo) {
|
|
1672
|
+
if (!this.trpcClient) {
|
|
1673
|
+
this.trpcClient = createTRPCClient(cloudSetupInfo.cliToken);
|
|
1674
|
+
}
|
|
1675
|
+
const selectedProjectId = cloudSetupInfo.selectedProjectId;
|
|
1676
|
+
if (userAnswers.crewUrl && userAnswers.crewName && userAnswers.crewBearerToken) {
|
|
1677
|
+
const isFlow = userAnswers.crewType === "Flows";
|
|
1678
|
+
const crewSpinner = ora5({
|
|
1679
|
+
text: chalk7(`\u{1F465} Adding CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud...`),
|
|
1680
|
+
color: "cyan"
|
|
1681
|
+
}).start();
|
|
1682
|
+
try {
|
|
1683
|
+
await this.trpcClient.createRemoteEndpoint.mutate({
|
|
1684
|
+
type: isFlow ? "CrewAIFlows" : "CrewAI",
|
|
1685
|
+
projectId: selectedProjectId,
|
|
1686
|
+
config: {
|
|
1687
|
+
type: isFlow ? "CrewAIFlows" : "CrewAI",
|
|
1688
|
+
url: userAnswers.crewUrl,
|
|
1689
|
+
agentName: userAnswers.crewName,
|
|
1690
|
+
agentDescription: `A helpful CrewAI ${isFlow ? "Flow" : "Crew"}`,
|
|
1691
|
+
crewApiBearerToken: userAnswers.crewBearerToken
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
crewSpinner.succeed(chalk7(`\u{1F465} CrewAI ${isFlow ? "Flow" : "Crew"} added to Copilot Cloud`));
|
|
1695
|
+
} catch (error) {
|
|
1696
|
+
crewSpinner.fail(chalk7(`\u{1F465} Failed to add CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud`));
|
|
1697
|
+
console.error(error);
|
|
1698
|
+
process.exit(1);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (userAnswers.mode === "LangGraph" && userAnswers.useCopilotCloud === "Yes" && userAnswers.alreadyDeployed === "Yes") {
|
|
1702
|
+
const langGraphSpinner = ora5({
|
|
1703
|
+
text: chalk7("\u{1F99C}\u{1F517} Adding LangGraph to Copilot Cloud..."),
|
|
1704
|
+
color: "cyan"
|
|
1705
|
+
}).start();
|
|
1706
|
+
if (userAnswers.langGraphPlatform === "Yes" && userAnswers.langGraphPlatformUrl) {
|
|
1707
|
+
try {
|
|
1708
|
+
if (!userAnswers.langSmithApiKey) {
|
|
1709
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} LangSmith API key not found. Please provide a valid LangSmith API key."));
|
|
1710
|
+
process.exit(1);
|
|
1711
|
+
}
|
|
1712
|
+
await this.trpcClient.createLGCRemoteEndpoint.mutate({
|
|
1713
|
+
type: "LangGraphCloud",
|
|
1714
|
+
projectId: selectedProjectId,
|
|
1715
|
+
config: {
|
|
1716
|
+
deploymentUrl: userAnswers.langGraphPlatformUrl,
|
|
1717
|
+
langsmithApiKey: userAnswers.langSmithApiKey,
|
|
1718
|
+
agents: []
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
langGraphSpinner.succeed(chalk7("\u{1F99C}\u{1F517} LangGraph Cloud remote endpoint created"));
|
|
1722
|
+
} catch (error) {
|
|
1723
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} Failed to create LangGraph Cloud remote endpoint. Please try again."));
|
|
1724
|
+
process.exit(1);
|
|
1725
|
+
}
|
|
1726
|
+
} else if (userAnswers.langGraphRemoteEndpointURL) {
|
|
1727
|
+
try {
|
|
1728
|
+
await this.trpcClient.createRemoteEndpoint.mutate({
|
|
1729
|
+
type: "CopilotKit",
|
|
1730
|
+
projectId: selectedProjectId,
|
|
1731
|
+
config: {
|
|
1732
|
+
type: "CopilotKit",
|
|
1733
|
+
url: userAnswers.langGraphRemoteEndpointURL
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
langGraphSpinner.succeed(chalk7("\u{1F99C}\u{1F517} LangGraph remote endpoint created"));
|
|
1737
|
+
} catch (error) {
|
|
1738
|
+
langGraphSpinner.fail(chalk7("\u{1F99C}\u{1F517} Failed to create LangGraph remote endpoint. Please try again."));
|
|
1739
|
+
process.exit(1);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1426
1744
|
validateProjectCompatibility(flags) {
|
|
1427
1745
|
const spinner = ora5("Checking Next.js project compatibility...").start();
|
|
1428
1746
|
try {
|
|
@@ -1497,13 +1815,24 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1497
1815
|
this.log(chalk7.bold(`\u{1F4CB} Recap`));
|
|
1498
1816
|
this.log(` - CopilotKit has been added to your Next.js app.`);
|
|
1499
1817
|
if (agentSetupMessage) this.log(` - ${agentSetupMessage}`);
|
|
1500
|
-
if (userAnswers.
|
|
1818
|
+
if (userAnswers.signupForCopilotCloud === "Yes") {
|
|
1819
|
+
if (userAnswers.useCopilotCloud === "Yes" || userAnswers.crewType === "Crews") {
|
|
1820
|
+
this.log(` - \u{1F680} Configured for Copilot Cloud deployment with error tracking.`);
|
|
1821
|
+
} else {
|
|
1822
|
+
this.log(` - \u{1F41B} Error tracking enabled for better debugging and insights.`);
|
|
1823
|
+
}
|
|
1824
|
+
} else if (userAnswers.useCopilotCloud === "Yes" || userAnswers.crewType === "Crews") {
|
|
1825
|
+
this.log(` - \u{1F680} Configured for Copilot Cloud deployment.`);
|
|
1826
|
+
}
|
|
1501
1827
|
this.log(chalk7.bold("\n\u{1F680} Next steps:"));
|
|
1502
1828
|
this.log(` - Start your Next.js app: ${chalk7.gray("$")} ${chalk7.cyan("npm run dev")}`);
|
|
1503
1829
|
if (agentDevInstructions)
|
|
1504
1830
|
this.log(` - Start your agent: ${chalk7.gray("$")} ${chalk7.cyan(`cd agent && ${agentDevInstructions}`)}`);
|
|
1505
1831
|
this.log(` - Navigate to ${chalk7.blue("http://localhost:3000/copilotkit")}`);
|
|
1506
1832
|
this.log(` - Talk to your agent.`);
|
|
1833
|
+
if (userAnswers.copilotCloudPublicApiKey) {
|
|
1834
|
+
this.log(` - \u{1F41B} Errors and performance data will be visible in your Copilot Cloud dashboard.`);
|
|
1835
|
+
}
|
|
1507
1836
|
if (userAnswers.setupIDEDocs === "Yes" && userAnswers.selectedIDE !== "skip") {
|
|
1508
1837
|
this.log(` - Your IDE now has CopilotKit documentation context for better AI assistance.`);
|
|
1509
1838
|
}
|