-
Notifications
You must be signed in to change notification settings - Fork 21
feat: support for agent sandboxes #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
MichaelGoberling
wants to merge
19
commits into
master
Choose a base branch
from
agent-sandboxes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
df5cd07
feat: add initial support for agent sandboxes on runtime
1ca7953
feat: get status and clean some things up
1129e18
nit: copyright dates + rename test files
650571f
feat: add region option and extract createSandboxHttpError helper
1672926
feat: file ops
bd5952d
fix: use node: prefix for node libs
01c944b
feat: network policies
6a85bc9
feat: add base sandbox network policies
5b2413e
fix: make netpols more sandbox specific
298cf0e
docs: sandbox
e07b6e3
docs: more sandbox netpol stuff
181ec4f
docs: policies differ
7773808
feat: allow sending stdin to processes
30a0da3
fix: no premade policies, we can't manage these client side
9a9df1e
feat: L7 egress rules
eb0cf0c
feat(sandbox): preview urls
10f5e2b
cleanup
0f027a9
Revert "cleanup"
af17eb0
feat: preview urls
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Sandbox Quickstart | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| npm install github:adobe/aio-lib-runtime#agent-sandboxes | ||
| ``` | ||
|
|
||
| ## Init | ||
|
|
||
| ```js | ||
| const { init } = require('@adobe/aio-lib-runtime') | ||
|
|
||
| const runtime = await init({ | ||
| apihost: process.env.AIO_RUNTIME_APIHOST, | ||
| namespace: process.env.AIO_RUNTIME_NAMESPACE, | ||
| api_key: process.env.AIO_RUNTIME_AUTH | ||
| }) | ||
| ``` | ||
|
|
||
| ## Create Sandbox | ||
|
|
||
| ```js | ||
| const sandbox = await runtime.compute.sandbox.create({ | ||
| name: 'my-sandbox', | ||
| type: 'cpu:nodejs', | ||
| workspace: 'workspace', | ||
| maxLifetime: 3600, | ||
| envs: { | ||
| API_KEY: 'your-api-key' | ||
| } | ||
| }) | ||
| ``` | ||
|
|
||
| ## Get Status | ||
|
|
||
| ```js | ||
| const status = await runtime.compute.sandbox.getStatus(sandbox.id) | ||
| console.log('status:', status) | ||
| ``` | ||
|
|
||
| ## Preview URLs | ||
|
|
||
| Use preview URLs to get access to servers or web services running in a sandbox on a particular port: | ||
|
|
||
| ```js | ||
| const url = await sandbox.getUrl({ port: 3000 }) | ||
| console.log('preview:', url) | ||
| // https://sb-abc123-va6-0-xK3mPq2nAeB-3000.sandbox-adobeioruntime.net | ||
| ``` | ||
|
|
||
| ## Exec | ||
|
|
||
| ```js | ||
| const result = await sandbox.exec('ls -al', { timeout: 10000 }) | ||
| console.log('stdout:', result.stdout.trim()) | ||
| console.log('exit code:', result.exitCode) | ||
| ``` | ||
|
|
||
| ## File Management | ||
|
|
||
| ```js | ||
| const script = `console.log('hello from sandbox script', process.version)\n` | ||
| await sandbox.writeFile('hello.js', script) | ||
|
|
||
| const content = await sandbox.readFile('hello.js') | ||
| console.log('readFile content:', content.trim()) | ||
|
|
||
| const entries = await sandbox.listFiles('.') | ||
| console.log('listFiles entries:', entries) | ||
| ``` | ||
|
|
||
| ## Exec a File | ||
|
|
||
| ```js | ||
| const result = await sandbox.exec('node hello.js', { timeout: 10000 }) | ||
| console.log('stdout:', result.stdout.trim()) | ||
| console.log('stderr:', result.stderr.trim()) | ||
| console.log('exit code:', result.exitCode) | ||
| ``` | ||
|
|
||
| ## Curl a Site | ||
|
|
||
| ```js | ||
| const result = await sandbox.exec('curl -s --connect-timeout 5 -o /dev/null -w "%{http_code}" https://github.com', { timeout: 10000 }) | ||
| console.log(` github.com (allowed) → HTTP ${result.stdout.trim()}`) | ||
| ``` | ||
|
|
||
| ## Write to Stdin | ||
|
|
||
| ### Command start | ||
| ```js | ||
| const result = await sandbox.exec('python process_csv.py', { | ||
| stdin: 'col1,col2\nval1,val2\n', | ||
| timeout: 10000 | ||
| }) | ||
| console.log('stdout:', result.stdout.trim()) | ||
| ``` | ||
|
|
||
| ### Running command | ||
| ```js | ||
| const execPromise = sandbox.exec('cat') | ||
| sandbox.writeStdin(execPromise.execId, 'line 1\n') | ||
| sandbox.writeStdin(execPromise.execId, 'line 2\n') | ||
| sandbox.closeStdin(execPromise.execId) | ||
|
|
||
| const result = await execPromise | ||
| console.log('stdout:', result.stdout.trim()) | ||
| ``` | ||
|
|
||
| ## Destroy | ||
|
|
||
| ```js | ||
| await sandbox.destroy() | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Network Policies | ||
|
|
||
| Sandboxes are default-deny. All outbound traffic is blocked unless explicitly allowed. | ||
|
|
||
| Pass a `policy.network.egress` array at creation time to allowlist outbound endpoints, paths, or HTTP verbs. | ||
|
|
||
| ```js | ||
| const sandbox = await runtime.compute.sandbox.create({ | ||
| name: 'policy-sandbox', | ||
| workspace: 'policy-test', | ||
| maxLifetime: 300, | ||
| policy: { | ||
| network: { | ||
| egress: [ | ||
| { host: 'httpbin.org', port: 443 }, | ||
| { | ||
| host: 'api.github.com', | ||
| port: 443, | ||
| rules: [{ methods: ['GET'], pathPattern: '/repos/**' }] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }) | ||
| ``` | ||
|
|
||
| ### Allow All (Not recommended for production) | ||
|
|
||
| ```js | ||
| const sandbox = await runtime.compute.sandbox.create({ | ||
| name: 'policy-allow-all', | ||
| workspace: 'policy-test', | ||
| maxLifetime: 300, | ||
| policy: { network: { egress: 'allow-all' } } | ||
| }) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| Copyright 2026 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| const SandboxAPI = require('./SandboxAPI') | ||
|
|
||
| /** | ||
| * Compute management API. | ||
| */ | ||
| class ComputeAPI { | ||
| /** | ||
| * @param {string} apiHost Runtime API host | ||
| * @param {string} namespace Runtime namespace | ||
| * @param {string} apiKey Runtime auth key | ||
| * @param {object} [options] SDK transport options | ||
| */ | ||
| constructor (apiHost, namespace, apiKey, options = {}) { | ||
| this.sandbox = new SandboxAPI(apiHost, namespace, apiKey, options) | ||
| } | ||
| } | ||
|
|
||
| module.exports = ComputeAPI | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright year reads '2026' which is in the future. Same issue exists in Sandbox.js and SandboxAPI.js.