@computesdk/workbench 21.0.3 → 21.1.0

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.
@@ -388,11 +388,15 @@ var init_output = __esm({
388
388
  });
389
389
 
390
390
  // src/cli/providers.ts
391
- import {
392
- PROVIDER_AUTH as SHARED_PROVIDER_AUTH,
393
- PROVIDER_NAMES as SHARED_PROVIDER_NAMES,
394
- getProviderConfigFromEnv
395
- } from "computesdk";
391
+ function getProviderConfigFromEnv(provider) {
392
+ const map = PROVIDER_ENV_MAP[provider] || {};
393
+ const config2 = {};
394
+ for (const [configKey, envVar] of Object.entries(map)) {
395
+ const value = process.env?.[envVar];
396
+ if (value) config2[configKey] = value;
397
+ }
398
+ return config2;
399
+ }
396
400
  function getProviderStatus(provider) {
397
401
  const authOptions = PROVIDER_AUTH[provider];
398
402
  if (typeof process === "undefined") {
@@ -592,12 +596,89 @@ function getProviderConfig(providerName) {
592
596
  }
593
597
  return getProviderConfigFromEnv(providerName);
594
598
  }
595
- var PROVIDER_NAMES, PROVIDER_AUTH;
599
+ var SHARED_PROVIDER_NAMES, SHARED_PROVIDER_AUTH, PROVIDER_ENV_MAP, PROVIDER_NAMES, PROVIDER_AUTH;
596
600
  var init_providers = __esm({
597
601
  "src/cli/providers.ts"() {
598
602
  "use strict";
599
603
  init_esm_shims();
600
604
  init_output();
605
+ SHARED_PROVIDER_NAMES = [
606
+ "e2b",
607
+ "railway",
608
+ "daytona",
609
+ "modal",
610
+ "runloop",
611
+ "vercel",
612
+ "cloudflare",
613
+ "beam",
614
+ "just-bash",
615
+ "codesandbox",
616
+ "blaxel",
617
+ "namespace",
618
+ "hopx",
619
+ "sprites",
620
+ "agentuity",
621
+ "freestyle",
622
+ "secure-exec",
623
+ "upstash"
624
+ ];
625
+ SHARED_PROVIDER_AUTH = {
626
+ e2b: [["E2B_API_KEY"]],
627
+ railway: [["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]],
628
+ daytona: [["DAYTONA_API_KEY"]],
629
+ modal: [["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]],
630
+ runloop: [["RUNLOOP_API_KEY"]],
631
+ vercel: [
632
+ ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"],
633
+ ["VERCEL_OIDC_TOKEN"]
634
+ ],
635
+ cloudflare: [
636
+ ["CLOUDFLARE_SANDBOX_URL", "CLOUDFLARE_SANDBOX_SECRET"],
637
+ ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]
638
+ ],
639
+ beam: [["BEAM_TOKEN", "BEAM_WORKSPACE_ID"]],
640
+ "just-bash": [[]],
641
+ codesandbox: [["CSB_API_KEY"]],
642
+ blaxel: [["BL_API_KEY", "BL_WORKSPACE"]],
643
+ namespace: [["NSC_TOKEN"], ["NSC_TOKEN_FILE"]],
644
+ hopx: [["HOPX_API_KEY"]],
645
+ sprites: [["SPRITES_TOKEN"]],
646
+ agentuity: [["AGENTUITY_SDK_KEY"]],
647
+ freestyle: [["FREESTYLE_API_KEY"]],
648
+ "secure-exec": [[]],
649
+ upstash: [["UPSTASH_BOX_API_KEY"]]
650
+ };
651
+ PROVIDER_ENV_MAP = {
652
+ e2b: { apiKey: "E2B_API_KEY" },
653
+ railway: {
654
+ apiKey: "RAILWAY_API_KEY",
655
+ projectId: "RAILWAY_PROJECT_ID",
656
+ environmentId: "RAILWAY_ENVIRONMENT_ID"
657
+ },
658
+ daytona: { apiKey: "DAYTONA_API_KEY" },
659
+ modal: { tokenId: "MODAL_TOKEN_ID", tokenSecret: "MODAL_TOKEN_SECRET" },
660
+ runloop: { apiKey: "RUNLOOP_API_KEY" },
661
+ vercel: {
662
+ token: "VERCEL_TOKEN",
663
+ teamId: "VERCEL_TEAM_ID",
664
+ projectId: "VERCEL_PROJECT_ID"
665
+ },
666
+ cloudflare: {
667
+ sandboxUrl: "CLOUDFLARE_SANDBOX_URL",
668
+ sandboxSecret: "CLOUDFLARE_SANDBOX_SECRET"
669
+ },
670
+ beam: { token: "BEAM_TOKEN", workspaceId: "BEAM_WORKSPACE_ID" },
671
+ "just-bash": {},
672
+ codesandbox: { apiKey: "CSB_API_KEY" },
673
+ blaxel: { apiKey: "BL_API_KEY", workspace: "BL_WORKSPACE" },
674
+ namespace: { token: "NSC_TOKEN", tokenFile: "NSC_TOKEN_FILE" },
675
+ hopx: { apiKey: "HOPX_API_KEY" },
676
+ sprites: { token: "SPRITES_TOKEN" },
677
+ agentuity: { sdkKey: "AGENTUITY_SDK_KEY" },
678
+ freestyle: { apiKey: "FREESTYLE_API_KEY" },
679
+ "secure-exec": {},
680
+ upstash: { apiKey: "UPSTASH_BOX_API_KEY" }
681
+ };
601
682
  PROVIDER_NAMES = [
602
683
  "gateway",
603
684
  ...SHARED_PROVIDER_NAMES
@@ -702,27 +783,22 @@ async function getComputeInstance(state) {
702
783
  throw new Error("No provider configured.");
703
784
  }
704
785
  let compute2;
786
+ const exportName = providerName.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase());
787
+ const providerModule = await loadProvider(providerName);
788
+ const providerFactory = providerModule[exportName] ?? providerModule[providerName];
789
+ if (!providerFactory) {
790
+ throw new Error(`Provider ${providerName} does not export a factory function`);
791
+ }
792
+ const config2 = getProviderConfig(providerName);
793
+ const providerInstance = providerFactory(config2);
705
794
  if (useDirect) {
706
- const providerModule = await loadProvider(providerName);
707
- const exportName = providerName.replace(/-([a-z])/g, (_, c2) => c2.toUpperCase());
708
- const providerFactory = providerModule[exportName] ?? providerModule[providerName];
709
- if (!providerFactory) {
710
- throw new Error(`Provider ${providerName} does not export a factory function`);
711
- }
712
- const config2 = getProviderConfig(providerName);
713
795
  compute2 = createCompute({
714
- defaultProvider: providerFactory(config2)
796
+ defaultProvider: providerInstance
715
797
  });
716
798
  } else {
717
- const { compute: gatewayCompute } = await import("computesdk");
718
- const providerConfig = getProviderConfig(providerName);
719
- const gatewayConfig = getProviderConfig("gateway");
720
- compute2 = gatewayCompute({
721
- provider: providerName,
722
- computesdkApiKey: gatewayConfig.apiKey,
723
- requestTimeoutMs: 6e4,
724
- // Spread provider-specific config
725
- [providerName]: providerConfig
799
+ const { compute: directCompute } = await import("computesdk");
800
+ compute2 = directCompute({
801
+ provider: providerInstance
726
802
  });
727
803
  }
728
804
  state.compute = compute2;