webserver

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 89 Imported by: 0

Documentation

Overview

Package webserver provides the embedded HTTP server for honey.

Package webserver provides the embedded HTTP server for honey.

@title Honey Web API @version 1.0 @description REST API for the honey web UI (`honey web`). Authenticate with the same token printed at startup, or `HONEY_WEB_TOKEN`. WebSocket endpoints `GET /ws/ssh` and `GET /ws/pve-qemu-vnc` are not described by this OpenAPI document.

@contact.name honey

@host 127.0.0.1:8765 @BasePath / @schemes http

@securityDefinitions.apikey BearerAuth @in header @name Authorization @description Use `Authorization: Bearer <token>` where `<token>` is the web UI token.

@securityDefinitions.apikey HoneyTokenHeader @in header @name X-Honey-Token @description Alternative header: `X-Honey-Token: <token>`.

@securityDefinitions.apikey TokenQuery @in query @name token @description Optional query token (same value) for URLs: `?token=<token>`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthToken

func AuthToken() (string, error)

AuthToken returns a fixed token from the environment when set, or generates a random hex token.

func ResolveToken added in v0.3.5

func ResolveToken(stateDir string) (string, error)

ResolveToken returns a stable web auth token. Precedence:

  1. HONEY_WEB_TOKEN env var, if set;
  2. a token previously persisted at stateDir/web_token;
  3. a freshly generated token, which is then persisted to stateDir/web_token.

Persisting the generated token keeps it stable across restarts (e.g. a docker container with a mounted state volume) so a bookmarked ?token= URL keeps working. A persist failure is non-fatal: the generated (ephemeral) token is still returned.

Types

type AIAssistant added in v0.3.6

type AIAssistant interface {
	// contains filtered or unexported methods
}

AIAssistant abstracts the AI-related functionality required by recipe generation and assistance.

type ActiveTunnel added in v0.2.9

type ActiveTunnel struct {
	ID        string    `json:"id"`
	Host      string    `json:"host"`
	RecordKey string    `json:"record_key"`
	Mapping   string    `json:"mapping"`
	StartedAt time.Time `json:"started_at"`
	Error     string    `json:"error,omitempty"`
	// contains filtered or unexported fields
}

ActiveTunnel is one in-process SSH port-forward tunnel.

type ConfigBackendEntryBody added in v0.2.9

type ConfigBackendEntryBody map[string]interface{}

ConfigBackendEntryBody is one backends.{kind}[] element; shape depends on path param kind.

type ConfigSchemaResponse added in v0.2.9

type ConfigSchemaResponse struct {
	JSONSchema map[string]interface{} `json:"json_schema"`
	UISchema   any                    `json:"ui_schema"`
}

ConfigSchemaResponse is returned by GET /api/v1/config/schema.

type CueExecDryRunResponse added in v0.2.9

type CueExecDryRunResponse struct {
	Plan           string            `json:"plan"`
	RiskAssessment []engine.StepRisk `json:"risk_assessment,omitempty"`
}

CueExecDryRunResponse is the JSON body when cue-exec runs in dry-run mode.

type CueExecExecuteResponse added in v0.2.9

type CueExecExecuteResponse struct {
	Results []engine.HostExecResult `json:"results"`
}

CueExecExecuteResponse is the JSON body when cue-exec runs with execute true.

type CueExecRequest added in v0.2.9

type CueExecRequest struct {
	RecipePath    string                 `json:"recipe_path,omitempty"`
	RecipeContent map[string]interface{} `json:"recipe_content,omitempty"`
	Execute       bool                   `json:"execute"`
	SSHUser       string                 `json:"ssh_user"`
	ApprovalID    string                 `json:"approval_id,omitempty"`
	Records       []hosts.Record         `json:"records"`
	Env           []string               `json:"env,omitempty"`
	RecordSession bool                   `json:"record_session"`
	Timeout       string                 `json:"timeout,omitempty"` // per-host command timeout (e.g. "30s"); empty uses config default
}

CueExecRequest is the JSON body for POST /api/v1/cue-exec.

type DeviceCA added in v0.3.6

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

DeviceCA is a minimal certificate authority that signs short-lived client certificates for enrolled devices. The CA keypair (EC P-256) is persisted under the state dir and reused across restarts. Its public cert goes into the gateway's mTLS client-CA trust store (see examples/mtls/apisix).

func LoadOrCreateDeviceCA added in v0.3.6

func LoadOrCreateDeviceCA(dir string) (*DeviceCA, error)

LoadOrCreateDeviceCA loads the CA from dir, or generates + persists one.

func (*DeviceCA) CertPEM added in v0.3.6

func (ca *DeviceCA) CertPEM() []byte

CertPEM returns the CA certificate in PEM form (for the gateway trust store).

func (*DeviceCA) Fingerprint added in v0.3.6

func (ca *DeviceCA) Fingerprint() string

Fingerprint is the hex SHA-256 of the CA certificate DER (for pinning).

func (*DeviceCA) Sign added in v0.3.6

func (ca *DeviceCA) Sign(csr *x509.CertificateRequest, cn string, ttl time.Duration) ([]byte, error)

Sign issues a client certificate for cn (valid for ttl) using the CSR's public key. The CSR signature is verified first.

type DeviceRecord added in v0.3.6

type DeviceRecord struct {
	CN          string    `json:"cn"`
	Fingerprint string    `json:"fingerprint"`
	IssuedAt    time.Time `json:"issued_at"`
	NotAfter    time.Time `json:"not_after"`
}

DeviceRecord is an issued device certificate, for listing / audit.

type EnrollAPI added in v0.3.7

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

EnrollAPI owns the mTLS device-enrollment endpoints (mint code / enroll / list). ca and store are nil-together when no state dir is available, in which case the endpoints report 503. Extracted from Server so the enrollment feature carries its own dependencies (mirrors RecipesAPI).

func NewEnrollAPI added in v0.3.7

func NewEnrollAPI(ca *DeviceCA, store *enrollStore) *EnrollAPI

NewEnrollAPI wires the device CA and enroll store. Pass (nil, nil) when enrollment is unavailable.

type ExecRequest added in v0.2.9

type ExecRequest struct {
	SSHUser               string         `json:"ssh_user"`
	Command               string         `json:"command"`
	ExecMode              string         `json:"exec_mode,omitempty"`
	ScriptInterpreter     string         `json:"script_interpreter,omitempty"`
	InterpreterArgsQuoted bool           `json:"interpreter_args_quoted,omitempty"`
	FileExtension         string         `json:"file_extension,omitempty"`
	RemoveTmpFile         *bool          `json:"remove_tmp_file,omitempty"`
	RunAs                 string         `json:"run_as,omitempty"`
	ScriptArgs            []string       `json:"script_args,omitempty"`
	Records               []hosts.Record `json:"records"`
	RecordSession         bool           `json:"record_session"`
	Timeout               string         `json:"timeout,omitempty"`          // per-host command timeout (e.g. "30s"); empty uses config default
	MaxOutputBytes        int            `json:"max_output_bytes,omitempty"` // 0 = default (6000), < 0 = unlimited
}

ExecRequest is the JSON body for POST /api/v1/exec.

type ExecResponse added in v0.2.9

type ExecResponse struct {
	Results []engine.HostExecResult `json:"results"`
}

ExecResponse is the JSON body for a successful exec run.

type FilesAPI added in v0.3.7

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

FilesAPI owns the file-management HTTP endpoints (upload + local/remote file browsing, copy, agent transfer, stat/mkdir/remove, streamed up/download), isolating them from the main Server so the file feature carries its own dependencies (mirrors EnrollAPI/RecipesAPI, architecture candidate arch-08).

func NewFilesAPI added in v0.3.7

func NewFilesAPI(opts Options, m *metrics.Registry, fileClientCache *engine.ClientCache, sshUser func(string) string) *FilesAPI

NewFilesAPI wires the file subsystem's dependencies. sshUser is injected (Server.sshUser) because it is shared Server-wide, not owned by this module.

type FilesAgentTransferRequest added in v0.2.9

type FilesAgentTransferRequest struct {
	SSHUser         string                   `json:"ssh_user"`
	AgentLocalPath  string                   `json:"agent_local_path,omitempty"`
	AgentRemoteDir  string                   `json:"agent_remote_dir,omitempty"`
	SourceRecord    hosts.Record             `json:"source_record"`
	SourcePath      string                   `json:"source_path"`
	DestRecord      hosts.Record             `json:"dest_record"`
	DestPath        string                   `json:"dest_path"`
	Cloud           engine.AgentCloudBackend `json:"cloud"`
	CloudBackendRef *engine.CloudBackendRef  `json:"cloud_backend_ref,omitempty"`
	Credentials     map[string]string        `json:"credentials"`
	KeepObject      bool                     `json:"keep_object,omitempty"`
	MaxRetries      int                      `json:"max_retries,omitempty"`
}

FilesAgentTransferRequest is the JSON body for agent-mediated file transfer.

type FilesAgentTransferResponse added in v0.2.9

type FilesAgentTransferResponse struct {
	Events []engine.AgentTransferEvent `json:"events"`
}

FilesAgentTransferResponse is the JSON body for agent transfer results.

type FilesCopyRequest added in v0.2.9

type FilesCopyRequest struct {
	Direction  string       `json:"direction"`
	SSHUser    string       `json:"ssh_user"`
	Record     hosts.Record `json:"record"`
	LocalPath  string       `json:"local_path"`
	RemotePath string       `json:"remote_path"`
}

FilesCopyRequest is the JSON body for copy between local and remote paths.

type FilesCopyResponse added in v0.2.9

type FilesCopyResponse struct {
	Status string `json:"status"`
	Local  string `json:"local"`
	Remote string `json:"remote"`
}

FilesCopyResponse is returned by POST /api/v1/files/copy.

type FilesLocalListRequest added in v0.2.9

type FilesLocalListRequest struct {
	Path string `json:"path"`
}

FilesLocalListRequest is the JSON body for listing local files.

type FilesLocalListResponse added in v0.2.9

type FilesLocalListResponse struct {
	Root    string              `json:"root"`
	Path    string              `json:"path"`
	Entries []ui.LocalFileEntry `json:"entries"`
}

FilesLocalListResponse is the JSON body for local list results.

type FilesRemoteListRequest added in v0.2.9

type FilesRemoteListRequest struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Path    string       `json:"path"`
}

FilesRemoteListRequest is the JSON body for listing remote files over SSH.

type FilesRemoteListResponse added in v0.2.9

type FilesRemoteListResponse struct {
	Path    string                   `json:"path"`
	Entries []engine.RemoteFileEntry `json:"entries"`
}

FilesRemoteListResponse is the JSON body for remote list results.

type FilesRemoteMkdirRequest added in v0.3.6

type FilesRemoteMkdirRequest struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Path    string       `json:"path"`
}

FilesRemoteMkdirRequest is the JSON body for creating a remote directory over SSH.

type FilesRemoteMkdirResponse added in v0.3.6

type FilesRemoteMkdirResponse struct {
	Success bool `json:"success"`
}

FilesRemoteMkdirResponse is the JSON body for remote mkdir results.

type FilesRemoteRemoveRequest added in v0.3.6

type FilesRemoteRemoveRequest struct {
	SSHUser   string       `json:"ssh_user"`
	Record    hosts.Record `json:"record"`
	Path      string       `json:"path"`
	Recursive bool         `json:"recursive"`
}

FilesRemoteRemoveRequest is the JSON body for removing a remote file/directory over SSH.

type FilesRemoteRemoveResponse added in v0.3.6

type FilesRemoteRemoveResponse struct {
	Success bool `json:"success"`
}

FilesRemoteRemoveResponse is the JSON body for remote remove results.

type FilesRemoteStatRequest added in v0.3.6

type FilesRemoteStatRequest struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Path    string       `json:"path"`
}

FilesRemoteStatRequest is the JSON body for stating a remote file over SSH.

type FilesRemoteStatResponse added in v0.3.6

type FilesRemoteStatResponse struct {
	Entry engine.RemoteFileEntry `json:"entry"`
}

FilesRemoteStatResponse is the JSON body for remote stat results.

type ForwardingAPI added in v0.3.7

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

ForwardingAPI owns the WebSocket forwarding/relay endpoints (ws/tunnel, ws/remote-forward, ws/udp), isolating them from the main Server so the feature carries its own deps (mirrors FilesAPI/ProxyAPI/TunnelsAPI, arch-08). authorized and sshUser are injected (shared Server-wide). remoteListenerFor and udpDialer are the seams tests inject to avoid real SSH/UDP; they move here from Server so a test still injects them post-construction (on s.forwardingAPI) before a request.

func NewForwardingAPI added in v0.3.7

func NewForwardingAPI(opts Options, authorized func(*http.Request) bool, sshUser func(string) string) *ForwardingAPI

NewForwardingAPI wires the shared auth + ssh-user resolvers and the production UDP dialer. remoteListenerFor stays nil (handlers fall back to defaultRemoteListener); tests overwrite either field on the returned value.

type GraphPlanRequest added in v0.2.9

type GraphPlanRequest struct {
	Path             string                 `json:"path,omitempty"`
	RecipeContent    map[string]interface{} `json:"recipe_content,omitempty"`
	RecipeContentRaw string                 `json:"recipe_content_raw,omitempty"`
}

GraphPlanRequest is the JSON body for POST /api/v1/recipes/graph-plan.

type HostPortsRequest added in v0.2.9

type HostPortsRequest struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
}

HostPortsRequest is the JSON body for POST /api/v1/host-ports.

type HostPortsResponse added in v0.2.9

type HostPortsResponse struct {
	Ports []string `json:"ports"`
}

HostPortsResponse is returned by POST /api/v1/host-ports.

type LibraryCategory added in v0.3.6

type LibraryCategory struct {
	Name    string          `json:"name"`
	Recipes []LibraryRecipe `json:"recipes"`
}

LibraryCategory groups LibraryRecipes by domain.

type LibraryRecipe added in v0.3.6

type LibraryRecipe struct {
	Name        string `json:"name"`
	Filename    string `json:"filename"`
	Description string `json:"description"`
	Content     string `json:"content"`
	Category    string `json:"category"`
}

LibraryRecipe represents a parsed recipe from the examples directory.

type LibraryResponse added in v0.3.6

type LibraryResponse struct {
	Categories []LibraryCategory `json:"categories"`
}

LibraryResponse is the JSON body for GET /api/v1/recipes/library.

type LintDiagnostic added in v0.3.4

type LintDiagnostic struct {
	Line     int    `json:"line"`
	Col      int    `json:"col"`
	Severity string `json:"severity"` // "error" | "warning"
	Message  string `json:"message"`
}

LintDiagnostic is one syntax/lint finding (1-based line/col).

type LintRequest added in v0.3.4

type LintRequest struct {
	Language string `json:"language"` // "bash" or "python"
	Content  string `json:"content"`
}

LintRequest is the JSON body for POST /api/v1/lint.

type LintResponse added in v0.3.4

type LintResponse struct {
	Available   bool             `json:"available"`
	Tool        string           `json:"tool,omitempty"`
	Diagnostics []LintDiagnostic `json:"diagnostics"`
}

LintResponse is the JSON body for a lint result. Available is false when no checker tool is installed on the server host (the UI then just highlights).

type MetaResponse added in v0.2.9

type MetaResponse struct {
	Version                   string `json:"version"`
	Commit                    string `json:"commit"`
	Date                      string `json:"date"`
	ConfigPath                string `json:"config_path"`
	SessionRecordingAvailable bool   `json:"session_recording_available"`
	SessionRecordingRetention string `json:"session_recording_retention,omitempty"`
	SessionRecordingLastPurge string `json:"session_recording_last_purge_at,omitempty"`
	TerminalAssistAvailable   bool   `json:"terminal_assist_available"`
	LogsCommandAllowed        bool   `json:"logs_command_allowed"`
	MetricsURL                string `json:"metrics_url,omitempty"`
}

MetaResponse is returned by GET /api/v1/meta.

type Options

type Options struct {
	ListenAddr         string // e.g. 127.0.0.1:8765
	Token              string
	DisableAuth        bool   // when true, skip token auth entirely (trusted networks / authenticating proxy)
	ConfigPath         string // optional explicit --config
	Config             *config.File
	ExecRegistry       hostexec.Registry
	SearchRegistry     *searchrun.Registry
	RecordDir          string // optional session recording output dir
	LocalFilesRoot     string // optional root for local file browser/upload/download
	AgentBinaryPath    string // optional explicit honey-transfer-agent binary path
	AgentBuildCacheDir string // optional cache dir for auto-built agent binary
	Version            string
	Commit             string
	Date               string
	MaxUploadSize      int64 // default 100 << 20
	MetricsListenAddr  string
	Metrics            *metrics.Registry
	NoCache            bool
	Refresh            bool
	AllowLogsCommand   bool
	// EnableMesh, when true, additionally serves this webserver's existing API
	// on a second listener obtained from internal/meshnet.Listener() — so other
	// honey instances can reach this one through the libp2p mesh (Circuit Relay
	// v2 + DCUtR), in addition to (not instead of) the normal TCP ListenAddr.
	// A misconfigured or not-yet-ready mesh must never prevent the ordinary
	// TCP listener from serving — see Start's handling below.
	EnableMesh bool
	OnReady    func() // called after the listener is bound, before serving

	// AuditSink receives one event per security-relevant action (approval decisions,
	// recipe runs). nil is replaced with a no-op sink in NewServer.
	AuditSink audit.Sink

	// JWTPubKey, when non-nil, enables Ed25519 JWT identity resolution: a valid
	// bearer JWT's subject claim becomes the request actor. nil disables JWT.
	JWTPubKey ed25519.PublicKey
	// TrustedProxyNets lists peer networks allowed to assert caller identity via
	// the X-Honey-User header. nil disables the trusted-header path.
	TrustedProxyNets []*net.IPNet
	// Enforcer, when non-nil, gates every authenticated API request through OPA.
	// nil disables the API policy gate.
	Enforcer *policy.Enforcer
	// Approvals holds pending require_approval runs. When nil, NewServer creates a
	// default in-memory store so the approval endpoints and recipe gate share one.
	Approvals *approval.Store
	// WebAuthn, when non-nil, enables passkey biometric step-up for
	// require_biometric verdicts and the /api/v1/webauthn/* endpoints.
	WebAuthn *webauthn.Manager

	// WebhookRatePerSecond and WebhookBurst control the per-app-name rate limit on
	// unauthenticated webhook endpoints. Defaults: 10 req/s, burst 20.
	WebhookRatePerSecond float64
	WebhookBurst         int
}

Options configures the embedded web server.

type PostgresAPI added in v0.3.7

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

PostgresAPI owns the Postgres data-browser endpoints (catalog + query), isolating them from the main Server so the feature carries its own deps (mirrors FilesAPI/EnrollAPI/RecipesAPI, architecture candidate arch-08). It reads the proxy session registry to resolve a running postgres tunnel, then queries through the pool manager.

func NewPostgresAPI added in v0.3.7

func NewPostgresAPI(opts Options, pgPools *postgres.PoolManager, proxyMgr *proxy.Manager) *PostgresAPI

NewPostgresAPI wires the pool manager and the shared proxy manager (used to look up the postgres tunnel session backing each request).

type PromptChoicesRequest added in v0.3.6

type PromptChoicesRequest struct {
	URL      string `json:"url"`
	JSONPath string `json:"json_path"` // Unused for now, we'll do filtering on frontend
}

PromptChoicesRequest is the request for POST /api/v1/recipes/prompts/choices

type PromptUploadResponse added in v0.3.6

type PromptUploadResponse struct {
	ID       string `json:"id"`
	Path     string `json:"path"`
	Filename string `json:"filename"`
	SHA      string `json:"sha"`
}

PromptUploadResponse is returned by POST /api/v1/recipes/prompts/upload.

type ProvidersResponse added in v0.2.9

type ProvidersResponse struct {
	Providers []string `json:"providers"`
}

ProvidersResponse is returned by GET /api/v1/providers.

type ProxyAPI added in v0.3.7

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

ProxyAPI owns the app-proxy session endpoints (list, start, stop), isolating them from the main Server so the feature carries its own deps (mirrors FilesAPI/PostgresAPI/TunnelsAPI/EnrollAPI, architecture candidate arch-08). It drives the proxy manager and resolves an app's dialer through the client cache + registries (opts). The /apps catalog listing stays on Server: it bridges the recipe module (recipesAPI.recipeWebhookNames), which this session module does not depend on.

func NewProxyAPI added in v0.3.7

func NewProxyAPI(opts Options, proxyMgr *proxy.Manager, fileClientCache *engine.ClientCache) *ProxyAPI

NewProxyAPI wires the proxy manager and the shared SSH client cache.

type PveQemuVncOfferRequest added in v0.2.9

type PveQemuVncOfferRequest struct {
	Record hosts.Record `json:"record"`
}

PveQemuVncOfferRequest is the JSON body for POST /api/v1/pve-qemu-vnc-offer.

type PveQemuVncOfferResponse added in v0.2.9

type PveQemuVncOfferResponse struct {
	SessionID   string `json:"session_id"`
	VNCPassword string `json:"vnc_password"`
}

PveQemuVncOfferResponse is returned on success.

type RecentRunEntry added in v0.2.9

type RecentRunEntry struct {
	RecipeName        string                  `json:"recipe_name"`
	RecipePath        string                  `json:"recipe_path"`
	HostCount         int                     `json:"host_count"`
	StartedAt         string                  `json:"started_at"`
	RecordingID       string                  `json:"recording_id"`
	RecipeContentHash string                  `json:"recipe_content_hash,omitempty"`
	Edited            bool                    `json:"edited"`
	Hosts             []hosts.Record          `json:"hosts,omitempty"`
	Plan              string                  `json:"plan,omitempty"`
	Graph             *cuetry.RecipeGraphPlan `json:"graph,omitempty"`
}

RecentRunEntry is one recent recipe run.

type RecentRunsResponse added in v0.2.9

type RecentRunsResponse struct {
	Runs []RecentRunEntry `json:"runs"`
}

RecentRunsResponse is returned by GET /api/v1/recipes/recent-runs.

type RecipeListEntry added in v0.2.9

type RecipeListEntry struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

RecipeListEntry is one recipe in the list API response.

type RecipeViewRequest added in v0.2.9

type RecipeViewRequest struct {
	Path string `json:"path"`
}

RecipeViewRequest is the JSON body for POST /api/v1/recipes/view.

type RecipeViewResponse added in v0.2.9

type RecipeViewResponse struct {
	Content string `json:"content"`
}

RecipeViewResponse is the JSON body for a successful recipe view.

type RecipesAIGraphResponse added in v0.3.6

type RecipesAIGraphResponse struct {
	Recipe      map[string]interface{} `json:"recipe"`
	Explanation string                 `json:"explanation,omitempty"`
}

RecipesAIGraphResponse is the JSON body returned by AI recipe endpoints.

type RecipesAPI added in v0.3.6

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

RecipesAPI handles all recipe-related HTTP endpoints, isolating them from the main Server.

func NewRecipesAPI added in v0.3.6

func NewRecipesAPI(
	opts Options,
	metrics *metrics.Registry,
	webhookQueue queue.Queue,
	pgPools *postgres.PoolManager,
	ai AIAssistant,
	plugins *plugincache.Cache,
	sshCache *engine.ClientCache,
) *RecipesAPI

NewRecipesAPI creates a new isolated router and handler set for Recipes.

recipeValidationCache/recipeGraphCache are constructed here rather than on Server: nothing outside RecipesAPI ever reads them, so storing them on Server too was pure duplication (architecture review candidate #6) — the same self-contained shape webhookDedupCache/webhookRL/webhookCapture below already followed.

func (*RecipesAPI) Routes added in v0.3.6

func (api *RecipesAPI) Routes() chi.Router

Routes returns a chi.Router with all standard recipe endpoints mounted.

func (*RecipesAPI) WebhookResultRoutes added in v0.3.6

func (api *RecipesAPI) WebhookResultRoutes() chi.Router

WebhookResultRoutes returns a chi.Router with authenticated webhook results endpoints.

func (*RecipesAPI) WebhookRoutes added in v0.3.6

func (api *RecipesAPI) WebhookRoutes() chi.Router

WebhookRoutes returns a chi.Router with unauthenticated webhook entrypoints.

type RecipesAssistFixRequest added in v0.3.6

type RecipesAssistFixRequest struct {
	RecipeContent map[string]interface{} `json:"recipe_content"`
	Errors        []ValidateContentError `json:"errors"`
	Model         string                 `json:"model"`
}

RecipesAssistFixRequest is the JSON body for POST /api/v1/recipes/assist-fix.

type RecipesAssistRequest added in v0.2.9

type RecipesAssistRequest struct {
	RecipePath string         `json:"recipe_path"`
	Model      string         `json:"model"`
	UserPrompt string         `json:"user_prompt"`
	SSHUser    string         `json:"ssh_user"`
	Records    []hosts.Record `json:"records"`
}

RecipesAssistRequest is the JSON body for POST /api/v1/recipes/assist.

type RecipesAssistResponse added in v0.2.9

type RecipesAssistResponse struct {
	Reply string `json:"reply"`
}

RecipesAssistResponse is the JSON body for a successful recipe assist reply.

type RecipesGenerateRequest added in v0.3.6

type RecipesGenerateRequest struct {
	Intent string `json:"intent"`
	Model  string `json:"model"`
}

RecipesGenerateRequest is the JSON body for POST /api/v1/recipes/generate.

type RecipesListResponse added in v0.2.9

type RecipesListResponse struct {
	Recipes []RecipeListEntry `json:"recipes"`
}

RecipesListResponse is the JSON body for GET /api/v1/recipes.

type RecipesParseRequest added in v0.2.9

type RecipesParseRequest struct {
	Path string `json:"path"`
}

RecipesParseRequest is the JSON body for POST /api/v1/recipes/parse.

type RecipesParseResponse added in v0.2.9

type RecipesParseResponse struct {
	Recipe map[string]interface{} `json:"recipe"`
}

RecipesParseResponse is the JSON body for a successful recipe parse.

type RecordingListEntry added in v0.2.9

type RecordingListEntry struct {
	FileName       string `json:"file_name"`
	ModifiedUnixMS int64  `json:"modified_unix_ms"`
	SizeBytes      int64  `json:"size_bytes"`
	Trigger        string `json:"trigger,omitempty"`
	Mode           string `json:"mode,omitempty"`
	Provider       string `json:"provider,omitempty"`
	HostName       string `json:"host_name,omitempty"`
	HostIP         string `json:"host_ip,omitempty"`
	User           string `json:"user,omitempty"`
}

RecordingListEntry is one session recording file in a list response.

type RecordingsListResponse added in v0.2.9

type RecordingsListResponse struct {
	Items      []RecordingListEntry     `json:"items"`
	FileCount  int                      `json:"file_count"`
	TotalBytes int64                    `json:"total_bytes"`
	Retention  *RecordingsRetentionInfo `json:"retention,omitempty"`
}

RecordingsListResponse is returned by GET /api/v1/recordings.

type RecordingsPlayRequest added in v0.2.9

type RecordingsPlayRequest struct {
	FileName string `json:"file_name"`
}

RecordingsPlayRequest is the JSON body for POST /api/v1/recordings/play.

type RecordingsPlayResponse added in v0.2.9

type RecordingsPlayResponse struct {
	FileName string             `json:"file_name"`
	Events   []recordings.Event `json:"events"`
}

RecordingsPlayResponse is returned by POST /api/v1/recordings/play.

type RecordingsRetentionInfo added in v0.3.0

type RecordingsRetentionInfo struct {
	Enabled bool   `json:"enabled"`
	MaxAge  string `json:"max_age,omitempty"`
}

RecordingsRetentionInfo describes auto-TTL policy for the record dir.

type RecordingsSummarizeRequest added in v0.3.0

type RecordingsSummarizeRequest struct {
	FileName string `json:"file_name"`
	Model    string `json:"model"`
}

RecordingsSummarizeRequest is the JSON body for POST /api/v1/recordings/summarize.

type RecordingsSummarizeResponse added in v0.3.0

type RecordingsSummarizeResponse struct {
	Reply string `json:"reply"`
}

RecordingsSummarizeResponse is returned by POST /api/v1/recordings/summarize.

type ResolvedStepSummary added in v0.2.8

type ResolvedStepSummary struct {
	Index   int      `json:"index"`
	ID      string   `json:"id,omitempty"`
	Depends []string `json:"depends,omitempty"`
	Wave    int      `json:"wave,omitempty"`
	Kind    string   `json:"kind"`
	Host    string   `json:"host"`
	RunAs   string   `json:"run_as,omitempty"`
	When    string   `json:"when,omitempty"`
	Retry   string   `json:"retry,omitempty"`
	Notify  bool     `json:"notify,omitempty"`
	Preview string   `json:"preview"`
}

ResolvedStepSummary is the per-step shape returned to the WebUI's Plan view. It mirrors cuetry.StepSummary; keep it small and JSON-stable — the wizard renders it directly.

type RunAgentInput added in v0.3.6

type RunAgentInput struct {
	ThreadID string            `json:"threadId"`
	RunID    string            `json:"runId"`
	Model    string            `json:"model,omitempty"`
	Messages []agtypes.Message `json:"messages"`
	Tools    []agtypes.Tool    `json:"tools,omitempty"`
}

RunAgentInput represents the JSON body of the AG-UI SSE request.

type ScheduleListItem added in v0.3.6

type ScheduleListItem struct {
	AppName      string            `json:"app_name"`
	ScheduleName string            `json:"schedule_name"`
	Cron         string            `json:"cron"`
	TimeZone     string            `json:"timezone,omitempty"`
	Env          map[string]string `json:"env,omitempty"`
	RecipePath   string            `json:"recipe_path"`
}

ScheduleListItem is the JSON shape returned by GET /api/v1/schedules.

type SealSecretRequest added in v0.3.6

type SealSecretRequest struct {
	Plaintext string `json:"plaintext"`
}

SealSecretRequest is the request payload for sealing a secret.

type SealSecretResponse added in v0.3.6

type SealSecretResponse struct {
	Sealed string `json:"sealed"`
}

SealSecretResponse is the response payload containing the sealed secret.

type Server

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

Server is the honey web UI HTTP server.

func NewServer

func NewServer(opts Options) (*Server, error)

NewServer builds handlers with the given auth token.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start listens and serves until ctx is cancelled.

type StartTunnelRequest added in v0.2.9

type StartTunnelRequest struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Mapping string       `json:"mapping"`
}

StartTunnelRequest is the JSON body for POST /api/v1/tunnels.

type StatusResponse added in v0.2.9

type StatusResponse struct {
	Status string `json:"status"`
	Path   string `json:"path"`
}

StatusResponse is returned by config write endpoints.

type StoreLoadResponse added in v0.3.5

type StoreLoadResponse struct {
	Recipe map[string]interface{}  `json:"recipe"`
	RawCUE string                  `json:"raw_cue"`
	Plan   string                  `json:"plan,omitempty"`
	Steps  []ResolvedStepSummary   `json:"steps,omitempty"`
	Graph  *cuetry.RecipeGraphPlan `json:"graph,omitempty"`
	Errors []ValidateContentError  `json:"errors,omitempty"`
}

StoreLoadResponse is returned by GET /api/v1/recipes/store/{name}. It combines the parsed recipe with graph/plan data so the Studio needs only one call.

type SyncASTRequest added in v0.3.6

type SyncASTRequest struct {
	OriginalCUE   string                 `json:"original_cue"`
	RecipeContent map[string]interface{} `json:"recipe_content"`
}

SyncASTRequest is the JSON body for POST /api/v1/recipes/sync-ast.

type SyncASTResponse added in v0.3.6

type SyncASTResponse struct {
	CUE string `json:"cue"`
}

SyncASTResponse is the JSON response for POST /api/v1/recipes/sync-ast.

type TerminalAssistModelsResponse added in v0.2.9

type TerminalAssistModelsResponse struct {
	Models []string `json:"models"`
}

TerminalAssistModelsResponse is returned by GET /api/v1/terminal-assist/models.

type TerminalAssistRequest added in v0.2.9

type TerminalAssistRequest struct {
	UserPrompt string `json:"user_prompt"`
	Scrollback string `json:"scrollback"`
	MaxLines   int    `json:"max_lines"`
	Model      string `json:"model"`
}

TerminalAssistRequest is the JSON body for POST /api/v1/terminal-assist.

type TerminalAssistResponse added in v0.2.9

type TerminalAssistResponse struct {
	Reply             string `json:"reply"`
	ScrollbackClipped bool   `json:"scrollback_clipped"`
}

TerminalAssistResponse is returned by POST /api/v1/terminal-assist.

type TunnelDeleteResponse added in v0.2.9

type TunnelDeleteResponse struct {
	Success bool `json:"success"`
}

TunnelDeleteResponse is returned by DELETE /api/v1/tunnels/{id}.

type TunnelLogsResponse added in v0.2.9

type TunnelLogsResponse struct {
	Logs string `json:"logs"`
}

TunnelLogsResponse is returned by GET /api/v1/tunnels/{id}/logs.

type TunnelStartResponse added in v0.2.9

type TunnelStartResponse struct {
	Tunnel ActiveTunnel `json:"tunnel"`
}

TunnelStartResponse is returned by POST /api/v1/tunnels.

type TunnelsAPI added in v0.3.7

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

TunnelsAPI owns the in-process SSH -L port-forward endpoints (list, logs, start, stop), isolating them from the main Server so the tunnels feature carries its own deps (mirrors FilesAPI/PostgresAPI/EnrollAPI, architecture candidate arch-08). It drives a tunnelManager and resolves records through the executor registry; sshUser is injected (Server.sshUser is shared Server-wide).

func NewTunnelsAPI added in v0.3.7

func NewTunnelsAPI(opts Options, tunnels *tunnelManager, sshUser func(string) string) *TunnelsAPI

NewTunnelsAPI wires the tunnel manager and the shared ssh-user resolver.

type TunnelsListResponse added in v0.2.9

type TunnelsListResponse struct {
	Tunnels []ActiveTunnel `json:"tunnels"`
}

TunnelsListResponse is returned by GET /api/v1/tunnels.

type UploadRequestMeta added in v0.2.9

type UploadRequestMeta struct {
	SSHUser    string       `json:"ssh_user"`
	RemotePath string       `json:"remote_path"`
	Record     hosts.Record `json:"record"`
}

UploadRequestMeta is the JSON in multipart field "meta" for POST /api/v1/upload.

type UploadResponse added in v0.2.9

type UploadResponse struct {
	Results []engine.HostExecResult `json:"results"`
}

UploadResponse is the non-stream JSON body for POST /api/v1/upload.

type ValidateContentError added in v0.2.9

type ValidateContentError struct {
	Path    string `json:"path,omitempty"`
	Kind    string `json:"kind"`
	Message string `json:"message"`
}

ValidateContentError is one validation issue.

type ValidateContentRequest added in v0.2.9

type ValidateContentRequest struct {
	RecipeContent    map[string]interface{} `json:"recipe_content,omitempty"`
	RecipeContentRaw string                 `json:"recipe_content_raw,omitempty"`
}

ValidateContentRequest is the JSON body for POST /api/v1/recipes/validate-content.

type ValidateContentResponse added in v0.2.9

type ValidateContentResponse struct {
	Plan   string                  `json:"plan,omitempty"`
	Steps  []ResolvedStepSummary   `json:"steps,omitempty"`
	Graph  *cuetry.RecipeGraphPlan `json:"graph,omitempty"`
	Errors []ValidateContentError  `json:"errors,omitempty"`
	Risk   *cuetry.RiskReport      `json:"risk,omitempty"`
}

ValidateContentResponse is returned on success or validation failure.

type WSExecHello added in v0.3.6

type WSExecHello struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Command string       `json:"command"`
}

WSExecHello is the initial message expected on an exec WebSocket connection.

type WSHello added in v0.2.9

type WSHello struct {
	SessionID     string       `json:"session_id"`
	SSHUser       string       `json:"ssh_user"`
	Record        hosts.Record `json:"record"`
	Cols          int          `json:"cols"`
	Rows          int          `json:"rows"`
	RecordSession bool         `json:"record_session"`
	Console       string       `json:"console,omitempty"` // "truenas_api" for TrueNAS /websocket/shell
}

WSHello is exported so it can be unmarshaled by the honey pty-proxy subcommand.

type WSRemoteForwardHello added in v0.3.7

type WSRemoteForwardHello struct {
	SSHUser      string       `json:"ssh_user"`
	Record       hosts.Record `json:"record"`
	RemoteBind   string       `json:"remote_bind"`
	RemoteListen int          `json:"remote_listen"`
}

WSRemoteForwardHello is the initial message expected on a remote-forward WebSocket connection. It requests that the server open a reverse listener on the target (remote) side and pipe accepted connections back to the client.

type WSTunnelHello added in v0.3.6

type WSTunnelHello struct {
	SSHUser string       `json:"ssh_user"`
	Record  hosts.Record `json:"record"`
	Target  string       `json:"target"` // The target address to dial (e.g. "127.0.0.1:8080")
}

WSTunnelHello is the initial message expected on a tunnel WebSocket connection.

type WSUDPRelayHello added in v0.3.7

type WSUDPRelayHello struct {
	Target string `json:"target"`
}

WSUDPRelayHello is the initial message expected on a UDP relay WebSocket connection.

type WebhookDelivery added in v0.3.6

type WebhookDelivery struct {
	ID             string                  `json:"id"`
	Source         string                  `json:"source"` // live | test | dry_run
	ReceivedAt     time.Time               `json:"received_at"`
	RemoteAddr     string                  `json:"remote_addr,omitempty"`
	ContentType    string                  `json:"content_type,omitempty"`
	Body           string                  `json:"body"`
	AuthOK         bool                    `json:"auth_ok"`
	Extracted      map[string]string       `json:"extracted,omitempty"`
	Actor          string                  `json:"actor,omitempty"`
	IdempotencyKey string                  `json:"idempotency_key,omitempty"`
	Async          bool                    `json:"async"`
	Outcome        string                  `json:"outcome"` // executed | queued | dry_run | unauthorized | duplicate | error | completed | failed
	ExecID         string                  `json:"exec_id,omitempty"`
	Error          string                  `json:"error,omitempty"`
	Results        []engine.HostExecResult `json:"results,omitempty"`
}

WebhookDelivery is a captured webhook invocation — a live delivery, a debug test-send, or a dry-run preview. It is what the web UI's webhook-debugging panel displays.

type WebhookResultResponse added in v0.3.6

type WebhookResultResponse struct {
	ID        string                  `json:"id"`
	Status    string                  `json:"status"`
	StartedAt string                  `json:"started_at,omitempty"`
	Results   []engine.HostExecResult `json:"results,omitempty"`
}

WebhookResultResponse is returned by GET /api/v1/webhooks/results/{id}

Directories

Path Synopsis
cmd
swag2openapi command
Command swag2openapi converts swag-generated Swagger 2.0 JSON to OpenAPI 3.x JSON for honey web.
Command swag2openapi converts swag-generated Swagger 2.0 JSON to OpenAPI 3.x JSON for honey web.
Package recipestore provides extensible storage abstractions for managing recipe content.
Package recipestore provides extensible storage abstractions for managing recipe content.
Package workspacestore persists the studio workspace layout blob on disk.
Package workspacestore persists the studio workspace layout blob on disk.

Jump to

Keyboard shortcuts

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