Documentation
¶
Overview ¶
Package sidechat answers a quick question about an agent tab's Claude session from a fork that is never saved: the main conversation does not change and the agent may be busy. The answer streams as events: deltas, then one done or error.
Index ¶
- Constants
- func Args(sessionID, forkID, model string) ([]string, error)
- func Ask(ctx context.Context, run Run, onEvent func(Event))
- func BuildPrompt(r Request) string
- func Claim(tabID string) func()
- func Env(base []string, rt Runtime) []string
- func Format(e Event) string
- func IsFork(id string) bool
- type Event
- type Excerpt
- type Request
- type Run
- type Runtime
- type Turn
Constants ¶
const ( MaxQuestion = 4000 MaxExcerpt = 2000 MaxExcerpts = 5 MaxHistory = 6 )
Variables ¶
This section is empty.
Functions ¶
func Args ¶
Args make the fork answer once and leave nothing behind: its own id, no persistence, no tools, MCP servers, slash commands or hooks. The question goes through stdin.
func Ask ¶
Ask asks a fork of the session one question and reports the answer as events: any number of deltas, then exactly one done or error. A cancelled ctx or the timeout kills the process.
func BuildPrompt ¶
BuildPrompt is the one text sent to the CLI. It begins with a fixed sentence, so a question that starts with a dash is never an option.
func Claim ¶
func Claim(tabID string) func()
Claim takes the tab's one running question; nil when it already has one.
Types ¶
type Event ¶
Event is one event of the stream: delta {text}, done {text, costUsd?} or error {code, message}.
type Excerpt ¶
Excerpt is a quoted piece of the conversation; Role and EntryID are set when it names its source.
type Request ¶
Request is a checked and cleaned question.
func ParseRequest ¶
ParseRequest checks a body from the browser; the text is the 400 error. The session is not part of it: the server finds it from the tab.
type Run ¶
type Run struct {
SessionID, Cwd, Prompt, Model string
Runtime Runtime
BaseEnv []string
Timeout time.Duration
// ProjectDir is the Claude projects folder of Cwd: a stray fork transcript there is removed afterwards.
ProjectDir string
Log func(level, msg string, kv ...any)
}
Run is one question.
type Runtime ¶
type Runtime struct {
Binary, AuthDirectory string
}
Runtime is the Claude binary the machine pins and its login folder ("" for the default login).
func ReadRuntime ¶
ReadRuntime reads `claude_binary` and `auth_directory` from the machine's runtime config; `claude` and the default login when it says nothing usable. Not the managed launcher: it takes a per-session lock the main agent holds while it runs.