api

package
v0.0.0-...-11e1b04 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableTelemetryMiddleware

func DisableTelemetryMiddleware()

DisableTelemetryMiddleware turns api_call event emission off.

func EnableTelemetryMiddleware

func EnableTelemetryMiddleware()

EnableTelemetryMiddleware turns on api_call event emission.

func TelemetryHTTPMiddleware

func TelemetryHTTPMiddleware(publish func(events.Event) (events.Envelope, bool)) func(http.Handler) http.Handler

TelemetryHTTPMiddleware emits a BrowserApiCallEvent per documented operation, capturing the final status and wall-clock duration. publish is wired to TelemetrySession.Publish; the middleware ignores the returns.

func TelemetryMiddlewareEnabled

func TelemetryMiddlewareEnabled() bool

TelemetryMiddlewareEnabled reports the current state.

func TelemetryStrictMiddleware

func TelemetryStrictMiddleware() oapi.StrictMiddlewareFunc

TelemetryStrictMiddleware records the matched OpenAPI operationId onto the per-request scratch so TelemetryHTTPMiddleware can include it in the event.

Types

type ApiService

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

func New

func New(
	recordManager recorder.RecordManager,
	factory recorder.FFmpegRecorderFactory,
	upstreamMgr *devtoolsproxy.UpstreamManager,
	stz scaletozero.PinnedController,
	nekoAuthClient *nekoclient.AuthClient,
	telemetrySession *telemetry.TelemetrySession,
	eventStream *events.EventStream,
	displayNum int,
) (*ApiService, error)

func (*ApiService) ChromiumConfigure

ChromiumConfigure batched Chromium/session configuration plus optional navigation.

func (*ApiService) ClickMouse

func (*ApiService) CreateDirectory

CreateDirectory creates a new directory (recursively) with an optional mode.

func (*ApiService) DeleteDirectory

DeleteDirectory removes a directory and its contents.

func (*ApiService) DeleteFile

DeleteFile removes a single file.

func (*ApiService) DownloadDirZip

func (*ApiService) DragMouse

func (*ApiService) FileInfo

FileInfo returns metadata about a file or directory.

func (*ApiService) GetTelemetry

GetTelemetry handles GET /telemetry. Returns the current telemetry configuration. Returns 404 if telemetry is not configured.

func (*ApiService) HandleProcessAttachWS

func (s *ApiService) HandleProcessAttachWS(w http.ResponseWriter, r *http.Request, id string)

HandleProcessAttachWS handles PTY attach via WebSocket for bidirectional streaming. Protocol:

  • Client sends BinaryMessage for stdin data
  • Server sends BinaryMessage for stdout data
  • Client sends TextMessage with JSON for control (e.g., resize)
  • Server sends TextMessage with JSON for events (e.g., exit code)

This endpoint is intentionally not defined in OpenAPI.

func (*ApiService) ListFiles

ListFiles returns FileInfo entries for the contents of a directory.

func (*ApiService) ListRecorders

ListRecorders returns a list of all registered recorders and whether each one is currently recording.

func (*ApiService) LogsStream

LogsStream implements Server-Sent Events log streaming. (GET /logs/stream)

func (*ApiService) MoveMouse

func (*ApiService) MovePath

MovePath renames or moves a file/directory.

func (*ApiService) PatchChromiumFlags

PatchChromiumFlags handles updating Chromium launch flags at runtime. It merges the provided flags with existing flags in /chromium/flags, writes the updated flags file, restarts Chromium via supervisord, and waits until DevTools is ready.

func (*ApiService) PatchChromiumPolicies

PatchChromiumPolicies applies user-provided Chromium enterprise policy overrides to policy.json, restarts Chromium, and waits for DevTools to be ready.

func (*ApiService) PatchDisplay

PatchDisplay updates the display configuration. When require_idle is true (default), it refuses to resize while live view or recording/replay is active. This method automatically detects whether the system is running with Xorg (headful) or Xvfb (headless) and uses the appropriate method to change resolution.

func (*ApiService) PatchTelemetry

PatchTelemetry handles PATCH /telemetry. Partially updates the telemetry configuration. Returns 404 if not configured. Setting all five categories to enabled:false clears the configuration (200).

func (*ApiService) PressKey

func (*ApiService) ProcessExec

Execute a command synchronously (POST /process/exec)

func (*ApiService) ProcessKill

Send signal to process (POST /process/{process_id}/kill)

func (*ApiService) ProcessResize

Resize PTY-backed process (POST /process/{process_id}/resize)

func (*ApiService) ProcessSpawn

Execute a command asynchronously (POST /process/spawn)

func (*ApiService) ProcessStatus

Get process status (GET /process/{process_id}/status)

func (*ApiService) ProcessStdin

Write to process stdin (POST /process/{process_id}/stdin)

func (*ApiService) ProcessStdoutStream

Stream process stdout/stderr (SSE) (GET /process/{process_id}/stdout/stream)

func (*ApiService) PublishTelemetryEvent

PublishTelemetryEvent handles POST /telemetry/events. Routes a caller-supplied event through the active telemetry session so it picks up category filtering and the telemetry_session_id metadata stamp. Returns 200 with the assigned envelope when the event is admitted, 204 when filtered (no active session or the category is disabled), or 400 on validation failure.

func (*ApiService) PutTelemetry

PutTelemetry handles PUT /telemetry. Sets the telemetry configuration. Returns 201 if not previously configured, 200 if it was. Setting all five categories to enabled:false clears the configuration (200).

func (*ApiService) ReadClipboard

func (*ApiService) ReadFile

ReadFile returns the contents of a file specified by the path param.

func (*ApiService) Scroll

func (*ApiService) SetCursor

func (*ApiService) SetFilePermissions

SetFilePermissions changes mode (and optionally owner/group) of a path.

func (*ApiService) Shutdown

func (s *ApiService) Shutdown(ctx context.Context) error

func (*ApiService) StartFsWatch

StartFsWatch is not implemented in this basic filesystem handler. It returns a 400 error to the client.

func (*ApiService) StreamTelemetryEvents

StreamTelemetryEvents handles GET /telemetry/stream. Opens an SSE stream of telemetry event envelopes from the telemetry stream ring buffer. Supports reconnection via the Last-Event-ID header. Emits a keepalive comment frame every 15 s when no event arrives.

func (*ApiService) TakeScreenshot

func (*ApiService) TypeText

func (*ApiService) UploadExtensionsAndRestart

UploadExtensionsAndRestart handles multipart upload of one or more extension zips, extracts them under /home/kernel/extensions/<name>, writes /chromium/flags to enable them, restarts Chromium via supervisord, and waits (via UpstreamManager) until DevTools is ready.

func (*ApiService) UploadFiles

UploadFiles handles multipart form uploads for one or more files. It supports the following field name encodings:

  • files[<index>].file and files[<index>].dest_path
  • files[<index>][file] and files[<index>][dest_path]
  • files.<index>.file and files.<index>.dest_path

Additionally, for single-file uploads it accepts:

  • file and dest_path

func (*ApiService) UploadZip

UploadZip handles a multipart upload of a zip archive and extracts it to dest_path.

func (*ApiService) UploadZstd

func (*ApiService) WriteClipboard

func (*ApiService) WriteFile

WriteFile creates or overwrites a file with the supplied data stream.

type XdoTool

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

XdoTool is a thin wrapper around the xdotool CLI utility. It ensures the DISPLAY environment variable is set correctly when invoking xdotool.

Usage:

output, err := defaultXdoTool.Run(ctx, "mousemove", "100", "100")

If you need a different display, construct your own instance using NewXdoTool(display).

func NewXdoTool

func NewXdoTool(display string) *XdoTool

NewXdoTool returns a new XdoTool configured to target the given X11 display. The display string should be in the form ":<num>", e.g. ":0" or ":1".

func (*XdoTool) Run

func (x *XdoTool) Run(ctx context.Context, args ...string) ([]byte, error)

Run executes xdotool with the provided arguments. The DISPLAY environment variable is injected ahead of the existing environment so that it always takes precedence.

Jump to

Keyboard shortcuts

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