session

package
v0.7.162 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package session tracks the identity of the agent session driving a chunk invocation, so per-session state (which sidecar this session owns) stays separate when several sessions share one working tree.

Index

Constants

View Source
const EnvClaudeSessionID = "CLAUDE_CODE_SESSION_ID"

EnvClaudeSessionID is set by Claude Code in the environment of every command it runs. It is what makes a session identifiable outside the Stop hook, where the session ID arrives in the hook payload instead: an agent running `chunk sidecar sync` or `chunk validate --remote` itself would otherwise look anonymous and share one sidecar with every other session in the repo.

It lives here rather than in the config package because, like the agent signals in internal/telemetry, it is a variable another tool sets rather than one of chunk's own. config.EnvChunkSessionID, which users set themselves, does live there.

Variables

This section is empty.

Functions

func IDFromCtx

func IDFromCtx(ctx context.Context) string

IDFromCtx returns the Claude session ID stored in ctx, or "" if not set.

func IDFromEnv added in v0.7.160

func IDFromEnv() string

IDFromEnv returns the session ID advertised by the environment, or "" when nothing in it names a session.

config.EnvChunkSessionID wins over the agent's own variable, so an agent chunk does not recognise — or a test — can still pin a session identity by hand.

The value is sanitised because it becomes part of a state file name and of a generated sidecar name: everything outside [A-Za-z0-9._-] is dropped and the result is capped. Real session IDs are UUIDs, so in practice this changes nothing; it only stops a hostile or malformed value from escaping the state directory.

func WithID

func WithID(ctx context.Context, id string) context.Context

WithID returns a new context carrying the given Claude session ID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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