Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

portail

The framework a workspace web app is built on. An app serves ONE object — its workspace — behind a Flask page and is managed from the command line. portail holds everything that does not depend on what the workspace holds:

  • serving in the foreground or detached (--background), the port settled before anything starts, the browser opened once the server answers;
  • stop / restart / list by the server's IDENTITY (its live /api/meta answer), never by a port alone;
  • the page's shell: /api/meta, the ⏻ and ↻ buttons, and every open page told when its server goes;
  • jobs: background work with its progress and a cooperative stop (docs/jobs.md);
  • the MCP server base (docs/mcp.md) and the filter language a records list is searched with (docs/query.md).

What each lifecycle command does, in user terms: docs/serving.md. Why it works this way: docs/architecture.md.

Install

pip install portail          # serving, the CLI commands, the page's shell
pip install "portail[mcp]"   # + the MCP server base

Quickstart: an app on portail

1. Say who the app is — AppSpec

from portail import AppSpec, Hooks

SPEC = AppSpec(
    name="demoapp",               # every message, file and log name: `demoapp stop`, demoapp.log
    cli_module="demoapp.cli",     # what `python -m` runs for a --background child and the page's ↻
    default_port=8710,
    hooks=Hooks(),                # optional, see below
)

The per-user state (the server registry, the last served workspace) lives in ~/.demoapp unless state_folder names another folder; environment variables are named through SPEC.env("continue_folder") → DEMOAPP_CONTINUE_FOLDER.

2. Implement Served — the workspace as portail sees it

class DemoWorkspace:
    def __init__(self, path: str = "", template: str = "", port: int = 8710) -> None:
        self.host, self.port, self.path, self.template, self.title = "127.0.0.1", port, path, template, "workspace"

    def state_dir(self) -> Path: ...             # its folder (a never-saved one: a temp folder); cheap, never raises

    def info(self) -> dict:                      # what /api/meta answers under "workspace"
        return {"path": self.path, "template": self.template, "state_dir": str(self.state_dir()), "dirty": False}

path is the workspace's file (absolute, "" when never saved), template the type it was opened from ("" for none). info()["dirty"] with a path makes ⏻ and ↻ ask before losing unsaved changes.

3. Add the lifecycle commands to the app's own CLI

from liquifai import LiquifyApp
from portail.cli import add_lifecycle_commands

app = LiquifyApp(name="demoapp", description="The demo workspace app.", strict_flags=True)
lifecycle = add_lifecycle_commands(
    app,
    SPEC,
    open_file=open_file,              # (absolute path) -> Served; raise a LiquifaiError for a file it refuses
    open_empty=DemoWorkspace,         # () -> Served
    open_type=open_type,              # (type name) -> Served; leave out for an app without types
    type_names=lambda: ["classification", "detection"],
    create_app=create_app,            # (Server) -> Flask; leave out to serve the bare shell
)

if __name__ == "__main__":
    app.run()

This registers demoapp [workspace.yaml] (the default command), demoapp workspace <type>, demoapp stop [target] [--all], demoapp restart [target] and demoapp list, with --auto-port, --port, --background/-b and --browser always|new|never on the serving commands. strict_flags=True is the app's choice — and the recommended one: a misspelled option is then refused instead of silently dropped.

An app that serves a folder says so — AppSpec(..., workspace="folder") — and its open_file is handed the folder's absolute path. Nothing is read from the folder before it is served, so its port is the default one or --port.

A serving option of the app's own (--notes-dir, say): the workspace carries it as options = {"notes_dir": "/n"} and answers it under options in info(). The app registers open and restart itself, asks portail for the other commands, and hands the option on:

lifecycle = add_lifecycle_commands(app, SPEC, open_file=open_folder, open_empty=open_here, commands=("stop", "list"))

@app.command(name="open", default=True, positionals=["folder"], short={"b": "background"})
def open_(folder: str = "", notes_dir: str = "", port: int = 0, background: bool = False) -> None:
    lifecycle.open(folder, port=port, background=background, options={"notes_dir": notes_dir} if notes_dir else {})

open_file then receives it as a keyword argument (open_folder(path, notes_dir="/n")), a --background child is started with --notes-dir /n, and a restart that names no option serves with the ones the running server has.

4. Mount the shell on the app's Flask app

from flask import Flask
from portail.serving import Server
from portail.web import mount_shell

def create_app(server: Server) -> Flask:
    app = Flask("demoapp", static_folder=None)

    @app.get("/")
    def index():
        return PAGE   # the app's own page

    return mount_shell(app, server)   # AFTER the app's own "/" — the shell's minimal page only fills a gap

The page loads the shell with relative addresses and names where ⏻ and ↻ go:

<link rel="stylesheet" href="portail/shell.css">
<header id="top">…</header>
<script src="portail/shell.js"></script>
<script>Portail.start({ buttons: "#top" });</script>

Portail.beforeLeaving = async (what) => true lets the page ask its own question before ⏻ / ↻ (return false to stay); Portail.toast is how a refusal is said. create_shell(server) is a Flask app holding only the shell.

Hooks

hook runs for
prepare(served) in the TERMINAL, before the server registers or a --background child starts checks the person must read, a page to build
starting(served) in the serving process, before the page answers startup jobs, a cleanup
leaving(served) on every way out, after the open pages were told keep unsaved work
holds_work(folder) when a never-saved workspace's folder is looked at whether a restart should continue it
kept_until() in messages how long such work is kept, in words
continued(folder, template) on a restart that continues a never-saved workspace open it from its folder

A hook that fails is logged and serving goes on. Without continued a restart never continues a never-saved workspace: it opens what it names.

For a Python caller

portail.serving.running_servers(spec) lists every server of the app that answers right now, lowest port first — each entry carries host, port, label, identity, path, template, state_dir and pid. portail.serving.post_json / get_json talk to one of them, with every failure one ServeError line.

Jobs, the MCP server base, the filter language, the protocols

  • Jobs: portail.jobs.Jobs().start(key, title, work) runs work(job) in a thread of its own; the work steps the job (job.step()), reads the stop between items (job.stop_asked, or job.check_stop()), and Jobs.list() is what the app's page polls. See docs/jobs.md.
  • MCP server base (pip install portail[mcp]): portail.mcp.make_server(spec, instructions) and ServerChoice(spec, start_hint=...) give an app tools that relay to its running page. The user picks the server — a port argument, a question to the user, or a kept "always" answer — and every failure answers in-band. See docs/mcp.md.
  • Filter language: portail.query.parse(text, aliases=..., flags=...) reads class = 7, class has 3, 7, snr 5..20, class != @pred, a name search, and the app's own flag words (flag_pairs("edited")). See docs/query.md.
  • Protocols: portail.protocols holds the structural Canvas, Recording, Recordings and Opener a domain package implements without importing the app.

License

PolyForm Noncommercial License 1.0.0 (the LICENSE file): free for personal, academic and other noncommercial use. Commercial use needs a separate licence from the author.

Metadata

Release files for portail 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for portail 0.1.0a1
File Size Uploaded Provenance Actions
portail-0.1.0a1.tar.gz 144.2 kB With provenance Details for portail-0.1.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for portail 0.1.0a1
File Interpreter ABI Platform Actions
portail-0.1.0a1-py3-none-any.whl Python 3 none any Details for portail-0.1.0a1-py3-none-any.whl

Total release size: 218.4 kB

Release files / portail-0.1.0a1.tar.gz

Download URL portail-0.1.0a1.tar.gz
Size 144.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bf24ad3ed9c69932cf61218c7576e574bd94f56d25709292fce5d2aaa932d9f3
BLAKE2b-256 checksum
How to use checksums
e9d17e020530ddac85c1d9c1f0b20c407b8dea30e75507091c07911af4564a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / portail-0.1.0a1-py3-none-any.whl

Download URL portail-0.1.0a1-py3-none-any.whl
Size 74.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cb0fb02b99525d0af228be9cfa0656dab75f0370e26cbd687298fa4392311df
BLAKE2b-256 checksum
How to use checksums
d0b7b4c665c06975a1447f03a85a2f05232baf845864f201c1aae7fbad74f692
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for portail 0.1.0a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for portail-0.1.0a1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page