Skip to content

Commit 758e0e7

Browse files
authored
add console, simulate, and agent dev commands + vendor webrtc & portaudio (#810) (#809)
* add vendored WebRTC APM and PortAudio native sources * add console, simulate, and agent dev commands (#810) * add console, simulate, agent dev commands with TUI and protobuf IPC * improve agent detection error messages and consistency - Add friendly error when no agent project is detected (start/dev/console) - Print detected language and directory to stderr for start/dev/console - Deduplicate console detection logic to use shared detectProject() - Add nil guard in BytesToSamples for empty data * improve error messages, entrypoint detection, and IPC safety - Detect project root from entrypoint directory when --entrypoint is set - Better entrypoint-not-found error showing checked paths - Print detected language and directory to stderr for start/dev/console - Render CLI errors in red at the call site - Add maxMessageSize check to IPC WriteProto * add console build docs and PortAudio submodule check * add blank line after user/agent messages in console TUI * remove duplicate -lc++ linker flags, cgo handles C++ linking automatically * fix console TUI rendering, add startup spinner and handoff support * remove local replace directives, use published server-sdk-go Switch to the server-sdk-go branch that exports CreateSourceTarball, MultipartUpload, and AgentSimulationClient. Fix spinnerFrames reference across build tags. * update server-sdk-go to include complete AgentSimulationClient * update server-sdk-go to merged main with SimulationAdmin grant * Fix agent watcher exitCh race on restart * Remove default num-simulations, let server decide * Show 'Generating scenarios' without count when num-simulations not specified * Improve agent simulate TUI setup and log display * Read NumSimulations from server response * Use larger circle icon (⏺) in TUI * Integrate save scenario overlay, show labels in job list, fix selected row highlight * Softer yellow, use ⏺ for pending icons * Pad selected row to max label width for consistent highlight * Remove q to quit, only ctrl+c exits * CI mode, TUI improvements, log filtering, and entrypoint fix CLI architecture: - Non-interactive CI mode auto-detected (no TTY or CI env var) - Shared lifecycle functions in simulate.go (no bubbletea dependency) - simulate_ci.go: sequential runner with ::group:: output for GHA TUI improvements: - Detail view: unified scrollable content (instructions, transcript, logs) - Log filtering by room name prefix (latest retry only) - Compact chat transcript rendering - Removed filter tabs, simplified matrix rain - Mouse capture removed (text selection works) - Summary unavailable message, summarizing spinner Agent subprocess: - Debug logging enabled, room-indexed log storage - Per-room log filtering by prefix with latest-room tracking Bug fix: - Send CodeEntrypoint in ConfirmSourceUpload so the generator analyzes the correct file instead of the entire workspace * Use positional arg for entrypoint instead of --entrypoint flag * Address PR review: remove redundant flags, fix console text mode - Remove --url, --api-key, --api-secret flags from agent run commands (already available as global flags) - Fix console text mode: suppress UserInputTranscribed events in text mode to prevent duplicate/out-of-order user messages - Clear partial transcript when switching to text mode mid-call * Put start/dev/console/simulate behind console build tag, revert CI changes - All agent subprocess commands (start, dev, console, simulate) require -tags console to build. Without the tag, they don't appear in lk agent. - Revert .github/workflows/release.yaml and banner to main - Remove .goreleaser.yaml (not on main) - Move noAgentError to agent.go (non-tagged) - Add init() registration for simulate command * Add CI job for no-console, no-CGO build verification * Remove build-binaries.yaml workflow * Remove Homebrew formula * Restore .goreleaser.yml * Rename .goreleaser.yml to .goreleaser.yaml * Remove console build section from README * Add CI job for no-console, no-CGO build verification * Read Go version from go.mod instead of hardcoding in CI * Remove windows_arm from build matrix (no CGO, redundant with no-console job) * Fix staticcheck: tag agent_reload, move console-only vars to agent_run * Fix Windows build: extract platform-specific process management * Clean up unused RoomLogCount and stale entrypoint error message * Pin GitHub Actions to SHA references in build.yaml
1 parent 34433ee commit 758e0e7

1,502 files changed

Lines changed: 271543 additions & 53 deletions

File tree

Some content is hidden

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

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
pkg/provider/resources/*.h264 filter=lfs diff=lfs merge=lfs -text
22
pkg/provider/resources/*.ivf filter=lfs diff=lfs merge=lfs -text
33
pkg/provider/resources/*.ogg filter=lfs diff=lfs merge=lfs -text
4+
5+
# Vendored C/C++ source (WebRTC APM, PortAudio, abseil, pffft, rnnoise)
6+
pkg/apm/webrtc/**/*.cc linguist-vendored
7+
pkg/apm/webrtc/**/*.c linguist-vendored
8+
pkg/apm/webrtc/**/*.h linguist-vendored
9+
pkg/apm/webrtc/**/*.m linguist-vendored
10+
pkg/apm/webrtc/**/*.inc linguist-vendored
11+
pkg/portaudio/pa_src/** linguist-vendored

.github/banner_dark.png

-407 Bytes
Loading

.github/workflows/build.yaml

Lines changed: 147 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,163 @@ on:
2020
pull_request:
2121
branches: [ main ]
2222

23+
permissions:
24+
contents: read
25+
2326
jobs:
24-
build:
27+
build-no-console:
28+
name: Build (no console, no CGO)
2529
runs-on: ubuntu-latest
2630
steps:
2731
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
28-
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
29-
with:
30-
path: |
31-
~/go/pkg/mod
32-
~/go/bin
33-
~/.cache
34-
key: livekit-cli
3532

3633
- name: Set up Go
3734
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
3835
with:
39-
go-version: "1.25"
36+
go-version-file: go.mod
37+
38+
- name: Build without console tag
39+
env:
40+
CGO_ENABLED: "0"
41+
run: go build -o bin/lk ./cmd/lk
42+
43+
- name: Verify binary
44+
run: bin/lk --help > /dev/null
45+
46+
lint-and-test:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
50+
with:
51+
submodules: true
4052

41-
- name: Download Go modules
42-
run: go mod download
53+
- name: Set up Go
54+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
55+
with:
56+
go-version-file: go.mod
4357

44-
- name: Lint
45-
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
58+
- name: Static Check
59+
uses: dominikh/staticcheck-action@288b4e28bae83c59f35f73651aeb5cab746a06fc # v1.4.0
4660
with:
47-
version: v2.11.4
61+
version: "latest"
62+
install-go: false
4863

49-
- name: Run Go tests
64+
- name: Test
5065
run: go test -v ./...
66+
67+
build:
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
include:
72+
- os: macos-latest
73+
suffix: darwin_arm64
74+
- os: ubuntu-latest
75+
suffix: linux_amd64
76+
zig_target: x86_64-linux-gnu.2.28
77+
alsa_arch: amd64
78+
alsa_triple: x86_64-linux-gnu
79+
- os: ubuntu-latest
80+
suffix: linux_arm64
81+
zig_target: aarch64-linux-gnu.2.28
82+
alsa_arch: arm64
83+
alsa_triple: aarch64-linux-gnu
84+
goarch: arm64
85+
- os: ubuntu-latest
86+
suffix: linux_arm
87+
zig_target: arm-linux-gnueabihf.2.28
88+
alsa_arch: armhf
89+
alsa_triple: arm-linux-gnueabihf
90+
goarch: arm
91+
goarm: "7"
92+
- os: ubuntu-latest
93+
suffix: windows_amd64
94+
zig_target: x86_64-windows-gnu
95+
goos: windows
96+
goarch: amd64
97+
- os: ubuntu-latest
98+
suffix: windows_arm64
99+
zig_target: aarch64-windows-gnu
100+
goos: windows
101+
goarch: arm64
102+
runs-on: ${{ matrix.os }}
103+
steps:
104+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
105+
with:
106+
submodules: true
107+
108+
- name: Set up Go
109+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
110+
with:
111+
go-version-file: go.mod
112+
113+
- name: Install Zig
114+
if: matrix.zig_target
115+
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
116+
with:
117+
version: 0.14.1
118+
119+
- name: Install ALSA headers
120+
if: matrix.alsa_arch
121+
run: |
122+
sudo dpkg --add-architecture ${{ matrix.alsa_arch }}
123+
if [ "${{ matrix.alsa_arch }}" != "amd64" ]; then
124+
CODENAME=$(lsb_release -cs)
125+
# Restrict existing sources to amd64 to avoid 404s for foreign arch
126+
for f in /etc/apt/sources.list.d/*.sources; do
127+
grep -q '^Architectures:' "$f" || sudo sed -i '/^Types:/a Architectures: amd64 i386' "$f"
128+
done
129+
# Add ports.ubuntu.com for the foreign architecture
130+
printf 'Types: deb\nURIs: http://ports.ubuntu.com/ubuntu-ports\nSuites: %s %s-updates\nComponents: main universe\nArchitectures: %s\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' \
131+
"$CODENAME" "$CODENAME" "${{ matrix.alsa_arch }}" | sudo tee /etc/apt/sources.list.d/ports.sources
132+
fi
133+
sudo apt-get update
134+
sudo apt-get install -y libasound2-dev:${{ matrix.alsa_arch }}
135+
136+
- name: Generate Windows import libraries
137+
if: matrix.goos == 'windows' && matrix.zig_target
138+
run: |
139+
ZIG_LIB=$(zig env | jq -r '.lib_dir')
140+
echo "ZIG_LIB=${ZIG_LIB}" >> "$GITHUB_ENV"
141+
LIB_DIR="${ZIG_LIB}/libc/mingw/lib-common"
142+
# Zig bundles MinGW .def files but lld needs .a import libraries.
143+
# Go's compiled objects embed COFF /DEFAULTLIB directives (e.g. dbghelp,
144+
# bcrypt) that lld resolves directly, bypassing Zig's lazy .def→.a
145+
# generation. Pre-generate all import libraries so lld can find them.
146+
MACHINE=${{ matrix.goarch == 'amd64' && 'i386:x86-64' || 'arm64' }}
147+
for def in "${LIB_DIR}"/*.def; do
148+
lib=$(basename "$def" .def)
149+
[ -f "${LIB_DIR}/lib${lib}.a" ] && continue
150+
zig dlltool -d "$def" -l "${LIB_DIR}/lib${lib}.a" -m "$MACHINE" 2>/dev/null || true
151+
done
152+
153+
- name: Build
154+
env:
155+
CGO_ENABLED: ${{ (matrix.goos && !matrix.zig_target) && '0' || '1' }}
156+
CC: ${{ matrix.zig_target && format('zig cc -target {0}', matrix.zig_target) || '' }}
157+
CXX: ${{ matrix.zig_target && format('zig c++ -target {0}', matrix.zig_target) || '' }}
158+
# Zig uses its own sysroot; point it at the system ALSA headers and libraries
159+
CGO_CFLAGS: ${{ matrix.alsa_triple && format('-isystem /usr/include -isystem /usr/include/{0}', matrix.alsa_triple) || '' }}
160+
CGO_LDFLAGS: ${{ matrix.alsa_triple && format('-L/usr/lib/{0}', matrix.alsa_triple) || '' }}
161+
# -fms-extensions: enable __try/__except (SEH) used by WebRTC
162+
# -DNTDDI_VERSION: target Windows 10 base to skip WinRT includes absent from MinGW
163+
CGO_CXXFLAGS: ${{ matrix.goos == 'windows' && '-fms-extensions -DNTDDI_VERSION=0x0A000000' || '' }}
164+
GOOS: ${{ matrix.goos || '' }}
165+
GOARCH: ${{ matrix.goarch || '' }}
166+
GOARM: ${{ matrix.goarm || '' }}
167+
shell: bash
168+
run: |
169+
EXT=""; if [ "${GOOS:-}" = "windows" ]; then EXT=".exe"; fi
170+
TAGS=""
171+
if [ "$CGO_ENABLED" = "1" ]; then TAGS="-tags console"; fi
172+
# Force external linking for Windows so Go uses zig cc (CC) as the linker,
173+
# and add Zig's MinGW lib path so lld can find the generated import libraries.
174+
EXTLD=""
175+
if [ "${GOOS:-}" = "windows" ] && [ "$CGO_ENABLED" = "1" ]; then
176+
EXTLD="-linkmode=external -extldflags '-L${ZIG_LIB}/libc/mingw/lib-common'"
177+
fi
178+
go build $TAGS -ldflags "-w -s $EXTLD" -o "bin/lk${EXT}" ./cmd/lk
179+
180+
- name: Verify binary
181+
if: "!matrix.goos && !matrix.goarch"
182+
run: bin/lk --help > /dev/null

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
- name: Set up Go
8282
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
8383
with:
84-
go-version: "1.25"
84+
go-version-file: go.mod
8585

8686
- name: Run GoReleaser
8787
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
2626
with:
27-
go-version: "1.25"
27+
go-version-file: go.mod
2828
cache: true
2929

3030
- name: Download Go modules

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dist/
2121
.task/
2222

2323
.DS_Store
24+
lk

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "pkg/portaudio/pa_src"]
2+
path = pkg/portaudio/pa_src
3+
url = https://github.com/PortAudio/portaudio.git

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ cli: check_lfs
1616
GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o bin/lk.exe ./cmd/lk
1717

1818

19+
console:
20+
CGO_ENABLED=1 go build -tags console -ldflags "-w -s" -o bin/lk ./cmd/lk
21+
1922
install: cli
2023
ifeq ($(DETECTED_OS),Windows)
2124
cp bin/lk.exe $(GOBIN)/lk.exe

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ git clone https://github.com/livekit/livekit-cli && cd livekit-cli
5454
make install
5555
```
5656

57+
5758
# Usage
5859

5960
See `lk --help` for a complete list of subcommands. The `--help` flag can also be used on any subcommand for more information.

cmd/lk/agent.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ var (
379379
}
380380
)
381381

382+
func noAgentError() error {
383+
return fmt.Errorf("no agent project detected in the current directory\n\n" +
384+
"Make sure you are running this command from an agent project directory\n" +
385+
"containing one of: pyproject.toml, requirements.txt, uv.lock, package.json, or lock files.\n\n" +
386+
"To get started, see: https://docs.livekit.io/agents/quickstart")
387+
}
388+
382389
func createAgentClient(ctx context.Context, cmd *cli.Command) (context.Context, error) {
383390
return createAgentClientWithOpts(ctx, cmd)
384391
}
@@ -605,7 +612,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
605612

606613
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
607614
if err != nil {
608-
return fmt.Errorf("unable to determine agent language: %w, please navigate to a directory containing an agent written in a supported language", err)
615+
return noAgentError()
609616
}
610617
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
611618

@@ -773,7 +780,7 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
773780

774781
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
775782
if err != nil {
776-
return fmt.Errorf("unable to determine agent language: %w, please make sure you are inside a directory containing an agent written in a supported language", err)
783+
return noAgentError()
777784
}
778785
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
779786

@@ -1611,7 +1618,7 @@ func generateAgentDockerfile(ctx context.Context, cmd *cli.Command) error {
16111618

16121619
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
16131620
if err != nil {
1614-
return fmt.Errorf("unable to determine agent language: %w, please make sure you are inside a directory containing an agent written in a supported language", err)
1621+
return noAgentError()
16151622
}
16161623
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
16171624

0 commit comments

Comments
 (0)