Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08aa0d69b6 | |||
| 81c2d2e6df | |||
| d80854deae |
@@ -51,10 +51,11 @@ On the deployment host, provision `/opt/endoleap-infra/foundry/codex` with:
|
||||
Keep this home dedicated to the worker. Supply the login only and keep user
|
||||
configuration, MCP servers, skills, and other workload files out of it.
|
||||
|
||||
Start the single worker with `bash deploy/codex-worker.sh /absolute/path/to/foundry`
|
||||
using the Linux binary built by ces-control. To replace the worker, stop and remove
|
||||
the existing `foundry-codex-worker` container first. The next normal Foundry
|
||||
deployment mounts the worker socket and grants directory read-only. The worker
|
||||
With that directory configured, the next normal Foundry deployment starts the
|
||||
worker using the Linux binary built by ces-control and mounts the worker socket
|
||||
and grants directory read-only. To replace an existing worker, stop and remove
|
||||
its container, then run `bash deploy/codex-worker.sh /absolute/path/to/foundry`
|
||||
with the desired ces-control build. The worker
|
||||
runs the installed Codex CLI with fixed read-only, no-approval arguments and
|
||||
disables command execution tools. It receives prompts via stdin and returns
|
||||
the final agent message. The worker has no published port and Foundry receives
|
||||
|
||||
@@ -7,7 +7,8 @@ binary=$(realpath "$1")
|
||||
test -x "$binary"
|
||||
test -s "$dir/home/auth.json"
|
||||
test -s "$dir/grants/projects.json"
|
||||
install -d -m 700 -o 1000 -g 1000 "$dir/run"
|
||||
install -d -m 700 "$dir/run"
|
||||
chown 1000:1000 "$dir/run"
|
||||
|
||||
# The host operator supplies an isolated Codex home and starts a single worker.
|
||||
# The Docker default bridge supplies egress independently of Foundry's network.
|
||||
|
||||
@@ -47,6 +47,13 @@ export HOST=0.0.0.0 PORT=8080 PUBLIC_ORIGIN="$origin"
|
||||
codex_mounts=()
|
||||
codex_dir=$foundry/codex
|
||||
if [[ -d "$codex_dir" ]]; then
|
||||
if ! docker inspect -f '{{.State.Running}}' foundry-codex-worker 2>/dev/null | grep -qx true; then
|
||||
bash "$(dirname "$0")/codex-worker.sh" "$release/foundry" >/dev/null
|
||||
fi
|
||||
for attempt in {1..20}; do
|
||||
[[ ! -S "$codex_dir/run/worker.sock" ]] || break
|
||||
sleep 0.25
|
||||
done
|
||||
test -S "$codex_dir/run/worker.sock"
|
||||
test -s "$codex_dir/grants/projects.json"
|
||||
codex_mounts=(
|
||||
@@ -87,6 +94,10 @@ docker exec "$candidate" node -e '
|
||||
const project = Object.keys(JSON.parse(process.env.FOUNDRY_PROJECTS))[0];
|
||||
const route = base + "/projects/" + encodeURIComponent(project) + "/auth";
|
||||
assert.equal((await fetch(route + "/me")).status, 401);
|
||||
if (process.env.FOUNDRY_CODEX_SOCKET) {
|
||||
const exec = base + "/projects/" + encodeURIComponent(project) + "/codex/exec";
|
||||
assert.equal((await fetch(exec, {method: "POST"})).status, 401);
|
||||
}
|
||||
}
|
||||
verify().catch(() => { console.error("Foundry readiness or anonymous access check failed"); process.exit(1); });
|
||||
'
|
||||
|
||||
@@ -20,16 +20,16 @@ const executable = "/opt/codex/node_modules/.bin/codex"
|
||||
var errOutputLimit = errors.New("Codex output limit exceeded")
|
||||
|
||||
type outputBuffer struct {
|
||||
bytes.Buffer
|
||||
buffer bytes.Buffer
|
||||
exceeded bool
|
||||
}
|
||||
|
||||
func (b *outputBuffer) Write(p []byte) (int, error) {
|
||||
if len(p) > maxOutput-b.Len() {
|
||||
if len(p) > maxOutput-b.buffer.Len() {
|
||||
b.exceeded = true
|
||||
return 0, errOutputLimit
|
||||
}
|
||||
return b.Buffer.Write(p)
|
||||
return b.buffer.Write(p)
|
||||
}
|
||||
|
||||
func ServeWorker(socket string) error {
|
||||
@@ -97,7 +97,7 @@ func execute(w http.ResponseWriter, r *http.Request, prompt string) {
|
||||
default:
|
||||
var result string
|
||||
var completed bool
|
||||
for _, line := range bytes.Split(bytes.TrimSpace(output.Bytes()), []byte("\n")) {
|
||||
for _, line := range bytes.Split(bytes.TrimSpace(output.buffer.Bytes()), []byte("\n")) {
|
||||
var event struct {
|
||||
Type string `json:"type"`
|
||||
Item struct {
|
||||
|
||||
Reference in New Issue
Block a user