-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from e2b-dev/js-sdk
Add JS SDK & video stream support
- Loading branch information
Showing
35 changed files
with
3,935 additions
and
2,069 deletions.
There are no files selected for viewing
This file contains 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,84 @@ | ||
name: Test Decktop SDK Packages | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
E2B_API_KEY: | ||
required: true | ||
NPM_TOKEN: | ||
required: true | ||
PYPI_TOKEN: | ||
required: true | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
test: | ||
name: Build and test SDK | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install and configure Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.5.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
|
||
- uses: pnpm/action-setup@v3 | ||
with: | ||
version: 9.5 | ||
|
||
- name: Setup Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
cache: pnpm | ||
|
||
- name: Configure pnpm | ||
run: | | ||
pnpm config set auto-install-peers true | ||
pnpm config set exclude-links-from-lockfile true | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Create new versions | ||
run: pnpm run version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Release new versions | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm run publish | ||
createGithubReleases: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
|
||
- name: Generate API Ref | ||
run: pnpm run generate-api-reference | ||
|
||
- name: Update lock file | ||
run: pnpm i --no-link --no-frozen-lockfile | ||
|
||
- name: Commit new versions | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add apps/web/src/app/\(docs\)/docs/api-reference | ||
git commit -am "[skip ci] Release new versions" || exit 0 | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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,55 @@ | ||
import { config } from 'dotenv' | ||
// import Tesseract from 'tesseract.js' | ||
import { createCanvas, loadImage } from 'canvas' | ||
import fs from 'fs' | ||
|
||
config() | ||
import { Sandbox } from './dist' | ||
|
||
|
||
|
||
const sbx = await Sandbox.create({ | ||
videoStream: true, | ||
onVideoStreamStart: (url) => console.log('Video stream started:', url) | ||
}) | ||
|
||
// const command = "ffmpeg -video_size 1024x768 -f x11grab -i :99 -c:v libx264 -c:a aac -g 50 -b:v 4000k -maxrate 4000k -bufsize 8000k -f flv rtmp://global-live.mux.com:5222/app/stream-key" | ||
// const ffmpeg = await sbx.commands.run(command, { background: true, onStdout: (data) => console.log(data.toString()) }) | ||
|
||
for (let i = 0; i < 30; i++) { | ||
const x = Math.floor(Math.random() * 1024); | ||
const y = Math.floor(Math.random() * 768); | ||
await sbx.moveMouse(x, y); | ||
await new Promise(resolve => setTimeout(resolve, 2000)); | ||
await sbx.rightClick(); | ||
console.log('right clicked', i) | ||
} | ||
|
||
|
||
// await sbx.kill() | ||
|
||
|
||
// // await sbx.rightClick() | ||
// let imageData = await sbx.takeScreenshot() | ||
// await processImage(imageData) | ||
// // const pos = await sbx.locateTextOnScreen('Applications') | ||
// // if (!pos) throw new Error('Text not found on screen') | ||
// await sbx.moveMouse(384 + 150, 1024 - 80) | ||
// // await new Promise(resolve => setTimeout(resolve, 5000)); | ||
// await sbx.doubleClick() | ||
// // await sbx.leftClick() | ||
// console.log('clicked') | ||
// await new Promise(resolve => setTimeout(resolve, 2000)); | ||
// console.log('screenshot') | ||
// imageData = await sbx.takeScreenshot() | ||
// await processImage(imageData) | ||
// await sbx.kill() | ||
|
||
|
||
|
||
|
||
// { | ||
// text: 'File System', | ||
// confidence: 95.43375396728516, | ||
// bbox: { x0: 33, y0: 228, x1: 107, y1: 241 } | ||
// } |
This file contains 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,62 @@ | ||
{ | ||
"name": "@e2b/desktop", | ||
"version": "1.0.0", | ||
"description": "E2B Desktop Sandbox - isolated cloud environment with a desktop-like interface powered by E2B. Ready for AI Computer Use", | ||
"author": { | ||
"name": "FoundryLabs, Inc.", | ||
"email": "[email protected]", | ||
"url": "https://e2b.dev" | ||
}, | ||
"keywords": [ | ||
"e2b", | ||
"ai-agents", | ||
"agents", | ||
"ai", | ||
"computer-use", | ||
"sandbox", | ||
"code", | ||
"runtime", | ||
"vm" | ||
], | ||
"bugs": "https://github.com/e2b-dev/desktop/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/e2b-dev/desktop", | ||
"directory": "packages/js-sdk" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"dist", | ||
"README.md", | ||
"package.json" | ||
], | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"browserslist": [ | ||
"defaults" | ||
], | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc --noEmit && tsup", | ||
"example": "tsx example.mts", | ||
"dev": "tsup --watch", | ||
"test": "vitest run --disable-console-intercept", | ||
"test:coverage": "vitest run --coverage" | ||
}, | ||
"devDependencies": { | ||
"canvas": "^2.11.2", | ||
"dotenv": "^16.4.5", | ||
"tsup": "^8.3.5", | ||
"tsx": "^4.19.2", | ||
"typescript": "^5.6.3", | ||
"vitest": "^2.1.5" | ||
}, | ||
"dependencies": { | ||
"e2b": "^1.0.5" | ||
} | ||
} |
This file contains 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,3 @@ | ||
export * from 'e2b' | ||
|
||
export { Sandbox } from './sandbox' |
Oops, something went wrong.