laravel/agent-detector 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

laravel/agent-detector

Composer 安装命令:

composer require laravel/agent-detector

包简介

Detect if code is running in an AI agent or automated development environment

README 文档

README

GitHub Workflow Status (main) Total Downloads Latest Version License

Introduction

Agent Detector is a lightweight PHP utility to detect if your code is running inside an AI agent or automated development environment.

Requires PHP 8.2+

Installation

To get started, install Agent Detector via the Composer package manager:

composer require laravel/agent-detector

Usage

use Laravel\AgentDetector\AgentDetector;
use Laravel\AgentDetector\KnownAgent;

$result = AgentDetector::detect();

if ($result->isAgent) {
    echo "Running inside: {$result->name}";
}

// Check for a specific known agent
if ($result->knownAgent() === KnownAgent::Claude) {
    echo "Hello from Claude!";
}

Or use the standalone function:

use function Laravel\AgentDetector\detectAgent;

$result = detectAgent();

Supported Agents

Agent Detection Method
Custom AI_AGENT env var
Cursor CURSOR_AGENT env var
Gemini GEMINI_CLI env var
Codex CODEX_SANDBOX, CODEX_CI, or CODEX_THREAD_ID env var
Augment CLI AUGMENT_AGENT env var
AMP AMP_CURRENT_THREAD_ID env var
Opencode OPENCODE_CLIENT or OPENCODE env var
Claude CLAUDECODE or CLAUDE_CODE env var
Cowork CLAUDE_CODE_IS_COWORK with CLAUDECODE or CLAUDE_CODE env var
Copilot AI_AGENT=github-copilot, AI_AGENT=github-copilot-cli, COPILOT_MODEL, COPILOT_ALLOW_ALL, COPILOT_GITHUB_TOKEN, or COPILOT_CLI env var
Replit REPL_ID env var
Devin /opt/.devin file exists
Antigravity ANTIGRAVITY_AGENT env var
Pi PI_CODING_AGENT env var
Kiro CLI KIRO_AGENT_PATH env var
v0 AI_AGENT=v0 env var

Custom Agent

Set the AI_AGENT environment variable to any value to identify your custom agent:

AI_AGENT=my-custom-agent php your-script.php

Testing

composer test

Contributing

Thank you for considering contributing to Agent Detector! You can read the contribution guide here.

Code of Conduct

In order to ensure that the Agent Detector community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Agent Detector is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 75
  • Watchers: 1
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固