/** * The PI_SUBAGENT_* environment contract between parent and child processes. * * The parent writes these keys through Native startup; the child reads them * in a separate process where no type system guards the contract — this file * is the single source of truth for the key names. Wire-format tests pin the * literal strings; production modules use these constants. */ /** Child display name. Written per Completion operation launch. */ export const SUBAGENT_ENV_NAME = "PI_SUBAGENT_NAME"; /** Completion operation identity for the current Fresh attempt. */ export const SUBAGENT_ENV_OPERATION_ID = "PI_SUBAGENT_OPERATION_ID"; /** Child activity snapshot file. */ export const SUBAGENT_ENV_ACTIVITY_FILE = "PI_SUBAGENT_ACTIVITY_FILE"; /** Completion evidence artifact for the current operation. */ export const SUBAGENT_ENV_COMPLETION_FILE = "PI_SUBAGENT_COMPLETION_FILE"; /** Parent cancellation request artifact for the current operation. */ export const SUBAGENT_ENV_CANCELLATION_REQUEST_FILE = "PI_SUBAGENT_CANCELLATION_REQUEST_FILE"; /** Child cancellation acknowledgement artifact for the current operation. */ export const SUBAGENT_ENV_CANCELLATION_FILE = "PI_SUBAGENT_CANCELLATION_FILE"; /** Agent profile name. Written by the launch policy, not per operation. */ export const SUBAGENT_ENV_AGENT = "PI_SUBAGENT_AGENT"; /** Environment fields that describe one Completion operation. */ export const OPERATION_ENVIRONMENT_KEYS: ReadonlySet = new Set([ SUBAGENT_ENV_NAME, SUBAGENT_ENV_OPERATION_ID, SUBAGENT_ENV_ACTIVITY_FILE, SUBAGENT_ENV_COMPLETION_FILE, SUBAGENT_ENV_CANCELLATION_REQUEST_FILE, SUBAGENT_ENV_CANCELLATION_FILE, ]); /** True when this process runs as a Fresh descendant. */ export function isNestedSubagentProcess(): boolean { return Boolean(process.env[SUBAGENT_ENV_OPERATION_ID]?.trim()); }