Documentation
¶
Index ¶
- Constants
- func VerifySelectedSDK(ctx context.Context, goPath, source, expectedRevision string, ...) (devsource.Identity, error)
- type BuildError
- type BuildOpts
- type DevProcessStatus
- type DevServerErrorPayload
- type DevServerInstance
- func (inst *DevServerInstance) GetLogs(count int) []LogEntry
- func (inst *DevServerInstance) Start() error
- func (inst *DevServerInstance) State() DevServerState
- func (inst *DevServerInstance) Stop() error
- func (inst *DevServerInstance) TriggerRebuild() error
- func (inst *DevServerInstance) VitePGID() int
- type DevServerManager
- func (m *DevServerManager) ConfigureDependencyWatching(enabled bool) error
- func (manager *DevServerManager) ConfigurePNPMCommands(commands map[string]PNPMCommand) error
- func (m *DevServerManager) ConfigureProcessSupervisor(config devsession.ProcessBridgeConfig) error
- func (m *DevServerManager) ConfigureWorkspace(profile instance.Profile, registryRoot, expectedSDKRevision string) error
- func (m *DevServerManager) GetDevServerLogs(pluginID string, count int) []LogEntry
- func (m *DevServerManager) GetDevServerState(pluginID string) DevServerState
- func (m *DevServerManager) IsManaged(pluginID string) bool
- func (m *DevServerManager) LifecycleGeneration(id, source string) string
- func (m *DevServerManager) ListDevServerStates() []DevServerState
- func (m *DevServerManager) NotifyPluginLifecycle(id, source, generation string, rpc, controllers bool, lifecycleErr error) bool
- func (m *DevServerManager) RebuildPlugin(pluginID string) error
- func (m *DevServerManager) RebuildPluginGeneration(ctx context.Context, id, generation string) error
- func (m *DevServerManager) RestartDevServer(pluginID string) (DevServerState, error)
- func (m *DevServerManager) RuntimeGeneration(id, source string) string
- func (m *DevServerManager) ServiceShutdown() error
- func (m *DevServerManager) ServiceStartup(ctx context.Context, _ application.ServiceOptions) error
- func (m *DevServerManager) SetDependencyWatching(id, generation string, enabled bool) error
- func (m *DevServerManager) StartDevServer(pluginID string) (DevServerState, error)
- func (m *DevServerManager) StartDevServerForPath(pluginID, devPath string) (DevServerState, error)
- func (m *DevServerManager) StopDevServer(pluginID string) error
- func (m *DevServerManager) SupervisorOwnsStartup() bool
- func (manager *DevServerManager) ValidateManagedSource(id, source string) (bool, error)
- func (m *DevServerManager) WaitReady(ctx context.Context, id, generation string) (DevServerState, error)
- func (m *DevServerManager) WatchedGoDirectories(id string) []string
- type DevServerMode
- type DevServerState
- type LifecycleStage
- type LogEntry
- type LogRingBuffer
- type PNPMCommand
- type PluginRef
- type PluginReloader
- type PortAllocator
- func (pa *PortAllocator) Allocate(id string) (int, error)
- func (pa *PortAllocator) BindFailed(id string) error
- func (pa *PortAllocator) CleanupStaleProcesses(ctx context.Context, logger logging.Logger)
- func (pa *PortAllocator) ConfirmBound(id string) error
- func (pa *PortAllocator) GetPort(id string) int
- func (pa *PortAllocator) RecordProcess(port int, record devcontract.ProcessIdentity) error
- func (pa *PortAllocator) Release(port int)
- func (pa *PortAllocator) ReleaseByPlugin(id string) int
- func (pa *PortAllocator) SavePIDs() error
- type ServiceWrapper
- func (s *ServiceWrapper) GetDevServerLogs(pluginID string, count int) []LogEntry
- func (s *ServiceWrapper) GetDevServerState(pluginID string) DevServerState
- func (s *ServiceWrapper) IsManaged(pluginID string) bool
- func (s *ServiceWrapper) ListDevServerStates() []DevServerState
- func (s *ServiceWrapper) RebuildPlugin(pluginID string) error
- func (s *ServiceWrapper) RestartDevServer(pluginID string) (DevServerState, error)
- func (s *ServiceWrapper) ServiceShutdown() error
- func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error
- func (s *ServiceWrapper) StartDevServer(pluginID string) (DevServerState, error)
- func (s *ServiceWrapper) StartDevServerForPath(pluginID, devPath string) (DevServerState, error)
- func (s *ServiceWrapper) StopDevServer(pluginID string) error
- type StartupError
Constants ¶
const ( PortRangeStart = 15173 PortRangeEnd = 15273 )
const ( // EventDevServerStatus is emitted whenever any field in DevServerState changes. // Payload: DevServerState. EventDevServerStatus = "plugin/devserver/status" // EventDevServerLog is emitted for batched log lines from Vite or Go build. // Payload: []LogEntry (each entry contains pluginID). EventDevServerLog = "plugin/devserver/log" // EventDevServerError is emitted for structured build errors. // Payload: (pluginID string, errors []BuildError). EventDevServerError = "plugin/devserver/error" )
const ( // DedupInterval is the debounce window for file change events. DedupInterval = 500 * time.Millisecond )
const DefaultLogBufferSize = 5000
Variables ¶
This section is empty.
Functions ¶
func VerifySelectedSDK ¶ added in v0.5.0
func VerifySelectedSDK(ctx context.Context, goPath, source, expectedRevision string, environment []string) (devsource.Identity, error)
VerifySelectedSDK validates the actual module selected by Go with GOWORK=off, including replacements. expectedRevision is a trusted reviewed fixed-source commit supplied by the host build graph, not metadata from the plugin repo. Managed workspace verification also binds that module to the canonical SDK checkout selected by the explicitly validated workspace/profile. The shared source verifier protects the reviewed containment core and records ordinary dirty SDK feature changes in the exact build source digest.
Types ¶
type BuildError ¶
type BuildError struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Message string `json:"message"`
}
BuildError is a structured build error parsed from Go compiler output.
type BuildOpts ¶
type BuildOpts struct {
GoPath string
PnpmPath string
PnpmArgs []string
NodePath string
Environment []string
StateRoot string
ExpectedSDKRevision string
ViteStarted func(devcontract.ProcessIdentity) error
ViteOwner devsession.ProcessOwner
ProcessSupervisor *devsession.ProcessBridgeClient
ExplicitPnpmPath string
ExplicitNodePath string
Generation string
DisableDependencyWatching bool
Workspace *devcontract.ResolvedWorkspace
}
BuildOpts holds resolved paths to build tools.
type DevProcessStatus ¶
type DevProcessStatus string
DevProcessStatus describes the current status of either the Vite process or the Go watcher.
const ( DevProcessStatusIdle DevProcessStatus = "idle" DevProcessStatusStarting DevProcessStatus = "starting" DevProcessStatusBuilding DevProcessStatus = "building" DevProcessStatusRunning DevProcessStatus = "running" DevProcessStatusReady DevProcessStatus = "ready" DevProcessStatusError DevProcessStatus = "error" DevProcessStatusStopped DevProcessStatus = "stopped" DevProcessStatusNotApplicable DevProcessStatus = "n/a" )
type DevServerErrorPayload ¶ added in v0.4.0
type DevServerErrorPayload struct {
PluginID string `json:"pluginID"`
Errors []BuildError `json:"errors"`
}
DevServerErrorPayload wraps a plugin ID and its build errors into a single event payload so it can be registered with RegisterEvent[T].
type DevServerInstance ¶
type DevServerInstance struct {
// contains filtered or unexported fields
}
DevServerInstance manages the dev server lifecycle for a single plugin. It coordinates the Vite process and Go file watcher.
func NewDevServerInstance ¶
func NewDevServerInstance( parentCtx context.Context, logger logging.Logger, pluginID string, devPath string, vitePort int, buildOpts BuildOpts, reloader PluginReloader, pluginsRoot *appstate.ScopedRoot, onStatus emitStatusFunc, onLogs emitLogsFunc, onErrors emitErrorsFunc, ) *DevServerInstance
NewDevServerInstance creates a new instance. Call Start() to begin.
func (*DevServerInstance) GetLogs ¶
func (inst *DevServerInstance) GetLogs(count int) []LogEntry
GetLogs returns log entries from the ring buffer.
func (*DevServerInstance) Start ¶
func (inst *DevServerInstance) Start() error
Start spawns the Vite dev server and Go watcher in background goroutines.
func (*DevServerInstance) State ¶
func (inst *DevServerInstance) State() DevServerState
State returns a snapshot of the current state, safe for JSON serialization.
func (*DevServerInstance) Stop ¶
func (inst *DevServerInstance) Stop() error
Stop gracefully stops both the Vite process and Go watcher. Sub-processes are stopped BEFORE the context is cancelled so that their Stop methods can still look up and signal the process group.
func (*DevServerInstance) TriggerRebuild ¶ added in v0.2.0
func (inst *DevServerInstance) TriggerRebuild() error
TriggerRebuild triggers an explicit Go rebuild + transfer + reload cycle.
func (*DevServerInstance) VitePGID ¶
func (inst *DevServerInstance) VitePGID() int
VitePGID returns the process group ID of the Vite child process, or 0.
type DevServerManager ¶
type DevServerManager struct {
// contains filtered or unexported fields
}
DevServerManager manages dev server instances for plugins in development mode. It is exposed as a Wails binding. All public methods are callable from the frontend.
func NewDevServerManager ¶
func NewDevServerManager( logger logging.Logger, stateRoot *appstate.ScopedRoot, pluginsRoot *appstate.ScopedRoot, pluginRef PluginRef, pluginReloader PluginReloader, settingsProvider pkgsettings.Provider, ) *DevServerManager
NewDevServerManager creates a new DevServerManager. Call Initialize() with the Wails context before using any other methods.
func (*DevServerManager) ConfigureDependencyWatching ¶ added in v0.5.0
func (m *DevServerManager) ConfigureDependencyWatching(enabled bool) error
ConfigureDependencyWatching is startup configuration for the single watch graph.
func (*DevServerManager) ConfigurePNPMCommands ¶ added in v0.5.0
func (manager *DevServerManager) ConfigurePNPMCommands(commands map[string]PNPMCommand) error
ConfigurePNPMCommands runs after ConfigureWorkspace and before managed starts. The launcher supplies one exact packageManager runner for each selected UI plugin; no global pin, shell command string or devworkspace import is needed.
func (*DevServerManager) ConfigureProcessSupervisor ¶ added in v0.5.0
func (m *DevServerManager) ConfigureProcessSupervisor(config devsession.ProcessBridgeConfig) error
ConfigureProcessSupervisor enables the outer workspace supervisor's retained frontend Cmd ownership. It is explicit and startup-only; absence keeps the local retained runner, never an error-triggered remote-to-local fallback.
func (*DevServerManager) ConfigureWorkspace ¶ added in v0.5.0
func (m *DevServerManager) ConfigureWorkspace(profile instance.Profile, registryRoot, expectedSDKRevision string) error
ConfigureWorkspace is startup-only, before services/managed plugins start. expectedSDKRevision must come from the trusted reviewed-source build graph, never plugin.yaml or a plugin-controlled environment value.
func (*DevServerManager) GetDevServerLogs ¶
func (m *DevServerManager) GetDevServerLogs(pluginID string, count int) []LogEntry
GetDevServerLogs returns the most recent log entries for a plugin's dev server.
func (*DevServerManager) GetDevServerState ¶
func (m *DevServerManager) GetDevServerState(pluginID string) DevServerState
GetDevServerState returns the current state of the dev server for a single plugin.
func (*DevServerManager) IsManaged ¶
func (m *DevServerManager) IsManaged(pluginID string) bool
IsManaged returns true if the plugin's dev server is currently managed by this manager, either via IDE-managed mode or external mode.
func (*DevServerManager) LifecycleGeneration ¶ added in v0.5.0
func (m *DevServerManager) LifecycleGeneration(id, source string) string
func (*DevServerManager) ListDevServerStates ¶
func (m *DevServerManager) ListDevServerStates() []DevServerState
ListDevServerStates returns the state of all running dev server instances, including externally-managed plugins.
func (*DevServerManager) NotifyPluginLifecycle ¶ added in v0.5.0
func (m *DevServerManager) NotifyPluginLifecycle(id, source, generation string, rpc, controllers bool, lifecycleErr error) bool
NotifyPluginLifecycle rejects late observations from stopped/rebound sessions.
func (*DevServerManager) RebuildPlugin ¶ added in v0.2.0
func (m *DevServerManager) RebuildPlugin(pluginID string) error
RebuildPlugin triggers a Go rebuild, transfers the binary, and reloads the plugin without restarting the Vite dev server.
func (*DevServerManager) RebuildPluginGeneration ¶ added in v0.5.0
func (m *DevServerManager) RebuildPluginGeneration(ctx context.Context, id, generation string) error
func (*DevServerManager) RestartDevServer ¶
func (m *DevServerManager) RestartDevServer(pluginID string) (DevServerState, error)
RestartDevServer stops and then starts the dev server for the given plugin.
func (*DevServerManager) RuntimeGeneration ¶ added in v0.5.0
func (m *DevServerManager) RuntimeGeneration(id, source string) string
RuntimeGeneration changes for each replacement build, independently of the stable managed watcher generation used by control operations.
func (*DevServerManager) ServiceShutdown ¶ added in v0.4.0
func (m *DevServerManager) ServiceShutdown() error
ServiceShutdown stops all owned managed dev server instances.
func (*DevServerManager) ServiceStartup ¶ added in v0.4.0
func (m *DevServerManager) ServiceStartup(ctx context.Context, _ application.ServiceOptions) error
ServiceStartup is called during Wails v3 service startup. It stores the application reference and starts the external plugin watcher.
func (*DevServerManager) SetDependencyWatching ¶ added in v0.5.0
func (m *DevServerManager) SetDependencyWatching(id, generation string, enabled bool) error
SetDependencyWatching hands dependency invalidation to A15 without creating a second owner. Plugin source/root watching remains in this canonical watcher.
func (*DevServerManager) StartDevServer ¶
func (m *DevServerManager) StartDevServer(pluginID string) (DevServerState, error)
StartDevServer starts a managed dev server for the given plugin. This spawns a Vite dev server process and a Go file watcher. The plugin must already be loaded in dev mode (DevMode=true, DevPath set).
Returns the initial DevServerState.
func (*DevServerManager) StartDevServerForPath ¶
func (m *DevServerManager) StartDevServerForPath(pluginID, devPath string) (DevServerState, error)
StartDevServerForPath starts a managed dev server for a plugin using the provided devPath directly, without requiring the plugin to be loaded first. This is used during InstallInDevMode and Initialize where the plugin hasn't been loaded yet but we need the dev server (and its initial Go build) to run before LoadPlugin.
func (*DevServerManager) StopDevServer ¶
func (m *DevServerManager) StopDevServer(pluginID string) error
StopDevServer stops the managed dev server for the given plugin.
func (*DevServerManager) SupervisorOwnsStartup ¶ added in v0.5.0
func (m *DevServerManager) SupervisorOwnsStartup() bool
SupervisorOwnsStartup reports whether this host's validated workspace supervisor owns initial selected-source linking. A workspace configured without that process capability retains standalone dev-plugin restoration.
func (*DevServerManager) ValidateManagedSource ¶ added in v0.5.0
func (manager *DevServerManager) ValidateManagedSource(id, source string) (bool, error)
ValidateManagedSource reports whether workspace selection is authoritative and rejects an unselected or rebound development source. ConfigureWorkspace is the sole source of this policy; persisted plugin state cannot extend the manifest.
func (*DevServerManager) WaitReady ¶ added in v0.5.0
func (m *DevServerManager) WaitReady(ctx context.Context, id, generation string) (DevServerState, error)
func (*DevServerManager) WatchedGoDirectories ¶ added in v0.5.0
func (m *DevServerManager) WatchedGoDirectories(id string) []string
type DevServerMode ¶
type DevServerMode string
DevServerMode describes how the dev server for a plugin is managed.
const ( // DevServerModeIdle means no dev server is running for this plugin. DevServerModeIdle DevServerMode = "idle" // DevServerModeManaged means the IDE spawned and manages the Vite + Go watcher processes. DevServerModeManaged DevServerMode = "managed" )
type DevServerState ¶
type DevServerState struct {
PluginID string `json:"pluginID"`
Mode DevServerMode `json:"mode"`
DevPath string `json:"devPath"`
VitePort int `json:"vitePort"`
ViteURL string `json:"viteURL"`
ViteStatus DevProcessStatus `json:"viteStatus"`
GoStatus DevProcessStatus `json:"goStatus"`
LastBuildDuration time.Duration `json:"lastBuildDuration"`
LastBuildTime string `json:"lastBuildTime"`
LastError string `json:"lastError"`
GRPCConnected bool `json:"grpcConnected"`
Generation string `json:"generation"`
HMRURL string `json:"hmrURL"`
BuildStatus LifecycleStage `json:"buildStatus"`
RPCStatus LifecycleStage `json:"rpcStatus"`
ControllerStatus LifecycleStage `json:"controllerStatus"`
Ready bool `json:"ready"`
}
DevServerState is the JSON-serializable state of a single plugin's dev server. This is sent to the frontend via Wails events and returned from query methods.
type LifecycleStage ¶ added in v0.5.0
type LifecycleStage string
LifecycleStage distinguishes successful compilation from a live plugin.
const ( StagePending LifecycleStage = "pending" StageBuilding LifecycleStage = "building" StageReady LifecycleStage = "ready" StageError LifecycleStage = "error" StageStopped LifecycleStage = "stopped" StageNotApplicable LifecycleStage = "n/a" )
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"timestamp"`
Source string `json:"source"` // "vite" | "go-build" | "go-watch" | "manager"
Level string `json:"level"` // "info" | "warn" | "error" | "debug"
Message string `json:"message"`
PluginID string `json:"pluginID"`
}
LogEntry is a single log line from either the Vite process or the Go build.
type LogRingBuffer ¶
type LogRingBuffer struct {
// contains filtered or unexported fields
}
LogRingBuffer is a fixed-size circular buffer for log entries. It is NOT thread-safe on its own; callers must hold the instance mutex.
func NewLogRingBuffer ¶
func NewLogRingBuffer(capacity int) *LogRingBuffer
NewLogRingBuffer creates a ring buffer with the given capacity.
func (*LogRingBuffer) Entries ¶
func (rb *LogRingBuffer) Entries() []LogEntry
Entries returns all entries in chronological order (oldest first).
func (*LogRingBuffer) Last ¶
func (rb *LogRingBuffer) Last(n int) []LogEntry
Last returns the most recent n entries in chronological order.
func (*LogRingBuffer) Push ¶
func (rb *LogRingBuffer) Push(entry LogEntry)
Push adds an entry to the ring buffer, overwriting the oldest if full.
type PNPMCommand ¶ added in v0.5.0
type PNPMCommand struct {
Program string `json:"program"`
Args []string `json:"args"`
Source string `json:"source"`
WorkspaceRoot string `json:"workspaceRoot"`
Version string `json:"version"`
}
PNPMCommand is a concrete native program plus an owned pnpm runner prefix, bound to one canonical plugin source. Args excludes the task arguments.
type PluginRef ¶
type PluginRef interface {
GetDevPluginInfo(pluginID string) (devMode bool, devPath string, err error)
}
PluginRef is the minimal interface for reading plugin info. This avoids importing the plugin package (which would cause circular deps).
type PluginReloader ¶
PluginReloader is the interface for reloading plugins after Go rebuild.
type PortAllocator ¶
type PortAllocator struct {
// contains filtered or unexported fields
}
PortAllocator uses shared sticky leases in workspaces. Production's legacy managed tools may allocate locally, but never persist numeric kill authority.
func NewPortAllocator ¶
func NewPortAllocator(root *appstate.ScopedRoot) *PortAllocator
func (*PortAllocator) BindFailed ¶ added in v0.5.0
func (pa *PortAllocator) BindFailed(id string) error
func (*PortAllocator) CleanupStaleProcesses ¶
func (pa *PortAllocator) CleanupStaleProcesses(ctx context.Context, logger logging.Logger)
func (*PortAllocator) ConfirmBound ¶ added in v0.5.0
func (pa *PortAllocator) ConfirmBound(id string) error
func (*PortAllocator) GetPort ¶
func (pa *PortAllocator) GetPort(id string) int
func (*PortAllocator) RecordProcess ¶ added in v0.5.0
func (pa *PortAllocator) RecordProcess(port int, record devcontract.ProcessIdentity) error
RecordProcess accepts a verified actual child identity, never a numeric PID recovered or adopted from a status record. The local Cmd or retained outer supervisor captures this identity immediately after its own successful Start.
func (*PortAllocator) Release ¶
func (pa *PortAllocator) Release(port int)
func (*PortAllocator) ReleaseByPlugin ¶
func (pa *PortAllocator) ReleaseByPlugin(id string) int
func (*PortAllocator) SavePIDs ¶
func (pa *PortAllocator) SavePIDs() error
SavePIDs retains rejected records. A stale/foreign record is not erased simply because the next supervisor could not safely terminate it (notably Darwin).
type ServiceWrapper ¶ added in v0.4.0
type ServiceWrapper struct {
Mgr *DevServerManager
}
ServiceWrapper exposes only frontend-safe methods of devserver.DevServerManager. The DevServerManager implements ServiceStartup/ServiceShutdown directly, but registering it raw causes service/model shadowing. This wrapper separates the service identity from the model type.
func (*ServiceWrapper) GetDevServerLogs ¶ added in v0.4.0
func (s *ServiceWrapper) GetDevServerLogs(pluginID string, count int) []LogEntry
func (*ServiceWrapper) GetDevServerState ¶ added in v0.4.0
func (s *ServiceWrapper) GetDevServerState(pluginID string) DevServerState
func (*ServiceWrapper) IsManaged ¶ added in v0.4.0
func (s *ServiceWrapper) IsManaged(pluginID string) bool
func (*ServiceWrapper) ListDevServerStates ¶ added in v0.4.0
func (s *ServiceWrapper) ListDevServerStates() []DevServerState
func (*ServiceWrapper) RebuildPlugin ¶ added in v0.4.0
func (s *ServiceWrapper) RebuildPlugin(pluginID string) error
func (*ServiceWrapper) RestartDevServer ¶ added in v0.4.0
func (s *ServiceWrapper) RestartDevServer(pluginID string) (DevServerState, error)
func (*ServiceWrapper) ServiceShutdown ¶ added in v0.4.0
func (s *ServiceWrapper) ServiceShutdown() error
func (*ServiceWrapper) ServiceStartup ¶ added in v0.4.0
func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error
func (*ServiceWrapper) StartDevServer ¶ added in v0.4.0
func (s *ServiceWrapper) StartDevServer(pluginID string) (DevServerState, error)
func (*ServiceWrapper) StartDevServerForPath ¶ added in v0.4.0
func (s *ServiceWrapper) StartDevServerForPath(pluginID, devPath string) (DevServerState, error)
func (*ServiceWrapper) StopDevServer ¶ added in v0.4.0
func (s *ServiceWrapper) StopDevServer(pluginID string) error
type StartupError ¶ added in v0.7.0
StartupError retains diagnostics after a failed instance has been cleaned up.
func (*StartupError) Error ¶ added in v0.7.0
func (e *StartupError) Error() string
func (*StartupError) Unwrap ¶ added in v0.7.0
func (e *StartupError) Unwrap() error