For the complete documentation index, see llms.txt. This page is also available as Markdown.

Namespace

Namespace provider for ComputeSDK - Deploy and manage containerized sandboxes on Namespace's cloud infrastructure.

Installation & Setup

npm install @computesdk/namespace

Add your Namespace credentials to a .env file:

NSC_TOKEN=your_namespace_nsc_token

Usage

import { namespace } from '@computesdk/namespace';

const compute = namespace({
  token: process.env.NSC_TOKEN,
});

// Create a new sandbox
const sandbox = await compute.sandbox.create();
console.log(`Sandbox created: ${sandbox.sandboxId}`);

// Get sandbox info
const info = await sandbox.getInfo();
console.log(`Sandbox status: ${info.status}`);

// Clean up when done
await sandbox.destroy();

Customizing Instance Resources

You can customize the compute resources allocated to your sandboxes:

Configuration Reference

Option
Environment Variable
Required
Description

token

NSC_TOKEN

Yes*

Your Namespace API token

tokenFile

NSC_TOKEN_FILE

Yes*

Path to a JSON token file (e.g. from nsc login) containing bearer_token

virtualCpu

-

No

Number of virtual CPU cores (default: 2)

memoryMegabytes

-

No

Memory allocation in MB (default: 4096)

machineArch

-

No

Machine architecture (default: 'amd64')

os

-

No

Operating system (default: 'linux')

documentedPurpose

-

No

Documented purpose for the instance

destroyReason

-

No

Reason recorded when destroying instances (default: 'ComputeSDK cleanup')

targetContainerName

-

No

Target container name for command execution (default: 'main-container')

* Provide either token (or NSC_TOKEN) or tokenFile (or NSC_TOKEN_FILE).

Next Steps

Last updated

Was this helpful?