Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Show resolvable url in error message (#596)
r33drichards56ca5e0b8b89
diff --git a/.changeset/sweet-geese-yell.md b/.changeset/sweet-geese-yell.mdnew file mode 100644index 000000000..d1db1982a--- /dev/null+++ b/.changeset/sweet-geese-yell.md@@ -0,0 +1,5 @@+---+'@e2b/cli': patch+---++Before the urls in our error messages pointed to a doc page that doesn't exist. This change updates the urls with links that resolve to dashboarddiff --git a/DEV.md b/DEV.mdnew file mode 100644index 000000000..277560c6f--- /dev/null+++ b/DEV.md@@ -0,0 +1,3 @@+# Releasing e2b cli++to create a changeset run `npx changeset`\ No newline at end of filediff --git a/packages/cli/src/api.ts b/packages/cli/src/api.tsindex 6865992f1..ca5deb12c 100644--- a/packages/cli/src/api.ts+++ b/packages/cli/src/api.ts@@ -7,24 +7,40 @@ import { asBold, asPrimary } from './utils/format'export let apiKey = process.env.E2B_API_KEYexport let accessToken = process.env.E2B_ACCESS_TOKEN-const authErrorBox =(keyName: string) => boxen.default(- `You must be logged in to use this command. Run ${asBold('e2b auth login')}.+const authErrorBox = (keyName: string) => {+ let link+ let msg+ switch (keyName) {+ case 'E2B_API_KEY':+ link = 'https://e2b.dev/dashboard?tab=keys'+ msg = 'API key'-If you are seeing this message in CI/CD you may need to set the ${asBold(- `${keyName}`- )} environment variable.-Visit ${asPrimary(- 'https://e2b.dev/docs/getting-started/api-key'- )} to get the access token.`,- {- width: 70,- float: 'center',- padding: 0.5,- margin: 1,- borderStyle: 'round',- borderColor: 'redBright',+ case 'E2B_ACCESS_TOKEN':+ link = 'https://e2b.dev/dashboard?tab=personal'+ msg = 'access token'+ }+ // throwing error in default in switch statement results in unreachable code,+ // so we need to check if link and msg are defined here instead+ if (!link || !msg) {+ throw new Error(`Unknown key name: ${keyName}`)}-)+ return boxen.default(+ `You must be logged in to use this command. Run ${asBold('e2b auth login')}.++If you are seeing this message in CI/CD you may need to set the ${asBold(+ `${keyName}`+ )} environment variable.+Visit ${asPrimary(link)} to get the ${msg}.`,+ {+ width: 70,+ float: 'center',+ padding: 0.5,+ margin: 1,+ borderStyle: 'round',+ borderColor: 'redBright',+ }+ )+}export function ensureAPIKey() {// If apiKey is not already set (either from env var or from user config), try to get it from config file