const TOOL_ENTITY_ID = "ai_assistant:mcp_tool";
const GLOBAL_TENANT_ID = "00000000-0000-0000-0000-000000000000";
const ESSENTIAL_TOOLS = [
  "context_whoami",
  // Auth context awareness
  "search_query",
  // Universal search
  "search_schema",
  // Entity discovery
  "search_status"
  // Check integrations
];
const TOOL_SEARCH_CONFIG = {
  /** Maximum tools to return from search */
  defaultLimit: 12,
  /** Minimum relevance score (0-1) */
  minScore: 0.2,
  /** Strategies to use (in priority order) */
  strategies: ["fulltext", "vector", "tokens"]
};
const toolSearchEntityConfig = {
  entityId: TOOL_ENTITY_ID,
  enabled: true,
  priority: 100,
  // High priority for tool results
  /**
   * Build searchable content from a tool definition.
   */
  buildSource: (ctx) => {
    const tool = ctx.record;
    const name = tool.name || "";
    const description = tool.description || "";
    const moduleId = ctx.record.moduleId;
    const normalizedName = name.replace(/[_.-]/g, " ");
    const textContent = [
      normalizedName,
      description,
      moduleId ? `module ${moduleId}` : ""
    ].filter(Boolean).join(" | ");
    return {
      text: textContent,
      fields: {
        name: normalizedName,
        originalName: name,
        description,
        moduleId: moduleId ?? null,
        requiredFeatures: tool.requiredFeatures ?? []
      },
      presenter: {
        title: name,
        subtitle: description.slice(0, 100),
        icon: "tool"
      },
      checksumSource: { name, description, moduleId }
    };
  },
  /**
   * Format result for display in search UI.
   */
  formatResult: (ctx) => {
    const tool = ctx.record;
    return {
      title: tool.name || "Unknown Tool",
      subtitle: (tool.description || "").slice(0, 100),
      icon: "tool"
    };
  },
  /**
   * Field policy for search strategies.
   */
  fieldPolicy: {
    searchable: ["name", "description", "moduleId"],
    hashOnly: [],
    excluded: ["requiredFeatures", "inputSchema", "handler"]
  }
};
function toolToIndexableRecord(tool, moduleId) {
  const normalizedName = tool.name.replace(/[_.-]/g, " ");
  const description = tool.description || "";
  const embeddingText = `${normalizedName} | ${description}`;
  const presenter = {
    title: tool.name,
    subtitle: description.slice(0, 100),
    icon: "tool"
  };
  return {
    entityId: TOOL_ENTITY_ID,
    recordId: tool.name,
    tenantId: GLOBAL_TENANT_ID,
    organizationId: null,
    fields: {
      name: normalizedName,
      originalName: tool.name,
      description,
      moduleId: moduleId ?? null,
      requiredFeatures: tool.requiredFeatures ?? []
    },
    presenter,
    text: embeddingText,
    checksumSource: {
      name: tool.name,
      description,
      moduleId
    }
  };
}
function computeToolsChecksum(tools) {
  const content = tools.map((t) => `${t.name}:${t.description}`).sort().join("|");
  let hash = 0;
  for (let i = 0; i < content.length; i++) {
    const char = content.charCodeAt(i);
    hash = (hash << 5) - hash + char | 0;
  }
  return hash.toString(16);
}
export {
  ESSENTIAL_TOOLS,
  GLOBAL_TENANT_ID,
  TOOL_ENTITY_ID,
  TOOL_SEARCH_CONFIG,
  computeToolsChecksum,
  toolSearchEntityConfig,
  toolToIndexableRecord
};
//# sourceMappingURL=tool-index-config.js.map
