LemonCliRunners. KimiSubagent
(lemon_cli_runners v0.1.0)
View Source
High-level API for using Kimi (Kimi CLI) as a collaborating subagent.
This module provides a convenient interface for spawning Kimi CLI sessions and interacting with them over time. Unlike one-shot LLM calls, Kimi subagents maintain state across multiple prompts when a resume token is provided.
Summary
Functions
Collect the final answer from the session.
Continue an existing session with a follow-up prompt.
Get the event stream as an enumerable of normalized events.
Resume an existing Kimi session with a new prompt.
Return the resume token for a session if available.
Run a Kimi task synchronously and return the answer.
Start a new Kimi subagent session.
Types
@type session() :: %{ pid: pid(), stream: LemonAgent.EventStream.t(), resume_token: LemonCore.ResumeToken.t() | nil, token_agent: pid() | nil, cwd: String.t() }
A Kimi subagent session
@type subagent_event() :: {:started, LemonCore.ResumeToken.t()} | {:action, action :: map(), phase :: atom(), opts :: keyword()} | {:completed, answer :: String.t(), opts :: keyword()} | {:error, reason :: term()}
Normalized event from the subagent
Functions
Collect the final answer from the session.
Continue an existing session with a follow-up prompt.
@spec events(session()) :: Enumerable.t()
Get the event stream as an enumerable of normalized events.
@spec resume( LemonCore.ResumeToken.t(), keyword() ) :: {:ok, session()} | {:error, term()}
Resume an existing Kimi session with a new prompt.
@spec resume_token(session()) :: LemonCore.ResumeToken.t() | nil
Return the resume token for a session if available.
Run a Kimi task synchronously and return the answer.
Start a new Kimi subagent session.