import { type AgentDef } from "./agents.js"; import { type WorkspaceEnvMode } from "./workspace-env.js"; import { type WorktreeInfo } from "./worktree.js"; import { type AgentProfile } from "./profiles.js"; import type { DispatchArgs } from "./protocol.js"; /** pi arguments a worker must repeat to load the same extensions and model. */ export declare function passthroughArgs(argv: string[], cwd: string): string[]; export interface EnvPolicy { /** M20: the workspace's own environment on top (default shell; off with inheritEnv off). */ workspaceEnv?: WorkspaceEnvMode; /** M20 (default): the launching shell's whole environment, less ENV_NEVER and the deny list. */ inheritEnv?: boolean; /** Settings envAllowList: names carried when inheritEnv is off; when it is on, names carried despite the deny list. */ extraEnv?: string[]; /** Settings envDenyList: names (`*` at the end matches a prefix) left out when inheriting. */ envDenyList?: string[]; } /** The environment a worker starts with. */ export declare function workerEnv(env: NodeJS.ProcessEnv, policy?: EnvPolicy): Record; /** Environment carried into a worker with inheritEnv off (PRD envAllowList defaults plus login basics). */ export declare function allowListedEnv(env: NodeJS.ProcessEnv, extra?: string[]): Record; /** DI-9 fallback name: the first six words of the prompt. */ export declare function fallbackName(task: string): string; export interface LaunchInput { /** First prompt; empty starts the worker idle on its session. */ task: string; cwd: string; sessionFile: string; name: string; origin: "bg" | "dispatch" | "adopt" | "fork"; /** The dispatching pi's own argv (process.argv), for extensions and model flags. */ argv: string[]; execPath: string; env: NodeJS.ProcessEnv; piVersion?: string; /** Extra variable names to carry (settings envAllowList, with inheritEnv off). */ extraEnv?: string[]; /** M20: carry the whole environment (default), less envDenyList; then the workspace's. */ inheritEnv?: boolean; envDenyList?: string[]; workspaceEnv?: WorkspaceEnvMode; /** Overrides from the agent view's /model and /thinking (DI-4). */ model?: string; thinking?: string; /** M10: the worktree made for it (prepareIsolation); cwd is inside it. */ worktree?: WorktreeInfo; /** M18: run as this agent (its model, thinking, tools and system prompt). */ agent?: AgentDef; } /** The daemon dispatch request for a new background pi running `task`. */ export declare function buildLaunch(input: LaunchInput): { worktree?: WorktreeInfo | undefined; piVersion?: string | undefined; thinking?: string | undefined; model?: string | undefined; agent?: string | undefined; name: string; origin: "dispatch" | "bg" | "adopt" | "fork"; envForce?: string[] | undefined; envDeny?: string[] | undefined; workspaceEnv?: WorkspaceEnvMode | undefined; cwd: string; sessionFile: string; command: string[]; env: Record; }; export interface Isolation { /** Where the session starts. */ cwd: string; worktree?: WorktreeInfo; /** For the user or the spawning agent: uncommitted changes left behind, or why it is not isolated. */ note?: string; /** Undo after a dispatch that never reached the daemon or that it refused (see refusedByDaemon). */ discard: () => void; } /** * M10: whether a dispatch error means no session started, so its worktree may go. A * dropped connection or a timeout may come after the daemon started it: keep the worktree. */ export declare function refusedByDaemon(err: unknown): boolean; /** * M10: a worktree for a new session when one is wanted. `explicit`: asked for by this * dispatch (an error outside a repository); otherwise a config default that falls back. */ export declare function prepareIsolation(cwd: string, name: string, want: boolean, explicit: boolean): Isolation; /** M10: whether a new session gets a worktree by default. */ export declare function isolationDefault(setting: "off" | "children" | "all", child: boolean): boolean; export interface ProfileLaunchInput extends EnvPolicy { name: string; profile: string; def: AgentProfile; task?: string; cwd: string; env: NodeJS.ProcessEnv; model?: string; thinking?: string; origin?: DispatchArgs["origin"]; } /** * M30: a level 0 agent's launch: the profile's argv with the task, model and thinking in * it, the environment as any job's plus the profile's own (through the same deny list). */ export declare function buildProfileLaunch(i: ProfileLaunchInput): DispatchArgs;