Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
- name: Family layers, harness, chat tree, approvals, artifacts, shares, devices, commands, migrations
working-directory: backend
run: python -m pytest tests -q -p no:cacheprovider
- name: Third-party notices cover what ships
run: python setup/notices.py --check

window:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Two page quirks: the Miranda page lists its download under the name `Uranus - Ar

## Third-party packages

This table is the human list. The full licence texts (copyright lines, conditions and disclaimers) of everything that ships are in `THIRD-PARTY-NOTICES.txt`, written by `python3 setup/notices.py` and checked in CI by `python3 setup/notices.py --check`. It ships in every installer and inside the packaged engine, and the window shows it under Settings, About, Third-party notices. Licence texts that the packages themselves do not carry (the GNU and native-library texts, and the LICENSE files of CTranslate2, tokenizers and flatbuffers, whose wheels have none) are kept in `tools/licence_texts/`. Crates published without a licence file have their texts in `tools/licence_texts/crates/<name>-<version>/`, each with a `SOURCE.txt` naming the upstream file and commit it came from, or saying the text is reconstructed from the SPDX standard text when the repository has none; the generator uses them and names that source in the crate's note.

| Package | Licence | Where |
| --- | --- | --- |
| Inter (`@fontsource/inter`) | OFL-1.1 | frontend fonts |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ Code owners are set in [`.github/CODEOWNERS`](.github/CODEOWNERS).

## License

FormAT is licensed under the Apache License 2.0 ([`LICENSE`](LICENSE), SPDX `Apache-2.0`). Copyright 2026 NodeAgentc, Inc. Third-party notices: [`NOTICE.md`](NOTICE.md).
FormAT is licensed under the Apache License 2.0 ([`LICENSE`](LICENSE), SPDX `Apache-2.0`). Copyright 2026 NodeAgentc, Inc. Third-party notices: [`NOTICE.md`](NOTICE.md) (what each component is and why) and [`THIRD-PARTY-NOTICES.txt`](THIRD-PARTY-NOTICES.txt) (their full licence texts).

<sub>FormAT is an independent project and is not affiliated with or endorsed by Anthropic, OpenAI or Cursor.</sub>
33,262 changes: 33,262 additions & 0 deletions THIRD-PARTY-NOTICES.txt

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,19 @@ Tool process tests and the sandbox. tests/test_tool_processes.py turns the sandb

The shared finder, version 1.0.2 (app/engine/agent_lookup.py, hash in setup/agents.py `LOOKUP_HASHES`). On Windows `start_argv` no longer puts cmd.exe in front of an npm, pnpm or bun shim: `shim_target` reads the .cmd and runs the .exe it names, or node.exe (beside the shim, then on PATH) and the script it names. A shim of another kind still goes through cmd.exe, now with /d, and only when every word, the program's path included, passes `cmd_safe`: none of & | < > ^ ( ) ! % " and no control character (\x00-\x1f, \x7f), with or without spaces, because the shim reads its arguments again through %* and quoting does not hold there; otherwise the start is refused with an OSError that says to pass long text through stdin or a file. A name ending in .cmd or .bat followed by dots or spaces counts as a shim too. The Claude Code chat run passes its child environment to `start_argv`, so node is looked for on the same PATH the program gets (tests/test_windows_start.py; not run on Windows). The other Form engines still carry 1.0.1.

### app/engine/agent_lookup.py and setup/agents.py · the shared finder is the family's 1.1.0
- refers-to: app/engine/agent_lookup.py (whole file, version 1.1.0); setup/agents.py `LOOKUP_HASHES`; tests/test_windows_start.py; tests/test_agent_lookup.py
- kind: decision
- logged: unreleased

FormAT's own 1.0.2 above is replaced by the family's 1.1.0, copied unchanged from FormVis (SHA-256 313fcd40541199c920314516026a0b225aeb4915e9a5dc26bf51d1ba05f1da8e), so every Form engine starts agent programs on Windows the same way. `LOOKUP_HASHES` records only 1.1.0, so an older copy fails `agents sync --check`. What changed for FormAT: an npm, pnpm or bun shim is followed only when it sets nothing of its own but NODE_PATH and every script line names one runner (node or bun, found beside the shim, then on the PATH of the environment given); a shim that names an .exe runs it; any other .cmd or .bat goes through cmd.exe /c (no /d now) and is refused with `CommandLineRefused`, an OSError, when a word or the program's path holds & | < > ^ ( ) ! % " or a control character, or when a quoted program path would lose its quotes. The 1.0.2 tests in tests/test_windows_start.py gave way to FormVis's 1.1.0 set (import path changed) plus one test that node is looked for on the PATH of the environment `start_argv` gets, which is how the Claude Code chat run passes its child environment. FormAT carried no other copy of the hardening, so nothing else was removed. Not run on Windows.

### THIRD-PARTY-NOTICES.txt, setup/notices.py, notices_texts.py, notices_crates.py, app/routers/system.py :: notices · the full licence texts ship and are checked in CI
- refers-to: setup/notices.py; setup/notices_texts.py; setup/notices_crates.py (copied from FormCel); tools/licence_texts/; app/core/config.py :: notices_path; app/routers/system.py :: notices; setup/freeze_backend; setup/freeze_backend.bat; src-tauri/tauri.conf.json; tests/test_notices.py; tests/test_window_key.py :: PUBLIC_READS
- kind: feature
- logged: unreleased

`setup/notices.py` writes THIRD-PARTY-NOTICES.txt the way FormCel's does: the Python runtime, the PyInstaller bootloader and the native libraries frozen with the interpreter; every Python package the engine requirements reach on macOS, Linux and Windows (requirements.txt, requirements_macos.txt and the desktop's browser and voice lists, with extras and platform markers); the npm packages package-lock.json does not mark dev; every crate Cargo.lock reaches from the shell crate `format`; the LGPL FFmpeg libraries inside the desktop engine with the LGPL-2.1 text; the Linux AppImage's system libraries; what is downloaded on request (Chromium, the Whisper model); and the NASA maps of the Orrery demo. `--check` reads only the lock files, the requirement lists and the installed packages, so the CI test job runs it with the base install. The optional native renderer (native/format-render) is not in the desktop app, so its crates are left out and the file says so. Texts a package does not carry are in tools/licence_texts (not in setup/, where the CI scripts job runs `bash -n` on every file and a folder fails): the GNU and native-library texts (as FormMorpheus keeps them) and the repository LICENSE files of CTranslate2 4.9.1, tokenizers 0.23.3 and flatbuffers 25.12.19, whose wheels carry none. To regenerate on macOS, the Linux and Windows only packages (jeepney, secretstorage; colorama, pywin32, pywin32-ctypes, pywinpty) were installed with `pip install --target DIR --platform ...` and passed with `--also`, and two crates missing from the local registry (syn 3.0.8, tauri-plugin-opener 2.7.1) were unpacked from crates.io and passed with `--crate-src`. The engine serves the file at `GET /api/notices` (public read: it holds nothing private), from the PyInstaller folder when frozen; the freeze scripts add it to the engine and tauri.conf.json to every installer. Seen: generated file 1.6 MB, 605 sections (77 Python, 14 npm, 514 crates), `--check` clean; the test file and the window-key walk pass. Not run: a frozen engine or an installer build.
### Other devices over TLS with a token per device (unreleased)
- refers-to: app/engine/lan_cert.py :: ensure, fingerprint, write_private; app/engine/device_tokens.py :: issue, check, revoke, revoke_all, watch; app/engine/devices.py :: Gate, _pair, _held, _code, _spend, listener_config, status, devices_list, devices_revoke, devices_forget; app/engine/store.py :: paired_devices (schema 9); app/core/local_guard.py :: LocalGuard._permitted; requirements.txt, requirements_macos.txt :: cryptography
- kind: decision
Expand Down
10 changes: 10 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ def workspace_dir() -> Path:
DESKTOP = os.environ.get("FORMAT_DESKTOP") == "1"


NOTICES_NAME = "THIRD-PARTY-NOTICES.txt"


def notices_path() -> Path:
import sys
if getattr(sys, "frozen", False):
return Path(getattr(sys, "_MEIPASS", "")) / NOTICES_NAME
return REPO_DIR / NOTICES_NAME


def frontend_dist() -> Path:
return Path(os.environ.get("FORMAT_DIST") or REPO_DIR / "frontend" / "dist")

Expand Down
133 changes: 90 additions & 43 deletions backend/app/engine/agent_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from dataclasses import dataclass, field
from pathlib import Path

VERSION = "1.0.2"
VERSION = "1.1.0"
PROGRAMS: dict = {
"claude": {"title": "Claude Code", "names": ("claude",), "setting": "claudeBin",
"install": "curl -fsSL https://claude.ai/install.sh | bash", "install_windows": "irm https://claude.ai/install.ps1 | iex",
Expand Down Expand Up @@ -359,67 +359,114 @@ def _quote(word: str, fish: bool) -> str:
return "'" + word.replace("'", "'\"'\"'") + "'"


def _node(folder: Path, env: dict) -> str | None:
for place in [str(folder), *(env.get("PATH") or env.get("Path") or "").split(";")]:
if place.strip() and Path(place.strip(), "node.exe").is_file():
return str(Path(place.strip(), "node.exe"))
return None
class CommandLineRefused(OSError):
"""A word the Windows command interpreter would not pass through to the program as it is."""


BATCH_ENDINGS = (".cmd", ".bat")
RUNNERS = ("node", "bun")
_STREAM = re.compile(r"(?:::\$data)?[ .]*$", re.I)
_DP0 = r'"%(?:~dp0|dp0%)\\?([^"%\r\n]+?\.{ext})"'
_RUNNER = r'(?:"%_prog%"|(node|bun)(?:\.exe)?|"%(?:~dp0|dp0%)\\?(node|bun)\.exe")'
_SHIM_SCRIPT = re.compile(r'(?:^|&)[ \t]*@?' + _RUNNER + r'[ \t]+' + _DP0.format(ext="(?:js|cjs|mjs)") + r'[ \t]+%\*[ \t\r]*$', re.I | re.M)
_SHIM_EXE = re.compile(r'(?:^|&)[ \t]*@?' + _DP0.format(ext="exe") + r'[ \t]+%\*[ \t\r]*$', re.I | re.M)
_SHIM_SETS = re.compile(r'\bset[ \t]+"?([A-Za-z_]\w*)=', re.I)
_SHIM_PROG = re.compile(r'\bset[ \t]+"?_prog=([^"\r\n]*)', re.I)
_PROG_VALUE = re.compile(r'(?:%(?:~dp0|dp0%)\\?)?(node|bun)(?:\.exe)?', re.I)
_SHIM_OWN_VARS = frozenset({"dp0", "_prog", "pathext", "node_path"})
_CMD_REFUSED = re.compile(r'[&|<>^()!%"\x00-\x1f\x7f]')
_CMD_QUOTED = re.compile(r'[ \t]')
REFUSAL = ("Windows starts this program through the command interpreter (cmd.exe), which would change or act on the text, so it "
"was not started. Pass long or special text through standard input or a file if the program supports it, or point "
"the setting at the program's .exe or node script so it starts without the command interpreter.")


def plain_name(path: str | os.PathLike) -> str:
"""The file name as Windows opens it: lower case, without trailing dots or spaces or a ::$DATA stream name."""
return _STREAM.sub("", Path(str(path)).name).lower()


def batch_file(path: str | os.PathLike) -> bool:
"""Whether Windows would start this file through the command interpreter (.cmd or .bat in any letter case)."""
return plain_name(path).endswith(BATCH_ENDINGS)


def _beside(folder: Path, rel: str) -> Path:
return folder.joinpath(*[part for part in rel.replace("\\", "/").split("/") if part])

def shim_target(path: str | os.PathLike, env: dict | None = None) -> list[str] | None:
"""The program a Windows .cmd or .bat shim of the npm, pnpm or bun kind starts, as the words to run it with: the .exe
it names, or node and the script it names. None when the shim is of another kind or its target is missing."""

def _runner(text: str, named: list[str]) -> str | None:
"""The one runner (node or bun) every script line of a shim uses, or None when they disagree or one is unknown."""
progs = _SHIM_PROG.findall(text)
stems = {word.lower() for word in named if word}
if any(not word for word in named):
for value in progs:
match = _PROG_VALUE.fullmatch(value.strip())
if not match:
return None
stems.add(match.group(1).lower())
return stems.pop() if len(stems) == 1 else None


def shim_target(shim: str, env: dict | None = None) -> list[str] | None:
"""The program an npm, pnpm or bun .cmd shim runs (its script with node or bun, or its .exe), so it can be started
without the command interpreter; None when the file is not such a shim (it sets anything of its own other than
NODE_PATH, or hands %* to anything else) or its target is missing. pnpm's NODE_PATH is not carried over: node finds a
package's own dependencies from the script's folder."""
env = os.environ if env is None else env
shim = Path(path)
folder = Path(shim).parent
try:
text = shim.read_text(encoding="utf-8", errors="replace")
text = Path(shim).read_text(encoding="utf-8", errors="replace")[:65536]
except OSError:
return None
hit = re.search(r'"%~?dp0%?[\\/]*([^"%\r\n]+)"\s*%\*', text)
if not hit:
return None
target = shim.parent.joinpath(*[p for p in re.split(r"[\\/]+", hit.group(1)) if p])
if not target.is_file():
if any(name.lower() not in _SHIM_OWN_VARS for name in _SHIM_SETS.findall(text)):
return None
if target.suffix.lower() == ".exe":
return [str(target)]
if target.suffix.lower() in (".js", ".cjs", ".mjs"):
node = _node(shim.parent, env)
return [node, str(target)] if node else None
lines = _SHIM_SCRIPT.findall(text)
scripts = [_beside(folder, rel) for _bare, _dp0, rel in lines]
exes = [_beside(folder, rel) for rel in _SHIM_EXE.findall(text)]
if scripts and not exes and len(set(scripts)) == 1 and scripts[0].is_file():
runner = _runner(text, [bare or dp0 for bare, dp0, _rel in lines])
if runner is None:
return None
beside = folder / f"{runner}.exe"
found = str(beside) if beside.is_file() else shutil.which(runner, path=env.get("PATH", ""))
return [found, str(scripts[0])] if found else None
if exes and not scripts and len(set(exes)) == 1 and plain_name(exes[0]) not in ("node.exe", "bun.exe") and exes[0].is_file():
return [str(exes[0])]
return None


CMD_SPECIAL = re.compile(r'[\x00-\x1f\x7f&|<>^()!%"]')
CMD_REFUSED = ("an argument holds a character the Windows command interpreter would read (& | < > ^ ( ) ! % \" or a control "
"character); pass long text through stdin or a file if the program supports it")


def cmd_safe(word: str) -> bool:
"""Whether word can go through the command interpreter: none of & | < > ^ ( ) ! % " and no control character,
quoted or not, because a .cmd shim reads its arguments again through %*."""
return not CMD_SPECIAL.search(word)


def _shim_ending(word: str) -> bool:
return word.rstrip(" .").lower().endswith((".cmd", ".bat"))
def cmd_safe(words: list[str]) -> None:
"""Raises CommandLineRefused unless cmd.exe /c would pass every word, the program's path included, unchanged. No word
may hold & | < > ^ ( ) ! % " or a control character: quotes do not protect a word there, so no word is let through
because it is quoted or has no spaces. A program path that needs quotes (a space or tab) keeps them only when it is
the line's one quoted word and holds no @, so such a path may not be followed by a word that needs quotes."""
words = [str(word) for word in words]
for index, word in enumerate(words):
if _CMD_REFUSED.search(word):
what = "The path of this program" if index == 0 else "A word for this program"
raise CommandLineRefused(f"{what} has one of & | < > ^ ( ) ! % \" or a control character. {REFUSAL}")
program, rest = words[0], words[1:]
if _CMD_QUOTED.search(program) and ("@" in program or any(word == "" or _CMD_QUOTED.search(word) for word in rest)):
raise CommandLineRefused("The path of this program has a space, and the command interpreter would drop its quotes when an "
f"@ is in it or another word has a space or is empty. {REFUSAL}")


def start_argv(cmd: list, env: dict | None = None, platform: str | None = None) -> list[str]:
"""How a program is started, the same for a tab, Chat and a check: through the person's login shell on macOS and Linux
(exec, so the process is the program), directly on Windows. A .cmd or .bat shim is replaced by the program it starts;
only a shim of another kind goes through the command interpreter, and then every word, the program's path included,
must pass cmd_safe or the start is refused."""
(exec, so the process is the program), directly on Windows. An npm, pnpm or bun .cmd shim is started as the node or bun
script or the program it names, with the words as an argv list; any other .cmd or .bat (any letter case, trailing dots
or spaces) goes through the command interpreter, only with words it passes through unchanged."""
words = [str(c) for c in cmd]
env = os.environ if env is None else env
if windows(platform):
if not _shim_ending(words[0]):
if not batch_file(words[0]):
return words
direct = shim_target(words[0].rstrip(" ."), env)
if direct:
direct = shim_target(words[0], env)
if direct and not batch_file(direct[0]):
return [*direct, *words[1:]]
if not all(cmd_safe(w) for w in words):
raise OSError(22, CMD_REFUSED)
return [env.get("COMSPEC") or "cmd.exe", "/d", "/c", *words]
cmd_safe(words)
return [env.get("COMSPEC") or "cmd.exe", "/c", *words]
shell = login_shell(env, platform)
fish = Path(shell).name == "fish"
return [shell, "-l", "-c", "exec " + " ".join(_quote(w, fish) for w in words)]
Expand Down
17 changes: 16 additions & 1 deletion backend/app/routers/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import threading

from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse
from fastapi.responses import HTMLResponse, PlainTextResponse

from app.core import config, window_key

Expand All @@ -15,6 +15,21 @@ def health() -> dict:
return {"ok": True, "name": config.APP_NAME, "version": config.VERSION}


NOTICES_CAP = 16 * 1024 * 1024


@router.get("/notices", response_class=PlainTextResponse)
def notices() -> str:
try:
with open(config.notices_path(), "r", encoding="utf-8") as handle:
text = handle.read(NOTICES_CAP + 1)
except OSError:
raise HTTPException(404, "The third-party notices are not in this build") from None
if len(text) > NOTICES_CAP:
raise HTTPException(500, "The third-party notices file is larger than expected")
return text


@router.post("/window/key")
def claim_window_key(request: Request) -> dict:
if window_key.stdout_mode() or window_key.paired(request.scope):
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_agent_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _agents():
def test_the_shared_finder_matches_the_hash_recorded_for_its_version(app):
module = _agents()
version = re.search(r'^VERSION = "([^"]+)"$', (REPO / LOOKUP).read_text(encoding="utf-8"), re.M).group(1)
assert module.LOOKUP_HASHES[version] == hashlib.sha256((REPO / LOOKUP).read_bytes()).hexdigest()
assert module.LOOKUP_HASHES == {version: hashlib.sha256((REPO / LOOKUP).read_bytes()).hexdigest()} and version == "1.1.0"
assert module.lookup_problems() == []


Expand Down
Loading
Loading