@daytonaio/sdk 0.9.2 → 0.10.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/Daytona.d.ts +239 -47
- package/dist/Daytona.js +274 -63
- package/dist/FileSystem.d.ts +183 -32
- package/dist/FileSystem.js +168 -28
- package/dist/Git.d.ts +178 -30
- package/dist/Git.js +178 -30
- package/dist/LspServer.d.ts +170 -22
- package/dist/LspServer.js +162 -18
- package/dist/Process.d.ts +187 -37
- package/dist/Process.js +185 -44
- package/dist/Workspace.d.ts +252 -36
- package/dist/Workspace.js +239 -49
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.js +4 -2
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.js +4 -2
- package/dist/errors/DaytonaError.d.ts +8 -0
- package/dist/errors/DaytonaError.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -1
- package/dist/utils/Axios.d.ts +6 -0
- package/dist/utils/Axios.js +28 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.js +36 -0
- package/dist/utils/timeout.d.ts +35 -0
- package/dist/utils/timeout.js +73 -0
- package/package.json +9 -8
- package/dist/client/apis/ApiKeyApi.d.ts +0 -54
- package/dist/client/apis/ApiKeyApi.js +0 -135
- package/dist/client/apis/BuildApi.d.ts +0 -95
- package/dist/client/apis/BuildApi.js +0 -228
- package/dist/client/apis/ContainerRegistryApi.d.ts +0 -68
- package/dist/client/apis/ContainerRegistryApi.js +0 -163
- package/dist/client/apis/DefaultApi.d.ts +0 -31
- package/dist/client/apis/DefaultApi.js +0 -72
- package/dist/client/apis/GitProviderApi.d.ts +0 -197
- package/dist/client/apis/GitProviderApi.js +0 -477
- package/dist/client/apis/PrebuildApi.d.ts +0 -97
- package/dist/client/apis/PrebuildApi.js +0 -241
- package/dist/client/apis/ProfileApi.d.ts +0 -51
- package/dist/client/apis/ProfileApi.js +0 -128
- package/dist/client/apis/ProjectConfigApi.d.ts +0 -94
- package/dist/client/apis/ProjectConfigApi.js +0 -220
- package/dist/client/apis/ProviderApi.d.ts +0 -71
- package/dist/client/apis/ProviderApi.js +0 -160
- package/dist/client/apis/SampleApi.d.ts +0 -28
- package/dist/client/apis/SampleApi.js +0 -73
- package/dist/client/apis/ServerApi.d.ts +0 -61
- package/dist/client/apis/ServerApi.js +0 -156
- package/dist/client/apis/TargetApi.d.ts +0 -67
- package/dist/client/apis/TargetApi.js +0 -159
- package/dist/client/apis/WorkspaceApi.d.ts +0 -141
- package/dist/client/apis/WorkspaceApi.js +0 -330
- package/dist/client/apis/WorkspaceToolboxApi.d.ts +0 -464
- package/dist/client/apis/WorkspaceToolboxApi.js +0 -1248
- package/dist/client/apis/index.d.ts +0 -14
- package/dist/client/apis/index.js +0 -32
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.js +0 -21
- package/dist/client/models/ApiKey.d.ts +0 -45
- package/dist/client/models/ApiKey.js +0 -60
- package/dist/client/models/ApikeyApiKeyType.d.ts +0 -26
- package/dist/client/models/ApikeyApiKeyType.js +0 -52
- package/dist/client/models/Build.d.ts +0 -98
- package/dist/client/models/Build.js +0 -91
- package/dist/client/models/BuildBuildState.d.ts +0 -31
- package/dist/client/models/BuildBuildState.js +0 -57
- package/dist/client/models/BuildConfig.d.ts +0 -40
- package/dist/client/models/BuildConfig.js +0 -57
- package/dist/client/models/CachedBuild.d.ts +0 -38
- package/dist/client/models/CachedBuild.js +0 -55
- package/dist/client/models/CloneTarget.d.ts +0 -25
- package/dist/client/models/CloneTarget.js +0 -51
- package/dist/client/models/CompletionContext.d.ts +0 -38
- package/dist/client/models/CompletionContext.js +0 -53
- package/dist/client/models/CompletionItem.d.ts +0 -68
- package/dist/client/models/CompletionItem.js +0 -63
- package/dist/client/models/CompletionList.d.ts +0 -39
- package/dist/client/models/CompletionList.js +0 -56
- package/dist/client/models/ContainerConfig.d.ts +0 -38
- package/dist/client/models/ContainerConfig.js +0 -55
- package/dist/client/models/ContainerRegistry.d.ts +0 -44
- package/dist/client/models/ContainerRegistry.js +0 -59
- package/dist/client/models/CreateBuildDTO.d.ts +0 -52
- package/dist/client/models/CreateBuildDTO.js +0 -62
- package/dist/client/models/CreatePrebuildDTO.d.ts +0 -56
- package/dist/client/models/CreatePrebuildDTO.js +0 -59
- package/dist/client/models/CreateProjectConfigDTO.d.ts +0 -71
- package/dist/client/models/CreateProjectConfigDTO.js +0 -72
- package/dist/client/models/CreateProjectDTO.d.ts +0 -72
- package/dist/client/models/CreateProjectDTO.js +0 -73
- package/dist/client/models/CreateProjectSourceDTO.d.ts +0 -33
- package/dist/client/models/CreateProjectSourceDTO.js +0 -52
- package/dist/client/models/CreateProviderTargetDTO.d.ts +0 -45
- package/dist/client/models/CreateProviderTargetDTO.js +0 -60
- package/dist/client/models/CreateWorkspaceDTO.d.ts +0 -51
- package/dist/client/models/CreateWorkspaceDTO.js +0 -64
- package/dist/client/models/DevcontainerConfig.d.ts +0 -32
- package/dist/client/models/DevcontainerConfig.js +0 -51
- package/dist/client/models/ExecuteRequest.d.ts +0 -38
- package/dist/client/models/ExecuteRequest.js +0 -53
- package/dist/client/models/ExecuteResponse.d.ts +0 -38
- package/dist/client/models/ExecuteResponse.js +0 -55
- package/dist/client/models/FRPSConfig.d.ts +0 -44
- package/dist/client/models/FRPSConfig.js +0 -59
- package/dist/client/models/FileInfo.d.ts +0 -74
- package/dist/client/models/FileInfo.js +0 -79
- package/dist/client/models/FileStatus.d.ts +0 -51
- package/dist/client/models/FileStatus.js +0 -64
- package/dist/client/models/GetRepositoryContext.d.ts +0 -80
- package/dist/client/models/GetRepositoryContext.js +0 -67
- package/dist/client/models/GitAddRequest.d.ts +0 -38
- package/dist/client/models/GitAddRequest.js +0 -55
- package/dist/client/models/GitBranch.d.ts +0 -38
- package/dist/client/models/GitBranch.js +0 -55
- package/dist/client/models/GitBranchRequest.d.ts +0 -38
- package/dist/client/models/GitBranchRequest.js +0 -55
- package/dist/client/models/GitCloneRequest.d.ts +0 -62
- package/dist/client/models/GitCloneRequest.js +0 -63
- package/dist/client/models/GitCommitInfo.d.ts +0 -56
- package/dist/client/models/GitCommitInfo.js +0 -67
- package/dist/client/models/GitCommitRequest.d.ts +0 -50
- package/dist/client/models/GitCommitRequest.js +0 -63
- package/dist/client/models/GitCommitResponse.d.ts +0 -32
- package/dist/client/models/GitCommitResponse.js +0 -51
- package/dist/client/models/GitNamespace.d.ts +0 -38
- package/dist/client/models/GitNamespace.js +0 -55
- package/dist/client/models/GitProvider.d.ts +0 -75
- package/dist/client/models/GitProvider.js +0 -76
- package/dist/client/models/GitPullRequest.d.ts +0 -68
- package/dist/client/models/GitPullRequest.js +0 -75
- package/dist/client/models/GitRepoRequest.d.ts +0 -44
- package/dist/client/models/GitRepoRequest.js +0 -55
- package/dist/client/models/GitRepository.d.ts +0 -87
- package/dist/client/models/GitRepository.js +0 -84
- package/dist/client/models/GitStatus.d.ts +0 -57
- package/dist/client/models/GitStatus.js +0 -62
- package/dist/client/models/GitUser.d.ts +0 -50
- package/dist/client/models/GitUser.js +0 -63
- package/dist/client/models/InstallProviderRequest.d.ts +0 -40
- package/dist/client/models/InstallProviderRequest.js +0 -55
- package/dist/client/models/ListBranchResponse.d.ts +0 -32
- package/dist/client/models/ListBranchResponse.js +0 -51
- package/dist/client/models/LogFileConfig.d.ts +0 -62
- package/dist/client/models/LogFileConfig.js +0 -67
- package/dist/client/models/LspCompletionParams.d.ts +0 -58
- package/dist/client/models/LspCompletionParams.js +0 -69
- package/dist/client/models/LspDocumentRequest.d.ts +0 -44
- package/dist/client/models/LspDocumentRequest.js +0 -59
- package/dist/client/models/LspLocation.d.ts +0 -39
- package/dist/client/models/LspLocation.js +0 -56
- package/dist/client/models/LspPosition.d.ts +0 -38
- package/dist/client/models/LspPosition.js +0 -55
- package/dist/client/models/LspRange.d.ts +0 -39
- package/dist/client/models/LspRange.js +0 -56
- package/dist/client/models/LspServerRequest.d.ts +0 -38
- package/dist/client/models/LspServerRequest.js +0 -55
- package/dist/client/models/LspSymbol.d.ts +0 -45
- package/dist/client/models/LspSymbol.js +0 -60
- package/dist/client/models/Match.d.ts +0 -44
- package/dist/client/models/Match.js +0 -59
- package/dist/client/models/NetworkKey.d.ts +0 -32
- package/dist/client/models/NetworkKey.js +0 -51
- package/dist/client/models/Position.d.ts +0 -38
- package/dist/client/models/Position.js +0 -55
- package/dist/client/models/PrebuildConfig.d.ts +0 -56
- package/dist/client/models/PrebuildConfig.js +0 -67
- package/dist/client/models/PrebuildDTO.d.ts +0 -62
- package/dist/client/models/PrebuildDTO.js +0 -68
- package/dist/client/models/ProfileData.d.ts +0 -34
- package/dist/client/models/ProfileData.js +0 -51
- package/dist/client/models/Project.d.ts +0 -91
- package/dist/client/models/Project.js +0 -88
- package/dist/client/models/ProjectConfig.d.ts +0 -84
- package/dist/client/models/ProjectConfig.js +0 -87
- package/dist/client/models/ProjectDirResponse.d.ts +0 -32
- package/dist/client/models/ProjectDirResponse.js +0 -49
- package/dist/client/models/ProjectInfo.d.ts +0 -56
- package/dist/client/models/ProjectInfo.js +0 -65
- package/dist/client/models/ProjectState.d.ts +0 -45
- package/dist/client/models/ProjectState.js +0 -60
- package/dist/client/models/Provider.d.ts +0 -44
- package/dist/client/models/Provider.js +0 -57
- package/dist/client/models/ProviderProviderInfo.d.ts +0 -44
- package/dist/client/models/ProviderProviderInfo.js +0 -57
- package/dist/client/models/ProviderProviderTargetProperty.d.ts +0 -72
- package/dist/client/models/ProviderProviderTargetProperty.js +0 -64
- package/dist/client/models/ProviderProviderTargetPropertyType.d.ts +0 -29
- package/dist/client/models/ProviderProviderTargetPropertyType.js +0 -55
- package/dist/client/models/ProviderTarget.d.ts +0 -51
- package/dist/client/models/ProviderTarget.js +0 -64
- package/dist/client/models/ReplaceRequest.d.ts +0 -44
- package/dist/client/models/ReplaceRequest.js +0 -59
- package/dist/client/models/ReplaceResult.d.ts +0 -44
- package/dist/client/models/ReplaceResult.js +0 -53
- package/dist/client/models/RepositoryUrl.d.ts +0 -32
- package/dist/client/models/RepositoryUrl.js +0 -51
- package/dist/client/models/Sample.d.ts +0 -44
- package/dist/client/models/Sample.js +0 -59
- package/dist/client/models/SearchFilesResponse.d.ts +0 -32
- package/dist/client/models/SearchFilesResponse.js +0 -51
- package/dist/client/models/ServerConfig.d.ts +0 -130
- package/dist/client/models/ServerConfig.js +0 -119
- package/dist/client/models/SetGitProviderConfig.d.ts +0 -75
- package/dist/client/models/SetGitProviderConfig.js +0 -70
- package/dist/client/models/SetProjectState.d.ts +0 -39
- package/dist/client/models/SetProjectState.js +0 -56
- package/dist/client/models/SigningMethod.d.ts +0 -25
- package/dist/client/models/SigningMethod.js +0 -51
- package/dist/client/models/Status.d.ts +0 -31
- package/dist/client/models/Status.js +0 -57
- package/dist/client/models/Workspace.d.ts +0 -51
- package/dist/client/models/Workspace.js +0 -64
- package/dist/client/models/WorkspaceDTO.d.ts +0 -58
- package/dist/client/models/WorkspaceDTO.js +0 -67
- package/dist/client/models/WorkspaceInfo.d.ts +0 -45
- package/dist/client/models/WorkspaceInfo.js +0 -58
- package/dist/client/models/index.d.ts +0 -79
- package/dist/client/models/index.js +0 -97
- package/dist/client/runtime.d.ts +0 -182
- package/dist/client/runtime.js +0 -340
package/dist/Workspace.d.ts
CHANGED
|
@@ -1,12 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Daytona SDK core Sandbox functionality.
|
|
3
|
+
*
|
|
4
|
+
* Provides the main Workspace class representing a Daytona Sandbox that coordinates file system,
|
|
5
|
+
* Git, process execution, and LSP functionality. It serves as the central point
|
|
6
|
+
* for interacting with Daytona Sandboxes.
|
|
7
|
+
*
|
|
8
|
+
* The Sandbox must be in a 'started' state before performing operations.
|
|
9
|
+
*
|
|
10
|
+
* @module Workspace
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Create and initialize workspace
|
|
14
|
+
* const daytona = new Daytona();
|
|
15
|
+
* const workspace = await daytona.create();
|
|
16
|
+
*
|
|
17
|
+
* // File operations
|
|
18
|
+
* await workspace.fs.uploadFile(
|
|
19
|
+
* '/app/config.json',
|
|
20
|
+
* new File(['{"setting": "value"}'], 'config.json')
|
|
21
|
+
* );
|
|
22
|
+
* const contentBlob = await workspace.fs.downloadFile('/app/config.json');
|
|
23
|
+
*
|
|
24
|
+
* // Git operations
|
|
25
|
+
* await workspace.git.clone('https://github.com/user/repo.git');
|
|
26
|
+
*
|
|
27
|
+
* // Process execution
|
|
28
|
+
* const response = await workspace.process.executeCommand('ls -la');
|
|
29
|
+
* console.log(response.result);
|
|
30
|
+
*
|
|
31
|
+
* // LSP functionality
|
|
32
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
33
|
+
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
34
|
+
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
35
|
+
* line: 10,
|
|
36
|
+
* character: 15
|
|
37
|
+
* });
|
|
38
|
+
* console.log(completions);
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
1
41
|
import { ToolboxApi, WorkspaceApi } from '@daytonaio/api-client';
|
|
2
|
-
import { Workspace as
|
|
42
|
+
import { WorkspaceState, Workspace as ApiWorkspace, WorkspaceInfo as ApiWorkspaceInfo, CreateWorkspaceTargetEnum as WorkspaceTargetRegion, CreateWorkspaceClassEnum as WorkspaceClass } from '@daytonaio/api-client';
|
|
3
43
|
import { FileSystem } from './FileSystem';
|
|
4
44
|
import { Git } from './Git';
|
|
5
|
-
import { Process } from './Process';
|
|
45
|
+
import { CodeRunParams, Process } from './Process';
|
|
6
46
|
import { LspLanguageId, LspServer } from './LspServer';
|
|
47
|
+
export interface WorkspaceInstance extends Omit<ApiWorkspace, 'info'> {
|
|
48
|
+
info?: WorkspaceInfo;
|
|
49
|
+
}
|
|
7
50
|
/**
|
|
8
|
-
* Resources allocated to a
|
|
51
|
+
* Resources allocated to a Sandbox
|
|
52
|
+
*
|
|
9
53
|
* @interface WorkspaceResources
|
|
54
|
+
* @property {string} cpu - Number of CPU cores allocated (e.g., "1", "2")
|
|
55
|
+
* @property {string | null} gpu - Number of GPUs allocated (e.g., "1") or null if no GPU
|
|
56
|
+
* @property {string} memory - Amount of memory allocated with unit (e.g., "2Gi", "4Gi")
|
|
57
|
+
* @property {string} disk - Amount of disk space allocated with unit (e.g., "10Gi", "20Gi")
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const resources: WorkspaceResources = {
|
|
61
|
+
* cpu: "2",
|
|
62
|
+
* gpu: "1",
|
|
63
|
+
* memory: "4Gi",
|
|
64
|
+
* disk: "20Gi"
|
|
65
|
+
* };
|
|
10
66
|
*/
|
|
11
67
|
export interface WorkspaceResources {
|
|
12
68
|
/** CPU allocation */
|
|
@@ -19,10 +75,33 @@ export interface WorkspaceResources {
|
|
|
19
75
|
disk: string;
|
|
20
76
|
}
|
|
21
77
|
/**
|
|
22
|
-
* Structured information about a
|
|
78
|
+
* Structured information about a Sandbox
|
|
79
|
+
*
|
|
80
|
+
* This interface provides detailed information about a Sandbox's configuration,
|
|
81
|
+
* resources, and current state.
|
|
82
|
+
*
|
|
23
83
|
* @interface WorkspaceInfo
|
|
84
|
+
* @property {string} id - Unique identifier for the Sandbox
|
|
85
|
+
* @property {string} name - Display name of the Sandbox
|
|
86
|
+
* @property {string} image - Docker image used for the Sandbox
|
|
87
|
+
* @property {string} user - OS user running in the Sandbox
|
|
88
|
+
* @property {Record<string, string>} env - Environment variables set in the Sandbox
|
|
89
|
+
* @property {Record<string, string>} labels - Custom labels attached to the Sandbox
|
|
90
|
+
* @property {boolean} public - Whether the Sandbox is publicly accessible
|
|
91
|
+
* @property {string} target - Target environment where the Sandbox runs
|
|
92
|
+
* @property {WorkspaceResources} resources - Resource allocations for the Sandbox
|
|
93
|
+
* @property {string} state - Current state of the Sandbox (e.g., "started", "stopped")
|
|
94
|
+
* @property {string | null} errorReason - Error message if Sandbox is in error state
|
|
95
|
+
* @property {string | null} snapshotState - Current state of Sandbox snapshot
|
|
96
|
+
* @property {Date | null} snapshotStateCreatedAt - When the snapshot state was created
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const workspace = await daytona.create();
|
|
100
|
+
* const info = await workspace.info();
|
|
101
|
+
* console.log(`Workspace ${info.name} is ${info.state}`);
|
|
102
|
+
* console.log(`Resources: ${info.resources.cpu} CPU, ${info.resources.memory} RAM`);
|
|
24
103
|
*/
|
|
25
|
-
export interface WorkspaceInfo {
|
|
104
|
+
export interface WorkspaceInfo extends ApiWorkspaceInfo {
|
|
26
105
|
/** Unique identifier */
|
|
27
106
|
id: string;
|
|
28
107
|
/** Workspace name */
|
|
@@ -38,17 +117,33 @@ export interface WorkspaceInfo {
|
|
|
38
117
|
/** Public access flag */
|
|
39
118
|
public: boolean;
|
|
40
119
|
/** Target location */
|
|
41
|
-
target: string;
|
|
120
|
+
target: WorkspaceTargetRegion | string;
|
|
42
121
|
/** Resource allocations */
|
|
43
122
|
resources: WorkspaceResources;
|
|
44
123
|
/** Current state */
|
|
45
|
-
state:
|
|
124
|
+
state: WorkspaceState;
|
|
46
125
|
/** Error reason if any */
|
|
47
126
|
errorReason: string | null;
|
|
48
127
|
/** Snapshot state */
|
|
49
128
|
snapshotState: string | null;
|
|
50
129
|
/** Snapshot state creation timestamp */
|
|
51
130
|
snapshotStateCreatedAt: Date | null;
|
|
131
|
+
/** Node domain */
|
|
132
|
+
nodeDomain: string;
|
|
133
|
+
/** Region */
|
|
134
|
+
region: WorkspaceTargetRegion;
|
|
135
|
+
/** Class */
|
|
136
|
+
class: WorkspaceClass;
|
|
137
|
+
/** Updated at */
|
|
138
|
+
updatedAt: string;
|
|
139
|
+
/** Last snapshot */
|
|
140
|
+
lastSnapshot: string | null;
|
|
141
|
+
/** Auto-stop interval in minutes*/
|
|
142
|
+
autoStopInterval: number;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use `state`, `nodeDomain`, `region`, `class`, `updatedAt`, `lastSnapshot`, `resources`, `autoStopInterval` instead.
|
|
145
|
+
*/
|
|
146
|
+
providerMetadata?: string;
|
|
52
147
|
}
|
|
53
148
|
/**
|
|
54
149
|
* Interface defining methods that a code toolbox must implement
|
|
@@ -56,11 +151,23 @@ export interface WorkspaceInfo {
|
|
|
56
151
|
*/
|
|
57
152
|
export interface WorkspaceCodeToolbox {
|
|
58
153
|
/** Generates a command to run the provided code */
|
|
59
|
-
getRunCommand(code: string): string;
|
|
154
|
+
getRunCommand(code: string, params?: CodeRunParams): string;
|
|
60
155
|
}
|
|
61
156
|
/**
|
|
62
|
-
* Represents a Daytona
|
|
63
|
-
*
|
|
157
|
+
* Represents a Daytona Sandbox.
|
|
158
|
+
*
|
|
159
|
+
* A Sandbox provides file system operations, Git operations, process execution,
|
|
160
|
+
* and LSP functionality. It serves as the main interface for interacting with
|
|
161
|
+
* a Daytona workspace.
|
|
162
|
+
*
|
|
163
|
+
* @property {string} id - Unique identifier for the Sandbox
|
|
164
|
+
* @property {WorkspaceInstance} instance - The underlying Sandbox instance
|
|
165
|
+
* @property {WorkspaceApi} workspaceApi - API client for Sandbox operations
|
|
166
|
+
* @property {ToolboxApi} toolboxApi - API client for toolbox operations
|
|
167
|
+
* @property {WorkspaceCodeToolbox} codeToolbox - Language-specific toolbox implementation
|
|
168
|
+
* @property {FileSystem} fs - File system operations interface
|
|
169
|
+
* @property {Git} git - Git operations interface
|
|
170
|
+
* @property {Process} process - Process execution interface
|
|
64
171
|
*/
|
|
65
172
|
export declare class Workspace {
|
|
66
173
|
readonly id: string;
|
|
@@ -68,65 +175,174 @@ export declare class Workspace {
|
|
|
68
175
|
readonly workspaceApi: WorkspaceApi;
|
|
69
176
|
readonly toolboxApi: ToolboxApi;
|
|
70
177
|
private readonly codeToolbox;
|
|
71
|
-
/** File system operations for the
|
|
178
|
+
/** File system operations for the Sandbox */
|
|
72
179
|
readonly fs: FileSystem;
|
|
73
|
-
/** Git operations for the
|
|
180
|
+
/** Git operations for the Sandbox */
|
|
74
181
|
readonly git: Git;
|
|
75
182
|
/** Process and code execution operations */
|
|
76
183
|
readonly process: Process;
|
|
77
184
|
/**
|
|
78
|
-
* Creates a new
|
|
79
|
-
* @param {string} id - Unique identifier for the workspace
|
|
80
|
-
* @param {WorkspaceInstance} instance - The underlying workspace instance
|
|
81
|
-
* @param {WorkspaceApi} workspaceApi - API client for workspace operations
|
|
82
|
-
* @param {ToolboxApi} toolboxApi - API client for toolbox operations
|
|
185
|
+
* Creates a new Sandbox instance
|
|
83
186
|
*
|
|
187
|
+
* @param {string} id - Unique identifier for the Sandbox
|
|
188
|
+
* @param {WorkspaceInstance} instance - The underlying Sandbox instance
|
|
189
|
+
* @param {WorkspaceApi} workspaceApi - API client for Sandbox operations
|
|
190
|
+
* @param {ToolboxApi} toolboxApi - API client for toolbox operations
|
|
84
191
|
* @param {WorkspaceCodeToolbox} codeToolbox - Language-specific toolbox implementation
|
|
85
192
|
*/
|
|
86
193
|
constructor(id: string, instance: WorkspaceInstance, workspaceApi: WorkspaceApi, toolboxApi: ToolboxApi, codeToolbox: WorkspaceCodeToolbox);
|
|
87
194
|
/**
|
|
88
|
-
* Gets the root directory path of the
|
|
89
|
-
*
|
|
195
|
+
* Gets the root directory path of the Sandbox.
|
|
196
|
+
*
|
|
197
|
+
* @returns {Promise<string | undefined>} The absolute path to the Sandbox root directory
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* const rootDir = await workspace.getWorkspaceRootDir();
|
|
201
|
+
* console.log(`Workspace root: ${rootDir}`);
|
|
90
202
|
*/
|
|
91
203
|
getWorkspaceRootDir(): Promise<string | undefined>;
|
|
92
204
|
/**
|
|
93
|
-
* Creates a new Language Server Protocol (LSP) server instance
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
205
|
+
* Creates a new Language Server Protocol (LSP) server instance.
|
|
206
|
+
*
|
|
207
|
+
* The LSP server provides language-specific features like code completion,
|
|
208
|
+
* diagnostics, and more.
|
|
209
|
+
*
|
|
210
|
+
* @param {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
211
|
+
* @param {string} pathToProject - Absolute path to the project root directory
|
|
212
|
+
* @returns {LspServer} A new LSP server instance configured for the specified language
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* const lsp = workspace.createLspServer('typescript', '/workspace/project');
|
|
97
216
|
*/
|
|
98
|
-
createLspServer(languageId: LspLanguageId, pathToProject: string): LspServer;
|
|
217
|
+
createLspServer(languageId: LspLanguageId | string, pathToProject: string): LspServer;
|
|
99
218
|
/**
|
|
100
|
-
* Sets labels for the
|
|
101
|
-
*
|
|
219
|
+
* Sets labels for the Sandbox.
|
|
220
|
+
*
|
|
221
|
+
* Labels are key-value pairs that can be used to organize and identify Sandboxes.
|
|
222
|
+
*
|
|
223
|
+
* @param {Record<string, string>} labels - Dictionary of key-value pairs representing Sandbox labels
|
|
224
|
+
* @returns {Promise<void>}
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* // Set workspace labels
|
|
228
|
+
* await workspace.setLabels({
|
|
229
|
+
* project: 'my-project',
|
|
230
|
+
* environment: 'development',
|
|
231
|
+
* team: 'backend'
|
|
232
|
+
* });
|
|
102
233
|
*/
|
|
103
234
|
setLabels(labels: Record<string, string>): Promise<void>;
|
|
104
235
|
/**
|
|
105
|
-
*
|
|
236
|
+
* Start the Sandbox.
|
|
237
|
+
*
|
|
238
|
+
* This method starts the Sandbox and waits for it to be ready.
|
|
239
|
+
*
|
|
240
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
241
|
+
* Defaults to 60-second timeout.
|
|
106
242
|
* @returns {Promise<void>}
|
|
243
|
+
* @throws {DaytonaError} - `DaytonaError` - If Sandbox fails to start or times out
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* const workspace = await daytona.getCurrentWorkspace('my-workspace');
|
|
247
|
+
* await workspace.start(40); // Wait up to 40 seconds
|
|
248
|
+
* console.log('Workspace started successfully');
|
|
107
249
|
*/
|
|
108
250
|
start(timeout?: number): Promise<void>;
|
|
109
251
|
/**
|
|
110
|
-
* Stops the
|
|
252
|
+
* Stops the Sandbox.
|
|
253
|
+
*
|
|
254
|
+
* This method stops the Sandbox and waits for it to be fully stopped.
|
|
255
|
+
*
|
|
256
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
257
|
+
* Defaults to 60-second timeout.
|
|
111
258
|
* @returns {Promise<void>}
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* const workspace = await daytona.getCurrentWorkspace('my-workspace');
|
|
262
|
+
* await workspace.stop();
|
|
263
|
+
* console.log('Workspace stopped successfully');
|
|
112
264
|
*/
|
|
113
|
-
stop(): Promise<void>;
|
|
265
|
+
stop(timeout?: number): Promise<void>;
|
|
114
266
|
/**
|
|
115
|
-
* Deletes the
|
|
267
|
+
* Deletes the Sandbox.
|
|
116
268
|
* @returns {Promise<void>}
|
|
117
269
|
*/
|
|
118
270
|
delete(): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Waits for the Sandbox to reach the 'started' state.
|
|
273
|
+
*
|
|
274
|
+
* This method polls the Sandbox status until it reaches the 'started' state
|
|
275
|
+
* or encounters an error.
|
|
276
|
+
*
|
|
277
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
278
|
+
* Defaults to 60 seconds.
|
|
279
|
+
* @returns {Promise<void>}
|
|
280
|
+
* @throws {DaytonaError} - `DaytonaError` - If the workspace ends up in an error state or fails to start within the timeout period.
|
|
281
|
+
*/
|
|
119
282
|
waitUntilStarted(timeout?: number): Promise<void>;
|
|
120
|
-
waitUntilStopped(): Promise<void>;
|
|
121
283
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
284
|
+
* Wait for Sandbox to reach 'stopped' state.
|
|
285
|
+
*
|
|
286
|
+
* This method polls the Sandbox status until it reaches the 'stopped' state
|
|
287
|
+
* or encounters an error.
|
|
288
|
+
*
|
|
289
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
290
|
+
* Defaults to 60 seconds.
|
|
291
|
+
* @returns {Promise<void>}
|
|
292
|
+
* @throws {DaytonaError} - `DaytonaError` - If the workspace fails to stop within the timeout period.
|
|
293
|
+
*/
|
|
294
|
+
waitUntilStopped(timeout?: number): Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Gets structured information about the Sandbox.
|
|
297
|
+
*
|
|
298
|
+
* @returns {Promise<WorkspaceInfo>} Detailed information about the Sandbox including its
|
|
299
|
+
* configuration, resources, and current state
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* const info = await workspace.info();
|
|
303
|
+
* console.log(`Workspace ${info.name}:`);
|
|
304
|
+
* console.log(`State: ${info.state}`);
|
|
305
|
+
* console.log(`Resources: ${info.resources.cpu} CPU, ${info.resources.memory} RAM`);
|
|
124
306
|
*/
|
|
125
307
|
info(): Promise<WorkspaceInfo>;
|
|
126
308
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @
|
|
309
|
+
* Converts an API workspace instance to a WorkspaceInfo object.
|
|
310
|
+
*
|
|
311
|
+
* @param {ApiWorkspace} instance - The API workspace instance to convert
|
|
312
|
+
* @returns {WorkspaceInfo} The converted WorkspaceInfo object
|
|
313
|
+
*/
|
|
314
|
+
static toWorkspaceInfo(instance: ApiWorkspace): WorkspaceInfo;
|
|
315
|
+
/**
|
|
316
|
+
* Set the auto-stop interval for the Sandbox.
|
|
317
|
+
*
|
|
318
|
+
* The Sandbox will automatically stop after being idle (no new events) for the specified interval.
|
|
319
|
+
* Events include any state changes or interactions with the Sandbox through the sdk.
|
|
320
|
+
* Interactions using Sandbox Previews are not included.
|
|
321
|
+
*
|
|
322
|
+
* @param {number} interval - Number of minutes of inactivity before auto-stopping.
|
|
323
|
+
* Set to 0 to disable auto-stop. Default is 15 minutes.
|
|
324
|
+
* @returns {Promise<void>}
|
|
325
|
+
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* // Auto-stop after 1 hour
|
|
329
|
+
* await workspace.setAutostopInterval(60);
|
|
330
|
+
* // Or disable auto-stop
|
|
331
|
+
* await workspace.setAutostopInterval(0);
|
|
130
332
|
*/
|
|
131
333
|
setAutostopInterval(interval: number): Promise<void>;
|
|
334
|
+
/**
|
|
335
|
+
* Gets the preview link for the workspace at a specific port. If the port is not open, it will open it and return the link.
|
|
336
|
+
* @param {number} port - The port to open the preview link on
|
|
337
|
+
* @returns {string} The preview link for the workspace at the specified port
|
|
338
|
+
* @throws {DaytonaError} If the node domain is not found in the provider metadata
|
|
339
|
+
*/
|
|
340
|
+
getPreviewLink(port: number): string;
|
|
341
|
+
/**
|
|
342
|
+
* Archives the workspace, making it inactive and preserving its state. When sandboxes are archived, the entire filesystem
|
|
343
|
+
* state is moved to cost-effective object storage, making it possible to keep sandboxes available for an extended period.
|
|
344
|
+
* The tradeoff between archived and stopped states is that starting an archived sandbox takes more time, depending on its size.
|
|
345
|
+
* Workspace must be stopped before archiving.
|
|
346
|
+
*/
|
|
347
|
+
archive(): Promise<void>;
|
|
132
348
|
}
|