import { type LocalRunner, type AgentDefinition, type NetworkEgressSetting } from "./config.ts"; export { shellSingleQuote } from "./shell.ts"; /** * Return a copy of `definition` whose `cmd` has the agent's `resumeArgs` * appended, so `crew resume` relaunches the agent into its previous * conversation (e.g. `--continue` for Claude, `resume --last` for Codex). * Appending after the base `cmd` keeps the first token — which * `inferAgentCommandName` reads for the safehouse profile — and the trailing * `"$_p"` prompt positional the launch builders add both intact. */ export declare function withResumeArgs(definition: AgentDefinition, resumeArgs: string): AgentDefinition; /** * Resolve the shipped Safehouse proxy wrapper inside `@clipboard-health/clearance` * via Node's module-resolution algorithm so the path works whether npm hoists * clearance as a sibling of groundcrew or nests it under * `groundcrew/node_modules/@clipboard-health/clearance`. * * @param baseUrl - **Test-only seam.** Production callers must omit this so the * helper resolves from this module's URL. Tests pass an invalid value to * exercise the catch branch. */ export declare function resolveSafehouseClearancePath(baseUrl?: string): string; export declare function isEnvironmentAssignment(token: string): boolean; /** * Infer the agent's command basename from a agent `cmd` (skipping a leading * `env`/`KEY=val` prefix). Safehouse uses it to pick the matching `.sb` * profile. */ export declare function inferAgentCommandName(agentCmd: string): string; export type WorkerEnvironment = Readonly<{ GROUNDCREW_TASK_ID: string; GROUNDCREW_COMPLETE?: string; }>; export declare function workerEnvironmentForTask(arguments_: { taskId: string; markDoneSupported: boolean; }): WorkerEnvironment; export interface SafehouseAgentIntegration { addDirsReadOnly: readonly string[]; envPass: readonly string[]; commandPreludes: readonly string[]; /** * Extra, already-shell-safe argv tokens appended to the agent invocation * before the prompt positional (e.g. `--settings ` to inject * cmux activity-reporting hooks for a Claude agent). */ agentArgs?: readonly string[]; /** * Extra **writable** safehouse `--add-dirs` paths contributed by the * integration (e.g. codex's relocated `CODEX_HOME` under safehouse, which * the agent must read AND write session/state into — unlike * `addDirsReadOnly`). Merged into the agent wrap's `--add-dirs` alongside * `safehouseAgentAddDirs`; never granted to the repo-controlled * prepareWorktree wrap. */ addDirs?: readonly string[]; /** * Files copied from their staged sandbox location back to the source store * by the host after the agent exits. This keeps credential refreshes without * granting the sandbox write access to the source config home. */ writeBackFiles?: readonly SafehouseAgentWriteBack[]; /** * Extra paths torn down (`rm -rf`) once the agent wrap exits — success or * failure — folded into the same EXIT trap that already cleans up the * profile-shim dir. Empty/undefined for integrations that stage nothing * (Claude), which leaves the trap's shape unchanged. */ teardownPaths?: readonly string[]; } interface SafehouseAgentWriteBack { baselinePath: string; sourcePath: string; stagedPath: string; } interface LaunchCommandArguments { definition: AgentDefinition; promptFile: string; worktreeDir: string; /** * Directory the agent and prepareWorktree hook cwd into (the `cd`/`-w` * target). Equals `worktreeDir` unless the repo recipe sets a `workdir`, in * which case it is the subproject dir. The `{{worktree}}` template keeps using * `worktreeDir` (the whole checkout). */ workingDir: string; /** * Optional path to a `KEY='value'` env file containing build-time * secrets (see `BUILD_SECRET_NAMES`). Sourced on the host shell before * prepareWorktree; for the sdx runner the names are propagated into the sandbox * via `sbx exec -e KEY`. Always unset before exec'ing the agent so the * agent process never inherits them. */ secretsFile?: string | undefined; /** * Optional repo-preparation hook resolved by the caller from the freshly * created worktree's `.groundcrew/config.json`, falling back to * `defaults.hooks.prepareWorktree` from crew.config.ts. */ prepareWorktreeCommand?: string | undefined; /** * Operator-only, per-repository setup command run on the HOST shell (never a * sandbox), before `prepareWorktreeCommand` and the agent. Resolved by the * caller from `knownRepositories[].unsandboxedHooks.prepareWorktree` in * crew.config.ts. Emitted for the safehouse and none runners; the sdx * runner rejects it (no host to run it on). */ prepareWorktreeUnsandboxedCommand?: string | undefined; /** * Concrete local isolation backend chosen for this launch. Resolved * from `config.local.runner` via `resolveLocalRunner` before this * function is called — `auto` is never seen here. */ runner: LocalRunner; /** * Network egress posture. The safehouse runner uses `"allowlisted"` for the * Clearance shim and `"open"` for bare `safehouse`; sdx/unwrapped paths * ignore it. */ networkEgress: NetworkEgressSetting; /** * sbx sandbox name when `runner === "sdx"`. Derived by the caller from * `sandboxNameFor({ agent })`. Required for sdx; ignored otherwise. * Kept off the agent definition so a agent can launch under safehouse * on one host and sdx on another without config edits. */ sandboxName?: string | undefined; /** * Extra filesystem paths granted read/write to the safehouse sandbox via * `--add-dirs`, beyond safehouse's automatic cwd grant. Resolved (and deduped) * by `composeAgentLaunch`'s `resolveSafehouseAddDirs` — see there for which * paths and why git needs them. Empty/undefined → no `--add-dirs` flag (the * pre-existing behavior). Only consumed by the safehouse wrap. */ safehouseAddDirs?: readonly string[] | undefined; /** * Extra read/write paths granted only to the Safehouse agent wrap. These are * intentionally withheld from the repo-controlled prepareWorktree wrap. */ safehouseAgentAddDirs?: readonly string[] | undefined; /** * Optional Safehouse integrations turned on for the agent wrap, emitted as * `--enable=` before the profile shim. Each name layers the * matching optional sandbox profile (e.g. `agent-browser`) on top of the * agent's deny-by-default policy. Withheld from the repo-controlled * prepareWorktree wrap, which never needs them. Empty/undefined → no * `--enable` flag. */ safehouseEnableFeatures?: readonly string[] | undefined; /** * Extra read-only paths granted only to the Safehouse agent wrap via * `--add-dirs-ro` (host toolchains the Safehouse profile masks but doesn't * re-open). Read-only so the agent cannot mutate host toolchain state. */ safehouseAgentAddDirsReadOnly?: readonly string[] | undefined; /** * Extra host-terminal integration surface granted only to the Safehouse agent * wrap. The agent may need to execute host shims and reach their sockets * while repo-controlled prepareWorktree hooks should not inherit those paths * or env vars. */ safehouseAgentIntegration?: SafehouseAgentIntegration | undefined; /** * Groundcrew-managed task metadata exposed to the launched worker. Forwarded * to the agent process, not the prepareWorktree hook. */ workerEnvironment?: WorkerEnvironment | undefined; /** * When set, the agent is exec'd with no trailing prompt positional so it opens * its interactive session and hands control to the user. The staged prompt is * still read into `$_p` (and the prompt dir cleaned up) for a uniform launch * chain; only the positional is dropped. Used by `crew open` when no * `--prompt`/`--prompt-file` is given. */ omitPromptArgument?: boolean | undefined; } /** * Build the shell command that runs inside the workspace. The prompt is * staged in a temp file (so backticks/quotes/$ in the description survive), * read into `$_p`, the temp dir is removed, then the agent CLI is exec'd * with the prompt as its trailing positional argument. This removes the * need for a `readyMarker` poll because the agent starts up with the * prompt in hand. */ export declare function buildLaunchCommand(arguments_: LaunchCommandArguments): string; //# sourceMappingURL=launchCommand.d.ts.map