Skip to main content

preprocess_command_injections

Function preprocess_command_injections 

Source
pub async fn preprocess_command_injections(
    content: &str,
    executor: &dyn CommandExecutor,
) -> String
Expand description

Preprocess !command`` placeholders in skill content.

Each !command`` is executed via the provided executor and replaced with its stdout. Execution is bounded: at most MAX_COMMAND_PLACEHOLDERS_PER_SKILL placeholders are expanded per call (extras are replaced with [Too many command placeholders: limit is N] sentinels), and at most COMMAND_EXECUTION_CONCURRENCY commands run concurrently.

Substitution pipeline order (caller is responsible for prior steps):

  1. $ARGUMENTS / $N substitution (sync)
  2. ${SESSION_ID} / ${SKILL_DIR} env substitution (sync)
  3. !command`` preprocessing (async) — this function

SECURITY: This function spawns shell processes on the worker host. It MUST only be called for skill content that came from a trusted source (see the trust-gate note at the top of this module). Untrusted content must bypass this step and be used verbatim.