copilotkit 0.0.12 → 0.0.14
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/README.md +28 -1
- package/dist/commands/base-command.js +1 -1
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/dev.js +42 -22
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/init.d.ts +36 -0
- package/dist/commands/init.js +856 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.js +13 -6
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +13 -6
- package/dist/commands/logout.js.map +1 -1
- package/dist/lib/init/index.d.ts +9 -0
- package/dist/lib/init/index.js +441 -0
- package/dist/lib/init/index.js.map +1 -0
- package/dist/lib/init/questions.d.ts +6 -0
- package/dist/lib/init/questions.js +133 -0
- package/dist/lib/init/questions.js.map +1 -0
- package/dist/lib/init/scaffold/env.d.ts +6 -0
- package/dist/lib/init/scaffold/env.js +68 -0
- package/dist/lib/init/scaffold/env.js.map +1 -0
- package/dist/lib/init/scaffold/github.d.ts +20 -0
- package/dist/lib/init/scaffold/github.js +138 -0
- package/dist/lib/init/scaffold/github.js.map +1 -0
- package/dist/lib/init/scaffold/index.d.ts +7 -0
- package/dist/lib/init/scaffold/index.js +339 -0
- package/dist/lib/init/scaffold/index.js.map +1 -0
- package/dist/lib/init/scaffold/packages.d.ts +6 -0
- package/dist/lib/init/scaffold/packages.js +60 -0
- package/dist/lib/init/scaffold/packages.js.map +1 -0
- package/dist/lib/init/scaffold/shadcn.d.ts +6 -0
- package/dist/lib/init/scaffold/shadcn.js +79 -0
- package/dist/lib/init/scaffold/shadcn.js.map +1 -0
- package/dist/lib/init/types/index.d.ts +3 -0
- package/dist/lib/init/types/index.js +41 -0
- package/dist/lib/init/types/index.js.map +1 -0
- package/dist/lib/init/types/questions.d.ts +55 -0
- package/dist/lib/init/types/questions.js +28 -0
- package/dist/lib/init/types/questions.js.map +1 -0
- package/dist/lib/init/types/templates.d.ts +6 -0
- package/dist/lib/init/types/templates.js +15 -0
- package/dist/lib/init/types/templates.js.map +1 -0
- package/dist/services/analytics.service.d.ts +1 -1
- package/dist/services/analytics.service.js +9 -2
- package/dist/services/analytics.service.js.map +1 -1
- package/dist/services/auth.service.js +12 -5
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/events.d.ts +11 -8
- package/dist/utils/detect-endpoint-type.utils.d.ts +2 -1
- package/dist/utils/detect-endpoint-type.utils.js +27 -13
- package/dist/utils/detect-endpoint-type.utils.js.map +1 -1
- package/dist/utils/trpc.d.ts +64 -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 +158 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts"],"sourcesContent":["// @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 cmd.log(`🪁 Logged in as ${chalk.hex('#7553fc')(loginResult.user.email)}\\n`)\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((resolve) => {\n const server = app.listen(port, () => {})\n\n 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 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`)\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 createTRPClient_, unstable_httpBatchStreamLink} from '@trpc/client'\nimport type {CLIRouter} from '@repo/trpc-cli/cli-router'\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) {\n return createTRPClient_<CLIRouter>({\n links: [\n unstable_httpBatchStreamLink({\n transformer: superjson,\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n headers: () => {\n const headers = new Headers()\n headers.set('x-trpc-source', 'cli')\n headers.set('x-cli-token', cliToken)\n return headers\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 ): void {\n if (!this.segment) {\n return;\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 this.segment.track(payload)\n }\n}\n"],"mappings":";AACA,OAAOA,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,kBAAkB,oCAAmC;AAEjF,OAAO,eAAe;AAEf,IAAM,yBAAyB,QAAQ,IAAI,0BAA0B;AAErE,SAAS,iBAAiB,UAAkB;AACjD,SAAO,iBAA4B;AAAA,IACjC,OAAO;AAAA,MACL,6BAA6B;AAAA,QAC3B,aAAa;AAAA,QACb,KAAK,GAAG,sBAAsB;AAAA,QAC9B,SAAS,MAAM;AACb,gBAAM,UAAU,IAAI,QAAQ;AAC5B,kBAAQ,IAAI,iBAAiB,KAAK;AAClC,kBAAQ,IAAI,eAAe,QAAQ;AACnC,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAA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UAAU,MAAM,aAAY,IAAI,IAAI;AAE3C,oBAAY,IAAI,iBAAiB,EAAC,QAAQ,KAAK,IAAI,gBAAgB,aAAa,IAAI,OAAO,KAAK,MAAK,CAAC;AACtG,kBAAU,MAAM;AAAA,UACd,OAAO;AAAA,UACP,YAAY;AAAA,YACV,gBAAgB,aAAa;AAAA,YAC7B,QAAQ,KAAK;AAAA,YACb,OAAO,KAAK;AAAA,UACd;AAAA,QACF,CAAC;AAED,YAAI,UAAU,IAAI,MAAM,OAAO;AAC7B,cAAI,OAAO,GAAG,EAAE,KAAK,EAAC,SAAS,gBAAe,CAAC;AAC/C,kBAAQ,KAAK,eAAe;AAC5B;AAAA,QACF;AAEA,aAAK,OAAO,IAAI,YAAY,QAAQ;AACpC,YAAI,OAAO,GAAG,EAAE,KAAK,EAAC,SAAS,kBAAiB,CAAC;AACjD,gBAAQ,QAAQ,uCAAgC,MAAM,IAAI,SAAS,EAAE,KAAK,KAAK,CAAC;AAAA,CAAI;AACpF,YAAI,gBAAgB;AAClB,kBAAQ,KAAK,CAAC;AAAA,QAChB,OAAO;AACL,iBAAO,MAAM;AACb,kBAAQ,EAAC,UAAU,MAAM,aAAY,CAAC;AAAA,QACxC;AAAA,MACF,CAAC;AAED,WAAK,GAAG,KAAK,sBAAsB,0CAA0C,IAAI,mBAAmB,KAAK,EAAE;AAAA,IAC7G,CAAC;AAAA,EACH;AACF;","names":["Conf","crypto","anonymousId","Conf","crypto"]}
|
|
1
|
+
{"version":3,"sources":["../../src/services/auth.service.ts","../../src/utils/trpc.ts","../../src/services/analytics.service.ts"],"sourcesContent":["// @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 cmd.log(`🪁 Logged in as ${chalk.hex('#7553fc')(loginResult.user.email)}\\n`)\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`)\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 createTRPClient_, unstable_httpBatchStreamLink} from '@trpc/client'\nimport type {CLIRouter} from '@repo/trpc-cli/cli-router'\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) {\n return createTRPClient_<CLIRouter>({\n links: [\n unstable_httpBatchStreamLink({\n transformer: superjson,\n url: `${COPILOT_CLOUD_BASE_URL}/api/trpc-cli`,\n headers: () => {\n const headers = new Headers()\n headers.set('x-trpc-source', 'cli')\n headers.set('x-cli-token', cliToken)\n return headers\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"],"mappings":";AACA,OAAOA,WAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAOC,aA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AAgC,MAAM,IAAI,SAAS,EAAE,KAAK,KAAK,CAAC;AAAA,CAAI;AACpF,YAAI,gBAAgB;AAClB,kBAAQ,KAAK,CAAC;AAAA,QAChB,OAAO;AACL,iBAAO,MAAM;AACb,kBAAQ,EAAC,UAAU,MAAM,aAAY,CAAC;AAAA,QACxC;AAAA,MACF,CAAC;AAED,WAAK,GAAG,KAAK,sBAAsB,0CAA0C,IAAI,mBAAmB,KAAK,EAAE;AAAA,IAC7G,CAAC;AAAA,EACH;AACF;","names":["Conf","crypto","anonymousId","Conf","crypto"]}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import { RemoteEndpointType } from '../utils/detect-endpoint-type.utils.js';
|
|
2
2
|
|
|
3
3
|
type AnalyticsEvents = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
'cli.login.initiated': {};
|
|
5
|
+
'cli.login.success': {
|
|
6
6
|
organizationId: string;
|
|
7
7
|
userId: string;
|
|
8
8
|
email: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
'cli.logout': {
|
|
11
11
|
organizationId: string;
|
|
12
12
|
userId: string;
|
|
13
13
|
email: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
'cli.dev.initiatied': {
|
|
16
16
|
port: string;
|
|
17
17
|
projectId: string;
|
|
18
|
-
endpointType: RemoteEndpointType.LangGraphPlatform | RemoteEndpointType.CopilotKit;
|
|
18
|
+
endpointType: RemoteEndpointType.LangGraphPlatform | RemoteEndpointType.CopilotKit | RemoteEndpointType.CrewAI;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
'cli.dev.tunnel.created': {
|
|
21
21
|
tunnelId: string;
|
|
22
22
|
port: string;
|
|
23
23
|
projectId: string;
|
|
24
|
-
endpointType: RemoteEndpointType.LangGraphPlatform | RemoteEndpointType.CopilotKit;
|
|
24
|
+
endpointType: RemoteEndpointType.LangGraphPlatform | RemoteEndpointType.CopilotKit | RemoteEndpointType.CrewAI;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
'cli.dev.tunnel.closed': {
|
|
27
27
|
tunnelId: string;
|
|
28
28
|
};
|
|
29
|
+
'cli.init.cloud_used': {
|
|
30
|
+
userId: string;
|
|
31
|
+
};
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
export type { AnalyticsEvents };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare enum RemoteEndpointType {
|
|
2
2
|
LangGraphPlatform = "LangGraphPlatform",
|
|
3
3
|
CopilotKit = "CopilotKit",
|
|
4
|
+
CrewAI = "CrewAI",
|
|
4
5
|
Invalid = "Invalid"
|
|
5
6
|
}
|
|
6
|
-
declare const getHumanReadableEndpointType: (type: RemoteEndpointType) => "CopilotKit" | "
|
|
7
|
+
declare const getHumanReadableEndpointType: (type: RemoteEndpointType) => "CopilotKit" | "CrewAI" | "Invalid" | "LangGraph Platform";
|
|
7
8
|
declare function detectRemoteEndpointType(url: string): Promise<{
|
|
8
9
|
url: string;
|
|
9
10
|
type: RemoteEndpointType;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var RemoteEndpointType = /* @__PURE__ */ ((RemoteEndpointType2) => {
|
|
3
3
|
RemoteEndpointType2["LangGraphPlatform"] = "LangGraphPlatform";
|
|
4
4
|
RemoteEndpointType2["CopilotKit"] = "CopilotKit";
|
|
5
|
+
RemoteEndpointType2["CrewAI"] = "CrewAI";
|
|
5
6
|
RemoteEndpointType2["Invalid"] = "Invalid";
|
|
6
7
|
return RemoteEndpointType2;
|
|
7
8
|
})(RemoteEndpointType || {});
|
|
@@ -12,40 +13,50 @@ var getHumanReadableEndpointType = (type) => {
|
|
|
12
13
|
return "LangGraph Platform";
|
|
13
14
|
case "CopilotKit" /* CopilotKit */:
|
|
14
15
|
return "CopilotKit";
|
|
16
|
+
case "CrewAI" /* CrewAI */:
|
|
17
|
+
return "CrewAI";
|
|
15
18
|
default:
|
|
16
19
|
return "Invalid";
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
async function detectRemoteEndpointType(url) {
|
|
20
|
-
const
|
|
23
|
+
const [isLangGraph, isCopilot, isCrewAI] = await Promise.all([
|
|
21
24
|
isLangGraphPlatformEndpoint(url),
|
|
22
|
-
isCopilotKitEndpoint(url)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const results = await Promise.all(promises);
|
|
28
|
-
if (results[0]) {
|
|
25
|
+
isCopilotKitEndpoint(url),
|
|
26
|
+
isCrewAIEndpoint(url)
|
|
27
|
+
]);
|
|
28
|
+
if (isLangGraph) {
|
|
29
29
|
return {
|
|
30
30
|
url,
|
|
31
31
|
type: "LangGraphPlatform" /* LangGraphPlatform */,
|
|
32
32
|
humanReadableType: "LangGraph Platform"
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
35
|
+
if (isCopilot) {
|
|
36
36
|
return {
|
|
37
37
|
url,
|
|
38
38
|
type: "CopilotKit" /* CopilotKit */,
|
|
39
39
|
humanReadableType: "CopilotKit"
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
42
|
+
if (isCrewAI) {
|
|
43
43
|
return {
|
|
44
|
-
url
|
|
45
|
-
type: "
|
|
46
|
-
humanReadableType: "
|
|
44
|
+
url,
|
|
45
|
+
type: "CrewAI" /* CrewAI */,
|
|
46
|
+
humanReadableType: "CrewAI"
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
+
if (!url.endsWith("/copilotkit")) {
|
|
50
|
+
const copilotKitUrl = `${removeTrailingSlash(url)}/copilotkit`;
|
|
51
|
+
const isCopilotWithPath = await isCopilotKitEndpoint(copilotKitUrl);
|
|
52
|
+
if (isCopilotWithPath) {
|
|
53
|
+
return {
|
|
54
|
+
url: copilotKitUrl,
|
|
55
|
+
type: "CopilotKit" /* CopilotKit */,
|
|
56
|
+
humanReadableType: "CopilotKit"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
49
60
|
return {
|
|
50
61
|
url,
|
|
51
62
|
type: "Invalid" /* Invalid */,
|
|
@@ -109,6 +120,9 @@ async function isCopilotKitEndpoint(url, retries = 0) {
|
|
|
109
120
|
}
|
|
110
121
|
return false;
|
|
111
122
|
}
|
|
123
|
+
async function isCrewAIEndpoint(url) {
|
|
124
|
+
return url.toLowerCase().includes("crew");
|
|
125
|
+
}
|
|
112
126
|
export {
|
|
113
127
|
RemoteEndpointType,
|
|
114
128
|
detectRemoteEndpointType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/detect-endpoint-type.utils.ts"],"sourcesContent":["export enum RemoteEndpointType {\n LangGraphPlatform = 'LangGraphPlatform',\n CopilotKit = 'CopilotKit',\n Invalid = 'Invalid',\n}\n\nconst removeTrailingSlash = (url: string) => url.replace(/\\/$/, '')
|
|
1
|
+
{"version":3,"sources":["../../src/utils/detect-endpoint-type.utils.ts"],"sourcesContent":["export enum RemoteEndpointType {\n LangGraphPlatform = 'LangGraphPlatform',\n CopilotKit = 'CopilotKit',\n CrewAI = 'CrewAI',\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 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] = await Promise.all([\n isLangGraphPlatformEndpoint(url),\n isCopilotKitEndpoint(url),\n isCrewAIEndpoint(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"],"mappings":";AAAO,IAAK,qBAAL,kBAAKA,wBAAL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SAAS,MAAM;AAC1C;","names":["RemoteEndpointType"]}
|
package/dist/utils/trpc.d.ts
CHANGED
|
@@ -28,10 +28,10 @@ declare function createTRPCClient(cliToken: string): {
|
|
|
28
28
|
reportRemoteEndpointLocalTunnel: {
|
|
29
29
|
mutate: _trpc_client.Resolver<{
|
|
30
30
|
input: {
|
|
31
|
-
port: number;
|
|
32
31
|
tunnelId: string;
|
|
33
32
|
projectId: string;
|
|
34
33
|
tunnelUrl: string;
|
|
34
|
+
port: number;
|
|
35
35
|
endpointType?: any;
|
|
36
36
|
};
|
|
37
37
|
output: {
|
|
@@ -134,6 +134,69 @@ declare function createTRPCClient(cliToken: string): {
|
|
|
134
134
|
transformer: true;
|
|
135
135
|
}>;
|
|
136
136
|
};
|
|
137
|
+
createRemoteEndpoint: {
|
|
138
|
+
mutate: _trpc_client.Resolver<{
|
|
139
|
+
input: {
|
|
140
|
+
projectId: string;
|
|
141
|
+
config: {
|
|
142
|
+
[x: string]: any;
|
|
143
|
+
url?: unknown;
|
|
144
|
+
metadata?: unknown;
|
|
145
|
+
type?: unknown;
|
|
146
|
+
} | {
|
|
147
|
+
[x: string]: any;
|
|
148
|
+
url?: unknown;
|
|
149
|
+
metadata?: unknown;
|
|
150
|
+
apiKey?: unknown;
|
|
151
|
+
type?: unknown;
|
|
152
|
+
} | {
|
|
153
|
+
[x: string]: any;
|
|
154
|
+
url?: unknown;
|
|
155
|
+
metadata?: unknown;
|
|
156
|
+
agentName?: unknown;
|
|
157
|
+
agentDescription?: unknown;
|
|
158
|
+
crewApiBearerToken?: unknown;
|
|
159
|
+
type?: unknown;
|
|
160
|
+
};
|
|
161
|
+
type?: any;
|
|
162
|
+
schemaVersion?: number | undefined;
|
|
163
|
+
localTunnel?: string | undefined;
|
|
164
|
+
};
|
|
165
|
+
output: void;
|
|
166
|
+
errorShape: {
|
|
167
|
+
data: {
|
|
168
|
+
zodError: zod.typeToFlattenedError<any, string> | null;
|
|
169
|
+
code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
|
|
170
|
+
httpStatus: number;
|
|
171
|
+
path?: string | undefined;
|
|
172
|
+
stack?: string | undefined;
|
|
173
|
+
};
|
|
174
|
+
message: string;
|
|
175
|
+
code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER;
|
|
176
|
+
};
|
|
177
|
+
transformer: true;
|
|
178
|
+
}>;
|
|
179
|
+
};
|
|
180
|
+
getCopilotCloudPublicApiKey: {
|
|
181
|
+
query: _trpc_client.Resolver<{
|
|
182
|
+
input: {
|
|
183
|
+
projectId: string;
|
|
184
|
+
};
|
|
185
|
+
output: any;
|
|
186
|
+
errorShape: {
|
|
187
|
+
data: {
|
|
188
|
+
zodError: zod.typeToFlattenedError<any, string> | null;
|
|
189
|
+
code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
|
|
190
|
+
httpStatus: number;
|
|
191
|
+
path?: string | undefined;
|
|
192
|
+
stack?: string | undefined;
|
|
193
|
+
};
|
|
194
|
+
message: string;
|
|
195
|
+
code: _trpc_server_unstable_core_do_not_import.TRPC_ERROR_CODE_NUMBER;
|
|
196
|
+
};
|
|
197
|
+
transformer: true;
|
|
198
|
+
}>;
|
|
199
|
+
};
|
|
137
200
|
};
|
|
138
201
|
|
|
139
202
|
export { COPILOT_CLOUD_BASE_URL, createTRPCClient };
|
package/dist/utils/version.d.ts
CHANGED
package/dist/utils/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/version.ts"],"sourcesContent":["// This is auto generated!\nexport const LIB_VERSION = \"0.0.
|
|
1
|
+
{"version":3,"sources":["../../src/utils/version.ts"],"sourcesContent":["// This is auto generated!\nexport const LIB_VERSION = \"0.0.14\";\n"],"mappings":";AACO,IAAM,cAAc;","names":[]}
|
package/oclif.manifest.json
CHANGED
|
@@ -57,6 +57,163 @@
|
|
|
57
57
|
"dev.js"
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
|
+
"init": {
|
|
61
|
+
"aliases": [],
|
|
62
|
+
"args": {},
|
|
63
|
+
"description": "Set up CopilotKit in your Next.js project",
|
|
64
|
+
"examples": [
|
|
65
|
+
"<%= config.bin %> init"
|
|
66
|
+
],
|
|
67
|
+
"flags": {
|
|
68
|
+
"copilotKitVersion": {
|
|
69
|
+
"description": "CopilotKit version to use (e.g. 1.7.0)",
|
|
70
|
+
"name": "copilotKitVersion",
|
|
71
|
+
"hasDynamicHelp": false,
|
|
72
|
+
"multiple": false,
|
|
73
|
+
"type": "option"
|
|
74
|
+
},
|
|
75
|
+
"agentFramework": {
|
|
76
|
+
"description": "Agent framework to power your copilot",
|
|
77
|
+
"name": "agentFramework",
|
|
78
|
+
"hasDynamicHelp": false,
|
|
79
|
+
"multiple": false,
|
|
80
|
+
"options": [
|
|
81
|
+
"CrewAI",
|
|
82
|
+
"LangGraph",
|
|
83
|
+
"None"
|
|
84
|
+
],
|
|
85
|
+
"type": "option"
|
|
86
|
+
},
|
|
87
|
+
"fastApiEnabled": {
|
|
88
|
+
"description": "Use FastAPI to serve your agent locally",
|
|
89
|
+
"name": "fastApiEnabled",
|
|
90
|
+
"hasDynamicHelp": false,
|
|
91
|
+
"multiple": false,
|
|
92
|
+
"options": [
|
|
93
|
+
"Yes",
|
|
94
|
+
"No"
|
|
95
|
+
],
|
|
96
|
+
"type": "option"
|
|
97
|
+
},
|
|
98
|
+
"useCopilotCloud": {
|
|
99
|
+
"description": "Use Copilot Cloud for production-ready hosting",
|
|
100
|
+
"name": "useCopilotCloud",
|
|
101
|
+
"hasDynamicHelp": false,
|
|
102
|
+
"multiple": false,
|
|
103
|
+
"options": [
|
|
104
|
+
"Yes",
|
|
105
|
+
"No"
|
|
106
|
+
],
|
|
107
|
+
"type": "option"
|
|
108
|
+
},
|
|
109
|
+
"chatUi": {
|
|
110
|
+
"description": "Chat UI component to add to your app",
|
|
111
|
+
"name": "chatUi",
|
|
112
|
+
"hasDynamicHelp": false,
|
|
113
|
+
"multiple": false,
|
|
114
|
+
"options": [
|
|
115
|
+
"CopilotChat",
|
|
116
|
+
"CopilotSidebar",
|
|
117
|
+
"Headless",
|
|
118
|
+
"CopilotPopup"
|
|
119
|
+
],
|
|
120
|
+
"type": "option"
|
|
121
|
+
},
|
|
122
|
+
"langGraphAgent": {
|
|
123
|
+
"description": "LangGraph agent template to use",
|
|
124
|
+
"name": "langGraphAgent",
|
|
125
|
+
"hasDynamicHelp": false,
|
|
126
|
+
"multiple": false,
|
|
127
|
+
"options": [
|
|
128
|
+
"Python Starter",
|
|
129
|
+
"TypeScript Starter",
|
|
130
|
+
"None"
|
|
131
|
+
],
|
|
132
|
+
"type": "option"
|
|
133
|
+
},
|
|
134
|
+
"crewType": {
|
|
135
|
+
"description": "CrewAI implementation type",
|
|
136
|
+
"name": "crewType",
|
|
137
|
+
"hasDynamicHelp": false,
|
|
138
|
+
"multiple": false,
|
|
139
|
+
"options": [
|
|
140
|
+
"Crews",
|
|
141
|
+
"Flows"
|
|
142
|
+
],
|
|
143
|
+
"type": "option"
|
|
144
|
+
},
|
|
145
|
+
"crewName": {
|
|
146
|
+
"description": "Name for your CrewAI agent",
|
|
147
|
+
"name": "crewName",
|
|
148
|
+
"hasDynamicHelp": false,
|
|
149
|
+
"multiple": false,
|
|
150
|
+
"type": "option"
|
|
151
|
+
},
|
|
152
|
+
"crewUrl": {
|
|
153
|
+
"description": "URL endpoint for your CrewAI agent",
|
|
154
|
+
"name": "crewUrl",
|
|
155
|
+
"hasDynamicHelp": false,
|
|
156
|
+
"multiple": false,
|
|
157
|
+
"type": "option"
|
|
158
|
+
},
|
|
159
|
+
"crewBearerToken": {
|
|
160
|
+
"description": "Bearer token for CrewAI authentication",
|
|
161
|
+
"name": "crewBearerToken",
|
|
162
|
+
"hasDynamicHelp": false,
|
|
163
|
+
"multiple": false,
|
|
164
|
+
"type": "option"
|
|
165
|
+
},
|
|
166
|
+
"langSmithApiKey": {
|
|
167
|
+
"description": "LangSmith API key for LangGraph observability",
|
|
168
|
+
"name": "langSmithApiKey",
|
|
169
|
+
"hasDynamicHelp": false,
|
|
170
|
+
"multiple": false,
|
|
171
|
+
"type": "option"
|
|
172
|
+
},
|
|
173
|
+
"llmToken": {
|
|
174
|
+
"description": "API key for your preferred LLM provider",
|
|
175
|
+
"name": "llmToken",
|
|
176
|
+
"hasDynamicHelp": false,
|
|
177
|
+
"multiple": false,
|
|
178
|
+
"type": "option"
|
|
179
|
+
},
|
|
180
|
+
"runtimeUrl": {
|
|
181
|
+
"description": "runtime URL",
|
|
182
|
+
"name": "runtimeUrl",
|
|
183
|
+
"hasDynamicHelp": false,
|
|
184
|
+
"multiple": false,
|
|
185
|
+
"type": "option"
|
|
186
|
+
},
|
|
187
|
+
"project": {
|
|
188
|
+
"description": "project ID (can be found in the Copilot Cloud dashboard)",
|
|
189
|
+
"name": "project",
|
|
190
|
+
"hasDynamicHelp": false,
|
|
191
|
+
"multiple": false,
|
|
192
|
+
"type": "option"
|
|
193
|
+
},
|
|
194
|
+
"dir": {
|
|
195
|
+
"description": "directory of the Next.js project",
|
|
196
|
+
"name": "dir",
|
|
197
|
+
"default": ".",
|
|
198
|
+
"hasDynamicHelp": false,
|
|
199
|
+
"multiple": false,
|
|
200
|
+
"type": "option"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"hasDynamicHelp": false,
|
|
204
|
+
"hiddenAliases": [],
|
|
205
|
+
"id": "init",
|
|
206
|
+
"pluginAlias": "copilotkit",
|
|
207
|
+
"pluginName": "copilotkit",
|
|
208
|
+
"pluginType": "core",
|
|
209
|
+
"strict": true,
|
|
210
|
+
"isESM": true,
|
|
211
|
+
"relativePath": [
|
|
212
|
+
"dist",
|
|
213
|
+
"commands",
|
|
214
|
+
"init.js"
|
|
215
|
+
]
|
|
216
|
+
},
|
|
60
217
|
"login": {
|
|
61
218
|
"aliases": [],
|
|
62
219
|
"args": {},
|
|
@@ -102,5 +259,5 @@
|
|
|
102
259
|
]
|
|
103
260
|
}
|
|
104
261
|
},
|
|
105
|
-
"version": "0.0.
|
|
262
|
+
"version": "0.0.14"
|
|
106
263
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copilotkit",
|
|
3
3
|
"description": "CopilotKit CLI",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"author": "CopilotKit",
|
|
6
6
|
"bin": {
|
|
7
7
|
"copilotkit": "./bin/run.js",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"chalk": "^5.3.0",
|
|
34
34
|
"conf": "^13.1.0",
|
|
35
35
|
"cors": "^2.8.5",
|
|
36
|
+
"cross-spawn": "^7.0.6",
|
|
36
37
|
"express": "^4.21.2",
|
|
37
38
|
"get-port": "^7.1.0",
|
|
38
39
|
"inquirer": "^12.3.0",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"@oclif/test": "^4",
|
|
48
49
|
"@types/chai": "^4.3.20",
|
|
49
50
|
"@types/cors": "^2.8.17",
|
|
51
|
+
"@types/cross-spawn": "^6.0.6",
|
|
50
52
|
"@types/express": "^5.0.0",
|
|
51
53
|
"@types/localtunnel": "^2.0.4",
|
|
52
54
|
"@types/mocha": "^10",
|