Skip to content

Commit 0e45903

Browse files
committed
initial commit
0 parents  commit 0e45903

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7485
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
out/
3+
vendor/
4+
*.out
5+
dist/

.goreleaser.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
builds:
4+
-
5+
env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
goarch:
10+
- 386
11+
- amd64
12+
- arm
13+
- arm64
14+
binary: eleven-agent
15+
checksum:
16+
name_template: 'checksums.txt'
17+
snapshot:
18+
name_template: "{{ incpatch .Version }}-next"
19+
changelog:
20+
sort: asc
21+
filters:
22+
exclude:
23+
- '^docs:'
24+
- '^test:'

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2022 Jeremy Levy jje.levy@gmail.com
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Agent
2+
3+
This repository contains the source code of the Eleven agent.
4+
5+
The Eleven agent is installed in the instance running your sandbox during its creation (most of the time via `cloud-init` but it may vary depending on the cloud provider used).
6+
7+
The main role of this agent is to enable communication between your sandboxes, the [CLI](https://github.com/eleven-sh/cli) and your code editor.
8+
9+
## License
10+
11+
Eleven is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

build.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# Eleven agent builder
3+
set -euo pipefail
4+
5+
log () {
6+
echo -e "${1}" >&2
7+
}
8+
9+
SUPPORTED_PLATFORMS=("linux/amd64" "linux/386" "linux/arm" "linux/arm64")
10+
11+
for platform in "${SUPPORTED_PLATFORMS[@]}"
12+
do
13+
platform_parts=(${platform//\// })
14+
platform_os="${platform_parts[0]}"
15+
platform_arch="${platform_parts[1]}"
16+
bin_name="agent-${platform_os}-${platform_arch}"
17+
18+
log "Building agent for ${platform_os}/${platform_arch}..."
19+
20+
env GOOS="${platform_os}" GOARCH="${platform_arch}" go build -o "out/${bin_name}" main.go
21+
if [ $? -ne 0 ]; then
22+
log "An error occured duing build for ${platform_os}/${platform_arch}!"
23+
exit 1
24+
fi
25+
done

config/env.go

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package config
2+
3+
import (
4+
"path/filepath"
5+
6+
"github.com/eleven-sh/eleven/entities"
7+
)
8+
9+
const (
10+
ElevenConfigDirPath = "/eleven"
11+
12+
ElevenAgentConfigDirPath = ElevenConfigDirPath + "/agent"
13+
ElevenAgentConfigFilePath = ElevenAgentConfigDirPath + "/config.json"
14+
15+
VSCodeConfigDirPath = ElevenConfigDirPath + "/vscode"
16+
17+
ElevenUserName = "eleven"
18+
ElevenUserHomeDirPath = "/home/" + ElevenUserName
19+
ElevenUserShellPath = "/usr/bin/zsh"
20+
21+
WorkspaceDirPath = ElevenUserHomeDirPath + "/workspace"
22+
)
23+
24+
var EnvReservedPorts = []string{
25+
DefaultSSHServerListenPort,
26+
SSHServerListenPort,
27+
HTTPServerListenPort,
28+
HTTPSServerListenPort,
29+
CaddyAPIListenPort,
30+
}
31+
32+
func GetVSCodeWorkspaceConfigFilePath(envName string) string {
33+
return filepath.Join(
34+
VSCodeConfigDirPath,
35+
entities.BuildSlugForEnv(envName)+".code-workspace",
36+
)
37+
}

config/grpc.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package config
2+
3+
const (
4+
GRPCServerAddrProtocol = "unix"
5+
GRPCServerAddr = ElevenAgentConfigDirPath + "/grpc-server.sock"
6+
GRPCServerURI = "unix://" + GRPCServerAddr
7+
)

config/http.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package config
2+
3+
const (
4+
HTTPServerListenPort = "80"
5+
HTTPSServerListenPort = "443"
6+
CaddyAPIListenPort = "2019"
7+
)

config/ssh.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package config
2+
3+
const (
4+
DefaultSSHServerListenPort = "22"
5+
SSHServerListenPort = "2200"
6+
SSHServerListenAddr = ":" + SSHServerListenPort
7+
SSHServerHostKeyFilePath = ElevenUserHomeDirPath + "/.ssh/eleven-ssh-server-host-key"
8+
9+
ElevenUserAuthorizedSSHKeysFilePath = ElevenUserHomeDirPath + "/.ssh/authorized_keys"
10+
GitHubPublicSSHKeyFilePath = ElevenUserHomeDirPath + "/.ssh/" + ElevenUserName + "-github.pub"
11+
)

go.mod

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module github.com/eleven-sh/agent
2+
3+
go 1.17
4+
5+
replace github.com/eleven-sh/eleven v0.0.0 => ../eleven
6+
7+
require (
8+
github.com/gliderlabs/ssh v0.3.3
9+
golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000
10+
)
11+
12+
require (
13+
github.com/briandowns/spinner v1.19.0
14+
github.com/creack/pty v1.1.17
15+
github.com/eleven-sh/eleven v0.0.0
16+
github.com/jwalton/gchalk v1.3.0
17+
github.com/prometheus/procfs v0.8.0
18+
google.golang.org/grpc v1.49.0
19+
google.golang.org/protobuf v1.28.1
20+
)
21+
22+
require (
23+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
24+
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
25+
github.com/fatih/color v1.7.0 // indirect
26+
github.com/golang/protobuf v1.5.2 // indirect
27+
github.com/google/go-github/v43 v43.0.0 // indirect
28+
github.com/google/go-querystring v1.1.0 // indirect
29+
github.com/google/uuid v1.3.0 // indirect
30+
github.com/gosimple/slug v1.12.0 // indirect
31+
github.com/gosimple/unidecode v1.0.1 // indirect
32+
github.com/jwalton/go-supportscolor v1.1.0 // indirect
33+
github.com/mattn/go-colorable v0.1.2 // indirect
34+
github.com/mattn/go-isatty v0.0.8 // indirect
35+
github.com/whilp/git-urls v1.0.0 // indirect
36+
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
37+
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
38+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
39+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
40+
golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b // indirect
41+
google.golang.org/appengine v1.6.7 // indirect
42+
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
43+
)

0 commit comments

Comments
 (0)