Add files via upload

This commit is contained in:
公明
2026-04-19 03:28:06 +08:00
committed by GitHub
parent 56697e9642
commit 1f570892d8
10 changed files with 142 additions and 129 deletions
+9 -6
View File
@@ -5,26 +5,28 @@
## 总体结论
- **改造已可用于生产试验**:流式对话、MCP 工具桥接、配置开关、前端模式切换均已落地。
- **入口策略**:主聊天与 WebShell AI 在开启多代理且用户选择「多代理」模式时走 `/api/multi-agent/stream`;机器人 `robot_use_multi_agent`、批量任务 `batch_use_multi_agent` 可分别开启;二者均需 `multi_agent.enabled`
- **入口策略**:主聊天与 WebShell 在开启多代理且用户选择 **Deep / Plan-Execute / Supervisor** 时走 `/api/multi-agent/stream`,请求体字段 **`orchestration`** 指定当次编排(与界面一致);**原生 ReAct** 走 `/api/agent-loop/stream`。机器人、批量任务无该请求体时服务端按 **`deep`** 执行。均需 `multi_agent.enabled`
## 已完成项
| 项 | 说明 |
|----|------|
| 依赖与代理 | `go.mod` 直接依赖 `github.com/cloudwego/eino``eino-ext/.../openai``go.mod` 注释与 `scripts/bootstrap-go.sh` 指导 **GOPROXY**(如 `https://goproxy.cn,direct`)。 |
| 配置 | `config.yaml``multi_agent``enabled``default_mode``robot_use_multi_agent``max_iteration``sub_agents`(含可选 `bind_role`)等;结构体见 `internal/config/config.go`。 |
| Markdown 子代理 / 主代理 | **常规用法**`agents_dir`(默认 `agents/`)下放 `*.md`front matter + 正文)。**子代理**供 Deep `task` 调度;**主代理**为 `orchestrator.md` `kind: orchestrator`单个文件,定义协调者 `description` / 系统提示(正文空则回退 `orchestrator_instruction` / Eino 默认)。可选:`multi_agent.sub_agents` 与目录合并(同 id 时 Markdown 覆盖)。管理:**Agents → Agent管理**API`/api/multi-agent/markdown-agents*`。 |
| 配置 | `config.yaml``multi_agent``enabled``default_mode``robot_use_multi_agent``max_iteration``sub_agents`(含可选 `bind_role``eino_skills``eino_middleware` 等;结构体见 `internal/config/config.go`。 |
| Markdown 子代理 / 主代理 | 在 `agents_dir` 下放 `*.md`。**子代理**供 Deep `task` `supervisor` `transfer`。**主代理(按模式分离)**`orchestrator.md``kind: orchestrator`**单个**其他 .md)→ **Deep**;固定名 `orchestrator-plan-execute.md`**plan_execute**;固定名 `orchestrator-supervisor.md`**supervisor**。正文优先于 YAML`multi_agent.orchestrator_instruction``orchestrator_instruction_plan_execute``orchestrator_instruction_supervisor`plan_execute / supervisor **不会**回退到 Deep 的 `orchestrator_instruction`。皆空时 plan_execute / supervisor 使用代码内置默认提示。管理:**Agents → Agent管理**API`/api/multi-agent/markdown-agents*`。 |
| MCP 桥 | `internal/einomcp``ToolsFromDefinitions` + 会话 ID 持有者,执行走 `Agent.ExecuteMCPToolForConversation`。 |
| 编排 | `internal/multiagent/runner.go``deep.New` + 子 `ChatModelAgent` + `adk.NewRunner``EnableStreaming: true`),事件映射为现有 SSE `tool_call` / `response_delta` 等。 |
| 编排 | `internal/multiagent/runner.go``deep.New` + 子 `ChatModelAgent` + `adk.NewRunner``EnableStreaming: true`,可选 `CheckPointStore`),事件映射为现有 SSE `tool_call` / `response_delta` 等。 |
| HTTP | `POST /api/multi-agent`(非流式)、`POST /api/multi-agent/stream`(SSE);路由**常注册**,是否可用由运行时 `multi_agent.enabled` 决定(流式未启用时 SSE 内 `error` + `done`)。 |
| 会话准备 | `internal/handler/multi_agent_prepare.go``prepareMultiAgentSession`(含 **WebShell** `CreateConversationWithWebshell`、工具白名单与单代理一致)。 |
| 单 Agent | `internal/agent` 增加 `ToolsForRole``ExecuteMCPToolForConversation`;原 `/api/agent-loop` 未删改语义。 |
| 前端 | 主聊天:`multi_agent.enabled`显示「模式」下拉;WebShell AI 与主聊天共用 `localStorage``cyberstrike-chat-agent-mode`。设置页可写 `multi_agent` 标量到 YAML。 |
| 前端 | 主聊天 / WebShell`multi_agent.enabled`可选 **原生 ReAct** 与三种 Eino 命名,多代理路径在 JSON 中带 `orchestration`。设置页不再配置预置编排项;`plan_execute` 外层循环上限等仍可在设置中保存。 |
| 流式兼容 | 与 `/api/agent-loop/stream` 共用 `handleStreamEvent``conversation``progress``response_start` / `response_delta``thinking` / `thinking_stream_*`(模型 `ReasoningContent`)、`tool_*``response``done` 等;`tool_result``toolCallId``tool_call` 联动;`data.mcpExecutionIds` 与进度 i18n 已对齐。 |
| 批量任务 | `batch_use_multi_agent: true` `executeBatchQueue` 中每子任务调用 `RunDeepAgent``roleTools` 沿用队列角色;Eino 路径不注入 `roleSkills` 系统提示,与 Web 多代理会话一致)。 |
| 批量任务 | 队列 `agentMode``deep` / `plan_execute` / `supervisor` 子任务带对应 `orchestration` 调用 `RunDeepAgent`;旧值 `multi` 与「`agentMode` 为空且 `batch_use_multi_agent: true`」均按 `deep`。 |
| 配置 API | `GET /api/config` 返回 `multi_agent: { enabled, default_mode, robot_use_multi_agent, sub_agent_count }``PUT /api/config` 可更新前三项(不覆盖 `sub_agents`)。 |
| OpenAPI | 多代理路径说明已更新(流式未启用为 SSE 错误事件)。 |
| 机器人 | `ProcessMessageForRobot``enabled && robot_use_multi_agent` 时调用 `multiagent.RunDeepAgent`。 |
| 预置编排 | 聊天 / WebShell`POST /api/multi-agent*` 请求体 `orchestration``deep` \| `plan_execute` \| `supervisor`(缺省 `deep`)。`plan_execute` 不构建 YAML/Markdown 子代理;`plan_execute_loop_max_iterations` 仍来自配置。`supervisor` 至少需一个子代理。 |
| Eino 中间件 | `multi_agent.eino_middleware`(可选):`patchtoolcalls`(默认开)、`toolsearch`(按阈值拆分 MCP 工具列表)、`plantask`(需 `eino_skills`)、`reduction`(大工具输出截断/落盘)、`checkpoint_dir`Runner 断点)、`deep_output_key` / `deep_model_retry_max_retries` / `task_tool_description_prefix`Deep 与 supervisor 主代理共享其中模型重试与 OutputKey)。`plan_execute` 的 Executor 无 Handlers:仅继承 **ToolsConfig** 侧效果(如 `tool_search` 列表拆分),不挂载 patch/plantask/reduction 中间件。 |
## 进行中 / 待办( backlog
@@ -55,3 +57,4 @@
| 2026-03-22 | 流式工具事件:按稳定签名去重,避免每 chunk 刷屏与「未知工具」;最终回复去重相同段落;内置调度显示为 `task`。 |
| 2026-03-22 | `agents/*.md` 子代理定义、`agents_dir`、合并进 `RunDeepAgent`、前端 Agents 菜单与 CRUD API。 |
| 2026-03-22 | `orchestrator.md` / `kind: orchestrator` 主代理、列表主/子标记、与 `orchestrator_instruction` 优先级。 |
| 2026-04-19 | 主聊天「对话模式」:原生 ReAct 与 Deep / Plan-Execute / Supervisor`POST /api/multi-agent*` 请求体 `orchestration` 与界面一致;`config.yaml` / 设置页不再维护预置编排字段(机器人/批量默认 `deep`)。 |
+6 -123
View File
@@ -1,124 +1,7 @@
# Skills 系统使用指南
# Skills 目录(Agent Skills / Eino
## 概述
Skills系统允许你为角色配置专业知识和技能文档。当角色执行任务时,系统会将技能名称添加到系统提示词中作为推荐提示,AI智能体可以通过 `read_skill` 工具按需获取技能的详细内容
## Skills结构
每个skill是一个目录,包含一个`SKILL.md`文件:
```
skills/
├── sql-injection-testing/
│ └── SKILL.md
├── xss-testing/
│ └── SKILL.md
└── ...
```
## SKILL.md格式
SKILL.md文件支持YAML front matter格式(可选):
```markdown
---
name: skill-name
description: Skill的简短描述
version: 1.0.0
---
# Skill标题
这里是skill的详细内容,可以包含:
- 测试方法
- 工具使用
- 最佳实践
- 示例代码
- 等等...
```
如果不使用front matter,整个文件内容都会被作为skill内容。
## 在角色中配置Skills
在角色配置文件中添加`skills`字段:
```yaml
name: 渗透测试
description: 专业渗透测试专家
user_prompt: 你是一个专业的网络安全渗透测试专家...
tools:
- nmap
- sqlmap
- burpsuite
skills:
- sql-injection-testing
- xss-testing
enabled: true
```
`skills`字段是一个字符串数组,每个字符串是skill目录的名称。
## 工作原理
1. **加载阶段**:系统启动时,会扫描`skills_dir`目录下的所有skill目录
2. **执行阶段**:当使用某个角色执行任务时:
- 系统会将角色配置的skill名称添加到系统提示词中作为推荐提示
- **注意**:skill的详细内容不会自动注入到系统提示词中
- AI智能体需要根据任务需要,主动调用 `read_skill` 工具获取技能的详细内容
3. **按需调用**:AI可以通过以下工具访问skills:
- `list_skills`: 获取所有可用的skills列表
- `read_skill`: 读取指定skill的详细内容
这样AI可以在执行任务过程中,根据实际需要自主调用相关skills获取专业知识。即使角色没有配置skills,AI也可以通过这些工具按需访问任何可用的skill。
## 示例Skills
### sql-injection-testing
包含SQL注入测试的专业方法、工具使用、绕过技术等。
### xss-testing
包含XSS测试的各种类型、payload、绕过技术等。
## 创建自定义Skill
1.`skills`目录下创建新目录,例如`my-skill`
2. 在该目录下创建`SKILL.md`文件
3. 编写skill内容
4. 在角色配置中添加该skill名称
```bash
mkdir -p skills/my-skill
cat > skills/my-skill/SKILL.md << 'EOF'
---
name: my-skill
description: 我的自定义技能
---
# 我的自定义技能
这里是技能内容...
EOF
```
## 注意事项
- **重要**:Skill的详细内容不会自动注入到系统提示词中,只有技能名称会作为提示添加
- AI智能体需要通过 `read_skill` 工具主动获取技能内容,这样可以节省token并提高灵活性
- Skill内容应该清晰、结构化,便于AI理解
- 可以包含代码示例、命令示例等
- 建议每个skill专注于一个特定领域或技能
- 建议在skill的YAML front matter中提供清晰的 `description`,帮助AI判断是否需要读取该skill
## 配置
`config.yaml`中配置skills目录:
```yaml
skills_dir: skills # 相对于配置文件所在目录
```
如果未配置,默认使用`skills`目录。
- 每个技能为**子目录**,根上必须有 **`SKILL.md`**YAML front matter`name``description` + Markdown 正文),见 [agentskills.io](https://agentskills.io/specification.md)。
- **目录名须与 `name` 一致**。
- **运行时加载**:在 **Eino DeepAgent(多代理)** 会话中由 ADK **`skill` 中间件**渐进披露(系统提示中列出各 skill 的 name/description,模型再调用 **`skill`** 工具拉取 `SKILL.md` 全文)。可选开启 **`multi_agent.eino_skills.filesystem_tools`**,使用与本机相同的 `read_file` / `execute` 等访问包内脚本与资源
- **Web 管理**HTTP `/api/skills/*` 仍用于列表、编辑、上传包内文件(实现为 `internal/skillpackage`,非 MCP)。
- **运行时**:多代理(DeepAgent)会话内由 ADK **`skill`** 工具渐进加载;单代理 MCP 循环不含 Skills,需开多代理或后续单代理 Eino 路径。
+8
View File
@@ -0,0 +1,8 @@
# 表单 / 检查项(示例)
本文件演示 **Level 3** 资源:与主说明分离,按需通过多代理 **`skill`** 或 HTTP `resource_path=FORMS.md` 加载。
## 授权检查表
- 书面授权是否在有效期内?
- 测试范围(域名 / IP)是否与授权一致?
+14
View File
@@ -0,0 +1,14 @@
# API / 参考(示例)
## HTTP `/api/skills/{id}`
- `resource_path`:包内相对路径,例如 `FORMS.md``scripts/payloads.txt`
- `depth=summary`:仅摘要与目录,适合首轮检索。
## 多代理运行时
- 使用 Eino ADK **`skill`** 工具按技能包渐进加载;可选开启 `multi_agent.eino_skills.filesystem_tools` 访问包内文件。
## 链接
- [Agent Skills 概览](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview)
+65
View File
@@ -0,0 +1,65 @@
---
name: cyberstrike-eino-demo
description: 满配示例技能包:SKILL.md + scripts/、references/、assets/ 等可选目录;验证 Eino skill 与 HTTP 包内路径(仅授权安全测试与教学)。
---
# CyberStrike × Eino 满配技能演示
本包与 [Agent Skills](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview) 一致:**`SKILL.md` 为清单 + 主说明**(无单独 `SKILL.yaml`)。同目录可有 **`scripts/`**、**`references/`**、**`assets/`** 等任意子目录(只要路径安全、未触达包深度/文件数上限),由 **`ListPackageFiles` / `resource_path`** 与 Eino 本机工具读取。补充说明见 `FORMS.md``REFERENCE.md`
## 概述
用于一次性验证:
- HTTP `GET /api/skills` 列表(`script_count``file_count``progressive` 等为推导/扫描结果)
- `GET /api/skills/cyberstrike-eino-demo?depth=summary|full`
- `section=` 对应 `SKILL.md`**`##` 标题**或 ASCII 标题的短 id(例如 `## Payload 样例` 常对应 `section=payload`
- 多代理内 ADK **`skill`** 工具(及可选本机文件工具)读取包内相对路径资源
- Eino `FilesystemSkillsRetriever` 对包摘要、`##` 分块、脚本条目的检索
**硬性要求**:任何测试须取得书面授权,并限定在约定范围与时间窗口内。
## 授权测试工作流
1. **范围确认**:域名 / IP、接口列表、禁止动作(DoS、数据拖库等)。
2. **基线记录**:对约定资产做只读探测,保存时间戳与原始请求/响应摘要。
3. **分类测试**:按漏洞类型拆分任务;高风险操作前二次确认授权边界。
4. **证据与报告**:每个发现附带复现步骤、影响、修复建议;敏感数据脱敏。
5. **收尾**:删除临时账号、清理测试数据、移交报告。
## Payload 样例
以下为 **教学占位**,实际测试需替换为目标上下文且不得用于未授权系统:
- SQLi 探测(错误型):`"'`(观察是否触发数据库错误信息泄露)
- XSS 反射型(无害化):`<script>alert(1)</script>` → 在靶场中应被编码或 CSP 拦截
- 路径穿越(只读验证):`....//....//etc/passwd`(仅在授权文件读取场景)
详细列表见 `scripts/payloads.txt`
## references/ 与 assets/
用于验证非 `scripts/` 的子目录是否被同等对待:
| 路径 | 用途 |
|------|------|
| `references/citations.md` | 引用与 HTTP `resource_path` 测试说明 |
| `assets/README.txt` | 占位资源(可换成真实二进制做读文件上限测试) |
## 推荐工具链
| 阶段 | 工具示例 |
|------|-----------|
| 代理与重放 | Burp Suite、mitmproxy |
| 扫描与目录 | ffuf、nuclei(需调低并发遵守授权) |
| 漏洞验证 | 自写 PoC、官方 CLI(sqlmap 等)仅在授权范围内 |
| 记录 | Markdown + JSON 片段模板(见 `scripts/report-snippet.json` |
## 清单与验证
- [ ] 已保存书面授权与测试窗口
- [ ] `scripts/` 下文件与正文引用一致
- [ ] Web 或 `GET /api/skills?...` 可核对索引;多代理会话内用 **`skill`** 工具按包加载以节省 token
- [ ] 需要细节时通过 **`skill`** 拉全文,或 HTTP `depth=full``section=<标题或短 id>`
- [ ] 需要脚本原文时通过本机文件工具或 HTTP `resource_path=scripts/check-env.sh`
- [ ] `resource_path=references/citations.md``resource_path=assets/README.txt` 可读取
@@ -0,0 +1,8 @@
CyberStrike skill package — assets/ smoke test
==============================================
This plain-text file checks that arbitrary subfolders under a skill package
(e.g. assets/) are listed and readable via /api/skills/...?resource_path=...
You may replace this with real binaries (images, zips, etc.) in authorized tests.
Max read size is enforced by the server (see skillpackage default limits).
@@ -0,0 +1,13 @@
# 引用与外链(示例)
本文件用于验证技能包内 **`references/`** 目录是否被列表 API、HTTP `resource_path` 及多代理本机文件工具正常识别。
## 测试方式(授权环境内)
1. `GET /api/skills/cyberstrike-eino-demo` 响应中的 `package_files` 应包含 `references/citations.md`
2. `GET /api/skills/cyberstrike-eino-demo?resource_path=references/citations.md` 应返回本文内容。
3. 多代理且开启 `eino_skills.filesystem_tools` 时,可通过相对路径读取本文件。
## 占位引用
- [OWASP Testing Guide](https://owasp.org/www-project-web-security-testing-guide/)(仅作链接格式示例)
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Demo only — not executed by CyberStrike server; safe to display when previewing the skill package.
set -euo pipefail
echo "cyberstrike-eino-demo / scripts/check-env.sh"
echo "Purpose: illustrate bundled script resource in a skill package."
echo "This script does not modify the system when shown in a preview or read-only context."
uname -s 2>/dev/null || echo "(uname unavailable in display context)"
@@ -0,0 +1,4 @@
# Placeholder payloads for authorized testing labs only.
sqli-probe: '
xss-probe: <svg/onload=alert(1)>
ssrf-probe: http://127.0.0.1:80 (only if scope explicitly allows loopback)
@@ -0,0 +1,8 @@
{
"title": "Example finding",
"severity": "medium",
"affected": "https://example.com/api/v1/search",
"summary": "Parameterized query reflects error message; verify with authorized DAST only.",
"remediation": "Use prepared statements; generic error pages in production.",
"references": ["OWASP SQL Injection"]
}