remote

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package remote stores remote session setup and transport configuration.

Package remote models remote-session environment and upstream proxy bootstrap state for Codog remote clients.

Index

Constants

View Source
const (
	// DefaultBaseURL is the Anthropic-compatible remote endpoint used when no
	// environment override is present.
	DefaultBaseURL = "https://api.anthropic.com"

	// DefaultTokenPath is the container path used by Claude Code remote sessions.
	DefaultTokenPath = "/run/ccr/session_token"

	// DefaultSystemCAPath is the system CA bundle path used when bootstrapping a
	// remote upstream proxy.
	DefaultSystemCAPath = "/etc/ssl/certs/ca-certificates.crt"
)

Variables

This section is empty.

Functions

func Env

func Env() map[string]string

Env reads the current process environment into a map.

func InheritedProxyEnv

func InheritedProxyEnv(env map[string]string) map[string]string

InheritedProxyEnv returns existing proxy environment values when both a proxy and CA bundle are already configured.

func MergeEnv

func MergeEnv(base []string, overlay map[string]string) []string

MergeEnv overlays environment map values onto a base env list while preserving unmodified entries and key order.

func NoProxyList

func NoProxyList() string

NoProxyList returns the default host list excluded from upstream proxying.

func ReadToken

func ReadToken(path string) (string, error)

ReadToken reads and trims a remote session token. Missing or blank files return an empty token.

func UpstreamProxyWebSocketURL

func UpstreamProxyWebSocketURL(baseURL string) string

UpstreamProxyWebSocketURL derives the upstream proxy websocket endpoint from an Anthropic-compatible base URL.

Types

type RuntimeReport

type RuntimeReport struct {
	Remote                SessionContext         `json:"remote"`
	UpstreamProxy         UpstreamProxyReport    `json:"upstream_proxy"`
	InheritedProxyEnvKeys []string               `json:"inherited_proxy_env_keys,omitempty"`
	SubprocessEnv         map[string]string      `json:"subprocess_env,omitempty"`
	Bootstrap             UpstreamProxyBootstrap `json:"-"`
	State                 UpstreamProxyState     `json:"-"`
	InheritedProxyEnv     map[string]string      `json:"-"`
}

RuntimeReport is a redacted, JSON-safe view of remote runtime readiness.

func InspectEnv

func InspectEnv(env map[string]string, proxyPort uint16) RuntimeReport

InspectEnv builds a redacted remote runtime report from an environment map.

type SessionContext

type SessionContext struct {
	Enabled   bool   `json:"enabled"`
	SessionID string `json:"session_id,omitempty"`
	BaseURL   string `json:"base_url"`
}

SessionContext describes whether the current process is running inside a remote Codog/Claude Code session.

func SessionContextFromEnv

func SessionContextFromEnv(env map[string]string) SessionContext

SessionContextFromEnv reads remote-session identity from an environment map.

type UpstreamProxyBootstrap

type UpstreamProxyBootstrap struct {
	Remote               SessionContext `json:"remote"`
	UpstreamProxyEnabled bool           `json:"upstream_proxy_enabled"`
	TokenPath            string         `json:"token_path"`
	CABundlePath         string         `json:"ca_bundle_path"`
	SystemCAPath         string         `json:"system_ca_path"`
	Token                string         `json:"-"`
	TokenConfigured      bool           `json:"token_configured"`
	Missing              []string       `json:"missing,omitempty"`
	WebSocketURL         string         `json:"websocket_url"`
}

UpstreamProxyBootstrap captures the environment and token facts needed to start an upstream proxy for remote sessions.

func BootstrapFromEnv

func BootstrapFromEnv(env map[string]string) UpstreamProxyBootstrap

BootstrapFromEnv reads the upstream proxy bootstrap contract from an environment map.

func (UpstreamProxyBootstrap) Report

func (b UpstreamProxyBootstrap) Report(state UpstreamProxyState, subprocessEnv map[string]string) UpstreamProxyReport

Report returns a redacted JSON-safe proxy readiness summary.

func (UpstreamProxyBootstrap) ShouldEnable

func (b UpstreamProxyBootstrap) ShouldEnable() bool

ShouldEnable reports whether the upstream proxy has every required runtime input.

func (UpstreamProxyBootstrap) StateForPort

func (b UpstreamProxyBootstrap) StateForPort(port uint16) UpstreamProxyState

StateForPort derives subprocess proxy settings for a local proxy listener.

type UpstreamProxyReport

type UpstreamProxyReport struct {
	Enabled              bool     `json:"enabled"`
	Ready                bool     `json:"ready"`
	SessionIDConfigured  bool     `json:"session_id_configured"`
	TokenConfigured      bool     `json:"token_configured"`
	TokenPath            string   `json:"token_path"`
	CABundlePath         string   `json:"ca_bundle_path"`
	SystemCAPath         string   `json:"system_ca_path"`
	WebSocketURL         string   `json:"websocket_url"`
	ProxyURL             string   `json:"proxy_url,omitempty"`
	NoProxy              string   `json:"no_proxy,omitempty"`
	Missing              []string `json:"missing,omitempty"`
	SubprocessEnvKeyList []string `json:"subprocess_env_keys,omitempty"`
}

UpstreamProxyReport is the redacted proxy-readiness summary shown in command and API reports.

type UpstreamProxyState

type UpstreamProxyState struct {
	Enabled      bool   `json:"enabled"`
	ProxyURL     string `json:"proxy_url,omitempty"`
	CABundlePath string `json:"ca_bundle_path,omitempty"`
	NoProxy      string `json:"no_proxy"`
}

UpstreamProxyState is the child-process proxy configuration derived from a ready bootstrap.

func (UpstreamProxyState) SubprocessEnv

func (s UpstreamProxyState) SubprocessEnv() map[string]string

SubprocessEnv returns the environment values needed by child processes that should use the local upstream proxy.

Jump to

Keyboard shortcuts

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