@alibaba-group/opensandbox 0.1.2-dev4 → 0.1.3-dev1

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/README.md CHANGED
@@ -210,12 +210,24 @@ const config2 = new ConnectionConfig({
210
210
  | `resource` | CPU and memory limits (string map) | `{"cpu":"1","memory":"2Gi"}` |
211
211
  | `env` | Environment variables | `{}` |
212
212
  | `metadata` | Custom metadata tags | `{}` |
213
+ | `networkPolicy` | Optional outbound network policy (egress) | - |
213
214
  | `extensions` | Extra server-defined fields | `{}` |
214
215
  | `skipHealthCheck` | Skip readiness checks (`Running` + health check) | `false` |
215
216
  | `healthCheck` | Custom readiness check | - |
216
217
  | `readyTimeoutSeconds` | Max time to wait for readiness | 30 seconds |
217
218
  | `healthCheckPollingInterval` | Poll interval while waiting (milliseconds) | 200 ms |
218
219
 
220
+ ```ts
221
+ const sandbox = await Sandbox.create({
222
+ connectionConfig: config,
223
+ image: "python:3.11",
224
+ networkPolicy: {
225
+ defaultAction: "deny",
226
+ egress: [{ action: "allow", target: "pypi.org" }],
227
+ },
228
+ });
229
+ ```
230
+
219
231
  ### 3. Resource cleanup
220
232
 
221
233
  Both `Sandbox` and `SandboxManager` own a scoped HTTP agent when running on Node.js
@@ -1397,6 +1397,10 @@ var Sandbox = class _Sandbox {
1397
1397
  resourceLimits: opts.resource ?? DEFAULT_RESOURCE_LIMITS,
1398
1398
  env: opts.env ?? {},
1399
1399
  metadata: opts.metadata ?? {},
1400
+ networkPolicy: opts.networkPolicy ? {
1401
+ ...opts.networkPolicy,
1402
+ defaultAction: opts.networkPolicy.defaultAction ?? "deny"
1403
+ } : void 0,
1400
1404
  extensions: opts.extensions ?? {}
1401
1405
  };
1402
1406
  let sandboxId;