feat(session): support Node.js agents in the local session daemon#861
Open
toubatbrian wants to merge 1 commit into
Open
feat(session): support Node.js agents in the local session daemon#861toubatbrian wants to merge 1 commit into
toubatbrian wants to merge 1 commit into
Conversation
The `lk agent session` daemon could previously only spawn Python agents; Node/JS projects were rejected at detection time. This wires up the Node path so a JS/TS agent can be driven over the same text-mode console protocol as Python. - agent_utils.go: stop gating `detectProject` on Python-only. Accept Node projects too (DetectProjectRoot already recognizes them via package.json) and update the error to reflect both supported runtimes. - simulate_subprocess.go: extract interpreter/argv resolution into `buildAgentCommand`, branching on project type. Python keeps `<python> <entry> <args>` (uv prefixes `run python`); Node runs `node [--experimental-strip-types] <entry> <args>`. Add `findNodeBinary` (resolves `node` from PATH) and `isTypeScriptEntry` so a `.ts`/`.mts`/ `.cts` entrypoint runs directly via the type-stripping loader with no build step. - session_daemon.go: drop the stale TODO; the daemon now spawns either runtime via `buildConsoleArgs` (`console --connect-addr <addr>`). Verified end-to-end: `lk agent session start examples/src/console_text_agent.ts` spawns the JS agent, connects to the Go TCP console server, completes the text-mode handshake, and round-trips multi-turn `say` requests including a function-tool call. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Depends on / must wait for: livekit/agents-js#1706 — feat(console): console CLI runner + AgentsConsole session wiring (text mode).
The Go daemon spawns the JS agent with
node <entry> console --connect-addr <addr>. The JSconsole --connect-addrTCP runner that accepts this is added in agents-js#1706, which is not yet merged. The underlyingTcpSessionTransport(agents-js#1693) is already merged, but without #1706 there is no JS console TCP entrypoint to dial the daemon. Do not merge this until agents-js#1706 lands.Summary
Extends the
lk agent sessionlocal daemon to drive Node.js/TypeScript agents, not just Python. Previously Node projects were rejected at project-detection time; this wires up the Node spawn path so a JS/TS agent is driven over the exact same text-mode console protocol (console --connect-addr <addr>) as Python.Changes
cmd/lk/agent_utils.go—detectProjectno longer gates on Python-only. It now also accepts Node projects (already recognized byDetectProjectRootviapackage.json) and the error message reflects both supported runtimes.cmd/lk/simulate_subprocess.go— extracted interpreter/argv resolution intobuildAgentCommand, branching on project type:<python> <entry> <args>(uv prefixesrun python)node [--experimental-strip-types] <entry> <args>findNodeBinary(resolvesnodefromPATH) andisTypeScriptEntryso a.ts/.mts/.ctsentrypoint runs directly via Node's type-stripping loader — no build step required.cmd/lk/session_daemon.go— dropped the staleTODO(node); the daemon now spawns either runtime viabuildConsoleArgs.Underlying spawned command
(
--experimental-strip-typesis added only for TypeScript entrypoints.)Test plan
Verified end-to-end against a JS agent (
@livekit/agents, with agents-js#1706 checked out locally):lk agent session start examples/src/console_text_agent.ts— detects the Node project, spawns the JS agent, connects to the Go TCP console server, completes the text-mode handshake (Session started.)lk agent session say "What is the weather in Tokyo?"— round-trips a turn including agetWeatherfunction-tool call and the agent replylk agent session end— clean shutdownDependencies
console --connect-addr). Required; merge after this lands.TcpSessionTransport+updateIohandler (already merged).