Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
endpoints.cpp File Reference

This checkout's endpoints, with {instance} resolved (designs 0018 and 0019). More...

#include "endpoints.h"
#include "common.h"
#include "http.h"
#include "instance_p.h"
#include <sonde/instance.h>
#include <QtCore/QDeadlineTimer>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QStandardPaths>
#include <QtCore/QXmlStreamReader>
#include <QtNetwork/QHostAddress>
#include <QtNetwork/QLocalSocket>
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QTcpSocket>

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

bool Sonde::Cli::anonymous_namespace{endpoints.cpp}::truthy (const QJsonValue &value)
 Whether value is true in Python's sense (not null, false, 0 or empty).
QJsonValue Sonde::Cli::anonymous_namespace{endpoints.cpp}::programName (const QJsonObject &config)
 "executable" if it is set, otherwise the program of "run".
QString Sonde::Cli::anonymous_namespace{endpoints.cpp}::bundleExecutableFromXml (const QByteArray &data)
 The value of CFBundleExecutable in the XML property list data, or empty.
std::optional< QJsonObject > Sonde::Cli::anonymous_namespace{endpoints.cpp}::structured (const QJsonObject &reply)
 The structured result of a tools/call reply, or nothing.
QJsonObject Sonde::Cli::anonymous_namespace{endpoints.cpp}::initializeRequest ()
 The initialize request sonde sends to ask for app_info.
QJsonObject Sonde::Cli::anonymous_namespace{endpoints.cpp}::appInfoRequest ()
 The tools/call request for app_info.
QByteArray Sonde::Cli::anonymous_namespace{endpoints.cpp}::compact (const QJsonObject &object)
 object as compact JSON.
quint16 Sonde::Cli::anonymous_namespace{endpoints.cpp}::portOf (const QString &url)
 The port in url ("http://host:port/path"), or 0.
QString Sonde::Cli::realPath (const QString &path)
 path absolute, with links resolved, as Python's os.path.realpath() gives it: canonical if it exists, otherwise its longest existing parent made canonical, followed by the rest.
QString Sonde::Cli::resolveProgram (const QString &name, const QString &root)
 The program name refers to, from root or PATH, or an empty string.
QString Sonde::Cli::bundleBinary (const QString &path)
 The executable inside the macOS application bundle path (a directory ending in .app), or path.
std::optional< QString > Sonde::Cli::applicationPath (const QJsonObject &config, const QString &root)
 The application's canonical path, as the application sees it, or nothing if it can't be found: "executable", or else the program of "run".
bool Sonde::Cli::httpReady (quint16 port)
 Whether something accepts connections on port port of 127.0.0.1.
std::optional< QJsonObject > Sonde::Cli::appInfoOverHttp (quint16 port)
 app_info's structured result from the Sonde server on port port, or nothing.
std::optional< QJsonObject > Sonde::Cli::appInfoOverSocket (const QString &name)
 app_info's structured result from the Sonde server on local socket name, or nothing.
void Sonde::Cli::showEndpoint (const QJsonObject &config, const Project &project)
 sonde endpoint: prints this checkout's endpoints, and writes endpoint.json.

Variables

constexpr int Sonde::Cli::anonymous_namespace{endpoints.cpp}::kConnectTimeoutMs = 500
 How long to wait for a connection to a port, in milliseconds.
constexpr int Sonde::Cli::anonymous_namespace{endpoints.cpp}::kAppInfoTimeoutMs = 3000
 How long to wait for app_info, in milliseconds.

Detailed Description

This checkout's endpoints, with {instance} resolved (designs 0018 and 0019).

Function Documentation

◆ resolveProgram()

QString Sonde::Cli::resolveProgram ( const QString & name,
const QString & root )

The program name refers to, from root or PATH, or an empty string.

On Windows a path may leave out .exe; the result has it.