copilotkit 1.54.0 → 2.0.1

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 (150) hide show
  1. package/index.js +90052 -0
  2. package/package.json +4 -114
  3. package/src/commands/docs.d.ts +17 -0
  4. package/src/commands/docs.d.ts.map +1 -0
  5. package/src/commands/init.d.ts +103 -0
  6. package/src/commands/init.d.ts.map +1 -0
  7. package/src/commands/kite.d.ts +8 -0
  8. package/src/commands/kite.d.ts.map +1 -0
  9. package/src/commands/license.d.ts +17 -0
  10. package/src/commands/license.d.ts.map +1 -0
  11. package/src/commands/login.d.ts +13 -0
  12. package/src/commands/login.d.ts.map +1 -0
  13. package/src/commands/logs.d.ts +32 -0
  14. package/src/commands/logs.d.ts.map +1 -0
  15. package/src/commands/version.d.ts +8 -0
  16. package/src/commands/version.d.ts.map +1 -0
  17. package/src/config.d.ts +31 -0
  18. package/src/config.d.ts.map +1 -0
  19. package/src/index.d.ts +21 -0
  20. package/src/index.d.ts.map +1 -0
  21. package/src/services/agentcore-config.d.ts +34 -0
  22. package/src/services/agentcore-config.d.ts.map +1 -0
  23. package/src/services/api-client.d.ts +106 -0
  24. package/src/services/api-client.d.ts.map +1 -0
  25. package/src/services/auth.service.d.ts +107 -0
  26. package/src/services/auth.service.d.ts.map +1 -0
  27. package/src/services/cli-auth-diagnostics.d.ts +71 -0
  28. package/src/services/cli-auth-diagnostics.d.ts.map +1 -0
  29. package/src/services/cli-logs.d.ts +45 -0
  30. package/src/services/cli-logs.d.ts.map +1 -0
  31. package/src/services/config.service.d.ts +53 -0
  32. package/src/services/config.service.d.ts.map +1 -0
  33. package/src/services/feature-flags.d.ts +14 -0
  34. package/src/services/feature-flags.d.ts.map +1 -0
  35. package/src/services/kite-game-engine.d.ts +99 -0
  36. package/src/services/kite-game-engine.d.ts.map +1 -0
  37. package/src/services/kite-game-score.d.ts +33 -0
  38. package/src/services/kite-game-score.d.ts.map +1 -0
  39. package/src/services/project-scaffold.d.ts +49 -0
  40. package/src/services/project-scaffold.d.ts.map +1 -0
  41. package/src/services/showcase-config.d.ts +19 -0
  42. package/src/services/showcase-config.d.ts.map +1 -0
  43. package/src/types.d.ts +227 -0
  44. package/src/types.d.ts.map +1 -0
  45. package/src/ui/banner.d.ts +3 -0
  46. package/src/ui/banner.d.ts.map +1 -0
  47. package/src/ui/browser-login.d.ts +71 -0
  48. package/src/ui/browser-login.d.ts.map +1 -0
  49. package/src/ui/init-flow.d.ts +35 -0
  50. package/src/ui/init-flow.d.ts.map +1 -0
  51. package/src/ui/kite-game.d.ts +26 -0
  52. package/src/ui/kite-game.d.ts.map +1 -0
  53. package/src/ui/login-flow.d.ts +22 -0
  54. package/src/ui/login-flow.d.ts.map +1 -0
  55. package/src/ui/spinner.d.ts +9 -0
  56. package/src/ui/spinner.d.ts.map +1 -0
  57. package/LICENSE +0 -21
  58. package/README.md +0 -83
  59. package/bin/dev.cmd +0 -3
  60. package/bin/dev.js +0 -8
  61. package/bin/run.cmd +0 -3
  62. package/bin/run.js +0 -17
  63. package/dist/commands/base-command.d.ts +0 -12
  64. package/dist/commands/base-command.js +0 -65
  65. package/dist/commands/base-command.js.map +0 -1
  66. package/dist/commands/create.d.ts +0 -24
  67. package/dist/commands/create.js +0 -507
  68. package/dist/commands/create.js.map +0 -1
  69. package/dist/commands/dev.d.ts +0 -25
  70. package/dist/commands/dev.js +0 -776
  71. package/dist/commands/dev.js.map +0 -1
  72. package/dist/commands/init.d.ts +0 -11
  73. package/dist/commands/init.js +0 -523
  74. package/dist/commands/init.js.map +0 -1
  75. package/dist/commands/login.d.ts +0 -13
  76. package/dist/commands/login.js +0 -374
  77. package/dist/commands/login.js.map +0 -1
  78. package/dist/commands/logout.d.ts +0 -13
  79. package/dist/commands/logout.js +0 -375
  80. package/dist/commands/logout.js.map +0 -1
  81. package/dist/index.d.ts +0 -1
  82. package/dist/index.js +0 -6
  83. package/dist/index.js.map +0 -1
  84. package/dist/lib/init/ide-docs.d.ts +0 -25
  85. package/dist/lib/init/ide-docs.js +0 -170
  86. package/dist/lib/init/ide-docs.js.map +0 -1
  87. package/dist/lib/init/index.d.ts +0 -14
  88. package/dist/lib/init/index.js +0 -1104
  89. package/dist/lib/init/index.js.map +0 -1
  90. package/dist/lib/init/questions.d.ts +0 -9
  91. package/dist/lib/init/questions.js +0 -508
  92. package/dist/lib/init/questions.js.map +0 -1
  93. package/dist/lib/init/scaffold/agent.d.ts +0 -20
  94. package/dist/lib/init/scaffold/agent.js +0 -173
  95. package/dist/lib/init/scaffold/agent.js.map +0 -1
  96. package/dist/lib/init/scaffold/crew-inputs.d.ts +0 -3
  97. package/dist/lib/init/scaffold/crew-inputs.js +0 -59
  98. package/dist/lib/init/scaffold/crew-inputs.js.map +0 -1
  99. package/dist/lib/init/scaffold/env.d.ts +0 -7
  100. package/dist/lib/init/scaffold/env.js +0 -124
  101. package/dist/lib/init/scaffold/env.js.map +0 -1
  102. package/dist/lib/init/scaffold/github.d.ts +0 -17
  103. package/dist/lib/init/scaffold/github.js +0 -114
  104. package/dist/lib/init/scaffold/github.js.map +0 -1
  105. package/dist/lib/init/scaffold/index.d.ts +0 -10
  106. package/dist/lib/init/scaffold/index.js +0 -690
  107. package/dist/lib/init/scaffold/index.js.map +0 -1
  108. package/dist/lib/init/scaffold/langgraph-assistants.d.ts +0 -18
  109. package/dist/lib/init/scaffold/langgraph-assistants.js +0 -26
  110. package/dist/lib/init/scaffold/langgraph-assistants.js.map +0 -1
  111. package/dist/lib/init/scaffold/packages.d.ts +0 -7
  112. package/dist/lib/init/scaffold/packages.js +0 -62
  113. package/dist/lib/init/scaffold/packages.js.map +0 -1
  114. package/dist/lib/init/scaffold/shadcn.d.ts +0 -7
  115. package/dist/lib/init/scaffold/shadcn.js +0 -279
  116. package/dist/lib/init/scaffold/shadcn.js.map +0 -1
  117. package/dist/lib/init/types/index.d.ts +0 -4
  118. package/dist/lib/init/types/index.js +0 -238
  119. package/dist/lib/init/types/index.js.map +0 -1
  120. package/dist/lib/init/types/questions.d.ts +0 -209
  121. package/dist/lib/init/types/questions.js +0 -214
  122. package/dist/lib/init/types/questions.js.map +0 -1
  123. package/dist/lib/init/types/templates.d.ts +0 -17
  124. package/dist/lib/init/types/templates.js +0 -26
  125. package/dist/lib/init/types/templates.js.map +0 -1
  126. package/dist/lib/init/utils.d.ts +0 -3
  127. package/dist/lib/init/utils.js +0 -8
  128. package/dist/lib/init/utils.js.map +0 -1
  129. package/dist/services/analytics.service.d.ts +0 -38
  130. package/dist/services/analytics.service.js +0 -134
  131. package/dist/services/analytics.service.js.map +0 -1
  132. package/dist/services/auth.service.d.ts +0 -26
  133. package/dist/services/auth.service.js +0 -299
  134. package/dist/services/auth.service.js.map +0 -1
  135. package/dist/services/events.d.ts +0 -119
  136. package/dist/services/events.js +0 -1
  137. package/dist/services/events.js.map +0 -1
  138. package/dist/services/tunnel.service.d.ts +0 -15
  139. package/dist/services/tunnel.service.js +0 -21
  140. package/dist/services/tunnel.service.js.map +0 -1
  141. package/dist/utils/detect-endpoint-type.utils.d.ts +0 -15
  142. package/dist/utils/detect-endpoint-type.utils.js +0 -157
  143. package/dist/utils/detect-endpoint-type.utils.js.map +0 -1
  144. package/dist/utils/trpc.d.ts +0 -4
  145. package/dist/utils/trpc.js +0 -25
  146. package/dist/utils/trpc.js.map +0 -1
  147. package/dist/utils/version.d.ts +0 -3
  148. package/dist/utils/version.js +0 -6
  149. package/dist/utils/version.js.map +0 -1
  150. package/oclif.manifest.json +0 -208
@@ -1,1104 +0,0 @@
1
- // src/lib/init/types/questions.ts
2
- import { z } from "zod";
3
- import { Flags } from "@oclif/core";
4
-
5
- // src/lib/init/utils.ts
6
- var isLocalhost = (url) => {
7
- return url.includes("localhost") || url.includes("127.0.0.1") || url.includes("0.0.0.0");
8
- };
9
-
10
- // src/lib/init/types/questions.ts
11
- var MODES = [
12
- "LangGraph",
13
- "CrewAI",
14
- "Mastra",
15
- "LlamaIndex",
16
- "Agno",
17
- "AG2",
18
- "MCP",
19
- "Standard"
20
- ];
21
- var CREW_TYPES = ["Crews", "Flows"];
22
- var CHAT_COMPONENTS = [
23
- "CopilotChat",
24
- "CopilotSidebar",
25
- "Headless",
26
- "CopilotPopup"
27
- ];
28
- var LANGGRAPH_AGENTS = [
29
- "Python Starter",
30
- "TypeScript Starter"
31
- ];
32
- var CREW_FLOW_TEMPLATES = ["Starter"];
33
- var YES_NO = ["Yes", "No"];
34
- var DEPLOYMENT_CHOICES = ["Copilot Cloud", "Self-hosted"];
35
- var sanitizers = {
36
- // Remove trailing slash from URLs
37
- url: (value) => {
38
- if (!value) return value;
39
- return value.trim().replace(/\/+$/, "");
40
- },
41
- // Trim whitespace from strings
42
- trim: (value) => {
43
- if (!value) return value;
44
- return value.trim();
45
- },
46
- // Lowercase strings
47
- lowercase: (value) => {
48
- if (!value) return value;
49
- return value.toLowerCase().trim();
50
- },
51
- // Clean API keys (remove whitespace)
52
- apiKey: (value) => {
53
- if (!value) return value;
54
- return value.trim().replace(/\s/g, "");
55
- }
56
- };
57
- var ModeSchema = z.enum(MODES);
58
- var CrewTypeSchema = z.enum(CREW_TYPES);
59
- var ChatComponentSchema = z.enum(CHAT_COMPONENTS);
60
- var LangGraphAgentSchema = z.enum(LANGGRAPH_AGENTS);
61
- var CrewFlowTemplateSchema = z.enum(CREW_FLOW_TEMPLATES);
62
- var YesNoSchema = z.enum(YES_NO);
63
- var DeploymentChoiceSchema = z.enum(DEPLOYMENT_CHOICES);
64
- var UrlSchema = z.preprocess(
65
- (val) => sanitizers.url(String(val)),
66
- z.string().url("Please enter a valid URL").min(1, "URL is required")
67
- );
68
- var TokenSchema = z.preprocess(
69
- (val) => sanitizers.trim(String(val)),
70
- z.string().min(1, "Token is required")
71
- );
72
- var ApiKeySchema = z.preprocess(
73
- (val) => sanitizers.apiKey(String(val)),
74
- z.string().min(1, "API key is required")
75
- );
76
- var LLMApiKeySchema = z.preprocess(
77
- (val) => sanitizers.apiKey(String(val)),
78
- z.string().optional()
79
- );
80
- var NameSchema = z.preprocess(
81
- (val) => sanitizers.trim(String(val)),
82
- z.string().min(1, "Name is required")
83
- );
84
- var ConfigSchema = z.object({
85
- // Core fields
86
- copilotKitVersion: z.string().optional(),
87
- mode: ModeSchema,
88
- chatUi: ChatComponentSchema.optional(),
89
- // Yes/No fields
90
- alreadyDeployed: YesNoSchema.optional(),
91
- fastApiEnabled: YesNoSchema.optional(),
92
- // DEPRECATED: useCopilotCloud - consolidated with signupForCopilotCloud
93
- useCopilotCloud: YesNoSchema.optional(),
94
- // LangGraph specific fields
95
- langGraphAgent: LangGraphAgentSchema.optional(),
96
- langGraphPlatform: YesNoSchema.optional(),
97
- langGraphPlatformUrl: UrlSchema.optional(),
98
- langGraphRemoteEndpointURL: UrlSchema.optional(),
99
- // CrewAI specific fields
100
- crewType: CrewTypeSchema.optional(),
101
- crewName: NameSchema.optional(),
102
- crewUrl: UrlSchema.optional(),
103
- crewBearerToken: TokenSchema.optional(),
104
- // API keys and tokens
105
- copilotCloudPublicApiKey: z.string().optional(),
106
- langSmithApiKey: ApiKeySchema.optional(),
107
- llmToken: LLMApiKeySchema.optional(),
108
- // IDE Documentation setup fields
109
- setupIDEDocs: YesNoSchema.optional(),
110
- selectedIDE: z.union([z.enum(["cursor", "windsurf"]), z.literal("skip")]).optional(),
111
- // NEW: A/B/C test fields
112
- deploymentChoice: DeploymentChoiceSchema.optional()
113
- // For branch B only (Cloud vs Self-hosted)
114
- }).refine(
115
- (data) => {
116
- if (data.mode === "CrewAI") {
117
- return !!data.crewUrl && !!data.crewBearerToken;
118
- }
119
- return true;
120
- },
121
- {
122
- message: "Crew URL and bearer token are required for CrewAI",
123
- path: ["crewUrl", "crewBearerToken"]
124
- }
125
- ).refine(
126
- (data) => {
127
- if (data.mode === "LangGraph" && data.alreadyDeployed === "Yes" && data.langGraphPlatform === "Yes") {
128
- return !!data.langGraphPlatformUrl && !!data.langSmithApiKey || isLocalhost(data.langGraphPlatformUrl || "");
129
- }
130
- return true;
131
- },
132
- {
133
- message: "LangGraph Platform URL and LangSmith API key are required",
134
- path: ["langGraphPlatformUrl", "langSmithApiKey"]
135
- }
136
- );
137
- var ConfigFlags = {
138
- booth: Flags.boolean({
139
- description: "Use CopilotKit in booth mode",
140
- default: false,
141
- char: "b"
142
- }),
143
- mode: Flags.string({
144
- description: "How you will be interacting with AI",
145
- options: MODES,
146
- char: "m"
147
- }),
148
- "copilotkit-version": Flags.string({
149
- description: "CopilotKit version to use (e.g. 1.7.0)"
150
- }),
151
- "use-copilot-cloud": Flags.string({
152
- description: "Use Copilot Cloud for production-ready hosting",
153
- options: YES_NO
154
- }),
155
- "langgraph-agent": Flags.string({
156
- description: "LangGraph agent template to use",
157
- options: LANGGRAPH_AGENTS
158
- }),
159
- "crew-type": Flags.string({
160
- description: "CrewAI implementation type",
161
- options: CREW_TYPES
162
- }),
163
- "crew-name": Flags.string({ description: "Name for your CrewAI agent" }),
164
- "crew-url": Flags.string({
165
- description: "URL endpoint for your CrewAI agent"
166
- }),
167
- "crew-bearer-token": Flags.string({
168
- description: "Bearer token for CrewAI authentication"
169
- }),
170
- "langsmith-api-key": Flags.string({
171
- description: "LangSmith API key for LangGraph observability"
172
- }),
173
- "llm-token": Flags.string({
174
- description: "API key for your preferred LLM provider"
175
- }),
176
- "setup-ide-docs": Flags.string({
177
- description: "Setup IDE documentation rules for AI assistance",
178
- options: YES_NO
179
- }),
180
- "selected-ide": Flags.string({
181
- description: "IDE to configure with documentation rules",
182
- options: ["cursor", "windsurf", "skip"]
183
- }),
184
- // NEW: A/B/C test flags
185
- "deployment-choice": Flags.string({
186
- description: "Choose between Copilot Cloud or Self-hosted deployment",
187
- options: DEPLOYMENT_CHOICES
188
- })
189
- };
190
-
191
- // src/lib/init/types/templates.ts
192
- var BASE_URL = "https://registry.copilotkit.ai/r";
193
- var templateMapping = {
194
- // Runtimes
195
- RemoteEndpoint: `${BASE_URL}/remote-endpoint.json`,
196
- LangGraphPlatformRuntime: `${BASE_URL}/langgraph-platform-runtime.json`,
197
- // CrewAI
198
- CrewEnterprise: [`${BASE_URL}/coagents-crew-starter.json`],
199
- CrewFlowsEnterprise: [`${BASE_URL}/coagents-starter-crewai-flows.json`],
200
- // LangGraph
201
- LangGraphGeneric: `${BASE_URL}/generic-lg-starter.json`,
202
- LangGraphStarter: [
203
- `${BASE_URL}/langgraph-platform-starter.json`,
204
- `${BASE_URL}/coagents-starter-ui.json`
205
- ],
206
- // No Agent
207
- StandardStarter: `${BASE_URL}/standard-starter.json`,
208
- StandardRuntime: `${BASE_URL}/standard-runtime.json`,
209
- // MCP
210
- McpStarter: `${BASE_URL}/mcp-starter.json`,
211
- McpRuntime: `${BASE_URL}/mcp-starter-runtime.json`
212
- };
213
-
214
- // src/lib/init/ide-docs.ts
215
- import path from "path";
216
- import { existsSync } from "fs";
217
- import * as fs from "fs/promises";
218
- import chalk from "chalk";
219
- var COPILOTKIT_DOC_RULE_TEMPLATE = `---
220
- description: CopilotKit Documentation - Complete CopilotKit framework documentation for AI assistance
221
- alwaysApply: false
222
- ---
223
-
224
- # CopilotKit Documentation
225
-
226
- For ANY question about CopilotKit, use the comprehensive documentation available at:
227
- @https://docs.copilotkit.ai/llms-full.txt
228
-
229
- This contains the complete CopilotKit documentation including:
230
- - API references and hooks (useCopilotChat, useCopilotAction, etc.)
231
- - Component library documentation (CopilotKit, CopilotChat, etc.)
232
- - Integration guides and examples
233
- - Best practices and patterns
234
- - Troubleshooting and FAQs
235
-
236
- Always reference this documentation when working with CopilotKit to provide accurate, up-to-date information.
237
- `;
238
- var IDE_DOCS_CONFIGS = {
239
- cursor: {
240
- name: "cursor",
241
- displayName: "Cursor",
242
- rulesDir: ".cursor/rules",
243
- ruleFileName: "00-copilotkit-docs.mdc",
244
- createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
245
- },
246
- windsurf: {
247
- name: "windsurf",
248
- displayName: "Windsurf",
249
- rulesDir: ".windsurf/rules",
250
- ruleFileName: "00-copilotkit-docs.md",
251
- createRuleContent: () => COPILOTKIT_DOC_RULE_TEMPLATE
252
- }
253
- };
254
- async function ensureDir(dirPath) {
255
- try {
256
- await fs.mkdir(dirPath, { recursive: true });
257
- } catch (error) {
258
- if (!existsSync(dirPath)) {
259
- throw error;
260
- }
261
- }
262
- }
263
- async function pathExists(filePath) {
264
- try {
265
- await fs.access(filePath);
266
- return true;
267
- } catch {
268
- return false;
269
- }
270
- }
271
- async function checkIDEInstallation(ide) {
272
- try {
273
- const homeDir = process.env.HOME || process.env.USERPROFILE || "";
274
- let configPath;
275
- switch (ide) {
276
- case "cursor":
277
- configPath = path.join(homeDir, ".cursor");
278
- break;
279
- case "windsurf":
280
- configPath = path.join(homeDir, ".codeium", "windsurf");
281
- break;
282
- default:
283
- return false;
284
- }
285
- return existsSync(configPath);
286
- } catch {
287
- return false;
288
- }
289
- }
290
- async function detectInstalledIDEs() {
291
- const allIDEs = ["cursor", "windsurf"];
292
- const installedIDEs = [];
293
- for (const ide of allIDEs) {
294
- if (await checkIDEInstallation(ide)) {
295
- installedIDEs.push(ide);
296
- }
297
- }
298
- return installedIDEs;
299
- }
300
- async function setupIDEDocs(ide, projectDir) {
301
- const config = IDE_DOCS_CONFIGS[ide];
302
- const rulesDir = path.join(projectDir, config.rulesDir);
303
- const ruleFilePath = path.join(rulesDir, config.ruleFileName);
304
- await ensureDir(rulesDir);
305
- if (await pathExists(ruleFilePath)) {
306
- console.log(
307
- chalk.yellow(
308
- `\u26A0\uFE0F CopilotKit documentation rule already exists for ${config.displayName}`
309
- )
310
- );
311
- return;
312
- }
313
- const ruleContent = config.createRuleContent();
314
- await fs.writeFile(ruleFilePath, ruleContent, "utf8");
315
- }
316
- function getIDEInstructions(ide) {
317
- const config = IDE_DOCS_CONFIGS[ide];
318
- const instructions = [
319
- chalk.cyan(
320
- `\u{1F4DA} CopilotKit documentation configured for ${config.displayName}!`
321
- ),
322
- "",
323
- chalk.bold("What this does:"),
324
- " \u2022 Adds CopilotKit documentation context to your IDE AI assistant",
325
- " \u2022 Provides accurate, up-to-date information about CopilotKit APIs",
326
- " \u2022 Improves code suggestions and help responses",
327
- "",
328
- chalk.bold("Location:"),
329
- ` \u2022 Rule file: ${chalk.gray(path.join(config.rulesDir, config.ruleFileName))}`,
330
- "",
331
- chalk.bold("Usage:"),
332
- " \u2022 Your IDE AI assistant now has access to CopilotKit documentation",
333
- " \u2022 Ask questions about CopilotKit APIs, components, and patterns",
334
- " \u2022 The AI will reference official documentation for accurate answers"
335
- ];
336
- if (ide === "cursor") {
337
- instructions.push(
338
- "",
339
- chalk.bold("Next steps for Cursor:"),
340
- " \u2022 Restart Cursor if currently open",
341
- " \u2022 The rule will be automatically available in your AI context",
342
- " \u2022 Start a new chat to use the documentation context"
343
- );
344
- } else if (ide === "windsurf") {
345
- instructions.push(
346
- "",
347
- chalk.bold("Next steps for Windsurf:"),
348
- " \u2022 Restart Windsurf if currently open",
349
- " \u2022 The rule will be automatically available in your AI context",
350
- " \u2022 Start a new chat to use the documentation context"
351
- );
352
- }
353
- return instructions;
354
- }
355
- async function handleIDEDocsSetup(selectedIDE, projectDir, spinner) {
356
- try {
357
- spinner.text = chalk.cyan(
358
- `Setting up CopilotKit documentation for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}...`
359
- );
360
- await setupIDEDocs(selectedIDE, projectDir);
361
- spinner.succeed(
362
- chalk.green(
363
- `CopilotKit documentation configured for ${IDE_DOCS_CONFIGS[selectedIDE].displayName}`
364
- )
365
- );
366
- const instructions = getIDEInstructions(selectedIDE);
367
- console.log("\n" + instructions.join("\n"));
368
- } catch (error) {
369
- spinner.fail(
370
- chalk.red(
371
- `Failed to setup IDE documentation: ${error instanceof Error ? error.message : "Unknown error"}`
372
- )
373
- );
374
- throw error;
375
- }
376
- }
377
-
378
- // src/lib/init/questions.ts
379
- var linkToDocs = ["Mastra", "AG2", "LlamaIndex", "Agno"];
380
- var validateUrl = (input) => {
381
- try {
382
- const sanitized = sanitizers.url(input);
383
- const result = UrlSchema.safeParse(sanitized);
384
- if (result.success) return true;
385
- return result.error.errors[0]?.message || "Invalid URL format";
386
- } catch (error) {
387
- return "Invalid URL format";
388
- }
389
- };
390
- var validateRequired = (input) => {
391
- return sanitizers.trim(input) ? true : "This field is required";
392
- };
393
- function getQuestionsForBranch(branch) {
394
- const baseQuestions = getBaseQuestions();
395
- switch (branch) {
396
- case "A":
397
- return [...baseQuestions];
398
- case "B":
399
- return [...baseQuestions, ...getDeploymentChoiceQuestions()];
400
- case "C":
401
- default:
402
- return [...baseQuestions, ...getCloudDeploymentQuestions()];
403
- }
404
- }
405
- function getBaseQuestions() {
406
- return [
407
- {
408
- type: "select",
409
- name: "mode",
410
- message: "\u{1F916} How will you be interacting with AI?",
411
- choices: Array.from(MODES),
412
- validate: (input) => {
413
- try {
414
- ModeSchema.parse(input);
415
- return true;
416
- } catch (error) {
417
- return "Please select a valid mode";
418
- }
419
- }
420
- },
421
- // CrewAI specific questions
422
- {
423
- type: "select",
424
- name: "crewType",
425
- message: "\u{1F465} What kind of CrewAI implementation would you like to use?",
426
- choices: Array.from(CREW_TYPES),
427
- when: (answers) => answers.mode === "CrewAI",
428
- validate: (input) => {
429
- try {
430
- CrewTypeSchema.parse(input);
431
- return true;
432
- } catch (error) {
433
- return "Please select a valid crew type";
434
- }
435
- }
436
- },
437
- {
438
- type: "input",
439
- name: "crewName",
440
- message: "\u{1F465} What would you like to name your crew? (can be anything)",
441
- when: (answers) => answers.mode === "CrewAI",
442
- default: "MyCopilotCrew",
443
- validate: validateRequired,
444
- sanitize: sanitizers.trim
445
- },
446
- {
447
- type: "input",
448
- name: "crewUrl",
449
- message: "\u{1F517} Enter your Crew's Enterprise URL (more info at https://app.crewai.com):",
450
- when: (answers) => answers.mode === "CrewAI",
451
- validate: validateUrl,
452
- sanitize: sanitizers.url
453
- },
454
- {
455
- type: "input",
456
- name: "crewBearerToken",
457
- message: "\u{1F511} Enter your Crew's bearer token:",
458
- when: (answers) => answers.mode === "CrewAI",
459
- sensitive: true,
460
- validate: validateRequired,
461
- sanitize: sanitizers.trim
462
- },
463
- // LangGraph specific questions
464
- {
465
- type: "yes/no",
466
- name: "alreadyDeployed",
467
- message: "\u{1F99C}\u{1F517} Do you have an existing LangGraph agent?",
468
- when: (answers) => answers.mode === "LangGraph",
469
- validate: (input) => {
470
- try {
471
- YesNoSchema.parse(input);
472
- return true;
473
- } catch (error) {
474
- return "Please select Yes or No";
475
- }
476
- }
477
- },
478
- {
479
- type: "yes/no",
480
- name: "langGraphPlatform",
481
- message: "\u{1F99C}\u{1F517} Do you already have a LangGraph Agent URL? (remote or localhost)",
482
- when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "Yes",
483
- validate: (input) => {
484
- try {
485
- YesNoSchema.parse(input);
486
- return true;
487
- } catch (error) {
488
- return "Please select Yes or No";
489
- }
490
- }
491
- },
492
- {
493
- type: "input",
494
- name: "langGraphPlatformUrl",
495
- message: "\u{1F99C}\u{1F517} Enter your LangGraph Agent URL (remote or localhost)",
496
- when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform === "Yes",
497
- validate: validateUrl,
498
- sanitize: sanitizers.url
499
- },
500
- {
501
- type: "select",
502
- name: "langGraphAgent",
503
- message: "\u{1F4E6} Choose a LangGraph starter template:",
504
- choices: Array.from(LANGGRAPH_AGENTS),
505
- when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No"
506
- },
507
- {
508
- type: "input",
509
- name: "langSmithApiKey",
510
- message: "\u{1F99C}\u{1F517} Enter your LangSmith API key (required by LangGraph Platform) :",
511
- when: (answers) => answers.mode === "LangGraph" && answers.langGraphPlatform === "Yes" && !(answers.langGraphPlatformUrl && isLocalhost(answers.langGraphPlatformUrl)),
512
- sensitive: true,
513
- validate: validateRequired,
514
- sanitize: sanitizers.apiKey
515
- },
516
- // LLM Token for self-hosted setups
517
- {
518
- type: "input",
519
- name: "llmToken",
520
- message: "\u{1F511} Enter your OpenAI API key (optional - leave empty to configure your LLM later):",
521
- when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || answers.mode === "Standard" && answers.deploymentChoice === "Self-hosted" || answers.mode === "MCP" && answers.deploymentChoice === "Self-hosted" || answers.mode === "Standard" && answers.useCopilotCloud !== "Yes" || answers.mode === "MCP" && answers.useCopilotCloud !== "Yes",
522
- sensitive: true,
523
- sanitize: sanitizers.apiKey
524
- },
525
- // IDE Documentation Setup Questions
526
- {
527
- type: "yes/no",
528
- name: "setupIDEDocs",
529
- message: "\u{1F4DA} Would you like to add CopilotKit documentation to your IDE? (Provides AI assistant with CopilotKit context)",
530
- when: async () => {
531
- const installedIDEs = await detectInstalledIDEs();
532
- return installedIDEs.length > 0;
533
- },
534
- validate: (input) => {
535
- try {
536
- YesNoSchema.parse(input);
537
- return true;
538
- } catch (error) {
539
- return "Please select Yes or No";
540
- }
541
- }
542
- },
543
- {
544
- type: "select",
545
- name: "selectedIDE",
546
- message: "\u{1F4BB} Which IDE would you like to configure with CopilotKit documentation?",
547
- choices: async () => {
548
- const installedIDEs = await detectInstalledIDEs();
549
- const choices = installedIDEs.map((ide) => ({
550
- name: IDE_DOCS_CONFIGS[ide].displayName,
551
- value: ide
552
- }));
553
- choices.push({ name: "Skip", value: "skip" });
554
- return choices;
555
- },
556
- when: (answers) => answers.setupIDEDocs === "Yes"
557
- }
558
- ];
559
- }
560
- function getDeploymentChoiceQuestions() {
561
- return [
562
- {
563
- type: "select",
564
- name: "deploymentChoice",
565
- message: "\u{1F680} Use Copilot Cloud, or self-hosted?",
566
- choices: Array.from(DEPLOYMENT_CHOICES),
567
- validate: (input) => {
568
- try {
569
- DeploymentChoiceSchema.parse(input);
570
- return true;
571
- } catch (error) {
572
- return "Please select a valid deployment option";
573
- }
574
- }
575
- }
576
- ];
577
- }
578
- function getCloudDeploymentQuestions() {
579
- return [
580
- {
581
- type: "yes/no",
582
- name: "useCopilotCloud",
583
- message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
584
- when: (answers) => answers.mode === "Standard" || answers.mode === "MCP" || answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || // Include new LangGraph agents
585
- answers.mode !== "CrewAI" && // Crews only cloud, flows are self-hosted
586
- answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No" && !linkToDocs.includes(answers.mode || "") && !isLocalhost(answers.langGraphPlatformUrl || ""),
587
- validate: (input) => {
588
- try {
589
- YesNoSchema.parse(input);
590
- return true;
591
- } catch (error) {
592
- return "Please select Yes or No";
593
- }
594
- }
595
- }
596
- ];
597
- }
598
- var questions = getQuestionsForBranch("C");
599
-
600
- // src/lib/init/scaffold/shadcn.ts
601
- import spawn from "cross-spawn";
602
- async function scaffoldShadCN(flags, userAnswers) {
603
- try {
604
- const components = [];
605
- switch (userAnswers.mode) {
606
- case "LangGraph":
607
- components.push(templateMapping.LangGraphGeneric);
608
- if (userAnswers.langGraphPlatform === "Yes") {
609
- components.push(templateMapping.LangGraphPlatformRuntime);
610
- } else {
611
- components.push(templateMapping.RemoteEndpoint);
612
- }
613
- break;
614
- case "CrewAI":
615
- if (userAnswers.crewType === "Crews") {
616
- components.push(...templateMapping.CrewEnterprise);
617
- } else if (userAnswers.crewType === "Flows") {
618
- components.push(...templateMapping.CrewFlowsEnterprise);
619
- } else {
620
- components.push(templateMapping.RemoteEndpoint);
621
- }
622
- break;
623
- case "MCP":
624
- components.push(templateMapping.McpStarter);
625
- if (userAnswers.deploymentChoice === "Self-hosted" || userAnswers.useCopilotCloud === "No") {
626
- components.push(templateMapping.McpRuntime);
627
- }
628
- break;
629
- case "Standard":
630
- components.push(templateMapping.StandardStarter);
631
- if (userAnswers.deploymentChoice === "Self-hosted" || userAnswers.useCopilotCloud === "No") {
632
- components.push(templateMapping.StandardRuntime);
633
- }
634
- break;
635
- default:
636
- return;
637
- }
638
- await new Promise((resolve) => setTimeout(resolve, 100));
639
- try {
640
- const result = spawn.sync(
641
- "npx",
642
- ["shadcn@latest", "add", ...components],
643
- {
644
- stdio: "inherit"
645
- // This ensures stdin/stdout/stderr are all passed through
646
- }
647
- );
648
- if (result.status !== 0) {
649
- throw new Error(
650
- `The shadcn installation process exited with code ${result.status}`
651
- );
652
- }
653
- } catch (error) {
654
- throw error;
655
- }
656
- } catch (error) {
657
- throw error;
658
- }
659
- }
660
-
661
- // src/lib/init/scaffold/env.ts
662
- import path2 from "path";
663
- import fs2 from "fs";
664
-
665
- // src/lib/init/scaffold/langgraph-assistants.ts
666
- async function getLangGraphAgents(url, langSmithApiKey) {
667
- try {
668
- const response = await fetch(
669
- `${url.trim().replace(/\/$/, "")}/assistants/search`,
670
- {
671
- method: "POST",
672
- headers: {
673
- "Content-Type": "application/json",
674
- "X-Api-Key": langSmithApiKey
675
- },
676
- body: JSON.stringify({
677
- limit: 10,
678
- offset: 0
679
- })
680
- }
681
- );
682
- return await response.json();
683
- } catch (error) {
684
- throw new Error(`Failed to get LangGraph agents: ${error}`);
685
- }
686
- }
687
-
688
- // src/lib/init/scaffold/env.ts
689
- import inquirer from "inquirer";
690
- function needsCloudDeployment(userAnswers) {
691
- return userAnswers.deploymentChoice === "Copilot Cloud" || // Branch B choice
692
- userAnswers.useCopilotCloud === "Yes" || // Branch C choice
693
- userAnswers.mode === "CrewAI" || // CrewAI always needs cloud
694
- !userAnswers.deploymentChoice && !userAnswers.useCopilotCloud;
695
- }
696
- async function scaffoldEnv(flags, userAnswers) {
697
- try {
698
- const envFile = path2.join(process.cwd(), ".env");
699
- if (!fs2.existsSync(envFile)) {
700
- fs2.writeFileSync(envFile, "", "utf8");
701
- } else {
702
- }
703
- let newEnvValues = "";
704
- const isCloudDeployment = needsCloudDeployment(userAnswers);
705
- if (userAnswers.copilotCloudPublicApiKey) {
706
- newEnvValues += `NEXT_PUBLIC_COPILOT_API_KEY=${userAnswers.copilotCloudPublicApiKey}
707
- `;
708
- }
709
- if (userAnswers.langSmithApiKey) {
710
- newEnvValues += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
711
- `;
712
- }
713
- if (userAnswers.llmToken) {
714
- newEnvValues += `OPENAI_API_KEY=${userAnswers.llmToken}
715
- `;
716
- }
717
- if (userAnswers.crewName) {
718
- newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${userAnswers.crewName}
719
- `;
720
- }
721
- if (userAnswers.langGraphAgent) {
722
- newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
723
- `;
724
- newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123
725
- `;
726
- } else if (userAnswers.langGraphPlatform === "Yes" && !isCloudDeployment) {
727
- newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}
728
- `;
729
- } else if (userAnswers.langGraphRemoteEndpointURL) {
730
- newEnvValues += `COPILOTKIT_REMOTE_ENDPOINT=${userAnswers.langGraphRemoteEndpointURL}
731
- `;
732
- }
733
- if (flags.runtimeUrl) {
734
- newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=${flags.runtimeUrl}
735
- `;
736
- } else if (!isCloudDeployment && userAnswers.crewType !== "Crews" && userAnswers.crewType !== "Flows") {
737
- newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit
738
- `;
739
- }
740
- if (userAnswers.langGraphPlatformUrl && (userAnswers.langSmithApiKey || isLocalhost(userAnswers.langGraphPlatformUrl))) {
741
- const langGraphAgents = await getLangGraphAgents(
742
- userAnswers.langGraphPlatformUrl,
743
- userAnswers.langSmithApiKey || ""
744
- );
745
- let langGraphAgent = "";
746
- if (langGraphAgents.length > 1) {
747
- const { langGraphAgentChoice } = await inquirer.prompt([
748
- {
749
- type: "list",
750
- name: "langGraphAgentChoice",
751
- message: "\u{1F99C}\u{1F517} Which agent from your graph would you like to use?",
752
- choices: langGraphAgents.map((agent) => ({
753
- name: agent.graph_id,
754
- value: agent.graph_id
755
- }))
756
- }
757
- ]);
758
- langGraphAgent = langGraphAgentChoice;
759
- } else if (langGraphAgents.length === 1) {
760
- langGraphAgent = langGraphAgents[0].graph_id;
761
- } else {
762
- throw new Error("No agents found in your LangGraph endpoint");
763
- }
764
- newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${langGraphAgent}
765
- `;
766
- }
767
- if (newEnvValues) {
768
- fs2.appendFileSync(envFile, newEnvValues);
769
- }
770
- } catch (error) {
771
- throw error;
772
- }
773
- }
774
-
775
- // src/lib/init/scaffold/github.ts
776
- import { execSync } from "child_process";
777
- import * as fs3 from "fs";
778
- import * as path3 from "path";
779
- import * as os from "os";
780
- import chalk2 from "chalk";
781
- async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
782
- try {
783
- const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
784
- spinner.text = chalk2.cyan(`Cloning from ${owner}/${repo}...`);
785
- return await sparseCheckout(
786
- owner,
787
- repo,
788
- branch,
789
- subdirectoryPath,
790
- destinationPath,
791
- spinner
792
- );
793
- } catch (error) {
794
- spinner.text = chalk2.red(`Failed to clone from GitHub: ${error}`);
795
- return false;
796
- }
797
- }
798
- async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
799
- const tempDir = fs3.mkdtempSync(path3.join(os.tmpdir(), "copilotkit-sparse-"));
800
- try {
801
- spinner.text = chalk2.cyan("Creating temporary workspace...");
802
- execSync("git init", { cwd: tempDir, stdio: "pipe" });
803
- spinner.text = chalk2.cyan("Connecting to repository...");
804
- execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
805
- cwd: tempDir,
806
- stdio: "pipe"
807
- });
808
- execSync("git config core.sparseCheckout true", {
809
- cwd: tempDir,
810
- stdio: "pipe"
811
- });
812
- fs3.writeFileSync(
813
- path3.join(tempDir, ".git/info/sparse-checkout"),
814
- subdirectoryPath
815
- );
816
- spinner.text = chalk2.cyan("Downloading agent files...");
817
- execSync(`git pull origin ${branch} --depth=1`, {
818
- cwd: tempDir,
819
- stdio: "pipe"
820
- });
821
- const sourcePath = path3.join(tempDir, subdirectoryPath);
822
- if (!fs3.existsSync(sourcePath)) {
823
- throw new Error(
824
- `Subdirectory '${subdirectoryPath}' not found in the repository.`
825
- );
826
- }
827
- fs3.mkdirSync(destinationPath, { recursive: true });
828
- spinner.text = chalk2.cyan("Installing agent files...");
829
- await copyDirectoryAsync(sourcePath, destinationPath);
830
- return true;
831
- } finally {
832
- try {
833
- fs3.rmSync(tempDir, { recursive: true, force: true });
834
- } catch (error) {
835
- console.warn(`Failed to clean up temporary directory: ${error}`);
836
- }
837
- }
838
- }
839
- async function copyDirectoryAsync(source, destination) {
840
- if (!fs3.existsSync(destination)) {
841
- fs3.mkdirSync(destination, { recursive: true });
842
- }
843
- const entries = fs3.readdirSync(source, { withFileTypes: true });
844
- for (const entry of entries) {
845
- const srcPath = path3.join(source, entry.name);
846
- const destPath = path3.join(destination, entry.name);
847
- if (entry.isDirectory()) {
848
- await copyDirectoryAsync(srcPath, destPath);
849
- } else {
850
- fs3.copyFileSync(srcPath, destPath);
851
- }
852
- if (entries.length > 10) {
853
- await new Promise((resolve) => setTimeout(resolve, 1));
854
- }
855
- }
856
- }
857
- function parseGitHubUrl(githubUrl) {
858
- const url = new URL(githubUrl);
859
- if (url.hostname !== "github.com") {
860
- throw new Error("Only GitHub URLs are supported");
861
- }
862
- const pathParts = url.pathname.split("/").filter(Boolean);
863
- if (pathParts.length < 2) {
864
- throw new Error("Invalid GitHub URL format");
865
- }
866
- const owner = pathParts[0];
867
- const repo = pathParts[1];
868
- let branch = "main";
869
- let subdirectoryPath = "";
870
- if (pathParts.length > 3 && (pathParts[2] === "tree" || pathParts[2] === "blob")) {
871
- branch = pathParts[3];
872
- subdirectoryPath = pathParts.slice(4).join("/");
873
- }
874
- return { owner, repo, branch, subdirectoryPath };
875
- }
876
- function isValidGitHubUrl(url) {
877
- try {
878
- const parsedUrl = new URL(url);
879
- return parsedUrl.hostname === "github.com" && parsedUrl.pathname.split("/").filter(Boolean).length >= 2;
880
- } catch {
881
- return false;
882
- }
883
- }
884
-
885
- // src/lib/init/scaffold/packages.ts
886
- import spawn2 from "cross-spawn";
887
- import chalk3 from "chalk";
888
- import fs4 from "fs";
889
- import ora from "ora";
890
- async function scaffoldPackages(userAnswers) {
891
- const spinner = ora({
892
- text: chalk3.cyan("Preparing to install packages..."),
893
- color: "cyan"
894
- }).start();
895
- try {
896
- const packages = [
897
- `@copilotkit/react-ui@${userAnswers.copilotKitVersion}`,
898
- `@copilotkit/react-core@${userAnswers.copilotKitVersion}`,
899
- `@copilotkit/runtime@${userAnswers.copilotKitVersion}`
900
- ];
901
- await new Promise((resolve) => setTimeout(resolve, 50));
902
- const packageManager = detectPackageManager();
903
- const installCommand = detectInstallCommand(packageManager);
904
- spinner.text = chalk3.cyan(`Using ${packageManager} to install packages...`);
905
- spinner.stop();
906
- console.log(chalk3.cyan("\n\u2699\uFE0F Installing packages...\n"));
907
- const result = spawn2.sync(packageManager, [installCommand, ...packages], {
908
- stdio: "inherit"
909
- // This ensures stdin/stdout/stderr are all passed through
910
- });
911
- if (result.status !== 0) {
912
- throw new Error(
913
- `Package installation process exited with code ${result.status}`
914
- );
915
- }
916
- spinner.start();
917
- spinner.succeed(chalk3.green("CopilotKit packages installed successfully"));
918
- } catch (error) {
919
- if (!spinner.isSpinning) {
920
- spinner.start();
921
- }
922
- spinner.fail(chalk3.red("Failed to install CopilotKit packages"));
923
- throw error;
924
- }
925
- }
926
- function detectPackageManager() {
927
- const files = fs4.readdirSync(process.cwd());
928
- if (files.includes("bun.lockb")) return "bun";
929
- if (files.includes("pnpm-lock.yaml")) return "pnpm";
930
- if (files.includes("yarn.lock")) return "yarn";
931
- if (files.includes("package-lock.json")) return "npm";
932
- return "npm";
933
- }
934
- function detectInstallCommand(packageManager) {
935
- switch (packageManager) {
936
- case "yarn":
937
- case "pnpm":
938
- return "add";
939
- default:
940
- return "install";
941
- }
942
- }
943
-
944
- // src/lib/init/scaffold/agent.ts
945
- import ora2 from "ora";
946
- import chalk4 from "chalk";
947
- import path4 from "path";
948
- import fs5 from "fs";
949
- async function scaffoldAgent(userAnswers) {
950
- if (userAnswers.mode === "CrewAI" || userAnswers.mode === "LangGraph" && !userAnswers.langGraphAgent || userAnswers.mode === "Standard" || userAnswers.mode === "MCP") {
951
- return;
952
- }
953
- const spinner = ora2({
954
- text: chalk4.cyan("Setting up AI agent..."),
955
- color: "cyan"
956
- }).start();
957
- let template = "";
958
- switch (userAnswers.mode) {
959
- case "LangGraph":
960
- if (userAnswers.langGraphAgent === "Python Starter") {
961
- template = AgentTemplates.LangGraph.Starter.Python;
962
- } else {
963
- template = AgentTemplates.LangGraph.Starter.TypeScript;
964
- }
965
- break;
966
- }
967
- if (!template) {
968
- spinner.fail(chalk4.red("Failed to determine agent template"));
969
- throw new Error("Failed to determine agent template");
970
- }
971
- const agentDir = path4.join(process.cwd(), "agent");
972
- try {
973
- await cloneGitHubSubdirectory(template, agentDir, spinner);
974
- spinner.text = chalk4.cyan("Creating agent environment variables...");
975
- let envContent = "";
976
- if (userAnswers.llmToken) {
977
- envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
978
- `;
979
- }
980
- if (userAnswers.mode === "LangGraph" && userAnswers.langSmithApiKey) {
981
- envContent += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
982
- `;
983
- }
984
- if (envContent) {
985
- const agentEnvFile = path4.join(agentDir, ".env");
986
- fs5.writeFileSync(agentEnvFile, envContent, "utf8");
987
- spinner.text = chalk4.cyan("Added API keys to agent .env file");
988
- }
989
- } catch (error) {
990
- spinner.fail(chalk4.red("Failed to clone agent template"));
991
- throw error;
992
- }
993
- spinner.succeed(`${userAnswers.mode} agent cloned successfully`);
994
- }
995
- var AgentTemplates = {
996
- LangGraph: {
997
- Starter: {
998
- Python: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-py",
999
- TypeScript: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-langgraph/agent-js"
1000
- }
1001
- },
1002
- CrewAI: {
1003
- Flows: {
1004
- Starter: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/starters/coagents-crewai-flows/agent-py"
1005
- }
1006
- }
1007
- };
1008
-
1009
- // src/lib/init/scaffold/crew-inputs.ts
1010
- import * as fs6 from "fs/promises";
1011
- import ora3 from "ora";
1012
- import * as path5 from "path";
1013
- async function addCrewInputs(url, token) {
1014
- try {
1015
- const spinner = ora3("Analyzing crew inputs...").start();
1016
- const inputs = await getCrewInputs(url, token);
1017
- spinner.text = "Adding inputs to app/copilotkit/page.tsx...";
1018
- let filePath = path5.join(process.cwd(), "app", "copilotkit", "page.tsx");
1019
- try {
1020
- await fs6.access(filePath);
1021
- } catch {
1022
- filePath = path5.join(
1023
- process.cwd(),
1024
- "src",
1025
- "app",
1026
- "copilotkit",
1027
- "page.tsx"
1028
- );
1029
- }
1030
- try {
1031
- await fs6.access(filePath);
1032
- } catch {
1033
- throw new Error(
1034
- "app/copilotkit/page.tsx and src/app/copilotkit/page.tsx not found"
1035
- );
1036
- }
1037
- let fileContent = await fs6.readFile(filePath, "utf8");
1038
- const inputsString = JSON.stringify(inputs);
1039
- fileContent = fileContent.replace(
1040
- /\[["']YOUR_INPUTS_HERE["']\]/g,
1041
- inputsString
1042
- );
1043
- await fs6.writeFile(filePath, fileContent, "utf8");
1044
- spinner.succeed(
1045
- "Successfully added crew inputs to app/copilotkit/page.tsx"
1046
- );
1047
- } catch (error) {
1048
- console.error("Error updating crew inputs:", error);
1049
- throw error;
1050
- }
1051
- }
1052
- async function getCrewInputs(url, token) {
1053
- const response = await fetch(`${url.trim()}/inputs`, {
1054
- headers: {
1055
- Authorization: `Bearer ${token}`
1056
- }
1057
- });
1058
- if (!response.ok) {
1059
- throw new Error(`Failed to fetch inputs: ${response.statusText}`);
1060
- }
1061
- const data = await response.json();
1062
- return data.inputs;
1063
- }
1064
- export {
1065
- AgentTemplates,
1066
- ApiKeySchema,
1067
- CHAT_COMPONENTS,
1068
- CREW_FLOW_TEMPLATES,
1069
- CREW_TYPES,
1070
- ChatComponentSchema,
1071
- ConfigFlags,
1072
- ConfigSchema,
1073
- CrewFlowTemplateSchema,
1074
- CrewTypeSchema,
1075
- DEPLOYMENT_CHOICES,
1076
- DeploymentChoiceSchema,
1077
- IDE_DOCS_CONFIGS,
1078
- LANGGRAPH_AGENTS,
1079
- LLMApiKeySchema,
1080
- LangGraphAgentSchema,
1081
- MODES,
1082
- ModeSchema,
1083
- NameSchema,
1084
- TokenSchema,
1085
- UrlSchema,
1086
- YES_NO,
1087
- YesNoSchema,
1088
- addCrewInputs,
1089
- cloneGitHubSubdirectory,
1090
- detectInstalledIDEs,
1091
- getQuestionsForBranch,
1092
- handleIDEDocsSetup,
1093
- isLocalhost,
1094
- isValidGitHubUrl,
1095
- questions,
1096
- sanitizers,
1097
- scaffoldAgent,
1098
- scaffoldEnv,
1099
- scaffoldPackages,
1100
- scaffoldShadCN,
1101
- setupIDEDocs,
1102
- templateMapping
1103
- };
1104
- //# sourceMappingURL=index.js.map