/** * Finding the harness launcher, the same four ways `bin/dshline.mjs` does. * * `/profiles` mutations shell out to `dsh plugin` (see `profiles/actions.ts` * for why that is the mechanism), so they have to reach the launcher in every * environment this frontend itself starts in. A PATH lookup alone does not: * a person who set `DSH_BIN`, or who runs against a source checkout through * `DSH_HARNESS`, has a working `dshline` and would have had a `/profiles` that * could not install anything. * * The order is the wrapper's, and it is the order that respects what the user * has already decided: * * ``` * DSH_BIN an explicit launcher path * DSH_HARNESS a source checkout, run through its own `dsh` script * dsh on PATH the ordinary global install * @deepseek-ai/dsh resolved from this package, run through this Node * ``` * * `bin/dshline.mjs` keeps its own copy of this policy and must: it is the * package's executable, it runs before anything is built, and giving it an * import from `lib/` would make the primary entry point fail in a source * checkout that has not run `pnpm build`. The duplication is therefore * deliberate and guarded rather than accidental — * `tests/launcher-policy.spec.ts` reads the wrapper and asserts both honour * the same mechanisms in the same order, so the two cannot drift in silence. * Behaviour that belongs to only one of them (the wrapper's `--setup`, its * first-run profile bootstrap, its `stdio: 'inherit'` hand-off) stays where it * is. * @module dshline/launcher */ /** The harness's launcher package, resolved when no `dsh` is on PATH. */ export declare const LAUNCHER_PACKAGE = "@deepseek-ai/dsh"; /** How to run the launcher: a command, arguments that must precede ours, and where from. */ export interface Launcher { /** The executable to spawn. */ readonly command: string; /** Arguments that must come before the ones a caller passes. */ readonly prefix: readonly string[]; /** * The working directory the launcher must run from, when it has one. * * A source checkout's launcher is a relative path inside it and its loader * resolves from there too, so that launcher only runs with the checkout as * the working directory. */ readonly cwd?: string; /** How to name this launcher in a diagnostic. */ readonly describe: string; /** * Which mechanism produced this launcher. * * Not how it is run — what a prerequisite failure should say. A checkout declares * its own pnpm in `packageManager`, so the remedy that keeps that version is * corepack; a package install has no such declaration and gets the global one. */ readonly origin: 'package' | 'checkout'; } /** What resolution found: a launcher, a misconfiguration, or nothing. */ export type LauncherResolution = /** A usable launcher. */ { readonly kind: 'found'; readonly launcher: Launcher; } /** * The user pointed at a launcher that is not there. Distinct from `'none'` * because the answer is different: a wrong `DSH_BIN` is a sentence about the * value they set, not an invitation to install anything. */ | { readonly kind: 'misconfigured'; readonly message: string; } /** No launcher could be found by any mechanism. */ | { readonly kind: 'none'; }; /** * Where a command is on PATH. * * Looked up rather than probed by running it: running `dsh --version` to find * out whether `dsh` exists would put a whole Node startup in front of an * answer the filesystem already has. The Windows extensions are tried because * a launcher installed by npm there is a `.cmd` shim rather than the name — * and the path is returned rather than a yes, because on Windows that shim is * the file that has to run: a bare `dsh` names nothing there, so spawning it * fails with ENOENT beside a launcher that is installed and working. * @param name - the command to look for. * @param env - the environment to read PATH from. * @returns the path of the first match, or undefined when there is none. */ export declare function onPath(name: string, env: NodeJS.ProcessEnv): string | undefined; /** * Split a manifest's `dsh` command line into a program and its arguments. * * Quote-aware, because a command line is what a shell would read and a program path * may legally contain a space. The case that needs it is Windows: Node lives under * `C:\Program Files\nodejs` on a default install, so a checkout naming its * interpreter in full — `"C:\Program Files\nodejs\node.exe" apps/cli.ts` — was split * into `C:\Program` and `Files\nodejs\node.exe`, and every launch failed with ENOENT * beside a checkout that worked from a shell. * * Kept identical to `bin/dshline.mjs`'s copy, for the reason the rest of this module * is duplicated: both have to run before anything is built, and a checkout that * launches from the wrapper must behave the same when a `/profiles` mutation reaches * the harness through it. * * Not a shell parser and deliberately not one: no expansion, no escapes, no * redirection. A value needing those is a value this cannot honour, and the * alternative — handing it to a shell — is what this project never does. * @param line - the command line, as a manifest wrote it. * @returns the program and its arguments, in order. */ export declare function splitCommandLine(line: string): string[]; /** * Find the harness launcher. * @param env - the environment to read; defaults to this process's. * @param anchor - module URL for the package fallback; defaults to this module. * @returns the resolution. */ export declare function resolveLauncher(env?: NodeJS.ProcessEnv, anchor?: string): LauncherResolution; //# sourceMappingURL=launcher.d.ts.map