copilotkit 0.0.35 → 0.0.36
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 +78 -33
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +26 -47
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/index.js +13 -36
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +9 -23
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/agent.js +1 -6
- package/dist/lib/init/scaffold/agent.js.map +1 -1
- package/dist/lib/init/scaffold/env.js +1 -5
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +8 -23
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +6 -12
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.js +4 -10
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +0 -8
- package/dist/lib/init/types/questions.js +3 -5
- package/dist/lib/init/types/questions.js.map +1 -1
- package/dist/lib/init/types/templates.d.ts +1 -1
- package/dist/lib/init/types/templates.js +1 -5
- package/dist/lib/init/types/templates.js.map +1 -1
- package/dist/lib/init/utils.js.map +1 -1
- package/dist/utils/detect-endpoint-type.utils.d.ts +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/oclif.manifest.json +1 -11
- package/package.json +6 -2
|
@@ -3,7 +3,7 @@ import { Command } from "@oclif/core";
|
|
|
3
3
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
4
4
|
|
|
5
5
|
// src/utils/version.ts
|
|
6
|
-
var LIB_VERSION = "0.0.
|
|
6
|
+
var LIB_VERSION = "0.0.36";
|
|
7
7
|
|
|
8
8
|
// src/utils/trpc.ts
|
|
9
9
|
import { createTRPCClient as trpcClient, httpBatchLink } from "@trpc/client";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/base-command.ts","../../src/utils/version.ts","../../src/utils/trpc.ts"],"sourcesContent":["import {Command} from '@oclif/core'\nimport Sentry, {consoleIntegration} from '@sentry/node'\nimport {LIB_VERSION} from '../utils/version.js'\nimport {COPILOT_CLOUD_BASE_URL} from '../utils/trpc.js'\nimport chalk from 'chalk'\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion()\n\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n 'https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120',\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n })\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED === 'true') {\n super.catch(err)\n return\n }\n\n Sentry.captureException(err)\n super.catch(err)\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.close()\n }\n\n async run() {}\n\n async checkCLIVersion() {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`)\n\n const data = await response.json()\n const cloudVersion = data.cliVersion\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n }\n\n async gracefulError(message: string) {\n this.log('\\n' + chalk.red(message))\n process.exit(1)\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.
|
|
1
|
+
{"version":3,"sources":["../../src/commands/base-command.ts","../../src/utils/version.ts","../../src/utils/trpc.ts"],"sourcesContent":["import {Command} from '@oclif/core'\nimport Sentry, {consoleIntegration} from '@sentry/node'\nimport {LIB_VERSION} from '../utils/version.js'\nimport {COPILOT_CLOUD_BASE_URL} from '../utils/trpc.js'\nimport chalk from 'chalk'\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion()\n\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n 'https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120',\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n })\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED === 'true') {\n super.catch(err)\n return\n }\n\n Sentry.captureException(err)\n super.catch(err)\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.close()\n }\n\n async run() {}\n\n async checkCLIVersion() {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`)\n\n const data = await response.json()\n const cloudVersion = data.cliVersion\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n }\n\n async gracefulError(message: string) {\n this.log('\\n' + chalk.red(message))\n process.exit(1)\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.36\";\n","import {createTRPCClient as trpcClient, httpBatchLink} from '@trpc/client'\nimport superjson from 'superjson'\n\nexport const COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\nexport function createTRPCClient(cliToken: string): any {\n return trpcClient({\n links: [\n httpBatchLink({\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n transformer: superjson,\n headers: () => {\n return {\n 'x-trpc-source': 'cli',\n 'x-cli-token': cliToken,\n }\n },\n }),\n ],\n })\n}\n"],"mappings":";AAAA,SAAQ,eAAc;AACtB,OAAO,UAAS,0BAAyB;;;ACAlC,IAAM,cAAc;;;ACD3B,SAAQ,oBAAoB,YAAY,qBAAoB;AAC5D,OAAO,eAAe;AAEf,IAAM,yBAAyB,QAAQ,IAAI,0BAA0B;;;AFC5E,OAAO,WAAW;AAEX,IAAM,cAAN,cAA0B,QAAQ;AAAA,EACvC,MAAM,OAAO;AACX,UAAM,KAAK,gBAAgB;AAE3B,QAAI,QAAQ,IAAI,oBAAoB,QAAQ;AAC1C;AAAA,IACF;AAEA,WAAO,KAAK;AAAA,MACV,KACE,QAAQ,IAAI,cACZ;AAAA,MACF,cAAc,CAAC,mBAAmB,CAAC;AAAA;AAAA,MAEnC,kBAAkB;AAAA;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAM,KAAU;AACpB,QAAI,QAAQ,IAAI,oBAAoB,QAAQ;AAC1C,YAAM,MAAM,GAAG;AACf;AAAA,IACF;AAEA,WAAO,iBAAiB,GAAG;AAC3B,UAAM,MAAM,GAAG;AAAA,EACjB;AAAA,EAEA,MAAM,UAAU;AACd,QAAI,QAAQ,IAAI,oBAAoB,QAAQ;AAC1C;AAAA,IACF;AAEA,WAAO,MAAM;AAAA,EACf;AAAA,EAEA,MAAM,MAAM;AAAA,EAAC;AAAA,EAEb,MAAM,kBAAkB;AACtB,UAAM,WAAW,MAAM,MAAM,GAAG,sBAAsB,cAAc;AAEpE,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAM,eAAe,KAAK;AAE1B,QAAI,CAAC,gBAAgB,iBAAiB,aAAa;AACjD;AAAA,IACF;AAAA,EAWF;AAAA,EAEA,MAAM,cAAc,SAAiB;AACnC,SAAK,IAAI,OAAO,MAAM,IAAI,OAAO,CAAC;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
|
package/dist/commands/dev.js
CHANGED
|
@@ -366,7 +366,7 @@ import { Command } from "@oclif/core";
|
|
|
366
366
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
367
367
|
|
|
368
368
|
// src/utils/version.ts
|
|
369
|
-
var LIB_VERSION = "0.0.
|
|
369
|
+
var LIB_VERSION = "0.0.36";
|
|
370
370
|
|
|
371
371
|
// src/commands/base-command.ts
|
|
372
372
|
import chalk2 from "chalk";
|
|
@@ -555,38 +555,83 @@ var Dev = class _Dev extends BaseCommand {
|
|
|
555
555
|
spinner,
|
|
556
556
|
tunnelId
|
|
557
557
|
}) {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
558
|
+
const TUNNEL_TIMEOUT = 15e3;
|
|
559
|
+
const CONNECTION_TEST_TIMEOUT = 5e3;
|
|
560
|
+
spinner.text = `Testing connection to localhost:${port}...`;
|
|
561
|
+
try {
|
|
562
|
+
const testResponse = await Promise.race([
|
|
563
|
+
fetch(`http://localhost:${port}`, { method: "HEAD" }),
|
|
564
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("Connection timeout")), CONNECTION_TEST_TIMEOUT))
|
|
565
|
+
]);
|
|
566
|
+
} catch (error) {
|
|
567
|
+
spinner.fail();
|
|
568
|
+
return this.gracefulError(
|
|
569
|
+
`Cannot connect to localhost:${port}. Please ensure your application is running on port ${port} and try again.`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
spinner.text = "Creating tunnel...";
|
|
573
|
+
try {
|
|
574
|
+
const tunnel = await Promise.race([
|
|
575
|
+
this.tunnelService.create({
|
|
576
|
+
port,
|
|
577
|
+
subdomain: tunnelId
|
|
578
|
+
}),
|
|
579
|
+
new Promise(
|
|
580
|
+
(_, reject) => setTimeout(() => reject(new Error("Tunnel creation timeout")), TUNNEL_TIMEOUT)
|
|
581
|
+
)
|
|
582
|
+
]);
|
|
583
|
+
tunnel.on("request", (info) => {
|
|
584
|
+
this.log(`${chalk3.green("\u279C")} ${chalk3.white((/* @__PURE__ */ new Date()).toISOString())} - ${info.method} ${info.path}`);
|
|
585
|
+
});
|
|
586
|
+
tunnel.on("error", (err) => {
|
|
587
|
+
this.gracefulError(chalk3.red(`Tunnel error: ${err.message}`));
|
|
588
|
+
});
|
|
589
|
+
tunnel.on("close", async () => {
|
|
590
|
+
this.log(chalk3.yellow("\nTunnel closed"));
|
|
591
|
+
await onTunnelClose({ id: tunnelId });
|
|
592
|
+
process.exit(0);
|
|
593
|
+
});
|
|
594
|
+
await Promise.all([
|
|
595
|
+
new Promise(() => {
|
|
596
|
+
process.on("SIGINT", async () => {
|
|
597
|
+
this.log("\nShutting down tunnel...");
|
|
598
|
+
await onTunnelClose({ id: tunnelId });
|
|
599
|
+
tunnel.close();
|
|
600
|
+
process.exit(0);
|
|
601
|
+
});
|
|
602
|
+
process.on("SIGTERM", async () => {
|
|
603
|
+
this.log("\nShutting down tunnel...");
|
|
604
|
+
await onTunnelClose({ id: tunnelId });
|
|
605
|
+
tunnel.close();
|
|
606
|
+
process.exit(0);
|
|
607
|
+
});
|
|
608
|
+
}),
|
|
609
|
+
onSuccess({ url: tunnel.url, id: tunnelId })
|
|
610
|
+
]);
|
|
611
|
+
} catch (error) {
|
|
612
|
+
spinner.fail();
|
|
613
|
+
if (error.message === "Tunnel creation timeout") {
|
|
614
|
+
return this.gracefulError(
|
|
615
|
+
`Unable to establish tunnel connection after ${TUNNEL_TIMEOUT / 1e3} seconds.
|
|
616
|
+
|
|
617
|
+
This usually means:
|
|
618
|
+
\u2022 Network connectivity issues
|
|
619
|
+
\u2022 Tunnel service is temporarily unavailable
|
|
620
|
+
\u2022 Firewall blocking outbound connections
|
|
621
|
+
|
|
622
|
+
Please try:
|
|
623
|
+
1. Check your internet connection
|
|
624
|
+
2. Try again in a few moments
|
|
625
|
+
`
|
|
626
|
+
);
|
|
627
|
+
} else if (error.message === "Connection timeout") {
|
|
628
|
+
return this.gracefulError(
|
|
629
|
+
`Cannot connect to localhost:${port}. Please ensure your application is running on port ${port} and try again.`
|
|
630
|
+
);
|
|
631
|
+
} else {
|
|
632
|
+
return this.gracefulError(`Failed to create tunnel: ${error.message}`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
590
635
|
}
|
|
591
636
|
};
|
|
592
637
|
export {
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/dev.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/utils/detect-endpoint-type.utils.ts","../../src/services/tunnel.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import {Config, Flags} from '@oclif/core'\nimport inquirer from 'inquirer'\nimport {createId} from '@paralleldrive/cuid2'\nimport ora, {Ora} from 'ora'\nimport chalk from 'chalk'\n\nimport {AuthService} from '../services/auth.service.js'\nimport {createTRPCClient} from '../utils/trpc.js'\nimport {\n detectRemoteEndpointType,\n getHumanReadableEndpointType,\n RemoteEndpointType,\n} from '../utils/detect-endpoint-type.utils.js'\nimport {TunnelService} from '../services/tunnel.service.js'\nimport {AnalyticsService} from '../services/analytics.service.js'\nimport {BaseCommand} from './base-command.js'\n\nexport default class Dev extends BaseCommand {\n static override flags = {\n port: Flags.string({description: 'port', required: true}),\n project: Flags.string({description: 'project ID (can be found in the Copilot Cloud dashboard)'}),\n }\n\n static override description = 'Start local development for a CopilotKit project'\n static override examples = ['<%= config.bin %> <%= command.id %> --port 8000 --project proj_mv3laowus0lz11kklo57bdr6']\n\n private trpcClient: ReturnType<typeof createTRPCClient> | null = null\n private copilotCloudTunnelId: string | null = null\n\n constructor(\n argv: string[],\n config: Config,\n private authService = new AuthService(),\n private tunnelService = new TunnelService(),\n ) {\n super(argv, config)\n }\n\n private async pingTunnelRecursively(): Promise<void> {\n if (!this.copilotCloudTunnelId) {\n return\n }\n\n try {\n await this.trpcClient!.pingLocalTunnel.query({\n localTunnelId: this.copilotCloudTunnelId!,\n })\n } catch (error: any) {\n if (error?.data?.code === 'NOT_FOUND') {\n this.gracefulError(error.message)\n } else {\n this.gracefulError('Failed to ping tunnel. The connection may have been lost.')\n }\n }\n\n await new Promise((resolve) => setTimeout(resolve, 5000))\n await this.pingTunnelRecursively()\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Dev)\n\n // Check authentication\n const {cliToken, organization, user} = await this.authService.requireLogin(this)\n const analytics = new AnalyticsService({userId: user.id, organizationId: organization.id, email: user.email})\n\n this.trpcClient = createTRPCClient(cliToken)\n\n const availableProjects = await this.trpcClient.listOrgProjects.query({orgId: organization.id})\n let selectedProjectId: string | null = null\n\n // Get project ID\n if (flags.project) {\n if (!availableProjects.some((project: any) => project.id === flags.project)) {\n this.log(chalk.red(`Project with ID ${flags.project} not found`))\n process.exit(1)\n }\n\n selectedProjectId = flags.project\n this.log(chalk.green(`✅ Selected project ${selectedProjectId}`))\n } else {\n const {projectId} = await inquirer.prompt([\n {\n name: 'projectId',\n type: 'list',\n message: 'Select a project',\n choices: availableProjects.map((project: any) => ({\n value: project.id,\n name: `${project.name} (ID: ${project.id})${availableProjects.length === 1 ? ' (press Enter to confirm)' : ''}`,\n })),\n },\n ])\n\n selectedProjectId = projectId\n }\n\n // Remote endpoint type detection\n const {type: remoteEndpointType} = await detectRemoteEndpointType(`http://localhost:${flags.port}`)\n\n if (remoteEndpointType === RemoteEndpointType.Invalid) {\n return this.gracefulError(\n `Invalid remote endpoint. Please ensure you are running a compatible endpoint at port ${flags.port} and try again.`,\n )\n }\n\n const humanReadableRemoteEndpointType = getHumanReadableEndpointType(remoteEndpointType)\n\n await analytics.track({\n event: 'cli.dev.initiatied',\n properties: {\n port: flags.port,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType,\n },\n })\n\n this.log(chalk.green(`✅ ${humanReadableRemoteEndpointType} endpoint detected`))\n const spinner = ora('Creating tunnel...\\n').start()\n\n const tunnelId = createId()\n\n // Starting tunnel\n const setupTunnel = this.setupTunnel({\n tunnelId,\n port: parseInt(flags.port),\n subdomain: createId(),\n onSuccess: async ({url, id}) => {\n // Print tunnel info\n this.log('\\nTunnel Information:\\n')\n this.log(`${chalk.bold.cyan('• Tunnel URL:\\t\\t')} ${chalk.white(url)}`)\n this.log(`${chalk.bold.cyan('• Endpoint Type:\\t')} ${chalk.white(humanReadableRemoteEndpointType)}`)\n this.log(\n `${chalk.bold.cyan('• Project:\\t\\t')} ${chalk.white(`${process.env.COPILOT_CLOUD_BASE_URL}/projects/${selectedProjectId!}`)}`,\n )\n this.log(chalk.yellow('\\nPress Ctrl+C to stop the tunnel'))\n this.log('\\n')\n\n spinner.text = 'Linking local tunnel to Copilot Cloud...'\n\n // Report to Cloud\n const {localTunnelId} = await this.trpcClient!.reportRemoteEndpointLocalTunnel.mutate({\n tunnelId: id,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType === RemoteEndpointType.CopilotKit ? 'CopilotKit' : 'LangGraphCloud',\n tunnelUrl: url,\n port: parseInt(flags.port),\n })\n\n this.copilotCloudTunnelId = localTunnelId\n\n await analytics.track({\n event: 'cli.dev.tunnel.created',\n properties: {\n tunnelId: localTunnelId,\n port: flags.port,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType,\n },\n })\n\n spinner.color = 'green'\n spinner.text = '🚀 Local tunnel is live and linked to Copilot Cloud!\\n'\n spinner.succeed()\n\n await this.pingTunnelRecursively()\n },\n onTunnelClose: async ({id}) => {\n if (this.copilotCloudTunnelId) {\n await analytics.track({\n event: 'cli.dev.tunnel.closed',\n properties: {\n tunnelId: id,\n },\n })\n\n await this.trpcClient!.deleteLocalTunnel.mutate({\n localTunnelId: this.copilotCloudTunnelId!,\n })\n this.copilotCloudTunnelId = null\n }\n },\n spinner,\n })\n\n await Promise.all([setupTunnel])\n }\n\n private async setupTunnel({\n port,\n subdomain,\n onSuccess,\n onTunnelClose,\n spinner,\n tunnelId,\n }: {\n port: number\n subdomain?: string\n onSuccess: (params: {url: string; id: string}) => Promise<void>\n onTunnelClose: (params: {id: string}) => Promise<void>\n spinner: Ora\n tunnelId: string\n }) {\n // Create the tunnel using the service\n const tunnel = await this.tunnelService.create({\n port,\n subdomain: tunnelId,\n })\n // Handle tunnel events\n tunnel.on('request', (info) => {\n this.log(`${chalk.green('➜')} ${chalk.white(new Date().toISOString())} - ${info.method} ${info.path}`)\n })\n\n tunnel.on('error', (err) => {\n this.gracefulError(chalk.red(`Tunnel error: ${err.message}`))\n })\n\n tunnel.on('close', async () => {\n this.log(chalk.yellow('\\nTunnel closed'))\n // eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit\n await onTunnelClose({id: tunnelId})\n process.exit(0)\n })\n\n // Keep the process alive until Ctrl+C\n await Promise.all([\n new Promise<void>(() => {\n process.on('SIGINT', async () => {\n this.log('\\nShutting down tunnel...')\n await onTunnelClose({id: tunnelId})\n tunnel.close()\n process.exit(0)\n })\n\n process.on('SIGTERM', async () => {\n this.log('\\nShutting down tunnel...')\n await onTunnelClose({id: tunnelId})\n tunnel.close()\n process.exit(0)\n })\n }),\n onSuccess({url: tunnel.url, id: tunnelId}),\n ])\n }\n}\n","// @ts-ignore\nimport Conf from 'conf'\nimport cors from 'cors'\nimport express from 'express'\nimport crypto from 'node:crypto'\nimport open from 'open'\nimport getPort from 'get-port'\nimport ora from 'ora'\nimport chalk from 'chalk'\nimport inquirer from 'inquirer'\nimport {Command} from '@oclif/core'\nimport {createTRPCClient} from '../utils/trpc.js'\nimport {AnalyticsService} from '../services/analytics.service.js'\nimport {BaseCommand} from '../commands/base-command.js'\n\ninterface LoginResponse {\n cliToken: string\n user: {\n email: string\n id: string\n }\n organization: {\n id: string\n }\n}\n\nexport class AuthService {\n private readonly config = new Conf({projectName: 'CopilotKitCLI'})\n private readonly COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\n getToken(): string | undefined {\n return this.config.get('cliToken') as string | undefined\n }\n\n getCLIToken(): string | undefined {\n const cliToken = this.config.get('cliToken') as string | undefined\n return cliToken\n }\n\n async logout(cmd: BaseCommand): Promise<void> {\n this.config.delete('cliToken')\n }\n\n async requireLogin(cmd: Command): Promise<LoginResponse> {\n let cliToken = this.getCLIToken()\n // Check authentication\n if (!cliToken) {\n try {\n const {shouldLogin} = await inquirer.prompt([\n {\n name: 'shouldLogin',\n type: 'confirm',\n message: '🪁 You are not yet authenticated. Authenticate with Copilot Cloud? (press Enter to confirm)',\n default: true,\n },\n ])\n if (shouldLogin) {\n const loginResult = await this.login({exitAfterLogin: false})\n cliToken = loginResult.cliToken\n return loginResult\n } else {\n cmd.error('Authentication required to proceed.')\n }\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n cmd.error(chalk.yellow('\\nAuthentication cancelled'))\n }\n\n throw error\n }\n }\n\n let me\n\n const trpcClient = createTRPCClient(cliToken)\n try {\n me = await trpcClient.me.query()\n } catch (error) {\n cmd.log(chalk.red('Could not authenticate with Copilot Cloud. Please run: npx copilotkit@latest login'))\n process.exit(1)\n }\n\n if (!me.organization || !me.user) {\n cmd.error('Authentication required to proceed.')\n }\n\n return {cliToken, user: me.user, organization: me.organization}\n }\n\n async login({exitAfterLogin}: {exitAfterLogin?: boolean} = {exitAfterLogin: true}): Promise<LoginResponse> {\n const spinner = ora('🪁 Opening browser for authentication...').start()\n let analytics: AnalyticsService\n analytics = new AnalyticsService()\n\n const app = express()\n app.use(cors())\n app.use(express.urlencoded({extended: true}))\n app.use(express.json())\n\n const port = await getPort()\n const state = crypto.randomBytes(16).toString('hex')\n\n return new Promise(async (resolve) => {\n const server = app.listen(port, () => {})\n\n await analytics.track({\n event: 'cli.login.initiated',\n properties: {},\n })\n\n spinner.text = '🪁 Waiting for browser authentication to complete...'\n\n app.post('/callback', async (req, res) => {\n const {cliToken, user, organization} = req.body\n\n analytics = new AnalyticsService({userId: user.id, organizationId: organization.id, email: user.email})\n await analytics.track({\n event: 'cli.login.success',\n properties: {\n organizationId: organization.id,\n userId: user.id,\n email: user.email,\n },\n })\n\n if (state !== req.query.state) {\n res.status(401).json({message: 'Invalid state'})\n spinner.fail('Invalid state')\n return\n }\n\n this.config.set('cliToken', cliToken)\n res.status(200).json({message: 'Callback called'})\n spinner.succeed(`🪁 Successfully logged in as ${chalk.hex('#7553fc')(user.email)}`)\n if (exitAfterLogin) {\n process.exit(0)\n } else {\n server.close()\n resolve({cliToken, user, organization})\n }\n })\n\n open(`${this.COPILOT_CLOUD_BASE_URL}/cli-auth?callbackUrl=http://localhost:${port}/callback&state=${state}`)\n })\n }\n}\n","import {createTRPCClient as trpcClient, httpBatchLink} from '@trpc/client'\nimport superjson from 'superjson'\n\nexport const COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\nexport function createTRPCClient(cliToken: string): any {\n return trpcClient({\n links: [\n httpBatchLink({\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n transformer: superjson,\n headers: () => {\n return {\n 'x-trpc-source': 'cli',\n 'x-cli-token': cliToken,\n }\n },\n }),\n ],\n })\n}\n","import {Analytics} from '@segment/analytics-node'\nimport {AnalyticsEvents} from './events.js'\nimport Conf from 'conf'\n\nexport class AnalyticsService {\n private segment: Analytics | undefined\n private globalProperties: Record<string, any> = {}\n private userId: string | undefined\n private email: string | undefined\n private organizationId: string | undefined\n private config = new Conf({projectName: 'CopilotKitCLI'})\n\n constructor(\n private readonly authData?: {\n userId: string\n email: string\n organizationId: string\n },\n ) {\n if (process.env.SEGMENT_DISABLED === 'true') {\n return\n }\n\n const segmentWriteKey = process.env.SEGMENT_WRITE_KEY || '9Pv6QyExYef2P4hPz4gks6QAvNMi2AOf'\n\n this.globalProperties = {\n service: 'cli',\n }\n\n if (this.authData?.userId) {\n this.userId = this.authData.userId\n }\n\n if (this.authData?.email) {\n this.email = this.authData.email\n this.globalProperties.email = this.authData.email\n }\n\n if (this.authData?.organizationId) {\n this.organizationId = this.authData.organizationId\n }\n\n this.segment = new Analytics({\n writeKey: segmentWriteKey,\n disable: process.env.SEGMENT_DISABLE === 'true',\n })\n\n const config = new Conf({projectName: 'CopilotKitCLI'})\n if (!config.get('anonymousId')) {\n config.set('anonymousId', crypto.randomUUID())\n }\n }\n\n private getAnonymousId(): string {\n const anonymousId = this.config.get('anonymousId')\n if (!anonymousId) {\n const anonymousId = crypto.randomUUID()\n this.config.set('anonymousId', anonymousId)\n return anonymousId\n }\n\n return anonymousId as string\n }\n\n public track<K extends keyof AnalyticsEvents>(\n event: Omit<Parameters<Analytics['track']>[0], 'userId'> & {\n event: K\n properties: AnalyticsEvents[K]\n },\n ): Promise<void> {\n if (!this.segment) {\n return Promise.resolve()\n }\n\n const payload = {\n userId: this.userId ? this.userId : undefined,\n email: this.email ? this.email : undefined,\n anonymousId: this.getAnonymousId(),\n event: event.event,\n properties: {\n ...this.globalProperties,\n ...event.properties,\n $groups: this.organizationId\n ? {\n segment_group: this.organizationId,\n }\n : undefined,\n eventProperties: {\n ...event.properties,\n ...this.globalProperties,\n },\n },\n }\n\n return new Promise((resolve, reject) => {\n this.segment!.track(payload, (err) => {\n if (err) {\n // Resolve anyway\n resolve()\n }\n\n resolve()\n })\n })\n }\n}\n","export enum RemoteEndpointType {\n LangGraphPlatform = 'LangGraphPlatform',\n CopilotKit = 'CopilotKit',\n CrewAI = 'CrewAI',\n MCP = 'MCP',\n Invalid = 'Invalid',\n}\n\nconst removeTrailingSlash = (url: string) => url.replace(/\\/$/, '')\n\nexport const getHumanReadableEndpointType = (type: RemoteEndpointType) => {\n switch (type) {\n case RemoteEndpointType.LangGraphPlatform:\n return 'LangGraph Platform'\n case RemoteEndpointType.CopilotKit:\n return 'CopilotKit'\n case RemoteEndpointType.CrewAI:\n return 'CrewAI'\n case RemoteEndpointType.MCP:\n return 'MCP'\n default:\n return 'Invalid'\n }\n}\n\nexport async function detectRemoteEndpointType(url: string): Promise<{\n url: string\n type: RemoteEndpointType\n humanReadableType: string\n}> {\n // First check base URL\n const [isLangGraph, isCopilot, isCrewAI, isMCP] = await Promise.all([\n isLangGraphPlatformEndpoint(url),\n isCopilotKitEndpoint(url),\n isCrewAIEndpoint(url),\n isMCPEndpoint(url),\n ])\n\n // Check base endpoints first\n if (isLangGraph) {\n return {\n url,\n type: RemoteEndpointType.LangGraphPlatform,\n humanReadableType: 'LangGraph Platform',\n }\n }\n\n if (isCopilot) {\n return {\n url,\n type: RemoteEndpointType.CopilotKit,\n humanReadableType: 'CopilotKit',\n }\n }\n\n if (isCrewAI) {\n return {\n url,\n type: RemoteEndpointType.CrewAI,\n humanReadableType: 'CrewAI',\n }\n }\n\n // If no match and URL doesn't already end with /copilotkit, try that path\n if (!url.endsWith('/copilotkit')) {\n const copilotKitUrl = `${removeTrailingSlash(url)}/copilotkit`\n const isCopilotWithPath = await isCopilotKitEndpoint(copilotKitUrl)\n\n if (isCopilotWithPath) {\n return {\n url: copilotKitUrl,\n type: RemoteEndpointType.CopilotKit,\n humanReadableType: 'CopilotKit',\n }\n }\n }\n\n return {\n url,\n type: RemoteEndpointType.Invalid,\n humanReadableType: 'Invalid',\n }\n}\n\nasync function isLangGraphPlatformEndpoint(url: string, retries: number = 0): Promise<boolean> {\n let response\n\n try {\n response = await fetch(`${url}/assistants/search`, {\n method: 'POST',\n\n body: JSON.stringify({\n metadata: {},\n limit: 99,\n offset: 0,\n }),\n })\n } catch (error) {\n return false\n }\n\n if (!response.ok) {\n if (response.status === 502) {\n if (retries < 3) {\n console.log('RETRYING LGC', retries + 1)\n return isLangGraphPlatformEndpoint(url, retries + 1)\n }\n }\n\n if (response.status === 403) {\n return true\n }\n\n return false\n }\n\n const data = await response.json()\n\n if (data[0].assistant_id) {\n return true\n }\n\n return false\n}\n\nasync function isCopilotKitEndpoint(url: string, retries: number = 0): Promise<boolean> {\n let response\n\n try {\n response = await fetch(`${url}/info`, {\n method: 'POST',\n body: JSON.stringify({}),\n })\n } catch (error) {\n return false\n }\n\n if (!response.ok) {\n if (response.status === 502) {\n if (retries < 3) {\n console.log('RETRYING CK', retries + 1)\n return isCopilotKitEndpoint(url, retries + 1)\n }\n }\n\n return false\n }\n\n const data = await response.json()\n\n if (data.agents && data.actions) {\n return true\n }\n\n return false\n}\n\nasync function isCrewAIEndpoint(url: string): Promise<boolean> {\n return url.toLowerCase().includes('crew')\n}\n\nasync function isMCPEndpoint(url: string): Promise<boolean> {\n return true\n}\n","import type {Tunnel} from 'localtunnel'\n\nimport axios from 'axios'\nimport localtunnel from 'localtunnel'\n\nexport interface TunnelOptions {\n port: number\n subdomain?: string\n}\n\nexport class TunnelService {\n private readonly META_DATA_URL = 'https://metadata-cdn.copilotkit.ai/cloud.config.json'\n\n async create(options: TunnelOptions): Promise<Tunnel> {\n const metadata = await this.getMetaData()\n\n return localtunnel({\n ...options,\n host: metadata.tunnelHost,\n })\n }\n\n async getMetaData() {\n const response = await axios.get<{\n tunnelHost: string\n }>(this.META_DATA_URL)\n return response.data\n }\n}\n","import {Command} from '@oclif/core'\nimport Sentry, {consoleIntegration} from '@sentry/node'\nimport {LIB_VERSION} from '../utils/version.js'\nimport {COPILOT_CLOUD_BASE_URL} from '../utils/trpc.js'\nimport chalk from 'chalk'\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion()\n\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n 'https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120',\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n })\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED === 'true') {\n super.catch(err)\n return\n }\n\n Sentry.captureException(err)\n super.catch(err)\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.close()\n }\n\n async run() {}\n\n async checkCLIVersion() {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`)\n\n const data = await response.json()\n const cloudVersion = data.cliVersion\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n }\n\n async gracefulError(message: string) {\n this.log('\\n' + chalk.red(message))\n process.exit(1)\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.35\";\n"],"mappings":";AAAA,SAAgB,aAAY;AAC5B,OAAOA,eAAc;AACrB,SAAQ,gBAAe;AACvB,OAAOC,UAAgB;AACvB,OAAOC,YAAW;;;ACHlB,OAAOC,WAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAOC,aAAY;AACnB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAO,SAAS;AAChB,OAAO,WAAW;AAClB,OAAO,cAAc;;;ACTrB,SAAQ,oBAAoB,YAAY,qBAAoB;AAC5D,OAAO,eAAe;AAEf,IAAM,yBAAyB,QAAQ,IAAI,0BAA0B;AAErE,SAAS,iBAAiB,UAAuB;AACtD,SAAO,WAAW;AAAA,IAChB,OAAO;AAAA,MACL,cAAc;AAAA,QACZ,KAAK,GAAG,sBAAsB;AAAA,QAC9B,aAAa;AAAA,QACb,SAAS,MAAM;AACb,iBAAO;AAAA,YACL,iBAAiB;AAAA,YACjB,eAAe;AAAA,UACjB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;;;ACpBA,SAAQ,iBAAgB;AAExB,OAAO,UAAU;AAEV,IAAM,mBAAN,MAAuB;AAAA,EAQ5B,YAC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../../src/commands/dev.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/utils/detect-endpoint-type.utils.ts","../../src/services/tunnel.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import {Config, Flags} from '@oclif/core'\nimport inquirer from 'inquirer'\nimport {createId} from '@paralleldrive/cuid2'\nimport ora, {Ora} from 'ora'\nimport chalk from 'chalk'\n\nimport {AuthService} from '../services/auth.service.js'\nimport {createTRPCClient} from '../utils/trpc.js'\nimport {\n detectRemoteEndpointType,\n getHumanReadableEndpointType,\n RemoteEndpointType,\n} from '../utils/detect-endpoint-type.utils.js'\nimport {TunnelService} from '../services/tunnel.service.js'\nimport {AnalyticsService} from '../services/analytics.service.js'\nimport {BaseCommand} from './base-command.js'\n\nexport default class Dev extends BaseCommand {\n static override flags = {\n port: Flags.string({description: 'port', required: true}),\n project: Flags.string({description: 'project ID (can be found in the Copilot Cloud dashboard)'}),\n }\n\n static override description = 'Start local development for a CopilotKit project'\n static override examples = ['<%= config.bin %> <%= command.id %> --port 8000 --project proj_mv3laowus0lz11kklo57bdr6']\n\n private trpcClient: ReturnType<typeof createTRPCClient> | null = null\n private copilotCloudTunnelId: string | null = null\n\n constructor(\n argv: string[],\n config: Config,\n private authService = new AuthService(),\n private tunnelService = new TunnelService(),\n ) {\n super(argv, config)\n }\n\n private async pingTunnelRecursively(): Promise<void> {\n if (!this.copilotCloudTunnelId) {\n return\n }\n\n try {\n await this.trpcClient!.pingLocalTunnel.query({\n localTunnelId: this.copilotCloudTunnelId!,\n })\n } catch (error: any) {\n if (error?.data?.code === 'NOT_FOUND') {\n this.gracefulError(error.message)\n } else {\n this.gracefulError('Failed to ping tunnel. The connection may have been lost.')\n }\n }\n\n await new Promise((resolve) => setTimeout(resolve, 5000))\n await this.pingTunnelRecursively()\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Dev)\n\n // Check authentication\n const {cliToken, organization, user} = await this.authService.requireLogin(this)\n const analytics = new AnalyticsService({userId: user.id, organizationId: organization.id, email: user.email})\n\n this.trpcClient = createTRPCClient(cliToken)\n\n const availableProjects = await this.trpcClient.listOrgProjects.query({orgId: organization.id})\n let selectedProjectId: string | null = null\n\n // Get project ID\n if (flags.project) {\n if (!availableProjects.some((project: any) => project.id === flags.project)) {\n this.log(chalk.red(`Project with ID ${flags.project} not found`))\n process.exit(1)\n }\n\n selectedProjectId = flags.project\n this.log(chalk.green(`✅ Selected project ${selectedProjectId}`))\n } else {\n const {projectId} = await inquirer.prompt([\n {\n name: 'projectId',\n type: 'list',\n message: 'Select a project',\n choices: availableProjects.map((project: any) => ({\n value: project.id,\n name: `${project.name} (ID: ${project.id})${availableProjects.length === 1 ? ' (press Enter to confirm)' : ''}`,\n })),\n },\n ])\n\n selectedProjectId = projectId\n }\n\n // Remote endpoint type detection\n const {type: remoteEndpointType} = await detectRemoteEndpointType(`http://localhost:${flags.port}`)\n\n if (remoteEndpointType === RemoteEndpointType.Invalid) {\n return this.gracefulError(\n `Invalid remote endpoint. Please ensure you are running a compatible endpoint at port ${flags.port} and try again.`,\n )\n }\n\n const humanReadableRemoteEndpointType = getHumanReadableEndpointType(remoteEndpointType)\n\n await analytics.track({\n event: 'cli.dev.initiatied',\n properties: {\n port: flags.port,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType,\n },\n })\n\n this.log(chalk.green(`✅ ${humanReadableRemoteEndpointType} endpoint detected`))\n const spinner = ora('Creating tunnel...\\n').start()\n\n const tunnelId = createId()\n\n // Starting tunnel\n const setupTunnel = this.setupTunnel({\n tunnelId,\n port: parseInt(flags.port),\n subdomain: createId(),\n onSuccess: async ({url, id}) => {\n // Print tunnel info\n this.log('\\nTunnel Information:\\n')\n this.log(`${chalk.bold.cyan('• Tunnel URL:\\t\\t')} ${chalk.white(url)}`)\n this.log(`${chalk.bold.cyan('• Endpoint Type:\\t')} ${chalk.white(humanReadableRemoteEndpointType)}`)\n this.log(\n `${chalk.bold.cyan('• Project:\\t\\t')} ${chalk.white(`${process.env.COPILOT_CLOUD_BASE_URL}/projects/${selectedProjectId!}`)}`,\n )\n this.log(chalk.yellow('\\nPress Ctrl+C to stop the tunnel'))\n this.log('\\n')\n\n spinner.text = 'Linking local tunnel to Copilot Cloud...'\n\n // Report to Cloud\n const {localTunnelId} = await this.trpcClient!.reportRemoteEndpointLocalTunnel.mutate({\n tunnelId: id,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType === RemoteEndpointType.CopilotKit ? 'CopilotKit' : 'LangGraphCloud',\n tunnelUrl: url,\n port: parseInt(flags.port),\n })\n\n this.copilotCloudTunnelId = localTunnelId\n\n await analytics.track({\n event: 'cli.dev.tunnel.created',\n properties: {\n tunnelId: localTunnelId,\n port: flags.port,\n projectId: selectedProjectId!,\n endpointType: remoteEndpointType,\n },\n })\n\n spinner.color = 'green'\n spinner.text = '🚀 Local tunnel is live and linked to Copilot Cloud!\\n'\n spinner.succeed()\n\n await this.pingTunnelRecursively()\n },\n onTunnelClose: async ({id}) => {\n if (this.copilotCloudTunnelId) {\n await analytics.track({\n event: 'cli.dev.tunnel.closed',\n properties: {\n tunnelId: id,\n },\n })\n\n await this.trpcClient!.deleteLocalTunnel.mutate({\n localTunnelId: this.copilotCloudTunnelId!,\n })\n this.copilotCloudTunnelId = null\n }\n },\n spinner,\n })\n\n await Promise.all([setupTunnel])\n }\n\n private async setupTunnel({\n port,\n subdomain,\n onSuccess,\n onTunnelClose,\n spinner,\n tunnelId,\n }: {\n port: number\n subdomain?: string\n onSuccess: (params: {url: string; id: string}) => Promise<void>\n onTunnelClose: (params: {id: string}) => Promise<void>\n spinner: Ora\n tunnelId: string\n }) {\n const TUNNEL_TIMEOUT = 15000 // 15 seconds\n const CONNECTION_TEST_TIMEOUT = 5000 // 5 seconds\n\n // First, test if the local port is accessible\n spinner.text = `Testing connection to localhost:${port}...`\n try {\n const testResponse = await Promise.race([\n fetch(`http://localhost:${port}`, {method: 'HEAD'}),\n new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout')), CONNECTION_TEST_TIMEOUT)),\n ])\n } catch (error) {\n spinner.fail()\n return this.gracefulError(\n `Cannot connect to localhost:${port}. Please ensure your application is running on port ${port} and try again.`,\n )\n }\n\n spinner.text = 'Creating tunnel...'\n\n try {\n // Create the tunnel with timeout\n const tunnel = await Promise.race([\n this.tunnelService.create({\n port,\n subdomain: tunnelId,\n }),\n new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error('Tunnel creation timeout')), TUNNEL_TIMEOUT),\n ),\n ])\n\n // Handle tunnel events\n tunnel.on('request', (info: any) => {\n this.log(`${chalk.green('➜')} ${chalk.white(new Date().toISOString())} - ${info.method} ${info.path}`)\n })\n\n tunnel.on('error', (err: any) => {\n this.gracefulError(chalk.red(`Tunnel error: ${err.message}`))\n })\n\n tunnel.on('close', async () => {\n this.log(chalk.yellow('\\nTunnel closed'))\n await onTunnelClose({id: tunnelId})\n process.exit(0)\n })\n\n // Keep the process alive until Ctrl+C\n await Promise.all([\n new Promise<void>(() => {\n process.on('SIGINT', async () => {\n this.log('\\nShutting down tunnel...')\n await onTunnelClose({id: tunnelId})\n tunnel.close()\n process.exit(0)\n })\n\n process.on('SIGTERM', async () => {\n this.log('\\nShutting down tunnel...')\n await onTunnelClose({id: tunnelId})\n tunnel.close()\n process.exit(0)\n })\n }),\n onSuccess({url: tunnel.url, id: tunnelId}),\n ])\n } catch (error: any) {\n spinner.fail()\n if (error.message === 'Tunnel creation timeout') {\n return this.gracefulError(\n `Unable to establish tunnel connection after ${TUNNEL_TIMEOUT / 1000} seconds.\\n\\n` +\n `This usually means:\\n` +\n `• Network connectivity issues\\n` +\n `• Tunnel service is temporarily unavailable\\n` +\n `• Firewall blocking outbound connections\\n\\n` +\n `Please try:\\n` +\n `1. Check your internet connection\\n` +\n `2. Try again in a few moments\\n`,\n )\n } else if (error.message === 'Connection timeout') {\n return this.gracefulError(\n `Cannot connect to localhost:${port}. Please ensure your application is running on port ${port} and try again.`,\n )\n } else {\n return this.gracefulError(`Failed to create tunnel: ${error.message}`)\n }\n }\n }\n}\n","// @ts-ignore\nimport Conf from 'conf'\nimport cors from 'cors'\nimport express from 'express'\nimport crypto from 'node:crypto'\nimport open from 'open'\nimport getPort from 'get-port'\nimport ora from 'ora'\nimport chalk from 'chalk'\nimport inquirer from 'inquirer'\nimport {Command} from '@oclif/core'\nimport {createTRPCClient} from '../utils/trpc.js'\nimport {AnalyticsService} from '../services/analytics.service.js'\nimport {BaseCommand} from '../commands/base-command.js'\n\ninterface LoginResponse {\n cliToken: string\n user: {\n email: string\n id: string\n }\n organization: {\n id: string\n }\n}\n\nexport class AuthService {\n private readonly config = new Conf({projectName: 'CopilotKitCLI'})\n private readonly COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\n getToken(): string | undefined {\n return this.config.get('cliToken') as string | undefined\n }\n\n getCLIToken(): string | undefined {\n const cliToken = this.config.get('cliToken') as string | undefined\n return cliToken\n }\n\n async logout(cmd: BaseCommand): Promise<void> {\n this.config.delete('cliToken')\n }\n\n async requireLogin(cmd: Command): Promise<LoginResponse> {\n let cliToken = this.getCLIToken()\n // Check authentication\n if (!cliToken) {\n try {\n const {shouldLogin} = await inquirer.prompt([\n {\n name: 'shouldLogin',\n type: 'confirm',\n message: '🪁 You are not yet authenticated. Authenticate with Copilot Cloud? (press Enter to confirm)',\n default: true,\n },\n ])\n if (shouldLogin) {\n const loginResult = await this.login({exitAfterLogin: false})\n cliToken = loginResult.cliToken\n return loginResult\n } else {\n cmd.error('Authentication required to proceed.')\n }\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n cmd.error(chalk.yellow('\\nAuthentication cancelled'))\n }\n\n throw error\n }\n }\n\n let me\n\n const trpcClient = createTRPCClient(cliToken)\n try {\n me = await trpcClient.me.query()\n } catch (error) {\n cmd.log(chalk.red('Could not authenticate with Copilot Cloud. Please run: npx copilotkit@latest login'))\n process.exit(1)\n }\n\n if (!me.organization || !me.user) {\n cmd.error('Authentication required to proceed.')\n }\n\n return {cliToken, user: me.user, organization: me.organization}\n }\n\n async login({exitAfterLogin}: {exitAfterLogin?: boolean} = {exitAfterLogin: true}): Promise<LoginResponse> {\n const spinner = ora('🪁 Opening browser for authentication...').start()\n let analytics: AnalyticsService\n analytics = new AnalyticsService()\n\n const app = express()\n app.use(cors())\n app.use(express.urlencoded({extended: true}))\n app.use(express.json())\n\n const port = await getPort()\n const state = crypto.randomBytes(16).toString('hex')\n\n return new Promise(async (resolve) => {\n const server = app.listen(port, () => {})\n\n await analytics.track({\n event: 'cli.login.initiated',\n properties: {},\n })\n\n spinner.text = '🪁 Waiting for browser authentication to complete...'\n\n app.post('/callback', async (req, res) => {\n const {cliToken, user, organization} = req.body\n\n analytics = new AnalyticsService({userId: user.id, organizationId: organization.id, email: user.email})\n await analytics.track({\n event: 'cli.login.success',\n properties: {\n organizationId: organization.id,\n userId: user.id,\n email: user.email,\n },\n })\n\n if (state !== req.query.state) {\n res.status(401).json({message: 'Invalid state'})\n spinner.fail('Invalid state')\n return\n }\n\n this.config.set('cliToken', cliToken)\n res.status(200).json({message: 'Callback called'})\n spinner.succeed(`🪁 Successfully logged in as ${chalk.hex('#7553fc')(user.email)}`)\n if (exitAfterLogin) {\n process.exit(0)\n } else {\n server.close()\n resolve({cliToken, user, organization})\n }\n })\n\n open(`${this.COPILOT_CLOUD_BASE_URL}/cli-auth?callbackUrl=http://localhost:${port}/callback&state=${state}`)\n })\n }\n}\n","import {createTRPCClient as trpcClient, httpBatchLink} from '@trpc/client'\nimport superjson from 'superjson'\n\nexport const COPILOT_CLOUD_BASE_URL = process.env.COPILOT_CLOUD_BASE_URL || 'https://cloud.copilotkit.ai'\n\nexport function createTRPCClient(cliToken: string): any {\n return trpcClient({\n links: [\n httpBatchLink({\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n transformer: superjson,\n headers: () => {\n return {\n 'x-trpc-source': 'cli',\n 'x-cli-token': cliToken,\n }\n },\n }),\n ],\n })\n}\n","import {Analytics} from '@segment/analytics-node'\nimport {AnalyticsEvents} from './events.js'\nimport Conf from 'conf'\n\nexport class AnalyticsService {\n private segment: Analytics | undefined\n private globalProperties: Record<string, any> = {}\n private userId: string | undefined\n private email: string | undefined\n private organizationId: string | undefined\n private config = new Conf({projectName: 'CopilotKitCLI'})\n\n constructor(\n private readonly authData?: {\n userId: string\n email: string\n organizationId: string\n },\n ) {\n if (process.env.SEGMENT_DISABLED === 'true') {\n return\n }\n\n const segmentWriteKey = process.env.SEGMENT_WRITE_KEY || '9Pv6QyExYef2P4hPz4gks6QAvNMi2AOf'\n\n this.globalProperties = {\n service: 'cli',\n }\n\n if (this.authData?.userId) {\n this.userId = this.authData.userId\n }\n\n if (this.authData?.email) {\n this.email = this.authData.email\n this.globalProperties.email = this.authData.email\n }\n\n if (this.authData?.organizationId) {\n this.organizationId = this.authData.organizationId\n }\n\n this.segment = new Analytics({\n writeKey: segmentWriteKey,\n disable: process.env.SEGMENT_DISABLE === 'true',\n })\n\n const config = new Conf({projectName: 'CopilotKitCLI'})\n if (!config.get('anonymousId')) {\n config.set('anonymousId', crypto.randomUUID())\n }\n }\n\n private getAnonymousId(): string {\n const anonymousId = this.config.get('anonymousId')\n if (!anonymousId) {\n const anonymousId = crypto.randomUUID()\n this.config.set('anonymousId', anonymousId)\n return anonymousId\n }\n\n return anonymousId as string\n }\n\n public track<K extends keyof AnalyticsEvents>(\n event: Omit<Parameters<Analytics['track']>[0], 'userId'> & {\n event: K\n properties: AnalyticsEvents[K]\n },\n ): Promise<void> {\n if (!this.segment) {\n return Promise.resolve()\n }\n\n const payload = {\n userId: this.userId ? this.userId : undefined,\n email: this.email ? this.email : undefined,\n anonymousId: this.getAnonymousId(),\n event: event.event,\n properties: {\n ...this.globalProperties,\n ...event.properties,\n $groups: this.organizationId\n ? {\n segment_group: this.organizationId,\n }\n : undefined,\n eventProperties: {\n ...event.properties,\n ...this.globalProperties,\n },\n },\n }\n\n return new Promise((resolve, reject) => {\n this.segment!.track(payload, (err) => {\n if (err) {\n // Resolve anyway\n resolve()\n }\n\n resolve()\n })\n })\n }\n}\n","export enum RemoteEndpointType {\n LangGraphPlatform = 'LangGraphPlatform',\n CopilotKit = 'CopilotKit',\n CrewAI = 'CrewAI',\n MCP = 'MCP',\n Invalid = 'Invalid',\n}\n\nconst removeTrailingSlash = (url: string) => url.replace(/\\/$/, '')\n\nexport const getHumanReadableEndpointType = (type: RemoteEndpointType) => {\n switch (type) {\n case RemoteEndpointType.LangGraphPlatform:\n return 'LangGraph Platform'\n case RemoteEndpointType.CopilotKit:\n return 'CopilotKit'\n case RemoteEndpointType.CrewAI:\n return 'CrewAI'\n case RemoteEndpointType.MCP:\n return 'MCP'\n default:\n return 'Invalid'\n }\n}\n\nexport async function detectRemoteEndpointType(url: string): Promise<{\n url: string\n type: RemoteEndpointType\n humanReadableType: string\n}> {\n // First check base URL\n const [isLangGraph, isCopilot, isCrewAI, isMCP] = await Promise.all([\n isLangGraphPlatformEndpoint(url),\n isCopilotKitEndpoint(url),\n isCrewAIEndpoint(url),\n isMCPEndpoint(url),\n ])\n\n // Check base endpoints first\n if (isLangGraph) {\n return {\n url,\n type: RemoteEndpointType.LangGraphPlatform,\n humanReadableType: 'LangGraph Platform',\n }\n }\n\n if (isCopilot) {\n return {\n url,\n type: RemoteEndpointType.CopilotKit,\n humanReadableType: 'CopilotKit',\n }\n }\n\n if (isCrewAI) {\n return {\n url,\n type: RemoteEndpointType.CrewAI,\n humanReadableType: 'CrewAI',\n }\n }\n\n // If no match and URL doesn't already end with /copilotkit, try that path\n if (!url.endsWith('/copilotkit')) {\n const copilotKitUrl = `${removeTrailingSlash(url)}/copilotkit`\n const isCopilotWithPath = await isCopilotKitEndpoint(copilotKitUrl)\n\n if (isCopilotWithPath) {\n return {\n url: copilotKitUrl,\n type: RemoteEndpointType.CopilotKit,\n humanReadableType: 'CopilotKit',\n }\n }\n }\n\n return {\n url,\n type: RemoteEndpointType.Invalid,\n humanReadableType: 'Invalid',\n }\n}\n\nasync function isLangGraphPlatformEndpoint(url: string, retries: number = 0): Promise<boolean> {\n let response\n\n try {\n response = await fetch(`${url}/assistants/search`, {\n method: 'POST',\n\n body: JSON.stringify({\n metadata: {},\n limit: 99,\n offset: 0,\n }),\n })\n } catch (error) {\n return false\n }\n\n if (!response.ok) {\n if (response.status === 502) {\n if (retries < 3) {\n console.log('RETRYING LGC', retries + 1)\n return isLangGraphPlatformEndpoint(url, retries + 1)\n }\n }\n\n if (response.status === 403) {\n return true\n }\n\n return false\n }\n\n const data = await response.json()\n\n if (data[0].assistant_id) {\n return true\n }\n\n return false\n}\n\nasync function isCopilotKitEndpoint(url: string, retries: number = 0): Promise<boolean> {\n let response\n\n try {\n response = await fetch(`${url}/info`, {\n method: 'POST',\n body: JSON.stringify({}),\n })\n } catch (error) {\n return false\n }\n\n if (!response.ok) {\n if (response.status === 502) {\n if (retries < 3) {\n console.log('RETRYING CK', retries + 1)\n return isCopilotKitEndpoint(url, retries + 1)\n }\n }\n\n return false\n }\n\n const data = await response.json()\n\n if (data.agents && data.actions) {\n return true\n }\n\n return false\n}\n\nasync function isCrewAIEndpoint(url: string): Promise<boolean> {\n return url.toLowerCase().includes('crew')\n}\n\nasync function isMCPEndpoint(url: string): Promise<boolean> {\n return true\n}\n","import type {Tunnel} from 'localtunnel'\n\nimport axios from 'axios'\nimport localtunnel from 'localtunnel'\n\nexport interface TunnelOptions {\n port: number\n subdomain?: string\n}\n\nexport class TunnelService {\n private readonly META_DATA_URL = 'https://metadata-cdn.copilotkit.ai/cloud.config.json'\n\n async create(options: TunnelOptions): Promise<Tunnel> {\n const metadata = await this.getMetaData()\n\n return localtunnel({\n ...options,\n host: metadata.tunnelHost,\n })\n }\n\n async getMetaData() {\n const response = await axios.get<{\n tunnelHost: string\n }>(this.META_DATA_URL)\n return response.data\n }\n}\n","import {Command} from '@oclif/core'\nimport Sentry, {consoleIntegration} from '@sentry/node'\nimport {LIB_VERSION} from '../utils/version.js'\nimport {COPILOT_CLOUD_BASE_URL} from '../utils/trpc.js'\nimport chalk from 'chalk'\n\nexport class BaseCommand extends Command {\n async init() {\n await this.checkCLIVersion()\n\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.init({\n dsn:\n process.env.SENTRY_DSN ||\n 'https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120',\n integrations: [consoleIntegration()],\n // Tracing\n tracesSampleRate: 1.0, // Capture 100% of the transactions\n })\n }\n\n async catch(err: any) {\n if (process.env.SENTRY_DISABLED === 'true') {\n super.catch(err)\n return\n }\n\n Sentry.captureException(err)\n super.catch(err)\n }\n\n async finally() {\n if (process.env.SENTRY_DISABLED === 'true') {\n return\n }\n\n Sentry.close()\n }\n\n async run() {}\n\n async checkCLIVersion() {\n const response = await fetch(`${COPILOT_CLOUD_BASE_URL}/api/healthz`)\n\n const data = await response.json()\n const cloudVersion = data.cliVersion\n\n if (!cloudVersion || cloudVersion === LIB_VERSION) {\n return\n }\n\n // TODO: add this back in, removed for crew ai launch since we don't want to keep releasing cloud\n // this.log(chalk.yellow('================ New version available! =================\\n'))\n // this.log(`You are using CopilotKit CLI v${LIB_VERSION}.`)\n // this.log(`A new CopilotKit CLI version is available (v${cloudVersion}).\\n`)\n // this.log('Please update your CLI to the latest version:\\n\\n')\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('npm:')))}\\t npm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('pnpm:')))}\\t pnpm install -g copilotkit@${cloudVersion}\\n`)\n // this.log(`${chalk.cyan(chalk.underline(chalk.bold('yarn:')))}\\t yarn global add copilotkit@${cloudVersion}\\n`)\n // this.log(chalk.yellow('============================================================\\n\\n'))\n }\n\n async gracefulError(message: string) {\n this.log('\\n' + chalk.red(message))\n process.exit(1)\n }\n}\n","// This is auto generated!\nexport const LIB_VERSION = \"0.0.36\";\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C;AAAA,MAC3C,CAAC;AAAA,IACH,SAAS,OAAY;AACnB,cAAQ,KAAK;AACb,UAAI,MAAM,YAAY,2BAA2B;AAC/C,eAAO,KAAK;AAAA,UACV,+CAA+C,iBAAiB,GAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQtE;AAAA,MACF,WAAW,MAAM,YAAY,sBAAsB;AACjD,eAAO,KAAK;AAAA,UACV,+BAA+B,IAAI,uDAAuD,IAAI;AAAA,QAChG;AAAA,MACF,OAAO;AACL,eAAO,KAAK,cAAc,4BAA4B,MAAM,OAAO,EAAE;AAAA,MACvE;AAAA,IACF;AAAA,EACF;AACF;","names":["inquirer","ora","chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk","inquirer","ora"]}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ declare class CloudInit extends BaseCommand {
|
|
|
23
23
|
'crew-bearer-token': _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
24
24
|
'langsmith-api-key': _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
25
25
|
'llm-token': _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
26
|
-
'crew-flow-agent': _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
27
26
|
};
|
|
28
27
|
constructor(argv: string[], config: Config, authService?: AuthService);
|
|
29
28
|
run(): Promise<void>;
|
package/dist/commands/init.js
CHANGED
|
@@ -222,7 +222,7 @@ import { Command } from "@oclif/core";
|
|
|
222
222
|
import Sentry, { consoleIntegration } from "@sentry/node";
|
|
223
223
|
|
|
224
224
|
// src/utils/version.ts
|
|
225
|
-
var LIB_VERSION = "0.0.
|
|
225
|
+
var LIB_VERSION = "0.0.36";
|
|
226
226
|
|
|
227
227
|
// src/commands/base-command.ts
|
|
228
228
|
import chalk2 from "chalk";
|
|
@@ -343,20 +343,19 @@ var ConfigSchema = z.object({
|
|
|
343
343
|
crewName: NameSchema.optional(),
|
|
344
344
|
crewUrl: UrlSchema.optional(),
|
|
345
345
|
crewBearerToken: TokenSchema.optional(),
|
|
346
|
-
crewFlowAgent: CrewFlowTemplateSchema.optional(),
|
|
347
346
|
// API keys and tokens
|
|
348
347
|
copilotCloudPublicApiKey: z.string().optional(),
|
|
349
348
|
langSmithApiKey: ApiKeySchema.optional(),
|
|
350
349
|
llmToken: ApiKeySchema.optional()
|
|
351
350
|
}).refine(
|
|
352
351
|
(data) => {
|
|
353
|
-
if (data.mode === "CrewAI"
|
|
352
|
+
if (data.mode === "CrewAI") {
|
|
354
353
|
return !!data.crewUrl && !!data.crewBearerToken;
|
|
355
354
|
}
|
|
356
355
|
return true;
|
|
357
356
|
},
|
|
358
357
|
{
|
|
359
|
-
message: "Crew URL and bearer token are required for CrewAI
|
|
358
|
+
message: "Crew URL and bearer token are required for CrewAI",
|
|
360
359
|
path: ["crewUrl", "crewBearerToken"]
|
|
361
360
|
}
|
|
362
361
|
).refine(
|
|
@@ -382,8 +381,7 @@ var ConfigFlags = {
|
|
|
382
381
|
"crew-url": Flags.string({ description: "URL endpoint for your CrewAI agent" }),
|
|
383
382
|
"crew-bearer-token": Flags.string({ description: "Bearer token for CrewAI authentication" }),
|
|
384
383
|
"langsmith-api-key": Flags.string({ description: "LangSmith API key for LangGraph observability" }),
|
|
385
|
-
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" })
|
|
386
|
-
"crew-flow-agent": Flags.string({ description: "CrewAI Flow template to use", options: CREW_FLOW_TEMPLATES })
|
|
384
|
+
"llm-token": Flags.string({ description: "API key for your preferred LLM provider" })
|
|
387
385
|
};
|
|
388
386
|
|
|
389
387
|
// src/lib/init/types/templates.ts
|
|
@@ -394,11 +392,7 @@ var templateMapping = {
|
|
|
394
392
|
LangGraphPlatformRuntime: `${BASE_URL}/langgraph-platform-starter.json`,
|
|
395
393
|
// CrewAI
|
|
396
394
|
CrewEnterprise: [`${BASE_URL}/coagents-crew-starter.json`],
|
|
397
|
-
|
|
398
|
-
`${BASE_URL}/coagents-starter-ui.json`,
|
|
399
|
-
`${BASE_URL}/agent-layout.json`,
|
|
400
|
-
`${BASE_URL}/remote-endpoint.json`
|
|
401
|
-
],
|
|
395
|
+
CrewFlowsEnterprise: [`${BASE_URL}/coagents-starter-crewai-flows.json`],
|
|
402
396
|
// LangGraph
|
|
403
397
|
LangGraphGeneric: `${BASE_URL}/generic-lg-starter.json`,
|
|
404
398
|
LangGraphStarter: [`${BASE_URL}/langgraph-platform-starter.json`, `${BASE_URL}/coagents-starter-ui.json`],
|
|
@@ -456,12 +450,12 @@ var questions = [
|
|
|
456
450
|
}
|
|
457
451
|
}
|
|
458
452
|
},
|
|
459
|
-
// CrewAI
|
|
453
|
+
// CrewAI specific questions - shown when CrewAI Crews or Flows selected
|
|
460
454
|
{
|
|
461
455
|
type: "input",
|
|
462
456
|
name: "crewName",
|
|
463
457
|
message: "\u{1F465} What would you like to name your crew? (can be anything)",
|
|
464
|
-
when: (answers) => answers.mode === "CrewAI"
|
|
458
|
+
when: (answers) => answers.mode === "CrewAI",
|
|
465
459
|
default: "MyCopilotCrew",
|
|
466
460
|
validate: validateRequired,
|
|
467
461
|
sanitize: sanitizers.trim
|
|
@@ -470,7 +464,7 @@ var questions = [
|
|
|
470
464
|
type: "input",
|
|
471
465
|
name: "crewUrl",
|
|
472
466
|
message: "\u{1F517} Enter your Crew's Enterprise URL (more info at https://app.crewai.com):",
|
|
473
|
-
when: (answers) => answers.mode === "CrewAI"
|
|
467
|
+
when: (answers) => answers.mode === "CrewAI",
|
|
474
468
|
validate: validateUrl,
|
|
475
469
|
sanitize: sanitizers.url
|
|
476
470
|
},
|
|
@@ -478,19 +472,11 @@ var questions = [
|
|
|
478
472
|
type: "input",
|
|
479
473
|
name: "crewBearerToken",
|
|
480
474
|
message: "\u{1F511} Enter your Crew's bearer token:",
|
|
481
|
-
when: (answers) => answers.mode === "CrewAI"
|
|
475
|
+
when: (answers) => answers.mode === "CrewAI",
|
|
482
476
|
sensitive: true,
|
|
483
477
|
validate: validateRequired,
|
|
484
478
|
sanitize: sanitizers.trim
|
|
485
479
|
},
|
|
486
|
-
// CrewAI Flows specific questions - shown when CrewAI Flows selected
|
|
487
|
-
{
|
|
488
|
-
type: "select",
|
|
489
|
-
name: "crewFlowAgent",
|
|
490
|
-
message: "\u{1F4E6} Choose a CrewAI Flow Template",
|
|
491
|
-
choices: Array.from(CREW_FLOW_TEMPLATES),
|
|
492
|
-
when: (answers) => answers.mode === "CrewAI" && answers.crewType === "Flows"
|
|
493
|
-
},
|
|
494
480
|
// LangGraph specific questions - shown when LangGraph selected
|
|
495
481
|
{
|
|
496
482
|
type: "yes/no",
|
|
@@ -564,7 +550,7 @@ var questions = [
|
|
|
564
550
|
type: "input",
|
|
565
551
|
name: "llmToken",
|
|
566
552
|
message: "\u{1F511} Enter your OpenAI API key (required for LLM interfacing):",
|
|
567
|
-
when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || answers.mode === "
|
|
553
|
+
when: (answers) => answers.mode === "LangGraph" && answers.alreadyDeployed === "No" || answers.mode === "Standard" && answers.useCopilotCloud !== "Yes" || answers.mode === "MCP" && answers.useCopilotCloud !== "Yes",
|
|
568
554
|
sensitive: true,
|
|
569
555
|
validate: validateRequired,
|
|
570
556
|
sanitize: sanitizers.apiKey
|
|
@@ -594,8 +580,8 @@ async function scaffoldShadCN(flags, userAnswers) {
|
|
|
594
580
|
case "CrewAI":
|
|
595
581
|
if (userAnswers.crewType === "Crews") {
|
|
596
582
|
components.push(...templateMapping.CrewEnterprise);
|
|
597
|
-
} else if (userAnswers.
|
|
598
|
-
components.push(...templateMapping.
|
|
583
|
+
} else if (userAnswers.crewType === "Flows") {
|
|
584
|
+
components.push(...templateMapping.CrewFlowsEnterprise);
|
|
599
585
|
} else {
|
|
600
586
|
components.push(templateMapping.RemoteEndpoint);
|
|
601
587
|
}
|
|
@@ -697,12 +683,8 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
697
683
|
if (flags.runtimeUrl) {
|
|
698
684
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=${flags.runtimeUrl}
|
|
699
685
|
`;
|
|
700
|
-
} else if (userAnswers.useCopilotCloud !== "Yes" && userAnswers.crewType !== "Crews") {
|
|
686
|
+
} else if (userAnswers.useCopilotCloud !== "Yes" && userAnswers.crewType !== "Crews" && userAnswers.crewType !== "Flows") {
|
|
701
687
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit
|
|
702
|
-
`;
|
|
703
|
-
}
|
|
704
|
-
if (userAnswers.crewFlowAgent === "Starter") {
|
|
705
|
-
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
|
|
706
688
|
`;
|
|
707
689
|
}
|
|
708
690
|
if (userAnswers.langGraphPlatformUrl && userAnswers.langSmithApiKey) {
|
|
@@ -829,7 +811,7 @@ import chalk5 from "chalk";
|
|
|
829
811
|
import path3 from "path";
|
|
830
812
|
import fs3 from "fs";
|
|
831
813
|
async function scaffoldAgent(userAnswers) {
|
|
832
|
-
if (userAnswers.mode === "CrewAI"
|
|
814
|
+
if (userAnswers.mode === "CrewAI" || userAnswers.mode === "LangGraph" && !userAnswers.langGraphAgent || userAnswers.mode === "Standard" || userAnswers.mode === "MCP") {
|
|
833
815
|
return;
|
|
834
816
|
}
|
|
835
817
|
const spinner = ora3({
|
|
@@ -845,11 +827,6 @@ async function scaffoldAgent(userAnswers) {
|
|
|
845
827
|
template = AgentTemplates.LangGraph.Starter.TypeScript;
|
|
846
828
|
}
|
|
847
829
|
break;
|
|
848
|
-
case "CrewAI":
|
|
849
|
-
if (userAnswers.crewFlowAgent === "Starter") {
|
|
850
|
-
template = AgentTemplates.CrewAI.Flows.Starter;
|
|
851
|
-
}
|
|
852
|
-
break;
|
|
853
830
|
}
|
|
854
831
|
if (!template) {
|
|
855
832
|
spinner.fail(chalk5.red("Failed to determine agent template"));
|
|
@@ -993,7 +970,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
993
970
|
\u{1F517} Please go to https://docs.copilotkit.ai/ag2/quickstart/ag2 to get started.`));
|
|
994
971
|
process.exit(0);
|
|
995
972
|
}
|
|
996
|
-
const needsCloudSetup = userAnswers.useCopilotCloud === "Yes" || userAnswers.mode === "CrewAI"
|
|
973
|
+
const needsCloudSetup = userAnswers.useCopilotCloud === "Yes" || userAnswers.mode === "CrewAI";
|
|
997
974
|
if (needsCloudSetup) await this.setupCloud(flags, userAnswers);
|
|
998
975
|
await scaffoldEnv(flags, userAnswers);
|
|
999
976
|
await scaffoldShadCN(flags, userAnswers);
|
|
@@ -1021,7 +998,8 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1021
998
|
message: "\u{1F99C}\u{1F517} What is the LangGraph's agent URL?",
|
|
1022
999
|
name: "agentURL",
|
|
1023
1000
|
validate: (value) => {
|
|
1024
|
-
if (!value)
|
|
1001
|
+
if (!value)
|
|
1002
|
+
return "You need a URL to continue, it should be present on the screen. If you need help, feel free to ask!";
|
|
1025
1003
|
if (!value.includes("http") || !value.includes("://")) return "Please provide a valid URL";
|
|
1026
1004
|
return true;
|
|
1027
1005
|
}
|
|
@@ -1164,26 +1142,27 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1164
1142
|
this.log(chalk6.red(`Failed to update configuration with Copilot Cloud API key: ${error.message}`));
|
|
1165
1143
|
}
|
|
1166
1144
|
if (userAnswers.crewUrl && userAnswers.crewName && userAnswers.crewBearerToken) {
|
|
1145
|
+
const isFlow = userAnswers.crewType === "Flows";
|
|
1167
1146
|
const crewSpinner = ora5({
|
|
1168
|
-
text: chalk6(
|
|
1147
|
+
text: chalk6(`\u{1F465} Adding CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud...`),
|
|
1169
1148
|
color: "cyan"
|
|
1170
1149
|
}).start();
|
|
1171
1150
|
try {
|
|
1172
1151
|
await this.trpcClient.createRemoteEndpoint.mutate({
|
|
1173
|
-
type: "CrewAI",
|
|
1152
|
+
type: isFlow ? "CrewAIFlows" : "CrewAI",
|
|
1174
1153
|
projectId: selectedProjectId,
|
|
1175
1154
|
config: {
|
|
1176
|
-
type: "CrewAI",
|
|
1155
|
+
type: isFlow ? "CrewAIFlows" : "CrewAI",
|
|
1177
1156
|
url: userAnswers.crewUrl,
|
|
1178
1157
|
// Already sanitized
|
|
1179
1158
|
agentName: userAnswers.crewName,
|
|
1180
|
-
agentDescription:
|
|
1159
|
+
agentDescription: `A helpful CrewAI ${isFlow ? "Flow" : "Crew"}`,
|
|
1181
1160
|
crewApiBearerToken: userAnswers.crewBearerToken
|
|
1182
1161
|
}
|
|
1183
1162
|
});
|
|
1184
|
-
crewSpinner.succeed(chalk6(
|
|
1163
|
+
crewSpinner.succeed(chalk6(`\u{1F465} CrewAI ${isFlow ? "Flow" : "Crew"} added to Copilot Cloud`));
|
|
1185
1164
|
} catch (error) {
|
|
1186
|
-
crewSpinner.fail(chalk6(
|
|
1165
|
+
crewSpinner.fail(chalk6(`\u{1F465} Failed to add CrewAI ${isFlow ? "Flow" : "Crew"} to Copilot Cloud`));
|
|
1187
1166
|
console.error(error);
|
|
1188
1167
|
process.exit(1);
|
|
1189
1168
|
}
|
|
@@ -1271,7 +1250,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1271
1250
|
if (userAnswers.crewType === "Crews") {
|
|
1272
1251
|
agentSetupMessage = `Using your Crew from ${chalk6.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
1273
1252
|
} else if (userAnswers.crewType === "Flows") {
|
|
1274
|
-
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(
|
|
1253
|
+
agentSetupMessage = `We've scaffolded a ${chalk6.cyan("CrewAI Flow")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
1275
1254
|
agentDevInstructions = "poetry lock && poetry install && poetry run demo";
|
|
1276
1255
|
}
|
|
1277
1256
|
}
|
|
@@ -1296,7 +1275,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1296
1275
|
agentSetupMessage = `Using your Crew from ${chalk6.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
1297
1276
|
break;
|
|
1298
1277
|
case "Flows":
|
|
1299
|
-
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(
|
|
1278
|
+
agentSetupMessage = `We've scaffolded a ${chalk6.cyan("CrewAI Flow")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
1300
1279
|
break;
|
|
1301
1280
|
}
|
|
1302
1281
|
break;
|