Something went wrong. Try again.
The agentic engineering control plane for the posthuman future
Something went wrong. Try again.
2.3 kB · 55 lines
C
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#pragma once
#include <QObject>#include <QQmlApplicationEngine>#include <QTcpServer>#include <QtGlobal>#include <qtmetamacros.h>
class QTcpSocket;
// Localhost eval server for driving and inspecting the live QML scene.// Built into every binary but inert unless XENO_DEV_SERVER is set in the// environment, so shipped builds expose nothing. Binds 127.0.0.1 only.//// Protocol: newline-delimited JSON, one response line per request.// Requests:// {"id":1,"expr":"shell.activeTabIndex()"} evaluate a QML/JS expression// {"id":2,"file":"/abs/path.js"} Qt.include() a JS file// {"id":3,"ping":true} liveness probe// {"id":4,"screenshot":true} grab the whole window, save to// /tmp/xenomorphic-<ms>.png,// value = saved path// Responses:// {"id":1,"ok":true,"value":<json>} value is best-effort JSON// {"id":1,"ok":false,"error":"..."} QML error or bad request//// Expressions evaluate against the engine root context with context// properties installed here: "ui" (the root Window), "shell" (the// TerminalPage, found by objectName "xeno-shell"), "dev" (DevHelpers),// plus the singletons "model" (AppModel) and "pool" (PanePool).class DevDriver : public QObject { Q_OBJECT Q_DISABLE_COPY_MOVE(DevDriver)
public: // Installs "ui" (root Window), "shell" (the page, objectName // "xeno-shell"), "dev" (DevHelpers), and the "model"/"pool" singletons // as root-context properties, then // listens on 127.0.0.1:$XENO_DEV_PORT (default 45773). Logs the bound // endpoint to stderr; on failure logs and disables itself rather than // crashing the app this diagnostic tool rides in. explicit DevDriver(QQmlApplicationEngine* engine, QObject* parent = nullptr); ~DevDriver() override;
private: void acceptConnections(); void readRequest(QTcpSocket* socket); void dispatch(QTcpSocket* socket, const QByteArray& line);
QQmlApplicationEngine* m_engine; // borrowed; the application owns it QTcpServer m_server; // Per-socket partial request lines awaiting their terminating newline. QHash<QTcpSocket*, QByteArray> m_readBuffers;};