Skip to main content

Module launcher

Module launcher 

Source
Expand description

The launcher: pair, the tab wrappers, the terminal walk, install-launcher and the pure Windows resolvers (spec “Launcher”), and resume and attach (Task 19), which reuse claim_file, write_wrapper, controller_env and LauncherCtx::before_claim.

Re-exports§

pub use posix::quote_sh;
pub use posix::select_terminal;
pub use posix::system_parent_chain;
pub use posix::tab_command;
pub use posix::wrapper_script_posix;
pub use posix::Terminal;
pub use posix::BOOT_ID_EXPR_POSIX;
pub use posix::STARTTIME_EXPR_POSIX;
pub use windows::cmd_line;
pub use windows::cmd_wrap;
pub use windows::controller_command;
pub use windows::controller_process;
pub use windows::quote_ps;
pub use windows::resolve_executable;
pub use windows::select_windows_shell;
pub use windows::strip_verbatim;
pub use windows::wrapper_script_ps1;
pub use windows::wt_directory_arg;
pub use windows::WindowsShell;

Modules§

posix
The POSIX tab wrapper, the shell expressions it embeds, and the terminal walk and tab commands.
windows
Windows rules that are pure text and path logic, compiled on every platform so the Linux and macOS legs test them: the verbatim-prefix strip, the wt directory argument, PATHEXT resolution, the cmd.exe /c wrap and the .ps1 wrapper.

Structs§

CaptureTransport 🔒
A transport that records the body of the one session.create call, so the dry run shows exactly what Engine::session_create (policy, model, lock rules and all) would send.
LauncherCtx
LockGuard 🔒
Deletes the resume-lock it was handed on drop, whatever way resume ends.
PairArgs
Staged 🔒
WrapperInput

Enums§

WrapperKind

Constants§

EXIT_NOTICE
The notice posted into the worker session when the controller exits (spec Launcher step 5).
NOT_OFFERED
What pair, resume, attach and install-launcher print on the OpenCode host.

Functions§

announce_tab 🔒
attach
attach <session-id | pair-id>.
attach_pair 🔒
attach_pair_run 🔒
attach_session 🔒
bind_controller 🔒
claude-pid from the child’s pid, boot id and start time.
check_pair_id 🔒
conflict 🔒
controller_env
Spec step 5’s environment, shared with resume. OPENCODE_CTL_SERVER is the EMPTY string when there is no server_url (never omitted: Command inherits the parent environment, and a stale value would point the controller at another server; empty = the background service).
controller_missing 🔒
controller_unavailable 🔒
create_args 🔒
delete_older_generations 🔒
pair.<id>.g<k>.* for every k < n: the tabs of older generations.
dry_create_body 🔒
dry_run 🔒
ensure_bin_dir 🔒
install_launcher
install_launcher_as
install-launcher [--force] for a platform flag (so the Windows copy rules run on every leg).
install_windows_copy 🔒
Windows: an in-use copy is first renamed to .old (which gc deletes), then the running exe is copied over and the .source file written.
invalid 🔒
is_missing_program 🔒
launcher_guard 🔒
live_controller 🔒
mint_pair_id 🔒
open_pair_log 🔒
<home>/logs/pair-<id>.log, scoped to this thread; a failed open is a stderr warning (plan decision 10) and the run continues.
open_tab 🔒
Spec step 4’s last action: the wrapper in a new tab of t; returns the tab process’s pid.
opencode_missing 🔒
pair
pair: spec Launcher steps 1-5. The order at the top is: mint the id, validate, OPENCODE_NOT_FOUND when there is no binary, open the log, then step 1; --dry-run writes, spawns and calls nothing.
pair_file 🔒
parse_attach_args
attach <session-id | pair-id> -> the target.
parse_pair_args
pair [directory] [--model m] [--title t] [--controller c] [--no-tab] [--dry-run] [-- <controller args>].
parse_resume_args
resume <pair-id> [--controller c] [-- <controller args>] -> (pair id, controller, args).
pick_controller 🔒
--controller, else the record’s, else the host constant (an attach record has None).
post_exit_notice 🔒
session.synthetic {text, resume: false} with no client id; one retry with the same body on the id-collision conflict. Failure is logged, never fatal.
print_closing 🔒
remove_if_present 🔒
replace_with_symlink 🔒
resolve_controller 🔒
resolve_directory 🔒
resume
resume <pair-id> with the record’s (else the host’s) controller.
resume_run 🔒
resume_with
resume with an explicit --controller (which wins over the record and the host constant).
rollback 🔒
Remove what a failed step 3 or 4 left: the session, then every pair.<id>.* file.
run 🔒
same_bytes 🔒
say 🔒
stage 🔒
Steps 3 and 4: the terminal, the record (once), the wrapper and the tab. A failure is returned for the caller to roll back.
stage_attached 🔒
The new record (controller: null, generation 1, tab from the terminal walk), then the wrapper, then the tab.
step5 🔒
Step 5: the controller, as a child with inherited stdio. Shared with resume, which passes the resume-lock it holds: deleted once claude-pid is written.
system_path_has
name (or name.exe, .cmd, .bat on Windows) found as a file in a directory of PATH.
system_spawn_and_wait
The controller: spawn with inherited stdio, hand the pid to on_pid, wait.
system_spawn_detached
The terminal tab: spawned and left to run; the child is reaped on a thread so it never lingers as a zombie of this long-lived process.
tab_argv_command 🔒
tab_plan 🔒
utc_hhmm 🔒
validate_launch_values
“Values that reach a shell” (spec Launcher): ids match their patterns, a newline is refused everywhere, ; in the directory on Windows (wt splits its command line on it), and on Windows a controller argument with a cmd.exe metacharacter. Nothing is written before this passes.
wrapper_path
wrapper_text 🔒
write_wrapper
The ONE wrapper writer: claim_file(path, bytes, 0o700), with U+FEFF prepended for a .ps1 (powershell.exe 5.1 decodes a BOM-less script as the ANSI code page). Ok(false): it exists.

Type Aliases§

SpawnAndWaitFn
dyn Fn(&mut Command, &mut dyn FnMut(u32)) -> io::Result<ExitStatus>.