remote

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRuntimeCatalog

func BuildRuntimeCatalog(options RuntimeCatalogOptions) []protocol.RuntimeCapability

func DeleteSessionTranscript

func DeleteSessionTranscript(sessionID, cwd string) error

DeleteSessionTranscript 删除本地 Claude transcript 文件。

func EvaluateSessionConfig

func EvaluateSessionConfig(ctx SessionConfigContext, cfg protocol.SessionConfigPayload) sessionConfigDecision

func ListDirectoryEntries

func ListDirectoryEntries(path, query string, limit int, recursive bool) (string, []protocol.DirEntry, error)

func ListSlashCommandsForRuntime

func ListSlashCommandsForRuntime(runtimeID, currentDir, query string) ([]protocol.SlashCommandEntry, error)

func ResolveDirectoryWithinUserHome

func ResolveDirectoryWithinUserHome(rawPath, relativeBase string, emptyUsesHome bool) (string, error)

func Run

func Run(cfg *Config) error

Run 阻塞式启动(CLI 兼容)

Types

type AttachedCodexBootstrap

type AttachedCodexBootstrap struct {
	ThreadID   string
	WorkingDir string
	Model      string
}

type AttachedCodexController

type AttachedCodexController struct {
	// contains filtered or unexported fields
}

func NewAttachedCodexController

func NewAttachedCodexController(service *Service, wsURL string, cfg AttachedCodexControllerConfig) *AttachedCodexController

func (*AttachedCodexController) ApplyConfig

func (*AttachedCodexController) Close

func (c *AttachedCodexController) Close() error

func (*AttachedCodexController) CurrentDir

func (c *AttachedCodexController) CurrentDir() string

func (*AttachedCodexController) CurrentModel

func (c *AttachedCodexController) CurrentModel() string

func (*AttachedCodexController) CurrentPermissionMode

func (c *AttachedCodexController) CurrentPermissionMode() string

func (*AttachedCodexController) CurrentSandboxMode

func (c *AttachedCodexController) CurrentSandboxMode() string

func (*AttachedCodexController) Done

func (c *AttachedCodexController) Done() <-chan struct{}

func (*AttachedCodexController) Err

func (c *AttachedCodexController) Err() error

func (*AttachedCodexController) ForwardProxyClientMessage

func (c *AttachedCodexController) ForwardProxyClientMessage(messageType int, data []byte, reply func([]byte) error) error

func (*AttachedCodexController) Interrupt

func (c *AttachedCodexController) Interrupt() error

func (*AttachedCodexController) RecordForwardedInput

func (c *AttachedCodexController) RecordForwardedInput(content string)

func (*AttachedCodexController) ResolvePermissionResponse

func (c *AttachedCodexController) ResolvePermissionResponse(resp protocol.PermissionResponsePayload) bool

func (*AttachedCodexController) RuntimeSessionID

func (c *AttachedCodexController) RuntimeSessionID() string

func (*AttachedCodexController) SendInput

func (c *AttachedCodexController) SendInput(content string) error

func (*AttachedCodexController) SetProxyForwarder

func (c *AttachedCodexController) SetProxyForwarder(forward func([]byte) error)

func (*AttachedCodexController) Start

func (*AttachedCodexController) StartPassive

func (c *AttachedCodexController) StartPassive() error

func (*AttachedCodexController) SyncInitialSnapshot

func (c *AttachedCodexController) SyncInitialSnapshot()

type AttachedCodexControllerConfig

type AttachedCodexControllerConfig struct {
	SessionID        string
	RuntimeSessionID string
	WorkingDir       string
	Model            string
	PermissionMode   string
	SandboxMode      string
	Resume           bool
}

type AttachedCodexRolloutMirror

type AttachedCodexRolloutMirror struct {
	// contains filtered or unexported fields
}

func NewAttachedCodexRolloutMirror

func NewAttachedCodexRolloutMirror(cwd string) *AttachedCodexRolloutMirror

func (*AttachedCodexRolloutMirror) BeginTurn

func (m *AttachedCodexRolloutMirror) BeginTurn() error

func (*AttachedCodexRolloutMirror) Poll

type AttachedCodexRolloutMirrorHandlers

type AttachedCodexRolloutMirrorHandlers struct {
	HandleRuntimeSessionID func(string) error
	HandleAssistantLine    func(string) error
	HandleTurnComplete     func() error
}

type AttachedHandlers

type AttachedHandlers struct {
	SendInput   func(string) error
	Interrupt   func() error
	ApplyConfig func(protocol.SessionConfigPayload) error
}

type AttachedSessionStateUpdate

type AttachedSessionStateUpdate struct {
	RuntimeSessionID string
	WorkingDir       string
	Model            string
	ApplyModel       bool
	PermissionMode   string
	ApplyPermission  bool
	SandboxMode      string
	ApplySandbox     bool
}

type AttachedTranscriptMirror

type AttachedTranscriptMirror struct {
	// contains filtered or unexported fields
}

func NewAttachedTranscriptMirror

func NewAttachedTranscriptMirror(sessionID, cwd string) *AttachedTranscriptMirror

func (*AttachedTranscriptMirror) Poll

type AttachedTranscriptMirrorHandlers

type AttachedTranscriptMirrorHandlers struct {
	HandleLine               func(string) error
	HandleResult             func(map[string]any) error
	HandlePermissionRequest  func(AttachedTranscriptToolUse) error
	HandlePermissionResolved func(string) error
}

type AttachedTranscriptToolUse

type AttachedTranscriptToolUse struct {
	RequestID string
	Tool      string
	Input     map[string]any
}

type ClaudeSessionResolution

type ClaudeSessionResolution struct {
	SessionID                string
	Resume                   bool
	TranscriptPath           string
	AdoptedRecentSession     bool
	ReplacedRequestedSession bool
}

func ResolveClaudeSessionStart

func ResolveClaudeSessionStart(requestedSessionID, cwd string, resume bool) (ClaudeSessionResolution, error)

type CodexLocalSession

type CodexLocalSession struct {
	RuntimeSessionID string
	Cwd              string
	Path             string
	ModelProvider    string
	CLIVersion       string
	Source           string
	Originator       string
	SessionTime      time.Time
	ModTime          time.Time
	LineCount        int
}

func ListCodexLocalSessions

func ListCodexLocalSessions(cwd string, includeAll bool) ([]CodexLocalSession, error)

type CodexSessionResolution

type CodexSessionResolution struct {
	RuntimeSessionID         string
	Resume                   bool
	RolloutPath              string
	AdoptedRecentSession     bool
	ReplacedRequestedSession bool
}

func ResolveCodexSessionStart

func ResolveCodexSessionStart(requestedRuntimeSessionID, cwd string, resume bool) (CodexSessionResolution, error)

type Config

type Config struct {
	ServerURL        string // WS 服务器地址,如 wss://example.com
	Token            string // JWT token
	Command          string // 要启动的命令,默认 "claude"
	ClaudeCommand    string
	CodexCommand     string
	Args             []string
	WorkingDir       string
	Model            string
	PermissionMode   string
	SandboxMode      string
	HostID           string
	SessionID        string
	RuntimeSessionID string
	Resume           bool
	Management       bool
	ClaudeEnabled    bool
	CodexEnabled     bool
	RuntimeCatalog   []protocol.RuntimeCapability
}

Config remote 模式配置

type DisplayParser

type DisplayParser struct {
	// contains filtered or unexported fields
}

DisplayParser 将 runtime 流式输出转换为适合 GUI 展示的消息。 Codex 的实时通知已经在 bridge 中被转换为 Claude 风格事件,因此统一复用 Claude 解析器。

func NewDisplayParser

func NewDisplayParser() *DisplayParser

func (*DisplayParser) ParseTextPayload

func (p *DisplayParser) ParseTextPayload(payload protocol.TextPayload) []protocol.SessionHistoryMessage

type RuntimeCatalogOptions

type RuntimeCatalogOptions struct {
	ClaudeEnabled bool
	CodexEnabled  bool
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service 管理 remote 代理的生命周期

func NewService

func NewService() *Service

NewService 创建 Service 实例

func (*Service) AddMessageObserver

func (s *Service) AddMessageObserver(observer func(protocol.Message) error) func()

func (*Service) ApplySessionConfig

func (s *Service) ApplySessionConfig(cfg protocol.SessionConfigPayload) error

func (*Service) AutoReconnectEnabled

func (s *Service) AutoReconnectEnabled() bool

func (*Service) CancelReconnects

func (s *Service) CancelReconnects()

func (*Service) ClearAttachedPermissionRequest

func (s *Service) ClearAttachedPermissionRequest(requestID string)

func (*Service) CodexAppServerURL

func (s *Service) CodexAppServerURL() string

func (*Service) CommandPath

func (s *Service) CommandPath() string

func (*Service) CurrentDir

func (s *Service) CurrentDir() string

CurrentDir 返回当前工作目录

func (*Service) CurrentModel

func (s *Service) CurrentModel() string

func (*Service) CurrentPermissionMode

func (s *Service) CurrentPermissionMode() string

func (*Service) CurrentSandboxMode

func (s *Service) CurrentSandboxMode() string

func (*Service) DeleteSession

func (s *Service) DeleteSession(sessionID string) error

DeleteSession 删除当前管理端名下的子会话,并清理本地 transcript。

func (*Service) EmitAttachedPermissionRequest

func (s *Service) EmitAttachedPermissionRequest(requestID, tool string, input map[string]any) error

func (*Service) EmitStructuredTextLine

func (s *Service) EmitStructuredTextLine(line string) error

func (*Service) EmitTerminalText

func (s *Service) EmitTerminalText(content string) error

func (*Service) FinishAttachedTurn

func (s *Service) FinishAttachedTurn(status string) error

func (*Service) FinishAttachedTurnFromResult

func (s *Service) FinishAttachedTurnFromResult(event map[string]any) error

func (*Service) ForgetSession

func (s *Service) ForgetSession(sessionID string) bool

func (*Service) HasActiveTurn

func (s *Service) HasActiveTurn() bool

func (*Service) HasAttachedPermissionRequest

func (s *Service) HasAttachedPermissionRequest() bool

func (*Service) Interrupt

func (s *Service) Interrupt() error

func (*Service) IsManagementRunning

func (s *Service) IsManagementRunning() bool

IsManagementRunning 返回远程管理会话是否在线

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning 返回运行状态

func (*Service) LocalMode

func (s *Service) LocalMode() bool

func (*Service) LocalSessionIDs

func (s *Service) LocalSessionIDs() []string

LocalSessionIDs 返回当前进程启动的所有代理会话 ID

func (*Service) MarkAttachedInterruptRequested

func (s *Service) MarkAttachedInterruptRequested()

func (*Service) PauseSession

func (s *Service) PauseSession(sessionID string) error

PauseSession 暂停当前管理端名下的子会话。

func (*Service) ResetAttachedSessionState

func (s *Service) ResetAttachedSessionState()

func (*Service) RespondPermission

func (s *Service) RespondPermission(resp protocol.PermissionResponsePayload) error

func (*Service) RuntimeID

func (s *Service) RuntimeID() string

func (*Service) RuntimeSessionID

func (s *Service) RuntimeSessionID() string

func (*Service) SendCurrentKeepalive

func (s *Service) SendCurrentKeepalive() error

func (*Service) SendInput

func (s *Service) SendInput(content string) error

func (*Service) SessionID

func (s *Service) SessionID() string

SessionID 返回当前会话 ID

func (*Service) SetAttachedPermissionResponseHandler

func (s *Service) SetAttachedPermissionResponseHandler(handler func(protocol.PermissionResponsePayload) bool)

func (*Service) SetAutoReconnectEnabled

func (s *Service) SetAutoReconnectEnabled(enabled bool)

func (*Service) SetChildStartedHook

func (s *Service) SetChildStartedHook(hook func(*Service, Config))

func (*Service) ShouldAutoApproveTool

func (s *Service) ShouldAutoApproveTool(toolName string, input map[string]any) bool

func (*Service) Start

func (s *Service) Start(cfg *Config) (string, error)

Start 非阻塞启动 claude (pipes + stream-json) + WS 桥接

func (*Service) StartAttached

func (s *Service) StartAttached(cfg *Config, handlers AttachedHandlers) (string, error)

func (*Service) StartAttachedTurn

func (s *Service) StartAttachedTurn() error

func (*Service) StartLocal

func (s *Service) StartLocal(cfg *Config, sink func(protocol.Message) error) (string, error)

StartLocal 启动仅本地使用的 CLI 代理会话,不连接远程 websocket。

func (*Service) StartManagement

func (s *Service) StartManagement(cfg *Config) (string, error)

StartManagement 启动远程管理会话

func (*Service) StartProxy

func (s *Service) StartProxy(cfg *Config) (string, error)

StartProxy 启动代理会话;若当前服务已作为管理会话在线,则拉起子代理

func (*Service) Stop

func (s *Service) Stop() error

Stop 优雅关闭

func (*Service) StopWithReason

func (s *Service) StopWithReason(reason string) error

StopWithReason 优雅关闭,并记录触发原因

func (*Service) UpdateAttachedSessionState

func (s *Service) UpdateAttachedSessionState(update AttachedSessionStateUpdate)

func (*Service) UpdateRuntimeSelection

func (s *Service) UpdateRuntimeSelection(claudeEnabled, codexEnabled bool, claudeCommand, codexCommand string, runtimeCatalog []protocol.RuntimeCapability)

type SessionConfigContext

type SessionConfigContext struct {
	Runtime               string
	CurrentWorkingDir     string
	CurrentModel          string
	CurrentPermissionMode string
	CurrentSandboxMode    string
}

Jump to

Keyboard shortcuts

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