LibTmux.Query.Json 0.1.2

Prefix Reserved
dotnet add package LibTmux.Query.Json --version 0.1.2
                    
NuGet\Install-Package LibTmux.Query.Json -Version 0.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LibTmux.Query.Json" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibTmux.Query.Json" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="LibTmux.Query.Json" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LibTmux.Query.Json --version 0.1.2
                    
#r "nuget: LibTmux.Query.Json, 0.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LibTmux.Query.Json@0.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LibTmux.Query.Json&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=LibTmux.Query.Json&version=0.1.2
                    
Install as a Cake Tool

LibTmux.Query.Json

LibTmux.Query.Json libtmux.org

JSON for LibTmux query documents. The core library does not reference System.Text.Json, so a caller who does not want it does not get it.

A query in LibTmux is a document: an expression translated into a closed tree that can be checked, stored, logged, or sent somewhere else.

This package carries that document across a process boundary. It suits a CLI that takes a filter argument, a service that accepts one over HTTP, and a tool that records what it queried.

Add it to your project:

$ dotnet add package LibTmux.Query.Json

Contents — Quick start · Send a filter · Limits · Fields · Leaves out · Support

Quick start

Write a filter over the objects LibTmux returns, send it as text, and read it back. The block needs no tmux server:

using LibTmux;
using LibTmux.Query;
using LibTmux.Query.Json;

QueryDocument document = QueryExtensions.Translate<Session>(
    session => session.Name.StartsWith("build", StringComparison.Ordinal)
        && session.Attached);

string wire = QueryJson.Serialize(document);
QueryDocument parsed = QueryJson.Deserialize(wire);

// The document that came back means what the one that left meant.
Console.WriteLine(parsed == document);

It prints True.

Send a filter to another process

QueryJson.Serialize: the document as versioned text

wire in the quick start is this document. It names its schema and version, so a reader can reject one it does not know:

{
  "schema": "libtmux-query",
  "version": 2,
  "target": "session",
  "predicate": {
    "kind": "and",
    "operands": [
      {
        "kind": "comparison",
        "operator": "startsWithOrdinal",
        "left": {
          "kind": "field",
          "target": "session",
          "wireName": "session_name"
        },
        "right": {
          "kind": "constant",
          "value": { "kind": "string", "value": "build" }
        }
      },
      {
        "kind": "field",
        "target": "session",
        "wireName": "session_attached"
      }
    ]
  }
}

QueryJson.Deserialize: apply a filter you received

The same document filters what you already hold, wherever it was written:

using LibTmux;
using LibTmux.Query;
using LibTmux.Query.Json;

// However this arrived — an argument, a request body, a stored filter.
string received = QueryJson.Serialize(QueryExtensions.Translate<Session>(
    session => session.Name.StartsWith("build", StringComparison.Ordinal)));

using var queryBudget = CancellationTokenSource.CreateLinkedTokenSource(ct);
queryBudget.CancelAfter(TimeSpan.FromSeconds(1));
IReadOnlyList<Session> sessions = await server.GetSessionsAsync(ct);
IReadOnlyList<Session> matched = sessions.Matching(
    QueryJson.Deserialize(received),
    queryBudget.Token);

Console.WriteLine(matched.Count);

It prints the number of sessions whose name starts with build.

For a document from another trust boundary, use the cancellable QueryExtensions.Matching overload with a deadline, as the block does.

Limit what a received document costs

QueryJsonLimits.Default: ceilings on what a reader accepts

using LibTmux.Query.Json;

Console.WriteLine($"depth {QueryJsonLimits.Default.MaximumDepth}, nodes {QueryJsonLimits.Default.MaximumNodes}");

It prints the nesting depth and node count the defaults allow.

  • Deserializing applies limits on document size, nesting depth, node count, string length, and regex pattern length. A caller may tighten them and cannot widen them.
  • Schema version 2 is the supported contract, shipped as libtmux-query-v2.schema.json. Other versions are rejected before their predicates are read.
  • Compile and Matching resolve public properties by name, so they warn trimmed callers to preserve that metadata.

Choose fields and relations

QueryFieldCatalog: the closed set of fields

QueryFieldCatalog.GetFields(QueryTarget.Pane) lists the fields, their native properties, and the operators each accepts. Write predicates against properties such as Session.Name, Client.IsControlClient, and Pane.CurrentCommand:

using LibTmux;
using LibTmux.Query;
using LibTmux.Query.Json;

QueryDocument paths = QueryExtensions.Translate<Pane>(
    pane => pane.CurrentPath == "/srv/api");
QueryDocument restoredPaths = QueryJson.Deserialize(QueryJson.Serialize(paths));
Console.WriteLine(restoredPaths.Version);

It prints the document's schema version.

  • The wire name pane_command binds to tmux's pane_current_command.
  • Pane.CurrentPath and Pane.CurrentCommand read captured state without I/O. Reading one that was never captured throws IncompleteSnapshotException.
  • A field outside the catalog throws UnsupportedQueryExpressionException at translation.
  • The catalog grows between releases, and a reader rejects a name it does not know, so pin the same LibTmux version on both sides of a process boundary.

Pane size

Pane dimensions support numeric comparisons over the same captured objects:

QueryDocument widePanes = QueryExtensions.Translate<Pane>(
    pane => pane.Width >= 50 && pane.Height >= 20);
QueryDocument restoredDimensions = QueryJson.Deserialize(QueryJson.Serialize(widePanes));
Server capturedPanes = await server.CaptureSnapshotAsync(SnapshotDepth.Panes, ct);
Console.WriteLine(capturedPanes.Panes.Matching(restoredDimensions).Count);

It prints how many captured panes are at least 50 columns by 20 rows.

Any and All: filters over a relation

Collection predicates use Any and All. Negate Any to require no matches. All is true for an empty captured collection:

QueryDocument linkedEditors = QueryExtensions.Translate<Session>(
    session => session.Windows.Any(window =>
        window.IsActive && window.Name == "editor"
        && window.LinkedSessions.Any(linked => linked.Name == "work")));
Console.WriteLine(linkedEditors.RequiredSnapshotDepth);

It prints the snapshot depth the document needs.

  • The conditions inside one Any must match the same window placement. Separate Any calls may match different windows.
  • Window.IsActive and Window.Index describe the placement the handle was captured through. Two handles for the same linked window can disagree on both.

Single relations: ordinary property navigation

QueryDocument selectedEditor = QueryExtensions.Translate<Session>(
    session => session.ActiveWindow.Value.Name == "editor");
Console.WriteLine(QueryJson.Serialize(selectedEditor));

It prints the serialized document.

Relation Property Required capture
session_active_window Session.ActiveWindow.Value Windows
session_active_pane Session.ActivePane.Value Panes
session_panes Session.Panes Panes
window_session Window.Session Windows
window_active_pane Window.ActivePane.Value Panes
window_linked_sessions Window.LinkedSessions Windows
pane_window Pane.Window Panes
pane_session Pane.Session Panes

A single relation needs a captured child; an unavailable value raises an error without fetching data.

Package Adds
LibTmux The client. Required.
LibTmux.Workspace Sessions from tmuxp YAML
LibTmux.Mcp A Model Context Protocol server, as a .NET tool

What it leaves out

  • A query language. Filters are C# expressions over LibTmux objects, and the document is their serialized form.
  • Unbounded input. A reader enforces size, depth, node, string, and regex limits before it evaluates anything.
  • Guessing at fields. A document that names a field outside the catalog is rejected, and so is a schema version other than 2.

Support and status

  • Pre-1.0. Any release may change or remove an exported identifier. The changelog marks each break, so pin an exact version.
  • Dependencies. LibTmux and System.Text.Json.
  • tmux and .NET. The tmux versions LibTmux supports, on net8.0 and net10.0.
  • Systems. Linux, including WSL. macOS is best effort.

Documentation

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.2 176 11/29/2026
0.1.1 378 11/1/2026
0.1.0 298 10/25/2026
0.0.0-alpha.24 106 10/25/2026
0.0.0-alpha.23 126 10/24/2026
0.0.0-alpha.22 141 10/19/2026
0.0.0-alpha.21 79 10/11/2026
0.0.0-alpha.20 431 10/5/2026
0.0.0-alpha.19 83 10/4/2026
0.0.0-alpha.18 74 10/3/2026
0.0.0-alpha.17 83 9/27/2026
0.0.0-alpha.16 76 9/26/2026
0.0.0-alpha.15 79 9/20/2026
0.0.0-alpha.14 81 9/20/2026
0.0.0-alpha.12 82 9/12/2026
0.0.0-alpha.10 95 8/30/2026
0.0.0-alpha.9 102 8/22/2026
0.0.0-alpha.8 91 8/22/2026
0.0.0-alpha.7 98 8/16/2026
0.0.0-alpha.6 100 8/16/2026
Loading failed

All eight LibTmux packages share version 0.1.2. LibTmux guards raw layout commands on older tmux servers, and LibTmux.Mcp ships the MCP SDK 2.4.0. Pin exact package versions while the public API is evolving. Read the LibTmux.Query.Json changelog at https://github.com/libtmux/libtmux-dotnet/blob/master/src/LibTmux.Query.Json/CHANGELOG.md and the release summary at https://github.com/libtmux/libtmux-dotnet/blob/v0.1.2/CHANGELOG.md