copilotkit 0.0.26 → 0.0.27
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 +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.js +73 -72
- 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 +58 -59
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +28 -25
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/agent.js +1 -1
- package/dist/lib/init/scaffold/agent.js.map +1 -1
- package/dist/lib/init/scaffold/env.js +4 -1
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +36 -40
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/shadcn.js +31 -38
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.js +6 -6
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/questions.d.ts +27 -27
- package/dist/lib/init/types/questions.js +3 -3
- 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 +3 -3
- package/dist/lib/init/types/templates.js.map +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 +4 -7
- package/package.json +1 -1
|
@@ -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.27";
|
|
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: process.env.SENTRY_DSN || \"https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120\",\n integrations: [\n consoleIntegration(),\n ],\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: process.env.SENTRY_DSN || \"https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120\",\n integrations: [\n consoleIntegration(),\n ],\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.27\";\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,SAAS,eAAe;AACxB,OAAO,UAAU,0BAA0B;;;ACApC,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,KAAK,QAAQ,IAAI,cAAc;AAAA,MAC/B,cAAc;AAAA,QACZ,mBAAmB;AAAA,MACrB;AAAA;AAAA,MAEA,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,OAAM,MAAM,IAAI,OAAO,CAAC;AACjC,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.27";
|
|
370
370
|
|
|
371
371
|
// src/commands/base-command.ts
|
|
372
372
|
import chalk2 from "chalk";
|
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 try again.'))\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(private readonly authData?: {\n userId: string,\n email: string,\n organizationId: string,\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\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 segment_group: this.organizationId,\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\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: process.env.SENTRY_DSN || \"https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120\",\n integrations: [\n consoleIntegration(),\n ],\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.26\";\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,YAA6B,UAI1B;AAJ0B;AAK3B,QAAI,QAAQ,IAAI,qBAAqB,QAAQ;AAC3C;AAAA,IACF;AAEA,UAAM,kBAAkB,QAAQ,IAAI,qBAAqB;AAEzD,SAAK,mBAAmB;AAAA,MACtB,SAAS;AAAA,IACX;AAGA,QAAI,KAAK,UAAU,QAAQ;AACzB,WAAK,SAAS,KAAK,SAAS;AAAA,IAC9B;AAEA,Q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IAAIA,OAAM,OAAM,oBAAI,KAAK,GAAE,YAAY,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,EAAE;AAAA,IACvG,CAAC;AAED,WAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,WAAK,cAAcA,OAAM,IAAI,iBAAiB,IAAI,OAAO,EAAE,CAAC;AAAA,IAC9D,CAAC;AAED,WAAO,GAAG,SAAS,YAAY;AAC7B,WAAK,IAAIA,OAAM,OAAO,iBAAiB,CAAC;AAExC,YAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAGD,UAAM,QAAQ,IAAI;AAAA,MAChB,IAAI,QAAc,MAAM;AACtB,gBAAQ,GAAG,UAAU,YAAY;AAC/B,eAAK,IAAI,2BAA2B;AACpC,gBAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,iBAAO,MAAM;AACb,kBAAQ,KAAK,CAAC;AAAA,QAChB,CAAC;AAED,gBAAQ,GAAG,WAAW,YAAY;AAChC,eAAK,IAAI,2BAA2B;AACpC,gBAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,iBAAO,MAAM;AACb,kBAAQ,KAAK,CAAC;AAAA,QAChB,CAAC;AAAA,MACH,CAAC;AAAA,MACD,UAAU,EAAC,KAAK,OAAO,KAAK,IAAI,SAAQ,CAAC;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;","names":["inquirer","ora","chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk","inquirer","ora"]}
|
|
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 try again.'))\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(private readonly authData?: {\n userId: string,\n email: string,\n organizationId: string,\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\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 segment_group: this.organizationId,\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\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: process.env.SENTRY_DSN || \"https://1eea15d32e2eacb0456a77db5e39aeeb@o4507288195170304.ingest.us.sentry.io/4508581448581120\",\n integrations: [\n consoleIntegration(),\n ],\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.27\";\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,YAA6B,UAI1B;AAJ0B;AAK3B,QAAI,QAAQ,IAAI,qBAAqB,QAAQ;AAC3C;AAAA,IACF;AAEA,UAAM,kBAAkB,QAAQ,IAAI,qBAAqB;AAEzD,SAAK,mBAAmB;AAAA,MACtB,SAAS;AAAA,IACX;AAGA,QAAI,KAAK,UAAU,QAAQ;AACzB,WAAK,SAAS,KAAK,SAAS;AAAA,IAC9B;AAEA,QAAI,KAAK,UAAU,OAAO;AACxB,WAAK,QAAQ,KAAK,SAAS;AAC3B,WAAK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K,MAAM,IAAI,KAAK,IAAI,EAAE;AAAA,IACvG,CAAC;AAED,WAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,WAAK,cAAcA,OAAM,IAAI,iBAAiB,IAAI,OAAO,EAAE,CAAC;AAAA,IAC9D,CAAC;AAED,WAAO,GAAG,SAAS,YAAY;AAC7B,WAAK,IAAIA,OAAM,OAAO,iBAAiB,CAAC;AAExC,YAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAGD,UAAM,QAAQ,IAAI;AAAA,MAChB,IAAI,QAAc,MAAM;AACtB,gBAAQ,GAAG,UAAU,YAAY;AAC/B,eAAK,IAAI,2BAA2B;AACpC,gBAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,iBAAO,MAAM;AACb,kBAAQ,KAAK,CAAC;AAAA,QAChB,CAAC;AAED,gBAAQ,GAAG,WAAW,YAAY;AAChC,eAAK,IAAI,2BAA2B;AACpC,gBAAM,cAAc,EAAC,IAAI,SAAQ,CAAC;AAClC,iBAAO,MAAM;AACb,kBAAQ,KAAK,CAAC;AAAA,QAChB,CAAC;AAAA,MACH,CAAC;AAAA,MACD,UAAU,EAAC,KAAK,OAAO,KAAK,IAAI,SAAQ,CAAC;AAAA,IAC3C,CAAC;AAAA,EACH;AACF;","names":["inquirer","ora","chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk","inquirer","ora"]}
|
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.27";
|
|
226
226
|
|
|
227
227
|
// src/commands/base-command.ts
|
|
228
228
|
import chalk2 from "chalk";
|
|
@@ -275,11 +275,11 @@ var BaseCommand = class extends Command {
|
|
|
275
275
|
// src/lib/init/types/questions.ts
|
|
276
276
|
import { z } from "zod";
|
|
277
277
|
import { Flags } from "@oclif/core";
|
|
278
|
-
var AGENT_FRAMEWORKS = ["CrewAI", "LangGraph"
|
|
278
|
+
var AGENT_FRAMEWORKS = ["CrewAI", "LangGraph"];
|
|
279
279
|
var CREW_TYPES = ["Crews", "Flows"];
|
|
280
280
|
var CHAT_COMPONENTS = ["CopilotChat", "CopilotSidebar", "Headless", "CopilotPopup"];
|
|
281
|
-
var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter"
|
|
282
|
-
var CREW_FLOW_TEMPLATES = ["Starter"
|
|
281
|
+
var LANGGRAPH_AGENTS = ["Python Starter", "TypeScript Starter"];
|
|
282
|
+
var CREW_FLOW_TEMPLATES = ["Starter"];
|
|
283
283
|
var YES_NO = ["Yes", "No"];
|
|
284
284
|
var sanitizers = {
|
|
285
285
|
// Remove trailing slash from URLs
|
|
@@ -389,14 +389,14 @@ var ConfigFlags = {
|
|
|
389
389
|
};
|
|
390
390
|
|
|
391
391
|
// src/lib/init/types/templates.ts
|
|
392
|
-
var BASE_URL = "
|
|
392
|
+
var BASE_URL = "http://localhost:3002/r";
|
|
393
393
|
var templateMapping = {
|
|
394
|
-
"
|
|
394
|
+
"LangGraphPlatformRuntime": `${BASE_URL}/langgraph-platform-starter.json`,
|
|
395
395
|
"RemoteEndpoint": `${BASE_URL}/remote-endpoint-starter.json`,
|
|
396
396
|
"CrewEnterprise": [
|
|
397
397
|
`${BASE_URL}/coagents-crew-starter.json`
|
|
398
398
|
],
|
|
399
|
-
"LangGraphGeneric": `${BASE_URL}/generic-lg-starter.json`,
|
|
399
|
+
"LangGraphGeneric": `${BASE_URL}/generic-lg-starter-with-cloud.json`,
|
|
400
400
|
"CrewFlowsStarter": [
|
|
401
401
|
`${BASE_URL}/coagents-starter-ui.json`,
|
|
402
402
|
`${BASE_URL}/agent-layout.json`,
|
|
@@ -471,7 +471,7 @@ var questions = [
|
|
|
471
471
|
{
|
|
472
472
|
type: "input",
|
|
473
473
|
name: "crewUrl",
|
|
474
|
-
message: "\u{1F517} Enter your Crew's URL:",
|
|
474
|
+
message: "\u{1F517} Enter your Crew's Enterprise URL (more info at https://app.crewai.com):",
|
|
475
475
|
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Crews",
|
|
476
476
|
validate: validateUrl,
|
|
477
477
|
sanitize: sanitizers.url
|
|
@@ -511,7 +511,7 @@ var questions = [
|
|
|
511
511
|
{
|
|
512
512
|
type: "yes/no",
|
|
513
513
|
name: "langGraphPlatform",
|
|
514
|
-
message: "\u{1F99C}\u{1F517} Is it hosted with LangGraph Platform (
|
|
514
|
+
message: "\u{1F99C}\u{1F517} Is it hosted with LangGraph Platform (either self-hosted or in LangSmith)?",
|
|
515
515
|
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes",
|
|
516
516
|
validate: (input) => {
|
|
517
517
|
try {
|
|
@@ -530,14 +530,17 @@ var questions = [
|
|
|
530
530
|
validate: validateUrl,
|
|
531
531
|
sanitize: sanitizers.url
|
|
532
532
|
},
|
|
533
|
-
{
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
533
|
+
// {
|
|
534
|
+
// type: 'input',
|
|
535
|
+
// name: 'langGraphRemoteEndpointURL',
|
|
536
|
+
// message: '🔌 Enter your LangGraph endpoint URL:',
|
|
537
|
+
// when: (answers) =>
|
|
538
|
+
// answers.agentFramework === 'LangGraph' &&
|
|
539
|
+
// answers.alreadyDeployed === 'Yes' &&
|
|
540
|
+
// answers.langGraphPlatform === 'No',
|
|
541
|
+
// validate: validateUrl,
|
|
542
|
+
// sanitize: sanitizers.url
|
|
543
|
+
// },
|
|
541
544
|
{
|
|
542
545
|
type: "select",
|
|
543
546
|
name: "langGraphAgent",
|
|
@@ -559,7 +562,7 @@ var questions = [
|
|
|
559
562
|
type: "yes/no",
|
|
560
563
|
name: "useCopilotCloud",
|
|
561
564
|
message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
|
|
562
|
-
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews") && answers.crewType !== "Flows" && answers.alreadyDeployed === "Yes",
|
|
565
|
+
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews") && answers.crewType !== "Flows" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform !== "No",
|
|
563
566
|
validate: (input) => {
|
|
564
567
|
try {
|
|
565
568
|
YesNoSchema.parse(input);
|
|
@@ -580,14 +583,14 @@ var questions = [
|
|
|
580
583
|
// answers.useCopilotCloud !== 'Yes',
|
|
581
584
|
// },
|
|
582
585
|
// UI components - always shown last
|
|
583
|
-
{
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
},
|
|
586
|
+
// {
|
|
587
|
+
// type: 'select',
|
|
588
|
+
// name: 'chatUi',
|
|
589
|
+
// message: '💬 Select a UI component for your copilot:',
|
|
590
|
+
// choices: Array.from(CHAT_COMPONENTS),
|
|
591
|
+
// default: 'CopilotChat',
|
|
592
|
+
// when: (answers) => answers.agentFramework === 'None',
|
|
593
|
+
// },
|
|
591
594
|
{
|
|
592
595
|
type: "input",
|
|
593
596
|
name: "llmToken",
|
|
@@ -604,40 +607,33 @@ import spawn from "cross-spawn";
|
|
|
604
607
|
async function scaffoldShadCN(userAnswers) {
|
|
605
608
|
try {
|
|
606
609
|
const components = [];
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
} else if (userAnswers.crewFlowAgent) {
|
|
620
|
-
components.push(...templateMapping.CrewFlowsStarter);
|
|
621
|
-
} else {
|
|
622
|
-
components.push(templateMapping.RemoteEndpoint);
|
|
610
|
+
switch (userAnswers.agentFramework) {
|
|
611
|
+
case "LangGraph":
|
|
612
|
+
if (userAnswers.langGraphAgent) {
|
|
613
|
+
components.push(...templateMapping.LangGraphStarter);
|
|
614
|
+
} else {
|
|
615
|
+
components.push(templateMapping.LangGraphGeneric);
|
|
616
|
+
if (userAnswers.useCopilotCloud !== "Yes") {
|
|
617
|
+
if (userAnswers.langGraphPlatform === "Yes") {
|
|
618
|
+
components.push(templateMapping.LangGraphPlatformRuntime);
|
|
619
|
+
} else {
|
|
620
|
+
components.push(templateMapping.RemoteEndpoint);
|
|
621
|
+
}
|
|
623
622
|
}
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
}
|
|
624
|
+
break;
|
|
625
|
+
case "CrewAI":
|
|
626
|
+
if (userAnswers.crewType === "Crews") {
|
|
627
|
+
components.push(...templateMapping.CrewEnterprise);
|
|
628
|
+
} else if (userAnswers.crewFlowAgent) {
|
|
629
|
+
components.push(...templateMapping.CrewFlowsStarter);
|
|
630
|
+
} else {
|
|
626
631
|
components.push(templateMapping.RemoteEndpoint);
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
components.push(...templateMapping.CopilotChat);
|
|
633
|
-
break;
|
|
634
|
-
case "CopilotSidebar":
|
|
635
|
-
components.push(...templateMapping.CopilotSidebar);
|
|
636
|
-
break;
|
|
637
|
-
case "CopilotPopup":
|
|
638
|
-
components.push(...templateMapping.CopilotPopup);
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
632
|
+
}
|
|
633
|
+
break;
|
|
634
|
+
default:
|
|
635
|
+
components.push(templateMapping.RemoteEndpoint);
|
|
636
|
+
break;
|
|
641
637
|
}
|
|
642
638
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
643
639
|
try {
|
|
@@ -709,13 +705,16 @@ async function scaffoldEnv(flags, userAnswers) {
|
|
|
709
705
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${userAnswers.crewName}
|
|
710
706
|
`;
|
|
711
707
|
}
|
|
712
|
-
if (userAnswers.langGraphAgent
|
|
708
|
+
if (userAnswers.langGraphAgent) {
|
|
713
709
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
|
|
714
710
|
`;
|
|
715
711
|
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123
|
|
716
712
|
`;
|
|
717
713
|
} else if (userAnswers.langGraphPlatform === "Yes" && userAnswers.useCopilotCloud === "No") {
|
|
718
714
|
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}
|
|
715
|
+
`;
|
|
716
|
+
} else if (userAnswers.langGraphRemoteEndpointURL) {
|
|
717
|
+
newEnvValues += `COPILOTKIT_REMOTE_ENDPOINT=${userAnswers.langGraphRemoteEndpointURL}
|
|
719
718
|
`;
|
|
720
719
|
}
|
|
721
720
|
if (flags.runtimeUrl) {
|
|
@@ -853,7 +852,7 @@ import chalk5 from "chalk";
|
|
|
853
852
|
import path3 from "path";
|
|
854
853
|
import fs3 from "fs";
|
|
855
854
|
async function scaffoldAgent(userAnswers) {
|
|
856
|
-
if (userAnswers.agentFramework === "
|
|
855
|
+
if (userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Crews" || userAnswers.agentFramework === "LangGraph" && !userAnswers.langGraphAgent) {
|
|
857
856
|
return;
|
|
858
857
|
}
|
|
859
858
|
const spinner = ora3({
|
|
@@ -1037,6 +1036,11 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1037
1036
|
}
|
|
1038
1037
|
});
|
|
1039
1038
|
const answers = await inquirer3.prompt(inquirerQuestions);
|
|
1039
|
+
if (answers.langGraphPlatform === "No") {
|
|
1040
|
+
this.log("\nCurrently the CLI only supports scaffolding LangGraph Platform agents. Use our quickstart guide to get started:\n");
|
|
1041
|
+
this.log(chalk6.blue("https://docs.copilotkit.ai/coagents/quickstart/langgraph"));
|
|
1042
|
+
process.exit(0);
|
|
1043
|
+
}
|
|
1040
1044
|
try {
|
|
1041
1045
|
const spinner = ora5({ text: "Validating configuration...", color: "green" }).start();
|
|
1042
1046
|
const validatedConfig = ConfigSchema.parse(answers);
|
|
@@ -1188,7 +1192,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1188
1192
|
spinner.fail(`Not a Next.js project`);
|
|
1189
1193
|
throw new Error(`Directory ${projectPath} does not appear to be a Next.js project. Make sure it has next in dependencies.`);
|
|
1190
1194
|
}
|
|
1191
|
-
spinner.succeed(
|
|
1195
|
+
spinner.succeed(`\u{1F53C} Valid Next.js project detected at ${projectPath}`);
|
|
1192
1196
|
return true;
|
|
1193
1197
|
} catch (error) {
|
|
1194
1198
|
if (!spinner.isSpinning) {
|
|
@@ -1203,15 +1207,12 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1203
1207
|
let agentDevInstructions = "";
|
|
1204
1208
|
let agentType = "";
|
|
1205
1209
|
let agentSetupMessage = "";
|
|
1206
|
-
if (userAnswers.agentFramework
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(userAnswers.crewFlowAgent || "CrewAI")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
1213
|
-
agentDevInstructions = "poetry install && poetry run demo";
|
|
1214
|
-
}
|
|
1210
|
+
if (userAnswers.agentFramework === "CrewAI") {
|
|
1211
|
+
agentType = "CrewAI";
|
|
1212
|
+
if (userAnswers.crewType === "Crews") {
|
|
1213
|
+
agentSetupMessage = `Using your Crew from ${chalk6.cyan(userAnswers.crewUrl || "the provided URL")}.`;
|
|
1214
|
+
} else if (userAnswers.crewType === "Flows") {
|
|
1215
|
+
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(userAnswers.crewFlowAgent || "CrewAI")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
1215
1216
|
}
|
|
1216
1217
|
}
|
|
1217
1218
|
switch (userAnswers.agentFramework) {
|
|
@@ -1219,7 +1220,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1219
1220
|
switch (userAnswers.langGraphAgent) {
|
|
1220
1221
|
case "Python Starter":
|
|
1221
1222
|
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(userAnswers.langGraphAgent || "LangGraph")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
1222
|
-
agentDevInstructions = "poetry install && npx @langchain/langgraph-cli dev --port 8123";
|
|
1223
|
+
agentDevInstructions = "poetry lock && poetry install && npx @langchain/langgraph-cli dev --port 8123";
|
|
1223
1224
|
break;
|
|
1224
1225
|
case "TypeScript Starter":
|
|
1225
1226
|
agentSetupMessage = `We've scaffolded a ${chalk6.cyan(userAnswers.langGraphAgent || "LangGraph")} agent in the ${chalk6.cyan("./agent")} directory.`;
|
|
@@ -1251,7 +1252,7 @@ var CloudInit = class _CloudInit extends BaseCommand {
|
|
|
1251
1252
|
this.log(` - Start your Next.js app: ${chalk6.gray("$")} ${chalk6.cyan("npm run dev")}`);
|
|
1252
1253
|
if (agentDevInstructions) this.log(` - Start your agent: ${chalk6.gray("$")} ${chalk6.cyan(`cd agent && ${agentDevInstructions}`)}`);
|
|
1253
1254
|
this.log(` - Navigate to ${chalk6.blue("http://localhost:3000/copilotkit")}`);
|
|
1254
|
-
this.log(` - Talk to your
|
|
1255
|
+
this.log(` - Talk to your agent.`);
|
|
1255
1256
|
this.log(` - Read the docs: ${chalk6.blue("https://docs.copilotkit.ai")}`);
|
|
1256
1257
|
this.log(chalk6.magenta("\nEnjoy building with CopilotKit \u{1FA81}\n"));
|
|
1257
1258
|
}
|