← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / openai4s / cli / README.md

Command-line interface

中文说明

The openai4s command lives here: daemon lifecycle (serve, status, stop, url), one-shot local task execution (run), first-run model configuration (init), scientific environment creation (setup) and the transactional env generations beside it, the support surfaces (doctor, diagnostics, verify-package), the workflow benchmark, read-only session sharing (share) with the public relay that fronts it, batch-job submission (cluster), team-mode account administration (user), and the optional Jupyter adapter commands. -V/--version answers with the package version.

Where this fits

The CLI composes; it does not orchestrate. openai4s run builds the local outer loop out of ../agent/, and a persistent kernel only starts if a turn actually routes a code cell. openai4s serve hands off to the HTTP/WebSocket server. The setup and status commands run outside any agent turn.

One argparse tree covers three kinds of command, and the difference decides what a failure means. run, init, setup, env, doctor, diagnostics, verify-package, benchmark, user and the Jupyter commands do their work in this process — user writes accounts through the store directly, because the operator who needs to bootstrap or disable one is often the operator whose daemon is down. serve becomes the daemon. share and cluster are REST clients of a daemon that must already be running, so they fail on a missing daemon or a missing credential before they ever reach the feature; cluster is daemon-facing deliberately, since a submission has to reach the reconciler that will act on it, and a second process writing workload rows behind the daemon's back is how two reconcilers end up disagreeing about one job.

Files

File Responsibility
__init__.py Re-exports main, so the package itself is the CLI entry point.
main.py One argparse tree plus its handlers. In-process: run, init, setup, env (plan/apply/list/rollback/recover), doctor, diagnostics, verify-package, benchmark, user (add/list/disable/reset-password, direct against the store; --password-stdin or a generated password printed exactly once, and disabling an account also clears its stored LLM keys), and jupyter describe/export/install. Daemon-facing: serve (with --detached to background it on Linux/macOS, including WSL2), status, stop, url, the eight share subcommands, and cluster (submit/list/cancel/logs/profiles against the daemon's orchestration routes); relay serve / relay gen-token run the public share relay on a VPS rather than on this machine. It also owns the daemon pidfile and statefile, and drives conda when building environments — setup --profile standard for the everyday Python and R pair, full for all four, or --only <name> for one. An existing environment is left alone unless --update says otherwise, an update never prunes what you installed yourself, and it names the prefix discovery actually found rather than the spec's name: — conda resolves a bare name against its own root, so the alternative is a second environment built somewhere the agent never runs, reported as success.

Operational contract