nexus-lite 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nexus_lite-0.2.2/LICENSE +21 -0
- nexus_lite-0.2.2/PKG-INFO +377 -0
- nexus_lite-0.2.2/README.md +346 -0
- nexus_lite-0.2.2/nexus_lite/__init__.py +190 -0
- nexus_lite-0.2.2/nexus_lite/__main__.py +7 -0
- nexus_lite-0.2.2/nexus_lite/_db.py +196 -0
- nexus_lite-0.2.2/nexus_lite/_proc.py +17 -0
- nexus_lite-0.2.2/nexus_lite/artifacts.py +83 -0
- nexus_lite-0.2.2/nexus_lite/cli.py +491 -0
- nexus_lite-0.2.2/nexus_lite/colab/__init__.py +55 -0
- nexus_lite-0.2.2/nexus_lite/colab/__main__.py +9 -0
- nexus_lite-0.2.2/nexus_lite/colab/env.py +298 -0
- nexus_lite-0.2.2/nexus_lite/colab/tunnel.py +1245 -0
- nexus_lite-0.2.2/nexus_lite/compute.py +803 -0
- nexus_lite-0.2.2/nexus_lite/core.py +845 -0
- nexus_lite-0.2.2/nexus_lite/demos/__init__.py +39 -0
- nexus_lite-0.2.2/nexus_lite/demos/__main__.py +7 -0
- nexus_lite-0.2.2/nexus_lite/demos/cli.py +251 -0
- nexus_lite-0.2.2/nexus_lite/demos/loom_multi_agent.py +689 -0
- nexus_lite-0.2.2/nexus_lite/demos/loom_multi_task.py +418 -0
- nexus_lite-0.2.2/nexus_lite/demos/loom_radiomics_tasks.py +1175 -0
- nexus_lite-0.2.2/nexus_lite/demos/orchestration.py +2232 -0
- nexus_lite-0.2.2/nexus_lite/demos/scenarios.py +1808 -0
- nexus_lite-0.2.2/nexus_lite/demos/viz.py +1017 -0
- nexus_lite-0.2.2/nexus_lite/guard.py +81 -0
- nexus_lite-0.2.2/nexus_lite/loom.py +282 -0
- nexus_lite-0.2.2/nexus_lite/loom_multi_agent.py +12 -0
- nexus_lite-0.2.2/nexus_lite/loom_multi_task.py +12 -0
- nexus_lite-0.2.2/nexus_lite/loom_radiomics_tasks.py +12 -0
- nexus_lite-0.2.2/nexus_lite/memory/__init__.py +24 -0
- nexus_lite-0.2.2/nexus_lite/memory/ltm.py +96 -0
- nexus_lite-0.2.2/nexus_lite/memory/mtm.py +269 -0
- nexus_lite-0.2.2/nexus_lite/memory/stm.py +756 -0
- nexus_lite-0.2.2/nexus_lite/phi.py +35 -0
- nexus_lite-0.2.2/nexus_lite/protocol.py +106 -0
- nexus_lite-0.2.2/nexus_lite/provider_errors.py +144 -0
- nexus_lite-0.2.2/nexus_lite/pty.py +913 -0
- nexus_lite-0.2.2/nexus_lite/roles.py +140 -0
- nexus_lite-0.2.2/nexus_lite/stm.py +13 -0
- nexus_lite-0.2.2/nexus_lite/viz.py +12 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/PKG-INFO +377 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/SOURCES.txt +68 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/dependency_links.txt +1 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/entry_points.txt +4 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/requires.txt +10 -0
- nexus_lite-0.2.2/nexus_lite.egg-info/top_level.txt +1 -0
- nexus_lite-0.2.2/pyproject.toml +50 -0
- nexus_lite-0.2.2/setup.cfg +4 -0
- nexus_lite-0.2.2/tests/test_artifacts.py +50 -0
- nexus_lite-0.2.2/tests/test_bus_v1.py +203 -0
- nexus_lite-0.2.2/tests/test_colab_storage.py +71 -0
- nexus_lite-0.2.2/tests/test_colab_tunnel_secure.py +370 -0
- nexus_lite-0.2.2/tests/test_guard.py +65 -0
- nexus_lite-0.2.2/tests/test_kernel_demo_split.py +132 -0
- nexus_lite-0.2.2/tests/test_loom.py +181 -0
- nexus_lite-0.2.2/tests/test_loom_contract.py +53 -0
- nexus_lite-0.2.2/tests/test_loom_install.py +84 -0
- nexus_lite-0.2.2/tests/test_loom_multi_agent.py +648 -0
- nexus_lite-0.2.2/tests/test_loom_radiomics.py +113 -0
- nexus_lite-0.2.2/tests/test_memory_package.py +112 -0
- nexus_lite-0.2.2/tests/test_nexus_lite.py +1405 -0
- nexus_lite-0.2.2/tests/test_pgkill_agy.py +99 -0
- nexus_lite-0.2.2/tests/test_phi_gate.py +89 -0
- nexus_lite-0.2.2/tests/test_provider_errors.py +58 -0
- nexus_lite-0.2.2/tests/test_pty_idle.py +115 -0
- nexus_lite-0.2.2/tests/test_pty_primitive.py +85 -0
- nexus_lite-0.2.2/tests/test_publish_snapshot.py +210 -0
- nexus_lite-0.2.2/tests/test_qradiomics_medimage_demos.py +287 -0
- nexus_lite-0.2.2/tests/test_schema_hygiene.py +124 -0
- nexus_lite-0.2.2/tests/test_standalone.py +69 -0
nexus_lite-0.2.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Choi Lab (Thomas Jefferson University)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nexus-lite
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Ultra-simple Colab-ready multi-agent primitives for Nexus
|
|
5
|
+
Author-email: Wookjin Choi <wookjin.choi@jefferson.edu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/choilab-jefferson/nexus.lite
|
|
8
|
+
Project-URL: Issues, https://github.com/choilab-jefferson/nexus.lite/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/choilab-jefferson/nexus.lite/blob/main/CHANGELOG.md
|
|
10
|
+
Keywords: agents,multi-agent,colab,pty,llm
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: pyte>=0.8.1
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
25
|
+
Provides-Extra: demos
|
|
26
|
+
Requires-Dist: numpy>=1.24.0; extra == "demos"
|
|
27
|
+
Requires-Dist: scipy>=1.10.0; extra == "demos"
|
|
28
|
+
Requires-Dist: pydicom>=2.4.0; extra == "demos"
|
|
29
|
+
Requires-Dist: SimpleITK>=2.3.0; extra == "demos"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# nexus-lite
|
|
33
|
+
|
|
34
|
+
| Interactive Colab Notebook | Description |
|
|
35
|
+
| :--- | :--- |
|
|
36
|
+
| [](https://colab.research.google.com/github/choilab-jefferson/nexus.lite/blob/main/notebooks/nexus_lite_colab_demo.ipynb) | **Core Multi-Agent Demo**: Persistent `dtach` PTYs, message bus pointer injection, swarms, role pipelines, remote tunnel, and live `agy` CLI orchestration |
|
|
37
|
+
| [](https://colab.research.google.com/github/choilab-jefferson/nexus.lite/blob/main/notebooks/qradiomics_medimage_colab_demo.ipynb) | **QRadiomics + MedImage Multi-Agent Demo**: 3D nodule spiculation/AHSN swarm, HIPAA DICOM de-identification pipeline, multi-modality CT/MRI/PET swarm, and Lung1 data-leakage & reproducibility audit |
|
|
38
|
+
|
|
39
|
+
Ultra-simple Colab-ready multi-agent primitives for Nexus.
|
|
40
|
+
|
|
41
|
+
`nexus-lite` turns standalone **CLI coding agents** (an *agent* here is a CLI such as `agy`, `opencode` or `claude`; a *worker* is the leaf agent process a `delegate` call starts) (`agy`, `opencode`, and `claude`) into a coordinated multi-agent system—providing persistent PTY control (`dtach` + `pyte`), inter-agent messaging with PTY pointer delivery (`[nexus] dm`), native `stm/1` short-term memory (`<nexus_stm>`), parallel swarm & role-pipeline delegation, 5-turn peer-to-peer A2A review loops (`interact`), autonomous 5-phase cooperative problem-solving swarms (`cooperate`), and a local Markdown wiki with full-text search (FTS5). Unlike prompt-chaining API libraries, `nexus-lite` orchestrates real coding agents with full shell and filesystem access while requiring **no external server daemons and zero infrastructure setup**, making it ideal for Google Colab, Jupyter notebooks, and lightweight research workflows.
|
|
42
|
+
|
|
43
|
+
- **Multi-Agent CLI Harness & Automatic Quota Fallback (`agy` + `opencode` + `claude`)**: Orchestrate heavy reasoning, adversarial `pytest` authoring, and closed-loop repair across **`agy`** (Google Antigravity CLI), **`opencode`** (`opencode/mimo-v2.6-flash-free`, `opencode/mimo-v2.6-flash-free`, `opencode/big-pickle`—which work out-of-the-box with **zero signup and zero API key**), and **`claude`** (Claude Code). If `claude` hits its weekly limit or `opencode` hits its daily free-tier limit, `nexus-lite` automatically falls back in-place (`fallback_cmd`) to available agents.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
1. **Persistent PTY Controller (`nexus_lite.pty`)**:
|
|
48
|
+
- Native `dtach` wire protocol client (`MSG_PUSH`, `MSG_ATTACH`, `MSG_DETACH`, `MSG_WINCH`).
|
|
49
|
+
- Terminal screen capture and VT rendering via `pyte`.
|
|
50
|
+
- Concurrency safety with `flock` on `{sock}.lock`.
|
|
51
|
+
- Multi-agent busy/idle classifier (`claude`, `agy`, `gemini`, `copilot`, `opencode`, `bash`).
|
|
52
|
+
- Keystroke injection (`keys`) and automated wait loops (`wait`).
|
|
53
|
+
|
|
54
|
+
2. **File & SQLite Message Bus (`nexus_lite.core.bus_*`)**:
|
|
55
|
+
- Zero-broker pub/sub over SQLite WAL and `.nexus/inbox/<msg_id>.md`.
|
|
56
|
+
- Real-time PTY pointer line injection: delivers `[nexus] <kind> <id> <path> - <summary>` directly into active PTY sessions.
|
|
57
|
+
|
|
58
|
+
3. **Native `stm/1` Short-Term Memory Store (`nexus_lite.memory.stm`)**:
|
|
59
|
+
- File-backed `stm/1` nodes (`.nexus/stm/stm-<project_id>/node/<id>.md`) following `Files = Source of Truth`.
|
|
60
|
+
- Deterministic `<nexus_stm>` JSON/fenced prompt-envelope packing (`nl.stm_pack()`) for cross-turn and cross-agent continuity.
|
|
61
|
+
|
|
62
|
+
4. **Subtask Delegation, Multi-Agent Swarms & Autonomous Problem Solving (`nexus_lite.core`)**:
|
|
63
|
+
- Executes leaf subagents via subprocess or background PTY sessions with in-place quota/auth fallback (`fallback_cmd`).
|
|
64
|
+
- Enforces recursion guards (`NEXUS_DELEGATION_DEPTH` max 2) and generates persistent artifacts in `.nexus/artifacts/<task_id>/`.
|
|
65
|
+
- **5-Turn Peer-to-Peer Interaction (`demos.run_agent_interaction`)**: Direct `[nexus] dm` exchange across `agy-architect` → `code-driver` → `opencode-reviewer` → `code-driver` → `agy-architect`.
|
|
66
|
+
- **Autonomous 5-Phase Cooperative Problem Solver (`demos.run_cooperative_problem_solver`)**: Takes any arbitrary problem `--goal` and coordinates `thinker-architect` (`agy`), `algo-driver` (`opencode`), `test-engineer` (`agy`), `leaf-scout` (`opencode/big-pickle`), and `peer-verifier` through contract decomposition, parallel code + adversarial `pytest` generation, live `pytest` execution, `<nexus_stm>` closed-loop repair, and consensus sign-off.
|
|
67
|
+
|
|
68
|
+
5. **Markdown Wiki with FTS5 (`nexus_lite.core.wiki_*`)**:
|
|
69
|
+
- Plain markdown documentation in `.nexus/wiki/<slug>.md`.
|
|
70
|
+
- Full-text search powered by SQLite FTS5 with snippet generation.
|
|
71
|
+
|
|
72
|
+
6. **Universal Environment Support (`ensure_env`, `detect_env`, `ensure_colab`)**:
|
|
73
|
+
- Universal runtime detection: Google Colab, VS Code Dev Containers, GitHub Codespaces, Docker, RunPod/Vast.ai, or Local Linux/macOS.
|
|
74
|
+
- One-call `ensure_env()` bootstraps `dtach` and initializes the `.nexus/` workspace.
|
|
75
|
+
- Ready-to-use `.devcontainer/devcontainer.json` configuration with automatic port forwarding.
|
|
76
|
+
|
|
77
|
+
7. **Cloudflared Remote Tunnel (`nexus_lite.colab.tunnel`)**:
|
|
78
|
+
- Auto-configures `cloudflared` to establish an ephemeral `trycloudflare.com` tunnel.
|
|
79
|
+
- Bearer token-authenticated HTTP JSON API server with endpoints for code execution, PTY sessions, bus messages, `stm/1` memory, swarms, pipelines, A2A `interact`, 5-phase `cooperate`, and wiki operations.
|
|
80
|
+
- Zero-dependency `ColabTunnelClient` client allows any local agent (`agy`, `claude`, `opencode`) to execute remote GPU code and orchestrate multi-agent workflows.
|
|
81
|
+
|
|
82
|
+
8. **Live HTML5 Multi-Agent Dashboard (`nexus_lite.demos.viz`)**:
|
|
83
|
+
- Standalone, zero-CDN HTML5 dashboard with compact 2x2 layout: KPI summary, inline SVG agent topology graph (including curved P2P DM edges, sequence diagram, and 5-phase cooperative timeline), dark PTY terminal screens, task kanban board, and message timeline.
|
|
84
|
+
- Accessible inline in notebooks or globally via the live dashboard `/dashboard?token=<token>&refresh=3`.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Installation & Environments
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install git+https://github.com/choilab-jefferson/nexus.lite.git
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Universal One-Liner (All Environments)
|
|
95
|
+
|
|
96
|
+
`nexus-lite` provides a single entrypoint `colab.ensure_env()` that automatically detects your environment and sets up the workspace:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import nexus_lite as nl
|
|
100
|
+
from nexus_lite import colab
|
|
101
|
+
from nexus_lite import demos
|
|
102
|
+
from nexus_lite.demos import viz
|
|
103
|
+
|
|
104
|
+
# Detects Colab, Codespaces, Dev Containers, Docker, or Local host
|
|
105
|
+
info = colab.ensure_env()
|
|
106
|
+
print(f"Runtime: {info['env']}, Workspace: {info['workspace']}")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Supported Environments
|
|
110
|
+
|
|
111
|
+
#### 1. Google Colab
|
|
112
|
+
Run in a Colab notebook cell:
|
|
113
|
+
```python
|
|
114
|
+
!apt-get update -qq && apt-get install -y -qq dtach
|
|
115
|
+
!pip install -q git+https://github.com/choilab-jefferson/nexus.lite.git
|
|
116
|
+
|
|
117
|
+
import nexus_lite as nl
|
|
118
|
+
from nexus_lite import colab
|
|
119
|
+
from nexus_lite import demos
|
|
120
|
+
from nexus_lite.demos import viz
|
|
121
|
+
info = colab.ensure_env() # Auto-detects Colab, defaults mount_drive=True, start_tunnel=True
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### 2. VS Code Dev Containers & GitHub Codespaces
|
|
125
|
+
A pre-configured dev container is included in `.devcontainer/devcontainer.json` (`python:3.12` base image, `dtach` system package, `pip install -e .[dev]`, and port 8765 auto-forwarding).
|
|
126
|
+
- Open the repository in VS Code using **Dev Containers: Reopen in Container** or launch in **GitHub Codespaces**.
|
|
127
|
+
- Call `colab.ensure_env()`. Port `8765` is forwarded automatically.
|
|
128
|
+
- Open the compact 2x2 live dashboard in your browser:
|
|
129
|
+
`http://127.0.0.1:8765/dashboard?token=<token>&refresh=3`
|
|
130
|
+
|
|
131
|
+
#### 3. Docker & Local Linux / macOS
|
|
132
|
+
```bash
|
|
133
|
+
# Ubuntu / Debian
|
|
134
|
+
sudo apt-get install -y dtach
|
|
135
|
+
pip install git+https://github.com/choilab-jefferson/nexus.lite.git
|
|
136
|
+
```
|
|
137
|
+
```python
|
|
138
|
+
import nexus_lite as nl
|
|
139
|
+
from nexus_lite import colab
|
|
140
|
+
from nexus_lite import demos
|
|
141
|
+
from nexus_lite.demos import viz
|
|
142
|
+
info = colab.ensure_env()
|
|
143
|
+
# Bridge server runs locally on http://127.0.0.1:8765
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### 4. RunPod / Vast.ai Headless GPU Pods
|
|
147
|
+
For remote GPU cloud instances behind NAT without open inbound ports, enable Cloudflare tunneling:
|
|
148
|
+
```python
|
|
149
|
+
import nexus_lite as nl
|
|
150
|
+
from nexus_lite import colab
|
|
151
|
+
from nexus_lite import demos
|
|
152
|
+
from nexus_lite.demos import viz
|
|
153
|
+
from nexus_lite.colab import tunnel
|
|
154
|
+
|
|
155
|
+
colab.ensure_env()
|
|
156
|
+
info = tunnel.start_tunnel(tunnel=True, token="my-token")
|
|
157
|
+
print("Public 2x2 Dashboard:", info["dashboard_url"] + "&refresh=3")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Quickstart (Python API)
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
import nexus_lite as nl
|
|
166
|
+
from nexus_lite import colab
|
|
167
|
+
from nexus_lite import demos
|
|
168
|
+
from nexus_lite.demos import viz
|
|
169
|
+
|
|
170
|
+
# 1. Initialize workspace
|
|
171
|
+
nl.init()
|
|
172
|
+
|
|
173
|
+
# 2. Launch an interactive CLI agent in PTY
|
|
174
|
+
nl.pty.spawn("bash", name="shell1")
|
|
175
|
+
nl.pty.send("shell1", "echo 'Hello from agent'")
|
|
176
|
+
screen = nl.pty.read("shell1")
|
|
177
|
+
print(screen)
|
|
178
|
+
|
|
179
|
+
# 3. Send a message (`bus_send` = nexus say/dm/relay; target ALL = broadcast to live sessions)
|
|
180
|
+
nl.bus_send(target="shell1", message="Review task artifact 42", kind="dm")
|
|
181
|
+
|
|
182
|
+
# 4. Delegate background task
|
|
183
|
+
res = nl.delegate(
|
|
184
|
+
agent_cmd="python3 -c 'print(\"Task Done\")'",
|
|
185
|
+
prompt="Perform computation",
|
|
186
|
+
caller="shell1",
|
|
187
|
+
bg=False,
|
|
188
|
+
)
|
|
189
|
+
print("Task status:", res["status"], "rc:", res["rc"])
|
|
190
|
+
|
|
191
|
+
# 5. Local Wiki with FTS5 search
|
|
192
|
+
nl.wiki_write("architecture", "# Architecture Overview\nNexus-lite uses SQLite WAL.")
|
|
193
|
+
results = nl.wiki_search("SQLite")
|
|
194
|
+
print("Search results:", results)
|
|
195
|
+
|
|
196
|
+
# 6. Remote Colab Tunnel & Client (Google Colab <-> Local Agent)
|
|
197
|
+
# In Colab:
|
|
198
|
+
from nexus_lite.colab import tunnel
|
|
199
|
+
|
|
200
|
+
info = tunnel.start_tunnel(port=8765, tunnel=True, token="secret-token")
|
|
201
|
+
print("Public Dashboard:", info["dashboard_url"])
|
|
202
|
+
|
|
203
|
+
# From local agent machine:
|
|
204
|
+
client = tunnel.ColabTunnelClient(info["local_url"], token=info["token"])
|
|
205
|
+
gpu_check = client.exec(python="import torch; print('CUDA:', torch.cuda.is_available())")
|
|
206
|
+
print(gpu_check["stdout"])
|
|
207
|
+
tunnel.stop_tunnel()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## CLI Reference
|
|
213
|
+
|
|
214
|
+
> Demo and orchestration subcommands (`demo`, `multi-tier`, `interact`, `cooperate`, `dashboard`) live in the separate `nexus-lite-demo` console script; `nexus-lite` is the kernel CLI only.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Initialize workspace (.nexus/)
|
|
218
|
+
nexus-lite init [--workspace .nexus]
|
|
219
|
+
|
|
220
|
+
# Manage PTY sessions (a session = one dtach PTY / registry row; never a worker)
|
|
221
|
+
nexus-lite pty new "bash" --name worker1
|
|
222
|
+
nexus-lite pty list
|
|
223
|
+
nexus-lite pty send worker1 "ls -la"
|
|
224
|
+
nexus-lite pty keys worker1 enter
|
|
225
|
+
nexus-lite pty read worker1 --cols 160 --rows 45
|
|
226
|
+
nexus-lite pty wait worker1 --provider bash --timeout 10
|
|
227
|
+
nexus-lite pty kill worker1
|
|
228
|
+
|
|
229
|
+
# Message bus (MTM: flow carried across interruptions; transport = bus)
|
|
230
|
+
nexus-lite bus send worker1 "Please review file" --sender orchestrator --kind dm
|
|
231
|
+
nexus-lite bus read --limit 10
|
|
232
|
+
|
|
233
|
+
# Task delegation (worker = leaf agent process; completion arrives as TASK_COMPLETE / TASK_ESCALATE to --caller)
|
|
234
|
+
nexus-lite delegate "python3 worker.py" "Run pipeline" --caller worker1
|
|
235
|
+
|
|
236
|
+
# Wiki management
|
|
237
|
+
nexus-lite wiki write getting-started "# Getting Started Guide"
|
|
238
|
+
nexus-lite wiki read getting-started
|
|
239
|
+
nexus-lite wiki search "Guide"
|
|
240
|
+
nexus-lite wiki list
|
|
241
|
+
|
|
242
|
+
# Chat helper
|
|
243
|
+
nexus-lite chat worker1 "What is current status?" --provider bash
|
|
244
|
+
|
|
245
|
+
# Remote Colab Tunnel Server & Client
|
|
246
|
+
nexus-lite-colab start --port 8765
|
|
247
|
+
nexus-lite-colab status
|
|
248
|
+
nexus-lite-colab exec "nvidia-smi" --url "https://xyz.trycloudflare.com" --token "secret"
|
|
249
|
+
nexus-lite-colab stop
|
|
250
|
+
|
|
251
|
+
# HTML5 Dashboard
|
|
252
|
+
nexus-lite-demo dashboard --out dashboard.html
|
|
253
|
+
|
|
254
|
+
# Short-Term Memory (stm/1)
|
|
255
|
+
nexus-lite stm write --kind decision --status done --summary "Use modified Z-score"
|
|
256
|
+
nexus-lite stm list
|
|
257
|
+
nexus-lite stm pack
|
|
258
|
+
|
|
259
|
+
# 5-Turn Peer-to-Peer Agent Interaction (interact) & Autonomous 5-Phase Cooperative Swarm (cooperate)
|
|
260
|
+
nexus-lite-demo interact --goal "Implement and peer-review a 3D NIfTI affine validator"
|
|
261
|
+
nexus-lite-demo cooperate \
|
|
262
|
+
--goal "Design, implement, and adversarially test a 3D Radiomics Z-Score Harmonizer and IQR Outlier Quarantine module (scanner_harmonizer.py)" \
|
|
263
|
+
--module-name scanner_harmonizer \
|
|
264
|
+
--architect-agent agy \
|
|
265
|
+
--verifier-agent opencode/mimo-v2.6-flash-free
|
|
266
|
+
|
|
267
|
+
# Practical QRadiomics + MedImage Multi-Agent Demos (with agy, multi-tier, or claude)
|
|
268
|
+
nexus-lite-demo demo all --agent agy # Run all 4 medical imaging & radiomics demos via Antigravity (agy)
|
|
269
|
+
nexus-lite-demo demo all --agent multi-tier # Run all 4 demos across OpenCode + AGY
|
|
270
|
+
nexus-lite-demo demo all --agent claude # Run all 4 demos via Claude Code (claude, auto-falls back if quota reached)
|
|
271
|
+
nexus-lite-demo demo phantom-swarm --agent agy # Demo 1: 3D lung nodule spiculation (spic6) & 180-D AHSN swarm
|
|
272
|
+
nexus-lite-demo demo hipaa-pipeline --agent claude # Demo 2: HIPAA Safe Harbor DICOM de-identification role pipeline
|
|
273
|
+
nexus-lite-demo demo multimodal-swarm --agent agy # Demo 3: CT body composition, CHAOS MRI steatosis & PET SUV swarm
|
|
274
|
+
nexus-lite-demo demo lung1-audit --agent claude # Demo 4: NSCLC-Radiomics (Lung1) data-leakage & reproducibility audit
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Practical Medical Imaging & Radiomics Demos (`qradiomics` + `medimage`)
|
|
280
|
+
|
|
281
|
+
`nexus-lite` ships with built-in multi-agent workflows (`nexus_lite.demos`) bridging [`qradiomics`](https://github.com/choilab-jefferson/qradiomics) and the 13-chapter [`medimage`](https://github.com/choilab-jefferson/medimage) Google Colab curriculum, orchestrating live `agy` or `claude` agents (`agent="agy" | "claude" | "auto" | "python"`):
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
import nexus_lite as nl
|
|
285
|
+
from nexus_lite import colab
|
|
286
|
+
from nexus_lite import demos
|
|
287
|
+
from nexus_lite.demos import viz
|
|
288
|
+
|
|
289
|
+
# 1. 3D Pulmonary Nodule Morphology Swarm (Choi 2014 CMPB AHSN + Choi 2021 CMPB spic6)
|
|
290
|
+
d1 = demos.run_phantom_shape_swarm(agent="agy")
|
|
291
|
+
|
|
292
|
+
# 2. HIPAA Safe Harbor DICOM De-Identification Pipeline (driver -> verifier -> refiner, medimage Ch.5)
|
|
293
|
+
d2 = demos.run_hipaa_privacy_pipeline(agent="claude")
|
|
294
|
+
|
|
295
|
+
# 3. Multi-Modality Quantitative Imaging Swarm: CT L3 Body Comp, MRI Steatosis, PET SUV (medimage Ch.6-8)
|
|
296
|
+
d3 = demos.run_multimodal_imaging_swarm(agent="agy")
|
|
297
|
+
|
|
298
|
+
# 4. NSCLC-Radiomics (Lung1) Target-Leakage & Reproducibility Audit Pipeline (medimage Ch.12-13)
|
|
299
|
+
d4 = demos.run_lung1_audit_pipeline()
|
|
300
|
+
|
|
301
|
+
# Render live 2x2 HTML5 multi-agent dashboard
|
|
302
|
+
viz.dashboard()
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Using loom
|
|
308
|
+
|
|
309
|
+
`nexus_lite.loom` wraps the `loom` agent harness as a subprocess (stdlib only). Set `LOOM_BIN` or put `loom` on `PATH`.
|
|
310
|
+
|
|
311
|
+
```python
|
|
312
|
+
from nexus_lite.loom import probe, LoomAdapter
|
|
313
|
+
print(probe().available) # never raises; False if loom is missing
|
|
314
|
+
r = LoomAdapter().run_prompt("Say hello", provider="mock")
|
|
315
|
+
print(r.status, r.ok) # "unavailable" when loom is not installed
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Exit codes map to `ok`, `task_failure` (retryable), `harness_or_policy_error`, `escalation_required`, `budget`, `interrupted`, else `unknown`; `loom capabilities --json` overrides the built-in table. Install is explicit and never implicit (import and `LoomAdapter` never touch the network). Fetch the pinned release (`LOOM_VERSION`, sha256-verified against the release `checksums.txt`; linux/darwin on amd64/arm64) with `nexus-lite loom install [--version V] [--dest PATH]` or `python -c "from nexus_lite import loom; print(loom.install_loom())"`. Default dest is `~/.local/bin/loom`; `LOOM_INSTALL_URL` overrides the release base URL.
|
|
319
|
+
|
|
320
|
+
The loom subprocess gets an env allowlist, not your full environment: `PATH`, `HOME`, `LANG`, `LC_ALL`, `TMPDIR`, `LOOM_*`, and provider keys (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `GOOGLE_API_KEY`, `OPENROUTER_API_KEY`, `OLLAMA_HOST`). Add more with `LoomAdapter(env_passthrough=[...])`.
|
|
321
|
+
`probe().version` reads the `version` capability (None for older binaries). `version_ok` is False below `MIN_LOOM_VERSION` (0.1.0), and `probe()` then emits a warning; unknown or unparseable versions are accepted.
|
|
322
|
+
|
|
323
|
+
## Terminology
|
|
324
|
+
|
|
325
|
+
Words below are lite names; the right column is the matching nexus word. Persisted and wire names (SQL, env vars, pointer-line format, `ALL`, `task_id`, ID formats) are frozen and are not renamed here. nexus is the downstream extension of nexus-lite and shares this vocabulary.
|
|
326
|
+
|
|
327
|
+
| lite word | meaning in lite | nexus word |
|
|
328
|
+
| :-- | :-- | :-- |
|
|
329
|
+
| agent | a CLI coding agent (`agy`, `opencode`, `claude`) or a role label passed as `agent=` | agent |
|
|
330
|
+
| worker | the leaf agent process started by `delegate` | worker / leaf |
|
|
331
|
+
| `delegate` | start a worker on a task | delegate / dispatch |
|
|
332
|
+
| caller | name that receives the completion message of a delegated task | caller (reply-to) |
|
|
333
|
+
| target | recipient of a bus message: an agent name, a PTY session, or `ALL` | recipient (`--to`) |
|
|
334
|
+
| sender | author field of a bus message; a worker uses its `task_id` | sender |
|
|
335
|
+
| `bus send` | write a message and inject a pointer line into live PTYs | say / dm / relay |
|
|
336
|
+
| `ALL` | broadcast to every live session | broadcast |
|
|
337
|
+
| pointer line | `[nexus] <kind> <id> <path> - <summary>` injected into a PTY | pointer line |
|
|
338
|
+
| `TASK_COMPLETE` / `TASK_ESCALATE` | completion channel: message to the caller when a task ends or needs escalation | completion channels |
|
|
339
|
+
| `task_id` | id of one `delegate` run (`t-<uuid8>`) | task |
|
|
340
|
+
| session | one dtach PTY / registry row (never a worker) | session |
|
|
341
|
+
| workspace / `.nexus/` | local directory holding `lite.db`, inbox, stm, wiki | project directory (in nexus, "workspace" means a pod; T1 undecided) |
|
|
342
|
+
| `memory.stm` | live working state (`stm/1` nodes) | STM |
|
|
343
|
+
| `memory.mtm` | flow carried across interruptions; transport is the bus | MTM (MTM+ retired) |
|
|
344
|
+
| `memory.ltm` | markdown wiki, the authoritative durable record | LTM |
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Acknowledgements
|
|
349
|
+
|
|
350
|
+
We gratefully acknowledge **Google** for providing **Gemini 4 Argon** access and support, which powered the multi-agent orchestration, quantitative radiomics synthesis, and automated methodological auditing across `nexus-lite`, [`qradiomics`](https://github.com/choilab-jefferson/qradiomics), and [`medimage`](https://github.com/choilab-jefferson/medimage).
|
|
351
|
+
|
|
352
|
+
*Computational Healthcare & Oncology Informatics (CHOI) Lab, Department of Radiation Oncology, Sidney Kimmel Medical College at Thomas Jefferson University* · MIT License
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
## Releasing
|
|
356
|
+
|
|
357
|
+
Releases are squash-commit snapshots (one per release, history kept) pushed to GitHub by a maintainer; see [docs/RELEASE.md](docs/RELEASE.md).
|
|
358
|
+
|
|
359
|
+
## loom multi-agent on Colab
|
|
360
|
+
|
|
361
|
+
`notebooks/loom_multi_agent_colab.ipynb` (or `python -m nexus_lite.demos.loom_multi_agent`) installs loom from a checksum-verified release (source-build fallback) and builds four tricky modules with an orchestrator/worker/reviewer team scored by hidden tests, next to a single-agent baseline (`--json-out`, `--runs`, `--inject-bad-key`, `--inject-timeout`). Keys come only from Colab Secrets (`ANTHROPIC_API_KEY`, `GEMINI_API_KEY`); with none set it uses the offline `mock` provider.
|
|
362
|
+
|
|
363
|
+
### Radiomics loom examples
|
|
364
|
+
|
|
365
|
+
Same orchestrator/worker/reviewer framework, pluggable tasks (`--task NAME[,NAME...]|all`, default `basic`). Each radiomics task has 3-4 flat stdlib-only modules scored by hidden tests (never put in a prompt); images are nested lists, masks 0/1 lists.
|
|
366
|
+
|
|
367
|
+
| task | modules |
|
|
368
|
+
|------|---------|
|
|
369
|
+
| `radiomics-firstorder` | discretise, roi, moments, distribution (bins, ROI + re-segmentation, mean/variance/skew/kurtosis/energy/entropy/rMAD) |
|
|
370
|
+
| `radiomics-texture` | glcm, glcm_features, glrlm, glrlm_features |
|
|
371
|
+
| `radiomics-stats` | icc (ICC 3,1), fdr (BH q-values), standardise (train-only z-score), cindex (Harrell C) |
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
python examples/loom_radiomics.py --providers mock # all three, offline scripted
|
|
375
|
+
python examples/loom_radiomics.py --task radiomics-stats --providers anthropic,gemini --json-out out.json
|
|
376
|
+
python -m nexus_lite.demos.loom_multi_agent --task radiomics-texture --providers mock
|
|
377
|
+
```
|