copilotkit 0.0.23 → 0.0.24
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 +4 -3
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.js +231 -146
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.js +4 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +4 -3
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/index.js +138 -112
- package/dist/lib/init/index.js.map +1 -1
- package/dist/lib/init/questions.js +46 -54
- package/dist/lib/init/questions.js.map +1 -1
- package/dist/lib/init/scaffold/agent.js +2 -2
- package/dist/lib/init/scaffold/agent.js.map +1 -1
- package/dist/lib/init/scaffold/env.js +60 -30
- package/dist/lib/init/scaffold/env.js.map +1 -1
- package/dist/lib/init/scaffold/index.js +98 -59
- package/dist/lib/init/scaffold/index.js.map +1 -1
- package/dist/lib/init/scaffold/langgraph-assistants.d.ts +18 -0
- package/dist/lib/init/scaffold/langgraph-assistants.js +27 -0
- package/dist/lib/init/scaffold/langgraph-assistants.js.map +1 -0
- package/dist/lib/init/scaffold/shadcn.js +11 -2
- package/dist/lib/init/scaffold/shadcn.js.map +1 -1
- package/dist/lib/init/types/index.js +6 -1
- package/dist/lib/init/types/index.js.map +1 -1
- package/dist/lib/init/types/templates.d.ts +2 -0
- package/dist/lib/init/types/templates.js +6 -1
- package/dist/lib/init/types/templates.js.map +1 -1
- package/dist/services/auth.service.js +3 -2
- package/dist/services/auth.service.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 +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/logout.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import {Config} from '@oclif/core'\nimport chalk from 'chalk'\nimport ora from 'ora'\n\nimport {AuthService} from '../services/auth.service.js'\nimport { BaseCommand } from './base-command.js'\n\nexport default class CloudLogout extends BaseCommand {\n static override description = 'Logout from Copilot Cloud'\n\n static override examples = ['<%= config.bin %> logout']\n\n constructor(argv: string[], config: Config, private authService = new AuthService()) {\n super(argv, config)\n }\n\n public async run(): Promise<void> {\n await this.parse(CloudLogout)\n this.log(\"Logging out...\\n\");\n await this.authService.logout(this);\n this.log(chalk.green('Successfully logged out!'))\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\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\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 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 const spinner = ora('Waiting for browser authentication to complete...\\n').start()\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","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.23\";\n"],"mappings":";AACA,OAAOA,YAAW;;;ACAlB,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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;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,OAAMA,OAAM,IAAI,OAAO,CAAC;AACjC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AJ9DA,IAAqB,cAArB,MAAqB,qBAAoB,YAAY;AAAA,EAKnD,YAAY,MAAgB,QAAwB,cAAc,IAAI,YAAY,GAAG;AACnF,UAAM,MAAM,MAAM;AADgC;AAAA,EAEpD;AAAA,EANA,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW,CAAC,0BAA0B;AAAA,EAMtD,MAAa,MAAqB;AAChC,UAAM,KAAK,MAAM,YAAW;AAC5B,SAAK,IAAI,kBAAkB;AAC3B,UAAM,KAAK,YAAY,OAAO,IAAI;AAClC,SAAK,IAAIC,OAAM,MAAM,0BAA0B,CAAC;AAAA,EAClD;AACF;","names":["chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/logout.ts","../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts","../../src/commands/base-command.ts","../../src/utils/version.ts"],"sourcesContent":["import {Config} from '@oclif/core'\nimport chalk from 'chalk'\nimport ora from 'ora'\n\nimport {AuthService} from '../services/auth.service.js'\nimport { BaseCommand } from './base-command.js'\n\nexport default class CloudLogout extends BaseCommand {\n static override description = 'Logout from Copilot Cloud'\n\n static override examples = ['<%= config.bin %> logout']\n\n constructor(argv: string[], config: Config, private authService = new AuthService()) {\n super(argv, config)\n }\n\n public async run(): Promise<void> {\n await this.parse(CloudLogout)\n this.log(\"Logging out...\\n\");\n await this.authService.logout(this);\n this.log(chalk.green('Successfully logged out!'))\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","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.24\";\n"],"mappings":";AACA,OAAOA,YAAW;;;ACAlB,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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,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,OAAMA,OAAM,IAAI,OAAO,CAAC;AACjC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AJ9DA,IAAqB,cAArB,MAAqB,qBAAoB,YAAY;AAAA,EAKnD,YAAY,MAAgB,QAAwB,cAAc,IAAI,YAAY,GAAG;AACnF,UAAM,MAAM,MAAM;AADgC;AAAA,EAEpD;AAAA,EANA,OAAgB,cAAc;AAAA,EAE9B,OAAgB,WAAW,CAAC,0BAA0B;AAAA,EAMtD,MAAa,MAAqB;AAChC,UAAM,KAAK,MAAM,YAAW;AAC5B,SAAK,IAAI,kBAAkB;AAC3B,UAAM,KAAK,YAAY,OAAO,IAAI;AAClC,SAAK,IAAIC,OAAM,MAAM,0BAA0B,CAAC;AAAA,EAClD;AACF;","names":["chalk","Conf","crypto","anonymousId","Conf","trpcClient","crypto","chalk","chalk"]}
|
package/dist/lib/init/index.js
CHANGED
|
@@ -22,18 +22,23 @@ var ConfigFlags = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// src/lib/init/types/templates.ts
|
|
25
|
-
var BASE_URL = "
|
|
25
|
+
var BASE_URL = "https://registry.copilotkit.ai/r";
|
|
26
26
|
var templateMapping = {
|
|
27
27
|
"LangGraphPlatform": `${BASE_URL}/langgraph-platform-starter.json`,
|
|
28
28
|
"RemoteEndpoint": `${BASE_URL}/remote-endpoint-starter.json`,
|
|
29
29
|
"CrewEnterprise": [
|
|
30
30
|
`${BASE_URL}/coagents-crew-starter.json`
|
|
31
31
|
],
|
|
32
|
+
"LangGraphGeneric": `${BASE_URL}/generic-lg-starter.json`,
|
|
32
33
|
"CrewFlowsStarter": [
|
|
33
34
|
`${BASE_URL}/coagents-starter-ui.json`,
|
|
34
35
|
`${BASE_URL}/agent-layout.json`,
|
|
35
36
|
`${BASE_URL}/remote-endpoint.json`
|
|
36
37
|
],
|
|
38
|
+
"LangGraphStarter": [
|
|
39
|
+
`${BASE_URL}/langgraph-platform-starter.json`,
|
|
40
|
+
`${BASE_URL}/coagents-starter-ui.json`
|
|
41
|
+
],
|
|
37
42
|
"Standard": `${BASE_URL}/standard-starter.json`,
|
|
38
43
|
"CopilotChat": `${BASE_URL}/chat.json`,
|
|
39
44
|
"CopilotPopup": `${BASE_URL}/popup.json`,
|
|
@@ -87,62 +92,50 @@ var questions = [
|
|
|
87
92
|
when: (answers) => answers.agentFramework === "CrewAI" && answers.crewType === "Flows"
|
|
88
93
|
},
|
|
89
94
|
// LangGraph specific questions - shown when LangGraph selected
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// answers.agentFramework === 'LangGraph' &&
|
|
129
|
-
// answers.alreadyDeployed === 'No',
|
|
130
|
-
// },
|
|
131
|
-
// {
|
|
132
|
-
// type: 'input',
|
|
133
|
-
// name: 'langSmithApiKey',
|
|
134
|
-
// message: '🦜🔗 Enter your LangSmith API key (required by LangGraph Platform) :',
|
|
135
|
-
// when: (answers) =>
|
|
136
|
-
// answers.agentFramework === 'LangGraph' &&
|
|
137
|
-
// answers.alreadyDeployed === 'No',
|
|
138
|
-
// sensitive: true,
|
|
139
|
-
// },
|
|
95
|
+
{
|
|
96
|
+
type: "yes/no",
|
|
97
|
+
name: "alreadyDeployed",
|
|
98
|
+
message: "\u{1F680} Is your LangGraph agent already deployed?",
|
|
99
|
+
when: (answers) => answers.agentFramework === "LangGraph"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "yes/no",
|
|
103
|
+
name: "langGraphPlatform",
|
|
104
|
+
message: "\u{1F99C}\u{1F517} Is it hosted with LangGraph Platform (local or cloud)?",
|
|
105
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: "input",
|
|
109
|
+
name: "langGraphPlatformUrl",
|
|
110
|
+
message: "\u{1F99C}\u{1F517} Enter your LangGraph platform URL:",
|
|
111
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform === "Yes"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "input",
|
|
115
|
+
name: "langGraphRemoteEndpointURL",
|
|
116
|
+
message: "\u{1F50C} Enter your LangGraph endpoint URL:",
|
|
117
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "Yes" && answers.langGraphPlatform === "No"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "select",
|
|
121
|
+
name: "langGraphAgent",
|
|
122
|
+
message: "\u{1F4E6} Choose a LangGraph starter template:",
|
|
123
|
+
choices: Array.from(LANGGRAPH_AGENTS),
|
|
124
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "No"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: "input",
|
|
128
|
+
name: "langSmithApiKey",
|
|
129
|
+
message: "\u{1F99C}\u{1F517} Enter your LangSmith API key (required by LangGraph Platform) :",
|
|
130
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.langGraphPlatform === "Yes",
|
|
131
|
+
sensitive: true
|
|
132
|
+
},
|
|
140
133
|
// Deployment options
|
|
141
134
|
{
|
|
142
135
|
type: "yes/no",
|
|
143
136
|
name: "useCopilotCloud",
|
|
144
137
|
message: "\u{1FA81} Deploy with Copilot Cloud? (recommended for production)",
|
|
145
|
-
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews") && answers.
|
|
138
|
+
when: (answers) => !(answers.agentFramework === "CrewAI" && answers.crewType === "Crews") && answers.crewType !== "Flows" && answers.alreadyDeployed === "Yes"
|
|
146
139
|
},
|
|
147
140
|
// {
|
|
148
141
|
// type: 'yes/no',
|
|
@@ -167,8 +160,7 @@ var questions = [
|
|
|
167
160
|
type: "input",
|
|
168
161
|
name: "llmToken",
|
|
169
162
|
message: "\u{1F511} Enter your OpenAI API key (required for agent functionality):",
|
|
170
|
-
when: (answers) => answers.agentFramework
|
|
171
|
-
(answers.agentFramework === "CrewAI" && answers.crewType === "Flows"),
|
|
163
|
+
when: (answers) => answers.agentFramework === "LangGraph" && answers.alreadyDeployed === "No" || answers.agentFramework === "CrewAI" && answers.crewType === "Flows",
|
|
172
164
|
sensitive: true
|
|
173
165
|
}
|
|
174
166
|
];
|
|
@@ -181,7 +173,11 @@ async function scaffoldShadCN(userAnswers) {
|
|
|
181
173
|
if (userAnswers.agentFramework !== "None") {
|
|
182
174
|
switch (userAnswers.agentFramework) {
|
|
183
175
|
case "LangGraph":
|
|
184
|
-
|
|
176
|
+
if (userAnswers.langGraphAgent && userAnswers.langGraphAgent !== "None") {
|
|
177
|
+
components.push(...templateMapping.LangGraphStarter);
|
|
178
|
+
} else {
|
|
179
|
+
components.push(templateMapping.LangGraphGeneric);
|
|
180
|
+
}
|
|
185
181
|
break;
|
|
186
182
|
case "CrewAI":
|
|
187
183
|
if (userAnswers.crewType === "Crews") {
|
|
@@ -217,75 +213,105 @@ async function scaffoldShadCN(userAnswers) {
|
|
|
217
213
|
// src/lib/init/scaffold/env.ts
|
|
218
214
|
import path from "path";
|
|
219
215
|
import fs from "fs";
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
|
|
217
|
+
// src/lib/init/scaffold/langgraph-assistants.ts
|
|
218
|
+
async function getLangGraphAgents(url, langSmithApiKey) {
|
|
219
|
+
try {
|
|
220
|
+
const response = await fetch(
|
|
221
|
+
`${url}/assistants/search`,
|
|
222
|
+
{
|
|
223
|
+
method: "POST",
|
|
224
|
+
headers: {
|
|
225
|
+
"Content-Type": "application/json",
|
|
226
|
+
"X-Api-Key": langSmithApiKey
|
|
227
|
+
},
|
|
228
|
+
body: JSON.stringify({
|
|
229
|
+
limit: 10,
|
|
230
|
+
offset: 0
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
const result = await response.json();
|
|
235
|
+
return result;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
throw new Error("Failed to get LangGraph agents");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/lib/init/scaffold/env.ts
|
|
242
|
+
import inquirer from "inquirer";
|
|
222
243
|
async function scaffoldEnv(flags, userAnswers) {
|
|
223
|
-
const spinner = ora({
|
|
224
|
-
text: chalk.cyan("Configuring environment variables..."),
|
|
225
|
-
color: "cyan"
|
|
226
|
-
}).start();
|
|
227
244
|
try {
|
|
228
245
|
const envFile = path.join(process.cwd(), ".env");
|
|
229
246
|
if (!fs.existsSync(envFile)) {
|
|
230
247
|
fs.writeFileSync(envFile, "", "utf8");
|
|
231
|
-
spinner.text = chalk.cyan("Created .env file...");
|
|
232
248
|
} else {
|
|
233
|
-
spinner.text = chalk.cyan("Updating existing .env file...");
|
|
234
249
|
}
|
|
235
250
|
let newEnvValues = "";
|
|
236
|
-
let varsAdded = false;
|
|
237
251
|
if (userAnswers.copilotCloudPublicApiKey) {
|
|
238
252
|
newEnvValues += `NEXT_PUBLIC_COPILOT_API_KEY=${userAnswers.copilotCloudPublicApiKey}
|
|
239
253
|
`;
|
|
240
|
-
spinner.text = chalk.cyan("Adding Copilot Cloud API key...");
|
|
241
|
-
varsAdded = true;
|
|
242
254
|
}
|
|
243
255
|
if (userAnswers.langSmithApiKey) {
|
|
244
256
|
newEnvValues += `LANGSMITH_API_KEY=${userAnswers.langSmithApiKey}
|
|
245
257
|
`;
|
|
246
|
-
spinner.text = chalk.cyan("Adding LangSmith API key...");
|
|
247
|
-
varsAdded = true;
|
|
248
258
|
}
|
|
249
259
|
if (userAnswers.llmToken) {
|
|
250
260
|
newEnvValues += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
251
261
|
`;
|
|
252
|
-
spinner.text = chalk.cyan("Adding OpenAI API key...");
|
|
253
|
-
varsAdded = true;
|
|
254
262
|
}
|
|
255
263
|
if (userAnswers.crewName) {
|
|
256
264
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${userAnswers.crewName}
|
|
257
265
|
`;
|
|
258
|
-
|
|
259
|
-
|
|
266
|
+
}
|
|
267
|
+
if (userAnswers.langGraphAgent !== "None" && userAnswers.langGraphPlatform !== "Yes") {
|
|
268
|
+
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
|
|
269
|
+
`;
|
|
270
|
+
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=http://localhost:8123
|
|
271
|
+
`;
|
|
272
|
+
} else if (userAnswers.langGraphPlatform === "Yes" && userAnswers.useCopilotCloud === "No") {
|
|
273
|
+
newEnvValues += `LANGGRAPH_DEPLOYMENT_URL=${userAnswers.langGraphPlatformUrl}
|
|
274
|
+
`;
|
|
260
275
|
}
|
|
261
276
|
if (flags.runtimeUrl) {
|
|
262
277
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=${flags.runtimeUrl}
|
|
263
278
|
`;
|
|
264
|
-
|
|
265
|
-
varsAdded = true;
|
|
266
|
-
} else if (!userAnswers.useCopilotCloud && userAnswers.crewType !== "Crews") {
|
|
279
|
+
} else if (userAnswers.useCopilotCloud !== "Yes" && userAnswers.crewType !== "Crews") {
|
|
267
280
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_RUNTIME_URL=/api/copilotkit
|
|
268
281
|
`;
|
|
269
|
-
spinner.text = chalk.cyan("Adding CopilotKit runtime URL...");
|
|
270
|
-
varsAdded = true;
|
|
271
282
|
}
|
|
272
283
|
if (userAnswers.crewFlowAgent === "Starter") {
|
|
273
284
|
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=sample_agent
|
|
274
285
|
`;
|
|
275
|
-
spinner.text = chalk.cyan("Adding Flow agent name...");
|
|
276
|
-
varsAdded = true;
|
|
277
286
|
}
|
|
278
|
-
if (
|
|
279
|
-
|
|
287
|
+
if (userAnswers.langGraphPlatformUrl && userAnswers.langSmithApiKey) {
|
|
288
|
+
const langGraphAgents = await getLangGraphAgents(userAnswers.langGraphPlatformUrl, userAnswers.langSmithApiKey);
|
|
289
|
+
let langGraphAgent = "";
|
|
290
|
+
if (langGraphAgents.length > 1) {
|
|
291
|
+
const { langGraphAgentChoice } = await inquirer.prompt([
|
|
292
|
+
{
|
|
293
|
+
type: "list",
|
|
294
|
+
name: "langGraphAgentChoice",
|
|
295
|
+
message: "\u{1F99C}\u{1F517} Which agent from your graph would you like to use?",
|
|
296
|
+
choices: langGraphAgents.map((agent) => ({
|
|
297
|
+
name: agent.graph_id,
|
|
298
|
+
value: agent.graph_id
|
|
299
|
+
}))
|
|
300
|
+
}
|
|
301
|
+
]);
|
|
302
|
+
langGraphAgent = langGraphAgentChoice;
|
|
303
|
+
} else if (langGraphAgents.length === 1) {
|
|
304
|
+
langGraphAgent = langGraphAgents[0].graph_id;
|
|
305
|
+
} else {
|
|
306
|
+
throw new Error("No agents found in your LangGraph endpoint");
|
|
307
|
+
}
|
|
308
|
+
newEnvValues += `NEXT_PUBLIC_COPILOTKIT_AGENT_NAME=${langGraphAgent}
|
|
309
|
+
`;
|
|
280
310
|
}
|
|
281
311
|
if (newEnvValues) {
|
|
282
312
|
fs.appendFileSync(envFile, newEnvValues);
|
|
283
|
-
spinner.succeed(chalk("Environment variables configured successfully"));
|
|
284
|
-
} else {
|
|
285
|
-
spinner.info(chalk.yellow("No environment variables were added"));
|
|
286
313
|
}
|
|
287
314
|
} catch (error) {
|
|
288
|
-
spinner.fail(chalk.red("Failed to update environment variables"));
|
|
289
315
|
throw error;
|
|
290
316
|
}
|
|
291
317
|
}
|
|
@@ -295,34 +321,34 @@ import { execSync } from "child_process";
|
|
|
295
321
|
import * as fs2 from "fs";
|
|
296
322
|
import * as path2 from "path";
|
|
297
323
|
import * as os from "os";
|
|
298
|
-
import
|
|
324
|
+
import chalk from "chalk";
|
|
299
325
|
async function cloneGitHubSubdirectory(githubUrl, destinationPath, spinner) {
|
|
300
326
|
try {
|
|
301
327
|
const { owner, repo, branch, subdirectoryPath } = parseGitHubUrl(githubUrl);
|
|
302
|
-
spinner.text =
|
|
328
|
+
spinner.text = chalk.cyan(`Cloning from ${owner}/${repo}...`);
|
|
303
329
|
return await sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner);
|
|
304
330
|
} catch (error) {
|
|
305
|
-
spinner.text =
|
|
331
|
+
spinner.text = chalk.red(`Failed to clone from GitHub: ${error}`);
|
|
306
332
|
return false;
|
|
307
333
|
}
|
|
308
334
|
}
|
|
309
335
|
async function sparseCheckout(owner, repo, branch, subdirectoryPath, destinationPath, spinner) {
|
|
310
336
|
const tempDir = fs2.mkdtempSync(path2.join(os.tmpdir(), "copilotkit-sparse-"));
|
|
311
337
|
try {
|
|
312
|
-
spinner.text =
|
|
338
|
+
spinner.text = chalk.cyan("Creating temporary workspace...");
|
|
313
339
|
execSync("git init", { cwd: tempDir, stdio: "pipe" });
|
|
314
|
-
spinner.text =
|
|
340
|
+
spinner.text = chalk.cyan("Connecting to repository...");
|
|
315
341
|
execSync(`git remote add origin https://github.com/${owner}/${repo}.git`, { cwd: tempDir, stdio: "pipe" });
|
|
316
342
|
execSync("git config core.sparseCheckout true", { cwd: tempDir, stdio: "pipe" });
|
|
317
343
|
fs2.writeFileSync(path2.join(tempDir, ".git/info/sparse-checkout"), subdirectoryPath);
|
|
318
|
-
spinner.text =
|
|
344
|
+
spinner.text = chalk.cyan("Downloading agent files...");
|
|
319
345
|
execSync(`git pull origin ${branch} --depth=1`, { cwd: tempDir, stdio: "pipe" });
|
|
320
346
|
const sourcePath = path2.join(tempDir, subdirectoryPath);
|
|
321
347
|
if (!fs2.existsSync(sourcePath)) {
|
|
322
348
|
throw new Error(`Subdirectory '${subdirectoryPath}' not found in the repository.`);
|
|
323
349
|
}
|
|
324
350
|
fs2.mkdirSync(destinationPath, { recursive: true });
|
|
325
|
-
spinner.text =
|
|
351
|
+
spinner.text = chalk.cyan("Installing agent files...");
|
|
326
352
|
await copyDirectoryAsync(sourcePath, destinationPath);
|
|
327
353
|
return true;
|
|
328
354
|
} finally {
|
|
@@ -381,12 +407,12 @@ function isValidGitHubUrl(url) {
|
|
|
381
407
|
|
|
382
408
|
// src/lib/init/scaffold/packages.ts
|
|
383
409
|
import spawn2 from "cross-spawn";
|
|
384
|
-
import
|
|
410
|
+
import chalk2 from "chalk";
|
|
385
411
|
import fs3 from "fs";
|
|
386
|
-
import
|
|
412
|
+
import ora from "ora";
|
|
387
413
|
async function scaffoldPackages(userAnswers) {
|
|
388
|
-
const spinner =
|
|
389
|
-
text:
|
|
414
|
+
const spinner = ora({
|
|
415
|
+
text: chalk2.cyan("Preparing to install packages..."),
|
|
390
416
|
color: "cyan"
|
|
391
417
|
}).start();
|
|
392
418
|
try {
|
|
@@ -398,9 +424,9 @@ async function scaffoldPackages(userAnswers) {
|
|
|
398
424
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
399
425
|
const packageManager = detectPackageManager();
|
|
400
426
|
const installCommand = detectInstallCommand(packageManager);
|
|
401
|
-
spinner.text =
|
|
427
|
+
spinner.text = chalk2.cyan(`Using ${packageManager} to install packages...`);
|
|
402
428
|
spinner.stop();
|
|
403
|
-
console.log(
|
|
429
|
+
console.log(chalk2.cyan("\n\u2699\uFE0F Installing packages...\n"));
|
|
404
430
|
const result = spawn2.sync(packageManager, [installCommand, ...packages], {
|
|
405
431
|
stdio: "inherit"
|
|
406
432
|
// This ensures stdin/stdout/stderr are all passed through
|
|
@@ -409,12 +435,12 @@ async function scaffoldPackages(userAnswers) {
|
|
|
409
435
|
throw new Error(`Package installation process exited with code ${result.status}`);
|
|
410
436
|
}
|
|
411
437
|
spinner.start();
|
|
412
|
-
spinner.succeed(
|
|
438
|
+
spinner.succeed(chalk2.green("CopilotKit packages installed successfully"));
|
|
413
439
|
} catch (error) {
|
|
414
440
|
if (!spinner.isSpinning) {
|
|
415
441
|
spinner.start();
|
|
416
442
|
}
|
|
417
|
-
spinner.fail(
|
|
443
|
+
spinner.fail(chalk2.red("Failed to install CopilotKit packages"));
|
|
418
444
|
throw error;
|
|
419
445
|
}
|
|
420
446
|
}
|
|
@@ -437,16 +463,16 @@ function detectInstallCommand(packageManager) {
|
|
|
437
463
|
}
|
|
438
464
|
|
|
439
465
|
// src/lib/init/scaffold/agent.ts
|
|
440
|
-
import
|
|
441
|
-
import
|
|
466
|
+
import ora2 from "ora";
|
|
467
|
+
import chalk3 from "chalk";
|
|
442
468
|
import path3 from "path";
|
|
443
469
|
import fs4 from "fs";
|
|
444
470
|
async function scaffoldAgent(userAnswers) {
|
|
445
471
|
if (userAnswers.agentFramework === "None" || userAnswers.agentFramework === "CrewAI" && userAnswers.crewType === "Crews" || userAnswers.agentFramework === "LangGraph" && (!userAnswers.langGraphAgent || userAnswers.langGraphAgent === "None")) {
|
|
446
472
|
return;
|
|
447
473
|
}
|
|
448
|
-
const spinner =
|
|
449
|
-
text:
|
|
474
|
+
const spinner = ora2({
|
|
475
|
+
text: chalk3.cyan("Setting up AI agent..."),
|
|
450
476
|
color: "cyan"
|
|
451
477
|
}).start();
|
|
452
478
|
let template = "";
|
|
@@ -465,7 +491,7 @@ async function scaffoldAgent(userAnswers) {
|
|
|
465
491
|
break;
|
|
466
492
|
}
|
|
467
493
|
if (!template) {
|
|
468
|
-
spinner.fail(
|
|
494
|
+
spinner.fail(chalk3.red("Failed to determine agent template"));
|
|
469
495
|
throw new Error("Failed to determine agent template");
|
|
470
496
|
}
|
|
471
497
|
const agentDir = path3.join(process.cwd(), "agent");
|
|
@@ -475,7 +501,7 @@ async function scaffoldAgent(userAnswers) {
|
|
|
475
501
|
agentDir,
|
|
476
502
|
spinner
|
|
477
503
|
);
|
|
478
|
-
spinner.text =
|
|
504
|
+
spinner.text = chalk3.cyan("Creating agent environment variables...");
|
|
479
505
|
let envContent = "";
|
|
480
506
|
if (userAnswers.llmToken) {
|
|
481
507
|
envContent += `OPENAI_API_KEY=${userAnswers.llmToken}
|
|
@@ -488,10 +514,10 @@ async function scaffoldAgent(userAnswers) {
|
|
|
488
514
|
if (envContent) {
|
|
489
515
|
const agentEnvFile = path3.join(agentDir, ".env");
|
|
490
516
|
fs4.writeFileSync(agentEnvFile, envContent, "utf8");
|
|
491
|
-
spinner.text =
|
|
517
|
+
spinner.text = chalk3.cyan("Added API keys to agent .env file");
|
|
492
518
|
}
|
|
493
519
|
} catch (error) {
|
|
494
|
-
spinner.fail(
|
|
520
|
+
spinner.fail(chalk3.red("Failed to clone agent template"));
|
|
495
521
|
throw error;
|
|
496
522
|
}
|
|
497
523
|
spinner.succeed(`${userAnswers.agentFramework} agent cloned successfully`);
|
|
@@ -499,8 +525,8 @@ async function scaffoldAgent(userAnswers) {
|
|
|
499
525
|
var AgentTemplates = {
|
|
500
526
|
LangGraph: {
|
|
501
527
|
Starter: {
|
|
502
|
-
Python: "https://github.com/CopilotKit/
|
|
503
|
-
TypeScript: "https://github.com/CopilotKit/
|
|
528
|
+
Python: "https://github.com/CopilotKit/coagents-starter-langgraph/tree/main/agent-py",
|
|
529
|
+
TypeScript: "https://github.com/CopilotKit/coagents-starter-langgraph/tree/main/agent-js"
|
|
504
530
|
}
|
|
505
531
|
},
|
|
506
532
|
CrewAI: {
|
|
@@ -512,11 +538,11 @@ var AgentTemplates = {
|
|
|
512
538
|
|
|
513
539
|
// src/lib/init/scaffold/crew-inputs.ts
|
|
514
540
|
import * as fs5 from "fs/promises";
|
|
515
|
-
import
|
|
541
|
+
import ora3 from "ora";
|
|
516
542
|
import * as path4 from "path";
|
|
517
543
|
async function addCrewInputs(url, token) {
|
|
518
544
|
try {
|
|
519
|
-
const spinner =
|
|
545
|
+
const spinner = ora3("Analyzing crew inputs...").start();
|
|
520
546
|
const inputs = await getCrewInputs(url, token);
|
|
521
547
|
spinner.text = "Adding inputs to app/copilotkit/page.tsx...";
|
|
522
548
|
let filePath = path4.join(process.cwd(), "app", "copilotkit", "page.tsx");
|