-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
77 lines (64 loc) · 2.25 KB
/
flake.nix
File metadata and controls
77 lines (64 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{
description = "Run the Agent Computer sandbox locally via Docker";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
version = "latest";
image = "ghcr.io/getcompanion-ai/computer-harness";
computer-harness = pkgs.writeShellScriptBin "computer-harness" ''
set -euo pipefail
IMAGE="${image}:${version}"
UI_PORT="''${COMPUTER_UI_PORT:-8080}"
VNC_PORT="''${COMPUTER_VNC_PORT:-6080}"
SSH_PORT="''${COMPUTER_SSH_PORT:-2222}"
# Pull latest image if not present
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
echo "Pulling $IMAGE ..."
docker pull "$IMAGE"
fi
ENV_ARGS=()
# Forward agent API keys from the host environment
for var in ANTHROPIC_API_KEY OPENAI_API_KEY OPENCODE_API_KEY; do
if [ -n "''${!var:-}" ]; then
ENV_ARGS+=(-e "$var=''${!var}")
fi
done
# Forward any extra env vars the user passes via COMPUTER_ENV
# e.g. COMPUTER_ENV="-e FOO=bar -e BAZ=qux"
# shellcheck disable=SC2206
EXTRA_ENV=(''${COMPUTER_ENV:-})
echo "Starting Agent Computer sandbox"
echo " UI: http://localhost:$UI_PORT"
echo " VNC: http://localhost:$VNC_PORT/vnc.html?autoconnect=1"
echo " SSH: ssh -p $SSH_PORT node@localhost"
echo ""
exec docker run --rm -it \
-p "''${UI_PORT}:8080" \
-p "''${VNC_PORT}:6080" \
-p "''${SSH_PORT}:2222" \
"''${ENV_ARGS[@]}" \
"''${EXTRA_ENV[@]}" \
"$@" \
"$IMAGE"
'';
in
{
packages = {
default = computer-harness;
computer-harness = computer-harness;
};
apps.default = {
type = "app";
program = "${computer-harness}/bin/computer-harness";
};
devShells.default = pkgs.mkShell {
packages = [ computer-harness ];
};
}
);
}