copilotkit 1.0.2 → 2.0.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.
Files changed (146) hide show
  1. package/index.js +89779 -0
  2. package/package.json +4 -108
  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/api-client.d.ts +106 -0
  22. package/src/services/api-client.d.ts.map +1 -0
  23. package/src/services/auth.service.d.ts +107 -0
  24. package/src/services/auth.service.d.ts.map +1 -0
  25. package/src/services/cli-auth-diagnostics.d.ts +71 -0
  26. package/src/services/cli-auth-diagnostics.d.ts.map +1 -0
  27. package/src/services/cli-logs.d.ts +45 -0
  28. package/src/services/cli-logs.d.ts.map +1 -0
  29. package/src/services/config.service.d.ts +53 -0
  30. package/src/services/config.service.d.ts.map +1 -0
  31. package/src/services/feature-flags.d.ts +14 -0
  32. package/src/services/feature-flags.d.ts.map +1 -0
  33. package/src/services/kite-game-engine.d.ts +99 -0
  34. package/src/services/kite-game-engine.d.ts.map +1 -0
  35. package/src/services/kite-game-score.d.ts +33 -0
  36. package/src/services/kite-game-score.d.ts.map +1 -0
  37. package/src/services/project-scaffold.d.ts +49 -0
  38. package/src/services/project-scaffold.d.ts.map +1 -0
  39. package/src/types.d.ts +205 -0
  40. package/src/types.d.ts.map +1 -0
  41. package/src/ui/banner.d.ts +3 -0
  42. package/src/ui/banner.d.ts.map +1 -0
  43. package/src/ui/browser-login.d.ts +71 -0
  44. package/src/ui/browser-login.d.ts.map +1 -0
  45. package/src/ui/init-flow.d.ts +35 -0
  46. package/src/ui/init-flow.d.ts.map +1 -0
  47. package/src/ui/kite-game.d.ts +26 -0
  48. package/src/ui/kite-game.d.ts.map +1 -0
  49. package/src/ui/login-flow.d.ts +22 -0
  50. package/src/ui/login-flow.d.ts.map +1 -0
  51. package/src/ui/spinner.d.ts +9 -0
  52. package/src/ui/spinner.d.ts.map +1 -0
  53. package/LICENSE +0 -21
  54. package/README.md +0 -83
  55. package/bin/dev.cmd +0 -3
  56. package/bin/dev.js +0 -8
  57. package/bin/run.cmd +0 -3
  58. package/bin/run.js +0 -17
  59. package/dist/commands/base-command.d.ts +0 -12
  60. package/dist/commands/base-command.js +0 -65
  61. package/dist/commands/base-command.js.map +0 -1
  62. package/dist/commands/create.d.ts +0 -27
  63. package/dist/commands/create.js +0 -710
  64. package/dist/commands/create.js.map +0 -1
  65. package/dist/commands/dev.d.ts +0 -25
  66. package/dist/commands/dev.js +0 -776
  67. package/dist/commands/dev.js.map +0 -1
  68. package/dist/commands/init.d.ts +0 -11
  69. package/dist/commands/init.js +0 -726
  70. package/dist/commands/init.js.map +0 -1
  71. package/dist/commands/login.d.ts +0 -13
  72. package/dist/commands/login.js +0 -374
  73. package/dist/commands/login.js.map +0 -1
  74. package/dist/commands/logout.d.ts +0 -13
  75. package/dist/commands/logout.js +0 -375
  76. package/dist/commands/logout.js.map +0 -1
  77. package/dist/index.d.ts +0 -1
  78. package/dist/index.js +0 -6
  79. package/dist/index.js.map +0 -1
  80. package/dist/lib/init/ide-docs.d.ts +0 -25
  81. package/dist/lib/init/ide-docs.js +0 -170
  82. package/dist/lib/init/ide-docs.js.map +0 -1
  83. package/dist/lib/init/index.d.ts +0 -14
  84. package/dist/lib/init/index.js +0 -1106
  85. package/dist/lib/init/index.js.map +0 -1
  86. package/dist/lib/init/questions.d.ts +0 -9
  87. package/dist/lib/init/questions.js +0 -508
  88. package/dist/lib/init/questions.js.map +0 -1
  89. package/dist/lib/init/scaffold/agent.d.ts +0 -20
  90. package/dist/lib/init/scaffold/agent.js +0 -173
  91. package/dist/lib/init/scaffold/agent.js.map +0 -1
  92. package/dist/lib/init/scaffold/crew-inputs.d.ts +0 -3
  93. package/dist/lib/init/scaffold/crew-inputs.js +0 -59
  94. package/dist/lib/init/scaffold/crew-inputs.js.map +0 -1
  95. package/dist/lib/init/scaffold/env.d.ts +0 -7
  96. package/dist/lib/init/scaffold/env.js +0 -126
  97. package/dist/lib/init/scaffold/env.js.map +0 -1
  98. package/dist/lib/init/scaffold/github.d.ts +0 -17
  99. package/dist/lib/init/scaffold/github.js +0 -114
  100. package/dist/lib/init/scaffold/github.js.map +0 -1
  101. package/dist/lib/init/scaffold/index.d.ts +0 -10
  102. package/dist/lib/init/scaffold/index.js +0 -692
  103. package/dist/lib/init/scaffold/index.js.map +0 -1
  104. package/dist/lib/init/scaffold/langgraph-assistants.d.ts +0 -18
  105. package/dist/lib/init/scaffold/langgraph-assistants.js +0 -28
  106. package/dist/lib/init/scaffold/langgraph-assistants.js.map +0 -1
  107. package/dist/lib/init/scaffold/packages.d.ts +0 -7
  108. package/dist/lib/init/scaffold/packages.js +0 -62
  109. package/dist/lib/init/scaffold/packages.js.map +0 -1
  110. package/dist/lib/init/scaffold/shadcn.d.ts +0 -7
  111. package/dist/lib/init/scaffold/shadcn.js +0 -279
  112. package/dist/lib/init/scaffold/shadcn.js.map +0 -1
  113. package/dist/lib/init/types/index.d.ts +0 -4
  114. package/dist/lib/init/types/index.js +0 -238
  115. package/dist/lib/init/types/index.js.map +0 -1
  116. package/dist/lib/init/types/questions.d.ts +0 -209
  117. package/dist/lib/init/types/questions.js +0 -214
  118. package/dist/lib/init/types/questions.js.map +0 -1
  119. package/dist/lib/init/types/templates.d.ts +0 -17
  120. package/dist/lib/init/types/templates.js +0 -26
  121. package/dist/lib/init/types/templates.js.map +0 -1
  122. package/dist/lib/init/utils.d.ts +0 -3
  123. package/dist/lib/init/utils.js +0 -8
  124. package/dist/lib/init/utils.js.map +0 -1
  125. package/dist/services/analytics.service.d.ts +0 -38
  126. package/dist/services/analytics.service.js +0 -134
  127. package/dist/services/analytics.service.js.map +0 -1
  128. package/dist/services/auth.service.d.ts +0 -26
  129. package/dist/services/auth.service.js +0 -299
  130. package/dist/services/auth.service.js.map +0 -1
  131. package/dist/services/events.d.ts +0 -119
  132. package/dist/services/events.js +0 -1
  133. package/dist/services/events.js.map +0 -1
  134. package/dist/services/tunnel.service.d.ts +0 -15
  135. package/dist/services/tunnel.service.js +0 -21
  136. package/dist/services/tunnel.service.js.map +0 -1
  137. package/dist/utils/detect-endpoint-type.utils.d.ts +0 -15
  138. package/dist/utils/detect-endpoint-type.utils.js +0 -157
  139. package/dist/utils/detect-endpoint-type.utils.js.map +0 -1
  140. package/dist/utils/trpc.d.ts +0 -4
  141. package/dist/utils/trpc.js +0 -25
  142. package/dist/utils/trpc.js.map +0 -1
  143. package/dist/utils/version.d.ts +0 -3
  144. package/dist/utils/version.js +0 -6
  145. package/dist/utils/version.js.map +0 -1
  146. package/oclif.manifest.json +0 -216
@@ -1,726 +0,0 @@
1
- // src/commands/base-command.ts
2
- import { Command } from "@oclif/core";
3
- import Sentry, { consoleIntegration } from "@sentry/node";
4
-
5
- // src/utils/version.ts
6
- var LIB_VERSION = "1.0.2";
7
-
8
- // src/utils/trpc.ts
9
- import { createTRPCClient as trpcClient, httpBatchLink } from "@trpc/client";
10
- import superjson from "superjson";
11
- var COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || "https://cloud.copilotkit.ai";
12
-
13
- // src/commands/base-command.ts
14
- import chalk from "chalk";
15
- var BaseCommand = class extends Command {
16
- async init() {
17
- await this.checkCLIVersion();
18
- if (process.env.SENTRY_DISABLED === "true") {
19
- return;
20
- }
21
- Sentry.init({
22
- dsn: process.env.SENTRY_DSN || "https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120",
23
- integrations: [consoleIntegration()],
24
- // Tracing
25
- tracesSampleRate: 1
26
- // Capture 100% of the transactions
27
- });
28
- }
29
- async catch(err) {
30
- if (process.env.SENTRY_DISABLED !== "true") {
31
- Sentry.captureException(err);
32
- }
33
- const message = err?.message ?? "Unknown error";
34
- this.log("\n" + chalk.red(message) + "\n");
35
- const exitCode = err?.oclif?.exit ?? 1;
36
- this.exit(exitCode);
37
- }
38
- async finally() {
39
- if (process.env.SENTRY_DISABLED === "true") {
40
- return;
41
- }
42
- Sentry.close();
43
- }
44
- async run() {
45
- }
46
- async checkCLIVersion() {
47
- try {
48
- const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`);
49
- const data = await response.json();
50
- const cloudVersion = data.cliVersion;
51
- if (!cloudVersion || cloudVersion === LIB_VERSION) {
52
- return;
53
- }
54
- } catch {
55
- }
56
- }
57
- async gracefulError(message) {
58
- this.log("\n" + chalk.red(message));
59
- process.exit(1);
60
- }
61
- };
62
-
63
- // src/commands/create.ts
64
- import { Flags, Args } from "@oclif/core";
65
- import inquirer from "inquirer";
66
- import chalk3 from "chalk";
67
- import fs2 from "fs-extra";
68
- import path2 from "path";
69
- import { promisify } from "util";
70
- import { pipeline } from "stream";
71
- import { createWriteStream } from "fs";
72
- import { extract } from "tar";
73
- import ora from "ora";
74
-
75
- // src/lib/init/scaffold/github.ts
76
- import { execSync } from "child_process";
77
- import * as fs from "fs";
78
- import * as path from "path";
79
- import * as os from "os";
80
- import chalk2 from "chalk";
81
- async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
82
- try {
83
- const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
84
- spinner.text = chalk2.cyan(`Cloning from ${owner}/${repo}...`);
85
- return await sparseCheckout(
86
- owner,
87
- repo,
88
- branch,
89
- subdirectoryPath,
90
- destinationPath,
91
- spinner
92
- );
93
- } catch (error) {
94
- spinner.text = chalk2.red(`Failed to clone from GitHub: ${error}`);
95
- return false;
96
- }
97
- }
98
- async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
99
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilotkit-sparse-"));
100
- try {
101
- spinner.text = chalk2.cyan("Creating temporary workspace...");
102
- execSync("git init", { cwd: tempDir, stdio: "pipe" });
103
- spinner.text = chalk2.cyan("Connecting to repository...");
104
- execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, {
105
- cwd: tempDir,
106
- stdio: "pipe"
107
- });
108
- execSync("git config core.sparseCheckout true", {
109
- cwd: tempDir,
110
- stdio: "pipe"
111
- });
112
- fs.writeFileSync(
113
- path.join(tempDir, ".git/info/sparse-checkout"),
114
- subdirectoryPath
115
- );
116
- spinner.text = chalk2.cyan("Downloading agent files...");
117
- execSync(`git pull origin ${branch} --depth=1`, {
118
- cwd: tempDir,
119
- stdio: "pipe"
120
- });
121
- const sourcePath = path.join(tempDir, subdirectoryPath);
122
- if (!fs.existsSync(sourcePath)) {
123
- throw new Error(
124
- `Subdirectory '${subdirectoryPath}' not found in the repository.`
125
- );
126
- }
127
- fs.mkdirSync(destinationPath, { recursive: true });
128
- spinner.text = chalk2.cyan("Installing agent files...");
129
- await copyDirectoryAsync(sourcePath, destinationPath);
130
- return true;
131
- } finally {
132
- try {
133
- fs.rmSync(tempDir, { recursive: true, force: true });
134
- } catch (error) {
135
- console.warn(`Failed to clean up temporary directory: ${error}`);
136
- }
137
- }
138
- }
139
- async function copyDirectoryAsync(source, destination) {
140
- if (!fs.existsSync(destination)) {
141
- fs.mkdirSync(destination, { recursive: true });
142
- }
143
- const entries = fs.readdirSync(source, { withFileTypes: true });
144
- for (const entry of entries) {
145
- const srcPath = path.join(source, entry.name);
146
- const destPath = path.join(destination, entry.name);
147
- if (entry.isDirectory()) {
148
- await copyDirectoryAsync(srcPath, destPath);
149
- } else {
150
- fs.copyFileSync(srcPath, destPath);
151
- }
152
- if (entries.length > 10) {
153
- await new Promise((resolve) => setTimeout(resolve, 1));
154
- }
155
- }
156
- }
157
- function parseGitHubUrl(githubUrl) {
158
- const url = new URL(githubUrl);
159
- if (url.hostname !== "github.com") {
160
- throw new Error("Only GitHub URLs are supported");
161
- }
162
- const pathParts = url.pathname.split("/").filter(Boolean);
163
- if (pathParts.length < 2) {
164
- throw new Error("Invalid GitHub URL format");
165
- }
166
- const owner = pathParts[0];
167
- const repo = pathParts[1];
168
- let branch = "main";
169
- let subdirectoryPath = "";
170
- if (pathParts.length > 3 && (pathParts[2] === "tree" || pathParts[2] === "blob")) {
171
- branch = pathParts[3];
172
- subdirectoryPath = pathParts.slice(4).join("/");
173
- }
174
- return { owner, repo, branch, subdirectoryPath };
175
- }
176
- function isValidGitHubUrl(url) {
177
- try {
178
- const parsedUrl = new URL(url);
179
- return parsedUrl.hostname === "github.com" && parsedUrl.pathname.split("/").filter(Boolean).length >= 2;
180
- } catch {
181
- return false;
182
- }
183
- }
184
-
185
- // src/commands/create.ts
186
- var streamPipeline = promisify(pipeline);
187
- var theme = {
188
- primary: chalk3.magenta,
189
- secondary: chalk3.gray,
190
- tertiary: chalk3.gray,
191
- error: chalk3.red,
192
- command: chalk3.blue,
193
- success: chalk3.green,
194
- warning: chalk3.yellow,
195
- divider: chalk3.gray("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),
196
- bottomPadding: ""
197
- };
198
- var TEMPLATE_REPOS = {
199
- "langgraph-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-python",
200
- "langgraph-js": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-js",
201
- mastra: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/mastra",
202
- flows: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/crewai-flows",
203
- llamaindex: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/llamaindex",
204
- agno: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/agno",
205
- "pydantic-ai": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/pydantic-ai",
206
- ag2: "ag2ai/ag2-copilotkit-starter",
207
- adk: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/adk",
208
- "aws-strands-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/strands-python",
209
- a2a: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/a2a-middleware",
210
- "microsoft-agent-framework-dotnet": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/ms-agent-framework-dotnet",
211
- "microsoft-agent-framework-py": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/ms-agent-framework-python",
212
- "mcp-apps": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/mcp-apps",
213
- "agentcore-langgraph": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/agentcore",
214
- "agentcore-strands": "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/agentcore",
215
- a2ui: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-python",
216
- opengenui: "https://github.com/CopilotKit/CopilotKit/tree/main/examples/integrations/langgraph-python"
217
- };
218
- var FRAMEWORK_DOCUMENTATION = {
219
- "langgraph-py": "https://langchain-ai.github.io/langgraph/concepts/why-langgraph",
220
- "langgraph-js": "https://langchain-ai.github.io/langgraphjs",
221
- flows: "https://docs.crewai.com/guides/flows/first-flow",
222
- mastra: "https://mastra.ai/en/docs",
223
- "pydantic-ai": "https://ai.pydantic.dev/ag-ui/",
224
- llamaindex: "https://docs.llamaindex.ai/en/stable",
225
- agno: "https://docs.agno.com/",
226
- ag2: "https://docs.ag2.ai/latest/docs/user-guide/basic-concepts/overview",
227
- adk: "https://google.github.io/adk-docs/",
228
- "aws-strands-py": "https://strandsagents.com/latest/documentation/docs/",
229
- a2a: "https://a2a-protocol.org/latest/",
230
- "microsoft-agent-framework-dotnet": "https://learn.microsoft.com/en-us/agent-framework/",
231
- "microsoft-agent-framework-py": "https://learn.microsoft.com/en-us/agent-framework/",
232
- "mcp-apps": "https://modelcontextprotocol.github.io/ext-apps",
233
- "agentcore-langgraph": "https://docs.copilotkit.ai/agentcore/quickstart",
234
- "agentcore-strands": "https://docs.copilotkit.ai/agentcore/quickstart",
235
- a2ui: "https://a2ui.org/specification/",
236
- opengenui: "https://docs.copilotkit.ai"
237
- };
238
- var FRAMEWORK_EMOJI = {
239
- "langgraph-js": "\u{1F99C}",
240
- "langgraph-py": "\u{1F99C}",
241
- flows: "\u{1F465}",
242
- mastra: "\u{1F311}",
243
- "pydantic-ai": "\u{1F53C}",
244
- llamaindex: "\u{1F999}",
245
- ag2: "\u{1F916}",
246
- agno: "\u{1F170}\uFE0F",
247
- adk: "\u{1F916}",
248
- a2a: "\u{1F916}",
249
- "aws-strands-py": "\u{1F9EC}",
250
- "microsoft-agent-framework-dotnet": "\u{1F7E6}",
251
- "microsoft-agent-framework-py": "\u{1F7E6}",
252
- "mcp-apps": "\u264D",
253
- "agentcore-langgraph": "\u2601\uFE0F",
254
- "agentcore-strands": "\u2601\uFE0F",
255
- a2ui: "\u{1F3A8}",
256
- opengenui: "\u{1F5BC}\uFE0F"
257
- };
258
- var KITE = `
259
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
260
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u281F\u2819\u28FF\u285B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
261
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u280B\u2800\u2800\u2808\u28BF\u2844\u2800\u2800\u2800\u2808\u2809\u2819\u28FB\u28FF\u28FF\u28FF
262
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u281F\u2801\u2800\u2800\u2800\u2800\u2808\u28BF\u2844\u2800\u2880\u28E0\u28F4\u283E\u280B\u28B8\u28FF\u28FF
263
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u285F\u2801\u2880\u28C0\u28C0\u28C0\u28C0\u28E4\u28E4\u287E\u28BF\u285F\u281B\u2809\u2800\u2800\u2800\u2800\u28FF\u28FF
264
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u285B\u281B\u281B\u281B\u2809\u2809\u2809\u2801\u2800\u28A0\u287F\u28FF\u2840\u2800\u2800\u2800\u2800\u2800\u28FF\u28FF
265
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28C6\u2800\u2800\u2800\u2800\u2800\u2800\u28F0\u285F\u2800\u2838\u28E7\u2800\u2800\u2800\u2800\u28A0\u28FF\u28FF
266
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F7\u28C4\u2800\u2800\u2880\u28FC\u280F\u2800\u2800\u2800\u28FF\u2840\u2800\u2800\u2800\u28B8\u28FF\u28FF
267
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u2802\u28E0\u287F\u2801\u2800\u2800\u2800\u2800\u28B8\u2847\u2800\u2800\u2800\u28FF\u28FF\u28FF
268
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u281F\u28E1\u28FE\u28FF\u28C4\u2800\u2800\u2800\u2800\u2800\u28B8\u2847\u2800\u2800\u28B0\u28FF\u28FF\u28FF
269
- \u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u285F\u281B\u287F\u280B\u28E1\u28FE\u28FF\u28FF\u28FF\u28FF\u28E6\u2840\u2800\u2800\u2800\u28B8\u2847\u2800\u2800\u28FF\u28FF\u28FF\u28FF
270
- \u28FF\u28FF\u28FF\u28FF\u287F\u283F\u28FF\u2837\u2802\u2840\u2818\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F7\u2840\u2800\u2800\u28B8\u2847\u2800\u28FC\u28FF\u28FF\u28FF\u28FF
271
- \u28FF\u28FF\u283B\u28BF\u2877\u2800\u2801\u2834\u28FF\u28F7\u28FE\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u2844\u2800\u28FE\u2807\u28F4\u28FF\u28FF\u28FF\u28FF\u28FF
272
- \u287F\u281B\u2800\u2800\u28B4\u28FE\u28F7\u28F6\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28E4\u28FF\u28FE\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
273
- \u28F7\u28FE\u28FF\u28E4\u28FE\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
274
- `;
275
- var Create = class _Create extends BaseCommand {
276
- static description = "Create a new CopilotKit project";
277
- static examples = [
278
- "$ copilotkit create my-app",
279
- "$ copilotkit create my-app --framework langgraph-js",
280
- "$ copilotkit create -n my-app -f langgraph-js"
281
- ];
282
- static flags = {
283
- ...BaseCommand.flags,
284
- framework: Flags.string({
285
- char: "f",
286
- description: "Agent framework to use",
287
- options: Object.keys(TEMPLATE_REPOS),
288
- required: false
289
- }),
290
- name: Flags.string({
291
- char: "n",
292
- description: "Name of the project",
293
- required: false
294
- }),
295
- "no-banner": Flags.boolean({
296
- char: "q",
297
- description: "Removes the banner",
298
- default: false,
299
- required: false
300
- }),
301
- project: Flags.string({
302
- description: "project ID (deprecated, kept for backwards compatibility)"
303
- })
304
- };
305
- static args = {
306
- projectName: Args.string({
307
- description: "Name of the project",
308
- required: false
309
- })
310
- };
311
- constructor(argv, config) {
312
- super(argv, config);
313
- }
314
- async run() {
315
- const { args, flags } = await this.parse(_Create);
316
- if (!flags["no-banner"]) {
317
- this.log(theme.primary(KITE));
318
- this.log(theme.primary("~ Welcome to CopilotKit! ~\n"));
319
- this.log(theme.divider);
320
- if (!flags.name && !args.projectName && !flags.framework) {
321
- this.log(
322
- "\n" + theme.secondary("Just a few questions to get started!\n")
323
- );
324
- }
325
- }
326
- const projectNameInput = flags.name || args.projectName || await this.promptProjectName();
327
- const projectName = projectNameInput.trim();
328
- const usingCurrentDir = projectName === "." || projectName === "./";
329
- const agentFramework = flags.framework || await this.promptAgentFramework();
330
- const projectDir = usingCurrentDir ? process.cwd() : path2.resolve(process.cwd(), projectName);
331
- if (usingCurrentDir) {
332
- const allowedEntries = /* @__PURE__ */ new Set([".git", ".gitignore", ".DS_Store"]);
333
- const existingEntries = await fs2.readdir(projectDir);
334
- const blockingEntries = existingEntries.filter(
335
- (entry) => !allowedEntries.has(entry)
336
- );
337
- if (blockingEntries.length > 0) {
338
- this.log(theme.error("\nCurrent directory is not empty."));
339
- this.log(
340
- theme.secondary(
341
- "\nPlease run create in an empty directory or specify a new project name."
342
- )
343
- );
344
- this.exit(1);
345
- }
346
- } else if (await fs2.pathExists(projectDir)) {
347
- this.log(theme.error(`
348
- Directory "${projectName}" already exists.`));
349
- this.log(theme.secondary("\nYou can:"));
350
- this.log(theme.secondary(" 1. Choose a different project name"));
351
- this.log(
352
- theme.secondary(
353
- " 2. Remove the existing directory manually if you want to use this name\n"
354
- )
355
- );
356
- this.exit(1);
357
- }
358
- const options = {
359
- projectName,
360
- agentFramework
361
- };
362
- const spinner = ora({
363
- text: theme.secondary.bold("Creating your project..."),
364
- color: "cyan",
365
- spinner: "dots"
366
- }).start();
367
- try {
368
- await fs2.ensureDir(projectDir);
369
- spinner.text = theme.secondary.bold("Downloading template...");
370
- await this.downloadTemplate(projectDir, options.agentFramework, spinner);
371
- await this.applyShowcaseConfig(projectDir, options.agentFramework);
372
- if (options.agentFramework === "agentcore-langgraph" || options.agentFramework === "agentcore-strands") {
373
- spinner.text = theme.secondary.bold("Configuring AgentCore...");
374
- await this.configureAgentCore(projectDir, options.agentFramework);
375
- }
376
- const displayName = usingCurrentDir ? "current directory" : `"${projectName}"`;
377
- spinner.succeed(
378
- theme.secondary.bold(`Project ${displayName} created successfully!`)
379
- );
380
- } catch (error) {
381
- spinner.fail(theme.error(`Failed to create project: ${error.message}`));
382
- this.exit(1);
383
- }
384
- this.log("\n" + theme.divider);
385
- this.log(
386
- "\n" + theme.secondary.bold(
387
- `\u{1FA81}\u{1F91D}${FRAMEWORK_EMOJI[options.agentFramework]} All set!
388
-
389
- Your project is ready to explore CopilotKit locally.`
390
- )
391
- );
392
- this.log("\n" + theme.secondary("Next steps:"));
393
- if (usingCurrentDir) {
394
- this.log(
395
- theme.secondary(
396
- " \u2022 You are already inside your new project directory"
397
- )
398
- );
399
- } else {
400
- this.log(theme.secondary(` \u2022 ${theme.command(`cd ${projectName}`)}`));
401
- }
402
- this.log(
403
- theme.secondary(" \u2022 Follow the setup instructions in the README.md")
404
- );
405
- this.log("\n" + theme.secondary("Documentation:"));
406
- this.log(
407
- theme.secondary(" \u2022 ") + theme.command("https://docs.copilotkit.ai")
408
- );
409
- this.log(
410
- theme.secondary(" \u2022 ") + theme.command(FRAMEWORK_DOCUMENTATION[options.agentFramework])
411
- );
412
- this.log(theme.bottomPadding);
413
- }
414
- async promptProjectName() {
415
- const { projectName } = await inquirer.prompt([
416
- {
417
- type: "input",
418
- name: "projectName",
419
- message: theme.secondary("What is your project named?"),
420
- validate: (input) => {
421
- if (!input) return theme.error("Project name is required");
422
- if (!/^[a-z0-9-]+$/.test(input)) {
423
- return theme.error(
424
- "Project name can only contain lowercase letters, numbers, and hyphens"
425
- );
426
- }
427
- if (input.length > 30) {
428
- return theme.error("Project name must be less than 30 characters");
429
- }
430
- return true;
431
- }
432
- }
433
- ]);
434
- return projectName;
435
- }
436
- async promptAgentFramework() {
437
- const { framework } = await inquirer.prompt([
438
- {
439
- type: "list",
440
- name: "framework",
441
- message: theme.secondary(
442
- "Which agent framework would you like to use?"
443
- ),
444
- choices: [
445
- {
446
- name: `${FRAMEWORK_EMOJI["langgraph-py"]} LangGraph (Python)`,
447
- value: "langgraph-py"
448
- },
449
- {
450
- name: `${FRAMEWORK_EMOJI["langgraph-js"]} LangGraph (JavaScript)`,
451
- value: "langgraph-js"
452
- },
453
- { name: `${FRAMEWORK_EMOJI.mastra} Mastra`, value: "mastra" },
454
- {
455
- name: `${FRAMEWORK_EMOJI["pydantic-ai"]} Pydantic AI`,
456
- value: "pydantic-ai"
457
- },
458
- {
459
- name: `${FRAMEWORK_EMOJI["aws-strands-py"]} AWS Strands (Python)`,
460
- value: "aws-strands-py"
461
- },
462
- { name: `${FRAMEWORK_EMOJI.adk} ADK`, value: "adk" },
463
- {
464
- name: `${FRAMEWORK_EMOJI["microsoft-agent-framework-dotnet"]} Microsoft Agent Framework (.NET)`,
465
- value: "microsoft-agent-framework-dotnet"
466
- },
467
- {
468
- name: `${FRAMEWORK_EMOJI["microsoft-agent-framework-py"]} Microsoft Agent Framework (Python)`,
469
- value: "microsoft-agent-framework-py"
470
- },
471
- {
472
- name: `${FRAMEWORK_EMOJI["mcp-apps"]} MCP Apps`,
473
- value: "mcp-apps"
474
- },
475
- { name: `${FRAMEWORK_EMOJI.flows} CrewAI Flows`, value: "flows" },
476
- {
477
- name: `${FRAMEWORK_EMOJI.llamaindex} LlamaIndex`,
478
- value: "llamaindex"
479
- },
480
- { name: `${FRAMEWORK_EMOJI.agno} Agno`, value: "agno" },
481
- { name: `${FRAMEWORK_EMOJI.ag2} AG2`, value: "ag2" },
482
- { name: `${FRAMEWORK_EMOJI.a2a} A2A`, value: "a2a" },
483
- {
484
- name: `${FRAMEWORK_EMOJI["agentcore-langgraph"]} AgentCore + LangGraph`,
485
- value: "agentcore-langgraph"
486
- },
487
- {
488
- name: `${FRAMEWORK_EMOJI["agentcore-strands"]} AgentCore + Strands`,
489
- value: "agentcore-strands"
490
- },
491
- { name: `${FRAMEWORK_EMOJI.a2ui} A2UI`, value: "a2ui" },
492
- {
493
- name: `${FRAMEWORK_EMOJI.opengenui} Open Generative UI`,
494
- value: "opengenui"
495
- }
496
- ]
497
- }
498
- ]);
499
- return framework;
500
- }
501
- async configureAgentCore(projectDir, framework) {
502
- const pattern = framework === "agentcore-langgraph" ? "langgraph-single-agent" : "strands-single-agent";
503
- const suffix = framework === "agentcore-langgraph" ? "-lg" : "-st";
504
- const examplePath = path2.join(projectDir, "config.yaml.example");
505
- const configPath = path2.join(projectDir, "config.yaml");
506
- if (!await fs2.pathExists(examplePath)) {
507
- throw new Error(
508
- `config.yaml.example not found in the AgentCore template at "${projectDir}". The downloaded template may be incomplete. Please try again.`
509
- );
510
- }
511
- let content = await fs2.readFile(examplePath, "utf-8");
512
- const patternRegex = /^(\s*pattern:\s*)\S+(.*)$/m;
513
- const stackRegex = /^(\s*stack_name_base:\s*)\S+(.*)$/m;
514
- if (!patternRegex.test(content) || !stackRegex.test(content)) {
515
- throw new Error(
516
- `Unexpected config.yaml.example format in the AgentCore template. Expected "pattern:" and "stack_name_base:" keys. Please try again or report this issue at https://github.com/CopilotKit/CopilotKit/issues`
517
- );
518
- }
519
- content = content.replace(patternRegex, `$1${pattern}$2`);
520
- content = content.replace(
521
- stackRegex,
522
- `$1my-copilotkit-agentcore${suffix}$2`
523
- );
524
- await fs2.writeFile(configPath, content, "utf-8");
525
- const isLanggraph = framework === "agentcore-langgraph";
526
- const removeAgent = isLanggraph ? "strands-single-agent" : "langgraph-single-agent";
527
- const removeScript = isLanggraph ? "deploy-strands.sh" : "deploy-langgraph.sh";
528
- const keepScript = isLanggraph ? "deploy-langgraph.sh" : "deploy-strands.sh";
529
- await Promise.all([
530
- fs2.remove(path2.join(projectDir, "agents", removeAgent)),
531
- fs2.remove(path2.join(projectDir, removeScript)),
532
- fs2.remove(path2.join(projectDir, "infra-terraform"))
533
- ]);
534
- const keepScriptPath = path2.join(projectDir, keepScript);
535
- if (await fs2.pathExists(keepScriptPath)) {
536
- await fs2.move(keepScriptPath, path2.join(projectDir, "deploy.sh"));
537
- }
538
- const deployShPath = path2.join(projectDir, "deploy.sh");
539
- if (await fs2.pathExists(deployShPath)) {
540
- let deployContent = await fs2.readFile(deployShPath, "utf-8");
541
- deployContent = deployContent.replace(/\(isolated from deploy-(?:langgraph|strands)\.sh\)\s*/g, "").replace(/# Using Terraform instead\?.*\n/g, "");
542
- await fs2.writeFile(deployShPath, deployContent, "utf-8");
543
- }
544
- const configYamlPath = path2.join(projectDir, "config.yaml");
545
- if (await fs2.pathExists(configYamlPath)) {
546
- let configContent = await fs2.readFile(configYamlPath, "utf-8");
547
- configContent = configContent.replace(
548
- /# overwritten by deploy-langgraph\.sh \/ deploy-strands\.sh/g,
549
- "# set by the CLI \u2014 do not change"
550
- );
551
- await fs2.writeFile(configYamlPath, configContent, "utf-8");
552
- }
553
- const agentShortName = isLanggraph ? "langgraph" : "strands";
554
- const otherShortName = isLanggraph ? "strands" : "langgraph";
555
- for (const relPath of ["docker/docker-compose.yml", "docker/up.sh"]) {
556
- const filePath = path2.join(projectDir, relPath);
557
- if (await fs2.pathExists(filePath)) {
558
- let fileContent = await fs2.readFile(filePath, "utf-8");
559
- fileContent = fileContent.replaceAll(
560
- `AGENT:-${otherShortName}`,
561
- `AGENT:-${agentShortName}`
562
- );
563
- fileContent = fileContent.replaceAll(
564
- `echo "${otherShortName}"`,
565
- `echo "${agentShortName}"`
566
- );
567
- await fs2.writeFile(filePath, fileContent, "utf-8");
568
- }
569
- }
570
- const resolveEnvPath = path2.join(projectDir, "docker/resolve-env.py");
571
- if (await fs2.pathExists(resolveEnvPath)) {
572
- let resolveContent = await fs2.readFile(resolveEnvPath, "utf-8");
573
- resolveContent = resolveContent.replaceAll(
574
- `os.environ.get("AGENT", "${otherShortName}")`,
575
- `os.environ.get("AGENT", "${agentShortName}")`
576
- );
577
- await fs2.writeFile(resolveEnvPath, resolveContent, "utf-8");
578
- }
579
- const frameworkLabel = isLanggraph ? "LangGraph" : "Strands";
580
- const stackSuffix = isLanggraph ? "lg" : "st";
581
- const agentFolder = isLanggraph ? "langgraph-single-agent" : "strands-single-agent";
582
- const readme = `# CopilotKit + AWS AgentCore (${frameworkLabel})
583
-
584
- Chat UI with generative charts, shared-state todo canvas, and inline tool rendering \u2014 deployed on AWS Bedrock AgentCore.
585
-
586
- ## Prerequisites
587
-
588
- | Tool | Version |
589
- | ------- | ---------------------------- |
590
- | AWS CLI | configured (\`aws configure\`) |
591
- | Node.js | 18+ |
592
- | Python | 3.8+ |
593
- | Docker | running |
594
-
595
- ## Deploy
596
-
597
- 1. **Edit \`config.yaml\`** \u2014 set \`stack_name_base\` and \`admin_user_email\`
598
-
599
- 2. **Deploy:**
600
-
601
- \`\`\`bash
602
- ./deploy.sh # full deploy (infra + frontend)
603
- ./deploy.sh --skip-frontend # infra/agent only
604
- ./deploy.sh --skip-backend # frontend only
605
- \`\`\`
606
-
607
- 3. **Open** the Amplify URL printed at the end. Sign in with your email.
608
-
609
- ## Local Development
610
-
611
- \`\`\`bash
612
- cd docker
613
- cp .env.example .env
614
- # Fill in AWS creds \u2014 STACK_NAME, MEMORY_ID, and aws-exports.json are auto-resolved
615
- ./up.sh --build
616
- \`\`\`
617
-
618
- - **Frontend** \u2192 hot reloads on save
619
- - **Agent** \u2192 rebuild on changes: \`docker compose up --build agent\`
620
- - **Browser** \u2192 \`http://localhost:3000\`
621
-
622
- The full chain runs locally: \`browser:3000 \u2192 bridge:3001 \u2192 agent:8080\`. AWS is only used for Memory and Gateway.
623
-
624
- ## What's inside
625
-
626
- | Piece | What it does |
627
- | ------------------------------ | ---------------------------------------------------------- |
628
- | \`frontend/\` | Vite + React with CopilotKit chat, charts, todo canvas |
629
- | \`agents/${agentFolder}/\` | ${frameworkLabel} agent with tools + shared todo state |
630
- | \`infra-cdk/\` | CDK: Cognito, AgentCore, CopilotKit Lambda, Amplify |
631
- | \`docker/\` | Local dev via Docker Compose |
632
-
633
- ## Tear down
634
-
635
- \`\`\`bash
636
- cd infra-cdk && npx cdk@latest destroy --all --output ../cdk.out-${stackSuffix}
637
- \`\`\`
638
-
639
- ## Docs
640
-
641
- - [CopilotKit](https://docs.copilotkit.ai)
642
- - [AWS Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)
643
- - [AgentCore + CopilotKit Guide](https://docs.copilotkit.ai/agentcore/quickstart)
644
- `;
645
- await fs2.writeFile(path2.join(projectDir, "README.md"), readme, "utf-8");
646
- }
647
- async downloadTemplate(projectDir, framework, spinner) {
648
- const templateRef = TEMPLATE_REPOS[framework];
649
- if (templateRef.startsWith("/")) {
650
- const EXCLUDE = [
651
- "node_modules",
652
- "cdk.out",
653
- ".git",
654
- "__pycache__",
655
- ".venv"
656
- ];
657
- await fs2.copy(templateRef, projectDir, {
658
- filter: (src) => !EXCLUDE.some(
659
- (ex) => src.split("/").includes(ex) || src.includes(`/${ex}`)
660
- )
661
- });
662
- return;
663
- }
664
- if (isValidGitHubUrl(templateRef)) {
665
- const success = await cloneGitHubSubdirectory(
666
- templateRef,
667
- projectDir,
668
- spinner
669
- );
670
- if (!success) {
671
- throw new Error(`Failed to clone template from ${templateRef}`);
672
- }
673
- return;
674
- }
675
- const url = `https://github.com/${templateRef}/archive/refs/heads/main.tar.gz`;
676
- try {
677
- const response = await fetch(url);
678
- if (!response.ok)
679
- throw new Error(`Failed to download template: ${response.statusText}`);
680
- const tempFile = path2.join(projectDir, "template.tar.gz");
681
- const fileStream = createWriteStream(tempFile);
682
- if (!response.body) throw new Error("Failed to get response body");
683
- await streamPipeline(response.body, fileStream);
684
- await extract({
685
- file: tempFile,
686
- cwd: projectDir,
687
- strip: 1
688
- });
689
- await fs2.remove(tempFile);
690
- } catch (error) {
691
- throw new Error(`Failed to download template: ${error.message}`, {
692
- cause: error
693
- });
694
- }
695
- }
696
- static SHOWCASE_FRAMEWORKS = {
697
- a2ui: "a2ui",
698
- opengenui: "opengenui"
699
- };
700
- async applyShowcaseConfig(projectDir, framework) {
701
- const showcase = _Create.SHOWCASE_FRAMEWORKS[framework];
702
- if (!showcase) return;
703
- const configPath = path2.join(projectDir, "showcase.json");
704
- await fs2.writeJSON(configPath, { showcase });
705
- }
706
- };
707
-
708
- // src/commands/init.ts
709
- var CloudInit = class extends BaseCommand {
710
- static description = "`init` is deprecated \u2014 use `create` instead.";
711
- static examples = ["<%= config.bin %> create"];
712
- constructor(argv, config) {
713
- super(argv, config);
714
- }
715
- async run() {
716
- this.log(
717
- "`copilotkit init` is deprecated. Redirecting to `copilotkit create`..."
718
- );
719
- const createCommand = new Create(this.argv, this.config);
720
- await createCommand.run();
721
- }
722
- };
723
- export {
724
- CloudInit as default
725
- };
726
- //# sourceMappingURL=init.js.map