@buddy-works/sandbox-sdk 0.1.5 → 0.1.6-rc.1

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.
Files changed (4) hide show
  1. package/README.md +73 -0
  2. package/dist/index.d.mts +574 -37
  3. package/dist/index.mjs +2035 -1518
  4. package/package.json +67 -65
package/README.md CHANGED
@@ -56,6 +56,7 @@ const sandbox = await Sandbox.create({
56
56
  os: "ubuntu:24.04",
57
57
  first_boot_commands: "apt-get update && apt-get install -y curl",
58
58
  apps: ["node server.js", "python worker.py"],
59
+ timeout: 600, // auto-stop after 10 minutes of inactivity
59
60
  });
60
61
 
61
62
  // List apps
@@ -73,6 +74,78 @@ const { logs } = await sandbox.getAppLogs(appId);
73
74
  console.log(logs);
74
75
  ```
75
76
 
77
+ ## Fetching repositories and artifacts
78
+
79
+ Use `fetch` to clone repositories or download artifacts into the sandbox on
80
+ first boot. Each entry sets a `type` (`PROJECT_REPO`, `PUBLIC_REPO`, or
81
+ `ARTIFACT`) plus the fields relevant to it.
82
+
83
+ ```typescript
84
+ await Sandbox.create({
85
+ identifier: "my-sandbox",
86
+ fetch: [
87
+ {
88
+ type: "PUBLIC_REPO",
89
+ repository: "https://github.com/octocat/Hello-World",
90
+ ref: "master",
91
+ path: "/workspace/hello",
92
+ build_command: "echo built",
93
+ },
94
+ ],
95
+ });
96
+ ```
97
+
98
+ ## Updating a sandbox
99
+
100
+ Use `sandbox.update()` to change configuration after creation - `timeout`, `apps`, `endpoints`, `variables`, `tags`, etc. The internal state is updated with the API's response.
101
+
102
+ ```typescript
103
+ const sandbox = await Sandbox.getByIdentifier("my-sandbox");
104
+
105
+ await sandbox.update({
106
+ timeout: 1200,
107
+ tags: ["staging", "feature-x"],
108
+ });
109
+ ```
110
+
111
+ ## Snapshots
112
+
113
+ Take point-in-time snapshots of a sandbox and restore from them later. Each snapshot is returned as a `Snapshot` instance with its own methods.
114
+
115
+ ```typescript
116
+ const sandbox = await Sandbox.getByIdentifier("my-sandbox");
117
+
118
+ // Create a snapshot. Returns immediately with status "CREATING".
119
+ const snapshot = await sandbox.createSnapshot({ name: "before-deploy" });
120
+
121
+ // Wait until the snapshot is "CREATED" before using it.
122
+ await snapshot.waitUntilReady();
123
+
124
+ // Create a new sandbox from the snapshot.
125
+ const restored = await Sandbox.createFromSnapshot(snapshot.id, {
126
+ name: "restored-sandbox",
127
+ });
128
+
129
+ // List all snapshots for this sandbox.
130
+ const snapshots = await sandbox.listSnapshots();
131
+
132
+ // Delete a snapshot.
133
+ await snapshot.delete();
134
+ ```
135
+
136
+ If you already have a snapshot ID from elsewhere (e.g. persisted in your own storage), get the entity directly:
137
+
138
+ ```typescript
139
+ const snapshot = await Sandbox.getSnapshotById(sandboxId, snapshotId);
140
+ ```
141
+
142
+ Equivalent convenience methods on `Sandbox` are available when you only have an ID and don't want to fetch the `Snapshot` first:
143
+
144
+ ```typescript
145
+ await sandbox.waitForSnapshotReady(snapshotId);
146
+ await sandbox.deleteSnapshot(snapshotId);
147
+ ```
148
+
76
149
  ## Regions
77
150
 
78
151
  Configure the API region: