// src/backends/shared/wrap-prompt.ts
var GATEWAY_PREAMBLE = "You are running inside an AgentStep sandboxed container. Execute tools directly \u2014 never announce what you will do before doing it. All tools are already available; do not search for or discover tools. If custom tools are defined, use them by name immediately.";
function withGatewayPreamble(system, memoryStores) {
  let preamble = system ? `${system}

${GATEWAY_PREAMBLE}` : GATEWAY_PREAMBLE;
  if (memoryStores && memoryStores.length > 0) {
    const lines = memoryStores.map((s) => {
      const parts = [];
      parts.push(`- /mnt/memory/${s.name.replace(/[^a-zA-Z0-9_.-]/g, "_")}/ (${s.access})`);
      if (s.description) parts[0] += ` \u2014 ${s.description}`;
      if (s.instructions) parts[0] += `. ${s.instructions}`;
      return parts[0];
    });
    preamble += `

Memory stores are mounted at /mnt/memory/:
${lines.join("\n")}`;
  }
  return preamble;
}
function wrapPromptWithSystem(prompt, systemPrompt, skills, memoryStores) {
  let systemBlock = withGatewayPreamble(systemPrompt, memoryStores);
  if (skills && skills.length > 0) {
    const skillsText = skills.map(
      (s) => `<skill name="${s.name}">
${s.content}
</skill>`
    ).join("\n\n");
    systemBlock = `${systemBlock}

## Agent Skills

${skillsText}`;
  }
  return `Instructions: ${systemBlock}

---

${prompt}`;
}

export {
  GATEWAY_PREAMBLE,
  withGatewayPreamble,
  wrapPromptWithSystem
};
