@levelcode/sdk 0.0.3 → 0.0.5

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/CHANGELOG.md CHANGED
@@ -49,7 +49,7 @@ Types updates.
49
49
 
50
50
  ### Added
51
51
 
52
- - You can now get an API key from the [LevelCode website](https://www.levelcode.com/profile?tab=api-keys)!
52
+ - You can now get an API key from the [LevelCode website](https://www.levelcode.vercel.app/profile?tab=api-keys)!
53
53
  - You can provide your own custom tools!
54
54
 
55
55
  ### Updated
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install @levelcode/sdk
10
10
 
11
11
  ## Prerequisites
12
12
 
13
- - Create a LevelCode account and get your [LevelCode API key here](https://www.levelcode.com/api-keys).
13
+ - Create a LevelCode account and get your [LevelCode API key here](https://www.levelcode.vercel.app/api-keys).
14
14
 
15
15
  ## Usage
16
16
 
@@ -22,14 +22,14 @@ import { LevelCodeClient } from '@levelcode/sdk'
22
22
  async function main() {
23
23
  const client = new LevelCodeClient({
24
24
  // You need to pass in your own API key here.
25
- // Get one here: https://www.levelcode.com/api-keys
25
+ // Get one here: https://www.levelcode.vercel.app/api-keys
26
26
  apiKey: process.env.LEVELCODE_API_KEY,
27
27
  cwd: process.cwd(),
28
28
  })
29
29
 
30
30
  // First run
31
31
  const runState1 = await client.run({
32
- // The agent id. Any agent on the store (https://levelcode.com/store)
32
+ // The agent id. Any agent on the store (https://levelcode.vercel.app/store)
33
33
  agent: 'levelcode/base@0.0.16',
34
34
  prompt: 'Create a simple calculator class',
35
35
  handleEvent: (event) => {
@@ -66,7 +66,7 @@ import type { AgentDefinition } from '@levelcode/sdk'
66
66
  async function main() {
67
67
  const client = new LevelCodeClient({
68
68
  // Note: You need to pass in your own API key.
69
- // Get it here: https://www.levelcode.com/profile?tab=api-keys
69
+ // Get it here: https://www.levelcode.vercel.app/profile?tab=api-keys
70
70
  apiKey: process.env.LEVELCODE_API_KEY,
71
71
  // Optional directory agent runs from (if applicable).
72
72
  cwd: process.cwd(),
package/dist/index.cjs CHANGED
@@ -13162,7 +13162,7 @@ var import_path12 = __toESM(require("path"));
13162
13162
  var import_v4 = __toESM(require("zod/v4"));
13163
13163
  var clientEnvSchema = import_v4.default.object({
13164
13164
  NEXT_PUBLIC_CB_ENVIRONMENT: import_v4.default.enum(["dev", "test", "prod"]).default("prod"),
13165
- NEXT_PUBLIC_LEVELCODE_APP_URL: import_v4.default.string().default(""),
13165
+ NEXT_PUBLIC_LEVELCODE_APP_URL: import_v4.default.string().default("https://levelcode.vercel.app"),
13166
13166
  NEXT_PUBLIC_SUPPORT_EMAIL: import_v4.default.string().default("support@levelcode.ai"),
13167
13167
  NEXT_PUBLIC_POSTHOG_API_KEY: import_v4.default.string().default(""),
13168
13168
  NEXT_PUBLIC_POSTHOG_HOST_URL: import_v4.default.string().default("https://app.posthog.com"),
@@ -13188,7 +13188,7 @@ var clientProcessEnv = {
13188
13188
  var parsedEnv = clientEnvSchema.safeParse(clientProcessEnv);
13189
13189
  var fallbackEnv = {
13190
13190
  NEXT_PUBLIC_CB_ENVIRONMENT: "prod",
13191
- NEXT_PUBLIC_LEVELCODE_APP_URL: "",
13191
+ NEXT_PUBLIC_LEVELCODE_APP_URL: "https://levelcode.vercel.app",
13192
13192
  NEXT_PUBLIC_SUPPORT_EMAIL: "support@levelcode.ai",
13193
13193
  NEXT_PUBLIC_POSTHOG_API_KEY: "",
13194
13194
  NEXT_PUBLIC_POSTHOG_HOST_URL: "https://app.posthog.com",
@@ -19687,7 +19687,7 @@ When the user requests a new git commit, please follow these steps closely:
19687
19687
  4. **Create the commit, ending with this specific footer:**
19688
19688
  \`\`\`
19689
19689
  Generated with LevelCode \uD83E\uDD16
19690
- Co-Authored-By: LevelCode <noreply@levelcode.com>
19690
+ Co-Authored-By: LevelCode <noreply@levelcode.vercel.app>
19691
19691
  \`\`\`
19692
19692
  To maintain proper formatting, use cross-platform compatible commit messages:
19693
19693
 
@@ -19697,7 +19697,7 @@ When the user requests a new git commit, please follow these steps closely:
19697
19697
  Your commit message here.
19698
19698
 
19699
19699
  \uD83E\uDD16 Generated with LevelCode
19700
- Co-Authored-By: LevelCode <noreply@levelcode.com>
19700
+ Co-Authored-By: LevelCode <noreply@levelcode.vercel.app>
19701
19701
  EOF
19702
19702
  )"
19703
19703
  \`\`\`
@@ -19707,7 +19707,7 @@ When the user requests a new git commit, please follow these steps closely:
19707
19707
  git commit -m "Your commit message here.
19708
19708
 
19709
19709
  \uD83E\uDD16 Generated with LevelCode
19710
- Co-Authored-By: LevelCode <noreply@levelcode.com>"
19710
+ Co-Authored-By: LevelCode <noreply@levelcode.vercel.app>"
19711
19711
  \`\`\`
19712
19712
 
19713
19713
  Always detect the platform and use the appropriate syntax. HEREDOC syntax (\`<<'EOF'\`) only works in bash/Unix shells and will fail on Windows Command Prompt.
@@ -19774,7 +19774,7 @@ ${$getNativeToolCallExampleString({
19774
19774
  command: `git commit -m "Your commit message here.
19775
19775
 
19776
19776
  \uD83E\uDD16 Generated with LevelCode
19777
- Co-Authored-By: LevelCode <noreply@levelcode.com>"`
19777
+ Co-Authored-By: LevelCode <noreply@levelcode.vercel.app>"`
19778
19778
  },
19779
19779
  endsAgentStep: endsAgentStep18
19780
19780
  })}
@@ -35366,9 +35366,15 @@ var getClaudeOAuthTokenFromEnv = () => {
35366
35366
  var getOpenRouterApiKeyFromEnv = () => {
35367
35367
  return process.env.OPENROUTER_API_KEY;
35368
35368
  };
35369
+ var getOpenRouterBaseUrlFromEnv = () => {
35370
+ return process.env.OPENROUTER_BASE_URL;
35371
+ };
35369
35372
  var getAnthropicApiKeyFromEnv = () => {
35370
35373
  return process.env.ANTHROPIC_API_KEY;
35371
35374
  };
35375
+ var getAnthropicBaseUrlFromEnv = () => {
35376
+ return process.env.ANTHROPIC_BASE_URL;
35377
+ };
35372
35378
  var isStandaloneMode = () => {
35373
35379
  const appUrl = process.env.NEXT_PUBLIC_LEVELCODE_APP_URL;
35374
35380
  if (!appUrl)
@@ -38646,11 +38652,29 @@ var userFromJson = (json) => {
38646
38652
  return null;
38647
38653
  }
38648
38654
  };
38649
- var getConfigDir = (clientEnv = env) => {
38655
+ var getLegacyConfigDir = (clientEnv = env) => {
38650
38656
  const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
38651
38657
  return import_node_path.default.join(import_os.default.homedir(), ".config", `manicode${envSuffix}`);
38652
38658
  };
38659
+ var getConfigDir = (clientEnv = env) => {
38660
+ const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
38661
+ return import_node_path.default.join(import_os.default.homedir(), ".config", `levelcode${envSuffix}`);
38662
+ };
38663
+ var migrateFromLegacyConfigDir = (clientEnv = env) => {
38664
+ const newDir = getConfigDir(clientEnv);
38665
+ const newCredsPath = import_node_path.default.join(newDir, "credentials.json");
38666
+ if (import_fs.default.existsSync(newCredsPath))
38667
+ return;
38668
+ const legacyCredsPath = import_node_path.default.join(getLegacyConfigDir(clientEnv), "credentials.json");
38669
+ if (!import_fs.default.existsSync(legacyCredsPath))
38670
+ return;
38671
+ try {
38672
+ ensureDirectoryExistsSync(newDir);
38673
+ import_fs.default.copyFileSync(legacyCredsPath, newCredsPath);
38674
+ } catch {}
38675
+ };
38653
38676
  var getCredentialsPath = (clientEnv = env) => {
38677
+ migrateFromLegacyConfigDir(clientEnv);
38654
38678
  return import_node_path.default.join(getConfigDir(clientEnv), "credentials.json");
38655
38679
  };
38656
38680
  var getUserCredentials = (clientEnv = env) => {
@@ -38838,12 +38862,14 @@ async function fetchClaudeOAuthResetTime(accessToken) {
38838
38862
  }
38839
38863
  }
38840
38864
  function createDirectOpenRouterModel(openRouterApiKey, model) {
38841
- const provider = createOpenRouter({ apiKey: openRouterApiKey, compatibility: "strict" });
38865
+ const baseURL = getOpenRouterBaseUrlFromEnv();
38866
+ const provider = createOpenRouter({ apiKey: openRouterApiKey, compatibility: "strict", ...baseURL && { baseURL } });
38842
38867
  return provider.chat(model);
38843
38868
  }
38844
38869
  function createDirectAnthropicModel(anthropicApiKey, model) {
38845
38870
  const anthropicModelId = toAnthropicModelId(model);
38846
- const anthropic = import_anthropic.createAnthropic({ apiKey: anthropicApiKey });
38871
+ const baseURL = getAnthropicBaseUrlFromEnv();
38872
+ const anthropic = import_anthropic.createAnthropic({ apiKey: anthropicApiKey, ...baseURL && { baseURL } });
38847
38873
  return anthropic(anthropicModelId);
38848
38874
  }
38849
38875
  async function getModelForRequest(params2) {
@@ -42204,7 +42230,7 @@ async function handlePromptResponse({
42204
42230
  const message = [
42205
42231
  "Received invalid prompt response from server:",
42206
42232
  JSON.stringify(parsedOutput.error.issues),
42207
- "If this issues persists, please contact support@levelcode.com"
42233
+ "If this issues persists, please contact support@levelcode.vercel.app"
42208
42234
  ].join(`
42209
42235
  `);
42210
42236
  onError({ message });
@@ -42468,5 +42494,5 @@ function loadMCPConfigSync(options) {
42468
42494
  return mergedConfig;
42469
42495
  }
42470
42496
 
42471
- //# debugId=3A02774EE46048ED64756E2164756E21
42497
+ //# debugId=16B068004CDA38AF64756E2164756E21
42472
42498
  //# sourceMappingURL=index.cjs.map