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