"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var types_exports = {};
__export(types_exports, {
  SYSTEM_PROMPT_SECTIONS: () => SYSTEM_PROMPT_SECTIONS,
  approveAll: () => approveAll,
  convertMcpCallToolResult: () => convertMcpCallToolResult,
  createSessionFsAdapter: () => import_sessionFsProvider.createSessionFsAdapter,
  defaultJoinSessionPermissionHandler: () => defaultJoinSessionPermissionHandler,
  defineTool: () => defineTool
});
module.exports = __toCommonJS(types_exports);
var import_sessionFsProvider = require("./sessionFsProvider.js");
function convertMcpCallToolResult(callResult) {
  const textParts = [];
  const binaryResults = [];
  for (const block of callResult.content) {
    switch (block.type) {
      case "text":
        if (typeof block.text === "string") {
          textParts.push(block.text);
        }
        break;
      case "image":
        if (typeof block.data === "string" && block.data && typeof block.mimeType === "string") {
          binaryResults.push({
            data: block.data,
            mimeType: block.mimeType,
            type: "image"
          });
        }
        break;
      case "resource": {
        if (block.resource?.text) {
          textParts.push(block.resource.text);
        }
        if (block.resource?.blob) {
          binaryResults.push({
            data: block.resource.blob,
            mimeType: block.resource.mimeType ?? "application/octet-stream",
            type: "resource",
            description: block.resource.uri
          });
        }
        break;
      }
    }
  }
  return {
    textResultForLlm: textParts.join("\n"),
    resultType: callResult.isError ? "failure" : "success",
    ...binaryResults.length > 0 ? { binaryResultsForLlm: binaryResults } : {}
  };
}
function defineTool(name, config) {
  return { name, ...config };
}
const SYSTEM_PROMPT_SECTIONS = {
  identity: { description: "Agent identity preamble and mode statement" },
  tone: { description: "Response style, conciseness rules, output formatting preferences" },
  tool_efficiency: { description: "Tool usage patterns, parallel calling, batching guidelines" },
  environment_context: { description: "CWD, OS, git root, directory listing, available tools" },
  code_change_rules: { description: "Coding rules, linting/testing, ecosystem tools, style" },
  guidelines: { description: "Tips, behavioral best practices, behavioral guidelines" },
  safety: { description: "Environment limitations, prohibited actions, security policies" },
  tool_instructions: { description: "Per-tool usage instructions" },
  custom_instructions: { description: "Repository and organization custom instructions" },
  last_instructions: {
    description: "End-of-prompt instructions: parallel tool calling, persistence, task completion"
  }
};
const approveAll = () => ({ kind: "approve-once" });
const defaultJoinSessionPermissionHandler = () => ({
  kind: "no-result"
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SYSTEM_PROMPT_SECTIONS,
  approveAll,
  convertMcpCallToolResult,
  createSessionFsAdapter,
  defaultJoinSessionPermissionHandler,
  defineTool
});
