Metadata-Version: 2.5
Name: knowop
Version: 0.1.7
Summary: Log in to KnowOp, connect your computer, and run your agents and GPU jobs where Chat can reach them.
Project-URL: Homepage, https://www.rekursiv.ai
Project-URL: Repository, https://github.com/rekursiv-ai/knowop
Project-URL: Source, https://github.com/rekursiv-ai/knowop
Project-URL: Issues, https://github.com/rekursiv-ai/knowop/issues
Project-URL: Changelog, https://github.com/rekursiv-ai/knowop/releases
Author-email: "rekursiv.ai" <hello@rekursiv.ai>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: agents,cli,sagent,terminal
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Requires-Dist: aiortc>=1.15.0
Requires-Dist: pydantic>=2.14.2
Requires-Dist: pyobjc-framework-cocoa>=13.0; sys_platform == 'darwin'
Requires-Dist: sagent>=0.2.3
Requires-Dist: trackinizer>=0.1.12
Requires-Dist: treekle>=0.4.1
Requires-Dist: websockets>=17.4
Requires-Dist: wrapt>=2.5.2
Provides-Extra: cpu
Requires-Dist: torch; extra == 'cpu'
Requires-Dist: torchao; extra == 'cpu'
Requires-Dist: torchvision; extra == 'cpu'
Provides-Extra: cu126
Requires-Dist: torch; extra == 'cu126'
Requires-Dist: torchao; extra == 'cu126'
Requires-Dist: torchvision; extra == 'cu126'
Provides-Extra: cu128
Requires-Dist: torch; extra == 'cu128'
Requires-Dist: torchao; extra == 'cu128'
Requires-Dist: torchvision; extra == 'cu128'
Provides-Extra: cu130
Requires-Dist: torch; extra == 'cu130'
Requires-Dist: torchao; extra == 'cu130'
Requires-Dist: torchvision; extra == 'cu130'
Provides-Extra: cu132
Requires-Dist: torch; extra == 'cu132'
Requires-Dist: torchao; extra == 'cu132'
Requires-Dist: torchvision; extra == 'cu132'
Provides-Extra: cu134
Requires-Dist: torch; extra == 'cu134'
Requires-Dist: torchao; extra == 'cu134'
Requires-Dist: torchvision; extra == 'cu134'
Description-Content-Type: text/markdown

# knowop🔌

[![PyPI version](https://img.shields.io/pypi/v/knowop.svg)](https://pypi.org/project/knowop/)
[![CI](https://github.com/rekursiv-ai/knowop/actions/workflows/package-validation.yml/badge.svg?branch=main)](https://github.com/rekursiv-ai/knowop/actions/workflows/package-validation.yml)
[![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
[![Discord](https://img.shields.io/discord/1530237005311639592?logo=discord&logoColor=white&label=Discord&color=5865F2)](https://discord.gg/2GZFPPvCqn)

One command to log in to KnowOp, connect your computer, and run your agents and GPU
jobs where Chat can reach them.

## Quick Start

```bash
uvx knowop@latest connect
```

See [Install](#install) for additional details.

## Use

```bash
knowop connect          # this computer: log in, enroll, serve it in the background
knowop logs -f          # follow this computer's connect
knowop run              # sagent in this folder, live in Chat
knowop run --headless -- --effort high   # no screen: this computer's connect runs it
knowop run --on lab-box # sagent on your computer lab-box, through its connect
knowop run -- login --provider oaisub    # sagent's sign-in, on this computer
knowop job submit -- python train.py   # a job on a GPU node, from this repository
knowop job submit --host lab-box -- python train.py   # on your computer lab-box
knowop upload ~/.claude # your finished Claude Code sessions, sub-agents and all
knowop status           # server, account, your hosts, their runs, this computer's services
knowop disconnect       # disconnect this computer and stop its agent processes
```

A run at a terminal reaches Chat with your account's key, not through `knowop
connect`, and Chat's Stop halts its turn. A run Chat or `knowop run --on` starts on a
host is started by that host's connect, and keeps running when the connect stops.
`knowop disconnect` revokes a host's connect and stops every agent process on it: those
its connect started, and those started at a terminal there.

A job can also run on a computer of your own: start it with `knowop connect --jobs`
there, push your branch, and `knowop job submit --host NAME -- CMD` from the
repository. That computer fetches the pushed commit into a fresh worktree and runs CMD
under a memory cap (a `systemd-run --user` scope), only for your account; its log and
results come back through the server, which keeps none of them.

A job runs with the full authority of the Unix user running `knowop connect --jobs`,
including access to that user's files, credentials and inherited environment. The
worktree and memory cap do not restrict that authority. GPU selection through
`CUDA_VISIBLE_DEVICES` is cooperative: submitted code can change it. Run untrusted
code under a separate Unix identity or external isolation that enforces the access
restrictions you need.

`knowop connect` prints a code; approve it in your browser, on any device. That one
approval logs you in, enrolls this computer and confirms it. The computer's terminal
then opens in the web app, its files can be browsed there (read-only, as you), and
it serves sagent's tools (the shell and your files, as you) to the server's
assistant; `--no-exec` serves the terminal and files only. A published install
has no tools to serve until sagent's host code ships in its wheel: `knowop
connect` then says so and reports none. `knowop connect acme` does the same on
`https://acme.knowop.ai`. A computer with no browser, such as a box, pipes an
enrollment token to `knowop connect` instead, and joins with no login.

At a terminal, `knowop connect` joins in the foreground, so a refusal shows there,
then keeps serving from a user service: a launchd agent in `~/Library/LaunchAgents`
on macOS, a `systemd --user` unit on Linux. It runs in the background, starts again
at login and after a crash, and returns once the server shows the computer online.
`knowop logs -f` follows its log, `knowop status` lists it with its flags, and
`knowop disconnect` stops and removes it. Running `knowop connect` again restarts it
only when its flags, its environment or its knowop changed; from a checkout, its
knowop is the checkout's commit, so a `git pull` counts. The
service runs the knowop that installed it: an installed one in place, so after `uv
tool upgrade knowop` run `knowop connect` again, and one `uvx` ran as `uvx
knowop@VERSION`, which `uv cache clean` cannot take away; `uvx knowop@latest
connect` moves it to the latest. It keeps your shell's `PATH`, `LANG`, `LC_*`
(except `LC_TRAX*`), `SAGENT_PROVIDER` and `SAGENT_ALLOW_PROVIDERS`, plus the
variables your per-user folders are read from (`HOME`, `XDG_*_HOME`), so it finds
your CLIs and your login as your shell does and selects sagent providers the same
way. It holds no secret: it reads the
host credential saved for your user each time it starts. It is never installed
as root. Over ssh on Linux, `sudo
loginctl enable-linger $USER` keeps it running after you log out; knowop says so.
Anywhere else, such as a pipe, a box or a service of your own, and with
`--foreground`, `knowop connect` serves in the foreground until Ctrl-C.

On macOS, `knowop connect` also shows the knowop mark in the menu bar: dimmed while
a connect service here is not online, with a menu of each server you are logged in
to, your hosts and their runs. It runs as one more launchd agent,
`ai.rekursiv.knowop.menubar`, and goes with the last connect service. Quit stops
every connect service here, then the menu bar, until the next login or `knowop
connect`; their hosts read offline meanwhile. It needs PyObjC, which installs with
knowop on macOS; where this knowop's Python cannot import it (a checkout not synced
since), `knowop connect` says so and installs no menu bar. `knowop status` says
whether it runs, and why it fails when it does.

System Settings > General > Login Items & Extensions lists the two background items
as "knowop" (a connect service) and "knowop menu bar", each with the knowop icon:
each launchd agent runs a small launcher of that name, in knowop's folder of the
user's data (`~/Library/Application Support/rekursiv-ai/knowop/launchers`), which
runs this knowop. They go with the last connect service.

Plain `knowop login` logs in to `https://alpha.knowop.ai`; `knowop login acme` to
`https://acme.knowop.ai`, and `knowop login URL` to any server. Use it on a computer
you will not connect, where only your agents work. A later `knowop connect` there
enrolls the computer with that login's key, and it waits until you confirm it in the
web app. A first `knowop run` logs in too.

## Install

`uvx knowop@latest connect` runs the latest knowop without installing it. To keep
the command for every day, install it:

```bash
uv tool install knowop && knowop connect
# Later: uv tool upgrade knowop
```

If you're missing `uvx`/`uv`,
- Mac
  ```bash
  brew install uv
  ```
- Linux
  ```bash
  sudo apt install -y curl
  curl -LsSf https://astral.sh/uv/install.sh | sh
  ```

Or with pip,
```bash
python -m pip install knowop
```

## In Docker

A container has no service manager: `knowop connect --foreground` serves it, and
Docker starts it again. A volume on `/root` keeps its login, the host credential
and uv's cache, so a new container joins again with no login:

```bash
docker run -d --name knowop --restart unless-stopped -v knowop:/root \
  ghcr.io/astral-sh/uv:python3.12-bookworm-slim \
  uvx knowop@latest connect --foreground --name my-box
docker logs -f knowop   # approve the code it prints, then Ctrl-C
```

Its terminals open a shell in the container, as root, and its agents and jobs run
there: start from an image that has the tools they need (`git`, at least).
Docker starts it again after a disconnect from the web app; `docker stop knowop`
keeps it stopped.

## As a systemd system service

`knowop connect` at a terminal installs a user service, which stops when you log
out unless lingering is on. To serve a Linux server with no one logged in, run it
from a system unit as your own user instead. Connect once in the foreground, which
logs in and enrolls this computer, then install the unit:

```bash
uv tool install knowop
knowop connect --foreground   # approve the code; once it is serving, Ctrl-C
sudo tee /etc/systemd/system/knowop-connect.service > /dev/null << EOF
[Unit]
Description=knowop connect
Wants=network-online.target
After=network-online.target

[Service]
User=$USER
Environment=PATH=$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=$HOME/.local/bin/knowop connect --foreground
Restart=on-failure
RestartSec=5
# knowop ends as Ctrl-C does on the SIGTERM that stops it.
SuccessExitStatus=130

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now knowop-connect
journalctl -u knowop-connect -f
```

`PATH` names where the tools your agents and jobs call are. `knowop status` shows the
host, not the unit, and `knowop logs` reads only a user service's log: use
`journalctl`. `sudo systemctl disable --now knowop-connect` stops it.

## Commands

| Command | Does |
|---|---|
| `knowop login [ORG\|URL]` | Logs in with a code approved in a browser and saves the key. |
| `knowop connect [ORG\|URL] [--name N] [--no-exec] [--sandbox] [--jobs [--job-results-max SIZE]] [--foreground] [--follow]` | Logs in first unless knowop is logged in to that server or a token is piped in, enrolling and confirming this computer in the same approval; then serves its terminal, and the assistant's commands unless `--no-exec`. At a terminal it serves from a user service that starts again at login, and `--follow` then follows its log; elsewhere, and with `--foreground`, until Ctrl-C. No server means knowop's own, else `https://alpha.knowop.ai`. `--sandbox` records that the computer is disposable. `--jobs` also runs your account's `knowop job submit --host` jobs, each under a memory cap; it needs systemd's user manager. |
| `knowop menubar` | Shows the knowop mark in the macOS menu bar until Quit, which stops this computer's connect services too; `knowop connect` starts it at login. |
| `knowop logs [NAME] [-f] [-n N]` | Prints the log of NAME's connect service on this computer (default this computer's name), its last N lines, or follows it until Ctrl-C. A host connected from another computer keeps its log there. |
| `knowop status [--json]` | Prints, for each server knowop is logged in to (the one its commands use first), the profile, the server, your account and role, your computers with whether each is online, the knowop version and process serving each one online, and the agent processes live on each; and this computer's connect services with their flags, and whether each is turned off (macOS Login Items). On macOS, the menu bar: running, stopped, or failing with its exit code and its last log line. `--json` prints the same as one JSON object, one entry per login. Exits 1 when not logged in, or when a server refuses its login's key. |
| `knowop disconnect [NAME]` | Disconnects NAME (default this computer) on the server: its connect is revoked and every agent process on it stops. Removes NAME's connect service on this computer, and waits until the server shows NAME offline. `knowop connect` joins it again with no login. |
| `knowop logout [NAME\|--all]` | Logs this computer's host out on the server (its connect revoked, its agent processes stopped, the keys its logins made revoked), revokes knowop's key if that left it, removes this computer's connect services of that server, and deletes the saved login; knowop then uses its login to another server, if it has one, and says which. `--all` logs every host of yours out first. NAME logs that one host out alone, as the Hosts page does, and keeps this computer's login. |
| `knowop run [--headless] [--session ID] [--on NAME] [--cwd DIR] [--time TIME] [-- SAGENT ARGUMENTS]` | Runs sagent's own agent, live in Chat: with sagent's screen in this process at a terminal; with none (`--headless`, or no terminal) through this computer's connect, which it starts first when it is not running, returning with the session's id while the agent runs on. The session opens in Chat as one started there does, and Chat names where its agent runs. `--session` continues a stored session, by its UUID or number (`AgentSession#412`), which Chat's ⋯ menu copies; `--on` starts the agent on host NAME through its connect. Everything after `--` is sagent's: its settings as flags, or an action (`-- login --provider oaisub`, `-- mcp list`, `-- --help`), which runs on this computer and opens no session. A sagent flag before `--` is refused with the command that puts it after; a mistyped command opens no session. Says to run `knowop connect` when this computer is not connected. |
| `knowop job submit\|logs\|results ...` | Runs a job on a GPU node from this repository, or with `--host NAME` on a computer of yours, and reads its log and results. |
| `knowop job status [JOB]\|cancel JOB\|secrets\|secret NAME set\|del` | Lists your jobs or shows one, stops one, and keeps the secrets a job may use. |
| `knowop host [NAME ...]` | Lists, shows, sets, labels and deletes the hosts campaigns may run on, then lists your KnowHosts. |
| `knowop host start\|NAME pause\|NAME resume\|NAME del` | Rents a KnowHost, billed to your account, that joins as one of your hosts; it pauses after 30 minutes unused, `resume` wakes it, and `del` ends it. On a server that runs KnowHost. |
| `knowop canvas [CANVAS_UUID] [show TYPE\|navigate ROUTE\|highlight UUID,...\|hide ID\|KEY to VALUE ...]` | Reads and changes a canvas with the grammar of `trax canvas`. Where `$TRAX_CANVAS` names a canvas, an agent drives the person's canvas with knowop alone. |
| `knowop watch-pr add\|remove\|fix URL [--session S]` | Watches a GitHub pull request for session S (default `$TRAX_SESSION`), lets S go of it, or makes S the one agent that fixes it. `add` starts this host's serve when none runs. |
| `knowop watch-pr status [URL]\|serve [--detach]\|stop` | Lists the watched pull requests and who watches, fixes and last read each; reads every one each minute through this host's `gh`, writing what GitHub says to its row and telling each watching agent the news; stops this host's serve. |
| `knowop session` | Prints the session `$TRAX_SESSION` names, which `knowop run` sets for its agent's tools: its number and its UUID. |
| `knowop upload PATH... [--public] [--server ORG\|URL] [--format claude\|codex\|sagent] [--no-subagents] [--jobs N] [--dry-run]` | Sends finished Claude Code, Codex and sagent sessions, files or folders searched for them (`~/.claude`, `~/.codex/sessions`, sagent's projects, or a copy of any; Codex's compressed `.jsonl.zst` rollouts too), each as an AgentSession under the CLI's own id, started and ended when it was. Each sub-agent, a workflow's agents included, goes as an AgentSession of its own, in its spawner's audience, linked to it (`produced_by`). A new session is private unless `--public`; uploading again sends only the records the server lacks, and lands on the same AgentSession when the same login sends it. A session the server holds keeps the audience it has, whichever flag is given. `--server` uses knowop's saved login for that server; `--dry-run` lists what would go and contacts no server. Records are masked as a run's are (`TRAX_REDACT_NAMES`). Exits 1 when a session fails. |
| `knowop --version` | Prints the version; from a checkout, its commit. |

Every command takes `--help`; `knowop run --help` and `knowop job submit --help`
show the runner's own, and `knowop run -- --help` shows sagent's.

knowop keeps a login per server it logs in or connects to, and every command uses
the last one; `knowop status` shows each. A connect service signs in with its own
server's login, so this computer can serve `alpha` and another server at once. Each
key is saved as a `trax` profile, and `trax`'s own current profile stays as it was:
knowop never acts on a server it did not log in to.

## Direct terminal link

Every install includes aiortc for a direct link between the browser and this
computer. Terminals use the server relay when a direct link is unavailable.

## Layout

| Package | Holds |
|---|---|
| `cli.py` | The `knowop` command. |
| `service.py` | The user service `knowop connect` installs: launchd's or systemd's. |
| `connect/` | The daemon `knowop connect` runs: terminals, sagent's tools for the assistant, the agent processes the server asks for (`session_serving.py`), and with `--jobs` your jobs (`job_serving.py`). |
| `process/` | The agent process `knowop run` runs: sagent in-process, live in Chat. |
| `agent/` | What the agent process needs to continue a stored session here. |
| `jobs/` | The job runner `knowop job` hands to. |
| `watch_pr/` | `knowop watch-pr`: pull request rows, their news, and the serve that reads them through `gh`. |
| `hosts.py` | `knowop host`: the host registry, and KnowHosts through the server's KnowHost API. |
| `canvas.py` | `knowop canvas`: trax's canvas command, named as knowop's. |
| `tools/` | The tools every agent of `knowop run` is given, plain functions over the client: the canvas's (`tools/canvas.py`), hosts, sessions and record reads (`tools/knowop.py`, whose `trax.read` action runs `tools/records.py`). |
| `upload.py` | `knowop upload`: finds session files and sends each as an AgentSession. |
| `skills/` | Each package's instructions for agents. |

knowop calls the server through trackinizer's `Client`, as trax does, and never
starts a `trax` process. KnowOp's `trax.read` action runs an agent's trax read commands
inside the agent's own process (`trax.invoke`), reads only, under the agent's key.
sagent's `Recall` tool searches the same server near the run's own session, under
the same key: the process hands the tool both, so the key is in no environment a
command of the agent inherits. A server a person names (`--tool.Recall.url`) is
sent no key.
The agent is told whose session it is, as the server names them for the run's key:
at a terminal, the key's person (`/api/me/profile`); with no screen, the account the
session is held for. A line from Chat that person wrote reads as theirs, with no
label; anyone else's names its author. A server that does not say leaves the agent
told no name.
`trax host` and `trax job` say they moved out of trax.

## Development

```bash
uv sync --all-groups
uv run pytest
```

## See also

Sibling projects in the [rekursiv-ai](https://github.com/rekursiv-ai) family:

- [trackinizer](https://github.com/rekursiv-ai/trackinizer) — Centralized agent database for tracking inquiries, work, and the evidence behind conclusions; knowop's `trax` and its client come from it.
- [sagent](https://github.com/rekursiv-ai/sagent) — The self-mutating multi-provider coding-agent CLI and typed Python library.
- [wesearch](https://github.com/rekursiv-ai/wesearch) — Web search, resilient page fetch, and scholarly-paper lookup without a browser stack.
