@computesdk/workbench 3.1.0 → 3.1.2
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/bin/workbench.js +7 -45
- package/dist/bin/workbench.js.map +1 -1
- package/dist/helpers.d.ts +9 -3
- package/dist/helpers.js +3 -2
- package/dist/helpers.js.map +1 -1
- package/dist/index.js +7 -45
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Workbench helpers for use in TypeScript files\n * \n * Import these in your .ts files for full TypeScript autocomplete!\n * \n * @example\n * ```typescript\n * import { createWorkbenchSession } from '@computesdk/workbench/helpers';\n * \n * const session = await createWorkbenchSession('e2b');\n * \n * // Now you get full TypeScript autocomplete!\n * await session.npm.install('express');\n * await session.git.clone('https://github.com/user/repo');\n * ```\n */\n\nimport * as cmd from '@computesdk/cmd';\nimport { createCompute, type Provider } from 'computesdk';\n\nexport interface WorkbenchSession {\n sandbox:
|
|
1
|
+
{"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["/**\n * Workbench helpers for use in TypeScript files\n * \n * Import these in your .ts files for full TypeScript autocomplete!\n * \n * @example\n * ```typescript\n * import { createWorkbenchSession } from '@computesdk/workbench/helpers';\n * \n * const session = await createWorkbenchSession('e2b');\n * \n * // Now you get full TypeScript autocomplete!\n * await session.npm.install('express');\n * await session.git.clone('https://github.com/user/repo');\n * ```\n */\n\nimport * as cmd from '@computesdk/cmd';\nimport { createCompute } from '@computesdk/provider';\nimport { compute as gatewayCompute, type SandboxInterface } from 'computesdk';\nimport type { Provider, ProviderSandbox } from '@computesdk/provider';\n\n/**\n * Represents any valid sandbox instance in the workbench context\n * Can be either a gateway sandbox or a direct provider sandbox\n */\nexport type WorkbenchSandboxInstance = SandboxInterface | ProviderSandbox;\n\nexport interface WorkbenchSession {\n sandbox: WorkbenchSandboxInstance;\n // Re-export all cmd functions with the sandbox bound\n npm: typeof cmd.npm;\n pnpm: typeof cmd.pnpm;\n yarn: typeof cmd.yarn;\n bun: typeof cmd.bun;\n pip: typeof cmd.pip;\n git: typeof cmd.git;\n mkdir: typeof cmd.mkdir;\n ls: typeof cmd.ls;\n pwd: typeof cmd.pwd;\n cat: typeof cmd.cat;\n node: typeof cmd.node;\n python: typeof cmd.python;\n // ... add more as needed\n}\n\n/**\n * Create a workbench session for use in TypeScript files\n * This gives you full TypeScript autocomplete!\n */\nexport async function createWorkbenchSession(provider?: Provider): Promise<WorkbenchSession> {\n const compute = provider ? createCompute({ defaultProvider: provider }) : gatewayCompute;\n const sandbox = await compute.sandbox.create();\n \n return {\n sandbox,\n npm: cmd.npm,\n pnpm: cmd.pnpm,\n yarn: cmd.yarn,\n bun: cmd.bun,\n pip: cmd.pip,\n git: cmd.git,\n mkdir: cmd.mkdir,\n ls: cmd.ls,\n pwd: cmd.pwd,\n cat: cmd.cat,\n node: cmd.node,\n python: cmd.python,\n };\n}\n"],"mappings":";AAiBA,YAAY,SAAS;AACrB,SAAS,qBAAqB;AAC9B,SAAS,WAAW,sBAA6C;AA+BjE,eAAsB,uBAAuB,UAAgD;AAC3F,QAAM,UAAU,WAAW,cAAc,EAAE,iBAAiB,SAAS,CAAC,IAAI;AAC1E,QAAM,UAAU,MAAM,QAAQ,QAAQ,OAAO;AAE7C,SAAO;AAAA,IACL;AAAA,IACA,KAAS;AAAA,IACT,MAAU;AAAA,IACV,MAAU;AAAA,IACV,KAAS;AAAA,IACT,KAAS;AAAA,IACT,KAAS;AAAA,IACT,OAAW;AAAA,IACX,IAAQ;AAAA,IACR,KAAS;AAAA,IACT,KAAS;AAAA,IACT,MAAU;AAAA,IACV,QAAY;AAAA,EACd;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -562,8 +562,8 @@ __export(commands_exports, {
|
|
|
562
562
|
cleanupOnExit: () => cleanupOnExit,
|
|
563
563
|
confirmSandboxSwitch: () => confirmSandboxSwitch,
|
|
564
564
|
connectToSandbox: () => connectToSandbox,
|
|
565
|
-
createProviderCommand: () => createProviderCommand,
|
|
566
565
|
createSandbox: () => createSandbox,
|
|
566
|
+
defineProviderCommand: () => defineProviderCommand,
|
|
567
567
|
destroySandbox: () => destroySandbox,
|
|
568
568
|
ensureSandbox: () => ensureSandbox,
|
|
569
569
|
getComputeInstance: () => getComputeInstance,
|
|
@@ -575,7 +575,7 @@ __export(commands_exports, {
|
|
|
575
575
|
toggleMode: () => toggleMode,
|
|
576
576
|
toggleVerbose: () => toggleVerbose
|
|
577
577
|
});
|
|
578
|
-
import { createCompute } from "computesdk";
|
|
578
|
+
import { createCompute } from "@computesdk/provider";
|
|
579
579
|
import * as readline from "readline";
|
|
580
580
|
async function confirm(question, defaultYes = false) {
|
|
581
581
|
return new Promise((resolve) => {
|
|
@@ -629,42 +629,8 @@ async function getComputeInstance(state) {
|
|
|
629
629
|
defaultProvider: providerFactory(config)
|
|
630
630
|
});
|
|
631
631
|
} else {
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
-
const providerConfig = getProviderConfig(providerName);
|
|
635
|
-
const providerHeaders = {};
|
|
636
|
-
switch (providerName) {
|
|
637
|
-
case "e2b":
|
|
638
|
-
if (providerConfig.apiKey) providerHeaders["X-E2B-API-Key"] = providerConfig.apiKey;
|
|
639
|
-
break;
|
|
640
|
-
case "railway":
|
|
641
|
-
if (providerConfig.apiKey) providerHeaders["X-Railway-API-Key"] = providerConfig.apiKey;
|
|
642
|
-
if (providerConfig.projectId) providerHeaders["X-Railway-Project-ID"] = providerConfig.projectId;
|
|
643
|
-
if (providerConfig.environmentId) providerHeaders["X-Railway-Environment-ID"] = providerConfig.environmentId;
|
|
644
|
-
break;
|
|
645
|
-
case "daytona":
|
|
646
|
-
if (providerConfig.apiKey) providerHeaders["X-Daytona-API-Key"] = providerConfig.apiKey;
|
|
647
|
-
break;
|
|
648
|
-
case "modal":
|
|
649
|
-
if (providerConfig.tokenId) providerHeaders["X-Modal-Token-ID"] = providerConfig.tokenId;
|
|
650
|
-
if (providerConfig.tokenSecret) providerHeaders["X-Modal-Token-Secret"] = providerConfig.tokenSecret;
|
|
651
|
-
break;
|
|
652
|
-
case "vercel":
|
|
653
|
-
if (providerConfig.token) providerHeaders["X-Vercel-Token"] = providerConfig.token;
|
|
654
|
-
if (providerConfig.teamId) providerHeaders["X-Vercel-Team-ID"] = providerConfig.teamId;
|
|
655
|
-
if (providerConfig.projectId) providerHeaders["X-Vercel-Project-ID"] = providerConfig.projectId;
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
const config = {
|
|
659
|
-
apiKey: process.env.COMPUTESDK_API_KEY,
|
|
660
|
-
provider: providerName,
|
|
661
|
-
// Tell gateway which backend to use
|
|
662
|
-
providerHeaders
|
|
663
|
-
// Pass provider credentials via headers
|
|
664
|
-
};
|
|
665
|
-
compute2 = createCompute({
|
|
666
|
-
defaultProvider: gatewayFactory(config)
|
|
667
|
-
});
|
|
632
|
+
const { compute: gatewayCompute } = await import("computesdk");
|
|
633
|
+
compute2 = gatewayCompute;
|
|
668
634
|
}
|
|
669
635
|
state.compute = compute2;
|
|
670
636
|
return compute2;
|
|
@@ -722,10 +688,6 @@ Install it with: ${c.cyan(`npm install @computesdk/${providerName}`)}
|
|
|
722
688
|
}
|
|
723
689
|
}
|
|
724
690
|
async function destroySandbox(state) {
|
|
725
|
-
if (!hasSandbox(state)) {
|
|
726
|
-
logWarning("No active sandbox");
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
691
|
const spinner = new Spinner("Destroying sandbox...").start();
|
|
730
692
|
try {
|
|
731
693
|
const sandbox = getCurrentSandbox(state);
|
|
@@ -856,7 +818,7 @@ async function switchProvider(state, mode, providerName) {
|
|
|
856
818
|
logSuccess(`Switched to ${modeStr}`);
|
|
857
819
|
}
|
|
858
820
|
}
|
|
859
|
-
function
|
|
821
|
+
function defineProviderCommand(state) {
|
|
860
822
|
return async function provider(mode, providerName) {
|
|
861
823
|
if (!mode) {
|
|
862
824
|
if (state.currentProvider) {
|
|
@@ -948,7 +910,7 @@ async function connectToSandbox(state, sandboxUrl, token) {
|
|
|
948
910
|
const spinner = new Spinner(`Connecting to ${cleanUrl}...`).start();
|
|
949
911
|
const startTime = Date.now();
|
|
950
912
|
try {
|
|
951
|
-
const { Sandbox } = await import("
|
|
913
|
+
const { Sandbox } = await import("computesdk");
|
|
952
914
|
let WebSocket;
|
|
953
915
|
try {
|
|
954
916
|
const wsModule = await import("ws");
|
|
@@ -1131,7 +1093,7 @@ function injectCmdContext(replServer) {
|
|
|
1131
1093
|
replServer.context.zsh = cmd.zsh;
|
|
1132
1094
|
}
|
|
1133
1095
|
function injectWorkbenchCommands(replServer, state) {
|
|
1134
|
-
replServer.context.provider =
|
|
1096
|
+
replServer.context.provider = defineProviderCommand(state);
|
|
1135
1097
|
replServer.context.providers = () => showProviders();
|
|
1136
1098
|
replServer.context.mode = async (modeName) => {
|
|
1137
1099
|
if (!modeName) {
|