mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-31 16:21:50 +03:00
fix(release): package TUI compliance materials
This commit is contained in:
@@ -243,6 +243,21 @@ jobs:
|
|||||||
working-directory: tui
|
working-directory: tui
|
||||||
run: bun run build
|
run: bun run build
|
||||||
|
|
||||||
|
- name: Verify licensed Linux release archive
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
working-directory: tui
|
||||||
|
run: |
|
||||||
|
bun scripts/release-notices.ts linux-x64
|
||||||
|
python3 scripts/package-release.py linux-x64
|
||||||
|
|
||||||
|
- name: Verify licensed Windows release archive
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
working-directory: tui
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
bun scripts/release-notices.ts win32-x64
|
||||||
|
python scripts/package-release.py win32-x64
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|||||||
@@ -1,14 +1,24 @@
|
|||||||
name: Publish Terminal UI
|
name: Publish Terminal UI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
workflow_dispatch:
|
||||||
types: [published]
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: Existing release tag (for example, v0.3.1)
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
compliance_reviewed:
|
||||||
|
description: Confirm notices, source offer, source archive, and relinking were reviewed
|
||||||
|
required: true
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
if: ${{ inputs.compliance_reviewed }}
|
||||||
name: ${{ matrix.target }}
|
name: ${{ matrix.target }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
@@ -24,6 +34,19 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.tag }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Verify release tag
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]
|
||||||
|
gh release view "$TAG" >/dev/null
|
||||||
|
test "$(git rev-parse HEAD)" = "$(git rev-list -n 1 "refs/tags/$TAG")"
|
||||||
|
|
||||||
- name: Set up Bun
|
- name: Set up Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
@@ -49,19 +72,25 @@ jobs:
|
|||||||
input_path: tui/dist/nanobot-tui-${{ matrix.target }}
|
input_path: tui/dist/nanobot-tui-${{ matrix.target }}
|
||||||
rcodesign_version: 0.29.0
|
rcodesign_version: 0.29.0
|
||||||
|
|
||||||
- name: Refresh signed checksum
|
- name: Build notices and release archive
|
||||||
working-directory: tui/dist
|
working-directory: tui
|
||||||
shell: bash
|
|
||||||
env:
|
env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
asset="nanobot-tui-${TARGET}"
|
bun scripts/release-notices.ts "$TARGET"
|
||||||
if [[ "$TARGET" == win32-* ]]; then asset="${asset}.exe"; fi
|
python3 scripts/package-release.py "$TARGET"
|
||||||
sha256sum "$asset" > "${asset}.sha256"
|
|
||||||
|
|
||||||
- name: Upload release assets
|
- name: Upload release assets
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
TAG: ${{ github.event.release.tag_name }}
|
TAG: ${{ inputs.tag }}
|
||||||
|
TARGET: ${{ matrix.target }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: gh release upload "$TAG" tui/dist/nanobot-tui-* --clobber
|
run: |
|
||||||
|
gh release view "$TAG" >/dev/null
|
||||||
|
asset="nanobot-tui-${TARGET}"
|
||||||
|
if [[ "$TARGET" == win32-* ]]; then asset="${asset}.exe"; fi
|
||||||
|
gh release upload "$TAG" \
|
||||||
|
"tui/dist/${asset}.zip" \
|
||||||
|
"tui/dist/${asset}.zip.sha256" \
|
||||||
|
--clobber
|
||||||
|
|||||||
+14
-4
@@ -142,12 +142,22 @@ A stable install must never combine Python from one version with a TUI from anot
|
|||||||
this order:
|
this order:
|
||||||
|
|
||||||
1. Set the package version and publish the matching GitHub release tag (`vX.Y.Z`).
|
1. Set the package version and publish the matching GitHub release tag (`vX.Y.Z`).
|
||||||
2. Wait for `tui-release.yml` to upload every supported native TUI and checksum to that release.
|
2. Review the pinned Bun/OpenTUI licenses, source offer, and relinking materials for that tag.
|
||||||
3. Only then publish the same `X.Y.Z` package to PyPI.
|
3. Manually run **Publish Terminal UI** for the exact tag and confirm the compliance review input.
|
||||||
|
4. Wait for every platform archive and checksum to appear on the release, then publish the same
|
||||||
|
`X.Y.Z` package to PyPI.
|
||||||
|
|
||||||
The wheel contains the built WebUI. The native TUI stays a platform-specific release sidecar so
|
The wheel contains the built WebUI. The native TUI stays a platform-specific release sidecar so
|
||||||
users download only the binary for their machine. Source checkouts use an editable Python install,
|
users download only the archive for their machine. Each archive must contain the executable,
|
||||||
run `tui/` with Bun, and rebuild stale `webui/` assets locally.
|
target-specific third-party notices, project and runtime licenses, corresponding application
|
||||||
|
source, a written source offer, relinking instructions, and a checksum manifest. Never upload a
|
||||||
|
naked TUI executable. Source checkouts use an editable Python install, run `tui/` with Bun, and
|
||||||
|
rebuild stale `webui/` assets locally.
|
||||||
|
|
||||||
|
The confirmation is an operational commitment, not a cosmetic checkbox. Before accepting it,
|
||||||
|
verify that the exact Bun/WebKit revisions remain retrievable and that the project can honor the
|
||||||
|
archive's corresponding-source offer for its full stated period. Preserve published archives and
|
||||||
|
their source materials.
|
||||||
|
|
||||||
## Questions?
|
## Questions?
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Pick **one** install method:
|
|||||||
| Stable | installer, `uv`, or pip | the same package tool | one released Python/WebUI/TUI version |
|
| Stable | installer, `uv`, or pip | the same package tool | one released Python/WebUI/TUI version |
|
||||||
| Current source | editable Git checkout | `git pull --ff-only` + editable dependency sync | Python, WebUI, and TUI from that checkout |
|
| Current source | editable Git checkout | `git pull --ff-only` + editable dependency sync | Python, WebUI, and TUI from that checkout |
|
||||||
|
|
||||||
Prerequisites: Python 3.11 or newer. Git and [Bun](https://bun.sh/) are only needed for a source install. Published packages include the WebUI and fetch a checksummed, version-matched TUI on first use.
|
Prerequisites: Python 3.11 or newer. Git and [Bun](https://bun.sh/) are only needed for a source install. Published packages include the WebUI and fetch a checksummed, version-matched TUI archive—with its licenses, notices, corresponding application source, source offer, and relinking instructions—on first use.
|
||||||
|
|
||||||
If terminals, API keys, or config files are new to you, use the guided zero-background walkthrough in [Start Without Technical Background](./docs/start-without-technical-background.md) instead of this compact README path.
|
If terminals, API keys, or config files are new to you, use the guided zero-background walkthrough in [Start Without Technical Background](./docs/start-without-technical-background.md) instead of this compact README path.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
# Third-Party Notices
|
# Third-Party Notices
|
||||||
|
|
||||||
The following third-party components are redistributed as part of the packaged
|
The following third-party components are redistributed as part of the packaged
|
||||||
nanobot Python distribution (`pip install nanobot-ai`).
|
nanobot Python distribution (`pip install nanobot-ai`). Native TUI executables are distributed
|
||||||
|
separately in per-platform release archives. Each TUI archive carries its generated
|
||||||
|
`THIRD_PARTY_NOTICES.txt`, project and runtime licenses, corresponding application source,
|
||||||
|
written source offer, and relinking instructions; those target-specific notices are generated by
|
||||||
|
`tui/scripts/release-notices.ts` and are not duplicated below.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ The default `--theme auto` mode probes the terminal's real foreground and backgr
|
|||||||
|
|
||||||
`Enter` sends the current message. While a turn is active, `Enter` steers it immediately, `Tab` queues a visible follow-up for the next turn, and `Option+Up` on macOS (`Alt+Up` on Windows/Linux) returns the latest queued message to the composer. Press `Shift+Enter` to add a newline; `Ctrl+J` is the universal fallback when a terminal cannot distinguish modified Enter keys. `Alt+Enter` and `Ctrl+Enter` are also accepted when distinguishable. Use `Up`/`Down` at the composer edge to recall prompts from the current saved session. Large pastes appear as a compact placeholder in the composer but are sent unchanged. Type `/` to discover nanobot commands and terminal navigation in one palette, or type `@` to complete installed apps, configured MCP servers, and saved sessions. Use the arrow keys to choose an item and `Tab` to complete it. `/sessions` opens a searchable conversation picker, `/new-chat` preserves the current conversation and starts another one, and `/branch` forks from a completed reply. `/diff` opens a read-only unified diff for the newest turn; use `Left`/`Right` to switch edits and `Esc` to close it. The core `/new` command retains its cross-channel behavior and resets the current chat. `Ctrl+C` copies a selection, stops a running turn, clears a non-empty composer, or exits when idle. Use `PageUp`/`PageDown` to scroll, `Ctrl+Home`/`Ctrl+End` to jump to the transcript edges, and `Ctrl+O` to expand or collapse long tool traces. When you leave the bottom, the TUI shows a scrollbar and a `Ctrl+End` hint until you return. The footer reports provider token/cache usage when available. Selections copy through OSC 52 when the terminal supports it. The transcript reflows when the terminal is resized, and exiting restores the previous screen.
|
`Enter` sends the current message. While a turn is active, `Enter` steers it immediately, `Tab` queues a visible follow-up for the next turn, and `Option+Up` on macOS (`Alt+Up` on Windows/Linux) returns the latest queued message to the composer. Press `Shift+Enter` to add a newline; `Ctrl+J` is the universal fallback when a terminal cannot distinguish modified Enter keys. `Alt+Enter` and `Ctrl+Enter` are also accepted when distinguishable. Use `Up`/`Down` at the composer edge to recall prompts from the current saved session. Large pastes appear as a compact placeholder in the composer but are sent unchanged. Type `/` to discover nanobot commands and terminal navigation in one palette, or type `@` to complete installed apps, configured MCP servers, and saved sessions. Use the arrow keys to choose an item and `Tab` to complete it. `/sessions` opens a searchable conversation picker, `/new-chat` preserves the current conversation and starts another one, and `/branch` forks from a completed reply. `/diff` opens a read-only unified diff for the newest turn; use `Left`/`Right` to switch edits and `Esc` to close it. The core `/new` command retains its cross-channel behavior and resets the current chat. `Ctrl+C` copies a selection, stops a running turn, clears a non-empty composer, or exits when idle. Use `PageUp`/`PageDown` to scroll, `Ctrl+Home`/`Ctrl+End` to jump to the transcript edges, and `Ctrl+O` to expand or collapse long tool traces. When you leave the bottom, the TUI shows a scrollbar and a `Ctrl+End` hint until you return. The footer reports provider token/cache usage when available. Selections copy through OSC 52 when the terminal supports it. The transcript reflows when the terminal is resized, and exiting restores the previous screen.
|
||||||
|
|
||||||
Packaged releases fetch a version-matched, checksummed terminal binary for macOS (Apple Silicon and Intel), Linux (x64 and ARM64), or Windows x64 on first use and cache it under the nanobot data directory. Windows ARM64 currently falls back to the classic prompt because the Bun runtime disables the FFI required by OpenTUI on that platform. Set `NANOBOT_TUI_NO_DOWNLOAD=1` or pass `--classic` to keep the Python-only path. An editable source checkout requires Bun and always runs its own `tui/` source; it never silently falls back to a release binary.
|
Packaged releases fetch a version-matched, checksummed terminal archive for macOS (Apple Silicon and Intel), Linux (x64 and ARM64), or Windows x64 on first use. The cache keeps the executable together with its licenses, third-party notices, source offer, relinking instructions, and corresponding TUI source. Windows ARM64 currently falls back to the classic prompt because the Bun runtime disables the FFI required by OpenTUI on that platform. Set `NANOBOT_TUI_NO_DOWNLOAD=1` or pass `--classic` to keep the Python-only path. A local source install requires Bun and runs its own `tui/` source while the original checkout remains available; it never silently falls back to a release binary.
|
||||||
|
|
||||||
Non-interactive input/output, `--logs`, and `--no-markdown` automatically retain the classic prompt so existing scripts and diagnostic workflows do not acquire terminal control sequences or silently ignore their options.
|
Non-interactive input/output, `--logs`, and `--no-markdown` automatically retain the classic prompt so existing scripts and diagnostic workflows do not acquire terminal control sequences or silently ignore their options.
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ outside the workspace when the gateway allows it.
|
|||||||
|
|
||||||
## Production notes
|
## Production notes
|
||||||
|
|
||||||
- Use `nanobot webui --background` when you do not want to keep a terminal open.
|
- Use `nanobot gateway --background` when you do not want to keep a terminal open, then open the
|
||||||
|
configured WebUI URL in a browser.
|
||||||
- Use `nanobot gateway status`, `logs`, `restart`, and `stop` to manage a
|
- Use `nanobot gateway status`, `logs`, `restart`, and `stop` to manage a
|
||||||
background gateway.
|
background gateway.
|
||||||
- If you expose the WebUI beyond localhost, set a token issue secret and review
|
- If you expose the WebUI beyond localhost, set a token issue secret and review
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ nanobot gateway
|
|||||||
For WebUI background usage:
|
For WebUI background usage:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nanobot webui --background
|
nanobot gateway --background
|
||||||
nanobot gateway status
|
nanobot gateway status
|
||||||
nanobot gateway logs
|
nanobot gateway logs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Open the configured WebUI URL in a browser, or run `nanobot webui` as a foreground client.
|
||||||
|
|
||||||
## Production notes
|
## Production notes
|
||||||
|
|
||||||
- Docker Compose is the most repeatable Linux container path.
|
- Docker Compose is the most repeatable Linux container path.
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ These repository docs follow current `main`. The recommended installer uses the
|
|||||||
- Access to one supported AI provider, company endpoint, or local model server.
|
- Access to one supported AI provider, company endpoint, or local model server.
|
||||||
- The credential, endpoint URL, and model ID required by that service. Local providers such as Ollama may not require a key.
|
- The credential, endpoint URL, and model ID required by that service. Local providers such as Ollama may not require a key.
|
||||||
|
|
||||||
Git and [Bun](https://bun.sh/) are only needed for a source install. The published package already contains the WebUI and fetches a checksummed, version-matched TUI on first use.
|
Git and [Bun](https://bun.sh/) are only needed for a source install. The published package already contains the WebUI and fetches a checksummed, version-matched TUI archive with its licenses, notices, corresponding application source, source offer, and relinking instructions on first use.
|
||||||
|
|
||||||
## 1. Install nanobot
|
## 1. Install nanobot
|
||||||
|
|
||||||
|
|||||||
+156
-45
@@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@@ -12,6 +13,7 @@ import time
|
|||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import zipfile
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
@@ -39,6 +41,29 @@ class TuiSessionError(ValueError):
|
|||||||
"""Raised when a session selector cannot be opened by the native TUI."""
|
"""Raised when a session selector cannot be opened by the native TUI."""
|
||||||
|
|
||||||
|
|
||||||
|
_TUI_RELEASE_FILES = (
|
||||||
|
"THIRD_PARTY_NOTICES.txt",
|
||||||
|
"RELINKING.md",
|
||||||
|
"SOURCE_OFFER.md",
|
||||||
|
"LICENSE",
|
||||||
|
"BUN-1.3.13-LICENSE.md",
|
||||||
|
"LGPL-2.0.txt",
|
||||||
|
"LGPL-2.1.txt",
|
||||||
|
"nanobot-tui-source.tar.gz",
|
||||||
|
)
|
||||||
|
_TUI_RELEASE_LIMITS = {
|
||||||
|
"THIRD_PARTY_NOTICES.txt": 4 * 1024 * 1024,
|
||||||
|
"RELINKING.md": 256 * 1024,
|
||||||
|
"SOURCE_OFFER.md": 256 * 1024,
|
||||||
|
"LICENSE": 256 * 1024,
|
||||||
|
"BUN-1.3.13-LICENSE.md": 1024 * 1024,
|
||||||
|
"LGPL-2.0.txt": 256 * 1024,
|
||||||
|
"LGPL-2.1.txt": 256 * 1024,
|
||||||
|
"nanobot-tui-source.tar.gz": 20 * 1024 * 1024,
|
||||||
|
"MANIFEST.sha256": 64 * 1024,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class _GatewayHandle:
|
class _GatewayHandle:
|
||||||
base_url: str
|
base_url: str
|
||||||
@@ -139,14 +164,20 @@ def _resolve_tui_command() -> list[str]:
|
|||||||
return [str(downloaded)]
|
return [str(downloaded)]
|
||||||
|
|
||||||
raise TuiUnavailableError(
|
raise TuiUnavailableError(
|
||||||
"this build does not include the native TUI; install Bun for a source checkout "
|
f"no native TUI archive is published for nanobot {__version__} on this platform; "
|
||||||
"or use `nanobot agent --classic`"
|
"current source installs must be editable and keep their checkout and Bun available, "
|
||||||
|
"while released packages need a matching GitHub release archive; use "
|
||||||
|
"`nanobot agent --classic` if intentional"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _source_checkout_tui_dir() -> Path | None:
|
def _source_checkout_tui_dir() -> Path | None:
|
||||||
"""Return this checkout's TUI source, never a neighboring unrelated directory."""
|
"""Return this checkout's TUI source, never a neighboring unrelated directory."""
|
||||||
project_root = Path(__file__).resolve().parents[2]
|
return _tui_source_dir(Path(__file__).resolve().parents[2])
|
||||||
|
|
||||||
|
|
||||||
|
def _tui_source_dir(project_root: Path) -> Path | None:
|
||||||
|
project_root = project_root.resolve(strict=False)
|
||||||
source_dir = project_root / "tui"
|
source_dir = project_root / "tui"
|
||||||
if (project_root / "pyproject.toml").is_file() and (source_dir / "package.json").is_file():
|
if (project_root / "pyproject.toml").is_file() and (source_dir / "package.json").is_file():
|
||||||
return source_dir
|
return source_dir
|
||||||
@@ -173,7 +204,7 @@ def _resolve_source_tui_command(source_dir: Path, bun: str) -> list[str]:
|
|||||||
|
|
||||||
|
|
||||||
def _download_release_tui(asset: str) -> Path | None:
|
def _download_release_tui(asset: str) -> Path | None:
|
||||||
"""Install the version-matched release sidecar into nanobot's data directory."""
|
"""Install the complete, version-matched TUI release bundle."""
|
||||||
if os.environ.get("NANOBOT_TUI_NO_DOWNLOAD") == "1":
|
if os.environ.get("NANOBOT_TUI_NO_DOWNLOAD") == "1":
|
||||||
return None
|
return None
|
||||||
version = __version__.strip()
|
version = __version__.strip()
|
||||||
@@ -181,61 +212,141 @@ def _download_release_tui(asset: str) -> Path | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
target_dir = get_data_dir() / "bin" / "tui" / version
|
target_dir = get_data_dir() / "bin" / "tui" / version
|
||||||
target = target_dir / asset
|
cached = _cached_release_tui(target_dir, asset)
|
||||||
cached_checksum = target.with_name(f"{target.name}.sha256")
|
if cached is not None:
|
||||||
if target.is_file():
|
return cached
|
||||||
try:
|
|
||||||
expected = cached_checksum.read_text(encoding="utf-8").split()[0].lower()
|
|
||||||
actual = hashlib.sha256(target.read_bytes()).hexdigest()
|
|
||||||
except (OSError, IndexError):
|
|
||||||
expected = ""
|
|
||||||
actual = ""
|
|
||||||
if len(expected) == 64 and actual == expected:
|
|
||||||
if os.name != "nt":
|
|
||||||
try:
|
|
||||||
target.chmod(0o755)
|
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
return target
|
|
||||||
try:
|
|
||||||
target.unlink(missing_ok=True)
|
|
||||||
cached_checksum.unlink(missing_ok=True)
|
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
base = f"https://github.com/HKUDS/nanobot/releases/download/v{version}"
|
base = f"https://github.com/HKUDS/nanobot/releases/download/v{version}"
|
||||||
|
archive_name = f"{asset}.zip"
|
||||||
try:
|
try:
|
||||||
checksum = _read_release_asset(f"{base}/{asset}.sha256", max_bytes=1024).decode()
|
checksum = _read_release_asset(f"{base}/{archive_name}.sha256", max_bytes=1024)
|
||||||
expected = checksum.split()[0].lower()
|
expected = _release_checksum(checksum, archive_name)
|
||||||
if len(expected) != 64:
|
if expected is None:
|
||||||
return None
|
return None
|
||||||
binary = _read_release_asset(f"{base}/{asset}", max_bytes=150 * 1024 * 1024)
|
archive = _read_release_asset(f"{base}/{archive_name}", max_bytes=200 * 1024 * 1024)
|
||||||
except (OSError, TimeoutError, urllib.error.URLError, urllib.error.HTTPError):
|
except (OSError, TimeoutError, urllib.error.URLError, urllib.error.HTTPError):
|
||||||
return None
|
return None
|
||||||
if hashlib.sha256(binary).hexdigest() != expected:
|
if hashlib.sha256(archive).hexdigest() != expected:
|
||||||
raise TuiUnavailableError("downloaded TUI binary failed checksum verification")
|
raise TuiUnavailableError("downloaded TUI archive failed checksum verification")
|
||||||
|
files = _verified_release_archive(archive, asset)
|
||||||
|
|
||||||
temporary = target.with_suffix(f"{target.suffix}.tmp-{os.getpid()}")
|
temporary: dict[str, Path] = {}
|
||||||
temporary_checksum = cached_checksum.with_suffix(
|
|
||||||
f"{cached_checksum.suffix}.tmp-{os.getpid()}"
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
target_dir.mkdir(parents=True, exist_ok=True)
|
target_dir.mkdir(parents=True, exist_ok=True)
|
||||||
temporary.write_bytes(binary)
|
for name, content in files.items():
|
||||||
temporary_checksum.write_text(f"{expected} {asset}\n", encoding="utf-8")
|
path = target_dir / name
|
||||||
if os.name != "nt":
|
pending = path.with_name(f"{path.name}.tmp-{os.getpid()}")
|
||||||
temporary.chmod(0o755)
|
pending.write_bytes(content)
|
||||||
temporary.replace(target)
|
if name == asset and os.name != "nt":
|
||||||
temporary_checksum.replace(cached_checksum)
|
pending.chmod(0o755)
|
||||||
|
temporary[name] = pending
|
||||||
|
for name in _release_bundle_names(asset):
|
||||||
|
temporary[name].replace(target_dir / name)
|
||||||
except OSError:
|
except OSError:
|
||||||
temporary.unlink(missing_ok=True)
|
for path in temporary.values():
|
||||||
temporary_checksum.unlink(missing_ok=True)
|
path.unlink(missing_ok=True)
|
||||||
target.unlink(missing_ok=True)
|
_clear_cached_release(target_dir, asset)
|
||||||
cached_checksum.unlink(missing_ok=True)
|
return None
|
||||||
|
return target_dir / asset
|
||||||
|
|
||||||
|
|
||||||
|
def _release_bundle_names(asset: str) -> tuple[str, ...]:
|
||||||
|
return (asset, *_TUI_RELEASE_FILES, "MANIFEST.sha256")
|
||||||
|
|
||||||
|
|
||||||
|
def _release_checksum(raw: bytes, archive_name: str) -> str | None:
|
||||||
|
try:
|
||||||
|
parts = raw.decode("utf-8").split()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return None
|
||||||
|
if len(parts) != 2 or parts[1] != archive_name:
|
||||||
|
return None
|
||||||
|
digest = parts[0].lower()
|
||||||
|
if len(digest) != 64 or any(character not in "0123456789abcdef" for character in digest):
|
||||||
|
return None
|
||||||
|
return digest
|
||||||
|
|
||||||
|
|
||||||
|
def _release_manifest(raw: bytes, asset: str) -> dict[str, str]:
|
||||||
|
expected_names = set(_release_bundle_names(asset)[:-1])
|
||||||
|
try:
|
||||||
|
lines = raw.decode("utf-8").splitlines()
|
||||||
|
except UnicodeDecodeError as exc:
|
||||||
|
raise TuiUnavailableError("TUI release manifest is not valid UTF-8") from exc
|
||||||
|
checksums: dict[str, str] = {}
|
||||||
|
for line in lines:
|
||||||
|
digest, separator, name = line.partition(" ")
|
||||||
|
digest = digest.lower()
|
||||||
|
if (
|
||||||
|
separator != " "
|
||||||
|
or name not in expected_names
|
||||||
|
or name in checksums
|
||||||
|
or len(digest) != 64
|
||||||
|
or any(character not in "0123456789abcdef" for character in digest)
|
||||||
|
):
|
||||||
|
raise TuiUnavailableError("TUI release manifest is malformed")
|
||||||
|
checksums[name] = digest
|
||||||
|
if set(checksums) != expected_names:
|
||||||
|
raise TuiUnavailableError("TUI release manifest is incomplete")
|
||||||
|
return checksums
|
||||||
|
|
||||||
|
|
||||||
|
def _verified_release_archive(raw: bytes, asset: str) -> dict[str, bytes]:
|
||||||
|
expected_names = set(_release_bundle_names(asset))
|
||||||
|
files: dict[str, bytes] = {}
|
||||||
|
try:
|
||||||
|
with zipfile.ZipFile(io.BytesIO(raw)) as archive:
|
||||||
|
entries = archive.infolist()
|
||||||
|
names = [entry.filename for entry in entries if not entry.is_dir()]
|
||||||
|
if len(names) != len(entries) or len(names) != len(set(names)):
|
||||||
|
raise TuiUnavailableError("TUI release archive contains invalid entries")
|
||||||
|
if set(names) != expected_names:
|
||||||
|
raise TuiUnavailableError("TUI release archive is incomplete")
|
||||||
|
for entry in entries:
|
||||||
|
limit = 150 * 1024 * 1024 if entry.filename == asset else _TUI_RELEASE_LIMITS[
|
||||||
|
entry.filename
|
||||||
|
]
|
||||||
|
if entry.file_size == 0 or entry.file_size > limit:
|
||||||
|
raise TuiUnavailableError(
|
||||||
|
f"TUI release file has an invalid size: {entry.filename}"
|
||||||
|
)
|
||||||
|
files[entry.filename] = archive.read(entry)
|
||||||
|
except zipfile.BadZipFile as exc:
|
||||||
|
raise TuiUnavailableError("downloaded TUI archive is not a valid ZIP file") from exc
|
||||||
|
|
||||||
|
checksums = _release_manifest(files["MANIFEST.sha256"], asset)
|
||||||
|
for name, expected in checksums.items():
|
||||||
|
if hashlib.sha256(files[name]).hexdigest() != expected:
|
||||||
|
raise TuiUnavailableError(f"TUI release file failed verification: {name}")
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
def _cached_release_tui(target_dir: Path, asset: str) -> Path | None:
|
||||||
|
target = target_dir / asset
|
||||||
|
manifest = target_dir / "MANIFEST.sha256"
|
||||||
|
if not target.is_file() and not manifest.exists():
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
checksums = _release_manifest(manifest.read_bytes(), asset)
|
||||||
|
for name, expected in checksums.items():
|
||||||
|
if hashlib.sha256((target_dir / name).read_bytes()).hexdigest() != expected:
|
||||||
|
raise OSError("cached release checksum mismatch")
|
||||||
|
if os.name != "nt":
|
||||||
|
target.chmod(0o755)
|
||||||
|
except (OSError, TuiUnavailableError):
|
||||||
|
_clear_cached_release(target_dir, asset)
|
||||||
return None
|
return None
|
||||||
return target
|
return target
|
||||||
|
|
||||||
|
|
||||||
|
def _clear_cached_release(target_dir: Path, asset: str) -> None:
|
||||||
|
for name in _release_bundle_names(asset):
|
||||||
|
try:
|
||||||
|
(target_dir / name).unlink(missing_ok=True)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _read_release_asset(url: str, *, max_bytes: int) -> bytes:
|
def _read_release_asset(url: str, *, max_bytes: int) -> bytes:
|
||||||
request = urllib.request.Request(url, headers={"User-Agent": f"nanobot/{__version__}"})
|
request = urllib.request.Request(url, headers={"User-Agent": f"nanobot/{__version__}"})
|
||||||
with urllib.request.urlopen(request, timeout=5) as response:
|
with urllib.request.urlopen(request, timeout=5) as response:
|
||||||
|
|||||||
+118
-17
@@ -1,5 +1,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
|
import io
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
@@ -24,6 +26,32 @@ from nanobot.cli.tui_launcher import (
|
|||||||
from nanobot.config.schema import Config, ModelPresetConfig
|
from nanobot.config.schema import Config, ModelPresetConfig
|
||||||
|
|
||||||
|
|
||||||
|
def _release_archive(
|
||||||
|
asset: str,
|
||||||
|
*,
|
||||||
|
binary: bytes = b"native-tui",
|
||||||
|
omit: str | None = None,
|
||||||
|
) -> tuple[bytes, bytes]:
|
||||||
|
files = {
|
||||||
|
asset: binary,
|
||||||
|
**{name: f"contents of {name}\n".encode() for name in tui_launcher._TUI_RELEASE_FILES},
|
||||||
|
}
|
||||||
|
if omit:
|
||||||
|
files.pop(omit)
|
||||||
|
manifest = "".join(
|
||||||
|
f"{hashlib.sha256(content).hexdigest()} {name}\n" for name, content in files.items()
|
||||||
|
).encode()
|
||||||
|
files["MANIFEST.sha256"] = manifest
|
||||||
|
output = io.BytesIO()
|
||||||
|
with zipfile.ZipFile(output, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
||||||
|
for name, content in files.items():
|
||||||
|
archive.writestr(name, content)
|
||||||
|
payload = output.getvalue()
|
||||||
|
archive_name = f"{asset}.zip"
|
||||||
|
checksum = f"{hashlib.sha256(payload).hexdigest()} {archive_name}\n".encode()
|
||||||
|
return payload, checksum
|
||||||
|
|
||||||
|
|
||||||
def test_authenticated_ws_url_preserves_existing_query(monkeypatch: pytest.MonkeyPatch) -> None:
|
def test_authenticated_ws_url_preserves_existing_query(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.os.getpid", lambda: 42)
|
monkeypatch.setattr("nanobot.cli.tui_launcher.os.getpid", lambda: 42)
|
||||||
url = _authenticated_ws_url(
|
url = _authenticated_ws_url(
|
||||||
@@ -374,26 +402,28 @@ def test_release_tui_is_verified_and_cached(
|
|||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
asset = "nanobot-tui-linux-x64"
|
||||||
binary = b"native-tui"
|
binary = b"native-tui"
|
||||||
digest = hashlib.sha256(binary).hexdigest().encode()
|
archive, checksum = _release_archive(asset, binary=binary)
|
||||||
downloads: list[str] = []
|
downloads: list[str] = []
|
||||||
|
|
||||||
def read_asset(url: str, *, max_bytes: int) -> bytes:
|
def read_asset(url: str, *, max_bytes: int) -> bytes:
|
||||||
downloads.append(url)
|
downloads.append(url)
|
||||||
return digest if url.endswith(".sha256") else binary
|
return checksum if url.endswith(".sha256") else archive
|
||||||
|
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher._read_release_asset", read_asset)
|
monkeypatch.setattr("nanobot.cli.tui_launcher._read_release_asset", read_asset)
|
||||||
|
|
||||||
target = _download_release_tui("nanobot-tui-linux-x64")
|
target = _download_release_tui(asset)
|
||||||
|
|
||||||
assert target == tmp_path / "bin" / "tui" / "9.9.9" / "nanobot-tui-linux-x64"
|
assert target == tmp_path / "bin" / "tui" / "9.9.9" / asset
|
||||||
assert target.read_bytes() == binary
|
assert target.read_bytes() == binary
|
||||||
assert target.with_name(f"{target.name}.sha256").read_text().startswith(digest.decode())
|
for name in (*tui_launcher._TUI_RELEASE_FILES, "MANIFEST.sha256"):
|
||||||
|
assert (target.parent / name).is_file()
|
||||||
assert len(downloads) == 2
|
assert len(downloads) == 2
|
||||||
|
|
||||||
assert _download_release_tui("nanobot-tui-linux-x64") == target
|
assert _download_release_tui(asset) == target
|
||||||
assert len(downloads) == 2
|
assert len(downloads) == 2
|
||||||
|
|
||||||
|
|
||||||
@@ -402,42 +432,113 @@ def test_release_tui_replaces_a_corrupted_cached_binary(
|
|||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
binary = b"native-tui"
|
binary = b"native-tui"
|
||||||
digest = hashlib.sha256(binary).hexdigest().encode()
|
|
||||||
asset = "nanobot-tui-linux-x64"
|
asset = "nanobot-tui-linux-x64"
|
||||||
target = tmp_path / "bin" / "tui" / "9.9.9" / asset
|
archive, checksum = _release_archive(asset, binary=binary)
|
||||||
target.parent.mkdir(parents=True)
|
|
||||||
target.write_bytes(b"corrupted")
|
|
||||||
target.with_name(f"{target.name}.sha256").write_text(
|
|
||||||
f"{hashlib.sha256(binary).hexdigest()} {asset}\n"
|
|
||||||
)
|
|
||||||
downloads: list[str] = []
|
downloads: list[str] = []
|
||||||
|
|
||||||
def read_asset(url: str, *, max_bytes: int) -> bytes:
|
def read_asset(url: str, *, max_bytes: int) -> bytes:
|
||||||
downloads.append(url)
|
downloads.append(url)
|
||||||
return digest if url.endswith(".sha256") else binary
|
return checksum if url.endswith(".sha256") else archive
|
||||||
|
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher._read_release_asset", read_asset)
|
monkeypatch.setattr("nanobot.cli.tui_launcher._read_release_asset", read_asset)
|
||||||
|
|
||||||
|
target = _download_release_tui(asset)
|
||||||
|
assert target is not None
|
||||||
|
target.write_bytes(b"corrupted")
|
||||||
|
|
||||||
assert _download_release_tui(asset) == target
|
assert _download_release_tui(asset) == target
|
||||||
assert target.read_bytes() == binary
|
assert target.read_bytes() == binary
|
||||||
assert len(downloads) == 2
|
assert len(downloads) == 4
|
||||||
|
|
||||||
|
|
||||||
|
def test_release_tui_replaces_corrupted_cached_notices(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
tmp_path: Path,
|
||||||
|
) -> None:
|
||||||
|
asset = "nanobot-tui-linux-x64"
|
||||||
|
archive, checksum = _release_archive(asset)
|
||||||
|
downloads: list[str] = []
|
||||||
|
|
||||||
|
def read_asset(url: str, *, max_bytes: int) -> bytes:
|
||||||
|
downloads.append(url)
|
||||||
|
return checksum if url.endswith(".sha256") else archive
|
||||||
|
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher._read_release_asset", read_asset)
|
||||||
|
|
||||||
|
target = _download_release_tui(asset)
|
||||||
|
assert target is not None
|
||||||
|
notices = target.parent / "THIRD_PARTY_NOTICES.txt"
|
||||||
|
notices.write_text("corrupted", encoding="utf-8")
|
||||||
|
|
||||||
|
assert _download_release_tui(asset) == target
|
||||||
|
assert notices.read_bytes() == b"contents of THIRD_PARTY_NOTICES.txt\n"
|
||||||
|
assert len(downloads) == 4
|
||||||
|
|
||||||
|
|
||||||
def test_release_tui_rejects_bad_checksum(
|
def test_release_tui_rejects_bad_checksum(
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
asset = "nanobot-tui-linux-x64"
|
||||||
|
archive, _checksum = _release_archive(asset)
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
"nanobot.cli.tui_launcher._read_release_asset",
|
"nanobot.cli.tui_launcher._read_release_asset",
|
||||||
lambda url, *, max_bytes: b"0" * 64 if url.endswith(".sha256") else b"tampered",
|
lambda url, *, max_bytes: (
|
||||||
|
f"{'0' * 64} {asset}.zip\n".encode() if url.endswith(".sha256") else archive
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(TuiUnavailableError, match="checksum"):
|
with pytest.raises(TuiUnavailableError, match="checksum"):
|
||||||
_download_release_tui("nanobot-tui-linux-x64")
|
_download_release_tui(asset)
|
||||||
|
|
||||||
|
|
||||||
|
def test_release_tui_rejects_an_archive_without_required_notices(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
tmp_path: Path,
|
||||||
|
) -> None:
|
||||||
|
asset = "nanobot-tui-linux-x64"
|
||||||
|
archive, checksum = _release_archive(asset, omit="THIRD_PARTY_NOTICES.txt")
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"nanobot.cli.tui_launcher._read_release_asset",
|
||||||
|
lambda url, *, max_bytes: checksum if url.endswith(".sha256") else archive,
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(TuiUnavailableError, match="archive is incomplete"):
|
||||||
|
_download_release_tui(asset)
|
||||||
|
|
||||||
|
|
||||||
|
def test_release_tui_rejects_an_empty_required_file(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
tmp_path: Path,
|
||||||
|
) -> None:
|
||||||
|
asset = "nanobot-tui-linux-x64"
|
||||||
|
archive, _checksum = _release_archive(asset)
|
||||||
|
source = io.BytesIO(archive)
|
||||||
|
output = io.BytesIO()
|
||||||
|
with zipfile.ZipFile(source) as original, zipfile.ZipFile(output, "w") as rebuilt:
|
||||||
|
for entry in original.infolist():
|
||||||
|
content = b"" if entry.filename == "SOURCE_OFFER.md" else original.read(entry)
|
||||||
|
rebuilt.writestr(entry.filename, content)
|
||||||
|
payload = output.getvalue()
|
||||||
|
checksum = f"{hashlib.sha256(payload).hexdigest()} {asset}.zip\n".encode()
|
||||||
|
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.__version__", "9.9.9")
|
||||||
|
monkeypatch.setattr("nanobot.cli.tui_launcher.get_data_dir", lambda: tmp_path)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"nanobot.cli.tui_launcher._read_release_asset",
|
||||||
|
lambda url, *, max_bytes: checksum if url.endswith(".sha256") else payload,
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(TuiUnavailableError, match="invalid size"):
|
||||||
|
_download_release_tui(asset)
|
||||||
|
|
||||||
|
|
||||||
def test_gateway_reuse_requires_the_matching_managed_instance(
|
def test_gateway_reuse_requires_the_matching_managed_instance(
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ bun run --cwd tui test
|
|||||||
bun run --cwd tui build
|
bun run --cwd tui build
|
||||||
```
|
```
|
||||||
|
|
||||||
`nanobot agent` launches this client, leases the shared local gateway or starts it on demand, and passes an authenticated local endpoint through environment variables. Other terminals and the WebUI keep that gateway alive; the final interactive launcher to exit releases the on-demand process. Only `nanobot gateway --background` makes it persistent without clients. Source checkouts automatically align dependencies with `bun.lock` before launch; released installs use a version-matched, checksum-verified sidecar. Startup fails explicitly if the native client is unavailable. The legacy Python prompt is only selected with `nanobot agent --classic`.
|
`nanobot agent` launches this client, leases the shared local gateway or starts it on demand, and passes an authenticated local endpoint through environment variables. Other terminals and the WebUI keep that gateway alive; the final interactive launcher to exit releases the on-demand process. Only `nanobot gateway --background` makes it persistent without clients. Source checkouts automatically align dependencies with `bun.lock` before launch; released installs use a version-matched, checksum-verified archive that keeps the executable together with its licenses, notices, corresponding application source, source offer, and relinking instructions. Startup fails explicitly if the native client is unavailable. The legacy Python prompt is only selected with `nanobot agent --classic`.
|
||||||
|
|
||||||
Standalone terminals use OpenTUI's retained full-screen layout: the transcript reflows with the terminal while the composer stays fixed at the bottom. Mouse and keyboard scrolling operate inside the transcript, and leaving the TUI restores the previous terminal screen.
|
Standalone terminals use OpenTUI's retained full-screen layout: the transcript reflows with the terminal while the composer stays fixed at the bottom. Mouse and keyboard scrolling operate inside the transcript, and leaving the TUI restores the previous terminal screen.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Native TUI corresponding source and relinking
|
||||||
|
|
||||||
|
The nanobot TUI release archive contains the executable, its complete JavaScript/TypeScript
|
||||||
|
application source, dependency lockfile, build scripts, and third-party notices. It is built with
|
||||||
|
Bun 1.3.13 and OpenTUI 0.5.3. See `SOURCE_OFFER.md` for the corresponding-source
|
||||||
|
offer that accompanies the executable. The archive also contains the complete LGPL 2.0 and
|
||||||
|
LGPL 2.1 license texts.
|
||||||
|
|
||||||
|
Corresponding upstream source:
|
||||||
|
|
||||||
|
- nanobot TUI: the `tui/` directory in the GitHub release tag that contains this archive
|
||||||
|
- Bun 1.3.13 (`bf2e2cecf27e800962b1e7f03d66278f9d5d2e79`):
|
||||||
|
<https://github.com/oven-sh/bun/tree/bun-v1.3.13>
|
||||||
|
- Bun's patched WebKit (`4d5e75ebd84a14edbc7ae264245dcd77fe597c10`):
|
||||||
|
<https://github.com/oven-sh/WebKit/tree/4d5e75ebd84a14edbc7ae264245dcd77fe597c10>
|
||||||
|
- OpenTUI 0.5.3: <https://www.npmjs.com/package/@opentui/core/v/0.5.3>
|
||||||
|
|
||||||
|
To rebuild against a modified JavaScriptCore/WebKit, first build Bun 1.3.13 from its complete
|
||||||
|
source checkout together with the WebKit revision above by following Bun's pinned license and
|
||||||
|
build instructions. Then unpack
|
||||||
|
`nanobot-tui-source.tar.gz` from the release archive and run the resulting Bun executable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd nanobot-tui-source
|
||||||
|
/path/to/modified/bun install --frozen-lockfile
|
||||||
|
/path/to/modified/bun run build -- <target>
|
||||||
|
```
|
||||||
|
|
||||||
|
Supported targets are `darwin-arm64`, `darwin-x64`, `linux-arm64`, `linux-x64`, and `win32-x64`.
|
||||||
|
The resulting executable is written to `dist/`.
|
||||||
|
|
||||||
|
Questions about source availability can be reported at
|
||||||
|
<https://github.com/HKUDS/nanobot/issues>.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Written offer for corresponding source
|
||||||
|
|
||||||
|
This offer applies to the native nanobot TUI executable distributed in the same release archive.
|
||||||
|
|
||||||
|
For at least three years after the release date, HKUDS offers any third party a
|
||||||
|
complete machine-readable copy of the corresponding source and relinking materials required for
|
||||||
|
the LGPL-covered libraries incorporated through Bun, for no more than the reasonable physical
|
||||||
|
cost of conveying that copy.
|
||||||
|
|
||||||
|
The nanobot application source, lockfile, build scripts, notices, and relinking instructions are
|
||||||
|
already included in this archive. Exact upstream revisions are listed in `RELINKING.md`.
|
||||||
|
|
||||||
|
To request any additional corresponding-source material, open an issue at
|
||||||
|
<https://github.com/HKUDS/nanobot/issues> or email <xubinrencs@gmail.com> and identify the nanobot
|
||||||
|
release tag and target platform shown in `THIRD_PARTY_NOTICES.txt`.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
Bun itself is MIT-licensed.
|
||||||
|
|
||||||
|
## JavaScriptCore
|
||||||
|
|
||||||
|
Bun statically links JavaScriptCore (and WebKit) which is LGPL-2 licensed. WebCore files from WebKit are also licensed under LGPL2. Per LGPL2:
|
||||||
|
|
||||||
|
> (1) If you statically link against an LGPL’d library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application.
|
||||||
|
|
||||||
|
You can find the patched version of WebKit used by Bun here: <https://github.com/oven-sh/webkit>. If you would like to relink Bun with changes:
|
||||||
|
|
||||||
|
- `git submodule update --init --recursive`
|
||||||
|
- `make jsc`
|
||||||
|
- `zig build`
|
||||||
|
|
||||||
|
This compiles JavaScriptCore, compiles Bun’s `.cpp` bindings for JavaScriptCore (which are the object files using JavaScriptCore) and outputs a new `bun` binary with your changes.
|
||||||
|
|
||||||
|
## Linked libraries
|
||||||
|
|
||||||
|
Bun statically links these libraries:
|
||||||
|
|
||||||
|
| Library | License |
|
||||||
|
|---------|---------|
|
||||||
|
| [`boringssl`](https://boringssl.googlesource.com/boringssl/) | [several licenses](https://boringssl.googlesource.com/boringssl/+/refs/heads/master/LICENSE) |
|
||||||
|
| [`brotli`](https://github.com/google/brotli) | MIT |
|
||||||
|
| [`libarchive`](https://github.com/libarchive/libarchive) | [several licenses](https://github.com/libarchive/libarchive/blob/master/COPYING) |
|
||||||
|
| [`lol-html`](https://github.com/cloudflare/lol-html/tree/master/c-api) | BSD 3-Clause |
|
||||||
|
| [`mimalloc`](https://github.com/microsoft/mimalloc) | MIT |
|
||||||
|
| [`picohttp`](https://github.com/h2o/picohttpparser) | dual-licensed under the Perl License or the MIT License |
|
||||||
|
| [`zstd`](https://github.com/facebook/zstd) | dual-licensed under the BSD License or GPLv2 license |
|
||||||
|
| [`simdutf`](https://github.com/simdutf/simdutf) | Apache 2.0 |
|
||||||
|
| [`tinycc`](https://github.com/tinycc/tinycc) | LGPL v2.1 |
|
||||||
|
| [`uSockets`](https://github.com/uNetworking/uSockets) | Apache 2.0 |
|
||||||
|
| [`zlib-ng`](https://github.com/zlib-ng/zlib-ng) | zlib |
|
||||||
|
| [`c-ares`](https://github.com/c-ares/c-ares) | MIT licensed |
|
||||||
|
| [`libicu`](https://github.com/unicode-org/icu) 72 | [license here](https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE) |
|
||||||
|
| [`libbase64`](https://github.com/aklomp/base64/blob/master/LICENSE) | BSD 2-Clause |
|
||||||
|
| [`libuv`](https://github.com/libuv/libuv) (on Windows) | MIT |
|
||||||
|
| [`libdeflate`](https://github.com/ebiggers/libdeflate) | MIT |
|
||||||
|
| [`uucode`](https://github.com/jacobsandlund/uucode) | MIT |
|
||||||
|
| A fork of [`uWebsockets`](https://github.com/jarred-sumner/uwebsockets) | Apache 2.0 licensed |
|
||||||
|
| Parts of [Tigerbeetle's IO code](https://github.com/tigerbeetle/tigerbeetle/blob/532c8b70b9142c17e07737ab6d3da68d7500cbca/src/io/windows.zig#L1) | Apache 2.0 licensed |
|
||||||
|
| `__cxa_thread_atexit` fallback from [LLVM libc++abi](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/libcxxabi/src/cxa_thread_atexit.cpp) | Apache 2.0 with LLVM exception |
|
||||||
|
|
||||||
|
## Polyfills
|
||||||
|
|
||||||
|
For compatibility reasons, the following packages are embedded into Bun's binary and injected if imported.
|
||||||
|
|
||||||
|
| Package | License |
|
||||||
|
|---------|---------|
|
||||||
|
| [`assert`](https://npmjs.com/package/assert) | MIT |
|
||||||
|
| [`browserify-zlib`](https://npmjs.com/package/browserify-zlib) | MIT |
|
||||||
|
| [`buffer`](https://npmjs.com/package/buffer) | MIT |
|
||||||
|
| [`constants-browserify`](https://npmjs.com/package/constants-browserify) | MIT |
|
||||||
|
| [`crypto-browserify`](https://npmjs.com/package/crypto-browserify) | MIT |
|
||||||
|
| [`domain-browser`](https://npmjs.com/package/domain-browser) | MIT |
|
||||||
|
| [`events`](https://npmjs.com/package/events) | MIT |
|
||||||
|
| [`https-browserify`](https://npmjs.com/package/https-browserify) | MIT |
|
||||||
|
| [`os-browserify`](https://npmjs.com/package/os-browserify) | MIT |
|
||||||
|
| [`path-browserify`](https://npmjs.com/package/path-browserify) | MIT |
|
||||||
|
| [`process`](https://npmjs.com/package/process) | MIT |
|
||||||
|
| [`punycode`](https://npmjs.com/package/punycode) | MIT |
|
||||||
|
| [`querystring-es3`](https://npmjs.com/package/querystring-es3) | MIT |
|
||||||
|
| [`stream-browserify`](https://npmjs.com/package/stream-browserify) | MIT |
|
||||||
|
| [`stream-http`](https://npmjs.com/package/stream-http) | MIT |
|
||||||
|
| [`string_decoder`](https://npmjs.com/package/string_decoder) | MIT |
|
||||||
|
| [`timers-browserify`](https://npmjs.com/package/timers-browserify) | MIT |
|
||||||
|
| [`tty-browserify`](https://npmjs.com/package/tty-browserify) | MIT |
|
||||||
|
| [`url`](https://npmjs.com/package/url) | MIT |
|
||||||
|
| [`util`](https://npmjs.com/package/util) | MIT |
|
||||||
|
| [`vm-browserify`](https://npmjs.com/package/vm-browserify) | MIT |
|
||||||
|
|
||||||
|
## Additional credits
|
||||||
|
|
||||||
|
- Bun's JS transpiler, CSS lexer, and Node.js module resolver source code is a Zig port of [@evanw](https://github.com/evanw)’s [esbuild](https://github.com/evanw/esbuild) project.
|
||||||
|
- Credit to [@kipply](https://github.com/kipply) for the name "Bun"!
|
||||||
@@ -0,0 +1,480 @@
|
|||||||
|
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the library GPL. It is
|
||||||
|
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Library General Public License, applies to some
|
||||||
|
specially designated Free Software Foundation software, and to any
|
||||||
|
other libraries whose authors decide to use it. You can use it for
|
||||||
|
your libraries, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if
|
||||||
|
you distribute copies of the library, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link a program with the library, you must provide
|
||||||
|
complete object files to the recipients so that they can relink them
|
||||||
|
with the library, after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
Our method of protecting your rights has two steps: (1) copyright
|
||||||
|
the library, and (2) offer you this license which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
Also, for each distributor's protection, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
library. If the library is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original
|
||||||
|
version, so that any problems introduced by others will not reflect on
|
||||||
|
the original authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that companies distributing free
|
||||||
|
software will individually obtain patent licenses, thus in effect
|
||||||
|
transforming the program into proprietary software. To prevent this,
|
||||||
|
we have made it clear that any patent must be licensed for everyone's
|
||||||
|
free use or not licensed at all.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the ordinary
|
||||||
|
GNU General Public License, which was designed for utility programs. This
|
||||||
|
license, the GNU Library General Public License, applies to certain
|
||||||
|
designated libraries. This license is quite different from the ordinary
|
||||||
|
one; be sure to read it in full, and don't assume that anything in it is
|
||||||
|
the same as in the ordinary license.
|
||||||
|
|
||||||
|
The reason we have a separate public license for some libraries is that
|
||||||
|
they blur the distinction we usually make between modifying or adding to a
|
||||||
|
program and simply using it. Linking a program with a library, without
|
||||||
|
changing the library, is in some sense simply using the library, and is
|
||||||
|
analogous to running a utility program or application program. However, in
|
||||||
|
a textual and legal sense, the linked executable is a combined work, a
|
||||||
|
derivative of the original library, and the ordinary General Public License
|
||||||
|
treats it as such.
|
||||||
|
|
||||||
|
Because of this blurred distinction, using the ordinary General
|
||||||
|
Public License for libraries did not effectively promote software
|
||||||
|
sharing, because most developers did not use the libraries. We
|
||||||
|
concluded that weaker conditions might promote sharing better.
|
||||||
|
|
||||||
|
However, unrestricted linking of non-free programs would deprive the
|
||||||
|
users of those programs of all benefit from the free status of the
|
||||||
|
libraries themselves. This Library General Public License is intended to
|
||||||
|
permit developers of non-free programs to use free libraries, while
|
||||||
|
preserving your freedom as a user of such programs to change the free
|
||||||
|
libraries that are incorporated in them. (We have not seen how to achieve
|
||||||
|
this as regards changes in header files, but we have achieved it as regards
|
||||||
|
changes in the actual functions of the Library.) The hope is that this
|
||||||
|
will lead to faster development of free libraries.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, while the latter only
|
||||||
|
works together with the library.
|
||||||
|
|
||||||
|
Note that it is possible for a library to be covered by the ordinary
|
||||||
|
General Public License rather than by this special one.
|
||||||
|
|
||||||
|
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library which
|
||||||
|
contains a notice placed by the copyright holder or other authorized
|
||||||
|
party saying it may be distributed under the terms of this Library
|
||||||
|
General Public License (also called "this License"). Each licensee is
|
||||||
|
addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also compile or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
c) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
d) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the source code distributed need not include anything that is normally
|
||||||
|
distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Library General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Moe Ghoul>, 1 April 1990
|
||||||
|
Moe Ghoul, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
||||||
@@ -0,0 +1,501 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 2.1, February 1999
|
||||||
|
|
||||||
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the Lesser GPL. It also counts
|
||||||
|
as the successor of the GNU Library Public License, version 2, hence
|
||||||
|
the version number 2.1.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Lesser General Public License, applies to some
|
||||||
|
specially designated software packages--typically libraries--of the
|
||||||
|
Free Software Foundation and other authors who decide to use it. You
|
||||||
|
can use it too, but we suggest you first think carefully about whether
|
||||||
|
this license or the ordinary General Public License is the better
|
||||||
|
strategy to use in any particular case, based on the explanations below.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom of use,
|
||||||
|
not price. Our General Public Licenses are designed to make sure that
|
||||||
|
you have the freedom to distribute copies of free software (and charge
|
||||||
|
for this service if you wish); that you receive source code or can get
|
||||||
|
it if you want it; that you can change the software and use pieces of
|
||||||
|
it in new free programs; and that you are informed that you can do
|
||||||
|
these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
distributors to deny you these rights or to ask you to surrender these
|
||||||
|
rights. These restrictions translate to certain responsibilities for
|
||||||
|
you if you distribute copies of the library or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link other code with the library, you must provide
|
||||||
|
complete object files to the recipients, so that they can relink them
|
||||||
|
with the library after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with a two-step method: (1) we copyright the
|
||||||
|
library, and (2) we offer you this license, which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
To protect each distributor, we want to make it very clear that
|
||||||
|
there is no warranty for the free library. Also, if the library is
|
||||||
|
modified by someone else and passed on, the recipients should know
|
||||||
|
that what they have is not the original version, so that the original
|
||||||
|
author's reputation will not be affected by problems that might be
|
||||||
|
introduced by others.
|
||||||
|
|
||||||
|
Finally, software patents pose a constant threat to the existence of
|
||||||
|
any free program. We wish to make sure that a company cannot
|
||||||
|
effectively restrict the users of a free program by obtaining a
|
||||||
|
restrictive license from a patent holder. Therefore, we insist that
|
||||||
|
any patent license obtained for a version of the library must be
|
||||||
|
consistent with the full freedom of use specified in this license.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the
|
||||||
|
ordinary GNU General Public License. This license, the GNU Lesser
|
||||||
|
General Public License, applies to certain designated libraries, and
|
||||||
|
is quite different from the ordinary General Public License. We use
|
||||||
|
this license for certain libraries in order to permit linking those
|
||||||
|
libraries into non-free programs.
|
||||||
|
|
||||||
|
When a program is linked with a library, whether statically or using
|
||||||
|
a shared library, the combination of the two is legally speaking a
|
||||||
|
combined work, a derivative of the original library. The ordinary
|
||||||
|
General Public License therefore permits such linking only if the
|
||||||
|
entire combination fits its criteria of freedom. The Lesser General
|
||||||
|
Public License permits more lax criteria for linking other code with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
We call this license the "Lesser" General Public License because it
|
||||||
|
does Less to protect the user's freedom than the ordinary General
|
||||||
|
Public License. It also provides other free software developers Less
|
||||||
|
of an advantage over competing non-free programs. These disadvantages
|
||||||
|
are the reason we use the ordinary General Public License for many
|
||||||
|
libraries. However, the Lesser license provides advantages in certain
|
||||||
|
special circumstances.
|
||||||
|
|
||||||
|
For example, on rare occasions, there may be a special need to
|
||||||
|
encourage the widest possible use of a certain library, so that it becomes
|
||||||
|
a de-facto standard. To achieve this, non-free programs must be
|
||||||
|
allowed to use the library. A more frequent case is that a free
|
||||||
|
library does the same job as widely used non-free libraries. In this
|
||||||
|
case, there is little to gain by limiting the free library to free
|
||||||
|
software only, so we use the Lesser General Public License.
|
||||||
|
|
||||||
|
In other cases, permission to use a particular library in non-free
|
||||||
|
programs enables a greater number of people to use a large body of
|
||||||
|
free software. For example, permission to use the GNU C Library in
|
||||||
|
non-free programs enables many more people to use the whole GNU
|
||||||
|
operating system, as well as its variant, the GNU/Linux operating
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the Lesser General Public License is Less protective of the
|
||||||
|
users' freedom, it does ensure that the user of a program that is
|
||||||
|
linked with the Library has the freedom and the wherewithal to run
|
||||||
|
that program using a modified version of the Library.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, whereas the latter must
|
||||||
|
be combined with the library in order to run.
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library or other
|
||||||
|
program which contains a notice placed by the copyright holder or
|
||||||
|
other authorized party saying it may be distributed under the terms of
|
||||||
|
this Lesser General Public License (also called "this License").
|
||||||
|
Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also combine or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (1) uses at run time a
|
||||||
|
copy of the library already present on the user's computer system,
|
||||||
|
rather than copying library functions into the executable, and (2)
|
||||||
|
will operate properly with a modified version of the library, if
|
||||||
|
the user installs one, as long as the modified version is
|
||||||
|
interface-compatible with the version that the work was made with.
|
||||||
|
|
||||||
|
c) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
d) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
e) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the materials to be distributed need not include anything that is
|
||||||
|
normally distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties with
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Lesser General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Moe Ghoul>, 1 April 1990
|
||||||
|
Moe Ghoul, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
"""Create one self-contained, licensed native TUI release archive."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import io
|
||||||
|
import sys
|
||||||
|
import tarfile
|
||||||
|
import zipfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
_SUPPORTED_TARGETS = {
|
||||||
|
"darwin-arm64",
|
||||||
|
"darwin-x64",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-x64",
|
||||||
|
"win32-x64",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _sha256(data: bytes) -> str:
|
||||||
|
return hashlib.sha256(data).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def _source_archive(root: Path) -> bytes:
|
||||||
|
included = [
|
||||||
|
"README.md",
|
||||||
|
"RELINKING.md",
|
||||||
|
"SOURCE_OFFER.md",
|
||||||
|
"package.json",
|
||||||
|
"bun.lock",
|
||||||
|
"tsconfig.json",
|
||||||
|
"src",
|
||||||
|
"scripts/build.ts",
|
||||||
|
"scripts/prepare-target.ts",
|
||||||
|
"scripts/release-notices.ts",
|
||||||
|
"scripts/package-release.py",
|
||||||
|
"licenses",
|
||||||
|
]
|
||||||
|
output = io.BytesIO()
|
||||||
|
with tarfile.open(fileobj=output, mode="w:gz", format=tarfile.PAX_FORMAT) as archive:
|
||||||
|
for relative in included:
|
||||||
|
path = root / relative
|
||||||
|
if not path.exists():
|
||||||
|
raise FileNotFoundError(path)
|
||||||
|
archive.add(path, arcname=Path("nanobot-tui-source") / relative)
|
||||||
|
return output.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
raise SystemExit("usage: package-release.py <target>")
|
||||||
|
target = sys.argv[1]
|
||||||
|
if target not in _SUPPORTED_TARGETS:
|
||||||
|
raise SystemExit(f"unsupported target: {target}")
|
||||||
|
root = Path(__file__).resolve().parent.parent
|
||||||
|
project_root = root.parent
|
||||||
|
extension = ".exe" if target.startswith("win32-") else ""
|
||||||
|
asset = f"nanobot-tui-{target}{extension}"
|
||||||
|
dist = root / "dist"
|
||||||
|
|
||||||
|
files = {
|
||||||
|
asset: (dist / asset).read_bytes(),
|
||||||
|
"THIRD_PARTY_NOTICES.txt": (dist / f"{asset}.THIRD_PARTY_NOTICES.txt").read_bytes(),
|
||||||
|
"RELINKING.md": (root / "RELINKING.md").read_bytes(),
|
||||||
|
"SOURCE_OFFER.md": (root / "SOURCE_OFFER.md").read_bytes(),
|
||||||
|
"LICENSE": (project_root / "LICENSE").read_bytes(),
|
||||||
|
"BUN-1.3.13-LICENSE.md": (root / "licenses" / "BUN-1.3.13-LICENSE.md").read_bytes(),
|
||||||
|
"LGPL-2.0.txt": (root / "licenses" / "LGPL-2.0.txt").read_bytes(),
|
||||||
|
"LGPL-2.1.txt": (root / "licenses" / "LGPL-2.1.txt").read_bytes(),
|
||||||
|
"nanobot-tui-source.tar.gz": _source_archive(root),
|
||||||
|
}
|
||||||
|
manifest = "".join(f"{_sha256(content)} {name}\n" for name, content in files.items()).encode()
|
||||||
|
files["MANIFEST.sha256"] = manifest
|
||||||
|
|
||||||
|
output = dist / f"{asset}.zip"
|
||||||
|
with zipfile.ZipFile(output, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as archive:
|
||||||
|
for name, content in files.items():
|
||||||
|
archive.writestr(name, content)
|
||||||
|
digest = _sha256(output.read_bytes())
|
||||||
|
output.with_name(f"{output.name}.sha256").write_text(
|
||||||
|
f"{digest} {output.name}\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
import { readdir, readFile, writeFile } from "node:fs/promises"
|
||||||
|
import { basename, join } from "node:path"
|
||||||
|
|
||||||
|
const target = process.argv[2]
|
||||||
|
if (!target) throw new Error("target is required")
|
||||||
|
const supportedTargets = new Set([
|
||||||
|
"darwin-arm64",
|
||||||
|
"darwin-x64",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-x64",
|
||||||
|
"win32-x64",
|
||||||
|
])
|
||||||
|
if (!supportedTargets.has(target)) throw new Error(`unsupported target: ${target}`)
|
||||||
|
const nativePackagesByTarget: Record<string, string[]> = {
|
||||||
|
"darwin-arm64": ["@opentui/core-darwin-arm64"],
|
||||||
|
"darwin-x64": ["@opentui/core-darwin-x64"],
|
||||||
|
"linux-arm64": ["@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl"],
|
||||||
|
"linux-x64": ["@opentui/core-linux-x64", "@opentui/core-linux-x64-musl"],
|
||||||
|
"win32-x64": ["@opentui/core-win32-x64"],
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = join(import.meta.dir, "..")
|
||||||
|
const projectRoot = join(root, "..")
|
||||||
|
const extension = target.startsWith("win32-") ? ".exe" : ""
|
||||||
|
const asset = `nanobot-tui-${target}${extension}`
|
||||||
|
const output = join(root, "dist", `${asset}.THIRD_PARTY_NOTICES.txt`)
|
||||||
|
|
||||||
|
type PackageNotice = {
|
||||||
|
name: string
|
||||||
|
version: string
|
||||||
|
license: string
|
||||||
|
files: Array<{ name: string; content: string }>
|
||||||
|
}
|
||||||
|
|
||||||
|
type PackageManifest = {
|
||||||
|
name?: unknown
|
||||||
|
version?: unknown
|
||||||
|
license?: unknown
|
||||||
|
dependencies?: Record<string, string>
|
||||||
|
optionalDependencies?: Record<string, string>
|
||||||
|
peerDependencies?: Record<string, string>
|
||||||
|
devDependencies?: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runtimePackageRoots(root: string): Promise<string[]> {
|
||||||
|
const manifest = JSON.parse(await readFile(join(root, "package.json"), "utf8")) as PackageManifest
|
||||||
|
const nodeModules = join(root, "node_modules")
|
||||||
|
const devDependencies = new Set(Object.keys(manifest.devDependencies ?? {}))
|
||||||
|
const pending = Object.keys(manifest.dependencies ?? {}).map((name) => ({ name, optional: false }))
|
||||||
|
const visited = new Set<string>()
|
||||||
|
const roots: string[] = []
|
||||||
|
|
||||||
|
while (pending.length) {
|
||||||
|
const next = pending.shift()
|
||||||
|
if (!next || visited.has(next.name)) continue
|
||||||
|
const { name, optional } = next
|
||||||
|
const path = join(nodeModules, name)
|
||||||
|
if (!(await Bun.file(join(path, "package.json")).exists())) {
|
||||||
|
if (optional) continue
|
||||||
|
throw new Error(`required runtime package is missing: ${name}`)
|
||||||
|
}
|
||||||
|
const dependency = JSON.parse(await readFile(join(path, "package.json"), "utf8")) as PackageManifest
|
||||||
|
visited.add(name)
|
||||||
|
roots.push(path)
|
||||||
|
pending.push(
|
||||||
|
...Object.keys(dependency.dependencies ?? {}).map((dependencyName) => ({
|
||||||
|
name: dependencyName,
|
||||||
|
optional: false,
|
||||||
|
})),
|
||||||
|
...Object.keys(dependency.optionalDependencies ?? {}).map((dependencyName) => ({
|
||||||
|
name: dependencyName,
|
||||||
|
optional: true,
|
||||||
|
})),
|
||||||
|
...Object.keys(dependency.peerDependencies ?? {})
|
||||||
|
.filter((peer) => !devDependencies.has(peer))
|
||||||
|
.map((peer) => ({ name: peer, optional: true })),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return roots.sort()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readPackageNotice(path: string): Promise<PackageNotice> {
|
||||||
|
const manifest = JSON.parse(await readFile(join(path, "package.json"), "utf8")) as PackageManifest
|
||||||
|
const entries = await readdir(path, { withFileTypes: true })
|
||||||
|
const licenseNames = entries
|
||||||
|
.filter((entry) => entry.isFile() && /^(licen[cs]e|copying|notice)([._-].*)?$/i.test(entry.name))
|
||||||
|
.map((entry) => entry.name)
|
||||||
|
.sort()
|
||||||
|
if (!licenseNames.length) throw new Error(`${manifest.name ?? basename(path)} has no license file`)
|
||||||
|
return {
|
||||||
|
name: String(manifest.name ?? basename(path)),
|
||||||
|
version: String(manifest.version ?? "unknown"),
|
||||||
|
license: String(manifest.license ?? "see included license"),
|
||||||
|
files: await Promise.all(
|
||||||
|
licenseNames.map(async (name) => ({ name, content: await readFile(join(path, name), "utf8") })),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const notices = await Promise.all(
|
||||||
|
(await runtimePackageRoots(root)).map(readPackageNotice),
|
||||||
|
)
|
||||||
|
const packagedNames = new Set(notices.map((notice) => notice.name))
|
||||||
|
for (const name of nativePackagesByTarget[target] ?? []) {
|
||||||
|
if (!packagedNames.has(name)) throw new Error(`target runtime package is missing: ${name}`)
|
||||||
|
}
|
||||||
|
const sections = [
|
||||||
|
"nanobot native TUI third-party notices",
|
||||||
|
"",
|
||||||
|
`Target: ${target}`,
|
||||||
|
"Runtime: Bun 1.3.13",
|
||||||
|
"The release archive also contains SOURCE_OFFER.md, RELINKING.md, and the complete TUI application source.",
|
||||||
|
"",
|
||||||
|
"===== nanobot project license =====",
|
||||||
|
"",
|
||||||
|
await readFile(join(projectRoot, "LICENSE"), "utf8"),
|
||||||
|
"",
|
||||||
|
"===== Bun 1.3.13 runtime license and linked-library notice =====",
|
||||||
|
"",
|
||||||
|
await readFile(join(root, "licenses", "BUN-1.3.13-LICENSE.md"), "utf8"),
|
||||||
|
"",
|
||||||
|
"===== GNU Lesser General Public License 2.0 =====",
|
||||||
|
"",
|
||||||
|
await readFile(join(root, "licenses", "LGPL-2.0.txt"), "utf8"),
|
||||||
|
"",
|
||||||
|
"===== GNU Lesser General Public License 2.1 =====",
|
||||||
|
"",
|
||||||
|
await readFile(join(root, "licenses", "LGPL-2.1.txt"), "utf8"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for (const notice of notices.sort((left, right) => left.name.localeCompare(right.name))) {
|
||||||
|
sections.push("", `===== ${notice.name} ${notice.version} (${notice.license}) =====`)
|
||||||
|
for (const file of notice.files) sections.push("", `--- ${file.name} ---`, "", file.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
await writeFile(output, `${sections.join("\n").trimEnd()}\n`, "utf8")
|
||||||
|
console.log(output)
|
||||||
Reference in New Issue
Block a user