承接 drupal-mods/content-agent-detector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drupal-mods/content-agent-detector

Composer 安装命令:

composer require drupal-mods/content-agent-detector

包简介

Provides machine-optimized content browsing API for AI agents powered by Commerce Agent Detector.

README 文档

README

pipeline status PHPCS PHPStan PHPUnit

A Drupal module that provides machine-optimized content browsing API endpoints for AI agents. Companion module to Commerce Agent Detector.

What It Does

AI agents visiting a Drupal site get themed HTML — full of navigation chrome, scripts, and layout markup that obscures the actual content. This module gives agents clean, structured JSON for every page on the site.

The key concept is the resolve endpoint: give it any internal URL and it returns the content as structured data, with all internal links rewritten as API URLs the agent can follow. Agents can browse the site naturally — following links, navigating menus, searching content — without ever parsing HTML.

Requirements

Installation

composer require drupal-mods/content-agent-detector
drush en content_agent_detector

API Endpoints

Discovery (Public)

EndpointDescription
GET /.well-known/agent-content.jsonDiscovery document with all endpoints
GET /api/content/agent/openapi.jsonFull OpenAPI 3.1.0 specification

Browsing (Authenticated)

EndpointDescription
GET /api/content/agent/resolve?path=/about-usResolve any URL to structured content
GET /api/content/agent/node/{id}Get content by node ID
GET /api/content/agent/search?q=keywordFull-text content search
GET /api/content/agent/list/{type}List content by type
GET /api/content/agent/typesList available content types
GET /api/content/agent/menusList available menus
GET /api/content/agent/menu/{name}Get menu tree with API links
GET /api/content/agent/sitemap.jsonAll published pages as API links
GET /api/content/agent/taxonomy/{vocabulary}Browse taxonomy terms
GET /api/content/agent/taxonomy/{vocabulary}/{term}Term detail with tagged content
GET /api/content/agent/breadcrumb?path=/about-usBreadcrumb navigation chain

How Agents Browse

  1. Discover — Fetch /.well-known/agent-content.json to find all endpoints
  2. Orient — Get the sitemap or menu tree to see what content exists
  3. Navigate — Use the resolve endpoint to read any page
  4. Follow links — Internal links in responses are rewritten as API URLs
  5. Search — Use the search endpoint for keyword queries

Example: Resolve a Page

GET /api/content/agent/resolve?path=/about-us
Authorization: Bearer cad_your_token_here
Accept: application/json
{
  "status": "success",
  "content": {
    "@type": "WebPage",
    "id": 42,
    "type": "page",
    "title": "About Us",
    "url": "https://example.com/about-us",
    "api_url": "/api/content/agent/node/42",
    "body": "## Our Story\n\nWe are a company that...",
    "fields": {
      "field_subtitle": "Learn more about our team"
    },
    "links": [
      {
        "text": "Meet the Team",
        "url": "/api/content/agent/resolve?path=/team",
        "type": "internal"
      }
    ],
    "taxonomy": {
      "tags": [
        {
          "id": 5,
          "name": "Company",
          "api_url": "/api/content/agent/taxonomy/tags/5"
        }
      ]
    }
  }
}

Example: Menu Navigation

GET /api/content/agent/menu/main
{
  "status": "success",
  "menu": "main",
  "tree": [
    {
      "title": "Home",
      "api_url": "/api/content/agent/resolve?path=/",
      "weight": 0,
      "children": []
    },
    {
      "title": "Products",
      "api_url": "/api/content/agent/resolve?path=/products",
      "weight": 1,
      "children": [
        {
          "title": "New Arrivals",
          "api_url": "/api/content/agent/resolve?path=/products/new",
          "weight": 0,
          "children": []
        }
      ]
    }
  ]
}

Authentication

Uses the same authentication mechanisms as Commerce Agent Detector:

  • Managed tokens — Created in the admin UI with content scope
  • Bearer tokensAuthorization: Bearer cad_...
  • X-Agent-Token headerX-Agent-Token: cad_...
  • Legacy config tokens — From Commerce Agent Detector settings
  • Agent detection — Recognized User-Agents (GPTBot, ClaudeBot, etc.)
  • Anonymous readonly — Optional, for public content sites

Configuration

Navigate to Commerce → Configuration → Agent Detector → Content API tab.

Settings include:

  • Allowed content types — Which node types to expose
  • Allowed vocabularies — Which taxonomies to expose
  • Body format — Markdown (default) or plain text
  • Max body length — Truncation limit for body content
  • Include media — Expose images and file attachments
  • Link rewriting — Rewrite internal links as API URLs
  • Anonymous readonly — Allow unauthenticated JSON requests

Content Rendering

The module converts Drupal content to clean structured data:

  • Body fields — HTML converted to Markdown with heading structure, links, lists, code blocks, and tables preserved
  • Entity references — Resolved to labels with API URLs
  • Images — Direct file URLs with alt text and dimensions
  • Files — Download URLs with MIME type and size
  • Taxonomy — Grouped by vocabulary with API URLs
  • Media entities — Resolved to source file URLs
  • Internal links — Rewritten from paths like /about-us to API URLs like /api/content/agent/resolve?path=/about-us

Architecture

This module is a companion to Commerce Agent Detector and reuses its infrastructure:

ServiceProvided By
Agent detectioncommerce_agent_detector.agent_detector
Token managementcommerce_agent_detector.token_manager
Rate limitingcommerce_agent_detector.rate_limiter
Interaction loggingcommerce_agent_detector.logger
Content renderingcontent_agent_detector.content_renderer
Link rewritingcontent_agent_detector.link_rewriter
Access checkingcontent_agent_detector.access_check

Agent interactions with content endpoints appear on the same Commerce Agent Detector dashboard with content_ action prefixes.

Development

# Install dependencies
composer install

# Run unit tests
vendor/bin/phpunit --configuration phpunit.xml --testdox

# Check coding standards
vendor/bin/phpcs --warning-severity=0

# Run static analysis
vendor/bin/phpstan analyse --no-progress

License

GPL-2.0-or-later

drupal-mods/content-agent-detector 适用场景与选型建议

drupal-mods/content-agent-detector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「drupal」 「headless」 「content」 「acp」 「Agent」 「ai」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 drupal-mods/content-agent-detector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 drupal-mods/content-agent-detector 我们能提供哪些服务?
定制开发 / 二次开发

基于 drupal-mods/content-agent-detector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 29
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-03-30