sidechat

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	MaxQuestion = 4000
	MaxExcerpt  = 2000
	MaxExcerpts = 5
	MaxHistory  = 6
)

Variables

This section is empty.

Functions

func Args

func Args(sessionID, forkID, model string) ([]string, error)

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

func Ask(ctx context.Context, run Run, onEvent func(Event))

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

func BuildPrompt(r Request) string

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.

func Env

func Env(base []string, rt Runtime) []string

Env is the child's environment: free of the parent agent, auto-memory and updates off, the login the managed launcher would pick.

func Format

func Format(e Event) string

Format is the event as a server-sent frame.

func IsFork

func IsFork(id string) bool

IsFork: the session id is a fork a side chat answers from right now; it is no conversation and stays out of lists.

Types

type Event

type Event struct {
	Type, Text, Code, Message string
	CostUSD                   *float64
}

Event is one event of the stream: delta {text}, done {text, costUsd?} or error {code, message}.

type Excerpt

type Excerpt struct {
	Quote         string
	HasSource     bool
	EntryID, Role string
}

Excerpt is a quoted piece of the conversation; Role and EntryID are set when it names its source.

type Request

type Request struct {
	TabID, Question string
	Excerpts        []Excerpt
	History         []Turn
	Model           string
}

Request is a checked and cleaned question.

func ParseRequest

func ParseRequest(body any) (Request, string)

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

func ReadRuntime(file string) Runtime

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.

type Turn

type Turn struct{ Question, Answer string }

Turn is an earlier question of this side chat and its answer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL