Skip to content

feat(session): support Node.js agents in the local session daemon#861

Open
toubatbrian wants to merge 1 commit into
feat/agent-session-daemonfrom
brian/agent-session-node-support
Open

feat(session): support Node.js agents in the local session daemon#861
toubatbrian wants to merge 1 commit into
feat/agent-session-daemonfrom
brian/agent-session-node-support

Conversation

@toubatbrian
Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian commented Jun 4, 2026

Important

Depends on / must wait for: livekit/agents-js#1706feat(console): console CLI runner + AgentsConsole session wiring (text mode).

The Go daemon spawns the JS agent with node <entry> console --connect-addr <addr>. The JS console --connect-addr TCP runner that accepts this is added in agents-js#1706, which is not yet merged. The underlying TcpSessionTransport (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 session local 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.godetectProject no longer gates on Python-only. It now also accepts Node projects (already recognized by DetectProjectRoot via package.json) and the error message reflects both supported runtimes.
  • cmd/lk/simulate_subprocess.go — extracted interpreter/argv resolution into buildAgentCommand, branching on project type:
    • Python: <python> <entry> <args> (uv prefixes run python)
    • Node: node [--experimental-strip-types] <entry> <args>
    • Added findNodeBinary (resolves node from PATH) and isTypeScriptEntry so a .ts/.mts/.cts entrypoint runs directly via Node's type-stripping loader — no build step required.
  • cmd/lk/session_daemon.go — dropped the stale TODO(node); the daemon now spawns either runtime via buildConsoleArgs.

Underlying spawned command

node --experimental-strip-types <entry> console --connect-addr 127.0.0.1:<port>

(--experimental-strip-types is 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 a getWeather function-tool call and the agent reply
  • Second turn ("And what about Paris?") — multi-turn confirmed
  • lk agent session end — clean shutdown
  • Python path unchanged (argv resolution refactor preserves prior behavior)

Note: lk agent session is text-mode only; this PR does not touch the audio/voice lk agent console path.

Dependencies

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>
@toubatbrian toubatbrian requested a review from theomonnom June 4, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant