Cotal TypeScript packages
    Preparing search index...

    Function selfArgv

    • This CLI's own invocation as argv: [node, ...loaderFlags, entryScript]. The loader flags carry tsx in dev (so a re-exec can run the .ts entry) and are empty in prod (entry = compiled JS). A daemon is started from daemonArgv instead. Re-execed children (web, manager) and cmux pane commands use this so they never depend on cotal being on PATH — works the same via npx, npm i -g, and a dev clone.

      A RE-EXEC IS ONLY VALID FROM THE CLI'S OWN ENTRY, and that is checked here rather than at each spawn site. Every caller appends a cotal subcommand (supervise, deliver, ext add) to this argv and detaches the child, so the entry has to be the file that READS a subcommand. Started from anything else the child re-runs THAT file with an argument it ignores, and a file that reaches this on load spawns its own successor.

      #1629 measured that: a smoke fixture calling ensureControlPlane under tsx had process.argv[1] pointing at the suite, so the detached "manager" was the suite, which ran to the same call and spawned the next generation. 970 generations in 4.7 hours on a persistent host, each holding a nats-server and a delivery holder, until the chain was killed by pid. The guard cannot live in the smoke harness: startManagerDetached unrefs its child on purpose, so nothing that owns the suite's children can own it. It is a THROW rather than a skipped spawn, because a re-exec that silently does not happen reports a healthy control plane over nothing.

      Returns string[]