diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ba103fb61..843134d87 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -129,8 +129,9 @@ jobs: # Windows (#1520): core and the laptop proxy must keep building, and the session archive and # cost ledger must keep writing where a directory is flushed only through a write handle and # cannot be renamed with a file open in it. Only those packages' tests run: the rest of core - # and cmd/cortex still have Unix-only tests (Setpgid, SIGUSR1), and agentop does not build - # yet. No -race: the race detector needs cgo and a C toolchain on the runner. + # and cmd/cortex still have Unix-only tests (Setpgid, SIGUSR1). agentop builds, but most of + # its tests need a Unix shell or service manager, so only a named set runs (see its step). + # No -race: the race detector needs cgo and a C toolchain on the runner. go-ci-windows: name: Go CI (Windows build, archive and ledger) runs-on: windows-latest @@ -188,6 +189,23 @@ jobs: go vet ./... go test -run 'TestRefuseUnsupported|TestProcessAlive|TestLockFile|TestWritable|TestTerminateRefusesOnWindows|TestNoRecordWanted|TestWithRecordOff|TestAddRecordOff' . + # release-binaries.yaml builds every platform in one loop, so a Windows build break would + # stop the Linux and macOS releases too, and main-latest on every merge. Build exactly its + # Windows targets here: cortex with the release's proxy variant (the full profile) and + # agentop, for amd64 and arm64, with cgo off as the release does. Keep the tags in step + # with proxy_variants there. + - name: Build the release's Windows targets + run: | + set -euo pipefail + full_tags=$(go -C scripts/profile-tags run . full) + for arch in amd64 arm64; do + echo "==> windows/${arch}" + ( cd cmd/cortex && CGO_ENABLED=0 GOOS=windows GOARCH="${arch}" \ + go build -trimpath -tags "${full_tags}" -o /dev/null . ) + ( cd cmd/agentop && CGO_ENABLED=0 GOOS=windows GOARCH="${arch}" \ + go build -trimpath -o /dev/null . ) + done + # The cpex plugin's FFI-backed code sits behind the `cpex` build tag and needs # cgo plus the pinned libcpex_ffi.a, so no other job compiles or tests it. It # runs in Alpine to link the same musl asset the authbridge-cpex image does, diff --git a/.github/workflows/release-binaries.yaml b/.github/workflows/release-binaries.yaml index 639fb3c28..910f61c43 100644 --- a/.github/workflows/release-binaries.yaml +++ b/.github/workflows/release-binaries.yaml @@ -135,7 +135,7 @@ jobs: with: go-version-file: cmd/cortex/go.mod - - name: Build binaries (linux/darwin, amd64/arm64) + - name: Build binaries (linux/darwin/windows, amd64/arm64) run: | set -euo pipefail mkdir -p dist @@ -151,35 +151,46 @@ jobs: ":${full_tags}" ) + # pack : a .tar.gz, or on Windows a + # .zip of the .exe (#1520), the format a Windows user can open without tools. + pack() { + local os="$1" archive="$2" bin="$3" + if [ "${os}" = windows ]; then + ( cd dist && zip -q "${archive#dist/}.zip" "${bin}" ) + else + tar -C dist -czf "${archive}.tar.gz" "${bin}" + fi + rm -f "dist/${bin}" + } + build_proxy() { local variant="$1" tags="$2" os="$3" arch="$4" local suffix=""; [ -n "${variant}" ] && suffix="-${variant}" + local bin="cortex"; [ "${os}" = windows ] && bin="cortex.exe" # ${TAG}, not ${VERSION}: the filename has to match the download URL the # installer builds from the release tag. They are the same string for a # v* tag and differ only on the rolling channel release. - local archive="dist/cortex${suffix}_${TAG}_${os}_${arch}.tar.gz" echo "==> cortex${suffix} ${os}/${arch}" ( cd cmd/cortex && \ GOWORK=off CGO_ENABLED=0 GOOS="${os}" GOARCH="${arch}" \ go build -trimpath \ -tags "${tags}" \ -ldflags "-s -w -X main.version=${VERSION}" \ - -o "${GITHUB_WORKSPACE}/dist/cortex" . ) - tar -C dist -czf "${archive}" cortex - rm -f dist/cortex + -o "${GITHUB_WORKSPACE}/dist/${bin}" . ) + pack "${os}" "dist/cortex${suffix}_${TAG}_${os}_${arch}" "${bin}" } - for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do + for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do os="${target%/*}"; arch="${target#*/}" + bin="agentop"; [ "${os}" = windows ] && bin="agentop.exe" echo "==> agentop ${os}/${arch}" ( cd cmd/agentop && \ GOWORK=off CGO_ENABLED=0 GOOS="${os}" GOARCH="${arch}" \ go build -trimpath \ -ldflags "-s -w -X main.version=${VERSION}" \ - -o "${GITHUB_WORKSPACE}/dist/agentop" . ) - tar -C dist -czf "dist/agentop_${TAG}_${os}_${arch}.tar.gz" agentop - rm -f dist/agentop + -o "${GITHUB_WORKSPACE}/dist/${bin}" . ) + pack "${os}" "dist/agentop_${TAG}_${os}_${arch}" "${bin}" for entry in "${proxy_variants[@]}"; do build_proxy "${entry%%:*}" "${entry#*:}" "${os}" "${arch}" @@ -191,7 +202,9 @@ jobs: uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: dist-go - path: dist/*.tar.gz + path: | + dist/*.tar.gz + dist/*.zip if-no-files-found: error retention-days: 1 @@ -313,10 +326,11 @@ jobs: # main-latest the prune below deletes whatever dist/ lacks, so a silent gap # here would also remove the previous build's asset from the release. missing="" - for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do + for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do os="${target%/*}"; arch="${target#*/}" + ext="tar.gz"; [ "${os}" = windows ] && ext="zip" for name in agentop cortex; do - f="dist/${name}_${TAG}_${os}_${arch}.tar.gz" + f="dist/${name}_${TAG}_${os}_${arch}.${ext}" [ -s "${f}" ] || missing="${missing} ${f}" done done @@ -336,7 +350,7 @@ jobs: p="${TAG}_${target%/*}_${target#*/}.tar.gz" cp "dist/cortex_${p}" "dist/cortex-cpex_${p}" done - ( cd dist && sha256sum ./*.tar.gz > checksums.txt ) + ( cd dist && sha256sum ./*.tar.gz ./*.zip > checksums.txt ) ls -l dist cat dist/checksums.txt @@ -345,7 +359,9 @@ jobs: if: github.event_name == 'push' uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: - subject-path: dist/*.tar.gz + subject-path: | + dist/*.tar.gz + dist/*.zip - name: Publish to GitHub Release # A main push publishes too, which is the whole point of the channel; the @@ -392,7 +408,8 @@ jobs: echo "::warning::Could not list the changes since the previous release; publishing ${TAG} without them." fi fi - add 'Prebuilt `agentop` and `cortex` binaries for linux and macOS (amd64/arm64).' + add 'Prebuilt `agentop` and `cortex` binaries for linux and macOS (amd64/arm64),' + add 'and a Windows preview (see below).' # The laptop cpex build is gone. Drop this, and the cortex-cpex_* copies above, # once no supported release ships a cpex laptop build. add 'The laptop cpex build is removed. `cortex-cpex_*` is a copy of `cortex_*`,' @@ -407,8 +424,8 @@ jobs: add '`cortex-gateway_*` is the praxis-mode gateway (static on linux).' add 'Install it with `install.sh --praxis`.' fi - add 'Every tarball carries build provenance:' - add '`gh attestation verify --repo rossoctl/cortex`.' + add 'Every archive (`.tar.gz` and `.zip`) carries build provenance:' + add '`gh attestation verify --repo rossoctl/cortex`.' add '' # The rename shipped with no alias, so it has to be said somewhere a v0.7.0 # user will look. Drop this once no supported release predates it. @@ -418,8 +435,9 @@ jobs: add '`authbridge-*`); image and container names are unchanged. Setup removes the old' add 'binary once the service no longer runs it. Stop a proxy you started by hand first.' add '' - add 'Verify downloads with `sha256sum -c checksums.txt`. On macOS, clear the' - add 'Gatekeeper quarantine after extracting: `xattr -dr com.apple.quarantine ./agentop`.' + add 'Verify downloads with `sha256sum -c checksums.txt`, which lists the `.zip` files too.' + add 'On macOS, clear the Gatekeeper quarantine after extracting:' + add '`xattr -dr com.apple.quarantine ./agentop`.' # Whoever is asked to try a release candidate lands on this page, and the # one-liner they already know will not install it. if [ -n "${prerelease}" ]; then @@ -440,6 +458,18 @@ jobs: add 'Each binary reports its own build (`agentop --version` -> `main-`). For a' add 'supported install, use the plain one-liner, which installs the newest stable release.' fi + # Windows (#1520), after the channel-specific block above, which replaces the notes + # on main-latest: every release with Windows archives keeps this guidance. + add '' + add '## Windows (preview)' + add '' + add '`agentop_*_windows_*.zip` and `cortex_*_windows_*.zip` (amd64/arm64). No installer' + add 'runs on Windows yet: check each `.zip` with' + add '`(Get-FileHash -Algorithm SHA256).Hash.ToLower()` against `checksums.txt`,' + add 'run `Unblock-File ` on it (the binaries are unsigned, so SmartScreen may block' + add 'them otherwise), and extract both onto your PATH. Then, in a NEW terminal (an open one' + add 'keeps the old PATH), run `cortex --local`, and `agentop observe` in another. `agentop service`, `setup`, `uninstall`' + add 'and `update` are not supported there yet. See docs/getting-started.md.' if gh release view "${TAG}" >/dev/null 2>&1; then # Uploading assets does not move the tag, so on a REUSED tag the release # would keep pointing at its first-publish commit forever: the "Source @@ -451,7 +481,7 @@ jobs: gh api --method PATCH "repos/${GITHUB_REPOSITORY}/git/refs/tags/${TAG}" \ -f sha="${GITHUB_SHA}" -F force=true >/dev/null fi - gh release upload "${TAG}" dist/*.tar.gz dist/checksums.txt --clobber + gh release upload "${TAG}" dist/*.tar.gz dist/*.zip dist/checksums.txt --clobber # --clobber replaces same-named assets but never deletes others, so every # name this build stops producing lingers on the rolling release: frozen at # its last build, and missing from checksums.txt, so nothing can verify it. @@ -489,7 +519,7 @@ jobs: # built. Usually the same on a main push, but it is exactly the drift the # PATCH above exists to prevent — and it made the FIRST publish create the # tag at the wrong commit, so the two paths disagreed. - gh release create "${TAG}" dist/*.tar.gz dist/checksums.txt \ + gh release create "${TAG}" dist/*.tar.gz dist/*.zip dist/checksums.txt \ --target "${GITHUB_SHA}" \ --title "${TAG}" --notes "${notes}" ${prerelease} fi diff --git a/cmd/cortex/local.go b/cmd/cortex/local.go index 6b04564e5..20ca3cd9f 100644 --- a/cmd/cortex/local.go +++ b/cmd/cortex/local.go @@ -9,6 +9,7 @@ import ( "log/slog" "os" "path/filepath" + "strings" "github.com/rossoctl/cortex/core/clientstate" "github.com/rossoctl/cortex/core/config" @@ -162,6 +163,14 @@ func parseBridgeCAPEM(pemBytes []byte) *x509.Certificate { return crt } +// yamlSingleQuoted is s as a YAML single-quoted scalar. In single quotes a backslash is a plain +// character and the only escape is a doubled single quote, so a Windows path such as +// C:\Users\me\.cortex\ca reads back unchanged. In double quotes \U and \. are escape sequences, +// and a fresh install's config did not load (#1520). +func yamlSingleQuoted(s string) string { + return "'" + strings.ReplaceAll(s, "'", "''") + "'" +} + // builtinConfigYAML returns the built-in --local config with caDir interpolated: a // forward-only proxy with the TLS bridge on (auto-generated CA in caDir) and // the LLM / MCP / A2A parsers, so an agent's egress is decrypted and parsed. @@ -213,7 +222,7 @@ stats: address: 127.0.0.1:47602 tls_bridge: mode: enabled - ca_dir: "` + caDir + `" + ca_dir: ` + yamlSingleQuoted(caDir) + ` generate_ca: true # passthrough_hosts is deliberately absent. Left unset, the bridge tunnels a # built-in list of developer-tooling hosts — GitHub, the Go module proxy, the diff --git a/cmd/cortex/local_test.go b/cmd/cortex/local_test.go index 5fa186ca1..65fde033b 100644 --- a/cmd/cortex/local_test.go +++ b/cmd/cortex/local_test.go @@ -27,6 +27,31 @@ import ( "github.com/rossoctl/cortex/core/session" ) +// The CA dir in the generated config reads back exactly, on every OS: a Windows path holds +// backslashes, and in a double-quoted YAML scalar \U and \. are escapes, so a fresh install on +// Windows wrote a config it could not load (#1520). A quote in the path is kept too. +func TestDemoConfig_CADirRoundTrips(t *testing.T) { + for _, caDir := range []string{ + `C:\Users\me\.cortex\ca`, + `C:\Users\new\dir\notes\x\nca`, // \n, \x and \U are escapes in double quotes + `/home/me/.cortex/ca`, + `/home/o'brien/.cortex/ca`, + } { + cortexDir := t.TempDir() + p, err := writeBuiltinConfig(cortexDir, caDir) + if err != nil { + t.Fatalf("%s: writeBuiltinConfig: %v", caDir, err) + } + cfg, err := config.Load(p) + if err != nil { + t.Fatalf("%s: Load: %v", caDir, err) + } + if cfg.TLSBridge.CADir != caDir { + t.Errorf("CADir = %q, want %q", cfg.TLSBridge.CADir, caDir) + } + } +} + // writeBuiltinConfig must produce a config file in cortexDir that loads, presets, // and validates cleanly and describes a forward-only TLS-bridge observe // pipeline pointed at caDir — otherwise --local would fail at boot instead of diff --git a/docs/getting-started.md b/docs/getting-started.md index 7ba5e06ab..28222e169 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -27,6 +27,21 @@ curl -fsSL https://www.rossoctl.dev/cortex/install.sh | sh -s -- --yes When setup is done, open a new terminal. The new terminal reads the new `PATH`. +### Windows (preview) + +`install.sh` and `agentop setup` don't run on Windows yet (#1520). Install by hand: + +1. From the [releases page](https://github.com/rossoctl/cortex/releases), download `agentop__windows_amd64.zip` and `cortex__windows_amd64.zip` (`arm64` on an Arm PC), and `checksums.txt`. +2. Check them in PowerShell. `checksums.txt` has lower-case hashes, and `Get-FileHash` prints upper case, so compare `(Get-FileHash .\agentop__windows_amd64.zip -Algorithm SHA256).Hash.ToLower()` with the line for that file, and the same for `cortex`. +3. Unblock both: `Unblock-File .\agentop__windows_amd64.zip`, and the same for `cortex`. The binaries are not signed yet, and a downloaded `.zip` passes its "from the internet" mark on to what it holds, so without this SmartScreen may block them. +4. Unzip both into one folder, for example `$HOME\.local\bin`, and add that folder to your user `PATH`. Then open a new terminal: a terminal that is already open keeps the old `PATH`. +5. In that new terminal, run the proxy: `cortex --local`. It writes `~/.cortex/config.yaml` on first run. Stop it with `Ctrl-C`. If it says it can't parse `~/.cortex/config.yaml`, a file written by an earlier Windows build, delete that file and run it again: Cortex writes a fresh one. +6. In a second new terminal, run `agentop observe`. + +Then connect Claude Code with `agentop configure claude-code enable`, or run one session through Cortex with `agentop exec -- claude`. + +Not on Windows yet: `agentop service`, `setup`, `uninstall` and `update` (they refuse and say so), so the proxy runs only while its terminal is open. Tools other than Node (`git`, `curl`, Python) inside a session don't trust the TLS bridge yet. + ## Connect your agent Connect each agent that you use. Do this one time per agent. @@ -126,4 +141,11 @@ To remove Cortex, run `agentop uninstall`. It asks once. Uninstall disconnects Claude Code, OpenCode, IBM Bob and Pi. It does not disconnect Codex. If you use Codex, run `agentop configure codex disable` first. +On Windows, `agentop uninstall` is not supported yet (#1520). Remove Cortex by hand: + +1. Disconnect each agent you connected: `agentop configure disable`. Then restart the agent. +2. Stop the proxy: `Ctrl-C` in its terminal. +3. Delete `agentop.exe` and `cortex.exe`, and remove their folder from your user `PATH` if you added it only for them. +4. Optional, and separate: delete `~/.cortex`. That deletes everything Cortex kept, including the session archive, the cost ledger and the TLS bridge's CA. + For more detail, read [Remove it](laptop-service.md#remove-it). diff --git a/scripts/collect-install-stats.sh b/scripts/collect-install-stats.sh index 69ff71662..e98a0d1a1 100755 --- a/scripts/collect-install-stats.sh +++ b/scripts/collect-install-stats.sh @@ -315,6 +315,9 @@ jq --arg date "${today}" \ elif $name | test("darwin_amd64") then "darwin_amd64" elif $name | test("linux_arm64") then "linux_arm64" elif $name | test("linux_amd64") then "linux_amd64" + # Windows .zip files (#1520), downloaded by hand: no installer fetches them. + elif $name | test("windows_arm64") then "windows_arm64" + elif $name | test("windows_amd64") then "windows_amd64" # Unanchored: v0.1 through v0.4 named this file # kagenti-extensions__checksums.txt, which an anchored ^checksums missed. # Those 24 releases were filed under "other" and read 0 installs apiece -- 79 diff --git a/scripts/install.sh b/scripts/install.sh index f7c8f6ecc..a092e3c3e 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -393,6 +393,7 @@ detect_platform() { case "$os" in Darwin) os=darwin ;; Linux) os=linux ;; + MINGW* | MSYS* | CYGWIN*) die "Windows: this installer does not run there yet; install from the release .zip (docs/getting-started.md, \"Windows (preview)\")" ;; *) die "unsupported OS: $os (the installer supports macOS and Linux)" ;; esac arch=$(uname -m)