Compare commits

..

No commits in common. "main" and "archive/local-main-20261103" have entirely different histories.

1282 changed files with 197929 additions and 131459 deletions

View File

@ -1,26 +0,0 @@
name: Deep assessments
on:
push:
paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/frontend/**', '.github/workflows/deep-assessments.yml']
pull_request:
paths: ['internal/deepassessment/**', 'internal/database/vulnerability*', 'internal/database/assessment*', 'internal/database/asset*', 'internal/database/schemas/application.sql', 'internal/app/vulnerability_tools.go', 'internal/app/assessment_finding_test.go', 'internal/handler/vulnerability*', 'internal/handler/deep_assessment*', 'internal/multiagent/**', 'internal/agentruntime/**', 'runtime/pi/**', 'web/frontend/**', '.github/workflows/deep-assessments.yml']
permissions:
contents: read
jobs:
isolated-regression:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.19.0'
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: npm ci --ignore-scripts && npm run build && npm test
working-directory: runtime/pi
- run: go test -race ./internal/database -run 'TestAssessment|TestSharedAssetGraph'
- run: go test ./internal/app -run TestRecordVulnerabilityAssessmentEvidence
- run: go test -race ./internal/deepassessment
- run: go test -race ./internal/handler -run TestDeepAssessment

View File

@ -1,41 +0,0 @@
name: Frontend build
on:
push:
paths: ['web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'internal/app/app.go', 'internal/app/spa_test.go', '.github/workflows/frontend-build.yml']
pull_request:
paths: ['web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'internal/app/app.go', 'internal/app/spa_test.go', '.github/workflows/frontend-build.yml']
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build React + Semi Design bundle
run: |
npm ci --prefix web/frontend
npm run --prefix web/frontend build
- name: Committed bundle matches sources
run: |
if [ -n "$(git status --porcelain web/static/app)" ]; then
echo "web/static/app is out of date; run: npm run --prefix web/frontend build" >&2
git status --porcelain web/static/app >&2
exit 1
fi
- name: SPA entry and build artifacts
run: go test ./internal/app -run TestSPA -count=1
- run: node --test web/frontend/tests/*.test.mjs
- name: Install Chromium for isolated UI tests
working-directory: web/frontend
run: npx playwright install --with-deps chromium
- name: Browser regression tests
run: npm run --prefix web/frontend test:ui -- --reporter=line

View File

@ -1,22 +0,0 @@
name: HTTP proxy pool
on:
push:
paths: ['tools/http-framework-test.yaml', 'scripts/test_http_proxy_pool.py', 'requirements.txt', '.github/workflows/http-proxy-pool.yml']
pull_request:
paths: ['tools/http-framework-test.yaml', 'scripts/test_http_proxy_pool.py', 'requirements.txt', '.github/workflows/http-proxy-pool.yml']
permissions:
contents: read
jobs:
proxy-pool:
strategy:
fail-fast: false
matrix:
httpx: ['0.27.0', '0.28.1']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: python -m pip install 'httpx[http2,socks]==${{ matrix.httpx }}' PyYAML
- run: python -m unittest discover -s scripts -p 'test_http_proxy_pool.py' -v

View File

@ -1,28 +0,0 @@
name: Pi runtime
on:
push:
paths: ['runtime/pi/**', 'internal/**', 'cmd/**', 'go.mod', 'go.sum', 'scripts/build-pi-runtime.sh', 'scripts/check-pi-only.sh', '.github/workflows/pi-runtime.yml']
pull_request:
paths: ['runtime/pi/**', 'internal/**', 'cmd/**', 'go.mod', 'go.sum', 'scripts/build-pi-runtime.sh', 'scripts/check-pi-only.sh', '.github/workflows/pi-runtime.yml']
permissions:
contents: read
jobs:
runtime:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.19.0'
cache: npm
cache-dependency-path: runtime/pi/package-lock.json
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: npm ci --ignore-scripts
working-directory: runtime/pi
- run: npm run build && npm test
working-directory: runtime/pi
- run: go run ./cmd/build-runtime
- run: bash scripts/check-pi-only.sh
- run: go test -race ./internal/agentruntime ./internal/multiagent ./internal/knowledge ./internal/workflow

View File

@ -1,28 +0,0 @@
name: Plugin authentication
on:
pull_request:
paths:
- 'plugins/**'
- 'scripts/test-plugin-auth.sh'
- '.github/workflows/plugin-auth.yml'
push:
branches: [main]
paths:
- 'plugins/**'
- 'scripts/test-plugin-auth.sh'
- '.github/workflows/plugin-auth.yml'
permissions:
contents: read
jobs:
auth:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '11'
- run: bash scripts/test-plugin-auth.sh

View File

@ -1,9 +1,9 @@
name: Self-update
on:
push:
paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml']
paths: ['internal/update/**', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/static/js/**', 'web/static/css/style.css', 'web/templates/index.html', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml']
pull_request:
paths: ['internal/update/**', 'internal/app/update_restart*', 'internal/security/auth*', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/frontend/**', 'web/static/app/**', 'web/static/i18n/**', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml']
paths: ['internal/update/**', 'internal/workflow/**', 'internal/config/**', 'internal/handler/**', 'internal/mcp/**', 'cmd/server/**', 'web/static/js/**', 'web/static/css/style.css', 'web/templates/index.html', 'upgrade.sh', 'run.sh', 'go.mod', 'go.sum', '.gitignore', '.github/workflows/self-update.yml']
permissions:
contents: read
jobs:
@ -23,16 +23,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: go test -race ./internal/update ./internal/app ./internal/config ./internal/handler ./cmd/server ./internal/workflow
- name: Authentication and update session handoff
run: go test -race ./internal/security -run '^(TestAuthManager|TestAttachRBACStore|TestRevokeRoleSessions|TestPublishSession|TestRestartHandoff)'
- run: go test -race ./internal/update ./internal/config ./internal/handler ./cmd/server ./internal/workflow
- run: go build ./...
- name: Frontend build and SPA artifacts
- name: Frontend regression tests
shell: bash
run: |
npm ci --prefix web/frontend
npm run --prefix web/frontend build
go test ./internal/app -run TestSPA -count=1
run: node --test web/static/js/*.test.cjs
- name: Shell syntax
shell: bash
run: bash -n run.sh upgrade.sh

6
.gitignore vendored
View File

@ -5,7 +5,6 @@ chat_uploads/
*.db-shm
*.db-wal
*.db-journal
*.instance.lock
*.sqlite
*.sqlite3
@ -24,9 +23,8 @@ config.yaml.backup
# Upgrade / settings backups
.upgrade-backup/
# Agent runtime task boards (including legacy data, under skills_dir)
# Eino runtime task board (under skills_dir)
skills/.eino/
skills/.pi/
# Build outputs
cyberstrike-ai
@ -73,8 +71,6 @@ __pycache__/
# Node / browser extension
node_modules/
/web/frontend/test-results/
/web/frontend/playwright-report/
# macOS / Windows / editors
.DS_Store

View File

@ -1,138 +1,15 @@
# Changelog
## 2026-11-27 · v1.8.2 全局安全底座融合与深度测评增强
- **全局非受信数据隔离与扫描面收敛**:新增 `internal/promptguard` 随机 16 字节(32 位十六进制)Nonce 包络(`[[CSAI_DATA nonce=... field=...]]`),自动中性化目标可控标记词干并支持可选工具回执隔离(`multi_agent.runtime.prompt_guard_tool_results`);新增 `internal/surfaceingest` 结构化解析 `nmap`、`nuclei`、`httpx`、`ffuf` 输出,剥离 URL 凭据、过滤排除范围并通过 `Claim(executionID)` 跨普通 MCP 与深度测评幂等去重入库。
- **确定性漏洞指纹去重与五维对抗复核**:`record_vulnerability`、状态流转、一键复测与深度测评独立复核共享同一套确定性三轴指纹(规范化位置 + 漏洞机制类 + 参数/组件锚点,按 `project_id` / `assessment_id` / `conversation_id` 作用域合并并保留 `force_distinct_reason` 显式拆分)与五维质量校验(可达性、前置条件、可复现性、授权范围、真实影响,区分控制有效拦截与机制不成立),漏洞详情抽屉同步展示结构化复核字段。
- **项目级结构化约束、扫描噪声档位与经验沉淀**:项目 `scope_json` 扩展结构化 `constraints`(`allow` / `deny`)与 `noise_profile`(`off` / `quiet` / `balanced` / `aggressive`),为常用扫描器提供具体速率/并发参数及 `429`/`503` `Retry-After` 退避指引;新增基于回执证据的项目级经验库(`off` / `shadow` / `inject` 三态切换,规则失败时自动撤回淘汰,`inject` 模式下按 `CSAI_DATA` 包络安全注入)。
- **离线安全分类标准与 Pi 提示词缓存前缀拆分**:内置离线 `lookup_security_taxonomy` 工具(打包 OWASP WSTG v4.2、核心 CWE 与 MITRE ATT&CK 技术摘要及来源许可说明);Pi 运行时支持紧凑排序技能索引与 `prompt_cache_prefix_split` 静态角色前缀 / 动态上下文拆分。
- **深度测评目标拆解、覆盖率账本与分段优雅收尾**:新增规划前 `set_goals` / `set_constraints` 控制会话(拦截过程性伪目标、消解指代目标,弱模型解析失败自动单次重试并平滑回退,支持任务级噪声档位覆盖);新增持久化覆盖率账本与计划笔记工具(`record_coverage`、`assessment_coverage_ledger`、`assessment_plan_notes`),识别四类覆盖缺口并在验收门禁(`AcceptanceGate`)阻断未覆盖必测风险类的过早结项(历史无目标任务完全兼容);Pi 执行分段耗尽前提供只读优雅收尾轮次(`WrapupPrompt`),服务端 `BeforeTool` 同步拦截收尾期新扫描与外部命令。
## 2026-11-19 · 前端整体迁移到 React + Semi Design
- Web 界面重写为 Vite 构建的 React 19 单页应用,组件统一使用 Semi Design;页面按 `#/<页面 id>` 路由,
深链接(会话、漏洞、项目、测评、设置分区、MCP 执行、HITL 审批)保持可分享。
- 服务端不再渲染业务模板:`GET /` 直接返回 `web/static/app/index.html`,`/api-docs` 302 到 `/#/api-docs`,
API 文档改为应用内 OpenAPI 浏览器(含在线调试)。
- 复用既有 REST 接口、`cyberstrike-auth` 会话令牌、`cyberstrike-theme` 主题偏好与 `web/static/i18n` 词条;
新增 `src/lib/http.js` 统一注入令牌、错误与 SSE 解析,`components/ui.jsx` 统一页面骨架、表格、指标卡、
Markdown/JSON 视图与抽屉。
- 30 个业务页面 + API 文档全部由 React 组件实现,覆盖对话流式回复与内联审批、深度测评图谱与验收、
资产/漏洞/项目/任务/工作流、WebShell 与 C2、MCP 与 HITL、知识与技能、角色与平台权限、系统设置。
- 新增 `internal/app/spa_test.go` 校验构建产物与入口路由;CI 增加 `frontend-build.yml`,
`self-update.yml` 的前端回归改为构建校验,移除依赖旧模板的 `task-ui.yml` 与浏览器夹具测试。
## 2026-11-15 · 深度测评工作台与完整链路
- 探索图增加主链路/执行记录两种视图,跨页引用和原始上下游分页导航;归档按真实分支分组,重新引用后重新计冷却轮次,漏洞与人工线索保持可见,旧归档链接继续可读。
- 详情默认展示运行概览:规划/验收阶段、活跃意图、工具活动、Pi 原生会话状态、队列数量、最近进展和下次唤醒;无变化时不重建正文,保留定向补充草稿和阅读位置。
- 增加单条意图暂停、继续、优先级和定向补充。独立取消执行上下文,补充持久化后通过 Pi 原生 steer 只发送到目标会话;手动暂停不会被整任务继续或规划器绕过。
- 测评报告补齐当前账号可读的关联漏洞、全部独立复核记录、已保存回执摘录和来源链接;原有批量任务行为保持不变。
## 2026-11-15 · 深度测评开始与整任务暂停
- 开始/继续统一续接原 Pi 会话;暂停同时取消本测评的规划与执行步骤、清除自动重试安排,阻止晚到重试及后台恢复队列覆盖手动暂停。
- 修复正常取消被一律记为结果不明的问题:资源清理后或手动开始时,按同任务、步骤、会话和工具的终态执行回执自动核对。已取消调用保留为错误回执,不计作成功证据;远端未确认和无可靠回执的调用仍需核对。
- 列表与详情保留开始、暂停入口,待核对状态可直接查看相关步骤及回执;概览展示实际状态和重启恢复设置,避免将历史路线误认为正在执行。原批量任务保持不变。
## 2026-11-15 · 大规模探索链路与节点阅读修复
- 修复循环引用将整组节点排成单列的问题;布局只避开回边的层级计算,原始节点、连线和证据保持完整,同层大量节点采用紧凑排列。
- 新增可定位的图缩略导航和关系着色;选中画布外或过小的节点时定位到可读尺度,自动刷新继续保留用户视图。
- 将多个目标资产链接放入详情正文的折叠区,避免固定操作区挤压正文;切换双图时不再继承空白详情栏。
## 2026-11-15 · 深度测评图阅读体验
- 整理任务标题、图工具栏及搜索间距,修复资产搜索焦点边框被裁切和控件挤靠,补充空资产提示。
- 扩大节点详情栏,支持拖动调整和页面内展开阅读;按摘要、执行说明、回执及来源组织内容,刷新保留滚动位置与展开状态。
- 资产节点使用字段式详情,保留原始记录及意图、证据和漏洞跳转;原批量任务逻辑不变。
## 2026-11-15 · 深度测评工作区与归档
- 测评详情改为主内容区的完整工作区,保留深链、漏洞返回及列表筛选;扩大图画布,支持收起节点详情,保持刷新和视图切换后的缩放位置。
- 行尾提供开始/继续、暂停、详情及归档操作;归档保留证据和关联,可筛选、恢复,恢复不自动执行。
- 执行中或结果不明的任务不能归档,归档任务不参与自动恢复;原批量任务逻辑保持不变。
## 2026-11-15 · 简化新建深度测评
- 将允许范围调整为「补充限制与排除项(选填)」,验收条件也标记选填,提供简短说明和示例。
- 两项留空时沿用完整目标,显式填写的内容保持独立;保存草稿与原批量任务行为不变。
## 2026-11-15 · 深度测评关联跳转实机修复
- 定时刷新保留已展开的独立复核记录和探索图来源引用,避免返回链接在阅读时消失。
- 会话失效后重新登录,恢复测评深链定位及当前账号的新建入口;批量任务逻辑保持不变。
## 2026-11-15 · 深度测评双图与意图队列
- 复用现有资产库建立共享资产图,关联测评资产、服务端点及首次执行快照;探索图增加事实、漏洞和来源关系。
- 步骤扩展为持久意图队列,支持资产锚定、优先级、依赖和状态筛选;规划/验收每轮使用新的 Pi 原生会话,worker 继续使用原生恢复与压缩。
- 事实、漏洞和资产变更按持久版本触发重规划,拒绝过时计划与完成结论;新变化可唤醒等待任务,手动暂停保持暂停。
- 测评漏洞登记绑定本意图原始回执,独立复核来自另一意图,追加记录并同步漏洞状态;保留旧漏洞链接和原批量任务行为。
## 2026-11-14 · 深度测评漏洞关联
- 已登记漏洞自动绑定来源测评与步骤,漏洞管理按测评名称分组,支持测评名称搜索及测评 ID 筛选;批量任务的 ID、队列和分组语义保持不变。
- 测评详情新增关联漏洞入口;漏洞详情可跳回具体步骤及复现证据,支持跨分页和刷新定位。
- 补建已有记录的可信来源关联,分别校验漏洞与测评权限;删除测评后保留漏洞及来源快照。
## 2026-11-14 · 持续探索与图记忆
- 深度测评取消任务时间、累计 Token、规划轮数、总步骤及累计分段次数上限;保留用量统计和手动暂停/停止。旧预算耗尽记录迁移为暂停,可直接继续。
- 新增可交互探索图,持久化步骤、观察、执行回执、人工线索和 Pi 原生压缩摘要;冷历史按引用折叠,活跃依赖重新展开,支持按节点检索原文。
- 暂无新进展时保存状态并定时重评,临时模型故障退避后继续;现有任务管理保持不变。
## 2026-11-14 · 深度测评界面统一
- 将深度测评入口移到对话下方,主页面采用整行列表,详情、新建和预算调整统一为右侧抽屉。
- 支持点击遮罩、Esc 与关闭按钮退出当前抽屉,保留原批量任务行为。
## 2026-11-14 · 独立深度测评
- 新增独立深度测评栏目,默认 48 小时任务窗口,持久计划、证据回执、分段续跑、模型故障退避和重启恢复;现有批量任务管理保持不变。
- 复用 Pi 原生会话、压缩、Skills、工具搜索、结构化工具和生命周期接口;工具结果不明时等待核对,阶段结束及预算耗尽不报告为完成。
- 增加隔离恢复测试、真实 Pi SDK 模拟模型集成及独立页面浏览器回归。真实目标的 48 小时效果尚待验收,详见 [深度测评](docs/zh-CN/deep-assessments.md)。
## 2026-11-14 · 恢复批量任务管理
- 按 v1.8.0 恢复批量队列、创建窗口和详情操作,撤回目标任务及后续统一列表与布局改造。
- 保留深度测评移除和 PR #383 关闭状态;不删除已有任务、会话及历史数据,不回退其他模块的修复。
## 2026-11-13 · 任务管理
- 移除深度测评模块;关闭上游 PR #383,保留通用授权及资产归属修复。
- 任务管理新增目标任务:持久计划与依赖、完整 Pi Agent 步骤、有限并发、结果触发再规划、任务内过程检索、独立验收、暂停恢复和补充方向。
- 保留批量队列;目标任务创建为草稿,中断/受阻/预算耗尽与完成分别显示。
## Unreleased
- 当前任务管理恢复批量队列逻辑,见 `docs/zh-CN/task-management.md`。
### Added
- 个人版上下文优化统一采用 #399 的 Pi 自动策略,清理 #367 遗留的摘要、消息和工具输出预算覆盖及辅助请求适配。DeepSeek 输入节省、本地服务窗口检测和已有通道配置兼容继续由自动策略处理。
- 默认 Agent 运行时迁移为 Pi 1.5.2:Go 工具网关继续处理角色、审批、监控与证据;聊天及子代理接入 Pi。新增按源码指纹发布的 Node Worker、流式协议、会话恢复和原生工具检索。部署需 Node.js >=22.19;已删除 Eino 内核、模型适配、桥接和全部依赖,运行时仅支持 Pi。
- Workflow 改用原生 DAG 与版本化检查点,知识库改用自身文档、切分、Embedding 和检索组件。旧 Eino Workflow 检查点无法由新版直接恢复,升级前需完成或导出旧任务,详见 [Pi 迁移说明](docs/zh-CN/pi-runtime.md)。
- 个人仓库正式命名为 `Sycun/CyberStrikeAI`,原上游贡献 fork 改为 `Sycun/CyberStrikeAI-upstream-fork`。新增任务接单、阶段汇报与主动请示的设计调研文档(尚未作为产品功能上线)。
- AI 渠道支持自定义 HTTP 请求头、环境变量和会话 ID 占位符;保存后的鉴权头可安全用于连接测试,独立审计身份隔离主渠道请求头,自定义头不会跟随跨源重定向。
- 系统设置新增代理二级菜单,提供固定出口、代理池、最短切换间隔及凭证脱敏;配置仅注入后续 HTTP 工具进程,不影响 Kali 其他工具和模型 API。`http-framework-test` 新增可选代理池:支持静态/结构化代理列表与供应商接口、粘性/轮询策略、供应商故障静态回退、失败冷却及有界切换;仅自动重放 GET/HEAD/OPTIONS,遵守 429 Retry-After,切换失败时返回响应或错误且不回退直连。附中英文指南与本地 HTTP/HTTPS/SOCKS5 回归测试(#357)。
- 支持通过 `agent.task_timeout_minutes` 配置单代理、多代理、工作流及异步任务执行超时:未配置默认 600 分钟,`0` 表示不限时,负数拒绝加载;续跑保留重新计时行为,单次工具超时仍独立生效。
- 漏洞列表的单条下载按钮新增格式选择弹窗,支持 Markdown 与 Word(.docx),Word 下载复用漏洞读取权限并仅包含所选漏洞(#365)。
- 新增单代理与多代理异步对话 API:接收后返回任务回执,客户端断线不停止执行;支持按用户隔离的幂等提交、持久状态与结果查询、显式取消以及服务重启后的中断状态。同步接口保持兼容。
- 启动时以统一最新 SQLite 定义自动检查全部项目管理表,缺表建表、缺字段补字段,无需维护逐字段迁移列表;保留已有数据和额外表/字段,结构补齐失败回滚并阻止启动。HITL 与通知表纳入统一初始化,历史漏洞外键迁移保留额外列、索引、触发器及依赖记录。
### Fixed
- 修复 WebShell 批量探活因请求构建异常一直停留在“探活中”的问题;使用连接自身 ID 读取已保存凭据,并在探活失败后恢复按钮、继续处理其他连接。
- 修复审计 Agent 向不支持 thinking 字段的兼容网关发起请求失败的问题;支持独立兼容 profile,并按模型和地址识别默认行为。
- 修复已知支持 `none` 的官方 OpenAI 模型在关闭推理后仍使用服务端默认推理的问题(#366):按提供商、端点和模型发送并保留显式关闭参数,覆盖 Planner 和强制工具选择;保留 DeepSeek 与第三方兼容网关行为,并明确提示需要 Responses 的工具调用限制。
- 防止内置管理员失权:拒绝停用内置 `admin` 或移除其系统管理员角色,失败时保留原资料、权限和会话;界面同步禁用对应操作。

527
README.md
View File

@ -1,202 +1,429 @@
<div align="center">
<img src="images/logo.png" alt="CyberStrikeAI" width="144">
<h1>CyberStrikeAI</h1>
<p><strong>Describe goals or tasks, run tool-calling security agents, and record verifiable execution evidence.</strong></p>
<p><a href="README_CN.md">中文</a> · <strong>English</strong></p>
<p>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/pi-runtime.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/pi-runtime.yml/badge.svg?branch=main" alt="Pi runtime CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/deep-assessments.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/deep-assessments.yml/badge.svg?branch=main" alt="Deep assessments CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/frontend-build.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/frontend-build.yml/badge.svg?branch=main" alt="Frontend build CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/self-update.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/self-update.yml/badge.svg?branch=main" alt="Self-update CI"></a>
</p>
<img src="images/logo.png" alt="CyberStrikeAI Logo" width="200" >
</div>
CyberStrikeAI is an open-source cybersecurity agent workbench built with **Go + Pi** (Go backend + React / Semi Design frontend). It unifies interactive security chat, goal-driven **Deep Assessments**, and list-driven **Batch Tasks**, enabling security agents to orchestrate tools and record structured execution evidence.
# CyberStrikeAI
> This repository ([Sycun/CyberStrikeAI](https://github.com/Sycun/CyberStrikeAI)) is forked from the original open-source [AIPentest/CyberStrikeAI](https://github.com/AIPentest/CyberStrikeAI) repository with its full commit history, copyright notices, and [Apache-2.0 License](LICENSE) preserved. Following the upstream project's transition to closed source, this repository is independently maintained and developed as an open-source branch by **[Sycun](https://github.com/Sycun)**, former core maintainer of the official project.
[Key highlights](#highlights) · [Preview](#screenshots) · [Quick start](#quick-start) · [Execution modes](#delegation) · [Capabilities](#capabilities) · [Architecture](#architecture) · [Documentation](#documentation) · [Feedback](#contributing)
[中文](README_CN.md) | [English](README.md)
<a id="highlights"></a>
**The system of action for AI-native cybersecurity—where intent becomes governed execution, evidence becomes operational memory, and every operation improves the next.**
## Key highlights
CyberStrikeAI connects planning, execution, human oversight, evidence, and replay in one auditable workspace. Built in Go, it combines Eino-powered agents, MCP-native tools, RAG knowledge, visual workflows, and attack-chain modeling and analysis for authorized security operations.
- **Native Pi 1.7.0 agent runtime**: Powered by native Pi session persistence, automatic context compaction, live mid-run steering (**Interrupt & continue**), and configurable reasoning-effort controls, with legacy Eino engine dependencies completely removed.
- **Goal-driven Deep Assessments workbench**: Long-running autonomous assessments backed by a shared project **Attack-Surface Graph**, hot/cold archived **Exploration Graph**, prioritized **Intent Queue**, and receipt-backed **Facts & Acceptance Evidence Matrix**.
- **React 19 + Semi Design workbench**: Modern single-page interface featuring unified detail drawers, project-grouped conversations, compact model/role pickers, domain/host/task vulnerability views, and **one-click vulnerability retesting**.
- **Multi-gateway compatibility & adaptive context**: Supports custom per-channel auth headers (same-origin guarded for third-party gateways), automatic runtime context-window probing, `local_auto` profiles for local inference servers (oMLX, Ollama, etc.), DeepSeek economy profiles, and dedicated HITL review model testing.
- **Isolated HTTP proxy pool & self-hosted operations**: Provides an [HTTP testing proxy pool with failover](docs/en-US/http-proxy-pool.md) isolated from model API traffic, supervisor-free **One-Click Update** preserving self-signed TLS certs and active sessions, plus previewable **Storage Cleanup**.
**Start here:** [Quick start](#quick-start-one-command-deployment) · [Documentation](docs/en-US/README.md) · [Security hardening](docs/en-US/security-hardening.md)
<a id="screenshots"></a>
> [!IMPORTANT]
> Use CyberStrikeAI only on systems you own or are explicitly authorized to test. For shared or production environments, review the [security model](docs/en-US/security-model.md) and [hardening guide](docs/en-US/security-hardening.md) before enabling high-risk tools, WebShell, or C2 capabilities.
## Workbench preview
## Interface & Integration Preview
| Dashboard (Risk distribution & live metrics) | Deep Assessments (Dark theme · Goals & progress) |
| :---: | :---: |
| ![Dashboard](images/dashboard.png) | ![Deep Assessments Dark Theme](images/dark.png) |
<div align="center">
| Deep Assessments · Exploration Graph (Intents, facts, findings & archive) | Chat Console (Project groups, tool receipts & summary) |
| :---: | :---: |
| ![Exploration Graph](images/deep-assessment-graph.png) | ![Chat Console](images/web-console.png) |
### System Dashboard Overview
| Vulnerability Management (Domain/host tree & severity overview) | MCP & Tool Management (External MCP status & built-in tools) |
| :---: | :---: |
| ![Vulnerability Management](images/vulnerability-management.png) | ![MCP Management](images/mcp-management.png) |
<table>
<tr>
<td width="50%" align="center">
<strong>Light Mode</strong><br/>
<img src="./images/dashboard.png" alt="System Dashboard (Light)" width="100%">
</td>
<td width="50%" align="center">
<strong>Dark Mode</strong><br/>
<img src="./images/dark.png" alt="System Dashboard (Dark)" width="100%">
</td>
</tr>
</table>
<a id="quick-start"></a>
## Quick start
### 1. Prepare the environment
| Dependency | Requirement | Purpose |
| --- | --- | --- |
| Go | 1.25+; see [go.mod](go.mod) | Build the backend server and runtime builder |
| Node.js and npm | Node.js 22.19+ | Build and run the Pi worker (and optional frontend rebuilds) |
| Python | 3.10+, with `venv` support | Launcher and Python tool dependencies |
| Git | Available on `PATH` | Clone source and run Web one-click updates |
You also need a model channel that supports tool calling, plus the local security tools or external MCP servers required by your tasks. The repository includes tool recipes, **not preinstalled third-party security binaries**. By default, `run.sh` configures temporary Go and PyPI mirrors for faster setup; set `GOPROXY` and `PIP_INDEX_URL` in your environment to override them.
### 2. Clone and start
Run the following commands in Bash on macOS or Linux:
```bash
git clone --branch main https://github.com/Sycun/CyberStrikeAI.git
cd CyberStrikeAI
cp config.example.yaml config.yaml
```
For local trials, set `server.host` in `config.yaml` to `127.0.0.1`, then start the server:
```bash
bash run.sh --http
```
The script builds the Pi worker, creates a Python virtual environment, installs dependencies, and compiles the Go server (prebuilt frontend assets are already included under `web/static/app/`). Open [http://127.0.0.1:8080/](http://127.0.0.1:8080/) by default, or check your terminal output for the active port.
Without `--http`, `run.sh` starts with HTTPS + HTTP/2 and generates a reusable local self-signed certificate when none is configured. For shared team deployments, see the [deployment guide](docs/en-US/deployment.md) for bind addresses, TLS certificates, and access controls.
### 3. Complete the initial setup
1. Sign in with the initial `admin` password printed under `ADMIN SETUP REQUIRED` in the terminal, then change it.
2. Go to **System settings → Basic → AI channel config**, enter your provider, Base URL, API key, and model, then save it as the default channel (values in `config.example.yaml` are placeholders).
3. Install the local tools needed for your engagement or connect external MCP servers, and verify each tool before assigning it to an agent role.
4. For multi-user deployments, create separate member accounts, roles, and project scopes under **Platform Access → Add Member**.
Use [config.example.yaml](config.example.yaml) as the full reference. See [configuration](docs/en-US/configuration.md) and [configuration profiles](docs/en-US/configuration-profiles.md) for model channels, local models, and context sizing.
*The dashboard provides a comprehensive overview of system runtime status, security vulnerabilities, tool usage, and knowledge base, helping users quickly understand the platform's core features and current state.*
<details>
<summary><strong>Manual build and frontend customization</strong></summary>
<summary><strong>More interface screenshots</strong></summary>
After preparing `config.yaml`, you can build the Pi worker and Go server step by step:
### Core Features Overview
```bash
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
./cyberstrike-ai -config config.yaml --http
```
If you modify frontend source files under `web/frontend/`, rebuild the static bundle before starting the server:
```bash
cd web/frontend && npm ci && npm run build
```
Deployments require the runtime directory, `web/static/`, and a matching Pi worker bundle (or a fresh build on the target host); copying the Go binary alone is not sufficient to run agents. Prepare Python tool dependencies separately. See the [Pi runtime guide](docs/en-US/pi-runtime.md).
<table>
<tr>
<td width="33.33%" align="center">
<strong>Web Console</strong><br/>
<img src="./images/web-console.png" alt="Web Console" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Task Management</strong><br/>
<img src="./images/task-management.png" alt="Task Management" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Vulnerability Management</strong><br/>
<img src="./images/vulnerability-management.png" alt="Vulnerability Management" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>WebShell Management</strong><br/>
<img src="./images/webshell-management.png" alt="WebShell Management" width="100%">
</td>
<td width="33.33%" align="center">
<strong>MCP Management</strong><br/>
<img src="./images/mcp-management.png" alt="MCP management" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Knowledge Base</strong><br/>
<img src="./images/knowledge-base.png" alt="Knowledge Base" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>Skills Management</strong><br/>
<img src="./images/skills.png" alt="Skills Management" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Agent Management</strong><br/>
<img src="./images/agent-management.png" alt="Agent Management" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Role Management</strong><br/>
<img src="./images/role-management.png" alt="Role Management" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>System Settings</strong><br/>
<img src="./images/settings.png" alt="System settings" width="100%">
</td>
<td width="33.33%" align="center">
<strong>MCP stdio Mode</strong><br/>
<img src="./images/mcp-stdio2.png" alt="MCP stdio mode" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Burp Suite Plugin</strong><br/>
<img src="./images/plugins.png" alt="Burp Suite plugin" width="100%">
</td>
</tr>
</table>
</details>
<a id="delegation"></a>
</div>
## Execution modes
## Highlights
CyberStrikeAI provides three complementary ways to run security work over a shared project asset library, tool permissions, and vulnerability records:
### Agents and orchestration
- **Chat**: Interactive investigation and ad-hoc tool execution across single-agent, Deep, Plan-Execute, and Supervisor modes, with project-grouped conversations and live mid-run steering via **Interrupt & continue**.
- **Deep Assessments**: Goal-driven persistent assessment workbench powered by native Pi sessions. Maintains attack-surface graphs, exploration graphs, prioritized intent queues, in-task operator Q&A, and receipt-backed acceptance criteria across pause/resume cycles. See the [deep assessments guide (zh-CN)](docs/zh-CN/deep-assessments.md).
- **Tasks (Task Management)**: Queue-based batch execution for explicit task lists. Open **Tasks → New task** (`Task Management`), enter one task per line, and configure project scope, role, agent mode, tool approval, concurrency, and optional Cron schedules. Inspect per-subtask results and conversations, or pause, resume, and edit subtasks from the queue detail view. See [batch task management (zh-CN)](docs/zh-CN/task-management.md).
- 🤖 **Agentic execution** translates natural-language intent into governed, auditable security actions.
- 🧩 **Eino orchestration** supports single-agent execution plus Deep, Plan-Execute, and Supervisor multi-agent modes.
- 🔀 **Graph workflows** combine Agents, tools, conditions, approvals, and outputs into reusable flows.
- 🎭 **Role-based testing** provides focused prompts and tool policies for common security scenarios.
<a id="capabilities"></a>
### Tools and knowledge
## Capabilities
- 🧰 **Security tools** include 100+ curated YAML recipes with custom extensions and role-scoped access.
- 🔌 **MCP integration** supports HTTP, stdio, SSE, external federation, and dynamic tool discovery.
- ⏱️ **Resilient tool execution** runs blocking MCP/tool calls in workers with bounded agent waits, resumable `execution_id` polling, cancellation, per-server circuit breakers, concurrency limits, and unified output caps.
- 🎯 **Agent Skills** follow the standard Skill layout and support progressive, on-demand loading.
- 📚 **Knowledge base** combines query rewriting, vector retrieval, reranking, and result post-processing.
- 🖼️ **Vision analysis** uses a separate vision model for screenshots, captchas, and UI while retaining text summaries only.
| Capability | What it provides | Details |
| --- | --- | --- |
| Pi agent orchestration | Single-agent, Deep, Plan-Execute, and Supervisor modes with live steering and reasoning controls | [Agents and roles](docs/en-US/agent-and-role-guide.md) |
| Deep assessments | Goal-driven planning, shared attack-surface graph, hot/cold exploration graph, intent queues, and acceptance matrix | [Deep assessments (zh-CN)](docs/zh-CN/deep-assessments.md) |
| Batch task queues | Concurrent task lists, Cron schedules, pause/resume, and subtask conversation logs | [Task management (zh-CN)](docs/zh-CN/task-management.md) |
| Tools, skills, and proxy pool | YAML tool recipes, MCP connections, on-demand skills, and isolated HTTP egress proxy pool | [Tools](tools/README_EN.md) · [Skills](skills/README.md) · [Proxy pool](docs/en-US/http-proxy-pool.md) |
| Visual workflows | Compose agent, tool, conditional, and human-approval nodes | [Workflows](docs/en-US/workflow-graph.md) |
| Knowledge, evidence, and reports | RAG retrieval, project facts, raw tool receipts, attack-chain analysis, and Word / Markdown reports | [Knowledge base](docs/en-US/knowledge-base.md) · [Reports](docs/en-US/word-reports.md) |
| Project & vulnerability workspace | Project-scoped asset library, domain/host/task vulnerability views, and one-click retesting | [Asset management](docs/en-US/asset-management.md) |
| Human oversight & governance | RBAC, human-in-the-loop (HITL) approvals, call guards, audit logs, and token monitoring | [Security model](docs/en-US/security-model.md) · [HITL](docs/en-US/hitl-best-practices.md) · [Token usage](docs/en-US/token-usage-monitoring.md) |
| Integrations | Burp Suite extension, browser DevTools extension, chat bots, and MCP federation | [Plugins](#integrations) · [Bots](docs/en-US/robot.md) · [MCP](docs/en-US/mcp-federation.md) |
### Governance and audit
Specialized operations also include [WebShell management](docs/en-US/webshell.md) and [C2](docs/en-US/c2.md). Enable only the capabilities required for your authorized scope; a bundled tool recipe does not imply the underlying binary is installed or validated in your environment.
- 🧑‍⚖️ **Human in the loop** provides approval modes, tool allowlists, audit-agent review, and traceable decisions.
- 🛡️ **Call blocking** under Security adds configurable regex checks before MCP execution, reminder templates, and dry runs, with government-domain protection enabled by default. See [Tool call blocking](docs/en-US/tool-call-guard.md).
- 🔐 **Platform RBAC** supports multiple users, system and custom roles, scoped permissions, ownership, and explicit assignments.
- 🔒 **Security and audit** provide authenticated access, audit logs, SQLite persistence, and operational evidence retention.
- 📄 **Result governance** stores the same capped tool result seen by the agent, protects resume paths from oversized historical output, and adds UI safeguards for large detail views. See [Tool Execution Governance](docs/en-US/tool-execution-governance.md).
<a id="architecture"></a>
### Security operations
## Architecture
- 📁 **Conversation management** provides pinning, renaming, and batch organization.
- 📂 **Projects and attack chains** connect cross-session facts, risk scoring, graph views, and step-by-step replay.
- 🗂️ **Asset management** normalizes and deduplicates domains, IP addresses, ports, and services; supports XLSX/CSV import and export, advanced filters and saved views, ownership and business metadata, cross-page bulk maintenance, and duplicate merging; and tracks scan coverage, linked vulnerabilities, and risk state. See the [Asset Management guide](docs/en-US/asset-management.md).
- 🛡️ **Vulnerability management** provides severity classification, lifecycle tracking, filtering, and statistics.
- 📋 **Batch tasks** provide queued execution, editing, status tracking, and retained results.
- 📱 **Chatbots** connect Personal WeChat, WeCom, DingTalk, Lark, Telegram, Slack, Discord, and QQ Bot.
| Component | Responsibility |
| --- | --- |
| **Go server and schedulers** | HTTP/SSE APIs, deep-assessment and batch-queue scheduling, tool governance, storage cleanup, and evidence persistence |
| **Pi runtime** | **Pi 1.7.0** model interaction, agent tool loops, native session persistence, compaction, steering, and tool discovery |
| **Tool gateway** | Dispatches local tools and MCP calls under role boundaries, permissions, HITL approvals, and output/timeout guards |
| **SQLite and Pi sessions** | Business state, graph nodes, and raw tool receipts in SQLite; model transcripts and compaction entries in Pi sessions |
| **Web workbench** | React 19 + Semi Design + Cytoscape frontend unifying chat, assessment graphs, task traces, and project assets |
### Authorized security operations
<a id="integrations"></a>
- 🐚 **WebShell management** provides connection management, a virtual terminal, file operations, and AI-assisted workflows.
- 📡 **Built-in C2** provides listeners, encrypted beacons, sessions, task queues, payload helpers, and live events.
## Browser and proxy plugins
> WebShell, C2, and other high-risk capabilities are for systems you own or are explicitly authorized to test. See the [security model](docs/en-US/security-model.md) and [hardening guide](docs/en-US/security-hardening.md).
| Integration | Usage | Documentation and package |
| --- | --- | --- |
| Burp Suite | Send selected HTTP requests to CyberStrikeAI for analysis | [Setup](plugins/burp-suite/cyberstrikeai-burp-extension/README.md) · [JAR](plugins/burp-suite/cyberstrikeai-burp-extension/dist/cyberstrikeai-burp-extension.jar) |
| Chrome / Edge | Capture and forward requests from the CyberStrikeAI DevTools panel | [Setup](plugins/browser-extension/cyberstrikeai-browser-extension/README.md) · [ZIP](plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip) |
## Plugins
## Updates and version migration
CyberStrikeAI includes optional integrations under `plugins/`.
Fresh installations using [config.example.yaml](config.example.yaml) point updates to this repository by default:
- **Burp Suite extension**: `plugins/burp-suite/cyberstrikeai-burp-extension/`
Build output: `plugins/burp-suite/cyberstrikeai-burp-extension/dist/cyberstrikeai-burp-extension.jar`
Docs: `plugins/burp-suite/cyberstrikeai-burp-extension/README.md`
- **Browser extension (Chrome / Edge)**: `plugins/browser-extension/cyberstrikeai-browser-extension/`
Capture Network traffic in DevTools and send it to CyberStrikeAI for AI-assisted security testing—aligned with the Burp plugin.
Install: `chrome://extensions/` → Load unpacked → F12 → **CyberStrikeAI** tab
Package output: `plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip`
Docs: `plugins/browser-extension/cyberstrikeai-browser-extension/README.md` / `README.zh-CN.md`
```yaml
update:
repo: https://github.com/Sycun/CyberStrikeAI
## Tool Overview
CyberStrikeAI ships with 100+ curated tools covering the whole kill chain:
<details>
<summary><strong>View the complete tool categories</strong></summary>
- **Network Scanners** – nmap, masscan, rustscan, arp-scan, nbtscan
- **Web & App Scanners** – sqlmap, nikto, dirb, gobuster, feroxbuster, ffuf, httpx
- **Vulnerability Scanners** – nuclei, wpscan, wafw00f, dalfox, xsser
- **Subdomain Enumeration** – subfinder, amass, findomain, dnsenum, fierce
- **Network Space Search Engines** – fofa_search, zoomeye_search, quake_search, shodan_search
- **API Security** – graphql-scanner, arjun, api-fuzzer, api-schema-analyzer
- **Container Security** – trivy, clair, docker-bench-security, kube-bench, kube-hunter
- **Cloud Security** – prowler, scout-suite, cloudmapper, pacu, terrascan, checkov
- **Binary Analysis** – gdb, radare2, ghidra, objdump, strings, binwalk
- **Exploitation** – metasploit, msfvenom, pwntools, ropper, ropgadget
- **Password Cracking** – hashcat, john, hashpump
- **Forensics** – volatility, volatility3, foremost, steghide, exiftool
- **Post-Exploitation** – linpeas, winpeas, mimikatz, bloodhound, impacket, responder
- **CTF Utilities** – stegsolve, zsteg, hash-identifier, fcrackzip, pdfcrack, cyberchef
- **System Helpers** – exec, create-file, delete-file, list-files, modify-file
</details>
See [tools/README_EN.md](tools/README_EN.md) for tool definitions, customization, and usage notes.
## Basic Usage
### Quick Start (One-Command Deployment)
**Prerequisites:**
- Go 1.25+ ([Install](https://go.dev/dl/); required by `go.mod`)
- Python 3.10+ ([Install](https://www.python.org/downloads/))
**One-Command Deployment:**
```bash
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
cd CyberStrikeAI
chmod +x run.sh && ./run.sh
```
When migrating an older installation, ensure `update.repo` is set to `https://github.com/Sycun/CyberStrikeAI` in `config.yaml` or under **System settings → One-Click Update** (leaving `update.repo` empty still points to the historical upstream URL, which no longer publishes open-source updates). One-click update pulls the latest source, rebuilds a matching Pi worker and server binary, and preserves existing self-signed TLS certificates and active sessions; see [deployment](docs/en-US/deployment.md) for details.
The `run.sh` script will automatically:
- ✅ Check and validate Go & Python environments
- ✅ Create Python virtual environment
- ✅ Install Python dependencies
- ✅ Download Go dependencies
- ✅ Build the project
- ✅ Start the server
Before upgrading from an older Eino-based release, back up your configuration and database and finish or export active workflow runs: **legacy Eino binary workflow checkpoints cannot be resumed in this version**. Historical records, configuration keys, and compatibility routes remain readable, with no legacy-engine fallback switch. See the [Pi runtime and migration guide](docs/en-US/pi-runtime.md).
**Verify the startup:**
## Validation and scope
1. Confirm the terminal displays `● ONLINE` followed by the actual Web UI URL.
2. Open that URL; the default HTTPS mode uses a local self-signed certificate, so accept the browser warning once.
3. On a new installation, store the one-time `admin` password shown under `ADMIN SETUP REQUIRED`, sign in, and change it immediately.
Continuous integration covers Go backend tests, Pi runtime protocol checks, frontend builds, process isolation, HTTP proxy pool tests, and isolated regressions for deep assessments and batch queues; check [GitHub Actions](https://github.com/Sycun/CyberStrikeAI/actions) for current status. Automated checks do not replace live evaluation—model compatibility, token cost, and effectiveness on real targets depend on your configured model channel and environment.
**Networking defaults:** `run.sh` starts the server with **`--https`** and the repo **`config.yaml`** (local self-signed TLS; better for many concurrent streams). Use **`./run.sh --http`** for plain HTTP. In production, set **`server.tls_cert_path`** / **`server.tls_key_path`** in **`config.yaml`** (see comments there). For manual runs, add **`--https`** or **`CYBERSTRIKE_HTTPS=1`**; if **`-config`** is wrong, the binary prints a short usage hint on stderr.
<a id="documentation"></a>
**First-Time Configuration:**
1. **Configure AI channels** (required before first use)
- After launch, open **`https://127.0.0.1:8080/`** (or **`https://localhost:8080/`**; replace **8080** with `server.port` in `config.yaml`) and accept the self-signed certificate warning once. If you used `./run.sh --http`, use **`http://`** instead.
- Go to `System Settings` → `Basic Settings` → `AI Channel Configuration`, add or edit a channel, then fill in provider, Base URL, API key, model, and token limits. Click **Save changes**. The left channel list supports setting a default, copy, delete, and bulk probe.
```yaml
ai:
default_channel: openai-main
channels:
openai-main:
name: OpenAI Main
provider: openai_compatible
api_key: "${OPENAI_API_KEY}"
base_url: "https://api.openai.com/v1" # or https://api.deepseek.com/v1
model: "gpt-4o" # or deepseek-chat, qwen3-max, etc.
max_total_tokens: 120000
max_completion_tokens: 16384
```
- Or edit `config.yaml` directly before launching. `ai.default_channel` is used for new conversations and tasks that do not explicitly select a channel; the chat page can also select any saved channel per session.
2. **Login** - On first startup the console prints an auto-generated initial `admin` password; create accounts from **Platform permissions → User management**
3. **Install security tools (optional)** - Install tools from `tools/` as needed; missing tools are skipped or substituted at runtime. Common examples:
## Documentation
**macOS (Homebrew):**
```bash
brew install nmap masscan sqlmap nikto gobuster ffuf hydra hashcat nuclei subfinder
```
| What you want to do | Start here |
| --- | --- |
| Deploy and configure models | [Deployment](docs/en-US/deployment.md) · [Configuration](docs/en-US/configuration.md) · [Config profiles](docs/en-US/configuration-profiles.md) · [Troubleshooting](docs/en-US/troubleshooting.md) |
| Run assessments and batch queues | [Deep assessments (zh-CN)](docs/zh-CN/deep-assessments.md) · [Task management (zh-CN)](docs/zh-CN/task-management.md) |
| Customize agents, tools, and proxies | [Pi runtime](docs/en-US/pi-runtime.md) · [Agents and roles](docs/en-US/agent-and-role-guide.md) · [Tool recipes](tools/README_EN.md) · [HTTP proxy pool](docs/en-US/http-proxy-pool.md) |
| Integrate external systems | [API reference](docs/en-US/api-reference.md) · [API examples](docs/en-US/api-recipes.md) · [MCP federation](docs/en-US/mcp-federation.md) |
| Operate a team service | [Security hardening](docs/en-US/security-hardening.md) · [Tool governance](docs/en-US/tool-execution-governance.md) · [Runbooks](docs/en-US/runbooks.md) |
| Contribute and explore the repo | [Developer guide](docs/en-US/developer-guide.md) · [Testing](docs/en-US/testing.md) · [Repository guide](docs/REPOSITORY_GUIDE.md) |
**Linux (Kali / Debian / Ubuntu):**
```bash
sudo apt update
sudo apt install -y nmap masscan sqlmap nikto gobuster hydra hashcat john binwalk
# On some distros, install ffuf/nuclei/subfinder via go install or upstream docs
```
Browse all topics in the [English documentation](docs/en-US/README.md) or the [bilingual index](docs/README.md).
See the `tools/` directory for the full list; refer to each tool's official docs for install details.
<a id="contributing"></a>
**Alternative Launch Methods:**
```bash
# Direct Go run (set up env yourself); add --https to match run.sh defaults
go run ./cmd/server --https
## Feedback and contributions
# Manual build
go build -o cyberstrike-ai ./cmd/server
./cyberstrike-ai --https
```
As an independently maintained open-source branch, community bug reports, feature requests, and pull requests (including tool recipes, UX refinements, and regression tests) are welcome in [Issues](https://github.com/Sycun/CyberStrikeAI/issues) and Pull Requests. When reporting issues, please include the commit hash, OS, model protocol/channel type, reproduction steps, and redacted logs—never upload live API keys, credentials, or sensitive engagement data.
If server logs show `client sent an HTTP request to an HTTPS server`, a client is still using **`http://`** on a TLS-only port—switch the URL to **`https://`**.
Thanks to the original authors and past contributors of the earlier open-source [AIPentest/CyberStrikeAI](https://github.com/AIPentest/CyberStrikeAI) project, as well as the Pi, MCP, and broader open-source communities.
**Note:** The Python virtual environment (`venv/`) is automatically created and managed by `run.sh`. Tools that require Python (like `api-fuzzer`, `http-framework-test`, etc.) will automatically use this environment.
## License and intended use
### Upgrade and Compatibility
Licensed under the [Apache License 2.0](LICENSE) with the original commit history and copyright notices preserved; third-party components retain their respective licenses and notices. Use this software only on systems you own or have explicit written authorization to test, in compliance with your agreed scope and applicable law. See [SECURITY.md](SECURITY.md) for vulnerability reporting.
**Prefer the platform's own one-click update** (console System settings -> One-click update, or
`./cyberstrike-ai -update` / `-check-update` / `-update-rollback`): it pulls the newest commit of the
**update source repository**'s default branch (the official repository by default; one setting points
it at your own fork or a mirror), fast-forwards, rebuilds and swaps the binary atomically, keeps your
`roles/skills/tools/agents/data/config.yaml` untouched (the result names every file it kept; only
`config.yaml`'s `version` field is synced to the new code, so the header badge matches it), and
refuses - rather than overwrites - when source is modified locally or the local history has diverged.
See the [deployment guide](docs/en-US/deployment.md).
`upgrade.sh` still works: when this directory is a git work tree it is a thin shell over the command
above; only a non-git (tarball) installation falls back to the old "download a GitHub Release and
rsync it in" path, where the source repository comes from `--repo owner/name` or `GITHUB_REPO` and the
built-in default applies only when neither is given (with a warning naming the repository).
The update source is one setting, a repository address in the `update` section of `config.yaml` or
right on the console page - the official repository, your own fork, or somebody else's fork. An
installation unpacked from a Release archive (no git) can be previewed and connected from the same
page and updates in one click from then on.
**CyberStrikeAI upgrade script:**
1. (First time) enable the script: `chmod +x upgrade.sh`
2. Upgrade with: `./upgrade.sh` (optional flags: `--check`, `--tag vX.Y.Z`, `--repo owner/name`, `--no-venv`, `--yes`). Local `tools/`, `roles/`, `skills/` and `agents/` are always preserved.
3. The script will back up your `config.yaml` and `data/`, upgrade the code, update `config.yaml`'s `version`, then restart the server.
Recommended one-liner:
`chmod +x upgrade.sh && ./upgrade.sh --yes`
If something goes wrong: inside a git work tree just run `./cyberstrike-ai -update-rollback` (back to
the commit and binary kept before that update); for a tarball installation restore from
`.upgrade-backup/` (or manually copy `data/` and `config.yaml` back) and run `./run.sh` again.
Requirements / tips (tarball path only):
* You need `curl` or `wget` for downloading Release packages.
* `rsync` is recommended/required for the safe code sync.
* If GitHub API rate-limits you, set `export GITHUB_TOKEN="..."` before running `./upgrade.sh`.
⚠️ **Before upgrading:** review the target release notes for configuration, database, and API changes. Backups are required even for patch upgrades; a version number alone is not a compatibility guarantee.
## Configuration
Use [`config.example.yaml`](config.example.yaml) as the authoritative configuration template and copy only the values required for your environment. At minimum, configure the server and one AI channel:
```yaml
server:
host: "127.0.0.1"
port: 8080
ai:
default_channel: openai-main
channels:
openai-main:
provider: openai_compatible
api_key: "${OPENAI_API_KEY}"
base_url: "https://api.openai.com/v1"
model: "your-model"
```
`openai` is a backward-compatible runtime field; maintain new model settings in `ai.channels`. Do not commit real credentials. Review the [configuration reference](docs/en-US/configuration.md), [recommended profiles](docs/en-US/configuration-profiles.md), and [security hardening guide](docs/en-US/security-hardening.md) before exposing the service beyond localhost.
## Related documentation
- **New users:** [Deployment](docs/en-US/deployment.md) → [Configuration](docs/en-US/configuration.md) → [Troubleshooting](docs/en-US/troubleshooting.md)
- **Operators:** [Configuration profiles](docs/en-US/configuration-profiles.md) → [Security hardening](docs/en-US/security-hardening.md) → [Runbooks](docs/en-US/runbooks.md)
- **Integrators:** [API reference](docs/en-US/api-reference.md) → [API recipes](docs/en-US/api-recipes.md) → [MCP federation](docs/en-US/mcp-federation.md)
- **Contributors:** [Developer guide](docs/en-US/developer-guide.md) → [Testing](docs/en-US/testing.md) → [Contributing](docs/en-US/contributing-guide.md)
- **All topics:** [English documentation](docs/en-US/README.md) · [Bilingual documentation index](docs/README.md)
## Project Layout
```
CyberStrikeAI/
├── cmd/ # Server, MCP stdio entrypoints, tooling
├── internal/ # Agent, MCP core, handlers, C2 (`internal/c2`), security executor
├── web/ # Static SPA + templates
├── tools/ # YAML tool recipes (100+ examples provided)
├── roles/ # Role configurations (12+ predefined security testing roles)
├── skills/ # Agent Skills dirs (SKILL.md + optional files; demo: cyberstrike-eino-demo)
├── agents/ # Multi-agent Markdown (orchestrator.md + sub-agent *.md)
├── docs/ # Topic docs (deployment, config, security, API, knowledge base, C2, WebShell, etc.)
├── images/ # Docs screenshots & diagrams
├── config.yaml # Runtime configuration
├── run.sh # Convenience launcher
└── README*.md
```
## Basic Usage Examples
```
Scan open ports on 192.168.1.1
Perform a comprehensive port scan on 192.168.1.1 focusing on 80,443,22
Check if https://example.com/page?id=1 is vulnerable to SQL injection
Scan https://example.com for hidden directories and outdated software
Enumerate subdomains for example.com, then run nuclei against the results
```
## Advanced Playbooks
```
Load the recon-engagement template, run amass/subfinder, then brute-force dirs on every live host.
Use external Burp-based MCP server for authenticated traffic replay, then pass findings back for graphing.
Compress the 5 MB nuclei report, summarize critical CVEs, and attach the artifact to the conversation.
Build an attack chain for the latest engagement and export the node list with severity >= high.
```
## 404Starlink
<img src="./images/404StarLinkLogo.png" width="30%">
CyberStrikeAI has joined [404Starlink](https://github.com/knownsec/404StarLink)
## TCH Top-Ranked Intelligent Pentest Project
<div align="left">
<a href="https://zc.tencent.com/competition/competitionHackathon?code=cha004" target="_blank">
<img src="./images/tch.png" alt="TCH Top-Ranked Intelligent Pentest Project" width="30%">
</a>
</div>
---
## Community and Support
- Join the community on [Discord](https://discord.gg/8PjVCMu8Zw).
<details>
<summary><strong>WeCom group</strong></summary>
<img src="./images/wecom-group-cyberstrikeai-qr.png" alt="CyberStrikeAI WeCom group QR code" width="280">
</details>
## License
CyberStrikeAI is licensed under the Apache License 2.0.
See the [LICENSE](LICENSE) file for details.
---
## ⚠️ Disclaimer
**This tool is for educational and authorized testing purposes only!**
CyberStrikeAI is a professional security testing platform designed to assist security researchers, penetration testers, and IT professionals in conducting security assessments and vulnerability research **with explicit authorization**.
**By using this tool, you agree to:**
- Use this tool only on systems where you have clear written authorization
- Comply with all applicable laws, regulations, and ethical standards
- Take full responsibility for any unauthorized use or misuse
- Not use this tool for any illegal or malicious purposes
**The developers are not responsible for any misuse!** Please ensure your usage complies with local laws and regulations, and that you have obtained explicit authorization from the target system owner.
For vulnerability reporting and deployment hardening guidance, see [SECURITY.md](SECURITY.md).
---
Need help or want to contribute? Open an issue or PR—community tooling additions are welcome!

View File

@ -1,202 +1,420 @@
<div align="center">
<img src="images/logo.png" alt="CyberStrikeAI" width="144">
<h1>CyberStrikeAI</h1>
<p><strong>描述目标或任务,驱动安全智能体调用工具并沉淀可核查的执行证据。</strong></p>
<p><strong>中文</strong> · <a href="README.md">English</a></p>
<p>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/pi-runtime.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/pi-runtime.yml/badge.svg?branch=main" alt="Pi runtime CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/deep-assessments.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/deep-assessments.yml/badge.svg?branch=main" alt="Deep assessments CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/frontend-build.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/frontend-build.yml/badge.svg?branch=main" alt="Frontend build CI"></a>
<a href="https://github.com/Sycun/CyberStrikeAI/actions/workflows/self-update.yml"><img src="https://github.com/Sycun/CyberStrikeAI/actions/workflows/self-update.yml/badge.svg?branch=main" alt="Self-update CI"></a>
</p>
<img src="images/logo.png" alt="CyberStrikeAI Logo" width="200">
</div>
CyberStrikeAI 是基于 **Go + Pi** 构建的开源网络安全智能体工作台(Go 后端 + React / Semi Design 前端),统一承载交互式安全对话、目标驱动的**深度测评**与清单驱动的**批量任务**,由智能体编排调用安全工具并沉淀结构化执行证据。
# CyberStrikeAI
> 本仓库([Sycun/CyberStrikeAI](https://github.com/Sycun/CyberStrikeAI))Fork 自原开源仓库 [AIPentest/CyberStrikeAI](https://github.com/AIPentest/CyberStrikeAI),完整保留原始提交历史、版权声明与 [Apache-2.0 许可证](LICENSE)。在原官方项目转向闭源后,本仓库由原官方核心维护者 **[Sycun](https://github.com/Sycun)** 作为独立开源分支继续维护与演进。
[中文](README_CN.md) | [English](README.md)
[核心特性](#highlights) · [界面预览](#screenshots) · [快速上手](#quick-start) · [任务与测评模式](#delegation) · [主要能力](#capabilities) · [架构](#architecture) · [文档](#documentation) · [反馈与贡献](#contributing)
**CyberStrikeAI 是 AI 原生网络安全的智能执行中枢——让意图转化为受治理的行动,让证据沉淀为运营记忆,并让每次行动优化下一次行动。**
<a id="highlights"></a>
CyberStrikeAI 将规划、执行、人工监督、证据与复盘连接在同一个可审计工作空间中。项目基于 Go 构建,融合 Eino 智能体、MCP 原生工具、RAG 知识、可视化工作流以及攻击链建模与分析能力,面向已获得明确授权的安全任务。
## 核心特性
**从这里开始:** [快速上手](#快速上手一条命令部署) · [中文文档](docs/zh-CN/README.md) · [安全加固](docs/zh-CN/security-hardening.md)
- **Pi 1.7.0 原生智能体运行时**:全面采用原生 Pi 会话持久化、自动上下文压缩(Compaction)、执行中实时「中断并继续(Steering)」以及推理强度(Reasoning Effort)档位调节,已彻底移除早期 Eino 引擎依赖。
- **目标驱动的「深度测评」持久工作台**:围绕测评目标与验收条件长周期推进,内置项目级共享**攻击面图**、支持冷热分支归档的**探索图谱**、优先级**意图队列**,以及强制绑定真实工具回执的**事实记录与验收证据矩阵**。
- **React 19 + Semi Design 统一工作台**:采用现代化单页架构,支持抽屉式详情查阅、按项目分组管理对话、紧凑模型与角色切换,以及按域名、主机、任务多维聚合的漏洞管理与**一键复测**。
- **多网关兼容与上下文自适应**:支持渠道自定义鉴权请求头(适配各类第三方聚合网关,限制同源重定向防泄露)、运行时上下文窗口自动探测、本地推理服务(oMLX / Ollama 等)`local_auto` 画像、DeepSeek 经济上下文画像及独立 HITL 审计模型配置。
- **独立出站代理池与自托管运维**:提供与模型 API 流量隔离的 [HTTP 测试代理池与故障切换](docs/zh-CN/http-proxy-pool.md);内置保留自签证书与登录态的 Web 端**一键自更新**,以及可预览的运行空间**存储清理**。
> [!IMPORTANT]
> 仅可对自有系统或已获得明确授权的目标使用 CyberStrikeAI。在共享或生产环境启用高风险工具、WebShell 或 C2 前,请先阅读[安全模型](docs/zh-CN/security-model.md)和[安全加固指南](docs/zh-CN/security-hardening.md)。
<a id="screenshots"></a>
## 界面与集成预览
## 界面预览
<div align="center">
| 系统仪表盘(风险分布与运行态概览) | 深度测评工作台(深色主题 · 目标与进度) |
| :---: | :---: |
| ![系统仪表盘](images/dashboard.png) | ![深度测评深色主题](images/dark.png) |
### 系统仪表盘概览
| 深度测评 · 探索图谱(意图、事实、漏洞与冷归档) | 对话控制台(项目分组、工具回执与任务总结) |
| :---: | :---: |
| ![探索图谱](images/deep-assessment-graph.png) | ![对话控制台](images/web-console.png) |
<table>
<tr>
<td width="50%" align="center">
<strong>浅色模式</strong><br/>
<img src="./images/dashboard.png" alt="系统仪表盘(浅色)" width="100%">
</td>
<td width="50%" align="center">
<strong>深色模式</strong><br/>
<img src="./images/dark.png" alt="系统仪表盘(深色)" width="100%">
</td>
</tr>
</table>
| 漏洞管理(按域名/主机树状聚合与严重度统计) | MCP 与工具管理(外部 MCP 连接与内置工具配置) |
| :---: | :---: |
| ![漏洞管理](images/vulnerability-management.png) | ![MCP 管理](images/mcp-management.png) |
<a id="quick-start"></a>
## 快速上手
### 1. 准备环境
| 依赖 | 要求 | 用途 |
| --- | --- | --- |
| Go | 1.25+,以 [go.mod](go.mod) 为准 | 编译后端服务与运行时构建器 |
| Node.js 与 npm | Node.js 22.19+ | 构建与运行 Pi Worker(及可选前端二次构建) |
| Python | 3.10+,支持 `venv` | 启动脚本及 Python 工具依赖 |
| Git | 已加入 `PATH` | 克隆源码与 Web 端一键更新 |
运行前还需准备支持工具调用(Tool Calling)的模型渠道,以及任务实际所需的本地安全工具或外部 MCP 服务。仓库内置工具配方,但**不会自动安装所有第三方安全工具**。`run.sh` 默认使用国内临时镜像加速 Go 与 pip 依赖下载,也可通过环境变量 `GOPROXY`、`PIP_INDEX_URL` 自定义。
### 2. 获取源码并启动
以下命令适用于 macOS / Linux 的 Bash 环境:
```bash
git clone --branch main https://github.com/Sycun/CyberStrikeAI.git
cd CyberStrikeAI
cp config.example.yaml config.yaml
```
本机试用建议先将 `config.yaml` 中的 `server.host` 改为 `127.0.0.1`,然后启动服务:
```bash
bash run.sh --http
```
脚本会自动构建 Pi Worker、创建 Python 虚拟环境、安装依赖并编译启动服务(前端静态产物已预构建在 `web/static/app/` 中,开箱即用)。默认监听 [http://127.0.0.1:8080/](http://127.0.0.1:8080/),实际端口以配置和终端输出为准。
不带 `--http` 时,`run.sh` 默认启用 HTTPS + HTTP/2(未配置证书时自动生成并复用本地自签证书)。团队共享部署的监听地址、TLS 证书与访问控制请参考[部署指南](docs/zh-CN/deployment.md)。
### 3. 完成首次配置
1. 使用终端 `ADMIN SETUP REQUIRED` 输出的初始 `admin` 密码登录,并按提示修改密码。
2. 在 **系统设置 → 基本设置 → AI 通道配置** 中填写提供商、Base URL、API Key 和模型,保存后设为默认通道(示例配置中的凭据仅为占位符)。
3. 按需安装本地安全工具或接入外部 MCP 服务,确认工具可用后再分配给对应角色或智能体。
4. 多人协作时,可在 **平台权限 → 添加成员** 中为团队成员分配独立账号、角色与数据范围。
完整配置项以 [config.example.yaml](config.example.yaml) 为准;模型通道、本地模型与上下文策略详见[配置参考](docs/zh-CN/configuration.md)与[配置画像](docs/zh-CN/configuration-profiles.md)。
*仪表盘提供系统运行状态、安全漏洞、工具使用情况和知识库的全面概览,帮助用户快速了解平台核心功能和当前状态。*
<details>
<summary><strong>手动构建与前端二次开发</strong></summary>
<summary><strong>查看更多界面截图</strong></summary>
完成 `config.yaml` 配置后,可分步构建 Pi Worker 与 Go 服务:
### 核心功能概览
```bash
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
./cyberstrike-ai -config config.yaml --http
```
若修改了 `web/frontend/` 下的前端源码,重新构建静态产物后再启动服务即可:
```bash
cd web/frontend && npm ci && npm run build
```
部署时需同时保留运行时目录、`web/static/` 与匹配的 Pi Worker 构建产物(或在目标机器重新执行构建),仅复制单个 Go 二进制无法运行智能体;Python 工具依赖需另行准备。详见 [Pi 运行时说明](docs/zh-CN/pi-runtime.md)。
<table>
<tr>
<td width="33.33%" align="center">
<strong>Web 控制台</strong><br/>
<img src="./images/web-console.png" alt="Web 控制台" width="100%">
</td>
<td width="33.33%" align="center">
<strong>任务管理</strong><br/>
<img src="./images/task-management.png" alt="任务管理" width="100%">
</td>
<td width="33.33%" align="center">
<strong>漏洞管理</strong><br/>
<img src="./images/vulnerability-management.png" alt="漏洞管理" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>WebShell 管理</strong><br/>
<img src="./images/webshell-management.png" alt="WebShell 管理" width="100%">
</td>
<td width="33.33%" align="center">
<strong>MCP 管理</strong><br/>
<img src="./images/mcp-management.png" alt="MCP 管理" width="100%">
</td>
<td width="33.33%" align="center">
<strong>知识库</strong><br/>
<img src="./images/knowledge-base.png" alt="知识库" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>Skills 管理</strong><br/>
<img src="./images/skills.png" alt="Skills 管理" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Agent 管理</strong><br/>
<img src="./images/agent-management.png" alt="Agent 管理" width="100%">
</td>
<td width="33.33%" align="center">
<strong>角色管理</strong><br/>
<img src="./images/role-management.png" alt="角色管理" width="100%">
</td>
</tr>
<tr>
<td width="33.33%" align="center">
<strong>系统设置</strong><br/>
<img src="./images/settings.png" alt="系统设置" width="100%">
</td>
<td width="33.33%" align="center">
<strong>MCP stdio 模式</strong><br/>
<img src="./images/mcp-stdio2.png" alt="MCP stdio 模式" width="100%">
</td>
<td width="33.33%" align="center">
<strong>Burp Suite 插件</strong><br/>
<img src="./images/plugins.png" alt="Burp Suite 插件" width="100%">
</td>
</tr>
</table>
</details>
<a id="delegation"></a>
</div>
## 任务与测评模式
## 特性速览
平台提供三种互补的执行入口,共享同一套项目资产库、工具权限与漏洞记录:
### 智能体与编排
- **对话(Chat)**:面向交互式研判与即时操作,支持单智能体、Deep、Plan-Execute、Supervisor 模式,支持按项目分组管理会话,并可在执行中通过「中断并继续」实时补充人工指令。
- **深度测评(Deep Assessments)**:面向目标驱动的持续安全测评。围绕测评目标与验收条件,基于 Pi 原生会话维护攻击面图、探索图、优先级意图队列与原始执行回执,支持长周期暂停、恢复、任务内追问与验收证据核对。详见[深度测评说明](docs/zh-CN/deep-assessments.md)。
- **任务管理(Batch Tasks)**:面向清单驱动的批量队列执行。在 **任务管理 → 新建任务** 中每行填写一项任务,配置项目、角色、代理模式、工具审批、并发数与可选 Cron 定时规则,在队列详情中查看子任务结果与执行会话,并按状态暂停、继续或编辑子任务。详见[批量任务管理](docs/zh-CN/task-management.md)。
- 🤖 **智能体执行层**:将自然语言意图转化为受控、可审计的安全行动。
- 🧩 **Eino 编排**:支持单智能体及 Deep、Plan-Execute、Supervisor 多智能体模式。
- 🔀 **工作流**:通过 Agent、工具、条件、审批和输出节点构建可复用流程。
- 🎭 **角色化测试**:为常见安全场景提供聚焦的提示词和工具策略。
<a id="capabilities"></a>
### 工具与知识扩展
## 主要能力
- 🧰 **安全工具**:提供 100+ 精选 YAML 工具配方,支持自定义扩展和按角色控制。
- 🔌 **MCP 集成**:支持 HTTP、stdio、SSE、外部 MCP 联邦和动态工具发现。
- ⏱️ **弹性工具执行**:阻塞型 MCP/工具调用交给 worker 执行,Agent 只有限等待;支持 `execution_id` 多轮等待、主动取消、单 server 熔断、并发限制和统一输出兜底。
- 🎯 **Agent Skills**:遵循标准 Skill 目录结构,支持渐进式按需加载。
- 📚 **知识库**:组合查询改写、向量检索、精排和结果后处理能力。
- 🖼️ **视觉分析**:使用独立视觉模型分析截图、验证码和 UI,对话中仅保留文字摘要。
| 能力 | 功能概述 | 参考文档 |
| --- | --- | --- |
| Pi 智能体编排 | 单智能体、Deep、Plan-Execute、Supervisor 多模式执行、中途引导与推理档位控制 | [智能体与角色](docs/zh-CN/agent-and-role-guide.md) |
| 深度测评 | 目标驱动规划、共享攻击面图、探索图冷热记忆、意图队列与验收证据矩阵 | [深度测评](docs/zh-CN/deep-assessments.md) |
| 批量任务队列 | 清单并发执行、Cron 定时调度、暂停/继续与子任务会话追溯 | [批量任务管理](docs/zh-CN/task-management.md) |
| 工具、Skills 与代理池 | YAML 工具配方、外部 MCP 接入、按需技能加载与独立 HTTP 出站代理池 | [工具](tools/README.md) · [Skills](skills/README.md) · [代理池](docs/zh-CN/http-proxy-pool.md) |
| 可视化工作流 | 编排智能体、工具、条件分支与人工审批节点 | [工作流](docs/zh-CN/workflow-graph.md) |
| 知识、证据与报告 | RAG 检索、项目事实沉淀、原始工具回执、攻击链分析与 Word / Markdown 报告导出 | [知识库](docs/zh-CN/knowledge-base.md) · [报告导出](docs/zh-CN/word-reports.md) |
| 项目与漏洞工作台 | 项目级资产库、域名/主机/任务多维漏洞视图、详情抽屉一键复测 | [资产管理](docs/zh-CN/asset-management.md) |
| 人工监督与治理 | RBAC 权限控制、高风险工具审批(HITL)、调用拦截、操作审计与 Token 监控 | [安全模型](docs/zh-CN/security-model.md) · [HITL](docs/zh-CN/hitl-best-practices.md) · [Token 监控](docs/zh-CN/token-usage-monitoring.md) |
| 外部生态集成 | Burp Suite 插件、浏览器 DevTools 扩展、IM 机器人与外部 MCP 联邦 | [插件](#integrations) · [机器人](docs/zh-CN/robot.md) · [MCP](docs/zh-CN/mcp-federation.md) |
### 安全治理与审计
专项能力还包括 [WebShell 管理](docs/zh-CN/webshell.md) 与 [C2 协同](docs/zh-CN/c2.md)。请按授权任务范围启用所需模块;仓库包含工具配方不代表对应二进制已在本地安装或完成环境校验。
- 🧑‍⚖️ **人机协同**:支持审批模式、工具白名单、审计 Agent 复核和决策追踪。
- 🛡️ **调用拦截**:「安全防护」下配置 MCP 执行前正则拦截、提醒模板和试匹配,默认启用政府域名保护。详见[调用拦截](docs/zh-CN/tool-call-guard.md)。
- 🔐 **平台 RBAC**:支持多用户、系统及自定义角色、权限 Scope、资源归属和显式授权。
- 🔒 **安全与审计**:提供登录保护、审计日志、SQLite 持久化和行动证据留存。
- 📄 **结果治理**:数据库保存与 Agent 实际看到的同一份兜底后工具结果,恢复路径会再次防御历史超大输出,前端详情也有展示保护。详见[工具执行治理](docs/zh-CN/tool-execution-governance.md)。
<a id="architecture"></a>
### 安全运营管理
## 架构概览
- 📁 **对话管理**:支持分组、置顶、重命名和批量管理。
- 📂 **项目与攻击链**:关联跨会话事实、风险评分、图谱视图和步骤回放。
- 🗂️ **资产管理**:统一归档和去重域名、IP、端口与服务,支持 XLSX/CSV 导入导出、高级筛选与保存视图、责任和业务属性、跨页批量维护、重复资产合并,并跟踪扫描覆盖、关联漏洞和风险状态。详见[资产管理指南](docs/zh-CN/asset-management.md)。
- 🛡️ **漏洞管理**:支持严重程度分级、状态流转、过滤和统计看板。
- 📋 **批量任务**:支持任务队列、编辑、状态跟踪和结果留存。
- 📱 **机器人接入**:支持个人微信、企业微信、钉钉、飞书、Telegram、Slack、Discord 和 QQ。
| 组件 | 核心职责 |
| --- | --- |
| **Go 服务与调度引擎** | 承载 HTTP/SSE 接口、深度测评与批量队列调度、工具执行管控、存储清理及证据落盘 |
| **Pi 运行时** | 基于 **Pi 1.7.0** 处理模型交互、工具调用循环、原生会话持久化、上下文压缩与中途引导(Steering) |
| **工具网关** | 统一分发本地工具与 MCP 调用,执行角色边界、权限校验、人工审批与超时/输出截断治理 |
| **SQLite 与 Pi 会话存储** | SQLite 保存业务状态、图谱节点与执行回执;Pi 会话记录模型上下文与压缩摘要 |
| **Web 工作台** | 基于 React 19 + Semi Design + Cytoscape 构建的前端界面,统一呈现对话、测评图谱、任务轨迹与项目资产 |
### 授权安全操作
<a id="integrations"></a>
- 🐚 **WebShell 管理**:提供连接管理、虚拟终端、文件操作和 AI 辅助工作流。
- 📡 **内置 C2**:提供监听器、加密 Beacon、会话、任务队列、Payload 辅助和实时事件。
## 浏览器与抓包插件
> WebShell、C2 及其他高风险能力仅限自有系统或已获得明确授权的测试环境。使用前请阅读[安全模型](docs/zh-CN/security-model.md)和[安全加固指南](docs/zh-CN/security-hardening.md)。
| 集成组件 | 用途 | 文档与构建包 |
| --- | --- | --- |
| Burp Suite 插件 | 将选中的 HTTP 请求一键发送至 CyberStrikeAI 进行安全分析 | [安装说明](plugins/burp-suite/cyberstrikeai-burp-extension/README.zh-CN.md) · [JAR](plugins/burp-suite/cyberstrikeai-burp-extension/dist/cyberstrikeai-burp-extension.jar) |
| Chrome / Edge 扩展 | 在浏览器 DevTools 的 CyberStrikeAI 面板捕获并提交请求 | [安装说明](plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md) · [ZIP](plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip) |
## 插件(Plugins)
## 更新与版本迁移
可选集成在 `plugins/` 目录下。
新安装的 [config.example.yaml](config.example.yaml) 默认将更新源指向本仓库:
- **Burp Suite 插件**:`plugins/burp-suite/cyberstrikeai-burp-extension/`
构建产物:`plugins/burp-suite/cyberstrikeai-burp-extension/dist/cyberstrikeai-burp-extension.jar`
说明文档:`plugins/burp-suite/cyberstrikeai-burp-extension/README.zh-CN.md`
- **浏览器扩展(Chrome / Edge)**:`plugins/browser-extension/cyberstrikeai-browser-extension/`
在 DevTools 中捕获 Network 流量并发送到 CyberStrikeAI 进行 AI 辅助安全测试,能力与 Burp 插件对齐。
安装:`chrome://extensions/` → 加载已解压 → F12 → **CyberStrikeAI** 标签页
打包产物:`plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip`
说明文档:`plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md`
```yaml
update:
repo: https://github.com/Sycun/CyberStrikeAI
## 工具概览
系统预置 100+ 渗透/攻防工具,覆盖完整攻击链:
<details>
<summary><strong>查看完整工具分类</strong></summary>
- **网络扫描**:nmap、masscan、rustscan、arp-scan、nbtscan
- **Web 应用扫描**:sqlmap、nikto、dirb、gobuster、feroxbuster、ffuf、httpx
- **漏洞扫描**:nuclei、wpscan、wafw00f、dalfox、xsser
- **子域名枚举**:subfinder、amass、findomain、dnsenum、fierce
- **网络空间搜索引擎**:fofa_search、zoomeye_search、quake_search、shodan_search
- **API 安全**:graphql-scanner、arjun、api-fuzzer、api-schema-analyzer
- **容器安全**:trivy、clair、docker-bench-security、kube-bench、kube-hunter
- **云安全**:prowler、scout-suite、cloudmapper、pacu、terrascan、checkov
- **二进制分析**:gdb、radare2、ghidra、objdump、strings、binwalk
- **漏洞利用**:metasploit、msfvenom、pwntools、ropper、ropgadget
- **密码破解**:hashcat、john、hashpump
- **取证分析**:volatility、volatility3、foremost、steghide、exiftool
- **后渗透**:linpeas、winpeas、mimikatz、bloodhound、impacket、responder
- **CTF 实用工具**:stegsolve、zsteg、hash-identifier、fcrackzip、pdfcrack、cyberchef
- **系统辅助**:exec、create-file、delete-file、list-files、modify-file
</details>
工具定义、自定义方式与使用说明见 [tools/README.md](tools/README.md)。
## 基础使用
### 快速上手(一条命令部署)
**环境要求:**
- Go 1.25+([下载安装](https://go.dev/dl/),以 `go.mod` 为准)
- Python 3.10+ ([下载安装](https://www.python.org/downloads/))
**一条命令部署:**
```bash
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
cd CyberStrikeAI
chmod +x run.sh && ./run.sh
```
若从旧版安装迁移而来,请在 `config.yaml` 或 **系统设置 → 一键更新** 中确认更新源已设为 `https://github.com/Sycun/CyberStrikeAI`(`update.repo` 留空仍指向已停止开源更新的旧仓库地址)。一键更新会自动拉取源码、重新构建匹配的 Pi Worker 与服务二进制,并保留现有自签 TLS 证书与登录会话;详细步骤见[部署指南](docs/zh-CN/deployment.md)。
`run.sh` 脚本会自动完成:
- ✅ 检查并验证 Go 和 Python 环境
- ✅ 创建 Python 虚拟环境
- ✅ 安装 Python 依赖包
- ✅ 下载 Go 依赖模块
- ✅ 编译构建项目
- ✅ 启动服务器
若从早期 Eino 版本升级,请先备份运行配置与数据库,并结束或导出旧工作流任务:**旧版 Eino 二进制工作流检查点无法在当前版本直接续跑**。历史数据记录、常用配置键与兼容路由仍保持可读,但不提供旧引擎切换开关。详见 [Pi 运行时与迁移说明](docs/zh-CN/pi-runtime.md)。
**验证是否启动成功:**
## 验证与质量边界
1. 确认终端显示 `● ONLINE`,并在其后给出实际 Web UI 地址。
2. 打开该地址;默认 HTTPS 使用本地自签证书,首次访问需接受一次浏览器证书提示。
3. 全新安装时,妥善保存 `ADMIN SETUP REQUIRED` 下仅展示一次的 `admin` 密码,登录后立即修改。
持续集成覆盖 Go 后端测试、Pi 运行时协议校验、前端构建、进程隔离、代理池以及深度测评与批量队列的隔离回归检查,最新状态见 [GitHub Actions](https://github.com/Sycun/CyberStrikeAI/actions)。自动化回归不替代真实环境验收;具体模型渠道的兼容性、Token 成本与真实目标测试效果需结合实际环境评估。
**网络默认:** `run.sh` 会以 **`--https`** 并传入项目根 **`config.yaml`** 启动(本机自签证书,多路流式场景更稳)。只要明文 HTTP 用 **`./run.sh --http`**。生产环境在 **`config.yaml`** 的 **`server.tls_cert_path` / `server.tls_key_path`** 配正式证书(见文件内注释)。手动启动可加 **`--https`** 或环境变量 **`CYBERSTRIKE_HTTPS=1`**;`-config` 写错时程序会在终端提示正确写法。
<a id="documentation"></a>
**首次配置:**
1. **配置 AI 通道**(首次使用前必填)
- 启动后在浏览器打开 **`https://127.0.0.1:8080/`**(或 **`https://localhost:8080/`**;端口以 `config.yaml` 中 **`server.port`** 为准,默认 8080),并按提示信任自签证书。若使用 **`./run.sh --http`**,则改用 **`http://`** 访问。
- 进入 `系统设置` → `基本设置` → `AI 通道配置`,新增或编辑通道,填写 API 提供商、Base URL、API Key、模型和 Token 上限,点击 **保存更改**。左侧通道列表支持设为默认、复制、删除和批量探活。
```yaml
ai:
default_channel: openai-main
channels:
openai-main:
name: OpenAI Main
provider: openai_compatible
api_key: "${OPENAI_API_KEY}"
base_url: "https://api.openai.com/v1" # 或 https://api.deepseek.com/v1
model: "gpt-4o" # 或 deepseek-chat, qwen3-max 等
max_total_tokens: 120000
max_completion_tokens: 16384
```
- 或启动前直接编辑 `config.yaml` 文件。`ai.default_channel` 会作为新对话和未显式选择通道任务的默认模型;对话页也可以在会话设置里选择某个已保存通道。
2. **登录系统** - 首次启动时控制台会显示自动生成的 `admin` 初始密码;也可在「平台权限 → 用户管理」中创建账号
3. **安装安全工具(可选)** - 按需安装 `tools/` 目录中的工具;未安装的工具在执行时会自动跳过或改用替代方案。常用示例:
## 文档导航
**macOS(Homebrew):**
```bash
brew install nmap masscan sqlmap nikto gobuster ffuf hydra hashcat nuclei subfinder
```
| 使用场景 | 推荐入口 |
| --- | --- |
| 部署服务与配置模型 | [部署指南](docs/zh-CN/deployment.md) · [配置参考](docs/zh-CN/configuration.md) · [配置画像](docs/zh-CN/configuration-profiles.md) · [故障排查](docs/zh-CN/troubleshooting.md) |
| 运行深度测评与批量任务 | [深度测评](docs/zh-CN/deep-assessments.md) · [批量任务管理](docs/zh-CN/task-management.md) |
| 定制智能体、工具与代理 | [Pi 运行时](docs/zh-CN/pi-runtime.md) · [智能体与角色](docs/zh-CN/agent-and-role-guide.md) · [工具配方](tools/README.md) · [HTTP 代理池](docs/zh-CN/http-proxy-pool.md) |
| 对接外部系统与自动化 | [API 参考](docs/zh-CN/api-reference.md) · [API 示例](docs/zh-CN/api-recipes.md) · [MCP 联邦](docs/zh-CN/mcp-federation.md) |
| 团队运维与安全加固 | [安全加固](docs/zh-CN/security-hardening.md) · [工具执行治理](docs/zh-CN/tool-execution-governance.md) · [运维手册](docs/zh-CN/runbooks.md) |
| 参与开发与了解仓库结构 | [开发者指南](docs/zh-CN/developer-guide.md) · [测试说明](docs/zh-CN/testing.md) · [仓库说明](docs/REPOSITORY_GUIDE.md) |
**Linux(Kali / Debian / Ubuntu):**
```bash
sudo apt update
sudo apt install -y nmap masscan sqlmap nikto gobuster hydra hashcat john binwalk
# 部分发行版需自行安装:ffuf、nuclei、subfinder 等可用 go install 或见各工具官网
```
完整目录请浏览[中文文档索引](docs/zh-CN/README.md)或[中英双语索引](docs/README.md)。
完整工具列表见 `tools/` 目录;各工具安装方式以官方文档为准。
<a id="contributing"></a>
**其他启动方式:**
```bash
# 直接运行(需自行配环境);与 run.sh 默认一致可加 --https
go run ./cmd/server --https
## 反馈与贡献
# 手动编译
go build -o cyberstrike-ai ./cmd/server
./cyberstrike-ai --https
```
本仓库作为独立开源分支持续演进,欢迎在 [Issues](https://github.com/Sycun/CyberStrikeAI/issues) 提交问题反馈与功能建议,也欢迎围绕工具配方适配、交互体验优化与回归测试提交 Pull Request。反馈问题时请附上 Commit 版本、操作系统、模型协议类型、复现步骤与脱敏日志,切勿上传真实 API Key、登录凭据或敏感目标数据。
若日志出现 `client sent an HTTP request to an HTTPS server`,说明仍有客户端用 **`http://`** 访问只提供 HTTPS 的端口,请改为 **`https://`**。
感谢早期开源阶段 [AIPentest/CyberStrikeAI](https://github.com/AIPentest/CyberStrikeAI) 的原作者与历任贡献者,以及 Pi、MCP 等开源社区项目。
**说明:** Python 虚拟环境(`venv/`)由 `run.sh` 自动创建和管理。需要 Python 的工具(如 `api-fuzzer`、`http-framework-test` 等)会自动使用该环境。
## 许可证与使用声明
### 版本升级与兼容性
本项目遵循 [Apache License 2.0](LICENSE) 开源许可证,完整保留原始提交历史与版权声明;第三方组件遵循其各自许可证与声明。本项目仅限用于自有系统或已获得明确书面授权的安全测试与研究,使用者须严格遵守授权范围及所在地法律法规。安全漏洞报告方式请参阅 [SECURITY.md](SECURITY.md)。
**优先用平台自带的「一键更新」**(控制台「系统设置 → 一键更新」,或 `./cyberstrike-ai -update` /
`-check-update` / `-update-rollback`):它从**更新源仓库**(默认官方仓库,可一处配置改成自己的二开或镜像)
拉取默认分支的最新代码,快进后重编译并原子换二进制,你的 `roles/skills/tools/agents/data/config.yaml`
会被原样保留(结果里逐个点名保留了什么,只有 `config.yaml` 的 `version` 字段会随新代码同步,让页头版本号与代码对上),
本地源码有改动或本地历史与更新源分叉时它会拒绝而不是覆盖。
详见 [部署指南](docs/zh-CN/deployment.md)。
`upgrade.sh` 仍然可用:本目录是 git 工作树时它就是上面那条命令的薄壳;不是 git 工作树(tarball 安装)时
才回落到"下载 GitHub Release 包 + rsync"的老路径,此时源码仓库由 `--repo owner/name` 或 `GITHUB_REPO`
决定(都不给才用内置默认值,并会警告说明代码来自哪个仓库)。
更新源是 `config.yaml` `update` 段里的一个仓库地址(`repo`),也可以在控制台「一键更新」页填写保存
(跟随官方仓库、自己的二开、别人的二开或镜像都只是这一处;不写就是官方仓库);解压安装(目录里没有 git)
也能在同一页「预览并接入」后进入一键更新。
1. (首次使用)启用脚本:`chmod +x upgrade.sh`
2. 升级:`./upgrade.sh`(可选参数:`--check`、`--tag vX.Y.Z`、`--repo owner/name`、`--no-venv`、`--yes`)。本地的 `tools/`、`roles/`、`skills/`、`agents/` 会始终保留不被覆盖。
3. 脚本会备份你的 `config.yaml` 和 `data/`,升级代码,更新 `config.yaml` 的 `version` 字段后重启服务。
推荐的一键指令:
`chmod +x upgrade.sh && ./upgrade.sh --yes`
如果升级失败:git 工作树里直接 `./cyberstrike-ai -update-rollback`(回到那次更新前的提交与二进制);
tarball 安装则从 `.upgrade-backup/` 恢复,或手动拷回 `data/` 和 `config.yaml` 后再运行 `./run.sh`。
依赖/提示(只有 tarball 路径用得到):
* 需要 `curl` 或 `wget` 用于下载 GitHub Release 包。
* 建议/需要 `rsync` 用于安全同步代码。
* 如果遇到 GitHub API 限流,运行前设置 `export GITHUB_TOKEN="..."` 再执行 `./upgrade.sh`。
⚠️ **升级前必读:** 请查看目标版本的 Release Notes,确认配置、数据库和 API 是否变化。即使只是补丁版本也应先备份,不能仅凭版本号判断兼容性。
## 配置
请以 [`config.example.yaml`](config.example.yaml) 作为权威配置模板,只复制当前环境需要的配置。最少需要配置服务监听地址和一个 AI 通道:
```yaml
server:
host: "127.0.0.1"
port: 8080
ai:
default_channel: openai-main
channels:
openai-main:
provider: openai_compatible
api_key: "${OPENAI_API_KEY}"
base_url: "https://api.openai.com/v1"
model: "your-model"
```
`openai` 是兼容旧版本的运行时字段,新配置优先维护 `ai.channels`。不要提交真实凭证。将服务暴露到 localhost 之外前,请阅读[配置参考](docs/zh-CN/configuration.md)、[推荐配置画像](docs/zh-CN/configuration-profiles.md)和[安全加固指南](docs/zh-CN/security-hardening.md)。
## 相关文档
- **新用户:** [部署指南](docs/zh-CN/deployment.md) → [配置参考](docs/zh-CN/configuration.md) → [排错指南](docs/zh-CN/troubleshooting.md)
- **运维人员:** [配置画像](docs/zh-CN/configuration-profiles.md) → [安全加固](docs/zh-CN/security-hardening.md) → [运维 Runbooks](docs/zh-CN/runbooks.md)
- **集成开发:** [API 参考](docs/zh-CN/api-reference.md) → [API Recipes](docs/zh-CN/api-recipes.md) → [MCP 联邦](docs/zh-CN/mcp-federation.md)
- **项目贡献:** [开发者指南](docs/zh-CN/developer-guide.md) → [测试指南](docs/zh-CN/testing.md) → [贡献规范](docs/zh-CN/contributing-guide.md)
- **全部专题:** [中文文档](docs/zh-CN/README.md) · [双语文档索引](docs/README.md)
## 项目结构
```
CyberStrikeAI/
├── cmd/ # Web 服务、MCP stdio 入口及辅助工具
├── internal/ # Agent、MCP 核心、路由、C2(`internal/c2`)与执行器
├── web/ # 前端静态资源与模板
├── tools/ # YAML 工具目录(含 100+ 示例)
├── roles/ # 角色配置文件目录(含 12+ 预设安全测试角色)
├── skills/ # Agent Skills 目录(SKILL.md + 可选文件;示例 cyberstrike-eino-demo)
├── agents/ # 多代理 Markdown(orchestrator.md + 子代理 *.md)
├── docs/ # 专题文档(部署、配置、安全、API、知识库、C2、WebShell 等)
├── images/ # 文档配图
├── config.yaml # 运行配置
├── run.sh # 启动脚本
└── README*.md
```
## 基础体验示例
```
扫描 192.168.1.1 的开放端口
对 192.168.1.1 做 80/443/22 重点扫描
检查 https://example.com/page?id=1 是否存在 SQL 注入
枚举 https://example.com 的隐藏目录与组件漏洞
获取 example.com 的子域并批量执行 nuclei
```
## 进阶剧本示例
```
加载侦察剧本:先 amass/subfinder,再对存活主机进行目录爆破。
挂载基于 Burp 的外部 MCP,完成认证流量回放并回传到攻击链。
将 5MB nuclei 报告压缩并生成摘要,附加到对话记录。
构建最新一次测试的攻击链,只导出风险 >= 高的节点列表。
```
## 404星链计划
<img src="./images/404StarLinkLogo.png" width="30%">
CyberStrikeAI 现已加入 [404星链计划](https://github.com/knownsec/404StarLink)
## TCH Top-Ranked Intelligent Pentest Project
<div align="left">
<a href="https://zc.tencent.com/competition/competitionHackathon?code=cha004" target="_blank">
<img src="./images/tch.png" alt="TCH Top-Ranked Intelligent Pentest Project" width="30%">
</a>
</div>
---
## 社区与支持
- 在 [Discord](https://discord.gg/8PjVCMu8Zw) 加入社区。
<details>
<summary><strong>企业微信群</strong></summary>
<img src="./images/wecom-group-cyberstrikeai-qr.png" alt="CyberStrikeAI 企业微信群二维码" width="280">
</details>
## 许可证
CyberStrikeAI 采用 **Apache License 2.0** 开源许可。
完整条款见仓库根目录 [LICENSE](LICENSE) 文件。
---
## ⚠️ 免责声明
**本工具仅供教育和授权测试使用!**
CyberStrikeAI 是一个专业的安全测试平台,旨在帮助安全研究人员、渗透测试人员和IT专业人员在**获得明确授权**的情况下进行安全评估和漏洞研究。
**使用本工具即表示您同意:**
- 仅在您拥有明确书面授权的系统上使用此工具
- 遵守所有适用的法律法规和道德准则
- 对任何未经授权的使用或滥用行为承担全部责任
- 不会将本工具用于任何非法或恶意目的
**开发者不对任何滥用行为负责!** 请确保您的使用符合当地法律法规,并获得目标系统所有者的明确授权。
安全问题报告与部署加固建议见 [SECURITY.md](SECURITY.md)。
---
欢迎提交 Issue/PR 贡献新的工具模版或优化建议!

View File

@ -1,15 +1,11 @@
---
id: cyberstrike-plan-execute
name: Plan-Execute 规划主代理
description: plan_execute 模式下的规划/重规划侧主代理:拆解目标、修订计划,由执行器调用 MCP 工具落地(通过 Pi task 工具委派 executor);计划中每步须含完整目标与范围,禁止让执行器凭猜测补全 URL/IP。
description: plan_execute 模式下的规划/重规划侧主代理:拆解目标、修订计划,由执行器调用 MCP 工具落地(不使用 Deep 的 task 子代理);计划中每步须含完整目标与范围,禁止让执行器凭猜测补全 URL/IP。
---
你是 **CyberStrikeAI** 在 **plan_execute** 模式下的 **规划主代理**。你的职责是制定与迭代**结构化计划**,并在每轮执行后根据证据**重规划**;具体工具调用由执行器代理完成。
## Pi 执行协议
使用可用的 write_todos 或 TaskCreate/TaskUpdate 维护计划。每一步通过 task 调用 `subagent_type=executor`,在 description 中写清目标、范围、动作和成功标准。根据执行器返回的真实证据再决定继续、调整或结束。不要只输出计划 JSON 就把任务标为完成;本轮计划中仍为 pending/in_progress 的步骤会使本轮被判为未完成(unfinished_plan)且不会自动续跑,调用 exit 前须把每一步更新为 completed(不再执行的步骤从计划中移除);最终交付通过 exit 提交,仍需经过宿主验收。
## 计划与执行器上下文(强制)
- 执行器**不保证**能看到你在规划侧对话中的全部细节;**每个计划步骤**必须自洽,包含执行所需最小事实。

View File

@ -153,7 +153,7 @@ description: 多代理模式下的 Deep 编排者:在已授权安全场景中
严重程度:critical / high / medium / low / info。证明须含足够证据(请求响应、截图、命令输出等)。
- **编排进度(待办)**:当你的任务包含 3 个或以上步骤,或你准备委派多个子目标并行/串行推进时,优先使用 `write_todos` 来向用户展示“当前在做什么/接下来做什么”。维护约束:同一时刻最多一个条目处于 `in_progress`;完成后立刻标记 `completed`;遇到阻塞就保留为 `in_progress` 并继续推进。
- **强触发建议(提升多 agent 使用率)**:如果你将要进行任何“证据收集/枚举/扫描/验证/复现/整理报告”这类实质执行动作,且不只是单步查询,请优先在第一个工具调用前就用 `write_todos` 建立计划;随后用 `task` 委派至少一个子代理获取结构化证据,而不是自己把全部步骤做完。
- **技能库(Skills)与知识库**:技能包位于服务器 `skills/` 目录(各子目录 `SKILL.md`,遵循 agentskills.io);知识库用于向量检索片段,Skills 为可执行工作流指令。多代理本会话通过内置 **`skill`** 工具渐进加载;子代理同样挂载 skill + 可选本机文件工具时,可在委派说明中提示按需加载。若当前无 skill 工具,先使用已提供的能力完成独立步骤,并说明缺失的能力。
- **技能库(Skills)与知识库**:技能包位于服务器 `skills/` 目录(各子目录 `SKILL.md`,遵循 agentskills.io);知识库用于向量检索片段,Skills 为可执行工作流指令。多代理本会话通过内置 **`skill`** 工具渐进加载;子代理同样挂载 skill + 可选本机文件工具时,可在委派说明中提示按需加载。若当前无 skill 工具,需要完整 Skill 工作流时请使用多代理模式或切换为 Eino 编排会话。
- **知识检索(快速补足背景)**:当需要漏洞类型/验证方法/常见绕过等“方法论”而不是直接工具执行细节时,优先用 `search_knowledge_base` 获取可落地的证据线索。

View File

@ -1,24 +0,0 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"os/signal"
"cyberstrike-ai/internal/agentruntime"
)
func main() {
root := flag.String("root", "runtime/pi", "Pi runtime source directory")
flag.Parse()
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
path, err := agentruntime.PreparePiRuntime(ctx, *root)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println(path)
}

View File

@ -22,10 +22,8 @@ import (
)
func main() {
updateActivation := app.TakeUpdateActivation()
updateSessions := app.TakeUpdateSessionHandoff()
var configPath = flag.String("config", "config.yaml", "Path to the configuration file")
var httpsBootstrap = flag.Bool("https", false, "Enable HTTPS for the main site; creates and reuses a local self-signed certificate when no cert/key is configured")
var httpsBootstrap = flag.Bool("https", false, "Enable HTTPS for the main site; uses an in-memory self-signed certificate when no cert/key is configured")
var httpBootstrap = flag.Bool("http", false, "Force plain HTTP for the main site, overriding TLS settings in the configuration file")
var resetAdminPassword = flag.Bool("reset-admin-password", false, "Interactively reset the built-in admin password and exit")
checkIsolation := flag.Bool("check-process-isolation", false, "Probe task containment and cleanup, then exit without starting services")
@ -158,11 +156,10 @@ func main() {
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
// 创建应用
application, err := app.New(cfg, log, cp, updateActivation)
application, err := app.New(cfg, log, cp)
if err != nil {
log.Fatal("应用初始化失败", "error", err)
}
application.RestoreUpdateSessions(updateSessions)
// 在后台监听信号
go func() {

View File

@ -1,8 +1,3 @@
# Fresh installations follow this independent repository. Existing deployments
# retain their own update.repo; adopting this version does not modify a running service.
update:
repo: https://github.com/Sycun/CyberStrikeAI
# ============================================
# CyberStrikeAI 配置文件
# ============================================
@ -16,7 +11,7 @@ update:
# 前端显示的版本号(可选,不填则显示默认版本)。一键更新完成后,会用新代码里这个文件的值
# 同步更新你的 config.yaml 的 version 字段(页头版本号与静态资源缓存随代码走)。
version: "v1.8.2"
version: "v1.7.24"
# 服务器配置
server:
host: 0.0.0.0 # 监听地址,0.0.0.0 表示监听所有网络接口
@ -33,38 +28,8 @@ server:
# 方式 A(推荐生产):PEM 证书与私钥路径
# tls_cert_path: /path/to/fullchain.pem
# tls_key_path: /path/to/privkey.pem
# 方式 B(仅本地/测试):在配置目录的 data/tls/self-signed.pem 保存并复用自签证书和私钥(SAN 含 localhost / 127.0.0.1)。
# 方式 B(仅本地/测试):无证书文件时内存自签(浏览器会提示不受信任;SAN 含 localhost / 127.0.0.1)
tls_auto_self_sign: true
# 插件平台。默认每个 WebUI 使用独立端口并复用主站 TLS 策略。
# 默认端口模式每个已安装插件占用一个代理端口,并复用主站的 TLS 配置。
# VPS、防火墙或容器端口映射可预先放行这个闭区间。插件后端端口保持在私网。
# plugins:
# directory: data/plugins # 相对配置文件目录
# egress:
# proxy_mode: system # system / direct / fixed
# # proxy_url: http://proxy.example.com:3128
# # github_token_env: CSAI_PLUGINS_GITHUB_TOKEN
# approval_policy: admin_confirm # 默认:全局插件管理员确认锁定计划,批准记录保存在 SQLite
# # 改为 host_config_only 时,由下方声明摘要与制品摘要列表授权执行。
# # approved_artifacts:
# # "<manifest SHA-256>": ["<artifact SHA-256>"]
# proxy:
# mode: port
# port_pool:
# start: 43100
# end: 43131
# # host_suffix: plugins.localhost # mode: host 使用
# # bind_host: 127.0.0.1 # 端口模式,缺省继承主站监听 IP
# # public_origin: https://csai.example.com
# # external_ports: {43100: 44310}
# llm_gateway:
# listen_host: 127.0.0.1 # 也可绑定明确的私有 bridge IP
# listen_port: 0 # 0 表示分配可用端口
# # container_host: host.docker.internal
# concurrency: 4
# rpm: 30
# token_budget: 200000 # 每实例每日 UTC 计费额度
# 认证配置
auth:
session_duration_hours: 12 # 登录有效期(小时),超时后需重新登录
@ -104,7 +69,7 @@ storage:
conversation_artifacts: # 摘要与超长输入台账 data/conversation_artifacts;默认 30 天
enabled: true
retention_days: 30
plantask: # 多代理计划看板 skills/.pi/plantask;默认 30 天(纯派生数据)
plantask: # 多代理计划看板 skills/.eino/plantask;默认 30 天(纯派生数据)
enabled: true
retention_days: 30
c2_artifacts: # C2 回传截图/上传件/下发文件/payload tmp/c2;默认 30 天
@ -131,7 +96,7 @@ storage:
# - DeepSeek: https://api.deepseek.com/v1
# - 其他兼容 OpenAI 协议的 API
# 常用模型: gpt-4, gpt-3.5-turbo, deepseek-chat, claude-3-opus 等
# provider: 可选值 openai_compatible(默认) | claude(Pi 原生 Anthropic Messages API)
# provider: 可选值 openai_compatible(默认) | claude(Eino 原生 Anthropic Messages API)
ai:
default_channel: qwen-max
channels:
@ -141,32 +106,15 @@ ai:
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
api_key: sk-xxxxxxx
model: qwen3-max
# 图片输入默认按模型能力自动判断。自定义网关可在「测试图片」通过后启用,或设置 image_input: enabled。
max_total_tokens: 120000
max_completion_tokens: 32768
# headers: 可选。追加或覆盖发给模型网关的 HTTP 请求头,值支持 ${ENV_VAR} 与 ${ENV_VAR:-默认值}。
# 用于兼容要求私有鉴权头、版本头或组织头的第三方 OpenAI 兼容供应商(如 opencode 等聚合网关)。
# 配置后会覆盖同名的内置头(Authorization、User-Agent 等),空值项会被忽略。
# headers:
# X-Api-Key: ${OPENCODE_API_KEY}
# x-opencode-session: "%session_id%" # 自动替换为当前对话 ID
# X-Client-Name: cyberstrike-ai
# HTTP-Referer: https://example.com
# 配置自定义头时,仅允许同源重定向,跨主机、端口或协议的重定向会被拒绝。
# HITL 审计仅在未显式配置 provider/base_url/api_key 时继承主渠道 headers;
# 独立审计身份如需请求头,请在 hitl.audit_model.headers 中单独配置。
# 空 headers 与未配置等价;所有自定义头值在设置接口中均按敏感值脱敏。
context_window: 0 # 0=未知;保存通道时按服务元数据自动检测
context_profile: auto # 默认自动优化;识别本地服务后保存为 local_auto;custom 可使用手动运行时参数
# Pi 路径模型推理:DeepSeek/OpenAI 为 thinking / reasoning_effort;Claude 4.6+ 为 adaptive + output_config.effort(仅显式配置 effort 时下发);3.7 为 enabled+budget_tokens:10000(文档示例),effort 不映射,自定义预算用 extra_request_fields
# Eino 路径模型推理:DeepSeek/OpenAI 为 thinking / reasoning_effort;Claude 4.6+ 为 adaptive + output_config.effort(仅显式配置 effort 时下发);3.7 为 enabled+budget_tokens:10000(文档示例),effort 不映射,自定义预算用 extra_request_fields
reasoning:
mode: on # auto | on | off;off:OpenAI/Claude 不附加推理字段,DeepSeek 发送 thinking.type=disabled(其默认开启思考)
effort: high # low | medium | high | max | xhigh(最高档:OpenAI 常用 xhigh,部分网关用 max,原样下发);空表示不指定
allow_client_reasoning: true # false 时忽略对话请求体 reasoning,仅以下方为准
profile: openai_compat # auto | deepseek_compat | openai_compat | output_config_effort
# extra_request_fields: {} # 可选:管理员自定义根级 JSON 片段(高级)
# 仅当 Chat Completions 网关明确拒绝 store 字段时,设置 {store: null} 省略该字段。
# 未配置时保留 Pi 默认行为;store: false/true 仍原样发送。
# qwen-plus:
# name: Qwen Plus Fallback
# provider: openai_compatible
@ -175,7 +123,7 @@ ai:
# model: qwen-plus
# max_total_tokens: 120000
# max_completion_tokens: 32768
# 可选的独立 analyze_image 工具配置。聊天图片可通过支持图片输入的模型通道发送。
# 视觉分析(analyze_image MCP 工具;图片仅在单次 VL 调用中出现,Agent 上下文只保留文字摘要)
vision:
enabled: false # true 且 model 非空时注册 analyze_image
model: qwen-vl # VL 模型名(enabled 时必填)
@ -187,7 +135,7 @@ vision:
jpeg_quality: 82
max_payload_bytes: 524288 # 编码后送 VL API 上限,默认 512KB
skip_preprocess_below_bytes: 2097152 # 低于 2MB 且长边<=max_dimension 且<=max_payload 时原图直传;0=始终压缩
detail: auto # low | high | auto(Pi ImageURLDetail)
detail: auto # low | high | auto(Eino ImageURLDetail)
timeout_seconds: 60
# ============================================
# 资产管理(网络空间测绘搜索)配置(可选)
@ -208,16 +156,7 @@ shodan:
api_key: "" # Shodan API Key;也可通过 SHODAN_API_KEY 环境变量配置
# Agent 配置
# 达到最大迭代次数时,AI 会自动总结测试结果
# Pi runtime (Node.js >=22.19). Build with: bash scripts/build-pi-runtime.sh
agent_runtime:
engine: pi # Pi is the only agent runtime
node_path: node
worker_path: "" # empty: use the source-addressed runtime bundle
session_dir: data/pi-sessions
agent:
# 修改后重启服务,对新任务生效;例如 1440 = 24 小时,单次工具超时独立生效。
task_timeout_minutes: 600 # 任务执行超时(分钟);未配置=600,0=不限时,负数无效;续跑重新计时
max_iterations: 12000 # 全局最大迭代次数(单代理 / Deep / Supervisor / Plan-Execute 主执行器 / 子代理均沿用;agents/*.md 中 max_iterations>0 可单独覆盖)
tool_timeout_minutes: 60 # 单次工具执行最大时长(分钟),超时自动终止;0 表示不限制(不推荐,易出现长时间挂起)
tool_wait_timeout_seconds: 300 # 工具本轮最多等待(秒);到时返回 execution_id,worker 继续后台执行,可用 wait_tool_execution 继续等待;0=等到完成
@ -262,8 +201,6 @@ hitl:
base_url: "" # openai 后端留空跟随主模型;typesafe 后端留空使用 https://api.typesafe.ai
api_key: "" # openai 后端留空跟随主模型;typesafe 后端填写 TypeSafe API Key
model: "" # openai 后端建议填小模型;typesafe 后端留空使用 jev-latest
reasoning:
profile: "" # auto / deepseek_compat / openai_compat;仅控制审计请求的 thinking 字段
# 已决策审计日志保留天数(与 MCP 监控一致;省略默认 90;0 表示不自动清理)
retention_days: 90
# 按你环境里的真实工具名增删(与侧栏一致、小写不敏感);不需要全局免审批可改为 []
@ -377,49 +314,77 @@ hitl:
- 只做最小必要修改以收窄范围、消除风险(如限制 path、去掉危险 flag)
- 禁止扩大攻击面:不得扩大目标范围、提升权限或引入破坏性参数
- 无法安全改参且存在上述高危情形时应 reject,不要勉强 approve
# 多代理与 Pi 单代理(Pi SDK;单代理入口 /api/agent*,多代理 /api/multi-agent*)
# 多代理与 Eino 单代理(CloudWeGo Eino ADK;单代理入口 /api/eino-agent*,多代理 /api/multi-agent*)
# 依赖在 go.mod 中拉取;若下载失败可设置: go env -w GOPROXY=https://goproxy.cn,direct
# Deep / Plan-Execute / Supervisor 由对话页与 WebShell 所选模式在请求体 orchestration 中指定;机器人按 robot_default_agent_mode
multi_agent:
enabled: true
robot_default_agent_mode: single # 企微/钉钉/飞书机器人默认:single | deep | plan_execute | supervisor
batch_use_multi_agent: false # true 时「批量任务」队列中每个子任务也走 Pi 多代理(成本更高)
# plan_execute 专用:向 executor 委派的外层步数预算上限;0 表示不单独限制(主/子代理 ReAct 轮次统一由 agent.max_iterations 控制)。
robot_default_agent_mode: eino_single # 企微/钉钉/飞书机器人默认:eino_single | deep | plan_execute | supervisor
batch_use_multi_agent: false # true 时「批量任务」队列中每个子任务也走 Eino 多代理(成本更高)
# plan_execute 专用:execute↔replan 外层循环上限,0 表示 Eino 默认 10。主/子代理 ReAct 轮次见 agent.max_iterations。
plan_execute_loop_max_iterations: 0
sub_agent_user_context_max_runes: 0 # 子代理 task 描述中注入用户原文;0=不截断(默认),>0=总字符上限,负数=禁用
without_general_sub_agent: false # false 时保留 Deep 内置 general-purpose 子代理
without_write_todos: false
orchestrator_instruction: "" # Deep 主代理:agents/orchestrator.md(或 kind: orchestrator 的单个 .md)正文优先;正文为空时用此处;皆空则 原生默认
orchestrator_instruction: "" # Deep 主代理:agents/orchestrator.md(或 kind: orchestrator 的单个 .md)正文优先;正文为空时用此处;皆空则 Eino 默认
orchestrator_instruction_plan_execute: "" # plan_execute 主代理:agents/orchestrator-plan-execute.md 正文优先;正文为空时用此处;皆空则用内置 plan_execute 提示(不使用 Deep 的 orchestrator_instruction)
orchestrator_instruction_supervisor: "" # supervisor 主代理:agents/orchestrator-supervisor.md 正文优先;正文为空时用此处;皆空则用内置 supervisor 提示(transfer/exit 说明仍由运行追加;不使用 Deep 的 orchestrator_instruction)
# Pi 官方 Skills:渐进式披露 + 可选本机文件/Shell(原生 Go 工具)。Skills 目录见 skills_dir。
skills:
# Eino 官方 Skills:渐进式披露 + 可选本机文件/Shell(eino-ext local backend)。Skills 目录见 skills_dir。
eino_skills:
disable: false # true:不注册 skill 渐进式披露中间件,也不挂本机 FS/Shell 工具;false:按下方开关加载
filesystem_tools: true # true:注册 read_file/glob/grep/write/edit/execute(授权环境慎用);false:仅 skill,不暴露本机读写与 Shell
skill_tool_name: skill # 模型侧可调用的「加载技能」工具名,一般保持 skill;与技能包文档中的调用名一致即可
# Pi 原生 中间件与 Deep/Supervisor/plan_execute Executor 调参(结构体见 internal/config/config.go → MultiAgentPiMiddlewareConfig)
# Eino ADK 中间件与 Deep/Supervisor/plan_execute Executor 调参(结构体见 internal/config/config.go → MultiAgentEinoMiddlewareConfig)
# plan_execute:下列 patch/reduction/tool_search/plantask 等同样作用于 Executor(经 ExecPreMiddlewares);Planner/Replanner 不挂 MCP 前置中间件。
runtime:
prompt_cache_prefix_split: false # keep the Pi role prompt separate from per-run context
tool_search_enable: true
tool_search_min_tools: 20
tool_search_always_visible: 12
tool_search_always_visible_tools: [get_tool_execution, wait_tool_execution, cancel_tool_execution, search_knowledge_base]
tool_search_include_builtins: true # true:后端内置工具始终常驻,绕过 tool_search
codemode_enable: false # true:启用 Pi 原生 QuickJS-WASI codemode 沙箱,模型可用一段 JS 批量编排/过滤多步工具调用
codemode_mode: on # codemode 工具面板形态:留空/on(默认,常规工具并存)或 only(脚本优先);其他值拒绝加载
codemode_inline_budget: 0 # >0 时限制 codemode 描述中内联工具声明的估算 token 预算;0 用 Pi 默认
plantask_enable: true
plantask_rel_dir: .pi/plantask
reduction_enable: true
reduction_root_dir: tmp/reduction
reduction_max_length_for_trunc: 12000
model_retry_max_retries: 0 # 0 uses Pi SDK defaults
model_retry_max_backoff_sec: 0 # 0 uses Pi SDK defaults
model_failover_channels: []
model_failover_max_retries: 0
empty_response_continue_max_attempts: 5
eino_middleware:
patch_tool_calls: true # true:修补历史中无 tool_result 的悬空 tool_call(流式中断/重试后更稳);false:关闭;字段省略时默认等同 true
tool_search_enable: true # true:工具数 ≥ min 时启用 tool_search,仅前 N 个工具常驻,其余按正则按需解锁,省 token、减误选;false:全量工具进上下文
tool_search_min_tools: 20 # 达到该数量才启用 tool_search(避免工具很少时多此一举);与 always_visible 配合使用
tool_search_always_visible: 12 # 始终直接暴露给模型的工具个数(顺序与角色工具列表一致);其余工具进入动态池,需 tool_search 解锁
tool_search_always_visible_tools: [read_file, glob, grep, analyze_image, write_file, edit_file, execute, task, transfer_to_agent, exit, write_todos, skill, tool_search, TaskCreate, TaskGet, TaskUpdate, TaskList, record_vulnerability, list_vulnerabilities, get_vulnerability, get_tool_execution, wait_tool_execution, cancel_tool_execution, list_knowledge_risk_types, search_knowledge_base, webshell_exec, webshell_file_list, webshell_file_read, webshell_file_write, manage_webshell_list, manage_webshell_add, manage_webshell_update, manage_webshell_delete, manage_webshell_test, batch_task_list, batch_task_get, batch_task_start, batch_task_rerun, batch_task_pause, batch_task_update_metadata, batch_task_update_schedule, batch_task_schedule_enabled, batch_task_update_task, batch_task_remove_task, batch_task_delete, batch_task_create, batch_task_add_task, http-framework-test, exec] # 后端内置常驻工具白名单(优先于 always_visible 数量策略)
plantask_enable: true # P0:主代理挂载 TaskCreate/Get/Update/List 结构化任务板;需 eino_skills 可用且 skills_dir 存在
plantask_rel_dir: .eino/plantask # 任务文件相对 skills_dir,按会话分子目录:skills/.eino/plantask/<conversationId>/
reduction_enable: true # true:大工具输出截断并落盘到本地文件(tmp/reduction/.../trunc/<id>),上下文只留 <persisted-output> 预览;不依赖 eino_skills
reduction_max_length_for_trunc: 100000 # 单条工具结果超过该字节数时:全文写入本地 trunc 文件,返回带路径的截断预览(MCP/exec 与 reduction 共用此阈值)
reduction_max_tokens_for_clear: 60000 # 历史工具结果清理阈值(tokens),应低于 max_total_tokens * summarization_trigger_ratio
reduction_root_dir: "" # 非空:截断/清理内容落盘根路径;空:项目目录下 tmp/reduction(按会话/项目隔离)
reduction_clear_exclude: [] # 不参与「清理阶段」的工具名额外列表(会与 task/transfer/exit 等内置排除项合并);需要时用 YAML 列表填写
reduction_sub_agents: true # true:子代理也挂 reduction;false:仅编排主代理使用 reduction
summarization_trigger_ratio: 0.8 # summarization 触发比例(max_total_tokens * ratio),建议 0.75~0.85
summarization_output_reserve_tokens: 40960 # 摘要模型输出预留 token;摘要输入预算 = 触发阈值 - 该值
summarization_emit_internal_events: true # true:发出 summarization 内部事件(便于诊断)
summarization_user_intent_ledger_max_runes: 96000 # 压缩后注入模型上下文的「原始用户输入与约束账本」总字符上限;DB 原始消息不裁剪
summarization_user_intent_ledger_entry_max_runes: 16000 # 账本中单条用户消息的字符上限;超出仅裁剪模型可见账本,不影响 DB 原文
latest_user_message_max_runes: 48000 # 本轮最新 user 进入模型上下文的字符上限;超出时全文落盘,仅注入 head/tail 预览
latest_user_message_head_runes: 24000 # 超长本轮 user 的头部预览字符数
latest_user_message_tail_runes: 24000 # 超长本轮 user 的尾部预览字符数
plan_execute_user_input_budget_ratio: 0.35 # plan_execute 中 userInput 预算比例(planner/replanner/executor 共用)
plan_execute_executed_steps_budget_ratio: 0.2 # plan_execute 中 executed_steps 预算比例
plan_execute_max_step_result_runes: 4000 # plan_execute 每步结果最大字符数(超出截断)
plan_execute_keep_last_steps: 8 # plan_execute 仅保留最近 N 步正文,早期步骤折叠为标题
checkpoint_dir: "" # 聊天链路不再使用 ADK checkpoint;跨轮模型态统一走 conversations.last_react_*,便于排查 stale context
model_retry_max_retries: 0 # Eino 原生 ChatModel retry;408/409/425/429/5xx/网络抖动/空流式输出会重试;0=默认 4(永久性 4xx 不重试)
model_retry_max_backoff_sec: 0 # Eino 原生 ChatModel retry 单次退避上限秒数;0=默认 30
model_failover_channels: [] # Eino 原生 ChatModel failover;填写 ai.channels ID,例如 [qwen-plus];retry 耗尽后按顺序切换
model_failover_max_retries: 0 # 备用通道最多尝试数;0=尝试全部 model_failover_channels
empty_response_continue_max_attempts: 0 # Run 成功但未捕获助手正文(含流式中断)时 Handler 退避续跑次数;0=默认 5
deep_output_key: final_answer # P0:Eino session 写入最终助手结论(框架内部;Deep/Supervisor 主/eino_single)
task_tool_description_prefix: "" # 非空:仅 Deep 的 task 工具使用自定义描述前缀,运行时会拼接子代理名称;空则走 Eino 默认生成逻辑
# Eino callbacks + OpenTelemetry:框架级 span(与 Zap 对齐);默认不向终端用户 UI 推 eino_trace_*(见 sse_trace_to_client)
eino_callbacks:
enabled: true
# log_only=仅 Zap+OTel(推荐默认)| sse/full=才启用流式回调副本关闭等(full 含 stream hooks)
mode: log_only
sse_trace_to_client: false # true:且 mode 为 sse/full 时,向前端时间线推送 eino_trace_*(排障/内网演示用)
max_input_summary_runes: 400
max_output_summary_runes: 400
zap_verbose: false # true:Debug 附带 input/output 摘要
otel:
enabled: true
service_name: cyberstrike-ai
exporter: stdout # none | stdout(开发/本机)| otlphttp(生产接 Collector)
otlp_endpoint: localhost:4318 # otlphttp 时使用,host:port,路径固定 /v1/traces
sample_ratio: 1.0 # 0~1,ParentBased+TraceIDRatio
# 数据库配置
database:
path: data/conversations.db # SQLite 数据库文件路径,用于存储对话历史和消息
@ -484,9 +449,9 @@ knowledge:
retrieval:
top_k: 5 # 检索返回的Top-K结果数量
similarity_threshold: 0.4 # 余弦相似度阈值(0-1),低于此值的结果将被过滤
# Pi MultiQuery:LLM 改写查询后多路向量检索再融合
# Eino MultiQuery:LLM 改写查询后多路向量检索再融合(始终启用)
multi_query:
max_queries: 4 # 含原查询的检索次数上限,设为 1 时直接向量检索
max_queries: 4 # 改写变体上限(含语义覆盖);建议 3~4
# 精排(始终启用):dashscope 用 gte-rerank;其他 OpenAI 兼容端点走 /v1/rerank
rerank:
provider: "" # 空=按 base_url 推断:dashscope | cohere
@ -514,15 +479,15 @@ knowledge:
# 重试配置
max_retries: 3 # 最大重试次数(默认 3),遇到速率限制或服务器错误时自动重试
retry_delay_ms: 1000 # 重试间隔毫秒数(默认 1000),每次重试会递增延迟
# 分块策略(Pi):markdown_then_recursive = 先按 Markdown 标题切再递归;recursive = 仅递归切分。留空时程序内默认 markdown_then_recursive
# 分块策略(Eino):markdown_then_recursive = 先按 Markdown 标题切再递归;recursive = 仅递归切分。留空时程序内默认 markdown_then_recursive
chunk_strategy: markdown_then_recursive
# 嵌入 HTTP 请求超时(秒)。0 表示使用内置默认(一般为 120),与向量化 API 客户端一致
request_timeout_seconds: 120
# true:索引时优先用知识项 file_path 指向的磁盘文件内容(Pi FileLoader);false:用数据库里存的正文。读盘失败会回退 DB
# true:索引时优先用知识项 file_path 指向的磁盘文件内容(Eino FileLoader);false:用数据库里存的正文。读盘失败会回退 DB
prefer_source_file: false
# 单次嵌入 API 请求的文本条数上限(索引写入按此分批)。须 ≤ 服务商限制(如部分兼容接口最多 10);过大易 400
batch_size: 10
# Pi indexer.WithSubIndexes:逻辑分区标签列表,会写入向量表 sub_indexes,检索可用 sub_index_filter 过滤;无需求可 []
# Eino indexer.WithSubIndexes:逻辑分区标签列表,会写入向量表 sub_indexes,检索可用 sub_index_filter 过滤;无需求可 []
sub_indexes: []
# ============================================
# 机器人配置(企业微信、钉钉、飞书)
@ -598,7 +563,7 @@ robots:
# ============================================
# 技能包目录:每个子目录仅标准 SKILL.md(Agent Skills:front matter 仅 name、description)+ 可选附属文件;无 SKILL.yaml
# 示例:skills/cyberstrike-pi-demo/
# 示例:skills/cyberstrike-eino-demo/
skills_dir: skills # Skills配置文件目录(相对于配置文件所在目录)
# ============================================
# 多代理子 Agent(Markdown,唯一维护处)
@ -639,15 +604,3 @@ project:
# 把目录变成跟踪该仓库的 git 工作树,此后按正常安装一键更新。
# update:
# repo: https://github.com/AIPentest/CyberStrikeAI.git # 一个仓库地址;留空/不写 = 官方仓库
# HTTP 测试工具的受管出口;不影响 Kali 其他工具、外部 MCP 或大模型 API。
# 固定 URL 是否固定公网 IP 取决于供应商。运行中的工具使用启动时快照。
proxy:
mode: manual # manual=沿用工具参数,fixed=固定代理,pool=显式启用代理池
proxy_url: "" # fixed 模式必填,支持 http(s)/socks5://host:port
proxy_pool: "" # pool 模式:每行一个代理 URL;与供应商至少配置一项
proxy_source: "" # 可选供应商 HTTP(S) 地址
strategy: sticky # sticky 或 round_robin
max_attempts: 3
cooldown: 60
min_switch_interval: 60 # 间隔内即使失败也不提前切换;0 表示不限制

View File

@ -19,7 +19,7 @@ CyberStrikeAI documentation is organized by user journey. Start with deployment,
- [安全模型](zh-CN/security-model.md)
- [Agent 与角色](zh-CN/agent-and-role-guide.md)
- [Skills 指南](zh-CN/skills-guide.md)
- [Pi 多代理](zh-CN/MULTI_AGENT_PI.md)
- [Eino 多代理](zh-CN/MULTI_AGENT_EINO.md)
- [黑板与上下文记忆](zh-CN/blackboard-context-memory.md)
- [Agent 最终回复治理](zh-CN/agent-finalization-best-practices.md)
- [工作流](zh-CN/workflow-graph.md)
@ -32,7 +32,6 @@ CyberStrikeAI documentation is organized by user journey. Start with deployment,
- [资产管理](zh-CN/asset-management.md)
- [项目任务续接](zh-CN/project-resume.md)
- [Token 用量分析](zh-CN/token-usage-monitoring.md)
- [HTTP 测试工具代理池](zh-CN/http-proxy-pool.md)
- [知识库](zh-CN/knowledge-base.md)
- [RBAC 权限管理](zh-CN/rbac.md)
- [机器人接入](zh-CN/robot.md)
@ -64,7 +63,7 @@ CyberStrikeAI documentation is organized by user journey. Start with deployment,
- [Security Model](en-US/security-model.md)
- [Agents and Roles](en-US/agent-and-role-guide.md)
- [Skills](en-US/skills-guide.md)
- [Pi Multi-Agent](en-US/MULTI_AGENT_PI.md)
- [Eino Multi-Agent](en-US/MULTI_AGENT_EINO.md)
- [Blackboard and Context Memory](en-US/blackboard-context-memory.md)
- [Agent Finalization](en-US/agent-finalization-best-practices.md)
- [Workflows](en-US/workflow-graph.md)
@ -77,7 +76,6 @@ CyberStrikeAI documentation is organized by user journey. Start with deployment,
- [Asset Management](en-US/asset-management.md)
- [Resuming Project Tasks](en-US/project-resume.md)
- [Token Usage Analysis](en-US/token-usage-monitoring.md)
- [HTTP Test Tool Proxy Pool](en-US/http-proxy-pool.md)
- [Knowledge Base](en-US/knowledge-base.md)
- [RBAC Administration](en-US/rbac.md)
- [Robot / Chatbot](en-US/robot.md)

View File

@ -1,43 +0,0 @@
# 仓库与分支说明 / Repository and branch guide
2026-11-11:个人仓库已由 `CyberStrikeAI-personal` 改名为 `CyberStrikeAI`。2026-11-25 起本项目仅在个人独立仓库维护发布,不再向官方上游提交 PR。
## 仓库职责
| 仓库 | 职责 |
| --- | --- |
| [Sycun/CyberStrikeAI](https://github.com/Sycun/CyberStrikeAI) | 个人维护主线。日常修复、优化和文档均在这里保存、使用与验证。 |
| [Sycun/csai-decouple-refactor](https://github.com/Sycun/csai-decouple-refactor) | 独立架构实验线,探索分层解耦与插件化;完成度以该仓库代码和验证记录为准。 |
| [AIPentest/CyberStrikeAI](https://github.com/AIPentest/CyberStrikeAI) | 官方上游。个人维护线与重构线均保留原始历史、许可证与版权说明。 |
个人主线与架构实验线分别演进,不把全部分支自动合入一个版本。
## 分支状态(2026-11-03 整理时核对)
| 分支 | 当前定位 | 上游状态与后续处理 |
| --- | --- | --- |
| `main` | 个人维护默认分支 | 初始快照来自 `codex/deep-assessment`,后续日常改动以本分支为基线。 |
| `codex/deep-assessment` | 深度测评功能与官方 PR 来源 | [上游 PR #383](https://github.com/AIPentest/CyberStrikeAI/pull/383) 已于 2026-11-13 关闭;个人版已移除该模块,来源分支仅保留历史。 |
| `codex/issue-365-word-reports` | 单条漏洞 Markdown / Word 下载的历史分支 | [上游 PR #378](https://github.com/AIPentest/CyberStrikeAI/pull/378) 已合并,分支尖端已包含在个人主线历史中;保留存档。 |
| `codex/issue-357-proxy-pool` | 代理池功能开发分支 | 已整合进个人主线;[上游 PR #381](https://github.com/AIPentest/CyberStrikeAI/pull/381) 待合并,整理时存在合并冲突。个人版已完成兼容整合;官方 PR 的冲突另行处理。 |
| `feat/local-model-context-profile` | 本地模型上下文优化分支 | 已整合进个人主线;[上游 PR #367](https://github.com/AIPentest/CyberStrikeAI/pull/367) 待合并,整理时存在合并冲突。个人版已完成兼容整合;官方 PR 的冲突另行处理。 |
| `archive/local-main-20261103` | 调整个人维护流程前的本地 `main` | 历史存档,不作为日常开发或部署来源。 |
上表是带日期的状态快照,PR 后续状态以对应 GitHub 页面为准。保留分支与标签用于追溯,不据此宣称功能已集成或验收通过。
## 本次个人版整合(2026-11-03)
代理池与本地模型上下文分支已合入个人版 `main`,并保留各自提交历史。当时合并保留自定义请求头、深度测评与 Word 下载功能(深度测评已于 2026-11-13 移除);上下文探测复用渠道鉴权头,禁止跟随重定向。此记录表示代码整合,真实模型与真实目标的运行验收仍单独记录。
## 验证与安装
- 任务管理已恢复 v1.8.0 的批量队列逻辑;入口、兼容性与验证边界见 [任务管理](zh-CN/task-management.md)。
- 现有自动化与夹具验证不代表完成真实模型、真实目标的长时验收,也不构成漏洞发现率或成本优势的证明。
- 安装个人维护版时使用本仓库 README 的克隆地址。官方仓库与个人仓库的更新来源应明确选择;采用个人仓库默认分支更新时,应先评估对应提交与运行数据迁移。
- 仓库整理与默认分支调整不等于部署。已有安装的更新配置和运行状态由各自环境管理。
## Development workflow (English)
`CyberStrikeAI/main` is the personal maintenance baseline. `csai-decouple-refactor` is a separate architecture experiment. This repository is maintained independently and no longer submits PRs to upstream.
The dated table above distinguishes integrated work, pending branches, and historical snapshots. Proxy-pool and local-model changes are integrated into the personal main line; upstream PR integration is tracked separately. Keep existing PR branches and archival refs. Automated checks and fixtures do not establish real-model or real-target acceptance; installation and deployment sources must be selected explicitly.

View File

@ -0,0 +1,66 @@
# Eino Multi-Agent Notes
[中文](../zh-CN/MULTI_AGENT_EINO.md)
CyberStrikeAI uses CloudWeGo Eino ADK for the current single-agent and multi-agent execution paths. The native legacy ReAct path has been removed.
## Entrypoints
- Single-agent: `/api/eino-agent` and `/api/eino-agent/stream`
- Multi-agent: `/api/multi-agent` and `/api/multi-agent/stream`
Multi-agent orchestration is selected by request body:
- `deep`
- `plan_execute`
- `supervisor`
Robots default to `robot_default_agent_mode`, and batch tasks can opt into multi-agent through config.
## Agent Definitions
Markdown agents live under `agents/`.
Typical files:
```text
agents/orchestrator.md
agents/orchestrator-plan-execute.md
agents/orchestrator-supervisor.md
agents/*.md
```
Front matter controls name, id, description, tools, bound role, max iterations, and optional orchestrator kind.
## Middleware
Important Eino middleware:
- tool search: exposes a small visible tool set and unlocks others on demand;
- patch tool calls: repairs interrupted histories;
- plan task: structured task board;
- reduction: truncates or persists large tool outputs;
- summarization: compresses long contexts;
- checkpoint: resume after crash/OOM.
These settings live under `multi_agent.eino_middleware`.
## Skills
Eino Skills support progressive disclosure. The Agent initially sees names and descriptions; details are loaded only when needed through the configured skill tool.
## Operational Notes
- Tool visibility is not the same as tool availability in the UI.
- Running streams keep their startup context even if config changes mid-run.
- Summarization can write transcripts under `data/conversation_artifacts/...`.
- High-risk tools should still be constrained by roles and HITL.
## Source Anchors
- Multi-agent handler: `internal/handler/multi_agent.go`
- Preparation: `internal/handler/multi_agent_prepare.go`
- Orchestration: `internal/multiagent/eino_orchestration.go`
- Run loop: `internal/multiagent/eino_adk_run_loop.go`
- Skills: `internal/multiagent/eino_skills.go`
- Middleware: `internal/multiagent/eino_middleware.go`

View File

@ -1,11 +0,0 @@
# Pi single and multi-agent execution
Pi is the only runtime. Go owns business state, tool permissions, HITL, execution receipts and finalization. The SDK owns model loops, sessions, compaction and streaming. See [Pi runtime](pi-runtime.md).
Canonical single-agent endpoints are `/api/agent`, `/api/agent/stream`, and `/api/agent/runs`; the mode is `single`. Multi-agent endpoints retain `/api/multi-agent` and support `deep`, `plan_execute`, and `supervisor`. Older route/mode identifiers are input aliases only and cannot select another engine.
Deep delegates with `task`; Plan-Execute records a plan and delegates bounded executor steps; Supervisor selects specialists and finishes with `exit`. Markdown definitions under `agents/` remain supported. Child tool catalogs may narrow, never widen, their parent's allowed catalog.
`multi_agent.skills` configures skill loading and native host tools. `multi_agent.runtime` contains discovery, task-board, retry, failover and output-budget settings. Large catalogs use native `tool_search`; TaskCreate/Update/Get/List and write_todos remain compatible with the conversation progress UI.
Steering enters at a tool-batch boundary; cancellation stops inference and host tools. Uncertain effects after a crash are retained as unresolved results. Runtime completion does not bypass execution-evidence checks.

View File

@ -12,7 +12,7 @@
## Concepts and orchestration
- [Architecture](architecture.md) · [Security Model](security-model.md) · [RBAC](rbac.md)
- [Agents and Roles](agent-and-role-guide.md) · [Skills](skills-guide.md) · [Pi Multi-Agent](MULTI_AGENT_PI.md) · [Agent Finalization](agent-finalization-best-practices.md)
- [Agents and Roles](agent-and-role-guide.md) · [Skills](skills-guide.md) · [Eino Multi-Agent](MULTI_AGENT_EINO.md) · [Agent Finalization](agent-finalization-best-practices.md)
- [Blackboard and Context Memory](blackboard-context-memory.md)
- [Tool Call Guard](tool-call-guard.md)
- [Workflows](workflow-graph.md) · [Tool Execution Governance](tool-execution-governance.md) · [HITL Best Practices](hitl-best-practices.md)
@ -20,7 +20,6 @@
## Feature guides
- [Resuming Project Tasks](project-resume.md) · [Token Usage Analysis](token-usage-monitoring.md)
- [HTTP Test Tool Proxy Pool](http-proxy-pool.md)
- [Asset Management](asset-management.md) · [Knowledge Base](knowledge-base.md) · [Robot / Chatbot](robot.md) · [Vision](VISION.md)
- [WebShell](webshell.md) · [C2](c2.md) · [MCP Federation](mcp-federation.md)
@ -34,7 +33,3 @@
- [Developer Guide](developer-guide.md) · [Plugin Development](plugin-development.md) · [Frontend i18n](frontend-i18n.md)
- [Testing](testing.md) · [Contributing](contributing-guide.md) · [Release Process](release-process.md)
- [Pi runtime and migration](pi-runtime.md)
- [Batch task management (Chinese)](../zh-CN/task-management.md)

View File

@ -18,12 +18,12 @@ Authorization boundaries belong in roles and HITL first, not only in Skills.
| Mode | Good for | Poor fit |
| --- | --- | --- |
| `single` | short tasks, interactive analysis | large multi-stage work |
| `eino_single` | short tasks, interactive analysis | large multi-stage work |
| `deep` | dynamic task decomposition | strict sequential workflows |
| `plan_execute` | plan, execute, replan loops | frequent user interruption |
| `supervisor` | expert routing | vague or too many sub-agents |
Start with `single`; use `plan_execute` for structured projects; use `deep` or `supervisor` when specialist agents matter.
Start with `eino_single`; use `plan_execute` for structured projects; use `deep` or `supervisor` when specialist agents matter.
## Markdown Sub-Agent
@ -75,5 +75,5 @@ This helps the orchestrator continue and supports reporting.
- Markdown Agent parser: `internal/agents/markdown.go`
- Multi-agent preparation: `internal/handler/multi_agent_prepare.go`
- Orchestration: `internal/multiagent/pi_runner.go`
- Tool search middleware: `internal/multiagent/pi_runner.go`
- Orchestration: `internal/multiagent/eino_orchestration.go`
- Tool search middleware: `internal/multiagent/eino_middleware.go`

View File

@ -1,9 +1,335 @@
# Native Agent finalization and task acceptance
# Agent final-response governance best practices
Pi `agent_settled` ends automatic model work for the current run. Go still decides whether the business result can be finalized.
[English documentation](README.md) | [中文](../zh-CN/agent-finalization-best-practices.md)
`internal/agentfinalizer` keeps runtime failure, cancellation and iteration-limit outcomes separate from candidate assistant text. Pending tool executions, empty responses and missing required execution evidence prevent completion. Specialist output must be checked against execution receipts; `exit.final_result` does not bypass finalization.
Research date: 2026-07-28.
A completed model run is distinct from a completed long-running objective.
This guide addresses a specific failure: an Agent produces natural language that sounds conclusive before tool calls, reasoning, planning, or sub-agent collaboration have actually finished, and the frontend or orchestrator displays it as the final response. Task completion should be determined by runtime state, tool state, verification results, and explicit terminal events together, rather than by the most recent assistant text.
Implementation: `internal/agentfinalizer/decision.go` and `internal/multiagent/pi_runner.go`.
## 1. Core conclusions
1. **A final response is a runtime event, not natural-language content.**
Phrases such as “obtained,” “next step,” or “Huge breakthrough” are candidate observations or progress, not completion signals.
2. **Separate execution details from delivery.**
`thinking`, `reasoning_chain`, `planning`, `response_delta`, sub-agent replies, and tool output belong to execution details. Only `response` / `final` events that pass the final gate may populate the main message bubble and `messages.content`.
3. **Complex tasks need a verifier, not a longer prompt.**
Prompts can encourage caution, but code must decide whether tools or background executions are pending, required plan steps remain incomplete, evidence is unverified, facts/vulnerabilities are unrecorded, or cleanup is unfinished without explanation.
4. **Agent modes differ, but finalization principles are shared.**
Single-agent, Deep, Plan-Execute, and Supervisor modes all need a final gate. Evidence sources differ: single-agent mode checks tool traces; Deep also checks sub-agent results; Plan-Execute checks the Replanner's termination decision; Supervisor checks `exit` and the supervisor's synthesis.
## 2. Public practices in established Agent systems
The following summarizes the practices surveyed on the research date, not a new verification of external products.
| System | Public practice | Implication for finalization |
| --- | --- | --- |
| Codex | OpenAI's Codex prompting guide advises against forcing upfront plans, preambles, or status updates because these can stop a rollout before completion | Model-written plans/status are not completion evidence; the harness owns the execution loop and finalization |
| Claude Code | Provides `PreToolUse`, `PostToolUse`, and `Stop` hooks; `PostToolUse` occurs after successful tool execution | Lifecycle events are more reliable than prose; attach verification, auditing, and blocking to deterministic boundaries |
| Claude Code Subagents | Sub-agents have separate contexts, custom system prompts, specific tool access, and permissions; suitable for isolating extensive retrieval/log/file reads | Sub-agent output is evidence material, not the parent task's final conclusion; the parent must synthesize and verify it |
| Claude Code Plan Mode | Reads files and produces a plan without editing before approval | Planning and execution are distinct states; a completed plan is not a completed task |
| Cursor Plan Mode | Studies the codebase, asks clarifying questions, generates a reviewable plan, and waits for confirmation before building | Separating plan/review/build helps users distinguish plans from delivered results |
| OpenCode | Separates agents such as Build, Plan, Review, Debug, and Docs by tools and purpose; Plan analyzes without making changes | Capability boundaries reduce accidental transitions: planning capability does not imply completed execution |
| Eino ADK | Provides event-driven output, Runner callbacks, interrupts, checkpoints, and collaboration primitives including Supervisor and Plan-Execute; the latter uses Planner, Executor, and Replanner | These primitives fit the project; event-driven behavior needs an explicit finalization contract |
Primary references from the source guide:
- [OpenAI Codex Prompting Guide](https://developers.openai.com/cookbook/examples/gpt-5/codex_prompting_guide)
- [Claude Code Hooks](https://docs.anthropic.com/en/docs/claude-code/hooks)
- [Claude Code Subagents](https://docs.anthropic.com/en/docs/claude-code/sub-agents)
- [Claude Code Common Workflows](https://docs.anthropic.com/en/docs/claude-code/common-workflows)
- [Cursor Agent Best Practices](https://cursor.com/blog/agent-best-practices)
- [OpenCode Agents](https://opencode.ai/docs/agents/)
- [CloudWeGo Eino ADK](https://www.cloudwego.io/docs/eino/core_modules/eino_adk/)
- [CloudWeGo Eino ADK Patterns](https://www.cloudwego.io/docs/eino/overview/eino_adk0_1/)
## 3. General best practices
### 1. Establish a Finalization Contract
Every execution entry point should produce one structured finalization object. Only that object may authorize a final response. The following is a conceptual contract:
```go
type FinalizationDecision struct {
Status string // in_progress | completed | blocked | failed | cancelled
Finalizable bool
CompletionReason string // verified | user_cancelled | timeout | blocked | failed
FinalText string
EvidenceVerified bool
EvidenceRefs []string
PendingToolRuns []string
PendingPlanSteps []string
PendingApprovals []string
MissingChecks []string
}
```
Hard rules:
- When `Finalizable=false`, do not send a `response` as a successful terminal event. The project's blocked-response envelope is described below.
- When `Status=in_progress`, use process events such as `progress`, `planning`, `tool_*`, and `reasoning_chain`.
- `FinalText` must not be empty, but nonempty text alone does not authorize finalization.
- Any nonempty `PendingToolRuns`, `PendingPlanSteps`, or `PendingApprovals` prevents `completed`.
- When `EvidenceVerified=false`, do not present candidate output as a verified conclusion.
### 2. Define SSE event semantics
Recommended event layers:
| Event | Display location | May write `messages.content`? | Meaning |
| --- | --- | --- | --- |
| `progress` | Task state/timeline | No | Short progress update |
| `planning` | Execution details | No | Main-agent plan or interim judgment |
| `reasoning_chain` / `thinking` | Execution details | No | Reasoning/thinking summary |
| `tool_call` / `tool_result` | Execution details | No | Tool events |
| `eino_agent_reply` | Execution details | No | Material returned by a sub-agent |
| `finalization_check` | Execution details | No | Verifier result |
| `finalization_auto_continue` | Execution details | No | Verifier-triggered continuation, `contextInjection=false` |
| `response` | Main message bubble | Yes | Final-response treatment requires `data.finalized=true` |
| `done` | Stream closure | No | The stream ended; it does not establish task success |
| `error` / `cancelled` | Main message bubble or system notice | Yes, as terminal failure | Must include a reason |
### 3. Separate final candidates from final responses
The model can produce candidate conclusions. First route them into `final_candidate` or `planning`; the verifier then decides whether to promote them:
```text
assistant text
-> candidate
-> finalization gate
-> response(finalized=true)
```
Avoid direct promotion:
```text
assistant text
-> response
```
### 4. Verify at stop time
Following the lifecycle-hook approach, run deterministic checks when an agent run stops:
- Every tool call has a corresponding tool result.
- Background executions are terminal, or explicitly registered as still running with task state `in_progress` / `blocked`.
- Plan-Execute has no unexecuted required steps.
- Supervisor has no unsynthesized sub-agent results.
- An evidence-required policy has at least one queryable completed tool execution.
### 5. Treat sub-agent output as evidence
A sub-agent reply cannot directly become the user-facing final response. The main agent must:
- Deduplicate and reconcile conflicts.
- Rank evidence strength.
- Identify uncertainty.
- Check scope boundaries.
- Produce a readable delivery for the user.
### 6. Use prompts for guidance and code for enforcement
A prompt may say:
```text
Interim observations must be marked as progress, not final.
Do not produce a final answer until verification is complete.
```
Backend fields and state machines must still decide finalization. Otherwise, any conclusive-sounding model text could mislead the UI.
## 4. Current CyberStrikeAI implementation
The project has an explicit final gate:
- [internal/agentfinalizer/decision.go](../../internal/agentfinalizer/decision.go) is the single final-response decision contract.
- [internal/handler/finalization_helpers.go](../../internal/handler/finalization_helpers.go) writes decisions to `process_details` and calls `UpdateAssistantMessageFinalize` only when `Finalizable=true`.
- [internal/handler/eino_single_agent.go](../../internal/handler/eino_single_agent.go), [internal/handler/multi_agent.go](../../internal/handler/multi_agent.go), [internal/handler/workflow_integration.go](../../internal/handler/workflow_integration.go), and [internal/handler/batch_queue_executor.go](../../internal/handler/batch_queue_executor.go) invoke the finalizer at completion.
- [web/static/js/monitor.js](../../web/static/js/monitor.js) treats a `response` as final only when `data.finalized === true`. Nonfinalized text is shown as a failed finalization check.
- [web/static/js/webshell.js](../../web/static/js/webshell.js) marks streaming text as candidate output and switches to completed only on `response(finalized=true)`.
- [internal/agentfinalizer/decision_test.go](../../internal/agentfinalizer/decision_test.go) covers pending tools, HITL, empty output, missing required execution evidence, failed evidence that cannot justify finalization, and completed evidence that can.
- [internal/handler/finalization_auto_continue.go](../../internal/handler/finalization_auto_continue.go) automatically continues up to two segments when completed execution evidence is missing. It restores existing model traces without injecting new user/system text.
Core rules of the implemented contract:
1. **Model prose is only a candidate.**
`RunResult.Response` must pass through `agentfinalizer.Decide` before becoming a final response.
2. **Every `response` carries terminal-state fields.**
At minimum: `finalized`, `finalizable`, `status`, `completionReason`, `evidenceVerified`, `evidenceRefs`, `pendingExecutionIds`, and `missingChecks`.
3. **Unfinished tools block finalization.**
Remaining `queued/running` executions produce `in_progress/pending_tool_executions`.
4. **Execution evidence is declared through structured policy.**
The backend does not infer execution intent from user prose, assistant replies, or agent-mode names. Chat requests explicitly declare `finalization.requireExecutionEvidence`; execution entry points such as WebShell, Workflow, batch tasks, and robots pass policy at the call site. When required, at least one queryable `completed` tool execution must exist. Failed/cancelled records alone cannot justify finalization.
5. **Missing evidence triggers continuation before blocking.**
Eino single-agent and main multi-agent paths automatically continue from existing traces on `missing_execution_evidence`, without injecting extra context. They record blocked only if evidence is still missing at the continuation limit.
6. **HITL and empty output do not finalize.**
Workflows awaiting human approval, empty assistant text, and Eino empty-output placeholders produce blocked messages instead of success summaries.
## 5. Architecture for this project
The implemented flow is:
```text
Agent / Eino ADK events
-> event normalizer
-> process_details
-> finalization verifier
-> response(finalized=true)
-> messages.content
```
### 1. A shared backend Finalizer
Responsibilities:
- Accept `RunResult` / candidate text, `mcpExecutionIds`, conversation and assistant-message IDs, HITL state, and orchestration mode.
- Query tool execution states in the database, distinguishing pending, completed, failed, and cancelled evidence.
- Return `FinalizationDecision`.
- Check state and evidence without invoking high-risk tools.
### 2. Terminal fields in RunResult
[internal/multiagent/runner.go](../../internal/multiagent/runner.go) includes terminal-state fields:
```go
type RunResult struct {
Response string
MCPExecutionIDs []string
LastAgentTraceInput string
LastAgentTraceOutput string
Finalized bool
Status string
CompletionReason string
EvidenceVerified bool
EvidenceRefs []string
PendingExecutionIDs []string
MissingChecks []string
}
```
### 3. Conditions for sending `response`
Single-agent, multi-agent, workflow, and batch completion paths use the same pattern. These snippets illustrate control flow rather than standalone compilable code:
```go
decision := h.finalizeAgentRunForDelivery(...)
if !decision.Finalizable {
sendEvent("finalization_check", "Final-response requirements have not been met", decision)
sendEvent("response", finalizationBlockedMessage(decision), finalizationResponsePayload(decision, extra))
return
}
sendEvent("response", decision.FinalText, finalizationResponsePayload(decision, extra))
```
### 4. The frontend trusts only `finalized=true`
The `case 'response'` branch in [web/static/js/monitor.js](../../web/static/js/monitor.js) enforces the check:
```js
const responseFinalized = isFinalizedResponseData(responseData);
const bubbleText = responseFinalized
? resolvedResponseText
: (event.message || 'Final-response requirements have not been met; no success conclusion is available.');
markAssistantFinalizationState(assistantIdFinal, responseData);
```
The same principle applies to WebShell. `response_delta` can preview live text labeled as output from an ongoing execution; only the final `response(finalized=true)` shows completion.
### 5. Final gates by mode
| Mode | Final candidate producer | Finalization decision | Required checks |
| --- | --- | --- | --- |
| Eino single-agent | Last assistant text from the agent | Finalizer | No pending tools; complete evidence references; terminal task state |
| Deep | Main-agent synthesis | Finalizer | Sub-agent results synthesized; sub-agent text cannot directly finalize; terminal tool states |
| Plan-Execute | Synthesis after Replanner ends | Replanner + Finalizer | Executor step output cannot finalize; plan steps completed or explicitly blocked |
| Supervisor | Supervisor `exit` / synthesis | Supervisor + Finalizer | Transfers returned; no unhandled specialist results; supervisor owns the final synthesis |
### 6. Evidence gates for security testing
For evidence-required scenarios such as security testing, WebShell, batch validation, Workflow, and multi-agent execution, final delivery should satisfy at least these governance requirements:
- Identify the target and authorization scope.
- Provide reviewable evidence references, such as tool execution IDs, request/response summaries, screenshot paths, command-output summaries, and fact/vulnerability record IDs.
- Validate identity or impact instead of relying only on marker text.
- Record results in the project blackboard or vulnerability store, or explicitly state that no project is bound and recording is unavailable.
- Clean up, roll back, or cancel high-risk actions, or explain why cleanup was not performed.
- Do not implicitly treat still-running scans, commands, WebShell, or C2 tasks as completed.
These are governance rules, not a requirement to expose sensitive exploitation details in final reports. Evidence summaries and internal references are sufficient.
## 6. Implementation status and future improvements
### P0: Prevent false finalization (implemented)
1. `FinalizationDecision` is in place.
2. Main Agent SSE `response` events carry fields such as `data.finalized/finalizable/status/completionReason`.
3. `monitor.js` and `webshell.js` distinguish candidate output from final responses using `finalized=true`.
4. `RunResult.Response` retains its compatible field name, but promotion is controlled by the finalizer. A future split into `CandidateResponse` / `FinalResponse` could reduce misuse.
5. Plan-Execute, Deep, Supervisor, and Eino Single use the unified handler completion gate.
### P1: Strengthen the evidence chain (partly implemented)
1. `mcp_execution:<id>` is the basic evidence reference.
2. `finalization_check` events expose pending executions and missing checks.
3. Execution entry points enable explicit evidence policy. When policy requires evidence but completed tool evidence is missing, the Eino main path continues without context injection and blocks only after reaching the limit.
4. Future work: finer-grained evidence references for `record_vulnerability`, `upsert_project_fact`, and blackboard records.
5. Future work: final report templates with conclusions, evidence, risks/uncertainty, and next actions.
### P2: Experience and observability (future work)
1. Display `in_progress / verifying / finalizing / completed / blocked` on task cards.
2. Add finalizer logs and metrics: false-block rate, missing-evidence types, and pending-tool counts.
3. Offer a “Continue verification” button that builds the next input from `FinalizationDecision.MissingChecks`.
## 7. Suggested acceptance tests
Include at least these regressions:
1. **Reasoning text cannot finalize.**
Simulate a conclusive-sounding candidate in `reasoning_chain` without completed tool evidence in the current turn. The main bubble should show ongoing or blocked state, not success.
2. **Interim main-agent output cannot finalize.**
Simulate “continue verification next” in `response_start/delta`. It should enter only timeline `planning`.
3. **Unfinished background tools cannot finalize.**
A tool returns `execution_id` with state `running`. Even with a model summary, the run remains `in_progress`.
4. **Plan-Execute Executor output cannot finalize.**
The Executor reports a successful breakthrough before the Replanner ends. `messages.content` must not finalize.
5. **Supervisor sub-agent output cannot finalize.**
A sub-agent returns a definite conclusion before Supervisor `exit`. It should enter only `eino_agent_reply`.
6. **Final events require finalized metadata.**
A legacy `response` without `finalized=true` should place candidate content only in details/warnings and show blocked state in the main message, without a successful final bubble.
7. **Failure and cancellation may be terminal.**
`error` / `cancelled` may update the assistant message, but `completionReason` must be `failed` / `user_cancelled`, never successful completion.
## 8. Recommended defaults
Recommended policies for CyberStrikeAI:
```text
eino_single: suitable for lightweight tasks, with the final gate enabled
deep: recommended default for complex security testing
plan_execute: recommended for clear goals needing strict plan-execute-replan control
supervisor: use for routing among specialists, not as the general default
```
The governing rule is:
```text
messages.content may come only from FinalizationDecision.FinalText;
process_details may show the entire process;
the frontend treats only response(finalized=true) as a final response.
```

View File

@ -30,7 +30,7 @@ curl -k https://127.0.0.1:8080/api/auth/validate \
Simplest path: call Agent without pre-creating an empty conversation.
```bash
curl -k https://127.0.0.1:8080/api/agent \
curl -k https://127.0.0.1:8080/api/eino-agent \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"Run authorized basic read-only recon against 127.0.0.1"}'
@ -50,7 +50,7 @@ Then pass `conversationId` to the Agent request.
## Recipe 3: Stream Agent Output
```bash
curl -k -N https://127.0.0.1:8080/api/agent/stream \
curl -k -N https://127.0.0.1:8080/api/eino-agent/stream \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"Summarize current project facts and propose read-only next steps"}'

View File

@ -35,8 +35,8 @@ Prefer `Authorization: Bearer` for scripts. Query tokens can leak through logs.
Single-agent:
- `POST /api/agent`
- `POST /api/agent/stream`
- `POST /api/eino-agent`
- `POST /api/eino-agent/stream`
Multi-agent:
@ -217,7 +217,7 @@ Every record being removed must share a domain, IP address, or Host with the pri
| API type | Stability | Recommendation |
| --- | --- | --- |
| `/api/auth/*` | high | safe to integrate |
| `/api/agent*` | high | preferred chat entry |
| `/api/eino-agent*` | high | preferred chat entry |
| `/api/openapi/spec` | high | client generation |
| `/api/assets/*` | high | asset management and bulk import |
| `/api/config*` | medium | admin automation only |
@ -247,7 +247,7 @@ curl -k https://127.0.0.1:8080/api/conversations \
```
```bash
curl -k https://127.0.0.1:8080/api/agent \
curl -k https://127.0.0.1:8080/api/eino-agent \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"Run authorized basic recon against 127.0.0.1; avoid high-risk actions."}'
@ -258,7 +258,7 @@ curl -k https://127.0.0.1:8080/api/agent \
- Routes: `internal/app/app.go`
- Auth middleware: `internal/security/auth_middleware.go`
- OpenAPI: `internal/handler/openapi.go`
- Single-agent: `internal/handler/single_agent.go`
- Single-agent: `internal/handler/eino_single_agent.go`
- Multi-agent: `internal/handler/multi_agent.go`
- Asset endpoints: `internal/handler/asset.go`
- Asset storage and deduplication: `internal/database/asset.go`

View File

@ -24,12 +24,12 @@ flowchart LR
## Request Path
For `/api/agent/stream`:
For `/api/eino-agent/stream`:
1. Gin route enters auth middleware.
2. Handler parses message, conversation, role, uploads, and WebShell context.
3. Agent builds model input: history, role prompt, project facts, tools.
4. Pi Runner calls the model.
4. Eino Runner calls the model.
5. Tool requests go through MCP.
6. HITL may interrupt before execution.
7. Tool results are saved to process details and monitoring.

View File

@ -176,7 +176,7 @@ Scan prompts support `{{asset_id}}`, `{{target}}`, `{{host}}`, `{{ip}}`, `{{doma
Select multiple assets and choose **Create Scan Task**. The system creates one subtask per asset and links each asset to its queue and subtask.
The current defaults use manual scheduling, one concurrent task, and Pi single-Agent mode to limit load on targets and the local host. You must still confirm the test window, request rate, permitted validation methods, and approval requirements.
The current defaults use manual scheduling, one concurrent task, and Eino single-Agent mode to limit load on targets and the local host. You must still confirm the test window, request rate, permitted validation methods, and approval requirements.
### Risk calculation

View File

@ -1,6 +1,6 @@
# Asynchronous conversations
Submit to `POST /api/agent/runs` or `POST /api/multi-agent/runs` with the corresponding synchronous request body and a required `Idempotency-Key` header (1–200 bytes). Multi-agent execution must be enabled. Omit conversationId to create a conversation, or supply an existing accessible conversation.
Submit to `POST /api/eino-agent/runs` or `POST /api/multi-agent/runs` with the corresponding synchronous request body and a required `Idempotency-Key` header (1–200 bytes). Multi-agent execution must be enabled. Omit conversationId to create a conversation, or supply an existing accessible conversation.
A 202 receipt contains runId, conversationId, assistantMessageId, status and statusUrl. The Location header points to statusUrl. After acceptance the client may disconnect; execution has its own 600-minute budget. Individual model and tool limits still apply.

View File

@ -1,11 +1,138 @@
# Pi context and project checkpoints
# Retaining blackboard checkpoints after long-context compaction
Pi SessionManager retains the full JSONL session and compaction entries. The current model context is a projection of that history, not the only copy of it.
[中文](../zh-CN/blackboard-context-memory.md)
When project memory is enabled and a conversation is bound to a project, a successful `compaction_end` saves a `note/context-*` checkpoint containing the summary, conversation/agent scope, session path and real entry ID. SQLite enforces `note`, `tentative` and unpinned status, and checks project binding atomically. Rebinding a conversation prevents stale runs from updating its former project's memory.
When a conversation is bound to a project and the project blackboard is enabled, every successful compaction summary automatically saves a continuation record. Retention no longer relies only on the Agent calling fact tools before compaction.
Generated summaries are not new user instructions. Generic trace exports represent them as explicitly labeled assistant working context. Legacy imports restore user intent only from trusted structured host metadata; summary/template content and text that merely resembles a ledger are not promoted to user input. Literal `<summary>` text supplied by a user remains user content.
## Saved content and retrieval
Conversation deletion removes its Pi session scopes without touching other conversations. Uncommitted tool effects after a crash remain uncertain and require execution-record reconciliation. Final findings continue through the existing evidence/review flow.
Continuation records use `note/context-*` keys. They contain important findings, authorization constraints, progress, unsuccessful attempts, and next steps from the summary, together with the source conversation, agent scope, and snapshot path of the original pre-compaction transcript. The main agent, each sub-agent, and the planner and executor in plan-execute mode maintain separate records. Repeated compactions for the same conversation/agent update the same key.
Implementation and tests: `runtime/pi/src/worker.ts`, `internal/multiagent/pi_memory.go`, and the database checkpoint/session tests. See [Pi runtime](pi-runtime.md).
Records use `category=note` and `confidence=tentative`. They are not automatically pinned and do not overwrite confirmed facts such as `finding/*`. A record is a model-generated working summary, not an independently verified vulnerability or new authorization. Maintain formal facts and vulnerabilities with `upsert_project_fact` and `record_vulnerability`.
The compacted context includes a `get_project_fact(key)` entry point and refreshes the system's blackboard index. Read records on demand, then use `read_file` to inspect the original evidence in segments; the full history need not be injected into every model request.
The new context and blackboard record retain the same continuation summary, incorporating the absolute snapshot path, historical snapshot directory, and retrieval hints. The summary preserves the source target, purpose, and discovery context of key evidence. If a task needs a Cookie, authentication information, exact parameters, or original error text, the Agent can search the relevant snapshot and inspect nearby original text with `read_file` instead of guessing values.
Existing summary sections and the original-user-input ledger remain unchanged. The same summary adds an “original evidence retrieval hints” section with sources and keywords for tool results or key progress. It adds no new summary of user input and does not ask the model to invent filenames or line numbers.
No separate `.index.md` file is generated, no regex or keyword classification scans snapshots, and no additional model call is made. The summary itself provides the evidence retrieval entry point. Details may still be omitted; snapshots remain authoritative for original content.
## User input and system summaries have different provenance
Eino transmits its default continuation summary with the `user` message role, but also marks it with `_eino_summarization_content_type=summary`; retained skill context uses the `skills` marker. The original-user-input ledger excludes internal summaries and skill messages using this metadata. `role=user` alone cannot establish that generated content is original user input. Simulated user ledgers within summaries are not imported as original input, preventing repeated compaction from promoting model-written goals or actions into user instructions. Snapshot and summarization-model text records also identify internal messages as system-generated, not user input or new authorization.
Ledger continuation preferentially reads structured provenance metadata in system messages, rather than extracting similarly named text labels from ordinary assistant or tool responses. JSON checkpoint restoration, classic/native conversion, and system-message merging preserve this provenance. Legacy compatibility accepts only a complete host ledger block at the end of a system message, not fragments embedded in a blackboard or response.
Compacted summaries remain in the model's working context; distinguishing provenance does not discard progress. Main/sub-agent input for the current turn still comes from the original request and chat records. Text keywords such as `<summary>` are not used to filter genuine user input. Regression tests invoke the real `DefaultFinalize`, perform three compaction rounds and classic/native conversions, and check that original authorized targets and the prohibition on testing the local machine remain; generated targets and simulated instructions do not enter the user ledger; summary progress is retained; and user quotations of summary text remain genuine user input.
## Read boundaries for conversation work records and shared project facts
The design distinguishes conversation state from cross-conversation memory rather than treating every automatic summary as a shared fact. The [official LangChain memory concepts](https://docs.langchain.com/oss/python/concepts/memory) describe working state as thread-scoped and cross-conversation memory as using a separate namespace. This project retains its existing fact structure and uses the reserved `note/context-*` prefix plus source conversation identity for the corresponding read scope, without a database migration or additional model extraction.
| Content | Automatic injection and default fact tools | Explicit historical queries |
| --- | --- | --- |
| Ordinary project facts, including confirmed findings and manual notes | Existing project-sharing behavior | Existing behavior |
| Automatic continuation records from the current conversation, including its sub-agents/planner/executor | Visible and labeled as current conversation work records | Visible |
| Automatic continuation records from other conversations in the same project | Not injected; absent from default lists/searches; direct get requires the history flag | Readable with `include_history=true`, labeled as historical reference |
| Legacy continuation records without a source conversation | Not returned as current work records | Readable through explicit historical queries, labeled as unknown origin |
| Records in other projects | Unreadable through current-project tools | The history flag cannot expand project scope or bypass `project:read` |
`list_project_facts`, `search_project_facts`, and `get_project_fact` default to the current conversation scope. The first two support `source_conversation_id` to narrow queries. Filtering occurs before database pagination, preventing pinned historical records from filling a page only to be discarded later. Initial main-agent injection, sub-agent blackboard supplements, and classic/native post-compaction index refreshes explicitly pass the current conversation ID. Missing conversation identity does not fall back to injecting every automatic continuation record.
Relationship overviews, inline relationship hints, and relation edges returned by get/upsert also filter automatic continuation keys from other conversations to prevent a scope bypass through edges. The mirrored “related” section in a fact body is returned unchanged by `get_project_fact` and is not reader-filtered, so no automatic continuation keys are written into that section. Structured relation edges still respect caller scope; the current conversation's own continuation records remain available. Historical bodies include source conversation and update time. Reading them does not promote them into confirmed facts or new task authorization. `note/context-*` is a system-reserved prefix: fact-writing tools and console create/update APIs cannot create, overwrite, or rename ordinary facts into it. Only compaction writes continuation records. Deprecation/restoration tools cannot modify other conversations' automatic records. Save verified project knowledge under separate fact keys with its evidence.
These are default context-injection and fact-retrieval scopes, not a new filesystem permission boundary. They do not delete snapshots, change existing records, or remove content already present in old conversation history. Authorized users can still view all project data through project management and existing database queries without scope parameters. Existing project permissions remain enforced by tool authorization.
Validation uses two conversations in one project, another project, and legacy records of unknown origin. It covers default/explicit queries, source filters, pagination, pinned history, relation edges, reserved-key write protection, permission denial, initial main-agent injection, and index refresh after actual classic/native compaction saves. Existing blackboard-budget and original-user-ledger tests ensure scope markers do not exceed length limits or alter user input.
## Original evidence survives later compactions
Previously, every compaction wrote the same `transcript.txt`, overwriting earlier records. Each pre-compaction history is now saved to `snapshots/transcript-<first-5-MD5-characters>-<timestamp>.txt`, for example `transcript-a1b2c-20261012-010203.000000004+0800.txt`. The timestamp includes nanoseconds and timezone and records the first save. Retries with identical content compare the complete file and reuse the snapshot without changing its time or path. The short MD5 is a label, not the uniqueness check; prefix or timestamp collisions do not overwrite files. Older SHA-256 filenames remain readable and reusable without renaming, preserving references in older summaries. `transcript.txt` remains a compatibility entry point for the latest record, while continuation summaries reference specific snapshots. Snapshots use the existing conversation transcript format, retaining user, assistant, and tool records while omitting unchanged system prompts and tool/skill indexes.
Snapshots remain under `conversation_artifacts/<conversationId>/summarization/` and follow the conversation-artifact lifecycle. Sub-agents use separate scope subdirectories. Deleting a conversation removes its artifacts through existing cleanup; snapshots are not independent post-deletion backups. Files are written through atomic replacement using temporary files, with mode 0600.
With the default database at `data/conversations.db`, the main-agent layout is as follows. Summaries provide absolute paths to the Agent:
```text
data/conversation_artifacts/<conversationId>/summarization/
├── transcript.txt
└── snapshots/
└── transcript-<first-5-MD5-characters>-<timestamp>.txt
```
Filename timestamps can order snapshots. A snapshot may be saved before summary generation, including failed attempts, and retries with identical history reuse files. File order therefore does not strictly correspond to the number of successful compactions.
When the database path is empty, temporary snapshots use `<temporary-directory>/cyberstrike-summarization/<conversationId>/summarization/snapshots/` instead of sharing one directory across conversations.
Sub-agents, planners, and executors use `summarization/scopes/<scopeHash>/snapshots/`. Summaries provide historical snapshot directories; the Agent can locate `transcript-*.txt` with `glob` and read older evidence on demand. Legacy index files are unused by the new process and are not automatically deleted on upgrade.
The system reuses the compaction summary already generated, without an additional model extraction call. Original history is snapshotted before summary generation, preserving a source even when the summary omits an exact detail. Blackboard or snapshot save failures log warnings and continue with the available summary without claiming that saving succeeded.
## Configuration and boundaries
```yaml
project:
enabled: true
context_checkpoints: true
```
`context_checkpoints` defaults to enabled when omitted. Setting it to false disables automatic blackboard continuation records without affecting original-evidence snapshots. Unbound conversations still retain local snapshots and never write their contents into another project.
Before saving automatically, the system checks the conversation's current project binding. The actual SQLite upsert checks the binding again in the same write statement, preventing a project switch between checking and writing from saving an old run into the old project. A mismatch inserts no row and changes no existing record. This adds no cross-project search. Existing blackboard permissions and fact-tool conversation scopes still apply.
Automatic records are persisted only when compaction occurs; they do not replace immediate registration of new findings. Summaries may omit details; snapshots remain the source for original text. Snapshots consume local storage until their conversation artifacts are cleaned up.
## Index budgets and provenance
Automatic injection still includes only keys, short summaries, and relation edges; complete bodies stay in the database for on-demand reads. Index queries no longer load bodies that will not be injected. The character budget includes headings, boundary markers, retrieval hints, omission notices, and relationship overviews. Very small budgets use a short retrieval hint or omit the index rather than truncating HTML boundaries.
The blackboard needs no additional model compaction. Each conversation/agent's automatic continuation body is updated to the current summary; short labels are capped at 200 characters. Neither full bodies nor original snapshots are automatically injected. Retrieval entry points are attached only to continuation summaries and blackboard bodies; no full history is copied and no extra evidence-category index is maintained. Original history stays in files, and updating continuation records does not alter confirmed facts.
If snapshot writing fails, the framework's default `transcript.txt` path hint is not injected, preventing reads of a nonexistent or previous-round file. Plain-text summaries, `<summary>`-tagged text, and multipart messages retain the same retrieval entry point without duplicating it in the body.
Legacy oversized summaries are shortened to one line for index display, leaving full summaries/bodies in the database unchanged. Index-row category and confidence values are also reduced to single lines: persistence supplies defaults but does not validate these fields, so embedded newlines could otherwise inject fake rows into the system index. Relationship overviews use only facts actually included in the index, preventing out-of-budget facts from consuming context through path views. An empty index also has an empty relationship overview; an empty set does not disable filtering. Existing pinning and fact-type priorities remain unchanged.
## Implementation basis and validation
Eino compaction supports summary processing and context rewriting in `Finalize`; `Callback` runs after postprocessing. This project saves the record, attaches snapshot references, and refreshes the index within its existing custom Finalize. Ordinary messages and native AgenticMessage paths use the same retention function. See [Eino Summarization](https://www.cloudwego.io/docs/eino/core_modules/eino_adk/eino_adk_chatmodelagentmiddleware/middleware_summarization/).
Regression coverage includes early evidence surviving repeated compaction, identical-snapshot idempotency, atomic file permissions, main/sub-agent isolation, unchanged confirmed facts, disabling the setting, project mismatch, no false save-success claims, multipart summaries, automatic persistence/refresh for ordinary and native middleware, hard index budgets, and no body injection.
## Additional code-review validation
Further fixes address tool/assistant text impersonating the original-user ledger, shared temporary directories without database paths, and races between checking and writing project bindings. Regression coverage includes forged labels in tool/assistant messages, fragments embedded in system blackboards, structured-provenance JSON restoration and system normalization, rejection of invalid provenance metadata, isolated conversation directories for classic/native paths without database paths, and project switching/unbinding that rejects inserts and updates without changing existing evidence. Historical snapshots are not migrated or rewritten; production updates should correspond to the validated code revision.
## Restoration and boundary regressions
Agent traces are restored through one parser, carrying only known `summary` / `skills` provenance markers and the structured original-user ledger from system messages. `agent.ChatMessage` carries these as runtime fields. Ordinary model-request JSON excludes internal metadata; trace-specific serialization retains allowed provenance fields. Restoration does not replay old system prompts and rerenders the host ledger within the current budget. Classic/native model entry points preserve structured provenance when merging system messages, and compatibility text cannot overwrite an existing structured ledger. Ordinary user quotations of summaries or labels remain original input. Multipart summary restoration preserves progress and provenance. Tests use the same Chinese ADK settings as production and cover actual database loading and three rounds of compaction → persistence → restoration → recompaction, including classic/native conversions. These fixes cannot recover provenance already lost in old traces and do not rewrite historical records.
After an immutable snapshot succeeds, its path remains in the summary and blackboard even if updating the `transcript.txt` compatibility entry point fails; logs report that separate failure. A failed snapshot itself is never reported as saved.
Fact-key writes reject surrounding whitespace. Default SQL scope filters recognize Unicode whitespace in existing keys consistently with Go checks. Reading does not bulk-rename or migrate older records. A successfully built empty index removes the old index block while preserving other system content and the user ledger; a database read failure retains the original index.
Blackboard short labels prefer evidence retrieval hints already generated in summary section 8, falling back to the previous label method when unavailable. Only the index label changes, not summary sections 1–7, the complete body, or the original-user ledger; no model call is added. The `Context memory` CI runs concurrency regressions for agent/attackchain/app/database/handler/multiagent/project/projectprompt on macOS, Ubuntu, and Windows. Windows does not check unsupported Unix permission bits.
## Pre-release scenario acceptance
User-role messages for planning and replanning are system-generated templates containing plans and model/tool results, not new user input. Templates use a separate allowlisted provenance field. Before construction, a bounded user ledger is saved from the original uncombined messages, followed by rewriting/compaction. Role and provenance remain visible in input text and snapshots. Trace restoration and framework user-message blocks do not import templates as original user input, while their working progress remains available to the model. Ordinary user quotations of plans or summaries remain genuine input.
Restarts after context overflow or transient failure remove old instructions and indexes but preserve and rebuild the structured original-user ledger within the current budget. Budgeting the first long input includes numbering, separators, and ellipses, so available space is not wasted by dropping the whole entry. Only bounded excerpts of original text are kept, without model-generated summaries of user input. Budgets cannot retain unlimited original text; retrieve exact details from snapshots when needed.
Facts with existing surrounding-whitespace keys can have summaries/bodies updated using their original ID, project, and complete key, without renaming or changing historical relation references. Creating or renaming to noncanonical keys remains rejected. Actual HTTP partial-update regression tests cover this compatibility path.
Acceptance also covers saving long tool output as an original-text file, obtaining its file reference from snapshots after compaction/restoration, and reading the exact Cookie through the `read_file` backend in segments. A synthetic Cookie sits in the middle of 2,001 output lines and appears in neither the truncated preview nor the summary; both classic/native paths recover it completely. This guarantees evidence and retrieval entry points are available, not that a model will choose to read them in every task.
Chat input, approval interactions, and API routes retain their existing flow. New visible content consists of automatic continuation records, short retrieval hints, and a summary entry point in the attack-chain sidebar. Automatic work records from other conversations in the project are not injected by default; ordinary shared facts and manual notes retain their existing read behavior. Local snapshots accumulate for distinct compacted content and follow the conversation-artifact deletion lifecycle.
## Summaries and evidence hints in attack chains
Attack-chain analysis input uses persisted provenance metadata to distinguish actual user input, the host-retained original-user ledger, system-generated summaries, skill context, and execution templates. Generated summaries and templates are working hints, not new authorization or independent proof of vulnerabilities or tool execution. Nodes still require actual tool records. User quotations of summary text remain genuine user input; provenance is not inferred from body keywords.
Actual tool-record grounding is enforced in code, not only in prompts. `action` and `vulnerability` nodes may include `tool_call_id`, copied exactly from a host-issued call ID in the trace. Referencing an ID absent from the trace is treated as fabrication; the node and its incident edges are dropped. `target` nodes are exempt. Whether references are mandatory depends on ID visibility to the model: if all actual IDs remain visible after budget trimming, a missing reference is also dropped. If some IDs were trimmed, missing references are unmatched rather than fabricated. Multi-agent supplemental process details are dumped as raw event JSON, whose IDs are absent from the parsed trace; validation is skipped in that case, as in the `messages` table fallback, to avoid discarding real nodes. Valid references are saved in node `metadata.tool_call_id`, not `attack_chain_nodes.tool_execution_id`: that column references `tool_executions`, whereas model references are call IDs.
The attack-chain sidebar offers an expandable “Compaction summaries and evidence hints” section showing complete bodies with summary provenance from the current conversation trace. It retains immutable snapshot paths and supports copying text for source checks. Reading an existing cached attack chain also returns summaries from the current trace without regenerating nodes. Summaries are displayed separately and do not become attack nodes or affect node counts, filters, or graph exports. A conversation without tool execution can show summaries with an empty graph.
This entry point reads only the current conversation's agent trace, not a shared-blackboard aggregation of other conversations. It adds no snapshot-download or arbitrary-file-reading API. Older traces without provenance metadata are not guessed to be summaries. Older summaries removed by subsequent compaction remain retrievable through snapshot directories. Updating code does not rewrite cached nodes; choose **Regenerate** to reanalyze a chain using the new provenance labels.
Attack-chain requests discard late responses based on conversation and request order. Switching, closing, and errors clear old summaries, preventing stale content from replacing a new view. A busy concurrent regeneration returns 409 without first deleting the cached graph. Cached empty nodes and edges are always arrays, and a single node with no edges displays correctly. Regressions cover real model HTTP request input, current-conversation versus same-project isolation, cached-summary update/clearing, summary HTML rendered as text, copying and failure fallbacks, and out-of-order requests within and across conversations.

View File

@ -29,7 +29,7 @@ c2:
enabled: false
multi_agent:
enabled: true
skills:
eino_skills:
filesystem_tools: true
```
@ -78,7 +78,7 @@ knowledge:
top_k: 5
similarity_threshold: 0.4
multi_agent:
skills:
eino_skills:
filesystem_tools: false
```
@ -102,8 +102,11 @@ hitl:
tool_whitelist: [read_file, glob, grep, tool_search]
c2:
enabled: false
agent_runtime:
engine: pi
multi_agent:
eino_callbacks:
enabled: true
mode: log_only
sse_trace_to_client: false
```
Pair with proxy auth, dedicated OS user, log collection, encrypted backups, and project closeout cleanup.
@ -139,7 +142,7 @@ Goal: connect trusted internal tool services.
external_mcp:
servers: {}
multi_agent:
runtime:
eino_middleware:
tool_search_enable: true
tool_search_min_tools: 20
hitl:

View File

@ -68,26 +68,14 @@ ai:
| `ai.default_channel` | Default channel ID for new conversations and requests without an explicit channel. |
| `ai.channels.<id>` | Channel config. IDs are normalized to lowercase letters, digits, and hyphens. |
| `name` | Display name in the Web UI; falls back to the ID. |
| `provider` | `openai_compatible` or `claude`. OpenAI-compatible channels map to runtime `openai`; Claude channels use Pi's native Anthropic Messages API component. |
| `provider` | `openai_compatible` or `claude`. OpenAI-compatible channels map to runtime `openai`; Claude channels use Eino's native Anthropic Messages API component. |
| `base_url/api_key/model` | Required. Base URL usually includes a version path such as `/v1`. |
| `max_total_tokens` | Shared context budget for compression, attack-chain generation, multi-agent summaries, and similar paths. |
| `max_completion_tokens` | Per-response output cap; default is used when empty. |
| `context_window` | Runtime context window, or 0 when unknown. Channel saves can fill the detected value and retain a smaller configured window. |
| `context_profile` | Background policy, default `auto`. Recognized local backends use `local_auto`. Configuration files also accept manual `local`, explicit `economy` savings, and `custom` runtime settings. |
| `reasoning` | Default reasoning fields for the channel. Gateway support varies; try `mode: off` first when a provider rejects requests. |
The chat page reads saved channels into the “AI Channel” selector. A non-empty request `aiChannelId` selects a channel for that run/session without sending API credentials through the prompt path. Empty `aiChannelId` follows `ai.default_channel`.
### Automatic input savings
DeepSeek endpoints, explicit DeepSeek reasoning profiles and model names containing DeepSeek enable input savings automatically. With at least 16 tools, discovery declares six catalog entries, core tools and explicitly pinned tools. JSON tool results lose formatting whitespace. When an authorized local reader is available, results over 8,000 bytes become previews backed by the full output. Provider-reported reasoning tokens are shown separately within completion usage.
Channel saves and connection tests probe metadata from Ollama, llama.cpp, LM Studio, vLLM and oMLX. oMLX is identified by `owned_by: omlx`. Its matching model or alias in `/v1/models/status` supplies the preferred window, with the model list as a fallback when status access is unavailable. Generic compatible responses and private IP addresses alone do not select local optimization. Failed probes allow the channel to be saved.
The local input budget is capped at 60% of the window and 131,072 tokens, with output room reserved. An unknown window uses 32,768 tokens. Local policies tighten tool discovery and result limits, and use the `max_tokens` output field. New channels reporting only an architecture maximum retain an unknown runtime window. Changing a model or endpoint clears the previous automatic classification. These policies are applied in the background.
Compare complete tasks using input, cache hits, output and call counts to measure savings. Tool discovery and evidence readback may add calls. Explicit configuration-file overrides remain supported.
### Disabling reasoning by provider and model
Use `reasoning.mode: off` (or **Reasoning → Off** in chat) to disable reasoning. The request format depends on the channel:
@ -174,7 +162,7 @@ Reclaims disk space used by runtime artifacts. Manage it from **System settings
| `workspace` | 30 days | agent workspaces, `tmp/workspace` |
| `reduction` | 7 days | oversized tool-output spill, `tmp/reduction` |
| `conversation_artifacts` | 30 days | summaries and user-input ledger, `data/conversation_artifacts` |
| `plantask` | 30 days | multi-agent plan boards, `skills/.pi/plantask` |
| `plantask` | 30 days | multi-agent plan boards, `skills/.eino/plantask` |
| `c2_artifacts` | 30 days | C2 results/uploads/downstream/payloads, `tmp/c2` (cleaning a payload invalidates its download link) |
| `chat_uploads` | 90 days | conversation attachments, `chat_uploads` |
| `workflow_checkpoints` | 7 days | workflow run checkpoints, `data/workflow-checkpoints` |

View File

@ -10,7 +10,7 @@ CyberStrikeAI can run as a local testing tool, an internal team service, or a pr
- Python for some MCP servers and tool scripts.
- SQLite files under `data/`; no external DB is required by default.
- Actual security tools installed in PATH. YAML files under `tools/` only describe commands.
- At least one `ai.channels` entry. Use `provider: openai_compatible` for OpenAI-compatible endpoints, or `provider: claude` for Pi's native Claude component.
- At least one `ai.channels` entry. Use `provider: openai_compatible` for OpenAI-compatible endpoints, or `provider: claude` for Eino's native Claude component.
Important persistent paths:
@ -64,8 +64,6 @@ server:
tls_auto_self_sign: true
```
The generated certificate and private key are saved in `data/tls/self-signed.pem` under the configuration directory and reused across restarts and updates. The first upgrade from an in-memory certificate generates a new certificate. To rotate it, stop the service and move the file aside before starting again.
For production, use real certificates or terminate TLS at a reverse proxy. If the proxy terminates TLS and forwards HTTP to the app, avoid enabling app-side TLS on the same upstream unless `proxy_pass` uses HTTPS.
Nginx must not buffer SSE:
@ -89,13 +87,11 @@ data/ config.yaml` - is put aside and restored, and the result names every file
is modified locally or the local history has diverged from the source it refuses and says why
instead of forcing. See [the developer guide](developer-guide.md) for the full semantics.
On macOS and Linux, when started from the `cyberstrike-ai` binary alongside its config, the console
defaults to switching to the new binary after a successful build. The old service remains available
during the build. Connections briefly drop at the switch. When the new service answers, the page
reloads and reuses the current login session if it is still valid. Under **One-click update**, the
**Running build** field shows the commit of the binary serving requests. A supervisor is still useful
for starting at boot and recovering from crashes. If you defer the switch or replace the binary from the
CLI, the console offers **Restart now** on installations that support the switch.
When a supervisor is detected (systemd/launchd startup markers in the environment), the "exit after
updating" tick is pre-ticked: the process stands down after a successful update, the supervisor brings
the new binary back, and the page reloads itself once the service answers (sessions live in memory, so
one fresh login follows). Forgot the tick, or swapped the binary from the CLI? The console carries a
persistent banner with **Restart now** - no shell login needed.
The update source is a single repository address in the `update` section of `config.yaml` (`repo`),
or right on the console page: the official repository, your own fork, somebody else's repository or a

View File

@ -13,7 +13,7 @@ internal/handler/ HTTP handlers
internal/database/ SQLite access
internal/security/ auth, rate limits, shell execution
internal/mcp/ MCP server and external MCP manager
internal/multiagent/ Pi single-agent, multi-agent, middleware
internal/multiagent/ Eino single-agent, multi-agent, middleware
internal/workflow/ graph orchestration runtime
internal/knowledge/ indexing and retrieval
internal/c2/ built-in C2
@ -48,7 +48,7 @@ disagree about why an update was refused.
| entry | how it is used |
|---|---|
| console | System settings -> One-click update (`#system-update`, the old deep link still works). **Update** starts a job the page polls. Supported installations switch to the newly built binary by default, and the page reloads once the service comes back. A rollback button sits below. |
| console | System settings -> One-click update (`#system-update`, the old deep link still works). Opening this section reads the local tree only and does not go online; **Check** is what performs the fetch; **Update** starts a job the page polls; the "exit after updating" tick is pre-ticked when a supervisor is detected (launchd/systemd startup markers), and while the process is down the page watches for its return and reloads itself (sessions live in memory, so a fresh login follows); a rollback button sits below |
| REST | `GET /api/system/update` (state on disk, no network), `POST /api/system/update/check` (fetch, then report the gap), `POST /api/system/update/apply` (`202` with `job_id`, polled through `GET /api/system/update/job`), `POST /api/system/update/rollback` |
| CLI | `./cyberstrike-ai -check-update`, `./cyberstrike-ai -update`, `./cyberstrike-ai -update-rollback`. The install root is the directory holding `--config`, or the current directory when `--config` was not given |
@ -150,25 +150,28 @@ again after an interruption to finish recovery; the console reports `rollbackPen
updates. Keep the recovery record, backup directory and `.prev` file. If recorded binary hashes do not
match the files on disk, recovery refuses to overwrite them.
### Switching to the new binary
### The two restart cases
On macOS and Linux, when started from the `cyberstrike-ai` binary alongside its config, the console
sends `restart: true` as soon as you click **One-Click Update**. After a successful build and binary swap, the service closes its
application resources and executes the new binary with the same PID, arguments, environment and
working directory. Installations that cannot switch in place return `400` on an explicit restart
request. CLI updates and REST updates without `restart: true` only replace files on disk.
The process only stands down (graceful `Shutdown`, then exit 0) when the request explicitly says
`restart: true` **and** a restart hook was wired at startup. Whether it actually comes back is up to a
supervisor (systemd, `run.sh`), and the page says exactly that rather than promising a boot that may
not happen. Asking for a restart with no hook wired is a `400`, instead of stopping the service and
claiming it restarted.
**A pending binary is a durable state, and it can be activated later.** The status endpoint compares
the binary identity captured at startup (size + nanosecond mtime) with what is on disk now: after an
update, a rollback or a CLI run swapped the file without a restart, `needsRestart` is true,
`binaryBuiltAt` says when it was built, and the console grows a persistent banner with **Restart now**
(`POST /api/system/update/restart`; `409 nothing_pending` when there is nothing to activate, `409`
while a job runs, `400` when unavailable). The console checks `canRestart` before requesting automatic activation.
while a job runs, `400` without a hook). The `supervised` field comes from environment markers
(launchd's `XPC_SERVICE_NAME`, systemd's `INVOCATION_ID`/`JOURNAL_STREAM`) and only decides the tick's
default.
**The page reloads automatically.** The console polls the session validation endpoint every two
seconds for the new boot marker. When both versions support session handoff, existing sessions keep
their original expiration and permissions are loaded from the current RBAC store. The first upgrade
from an older version may still require sign-in. Leaving the console stops the polling.
**And the page recovers by itself.** While the process is down the console becomes a recovery view
that probes the status endpoint every 2 seconds: a 200 means the old process is still answering (keep
waiting), a dead connection means it is on its way out, and a 401 from a process that no longer knows
the session is the proof the restart happened - the page then `location.replace`s itself back to
`#system-update`. Leaving the console stops the watching instead of yanking the user back.
## Adding a Business Module

View File

@ -2,38 +2,53 @@
[中文](../zh-CN/frontend-i18n.md)
The web UI is a React + Semi Design single-page app. Translations come from
`web/frontend/src/lib/i18n.jsx`, backed by the same JSON files the backend ships.
CyberStrikeAI frontend i18n is static and lightweight. Text is organized in JSON files and applied through `data-i18n` attributes plus JavaScript helper functions.
## Files
```text
web/static/i18n/zh-CN.json
web/static/i18n/en-US.json
web/static/i18n/ru-RU.json
web/static/i18n/ar-SA.json
web/frontend/src/lib/i18n.jsx
web/static/js/i18n.js
```
## Runtime behavior
## Key Principles
- Preference is stored in `localStorage['csai_lang']`; otherwise it follows `navigator.language`, defaulting to `zh-CN`.
- The provider loads the active language plus `zh-CN` and `en-US` fallbacks; lookups fall back `active → zh-CN → en-US → caller default`.
- Switching language updates `<html lang>`, sets `dir="rtl"` for Arabic, and swaps Semi's `ConfigProvider` locale.
- No page reload is required; `useT()` re-renders consumers.
- Keep keys stable and semantic.
- Update Chinese and English together.
- Do not hardcode new visible text in JS when it should be localized.
- Preserve default HTML text as fallback before JS initialization.
## Usage
## HTML Usage
```jsx
const t = useT();
t('vulnerability.title');
t('common.minutesAgo', { n: 5 }); // {{n}} interpolation
t('chat.unknownKey', null, '中文兜底'); // explicit Chinese fallback
```html
<button data-i18n="common.save">保存</button>
```
Rules:
For attributes, follow the existing `i18n.js` conventions.
1. Every visible string goes through `t(...)` with a Chinese fallback as the third argument.
2. Add new keys to `zh-CN.json` and `en-US.json` together; `ru-RU`/`ar-SA` may lag and rely on the fallback chain.
3. Format dates with `formatDateTime`/`relativeTime` from `src/lib/format.js`.
4. Keep keys two levels deep (`<domain>.<key>`) and stable across releases.
## JavaScript Usage
Use the global translation helper where available:
```javascript
const label = t('common.save');
```
When adding dynamic UI, make sure language switching refreshes the text or re-renders the component.
## Migration Workflow
1. Add or update UI text.
2. Add keys to `zh-CN.json`.
3. Add matching keys to `en-US.json`.
4. Replace hardcoded text with `data-i18n` or `t()`.
5. Test both languages and browser console.
## Common Pitfalls
- Missing keys only in one language.
- Dynamic text built from hardcoded fragments.
- Button labels too long in English.
- HTML fallback text diverges from JSON text.
- Adding new page text without updating language switch behavior.

View File

@ -106,7 +106,7 @@ Allowlisted tools skip approval, so keep the list stable and low-risk. Recommend
- Execution and task-state reads: `get_tool_execution`, `wait_tool_execution`, `batch_task_list`, `batch_task_get`
- Local management-metadata reads: `manage_webshell_list`, `c2_event`, `c2_file`
These built-in MCP reads remain constrained by RBAC and resource scope; the allowlist only bypasses HITL approval and does not grant additional access. `list_dir` is effective only when that is the actual tool name; the Pi filesystem directory-listing tool is named `ls`.
These built-in MCP reads remain constrained by RBAC and resource scope; the allowlist only bypasses HITL approval and does not grant additional access. `list_dir` is effective only when that is the actual tool name; the Eino filesystem directory-listing tool is named `ls`.
Avoid globally allowlisting:

View File

@ -1,99 +0,0 @@
# HTTP test tool proxy pool
[中文](../zh-CN/http-proxy-pool.md) | [Documentation home](README.md)
`http-framework-test` accepts a user-supplied proxy list and/or provider endpoint. It switches proxies within a bounded attempt budget on transport failures or configured HTTP status codes, and reuses a successful proxy. Settings → Proxy settings can manage egress for this HTTP tool; the default remains per-call arguments.
## Usage
After updating the tool file, apply configuration in settings or restart the service to reload its parameters. The proxy submenu also supports persistent settings that apply to subsequent invocations without restarting active processes.
Example MCP tool arguments:
```json
{
"url": "https://your-authorized-target.example/health",
"method": "GET",
"proxy_pool": "[\"http://127.0.0.1:8081\",\"http://127.0.0.1:8082\"]",
"proxy_max_attempts": 3,
"proxy_cooldown": "60",
"proxy_fail_status": "403,429",
"response_max_bytes": 8192
}
```
`proxy_pool` also accepts newline-separated endpoints. Supported forms are `http://host:port`, `https://host:port`, `socks5://host:port`, and bare `host:port` (HTTP). An explicit port is required. IPv6 brackets and URL-encoded `user:password@host:port` credentials are supported. SOCKS support is included in the `httpx[http2,socks]` requirement.
To fetch proxies automatically, add or use `proxy_source` alone:
```json
{
"url": "https://your-authorized-target.example/health",
"proxy_source": "https://your-proxy-provider.example/api/proxies"
}
```
The endpoint must return UTF-8 newline-separated endpoints, a JSON array of endpoint strings, or an object containing a `proxies` or `data` array:
```json
{"proxies": ["http://127.0.0.1:8081", "127.0.0.1:8082"]}
```
Entries may also be objects such as `{"host":"127.0.0.1","port":8081,"scheme":"http","username":"user","password":"pass"}` (`ip` aliases `host`) or `{"url":"http://127.0.0.1:8081"}`. Scheme defaults to HTTP, credentials are optional and automatically URL-encoded. Other provider formats require an adapter. No public free-proxy sources are built in. The source is fetched at startup and at most once more per request/redirect hop when available candidates run out. New endpoints are deduplicated and merged without clearing cooldowns. Fetches have 10-second connect/read timeouts, do not follow redirects, accept at most 1 MiB, and the pool holds at most 256 endpoints. An initial fetch failure warns and uses static endpoints when available; source-only calls fail. A refresh failure preserves the last HTTP failure response, or reports an error if no response exists.
## Behavior
| Parameter | Default | Meaning |
| --- | --- | --- |
| `proxy_pool` | Empty | JSON string array or newline-separated list |
| `proxy_strategy` | `"sticky"` | `sticky` reuses successful proxies; `round_robin` rotates and skips cooldowns |
| `proxy_source` | Empty | User-configured HTTP(S) provider endpoint, optionally combined with a list |
| `proxy_max_attempts` | `3` | 1–10 distinct proxy attempts per request/redirect hop |
| `proxy_cooldown` | `"60"` | 0–86400 seconds before a failed proxy is eligible again |
| `proxy_fail_status` | `"403,429"` | Comma-separated status codes from 400–599; `"none"` disables status-based switching |
- Successful proxies stay selected by default. With `proxy_strategy="round_robin"`, each request/redirect hop rotates through eligible proxies. Failed proxies enter cooldown. Each proxy is tried at most once per request/redirect hop.
- Only GET, HEAD and OPTIONS are replayed automatically. POST, PUT, DELETE and other methods retain the first result. An explicit `repeat` still requests additional executions.
- Transport failures before response headers can trigger switching. Failures while reading a response body are reported without replaying a partial response.
- A 429 with a valid future `Retry-After` stops automatic replay and reports that the caller should retry later. Further requests to that origin within the same tool invocation are blocked until the wait expires; waits are recorded for at most 24 hours.
- If the final attempt returns an HTTP failure response, it is preserved with a nonzero exit code. A network failure or a pool with all endpoints cooling down reports an error. There is no direct fallback or extra direct DNS/TCP/TLS target probe.
- Pool diagnostics show attempt numbers, proxy numbers and failure types. They omit proxy credentials and provider URLs. The platform's existing argument traces, audit records and logs still apply; treat arguments containing credentials as sensitive configuration.
## Scope and design
[#357](https://github.com/AIPentest/CyberStrikeAI/issues/357) requests automatic proxy acquisition and switching after a ban, without specifying providers, detection or tool scope. This implementation starts with `http-framework-test`, where both HTTP and decrypted HTTPS responses can be inspected. A standalone forwarding proxy cannot read HTTPS responses inside a CONNECT tunnel. See the [HTTPX proxy](https://www.python-httpx.org/advanced/proxies/) and [transport](https://www.python-httpx.org/advanced/transports/) documentation.
A 403 can be an application authorization failure; a 429 can apply to an account or other scope. Status matching is a configurable policy, not proof of an IP ban. CAPTCHA or HTTP 200 block pages remain unchanged. Replay and waiting rules are informed by [RFC 9110 §9.2.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.2.2) and [RFC 6585 §4](https://www.rfc-editor.org/rfc/rfc6585.html#section-4).
Pool state lasts for one tool invocation. Other scanners, `exec`, Pi `execute`, external MCP servers and LLM API connections are outside this pool; the settings submenu manages only this HTTP tool. Provider fetching uses a separate client with TLS verification and no target cookies, target Authorization, environment proxies or inherited `allow_insecure`. Use HTTPS for production provider endpoints.
## Troubleshooting and source
| Message | Action |
| --- | --- |
| `Proxy pool exhausted` | Check endpoint connectivity, wait for cooldown, or replace the list/provider results |
| `failure policy still matched` | Inspect the preserved response and distinguish IP restrictions from normal authorization/rate limits; adjust `proxy_fail_status` if needed |
| `Retry-After is still active` | Wait for the target's requested delay before another call |
| `Could not fetch proxy source` | Check provider connectivity, authentication and TLS; target `allow_insecure` does not affect provider connections |
| `SOCKS support requires ...` | Install `httpx[socks]` in the tool's Python environment or update its requirements |
The implementation and MCP parameter definitions are in [tools/http-framework-test.yaml](../../tools/http-framework-test.yaml); regression scenarios are in [scripts/test_http_proxy_pool.py](../../scripts/test_http_proxy_pool.py).
## Local verification
```sh
python3 -m pip install 'httpx[http2,socks]>=0.27.0' PyYAML
python3 -m unittest discover -s scripts -p 'test_http_proxy_pool.py' -v
```
Tests execute the code read from the tool YAML against local HTTP proxies, CONNECT tunnels and TLS servers. No external targets or real providers are contacted. The HTTPS fixture requires `openssl`.
## Managed settings and stable egress
Settings → Proxy settings offers manual arguments, a fixed proxy, or a pool. Fixed mode keeps the configured endpoint across calls and does not fail over. Pool mode offers sticky or round-robin selection with a minimum switch interval (60 seconds in the settings form). The interval also prevents early failover: return the failure response/error instead. Timing is invocation-local; use fixed mode and a provider with fixed egress for stability across calls. A fixed URL alone cannot guarantee the provider's public IP.
`PUT /api/config` persists the `proxy` object and applies it to future HTTP tool invocations. GET masks `proxy_url`, `proxy_pool`, and `proxy_source`; preserve `********` to keep a saved value or send an empty string to clear it. The settings list accepts one URL per line; provider responses may still use structured entries. See `config.example.yaml`. Managed values override model-supplied proxy arguments through a process-local environment snapshot, never global HTTP_PROXY or command arguments. This is not a network sandbox for arbitrary shell commands.
Design references: [Zyte sessions](https://docs.zyte.com/zyte-api/usage/features.html#sessions) motivate stable IP/cookie conditions; [HTTPX clients](https://www.python-httpx.org/advanced/clients/) motivate connection reuse; [Nuclei](https://docs.projectdiscovery.io/opensource/nuclei/running) exposes distinct proxy/rate controls; [Nmap](https://nmap.org/book/man-bypass-firewalls-ids.html) documents limits on which scan phases support proxies. Other Kali tools retain native routing, proxy and rate settings. No output-based ban guessing or process restarts are introduced.
LLM API transports, streams and retry/backoff remain separate from the scan pool. Account/token rate limits are handled by existing provider retry policies. Stable public-IP requirements depend on the provider; this feature never rotates model API egress.

View File

@ -100,8 +100,8 @@ Use logs to improve content:
- Manager: `internal/knowledge/manager.go`
- Index pipeline: `internal/knowledge/index_pipeline.go`
- Chunking: `internal/knowledge/splitter.go`
- Chunking: `internal/knowledge/chunk_eino.go`
- Retriever: `internal/knowledge/retriever.go`
- Native retrieval pipeline: `internal/knowledge/retrieve_chain.go`
- Eino chain: `internal/knowledge/eino_retrieve_chain.go`
- Rerank: `internal/knowledge/rerank_http.go`
- MCP tools: `internal/knowledge/tool.go`

View File

@ -81,6 +81,6 @@ Before connecting an external MCP, ask:
- External manager: `internal/mcp/external_manager.go`
- Recovery: `internal/mcp/connection_recovery.go`
- Tool adapter: `internal/agentruntime/mcp_tools.go`
- Tool adapter: `internal/einomcp/mcp_tools.go`
- Handler: `internal/handler/external_mcp.go`
- Invoke notification: `internal/agentruntime/tool_invoke_notify.go`
- Invoke notification: `internal/einomcp/tool_invoke_notify.go`

View File

@ -1,38 +0,0 @@
# Pi runtime
CyberStrikeAI uses Pi 1.7.0 as its only runtime. Go owns business state, permissions, MCP execution, evidence, and delivery checks; an isolated Node worker hosts the Pi SDK. The source repository is [Sycun/CyberStrikeAI](https://github.com/Sycun/CyberStrikeAI).
Prefer public APIs from the pinned Pi SDK. Add host or worker logic where project permissions, business records, or compatibility require it.
## Build
Node.js >=22.19 and the Go version in go.mod are required:
```sh
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```
The launcher and self-update build prepare the worker. The new server also prepares a missing matching bundle at startup and checks the worker handshake before accepting requests. This covers the first upgrade from Eino, whose old updater only builds Go. Preparation requires Node.js >=22.19, npm and access to the locked npm dependencies; failures stop startup with an actionable error. An existing matching bundle starts without npm or dependency downloads. Dependency installation uses the lockfile with lifecycle scripts disabled. Complete bundles are published under `runtime/pi/.builds/<source fingerprint>`; running workers keep their original dependencies, and source rollback selects the corresponding old bundle. Retain the runtime sources and matching bundle when deploying, or rebuild on the destination. A Go binary alone is insufficient for Pi.
After pulling a worker fix into a source installation, run `bash scripts/build-pi-runtime.sh` in that installation before restarting the service. If `agent_runtime.worker_path` is set, make sure it points to the rebuilt worker. Keep existing session files: the worker corrects interrupted OpenAI-compatible tool batches when preparing model requests.
Chat Completions channels outside the native OpenAI service send instructions with the `system` role. This prevents Pi from switching to an unsupported `developer` role when thinking is enabled, while preserving the configured reasoning options. Primary models, fallback models and background generation share this setting. Native OpenAI channels and the Responses/Anthropic protocols keep the SDK's role handling.
## Configuration
`agent_runtime.engine` accepts only `pi` (also the default). The former engine and dependencies have been removed. Optional `node_path`, `worker_path`, and `session_dir` control deployment. The retired `agent_runtime.purge` key is ignored on load and removed when system settings are saved.
The model worker uses HTTP/1.1 and respects the service's `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables. Model redirects stay on the original origin to protect credentials.
Deleting a conversation turn removes all of its persisted Pi mode/child sessions and advances a database revision; the next request imports the remaining database history. A running conversation must be stopped before deleting a turn. Session roots are retained in the database across configuration changes and restarts so deletion cleans both old and new locations.
Pi's `SessionManager` opens `session.jsonl` directly for new conversations. Existing conversations keep using the file referenced by their `current-session` pointer, preserving saved evidence paths. If rolled back to an older worker, it rebuilds the context for new-format sessions from the history supplied by the host without loading their Pi compaction records.
Chat agents, specialists and workflow Agent nodes use Pi. User steering goes through Pi's native queue.
Workflow now uses a native DAG and versioned JSON checkpoints. Old Eino Workflow binary checkpoints cannot be resumed by this version; finish those runs before upgrading, or export their material and start new Pi tasks. Knowledge retrieval and indexing use native domain types and HTTP embeddings. Old configuration keys are read as data migration only; saving emits the native skills/runtime keys. Legacy URL aliases call the same Pi handlers and cannot select a different engine.
See the [Chinese implementation and validation guide](../zh-CN/pi-runtime.md) for protocol, recovery and test details. Local fixtures establish functional behavior, not live-provider reliability, refusal-rate improvements or production acceptance.
The example configuration follows Sycun/CyberStrikeAI. Existing installations retain their own update source, which must be checked separately; this source migration does not deploy or change a running production configuration.

View File

@ -46,7 +46,7 @@ Server `POST /api/auth/login` returns `{ token, expires_at }`. There is **no ref
| Local check | Re-check `expires_at` + `GET /api/auth/validate` every 30s |
| Server probe | Immediate probe when DevTools panel becomes visible |
| Unreachable | Show warning; keep token during transient outage |
| 401/403 | Clear token and require re-authentication |
| 401/403 | Clear token (server restart clears in-memory sessions) |
| Before Send | `ensureAuthReady()` before SSE |
| Permissions | `optional_host_permissions` — request origin on Validate |
@ -62,7 +62,7 @@ After extension reload, close DevTools completely and reopen F12 (stale panel co
- Login: `POST /api/auth/login`, then `GET /api/auth/validate`.
- Persist `expires_at`; re-login when expired (no silent refresh).
- Prefer `/api/agent/stream` or `/api/multi-agent/stream` (SSE).
- Prefer `/api/eino-agent/stream` or `/api/multi-agent/stream` (SSE).
- Large files: `/api/chat-uploads`, then reference in message.
- Full spec: `/api-docs` or `/api/openapi/spec`.
@ -117,4 +117,4 @@ Plugins should not bypass platform controls:
- Capture: `devtools.js`, `background/service-worker.js`
- OpenAPI: `internal/handler/openapi.go`
- External MCP: `internal/handler/external_mcp.go`
- Web auth reference: `web/frontend/src/lib/auth.jsx`
- Web auth reference: `web/static/js/auth.js`

View File

@ -53,7 +53,6 @@ SQLite migrations must be:
```bash
go test ./internal/...
go test ./cmd/...
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```

View File

@ -566,4 +566,4 @@ Check in this order:
- All platforms: **text messages only**; other types (e.g. image, voice) are not supported and may be ignored.
- Personal WeChat: **private chat only**—group @-bot is not supported.
- Bot data is shared with the web UI: under `user_binding` it belongs to the bound user; under `service_account` it belongs to the service account and is shared by allowlisted senders.
- Bot execution uses the same **Pi single/multi-agent** path as the web UI (`ProcessMessageForRobot`, with progress callbacks and process details stored in the DB); only the final reply is sent back to personal WeChat/DingTalk/Lark/WeCom in one message (no SSE). Default: `robot_default_agent_mode: single`.
- Bot execution uses the same **Eino single/multi-agent** path as the web UI (`ProcessMessageForRobot`, with progress callbacks and process details stored in the DB); only the final reply is sent back to personal WeChat/DingTalk/Lark/WeCom in one message (no SSE). Default: `robot_default_agent_mode: eino_single`.

View File

@ -66,5 +66,5 @@ For SSRF, a Skill describes the test procedure; the KB stores metadata addresses
- Validation: `internal/skillpackage/validate.go`
- Service: `internal/skillpackage/service.go`
- Pi Skills: `internal/multiagent/pi_local_tools.go`
- Eino Skills: `internal/multiagent/eino_skills.go`
- Handler: `internal/handler/skills.go`

View File

@ -40,7 +40,7 @@ Expand testing when changing:
- `internal/multiagent/`: streaming, tool calls, summarization, retry, HITL;
- `internal/security/`: auth, shell, timeout, no-output;
- `internal/database/`: old data compatibility;
- `web/frontend/src/pages/chat/`: chat, process details, attack chain, groups.
- `web/static/js/chat.js`: chat, process details, attack chain, groups.
## Test Data

View File

@ -1,17 +1,72 @@
# Pi token usage monitoring
# Token usage monitoring: research and implementation
Pi reports usage; Go accumulates completed model turns and emits `agent_usage_summary` into the existing database and timeline. Local statistics are not a provider billing statement and may not cover every auxiliary HTTP request.
[中文](../zh-CN/token-usage-monitoring.md)
Prompt tokens are Pi input + cacheRead + cacheWrite. Completion tokens are output, and total is prompt + completion. Cache details are already included and must not be added again. The usage view shows provider-reported reasoning tokens as a subset of completion tokens. Model-call counts reflect observed turns. Missing reasoning/cache details mean unreported data, not proven zero use.
Research date: 2026-10-11.
The dashboard and Settings usage view retain period, model and project filters. APIs are `GET /api/usage/tokens` and `GET /api/conversations/:id/token-usage`. Existing usage rows and historical timeline backfill remain compatible.
## Research findings
Streaming updates carry deltas; complete messages are committed at message end. Implementation: `internal/multiagent/pi_runner.go` and `internal/database/model_token_usage.go`. See [Pi AI](https://github.com/earendil-works/pi/tree/v1.7.0/packages/ai).
| Reference | Official capability | Design adopted by this project |
| --- | --- | --- |
| [ZCode usage statistics](https://zcode.z.ai/cn/docs/usage-stats) | Separates local session statistics from remote coding-plan quotas; supports date ranges, daily trends, and model shares | A local usage view with 7/30/90-day ranges, daily trends, model shares, and details; initially designed as an expandable dashboard panel |
| [DeepSeek context caching](https://api-docs.deepseek.com/guides/kv_cache/) | Response usage distinguishes input cache hits and misses with `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens` | Map cache hits to the standard OpenAI cache-read field; do not map misses to cache writes |
| [Eino v0.9.21](https://github.com/cloudwego/eino/releases/tag/v0.9.21), [schema PR #1309](https://github.com/cloudwego/eino/pull/1309) | The stable release adds `PromptTokenDetails.CacheWriteTokens`, retaining cache reads, input, output, and reasoning fields | Carry the stable standard fields through streaming merges, run summaries, the database, and UI |
| [Eino-ext PR #1015](https://github.com/cloudwego/eino-ext/pull/1015) | Model adapters forward cache-write counts | Upgrade agenticclaude to 0.1.7, agenticopenai to 0.2.4, and the corresponding OpenAI ACL, rather than upgrading only the framework |
| [Eino callbacks and tracing](https://www.cloudwego.io/docs/eino/quick_start/chapter_06_callback_and_trace/) | Component callbacks can collect model lifecycle, usage, and duration data | Retain existing run-event collection; covering every internal call would require a separate unified model-call ledger |
## DeepSeek
Versions were checked through Go module resolution and local source inspection; the 0.10 alpha was not adopted. Raw DeepSeek fields do not automatically enter Eino's standard cache-read count, so the project's existing HTTP compatibility layer supplies the mapping for ordinary JSON and SSE streaming responses. Existing standard `cached_tokens` takes precedence. Unknown fields are preserved as RawMessage to avoid loss of numeric precision through floating-point conversion.
In the channel’s reasoning settings, use `off` for simple Q&A and format conversions or pair `auto` with `low` to keep reasoning on at a lower effort. The official API defaults to `high` when effort is unspecified and maps `medium` to `high`. The channel sends its per-request output limit as `max_tokens`, shared by reasoning and the visible answer. Compare output tokens, reasoning tokens and the cache hit rate for the same tasks at different effort levels. [DeepSeek Thinking Mode](https://api-docs.deepseek.com/guides/thinking_mode/) · [Chat Completions](https://api-docs.deepseek.com/api/create-chat-completion/)
## Metric definitions
The official API automatically caches reusable request prefixes. Pi orders MCP tool definitions by name so the same catalog introduces fewer prefix changes across requests. The provider reports the actual cache hits. [DeepSeek Context Caching](https://api-docs.deepseek.com/guides/kv_cache/)
- `promptTokens`: all input reported by the model.
- `completionTokens`: all output, including reasoning counted as output by the provider.
- `totalTokens`: the provider's total; falls back to input plus output when absent.
- `cachedTokens`: the cache-read portion of input.
- `cacheWriteTokens`: the cache-write portion of input.
- `reasoningTokens`: the reasoning portion of output.
- Cache reads, cache writes, and reasoning are breakdowns and must not be added to the total again. The cache-read share of input is `cachedTokens / promptTokens`; a dash is shown when there is no input.
- A streaming model output may report cumulative counts multiple times. The merge retains the maximum for each field and adds the output to the run summary only once when it ends. Usage already received can be retained even if the output subsequently fails.
Input savings activate in the background for the official DeepSeek endpoint, explicit `deepseek` / `deepseek_compat` reasoning profiles, and model names containing `deepseek` (case-insensitive). At 16 tools, native discovery keeps six catalog entries plus core tools and explicit always-visible tools available. Other builtins load on demand. With authorized file access, results over 8,000 bytes become head/tail previews backed by the full output. Tighter configured limits take precedence. Valid JSON tool results lose formatting whitespace, including when replaying older sessions. Strings and numeric lexemes retain their original text. Existing configuration-file overrides remain supported. Compare complete tasks, including discovery/readback calls and evidence quality, to measure actual savings.
DeepSeek cache misses are not equivalent to Claude cache writes. Text length cannot establish billing-grade counts, and an absent field does not prove that the provider used no cache. New fields on older records default to 0, meaning that the breakdown was not recorded.
## Entry points and data flow
Click the dashboard **Token Usage** card to open **System Settings → Token Usage**, or open the section directly from the settings submenu. The dashboard card shows total usage for the last seven days; its subtitle shows only the cache-hit rate (cache-read tokens / input tokens). Call counts and daily usage remain on the detail page. The detail page supports the current project scope, 7/30/90-day ranges, eight metrics, up to 20 model-ranking entries grouped by the run's configured model, daily trends and full daily details, and up to 20 recent runs. It loads independently, supports manual refresh and request cancellation, and does not refresh the whole dashboard when the range changes. Reloading the page retains the settings section.
The detail page separates four primary metrics (total, input, output, and cache-read share of input) from four secondary metrics (calls, cache reads, cache writes, and reasoning). Trends switch between total tokens, model calls, and cache-hit rate. Hover over or keyboard-focus a bar to see the date and exact value; switching chart metrics does not request the API again. The cache donut separates cache reads from remaining input instead of adding cache or reasoning to the total. Model details include share bars; daily numeric details are collapsed by default; recent runs distinguish complete and partial records. Metric definitions can be expanded.
Daily charts use the server dates returned by the API and fill only gaps between returned dates; they do not guess the query endpoint from the browser timezone. Charts and wide tables scroll horizontally within their own areas on small screens. No records and unavailable statistics have distinct empty and unavailable states.
### UI research basis (2026-10-12)
| Reference | Design adopted |
| --- | --- |
| [DeepSeek Context Caching](https://api-docs.deepseek.com/guides/kv_cache/) | Its explicit cache-hit/miss input definitions inform the cache composition view; the ratio uses tokens, not request counts |
| [LiteLLM Usage](https://docs.litellm.ai/docs/proxy/ui/chat_ui) | Separate range selection, core metrics, and usage logs; retain the existing data scope without adding costs or success rates that cannot be measured accurately |
| [Langfuse Custom Dashboards](https://langfuse.com/docs/metrics/features/custom-dashboards) | Separate summaries, time trends, and model distribution into readable areas, with switchable trend metrics |
Full DeepSeek and GLM console pages were not publicly readable during that research. The visual design therefore used verifiable open-source dashboards and does not claim to reproduce their current authenticated interfaces. The project adds no provider billing, budget, or savings estimates.
Run events → streaming/non-streaming usage accumulation → `eino_usage_summary` → `process_details` and `model_token_usage` → existing `/api/usage/tokens` and conversation usage endpoints → dashboard and chat summaries.
`model_token_usage.cache_write_tokens INTEGER NOT NULL DEFAULT 0` was added. Existing declarative SQLite schema reconciliation adds the column at startup; older databases need no manual migration. Existing event-ID idempotency, foreign-key deletion relationships, and historical backfills remain in effect. Daily grouping uses the server's local timezone, matching the dashboard's “Today” boundary.
Provider model names are rendered as text nodes. Tables scroll locally on mobile, and labels support Chinese, English, and Russian. Chat-turn tooltips, the main conversation timeline, and WebShell timelines also include cache writes.
## Current scope and future work
Statistics use recorded Agent output events, including sub-agents in the existing collection path. They are **not a site-wide API request ledger**. Compaction, retrieval embeddings, hidden model calls, and requests without usage data are not fully covered. Consumption whose final usage was lost through request cancellation cannot be reconstructed.
Model rankings group by the model name configured for the run. A failover run may mix multiple models, so rankings cannot be used for per-model billing. Each recent entry is a run summary, not an individual HTTP request. Model call counts include only outputs with nonempty usage.
Costs and remaining plan quotas are not displayed. Custom gateways and subscription plans have different pricing and billing rules; multiplying tokens by a fixed price cannot reliably represent cost. Complete cost management would first require a per-request ledger covering call origin, actual provider and model, success/error/cancellation, duration, TTFT, whether usage was returned, price version, and currency. It should cover main/sub-agents, compaction, retries, and embeddings, with separate provider quota integrations.
## Validation
The Chinese guide records these implementation-time checks; this translation does not represent a new execution of them:
- `go test ./...`: the full repository passed.
- `node --test web/static/js/*.test.cjs`: 295 tests passed.
- Regression coverage was added for cache-write persistence, grouping, recent entries, adding the column to older schemas, user visibility, streaming deduplication, and total-token fallback.
- DeepSeek JSON/SSE cache-field conversion, standard-field precedence, preservation of error/termination chunks, and very large number precision passed validation.
- Browser checks used synthetic data for desktop, 390px mobile, dark mode, model-name escaping, empty data, and unavailable API states. No real run database or paid model was accessed.

View File

@ -2,7 +2,7 @@
[Back to English documentation](README.md)
This document describes how CyberStrikeAI governs long-running tools, blocking MCP calls, oversized outputs, cancellation, and context restore. The goal is to preserve standard Agent/Pi tool semantics while preventing tool hangs, context blowups, oversized database records, and unsafe resume behavior.
This document describes how CyberStrikeAI governs long-running tools, blocking MCP calls, oversized outputs, cancellation, and context restore. The goal is to preserve standard Agent/Eino tool semantics while preventing tool hangs, context blowups, oversized database records, and unsafe resume behavior.
## Goals
@ -15,7 +15,7 @@ This document describes how CyberStrikeAI governs long-running tools, blocking M
## Execution Model
Tool calls still appear to Pi/Agent as standard tool invocations, but the blocking work runs in a worker:
Tool calls still appear to Eino/Agent as standard tool invocations, but the blocking work runs in a worker:
```text
Agent calls tool
@ -67,7 +67,7 @@ Typical flow:
4. If still incomplete, continue waiting or call cancel_tool_execution
```
`tool_wait_timeout_seconds` applies to internal MCP tools, external MCP tools, and Pi filesystem's streaming `execute`. Pi's non-streaming filesystem tools such as `ls/read_file/write_file/edit_file/glob/grep` are recorded in execution monitoring, but they are not converted into resumable background workers.
`tool_wait_timeout_seconds` applies to internal MCP tools, external MCP tools, and Eino filesystem's streaming `execute`. Eino's non-streaming filesystem tools such as `ls/read_file/write_file/edit_file/glob/grep` are recorded in execution monitoring, but they are not converted into resumable background workers.
## Cancellation and Session Cleanup
@ -98,11 +98,11 @@ agent:
## Output Governance
CyberStrikeAI uses `multi_agent.runtime.reduction_max_length_for_trunc` as the unified tool result cap. The example configuration uses 50000 bytes.
CyberStrikeAI uses `multi_agent.eino_middleware.reduction_max_length_for_trunc` as the unified tool result cap. The example configuration uses 50000 bytes.
```yaml
multi_agent:
runtime:
eino_middleware:
reduction_enable: true
reduction_max_length_for_trunc: 50000
```
@ -114,7 +114,7 @@ Coverage:
| Agent-facing tool result | Uses the canonical capped result |
| DB / monitor storage | Stores the same canonical result |
| `get_tool_execution` / `wait_tool_execution` | Reads the same canonical result |
| Pi `execute` / filesystem monitor records | Capped before completion is persisted |
| Eino `execute` / filesystem monitor records | Capped before completion is persisted |
| Non-streaming `exec` stdout/stderr | Source-side bounded buffer |
| Streaming `exec` stdout/stderr | Streamed UI output is also bounded |
| PTY execution path | Uses the same output cap |
@ -176,7 +176,7 @@ agent:
shell_no_output_timeout_seconds: 1200
multi_agent:
runtime:
eino_middleware:
reduction_enable: true
reduction_max_length_for_trunc: 50000
```
@ -222,11 +222,7 @@ Expected behavior:
## Task-owned process lifetime
Each task has a distinct `runId`. Local commands and detached MCP workers retain ownership through context values. Managed `exec ... &` and Pi background execution return promptly but cannot outlive task cleanup. Unowned background launches are rejected. Cleanup seals process and worker admission, cancels workers, terminates processes and waits for reaping. Interrupt-and-continue retains ownership; SSE disconnection does not end the task. Failed cleanup retains the conversation slot and reports `cleanup_failed`; a 15-second sweep retries it.
Set `CS_CLEANUP_GRACE`, `CS_CLEANUP_KILL`, and `CS_CLEANUP_GUARD` to positive Go durations (for example, `10s`) to tune the graceful exit wait, post-SIGKILL wait, and isolation backend wait. Each defaults to 3 seconds when unset or invalid.
On Linux, only-zombie process groups count as exited once the direct child has been reaped. With the process group watchdog, if cleanup times out and every surviving member is in uninterruptible sleep (D) with SIGKILL pending, the task reports `cleanup_unconfirmed` after local workers finish. The service log records the run ID and PGID. The kernel delivers the pending signal when the process can exit. The cgroup and Windows Job Object backends still require their own exit verification.
Each task has a distinct `runId`. Local commands and detached MCP workers retain ownership through context values. Managed `exec ... &` and Eino background execution return promptly but cannot outlive task cleanup. Unowned background launches are rejected. Cleanup seals process and worker admission, cancels workers, terminates processes and waits for reaping. Interrupt-and-continue retains ownership; SSE disconnection does not end the task. Failed cleanup retains the conversation slot and reports `cleanup_failed`; a 15-second sweep retries it.
### Kernel containment and crash recovery

View File

@ -1,11 +0,0 @@
# Vulnerability report download
Click the download icon beside a vulnerability. A dialog offers **Markdown (.md)** and **Word (.docx)**. Choosing a format downloads only that finding. Cancel or Escape dismisses the dialog without downloading. A failed download leaves the dialog available for retry.
Markdown retains the existing content, UI language and filename. Word includes the selected finding's metadata, description, prerequisites, reproduction steps, evidence, impact, remediation and retest records. Original statuses remain intact. Evidence is plain text; embedded HTML, Markdown formatting and screenshots are not rendered.
The feature creates no automatic tasks, database schema changes or stored report artifacts. No Office, Python or Pandoc installation is required on the server. The Word viewer needs Chinese font support.
Word uses `GET /api/vulnerabilities/:id/download?format=docx`, authorized with `vulnerability:read` and the finding's resource scope. No file-management permission is needed. The endpoint also accepts `format=md`. Unsupported formats return 400, missing records 404 and unauthorized access 403. Word body input is limited to 8 MiB.
Existing page-level Markdown batch export is unchanged.

View File

@ -248,7 +248,7 @@ Runs an LLM Agent task. Supports multiple modes.
| Field | Description | Default |
|-------|-------------|---------|
| Agent mode | `single` / `deep` / `plan_execute` / `supervisor` | `single` |
| Agent mode | `eino_single` / `deep` / `plan_execute` / `supervisor` | `eino_single` |
| Input source | Template for upstream data | `{{previous.output}}` |
| Node instruction | Task description for this node | empty |
| Output variable name | Key written into `outputs` | `agent_result` |
@ -264,7 +264,7 @@ After execution:
- `previous.output` becomes this node’s response text
- If **Output variable name** is set, the value is also stored in `outputs[variable_name]`
- The native DAG invokes Pi for Agent nodes and persists node state in Go checkpoints
- In the Eino graph, the Agent node is split into `prepare → execute → finalize` for clearer trace and future checkpointing
### 5.3 Tool
@ -310,7 +310,7 @@ Edge condition examples (select an edge, configure in the right panel):
### 5.5 HITL (human-in-the-loop)
Human approval checkpoint. The run pauses before this node through the native Workflow checkpoint and resumes after approval via API or the monitor panel.
Human approval checkpoint. The run pauses before this node through Eino interrupt/checkpoint and resumes after approval via API or the monitor panel.
| Field | Description | Default |
|-------|-------------|---------|
@ -576,10 +576,10 @@ On save, the system checks:
| Module | Path |
|--------|------|
| Execution engine | `internal/workflow/runner.go` |
| Native DAG / checkpoint / HITL | `internal/workflow/native_runtime.go` |
| Eino compile / checkpoint / HITL | `internal/workflow/eino_compile.go` |
| Graph validation | `internal/workflow/validation.go` |
| Expressions / JSONPath / joins | `internal/workflow/expression.go`, `jsonpath.go`, `join.go` |
| Dry-run / replay data | `internal/workflow/dry_run.go`, `internal/handler/workflow_run.go` |
| Canvas UI | `web/frontend/src/pages/workflows/` |
| Canvas UI | `web/static/js/workflows.js` |
| Workflow API | `internal/handler/workflow.go` |
| Role binding | `internal/config/config.go` (`workflow_id` field) |

View File

@ -1,34 +0,0 @@
# 前端设计系统
主应用前端已统一迁移到 [Semi Design](https://semi.design/zh-CN/)(React 19 + Vite),
不再维护手写 HTML/CSS/JS 的组件体系。
## 结构
- 页面:`web/frontend/src/pages/<页面 id>/index.jsx`,路由 `#/<页面 id>`。
- 共享组件:`web/frontend/src/components/ui.jsx`(PageHeader、SectionCard、DataTable、StatGrid、ErrorBanner、MarkdownView、JsonViewer、Drawer 等)。
- 外壳样式:`web/frontend/src/styles/app.css`,只放布局与共享排版;颜色一律用 Semi 变量。
- 构建产物:`web/static/app/`,由 Go 直接提供。
## 颜色与主题
品牌主色 `#3266e3`(暗色 `#81a7ff`),通过覆盖 `--semi-color-primary` 等变量接入 Semi 主题,
暗色由 `body[theme-mode="dark"]` 驱动,偏好保存在 `localStorage['cyberstrike-theme']`(system/light/dark)。
## 组件约定
- 列表页用 `DataTable` + `useResource`,统一 loading / 空态 / 错误态(`ErrorBanner`)。
- 指标卡用 `StatGrid`/`StatCard`;详情抽屉用 `Drawer`(封装 Semi `SideSheet`)。
- 危险操作用 `confirmAction`;反馈用 `toastSuccess`/`toastError`。
- Markdown 统一走 `MarkdownView`(marked + DOMPurify),不要自行插入 HTML。
## 校验
```sh
npm ci --prefix web/frontend
npm run --prefix web/frontend build
go test ./internal/app -run TestSPA -count=1
```
`internal/app/spa_test.go` 会检查 `web/static/app/index.html` 引用的哈希资源是否存在,
防止构建产物缺失或未提交。页面开发契约见 `web/frontend/CONTRACT.md`。

File diff suppressed because one or more lines are too long

View File

@ -1,37 +0,0 @@
# Pi 单代理与多代理
CyberStrikeAI 仅使用 Pi 运行时。Go 负责业务、权限、工具执行与结果验收;Pi SDK 负责模型循环、会话、流式事件和压缩。部署与配置见 [Pi 运行时](pi-runtime.md)。
## 入口与模式
- 单代理:`POST /api/agent`、`POST /api/agent/stream`,模式值 `single`。
- 多代理:`POST /api/multi-agent`、`POST /api/multi-agent/stream`,模式 `deep`、`plan_execute`、`supervisor`。
- 后台回执:`POST /api/agent/runs`、`POST /api/multi-agent/runs`。
- 机器人、批量任务及工作流 Agent 节点复用同一 Pi 调度入口。
旧 `/api/eino-agent` 路由和 `eino_single` 模式只作为输入兼容,执行仍进入 Pi;不存在旧引擎或切换选项。
## 分工
| 模式 | 行为 |
| --- | --- |
| single | 一个 Pi 会话调用被允许的工具完成当前工作 |
| deep | 主代理通过 task 委派专家,核对返回结果并综合交付 |
| plan_execute | 维护计划,逐步委派 executor,根据结果调整后续步骤,受规划轮数与 Agent 轮数限制 |
| supervisor | 按专家职责委派 task/transfer_to_agent,汇总后通过 exit 交付 |
主代理与专家定义继续位于 `agents/` 的 Markdown 文件。主代理提示文件为 `orchestrator.md`、`orchestrator-plan-execute.md`、`orchestrator-supervisor.md`。子代理绑定角色可以缩小工具范围,不得扩大主代理的工具集合。
## 工具与能力
工具执行统一回到 Go。MCP 和本机文件/Shell 工具经过相应权限和 HITL;执行记录与最终证据关联。工具较多时,Pi 原生 tool_search 先检索元数据,再按需加载工具定义。
`multi_agent.skills` 控制 skill 与本机工具;`multi_agent.runtime` 保存工具检索、任务板、模型重试、备用渠道及输出预算设置。旧配置键在读取时迁移,保存采用新键。TaskCreate/TaskUpdate/TaskGet/TaskList 与 write_todos 使用现有对话任务板。
## 生命周期
- 补充指令通过 steering 在工具批次后的安全点进入后续推理。
- 立即取消同时中止模型请求和当前宿主工具。
- 中断后的未提交工具结果标为不确定,继续前核对执行记录,不能自动当作成功或直接重放。
- 完成状态由宿主结果验收决定。达到迭代上限、存在待完成工具或缺少执行证据时,不得升级为任务完成。
- Pi 会话和压缩记录落盘;已绑定项目的自动工作摘要另存为 tentative 的续接记录。

View File

@ -12,7 +12,7 @@
## 核心概念与编排
- [架构说明](architecture.md) · [安全模型](security-model.md) · [RBAC](rbac.md)
- [Agent 与角色](agent-and-role-guide.md) · [Skills](skills-guide.md) · [Pi 多代理](MULTI_AGENT_PI.md) · [Agent 最终回复治理](agent-finalization-best-practices.md)
- [Agent 与角色](agent-and-role-guide.md) · [Skills](skills-guide.md) · [Eino 多代理](MULTI_AGENT_EINO.md) · [Agent 最终回复治理](agent-finalization-best-practices.md)
- [黑板与上下文记忆](blackboard-context-memory.md)
- [调用拦截规则](tool-call-guard.md)
- [工作流](workflow-graph.md) · [工具执行治理](tool-execution-governance.md) · [人机协同最佳实践](hitl-best-practices.md)
@ -20,7 +20,6 @@
## 功能指南
- [项目任务续接](project-resume.md) · [Token 用量分析](token-usage-monitoring.md)
- [HTTP 测试工具代理池](http-proxy-pool.md)
- [资产管理](asset-management.md) · [知识库](knowledge-base.md) · [机器人接入](robot.md) · [视觉分析](VISION.md)
- [WebShell](webshell.md) · [C2](c2.md) · [MCP 联邦](mcp-federation.md)
@ -34,7 +33,3 @@
- [开发者指南](developer-guide.md) · [插件开发](plugin-development.md) · [前端国际化](frontend-i18n.md)
- [测试指南](testing.md) · [贡献规范](contributing-guide.md) · [发布流程](release-process.md)
- [Pi 原生运行时与迁移](pi-runtime.md)
- [批量任务管理](task-management.md) · [深度测评与长程恢复](deep-assessments.md)

View File

@ -38,7 +38,7 @@ vision:
系统提示已说明:遇图片调用 `analyze_image`,勿用 `read_file` 读二进制图。
`multi_agent.runtime.tool_search_always_visible_tools` 建议包含 `analyze_image`。
`multi_agent.eino_middleware.tool_search_always_visible_tools` 建议包含 `analyze_image`。
## 合规

View File

@ -32,8 +32,8 @@ CyberStrikeAI 的 Agent 行为由三类资源共同决定:角色、子代理
单代理接口:
- `POST /api/agent`
- `POST /api/agent/stream`
- `POST /api/eino-agent`
- `POST /api/eino-agent/stream`
适合:
@ -151,12 +151,12 @@ max_iterations: 300
| 模式 | 适合 | 不适合 |
| --- | --- | --- |
| `single` | 短任务、交互式分析、需要稳定上下文 | 多阶段大任务 |
| `eino_single` | 短任务、交互式分析、需要稳定上下文 | 多阶段大任务 |
| `deep` | 主代理动态拆分任务,子代理按需深入 | 需要严格步骤顺序的流程 |
| `plan_execute` | 有明确阶段、需要执行后复盘和重规划 | 用户频繁打断的即兴对话 |
| `supervisor` | 专家分工明确,需要主管路由 | 子代理定义含糊或过多 |
经验上,普通安全测试先用 `single`;复杂项目用 `plan_execute`;需要多个专业角色时用 `deep` 或 `supervisor`。
经验上,普通安全测试先用 `eino_single`;复杂项目用 `plan_execute`;需要多个专业角色时用 `deep` 或 `supervisor`。
## 工具可见性如何影响行为
@ -192,6 +192,6 @@ max_iterations: 300
- Markdown Agent 解析:`internal/agents/markdown.go`
- 多代理准备:`internal/handler/multi_agent_prepare.go`
- 编排实现:`internal/multiagent/pi_runner.go`
- 工具搜索中间件:`internal/multiagent/pi_runner.go`
- 编排实现:`internal/multiagent/eino_orchestration.go`
- 工具搜索中间件:`internal/multiagent/eino_middleware.go`
- 子代理上下文:`internal/multiagent/sub_agent_context_test.go`

View File

@ -1,17 +1,333 @@
# 原生 Agent 运行收尾与任务验收
# Agent 最终回复治理最佳实践
Pi 的 `agent_settled` 表示本次模型运行不再自动继续。业务任务是否完成,仍由 Go 的运行状态、工具记录和验收条件决定。
[返回中文文档](README.md) | [English](../en-US/agent-finalization-best-practices.md)
## 单次运行
调研日期:2026-07-28
`internal/agentfinalizer` 统一处理单代理、多代理、机器人和相关任务入口。助手文本只是候选交付:
本文聚焦一个具体问题:Agent 在工具调用、推理、计划或子代理协作尚未真正完成时,输出了一段“像结论”的自然语言,前端或编排层把它当作最终回复展示。结论先说清楚:成熟 Agent 系统不会用“最近一段 assistant 文本”判断任务完成,而是用运行时状态、工具状态、验证结果和显式终态事件共同决定是否 final。
- 迭代上限、失败、取消和等待状态不得被普通文本覆盖为完成。
- 未完成的工具 execution ID 必须保留并处理。
- 需要实际执行的请求必须具有已完成的工具证据。
- 空文本和占位回复不能当成成功交付。
- 主代理汇总子代理结果;子代理一句“完成”不能替代原始执行记录。
## 一、核心结论
过程事件、思考、工具输出与最终交付分开记录。退出工具的 final_result 仍经过宿主验收,不能绕过这些规则。
1. **最终回复是运行时事件,不是自然语言内容。**
“已拿到”“下一步”“Huge breakthrough”这类文本只能作为候选观察或进展,不能作为完成信号。
实现:`internal/agentfinalizer/decision.go`、`internal/multiagent/pi_runner.go`。
2. **过程面和交付面必须隔离。**
`thinking`、`reasoning_chain`、`planning`、`response_delta`、子代理回复、工具输出都属于过程面;只有通过 final gate 的 `response` / `final` 事件才能写入主消息气泡和 `messages.content`。
3. **复杂任务需要 verifier,而不是更长 prompt。**
Prompt 可以提醒模型谨慎,但最终完成必须由代码层判断:是否仍有待执行工具、后台 execution、未完成计划步骤、未验证证据、未记录事实/漏洞、未清理或未说明不可清理。
4. **不同 agent 模式不同,但 final 治理原则一致。**
单代理、Deep、Plan-Execute、Supervisor 都需要 final gate。区别只是 gate 的证据来源不同:单代理看工具轨迹,Deep 还要看子代理结果,Plan-Execute 要看 Replanner 的终止判断,Supervisor 要看 `exit` 与 supervisor 汇总。
## 二、成熟 Agent 的公开做法
| 系统 | 公开做法 | 对 final 治理的启发 |
|---|---|---|
| Codex | OpenAI 的 Codex prompting guide 建议不要在 prompt 中强行要求 upfront plan、preamble 或 status updates,因为这可能导致 rollout 未完成就停止。 | 不要把“模型自己说的阶段性计划/状态”当完成依据;agent harness 应负责执行循环和收尾。 |
| Claude Code | Claude Code 提供 `PreToolUse`、`PostToolUse`、`Stop` 等 hooks;`PostToolUse` 明确发生在工具成功执行之后。 | 生命周期事件比自然语言可靠。验证、审计、阻断应挂在确定的阶段边界上。 |
| Claude Code Subagents | 子代理有独立上下文、自定义系统提示、特定工具权限和独立权限;子代理适合隔离大量检索/日志/文件读取。 | 子代理输出是证据材料,不是主任务最终结论;主代理必须汇总、验收、再 final。 |
| Claude Code Plan Mode | Plan mode 先读文件并产出计划,获得批准前不编辑。 | 计划与执行是不同状态;计划完成不等于任务完成。 |
| Cursor Plan Mode | Cursor Plan Mode 会研究代码库、询问澄清问题、生成可审查计划,并等待用户确认后再构建。 | UI 层把 plan/review/build 拆开,用户不会把计划误认为最终交付。 |
| OpenCode | OpenCode 把 Build、Plan、Review、Debug、Docs 等 agent 分成不同工具权限与用途,Plan agent 只分析规划不做修改。 | 用 agent 能力边界降低误触发:能规划的 agent 不等于能执行完成。 |
| Eino ADK | Eino ADK 提供事件驱动输出、Runner 回调、中断、checkpoint,以及 Supervisor、Plan-Execute 等协作原语。Plan-Execute 由 Planner、Executor、Replanner 协作。 | 当前项目选型方向正确;需要把事件驱动能力进一步固化为 finalization contract。 |
主要参考:
- OpenAI Codex Prompting Guide: https://developers.openai.com/cookbook/examples/gpt-5/codex_prompting_guide
- Claude Code Hooks: https://docs.anthropic.com/en/docs/claude-code/hooks
- Claude Code Subagents: https://docs.anthropic.com/en/docs/claude-code/sub-agents
- Claude Code Common Workflows: https://docs.anthropic.com/en/docs/claude-code/common-workflows
- Cursor Agent Best Practices: https://cursor.com/blog/agent-best-practices
- OpenCode Agents: https://opencode.ai/docs/agents/
- CloudWeGo Eino ADK: https://www.cloudwego.io/docs/eino/core_modules/eino_adk/
- CloudWeGo Eino ADK Patterns: https://www.cloudwego.io/docs/eino/overview/eino_adk0_1/
## 三、通用最佳实践
### 1. 建立 Finalization Contract
所有执行入口统一产出一个结构化收尾对象,只有它允许触发最终回复。
```go
type FinalizationDecision struct {
Status string // in_progress | completed | blocked | failed | cancelled
Finalizable bool
CompletionReason string // verified | user_cancelled | timeout | blocked | failed
FinalText string
EvidenceVerified bool
EvidenceRefs []string
PendingToolRuns []string
PendingPlanSteps []string
PendingApprovals []string
MissingChecks []string
}
```
硬规则:
- `Finalizable=false` 时禁止发送 `response` 终态事件。
- `Status=in_progress` 时只能发 `progress`、`planning`、`tool_*`、`reasoning_chain` 等过程事件。
- `FinalText` 不能为空,但非空不代表可以 final。
- `PendingToolRuns`、`PendingPlanSteps`、`PendingApprovals` 任一非空时不能 `completed`。
- `EvidenceVerified=false` 时不能把候选输出写成已验证结论。
### 2. 固定 SSE 事件语义
推荐事件分层:
| 事件 | 展示位置 | 可否写 `messages.content` | 说明 |
|---|---|---:|---|
| `progress` | 任务状态/时间线 | 否 | 简短进度 |
| `planning` | 执行详情 | 否 | 主代理计划、阶段性判断 |
| `reasoning_chain` / `thinking` | 执行详情 | 否 | 推理/思考摘要 |
| `tool_call` / `tool_result` | 执行详情 | 否 | 工具事件 |
| `eino_agent_reply` | 执行详情 | 否 | 子代理返回材料 |
| `finalization_check` | 执行详情 | 否 | verifier 结果 |
| `finalization_auto_continue` | 执行详情 | 否 | verifier 触发的工程续跑,`contextInjection=false` |
| `response` | 主消息气泡 | 是 | 只能在 `data.finalized=true` 时使用 |
| `done` | 关闭流 | 否 | 仅表示流结束,不表示任务成功 |
| `error` / `cancelled` | 主消息气泡或系统提示 | 是,终态失败类 | 必须带原因 |
### 3. 把“最终候选”与“最终回复”分开
模型可以输出候选结论,但候选结论必须先进入 `final_candidate` 或 `planning`,再由 verifier 决定是否提升:
```text
assistant text
-> candidate
-> finalization gate
-> response(finalized=true)
```
不要这样做:
```text
assistant text
-> response
```
### 4. Stop-time Verification
借鉴 Claude Code hook 思路,在 agent run 停止时做一次确定性检查:
- 所有工具调用都有对应 tool result。
- 后台 execution 都处于 terminal 状态,或被明确登记为仍在运行且任务状态为 `in_progress` / `blocked`。
- Plan-Execute 没有未执行的 required step。
- Supervisor 没有未汇总的子代理结果。
- 在 evidence-required 策略下,至少存在可查询到的 completed 工具执行证据。
### 5. 子代理输出只作证据
子代理返回不能直接成为用户最终回复。主代理必须完成:
- 去重和冲突合并。
- 证据强度排序。
- 不确定性标注。
- 范围边界确认。
- 用户可读交付。
### 6. Prompt 只做软约束,代码做硬约束
Prompt 中可以写:
```text
Interim observations must be marked as progress, not final.
Do not produce a final answer until verification is complete.
```
但真正决定 final 的必须是后端字段和状态机。否则模型只要生成一段像最终结论的自然语言,UI 仍可能误判。
## 四、CyberStrikeAI 当前落地状态
当前项目已经具备一套显式 final gate:
- [internal/agentfinalizer/decision.go](../../internal/agentfinalizer/decision.go) 是唯一的最终回复决策契约。
- [internal/handler/finalization_helpers.go](../../internal/handler/finalization_helpers.go) 负责把决策结果写入 `process_details`,并且只有 `Finalizable=true` 时才调用 `UpdateAssistantMessageFinalize`。
- [internal/handler/eino_single_agent.go](../../internal/handler/eino_single_agent.go)、[internal/handler/multi_agent.go](../../internal/handler/multi_agent.go)、[internal/handler/workflow_integration.go](../../internal/handler/workflow_integration.go)、[internal/handler/batch_queue_executor.go](../../internal/handler/batch_queue_executor.go) 均已在收尾处接入 finalizer。
- [web/static/js/monitor.js](../../web/static/js/monitor.js) 只把 `data.finalized === true` 的 `response` 当最终回复;未最终化文本会显示为最终回复检查未通过。
- [web/static/js/webshell.js](../../web/static/js/webshell.js) 将流式正文标记为候选输出,只有 `response(finalized=true)` 才切换为完成态。
- [internal/agentfinalizer/decision_test.go](../../internal/agentfinalizer/decision_test.go) 覆盖 pending tool、HITL、空输出、证据策略要求但缺执行证据、失败证据不能支撑最终化、完成态证据可 final 等回归场景。
- [internal/handler/finalization_auto_continue.go](../../internal/handler/finalization_auto_continue.go) 在缺 completed 执行证据时最多自动续跑 2 段;续跑只恢复已有模型轨迹,不向 agent 注入新的 user/system 文案。
当前契约的核心规则:
1. **模型自然语言只是 candidate。**
`RunResult.Response` 不能直接升级为最终回复,必须经过 `agentfinalizer.Decide`。
2. **所有 `response` 事件必须携带终态字段。**
至少包含 `finalized`、`finalizable`、`status`、`completionReason`、`evidenceVerified`、`evidenceRefs`、`pendingExecutionIds`、`missingChecks`。
3. **未完成工具会阻断 final。**
`queued/running` 工具执行仍存在时,决策结果为 `in_progress/pending_tool_executions`。
4. **执行证据必须由结构化策略声明。**
后端不从用户自然语言、助手回复或 agent mode 名称中推断执行意图。聊天请求通过 `finalization.requireExecutionEvidence` 显式声明;WebShell、Workflow、批量、机器人等执行入口由调用点显式传入 policy。policy 要求证据时,至少需要一个可查询到的 `completed` 工具执行记录;只有 failed/cancelled 记录不能支撑最终化。
5. **缺执行证据先工程续跑,再阻断。**
Eino 单代理和 Eino 多代理主链路在 `missing_execution_evidence` 时会先通过已有 trace 自动续跑,不注入额外上下文;达到续跑上限后仍缺证据才写入 blocked。
6. **HITL 和空输出不会 final。**
workflow 等待人工确认、空 assistant 文本、Eino 空输出占位均会写入阻断文案,而不是成功总结。
## 五、贴合当前项目的推荐架构
当前采用的链路是:
```text
Agent / Eino ADK events
-> event normalizer
-> process_details
-> finalization verifier
-> response(finalized=true)
-> messages.content
```
### 1. 后端统一 Finalizer
职责:
- 接收 `RunResult` / 候选文本、`mcpExecutionIds`、会话与助手消息 ID、HITL 状态、编排模式。
- 通过数据库查询工具执行状态,识别 pending、completed、failed、cancelled 等证据状态。
- 返回 `FinalizationDecision`。
- 不调用高风险工具,只做状态和证据检查。
### 2. RunResult 终态字段
[internal/multiagent/runner.go](../../internal/multiagent/runner.go) 已扩展终态字段:
```go
type RunResult struct {
Response string
MCPExecutionIDs []string
LastAgentTraceInput string
LastAgentTraceOutput string
Finalized bool
Status string
CompletionReason string
EvidenceVerified bool
EvidenceRefs []string
PendingExecutionIDs []string
MissingChecks []string
}
```
### 3. 发送 `response` 的条件
在单代理、多代理、工作流、批处理收尾处统一执行:
```go
decision := h.finalizeAgentRunForDelivery(...)
if !decision.Finalizable {
sendEvent("finalization_check", "任务尚未达到最终回复条件", decision)
sendEvent("response", finalizationBlockedMessage(decision), finalizationResponsePayload(decision, extra))
return
}
sendEvent("response", decision.FinalText, finalizationResponsePayload(decision, extra))
```
### 4. 前端只信 `finalized=true`
在 [web/static/js/monitor.js](../../web/static/js/monitor.js) 的 `case 'response'` 中执行硬判断:
```js
const responseFinalized = isFinalizedResponseData(responseData);
const bubbleText = responseFinalized
? resolvedResponseText
: (event.message || '任务尚未达到最终回复条件,暂不生成成功结论。');
markAssistantFinalizationState(assistantIdFinal, responseData);
```
WebShell 侧同理:`response_delta` 可以用于实时预览,但 UI 文案应标记为“执行中输出”,只有最终 `response(finalized=true)` 才显示为完成态。
### 5. 各模式 final gate
| 模式 | 谁可以产出最终候选 | 谁决定 final | 必须检查 |
|---|---|---|---|
| Eino 单代理 | 单代理最后助手文本 | Finalizer | 无 pending tool、证据引用完整、任务状态 terminal |
| Deep | 主代理汇总文本 | Finalizer | 子代理结果已汇总;子代理文本不能直接 final;工具状态 terminal |
| Plan-Execute | Replanner 结束后的汇总文本 | Replanner + Finalizer | Executor 单步输出不能 final;计划步骤完成或明确 blocked |
| Supervisor | Supervisor 的 `exit` / 汇总文本 | Supervisor + Finalizer | transfer 已返回;无未处理专家结果;最终由 supervisor 统一口径 |
### 6. 安全测试场景的证据 gate
安全测试、WebShell、批量验证、Workflow 和多代理执行等 evidence-required 场景,最终回复必须至少满足:
- 有明确目标和授权范围标识。
- 有可复核证据引用,例如工具 execution id、请求/响应摘要、截图路径、命令输出摘要、事实/漏洞记录 ID。
- 有身份或影响验证结果,而不是只凭 marker 文本判断。
- 已记录到项目黑板或漏洞库,或明确说明未绑定项目导致无法记录。
- 高风险动作已清理、回滚、取消,或明确说明未执行清理的原因。
- 仍在运行的扫描/命令/WebShell/C2 任务不能被隐式当作完成。
注意:这里的 gate 是治理规则,不要求最终报告暴露敏感利用细节;可以只给证据摘要和内部引用。
## 六、落地状态与后续增强
### P0:先修“误 final”(已落地)
1. 已引入 `FinalizationDecision`。
2. 主要 agent SSE `response` 事件已携带 `data.finalized/finalizable/status/completionReason` 等字段。
3. 前端 `monitor.js` 和 `webshell.js` 已按 `finalized=true` 区分候选输出和最终回复。
4. `RunResult.Response` 仍保留兼容字段名,但语义已由 finalizer 统一提升;后续可再拆成 `CandidateResponse` / `FinalResponse`,减少误用空间。
5. Plan-Execute / Deep / Supervisor / Eino Single 等模式均通过统一 handler 收尾 gate。
### P1:补证据链(部分落地)
1. 已用 `mcp_execution:<id>` 作为基础 evidence refs。
2. `finalization_check` 事件已展示 pending execution 与 missing checks。
3. 执行入口已启用显式 execution evidence policy;Eino 主链路在 policy 要求证据且缺少 completed 工具证据时先无注入续跑,达到上限后才阻断 final。
4. 后续建议:为 `record_vulnerability`、`upsert_project_fact`、项目黑板记录建立更细粒度 evidence refs。
5. 后续建议:最终报告模板固定包含“结论、证据、风险/不确定性、后续动作”。
### P2:体验和观测(后续增强)
1. 在任务卡片展示 `in_progress / verifying / finalizing / completed / blocked`。
2. 为 finalizer 加日志和指标:误拦截率、缺失证据类型、pending tool 数量。
3. 支持“继续验证”按钮,从 `FinalizationDecision.MissingChecks` 自动生成下一轮输入。
## 七、验收测试建议
至少加入这些回归测试:
1. **推理文本不 final**
模拟 `reasoning_chain` 里出现看似完成的候选结论,但本轮没有 completed 工具执行证据;预期主消息气泡不显示成功结论,只显示执行中或阻断态。
2. **主代理阶段性输出不 final**
模拟 `response_start/delta` 输出“下一步继续验证”;预期只进入 timeline `planning`。
3. **未完成后台工具不 final**
工具返回 `execution_id` 且状态 `running`;即使模型给出总结,也只能 `in_progress`。
4. **Plan-Execute Executor 输出不 final**
Executor 输出“突破成功”,但 Replanner 未结束;预期不触发 `messages.content` finalize。
5. **Supervisor 子代理输出不 final**
子代理返回确定结论,Supervisor 未 `exit`;预期只进入 `eino_agent_reply`。
6. **最终事件必须带 finalized**
前端收到旧格式 `response` 无 `finalized=true`;预期候选内容只进入详情/警告,主消息显示阻断态,不创建成功最终气泡。
7. **失败和取消可终态**
`error` / `cancelled` 仍可更新助手消息,但 `completionReason` 必须是 `failed` / `user_cancelled`,不能伪装为成功完成。
## 八、推荐默认策略
对 CyberStrikeAI,建议默认策略是:
```text
eino_single:轻量任务可用,但 final gate 必须开启
deep:复杂安全测试默认推荐
plan_execute:目标明确、需要严格“规划-执行-重规划”的任务推荐
supervisor:多专家路由任务使用,不作为默认泛化模式
```
最终治理一句话:
```text
messages.content 只能来自 FinalizationDecision.FinalText;
process_details 可以展示所有过程;
前端只能把 response(finalized=true) 当最终回复。
```

View File

@ -30,7 +30,7 @@ curl -k https://127.0.0.1:8080/api/auth/validate \
最简单方式是不先创建空对话,直接调用 Agent:
```bash
curl -k https://127.0.0.1:8080/api/agent \
curl -k https://127.0.0.1:8080/api/eino-agent \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"对 127.0.0.1 做授权的基础信息收集,只做只读操作"}'
@ -50,7 +50,7 @@ curl -k https://127.0.0.1:8080/api/conversations \
## Recipe 3:流式调用 Agent
```bash
curl -k -N https://127.0.0.1:8080/api/agent/stream \
curl -k -N https://127.0.0.1:8080/api/eino-agent/stream \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"总结当前项目事实并列出下一步,只读"}'

View File

@ -38,8 +38,8 @@ Content-Type: application/json
单代理:
- `POST /api/agent`
- `POST /api/agent/stream`
- `POST /api/eino-agent`
- `POST /api/eino-agent/stream`
多代理:
@ -354,7 +354,7 @@ C2:
## SSE 客户端注意事项
`/api/agent/stream` 和 `/api/multi-agent/stream` 是长连接。客户端应处理:
`/api/eino-agent/stream` 和 `/api/multi-agent/stream` 是长连接。客户端应处理:
- 网络中断后不要盲目重放破坏性请求。
- 收到 `error` 事件后读取错误正文。
@ -367,7 +367,7 @@ C2:
| API 类型 | 稳定性 | 集成建议 |
| --- | --- | --- |
| `/api/auth/*` | 高 | 可直接集成 |
| `/api/agent*` | 高 | 推荐外部对话入口 |
| `/api/eino-agent*` | 高 | 推荐外部对话入口 |
| `/api/openapi/spec` | 高 | 用于生成客户端 |
| `/api/assets/*` | 高 | 资产管理与批量导入 |
| `/api/config*` | 中 | 管理工具使用,谨慎自动化 |
@ -386,7 +386,7 @@ curl -k https://127.0.0.1:8080/api/conversations \
发送非流式单代理请求:
```bash
curl -k https://127.0.0.1:8080/api/agent \
curl -k https://127.0.0.1:8080/api/eino-agent \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"对 127.0.0.1 做授权的基础信息收集,先不要执行高风险操作"}'
@ -397,7 +397,7 @@ curl -k https://127.0.0.1:8080/api/agent \
- 路由:`internal/app/app.go`
- 认证:`internal/security/auth_middleware.go`
- OpenAPI:`internal/handler/openapi.go`
- 单代理:`internal/handler/single_agent.go`
- 单代理:`internal/handler/eino_single_agent.go`
- 多代理:`internal/handler/multi_agent.go`
- 资产接口:`internal/handler/asset.go`
- 资产存储与去重:`internal/database/asset.go`

View File

@ -24,10 +24,10 @@ flowchart LR
入口在 `cmd/server/`,应用组装在 `internal/app/`。Web 使用 Gin:
- `web/frontend/`:前端源码(React 19 + Semi Design,Vite 构建),页面位于 `src/pages/<页面 id>/`。
- `web/static/app/`:前端构建产物,`GET /` 直接返回其中的 `index.html`,`/api-docs` 跳转到 `/#/api-docs`。
- `web/static/i18n/`:多语言词条,前端与后端共用。
- `web/static/`:Logo、favicon 与多语言等公共静态资源。
- `web/templates/index.html`:主页面。
- `web/templates/api-docs.html`:API 文档页面。
- `web/static/js/`:各业务模块前端逻辑。
- `web/static/css/`:样式。
路由注册集中在 `internal/app/app.go`。
@ -35,7 +35,7 @@ flowchart LR
`internal/handler/` 按业务拆分:
- `agent.go`、`single_agent.go`、`multi_agent.go`
- `agent.go`、`eino_single_agent.go`、`multi_agent.go`
- `workflow.go`、`workflow_run.go`
- `knowledge.go`
- `webshell.go`
@ -58,14 +58,14 @@ Handler 负责参数解析、权限中间件后的业务协调和 HTTP 响应。
- `internal/agents/`
- `agents/`
默认运行时是 Pi TypeScript SDK。`internal/agentruntime/` 管理子进程协议与构建,`internal/multiagent/pi_*.go` 负责角色、工具、审批和事件适配。单代理及 Deep、Plan-Execute、Supervisor 均使用 Pi 会话;角色仍由 Markdown 定义。旧框架内核与依赖已删除,运行时仅支持 Pi。详见 [Pi 运行时](pi-runtime.md)。
Eino ADK 提供单代理、Deep、Plan-Execute、Supervisor 等执行模式。多代理子 Agent 由 Markdown 文件定义。
## MCP 与工具
MCP 相关:
- `internal/mcp/`:Server、外部 MCP、连接恢复。
- `internal/agentruntime/` 与 `internal/multiagent/pi_runner.go`:Pi 与 Go MCP 执行链适配;`internal/agentruntime/` 留作 Pi 兼容路径。
- `internal/einomcp/`:Eino 与 MCP 工具适配。
- `tools/`:YAML 命令工具。
- `internal/app/*_tools.go`:Go 内置工具注册。
@ -73,7 +73,7 @@ MCP 相关:
## Workflow
工作流引擎在 `internal/workflow/`,HTTP 入口在 `internal/handler/workflow*.go`。原生 DAG 执行器支持 start、agent、tool、condition、hitl、output、end 等节点,使用版本化 JSON 检查点保存恢复状态。
工作流引擎在 `internal/workflow/`,HTTP 入口在 `internal/handler/workflow*.go`。它支持 start、agent、tool、condition、hitl、output、end 等节点。
详细使用见 [工作流使用说明](workflow-graph.md)。
@ -123,13 +123,13 @@ MCP 相关:
## 一次对话请求的真实路径
以 `/api/agent/stream` 为例:
以 `/api/eino-agent/stream` 为例:
1. Gin 路由进入认证中间件。
2. Handler 解析请求体、会话 ID、角色、附件和 WebShell 上下文。
3. Agent 构建模型输入,包括历史消息、角色提示、项目事实、工具列表。
4. Pi Worker 调用模型,Go 接收生命周期事件。
5. 模型需要工具时通过双向协议回到 Go 工具网关,再进入 MCP 或原生工具。
4. Eino Runner 调用模型。
5. 模型需要工具时走 MCP Tool。
6. 工具调用前可能触发 HITL。
7. 工具执行结果写入过程详情和监控。
8. 模型继续推理并生成最终回答。

View File

@ -176,7 +176,7 @@ HTTP API 和 `query_assets` 还支持 `max_vulnerabilities`、最近扫描时间
在资产库中选择多个目标后,点击 **创建扫描任务**。系统会为每个资产创建独立子任务,并建立资产、队列和子任务之间的关联。
当前默认使用手动调度、单并发和 Pi 单 Agent 模式,以减少对目标和本机资源的瞬时压力。执行前仍需确认测试窗口、请求频率、允许的验证方式和审批要求。
当前默认使用手动调度、单并发和 Eino 单 Agent 模式,以减少对目标和本机资源的瞬时压力。执行前仍需确认测试窗口、请求频率、允许的验证方式和审批要求。
### 风险计算

View File

@ -1,9 +1,9 @@
# 异步对话 API
长任务使用 `POST /api/agent/runs`(单代理)或 `POST /api/multi-agent/runs`(多代理,需启用配置)。请求体与对应同步接口相同;支持已有 conversationId,省略时创建会话。原同步接口仍等待最终结果,连接断开会取消同步执行。
长任务使用 `POST /api/eino-agent/runs`(单代理)或 `POST /api/multi-agent/runs`(多代理,需启用配置)。请求体与对应同步接口相同;支持已有 conversationId,省略时创建会话。原同步接口仍等待最终结果,连接断开会取消同步执行。
```sh
curl -X POST "$CSAI_URL/api/agent/runs" \
curl -X POST "$CSAI_URL/api/eino-agent/runs" \
-H "Authorization: Bearer $CSAI_TOKEN" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: example-task-001' \
@ -13,7 +13,7 @@ curl -X POST "$CSAI_URL/api/agent/runs" \
HTTP 202 示例:
```json
{"runId":"...","conversationId":"...","assistantMessageId":"...","status":"running","statusUrl":"/api/agent/runs/..."}
{"runId":"...","conversationId":"...","assistantMessageId":"...","status":"running","statusUrl":"/api/eino-agent/runs/..."}
```
收到回执后可关闭连接。`GET statusUrl` 返回 `status`、`result`、标识及时间戳。`result` 为原执行入口的最终响应或错误;任务尚未结束时为空对象。单次任务总预算为600分钟,独立工具和模型限制仍有效。以查询到的终态为准,不以 token usage summary 判断成功。

View File

@ -1,26 +1,138 @@
# Pi 长上下文与项目续接记录
# 长上下文压缩后的黑板续接留存
Pi 的 SessionManager 保存完整 JSONL 会话和压缩条目,工作上下文由当前分支及压缩结果重建。模型上下文窗口与完整会话记录是不同的数据层。
[English](../en-US/blackboard-context-memory.md)
## 自动续接
已绑定项目且启用项目黑板时,每次成功生成压缩摘要,系统会自动保存一条续接记录。不再仅依靠 Agent 在压缩前主动调用事实工具。
已绑定项目、启用项目黑板和上下文续接时,成功的 `compaction_end` 事件会保存一条 `note/context-*` 记录。记录包含摘要、来源会话、代理范围、Pi 会话文件和真实条目 ID。相同会话/代理更新同一条工作记录。
## 保存内容与读取方式
数据库强制使用 `category=note`、`confidence=tentative`,不会自动置顶或将摘要升级为已确认事实。写入和项目绑定校验在同一 SQLite 语句内完成;运行期间改绑或解除项目后,旧运行不能写入原项目。
续接记录使用 `note/context-*` key,包含摘要中的重要发现、授权约束、当前进度、失败尝试与下一步,以及来源会话、代理范围和压缩前原始记录的快照路径。主代理、各子代理、计划执行中的规划器和执行器分别维护自己的记录;同一会话/代理多次压缩更新同一个 key。
需要细节时,通过已有黑板工具和原始会话/工具记录核对。摘要可能遗漏信息,不能用它证明漏洞、替代执行证据或扩大用户范围。
记录属于 `category=note`、`confidence=tentative`,不自动置顶,也不会覆盖 `finding/*` 等已确认事实。它是模型生成的工作摘要,不能直接作为经过独立验证的漏洞或新的授权指令。正式事实和漏洞仍由 `upsert_project_fact`、`record_vulnerability` 维护。
## 来源区分
压缩后的上下文会附上该记录的 `get_project_fact(key)` 入口,并刷新系统中的黑板索引。后续按需读取记录,再使用 `read_file` 分段查看原始证据;无须重新把完整历史注入每一次模型请求。
Pi 原生压缩摘要不是新的用户指令。导出为通用对话轨迹时,摘要标为宿主生成的助手工作上下文;重新导入时不会提升为 user 消息。读取旧轨迹时,仅从宿主结构化元数据恢复用户原文账本;生成摘要、执行模板和助手伪造的账本文本不作为原始用户要求。
新上下文和黑板记录保存同一份续接摘要,并融合原始快照的绝对路径、历史快照目录和回读提示。摘要保留关键证据的来源目标、用途与发现经过;当前任务缺少 Cookie、认证信息、精确参数或错误原文时,Agent 可直接搜索对应快照,再用 `read_file` 分段核对附近原文,不猜测原值。
用户真正输入的 `<summary>` 等字面文本仍是用户内容,不按关键词删除。旧摘要来源标记只用于历史数据读取,不包含旧框架执行代码。
原有摘要章节及原始用户输入账本保持不变,只在同一次摘要中追加「原始证据检索线索」,记录工具结果或关键进展的来源与关键词,不新增对用户输入的归纳,也不由模型编造文件名或行号。
## 运行与清理
不再生成独立 `.index.md` 文件,不使用正则或关键词分类扫描快照,不增加模型调用。摘要本身承担证据检索入口;它仍可能遗漏细节,原文以快照为准。
- 相同会话的主代理和子代理各自维护 Pi 会话范围。
- 会话目录按会话存储键分组;删除对话会清理该对话的全部 Pi 子会话,不影响其他对话。
- 进程中断后未提交的工具结果保持不确定,先核对执行记录,再决定下一步。
- 阶段成果和正式发现仍由已有工具与评估复核流程维护。
## 用户输入与系统摘要不能混为同一来源
实现:`runtime/pi/src/worker.ts`、`internal/multiagent/pi_memory.go`、`internal/database/project.go`、`internal/database/pi_sessions_test.go`。回归覆盖真实 SDK 压缩、来源区分、项目改绑和对话隔离清理。
Eino 默认续接摘要使用 `user` 消息角色传输,但同时带 `_eino_summarization_content_type=summary` 的来源标记;保留的技能上下文使用 `skills` 标记。原始用户输入账本按该元数据排除内部摘要和技能消息,不能仅凭 `role=user` 将生成内容归入用户原文。摘要中的模拟用户账本也不作为原始输入来源导入,避免多轮压缩把模型自己写的目标或操作提升为用户指令。快照和摘要模型的文本记录同时标出内部消息的系统生成来源,明确其不是用户输入或新的授权。
用户账本的延续优先读取系统消息内的结构化来源元数据,不再从普通助手或工具响应中提取同名文本标签。JSON 检查点恢复、classic/native 转换和系统消息合并均保留这份来源;兼容旧版本时,仅接受系统消息尾部完整的宿主账本区块,不导入嵌在黑板或响应中的片段。
压缩摘要仍保留在模型工作上下文中,不因来源区分而丢弃进展;主/子代理本轮输入仍来自原始请求及原始聊天记录。不会用 `<summary>` 等文本关键词过滤真正的用户输入。回归测试调用实际 `DefaultFinalize`、连续执行三轮压缩并经过 classic/native 转换,核对原始授权目标与禁止测试本机的约束保留、生成目标与模拟指令不进入用户账本、摘要进展不丢失,以及用户引用摘要文本时仍被视为真正用户输入。
## 会话工作记录与项目共享事实的读取边界
设计依据是区分会话状态和跨会话记忆,而非把每次自动摘要直接视为共享事实。[LangChain 官方记忆概念文档](https://docs.langchain.com/oss/python/concepts/memory) 将工作状态定义为 thread-scoped,跨会话记忆使用独立 namespace;本项目保留现有项目事实结构,用保留前缀 `note/context-*` 与来源会话标识建立相应读取范围,不增加数据库迁移或额外模型提取。
| 内容 | 自动注入与默认事实工具 | 显式历史查询 |
|---|---|---|
| 普通项目事实(含已确认发现、手工 note) | 沿用原有项目共享行为 | 沿用原有行为 |
| 当前会话的自动续接记录(含该会话子代理/规划器/执行器) | 可见,标为当前会话工作记录 | 可见 |
| 同项目其他会话的自动续接记录 | 不自动注入,列表/搜索默认不返回,直接 get 要求历史标志 | `include_history=true` 可读,标为历史参考 |
| 缺少来源会话的旧续接记录 | 不作为当前工作记录返回 | 显式历史查询可读,标明未知来源 |
| 其他项目的记录 | 当前项目工具不可读 | 历史标志不能扩大项目范围或绕过 project:read |
`list_project_facts`、`search_project_facts` 与 `get_project_fact` 默认使用当前会话范围;前两者支持 `source_conversation_id` 缩小查询。过滤在数据库分页前执行,避免置顶历史记录占满一页后才被丢弃。初始主 Agent 注入、子 Agent 黑板补充以及普通/原生压缩后的索引刷新,都显式传入当前会话 ID;缺少会话 ID 时不会退回注入全部自动续接记录。
关系速览、索引行内关系提示以及 get/upsert 的关系边返回同样过滤其他会话的自动续接 key,防止通过关系边绕过默认范围。事实 body 的「关联」镜像段由 `get_project_fact` 原样返回、没有按读取方过滤,因此该段不写入任何自动续接 key;结构化关系边仍按调用方范围返回,本会话自己的续接记录不会因此消失。历史正文附来源会话和更新时间,不因读取自动升级为已确认事实或新的任务授权。`note/context-*` 为系统保留前缀,事实写入工具与控制台的事实新建/改写接口都不能创建、覆盖或把普通事实改名进该前缀(续接记录只由压缩流程写入);废弃/恢复工具不能修改其他会话的自动续接记录。核实后的项目知识应另写独立事实 key 并保留证据。
这属于上下文注入和事实检索的默认范围,不是新的文件访问权限隔离;不删除快照、不修改既有记录,也不清洗已进入旧对话历史的内容。项目管理页面及原有不带范围参数的数据库查询仍可供有权用户查看项目全量数据。现有项目权限继续由工具授权层核验。
验证使用同项目两会话、另一个项目及未知来源旧记录:覆盖默认/显式查询、来源筛选、分页、置顶历史记录、关系边、保留 key 写保护、权限拒绝、初始主 Agent 注入,以及真实 classic/native 压缩自动保存后的索引刷新。已有黑板预算与原始用户账本测试继续运行,确保范围标识不突破长度上限、不更改用户输入。
## 原始证据不会随下一次压缩被覆盖
过去所有压缩轮次写入同一个 `transcript.txt`,后一次写入会覆盖前一次记录。现在每份压缩前历史保存到 `snapshots/transcript-<MD5前5位>-<时间戳>.txt`,例如 `transcript-a1b2c-20261012-010203.000000004+0800.txt`。时间戳带纳秒与时区,记录首次保存时间;相同内容的重试通过完整文件内容核对复用快照,不改变原快照的时间或路径。短 MD5 仅用于识别,不用作唯一性判断;前缀或时间戳碰撞时不覆盖旧文件。旧 SHA-256 文件名保持可读且可复用,不改名以免旧摘要的引用失效。`transcript.txt` 仍保留为最新记录的兼容入口,续接摘要引用的是具体快照。快照沿用现有会话记录格式,保留用户、助手与工具记录,省略不变的系统提示与工具/技能索引。
快照沿用 `conversation_artifacts/<conversationId>/summarization/` 目录,与会话产物一起管理;子代理使用独立 scope 子目录。删除会话时现有清理逻辑会删除对应产物,快照不作为会话删除后的独立备份。文件通过临时文件原子替换写入,权限为 0600。
默认数据库为 `data/conversations.db` 时,主代理文件布局如下(摘要向 Agent 提供绝对路径):
```text
data/conversation_artifacts/<conversationId>/summarization/
├── transcript.txt
└── snapshots/
└── transcript-<MD5前5位>-<时间戳>.txt
```
可按文件名中的时间排序判断快照先后。快照可能在生成摘要前保存,包括失败尝试;相同历史的重试复用文件,因此文件序号不严格等同于成功压缩次数。
数据库路径为空时,临时快照也使用 `<临时目录>/cyberstrike-summarization/<conversationId>/summarization/snapshots/`,不会退回多个会话共用一个目录。
子代理、规划器和执行器使用 `summarization/scopes/<scopeHash>/snapshots/`。摘要提供历史快照目录,Agent 可用 `glob` 查找 `transcript-*.txt`,按需回读更早证据。已有旧索引文件不参与新流程,也不会在升级时被自动删除。
系统复用本次已经生成的压缩摘要,不增加一次额外的模型提取调用。原始历史在生成摘要前就做快照,因此即使摘要遗漏某个精确细节,也还有来源可以追溯。黑板或快照保存失败时会记录告警,保留当前可用摘要继续运行,不提示保存成功。
## 配置和边界
```yaml
project:
enabled: true
context_checkpoints: true
```
`context_checkpoints` 省略时默认开启;设置为 false 可关闭自动黑板续接记录,不影响原始证据快照。没有绑定项目的会话仍保留本地快照,但不会把内容写进其他项目。
自动记录前会核对会话当前绑定的项目,并在实际 SQLite upsert 的同一条写入语句中再次核验绑定,避免检查与写入之间切换项目造成旧运行写入旧项目。绑定不匹配时不新增行,也不改写已有记录。这里没有增加跨项目搜索。现有项目黑板权限与事实工具的当前会话范围继续适用。
自动记录只在压缩触发时落库,不能代替每次新发现后的即时事实登记。摘要仍可能遗漏细节;具体原文以快照为准。快照累计占用本地存储,保留到对应会话产物被清理。
## 索引预算与来源区分
自动注入仍只包含 key、短摘要与关系边,完整 body 留在数据库按需读取。索引查询不再加载最终不会注入的 body。字符预算现在包含标题、起止标记、查询提示、遗漏说明和关系速览;特别小的预算会使用简短查询提示或不注入索引,不截断 HTML 边界。
黑板不需要再次调用模型压缩:同一会话/代理的自动续接正文更新为本次摘要,短标签最多 200 字符,不自动注入完整正文或原始快照。读取入口只附在续接摘要与黑板正文中,不复制完整历史,也不维护额外的证据类别索引。历史原文保留在文件中,已确认事实不因续接记录更新而被改写。
快照写入失败时,不注入框架默认的 `transcript.txt` 路径提示,避免 Agent 读取不存在或属于上一轮的文件。普通文本、带 `<summary>` 标签的文本与多段消息均保留同一读取入口,避免正文重复附加。
遗留超长 summary 在展示索引时缩短为单行,库中的完整 summary/body 不改动。索引行的 category 与 confidence 同样只取单行:两者入库时只补默认值、不做校验,含换行就能往系统提示的索引里插入伪造行。关系速览仅使用实际列入索引的事实,避免预算外事实继续通过路径视图占用上下文;索引为空时关系速览也为空,不因集合为空而放开过滤。置顶与事实类型的原有优先级保持不变。
## 实现依据与验证
Eino 的压缩流程支持在 `Finalize` 中处理摘要并重写上下文,`Callback` 在后处理之后触发;本项目在既有自定义 Finalize 中落库、附上快照引用,然后更新索引。普通消息与原生 AgenticMessage 路径均使用同一留存函数。[Eino Summarization 文档](https://www.cloudwego.io/docs/eino/core_modules/eino_adk/eino_adk_chatmodelagentmiddleware/middleware_summarization/)
回归覆盖多次压缩保留早期证据、重复快照幂等、原子文件权限、主/子代理记录隔离、已确认事实保持不变、配置关闭、项目不匹配、保存失败不宣称成功、多段文本摘要、普通与原生中间件自动落库/刷新,以及索引硬预算和正文不注入。
## 追加代码审查验证
本轮进一步修复工具/助手文本伪装原始用户账本、无数据库路径时临时目录混用,以及项目绑定检查/写入竞态。回归覆盖工具与助手伪造标签、系统黑板嵌入片段、结构化来源 JSON 恢复及系统归一化、错误来源元数据拒绝、classic/native 无数据库路径的独立会话目录,以及切换/解绑项目时拒绝新增和更新且已有证据不变。该改动不迁移或改写历史快照,生产更新应与本轮代码验证结果对应。
## 恢复链路与边界回归
代理轨迹恢复统一通过同一解析器处理,只携带已知的 `summary` / `skills` 来源标记与系统消息中的结构化原始用户账本。`agent.ChatMessage` 以运行时字段传递这些信息,普通模型请求 JSON 不包含内部元数据;轨迹专用序列化保留允许的来源字段。恢复时不重放旧系统提示,仅按当前预算重新渲染宿主账本;经典及原生模型调用入口合并系统消息时继续保留结构化来源,且兼容文本不能覆盖已有结构化账本;普通用户引用摘要或标签仍作为用户原文。多段文本摘要恢复后继续保留工作进展与来源标记。测试使用生产相同的中文 ADK 设置,覆盖实际数据库加载和三轮「压缩→持久化→恢复→再次压缩」,包含 classic/native 转换。修复不能补回旧轨迹中已经丢失的来源信息,不改写历史记录。
不可变快照成功后,即使更新 `transcript.txt` 兼容入口失败,摘要及黑板仍保留成功快照的路径;日志单独报告兼容入口故障。快照本身失败时仍不宣称保存成功。
事实 key 的写入校验拒绝首尾空白,默认 SQL 范围过滤兼容已有 key 的 Unicode 空白,与 Go 判断一致;读取不会批量改名或迁移旧记录。索引成功构建为空时会移除旧索引块,其他系统内容及用户账本保持;数据库读取失败时继续保留原索引。
黑板短标签优先使用第 8 节中已经生成的证据检索线索;没有可用线索则沿用原先的标签取法。只更改索引标签,不改摘要第 1–7 节、完整正文或原始用户账本,不增加模型调用。新增 `Context memory` CI 在 macOS、Ubuntu、Windows 上直接运行 agent/attackchain/app/database/handler/multiagent/project/projectprompt 的并发回归测试;Windows 不检查其文件系统不支持的 Unix 权限位。
## 发布前场景验收
计划执行和重新规划的用户角色消息是系统生成模板,包含计划与模型/工具结果,不等于用户新输入。模板使用独立的允许列表来源字段,生成前从未拼接的原始消息保存受限用户账本,再进入重写/压缩;角色与来源也保留在输入文本和快照中。恢复轨迹及框架的用户消息区块不会把模板内容归入用户原文,模板中的工作进展仍保留给模型使用。普通用户引用计划或摘要文字继续作为真实输入处理。
上下文超限或临时故障重新启动时,移除旧指令与索引,但保留并按当前预算重建结构化原始用户账本。首条长输入的预算计算包含编号、分隔符和省略号,避免有空间却整条丢弃;只保留原文的受限片段,不增加用户输入的模型摘要。预算仍不能保存无限原文,精确细节按需回读快照。
已有首尾空白 key 的事实可按原 ID、项目和完整 key 更新摘要/正文,不改名、不修改历史关系引用;新建及更改为非规范 key 仍被拒绝。真实 HTTP 部分更新回归覆盖这一兼容路径。
验收还覆盖长工具输出先保存为原文文件、压缩与恢复后从快照获得文件引用,再通过 read_file 后端分段回读精确 Cookie。合成 Cookie 放在 2001 行输出的中间,不出现在截断预览或摘要中;classic/native 两种路径均可完整恢复。这里只保证证据与读取入口可用,模型是否主动回读取决于任务与模型行为。
聊天输入、审批交互和 API 路由沿用原流程。新增可见内容是自动续接记录、简短读取提示和攻击链侧栏的摘要入口;同项目其他会话的自动工作记录默认不注入,普通共享事实与手工 note 保持原有读取方式。本地快照随不同压缩内容累计,沿用会话产物删除生命周期。
## 攻击链中的摘要与证据线索
攻击链分析输入根据持久化的来源元数据,分别标明真实用户输入、宿主保留的原始用户账本、系统生成摘要、技能上下文和执行模板。生成摘要和模板只是工作线索,不构成新的用户授权,也不能独立证明漏洞或工具执行;节点仍须以实际工具记录为依据。用户自己引用摘要文字时继续作为真实用户输入,不根据正文关键词判定来源。
「以实际工具记录为依据」由程序判定,不只写在提示词里。`action` 与 `vulnerability` 节点可带 `tool_call_id`,取值须逐字来自轨迹中宿主签发的调用 ID;引用了轨迹里不存在的 ID 即判为编造,节点连同指向它的边一起丢弃,`target` 节点不参与判定。是否强制「必须引用」取决于模型当时看不看得到 ID:预算裁剪后全部真实 ID 仍可见时,留空同样丢弃;有 ID 被裁掉时,留空只算无法对应、不算编造。多代理补充的过程详情原样转储事件 JSON,其 ID 不在解析后的轨迹内,此时与 `messages` 表回退分支一样跳过判定,避免误杀真实节点。通过校验的引用写入节点 `metadata.tool_call_id`;不写 `attack_chain_nodes.tool_execution_id`,该列有指向 `tool_executions` 的外键,而模型引用的是调用 ID。
攻击链侧栏提供可展开的「压缩摘要与证据线索」,显示当前会话轨迹中带摘要来源标记的完整正文,保留其中的不可变快照路径,并可复制正文按路径核对原文。读取已有缓存攻击链时也会返回当前轨迹中的摘要,不需要重新生成节点才能查看。摘要单独展示,不变成图中的攻击节点,不改变节点统计、筛选或图导出。没有工具执行的会话可展示摘要而保持空图。
该入口只读取当前会话的代理轨迹,不从项目共享黑板汇总其他会话,不增加快照文件下载或任意文件读取接口。旧轨迹缺少来源元数据时不猜测其摘要身份;已被后续压缩移出轨迹的旧摘要仍按快照目录回溯。更新代码不会重写旧缓存节点;需要使用新的来源标注重新分析攻击链时,点击「重新生成」。
攻击链请求按会话和请求顺序丢弃迟到响应;切换、关闭和错误时清理旧摘要,避免旧内容覆盖新视图。并发重新生成的忙碌请求返回 409 前不再删除缓存图;缓存图的空节点和边统一返回数组,单节点无边也可正常展示。回归覆盖真实模型 HTTP 请求输入、当前会话与同项目其他会话隔离、缓存摘要更新/清空、摘要中的 HTML 仅作为文本、复制与失败回退,以及跨会话和同会话请求乱序。

View File

@ -29,7 +29,7 @@ c2:
enabled: false
multi_agent:
enabled: true
skills:
eino_skills:
filesystem_tools: true
```
@ -91,7 +91,7 @@ knowledge:
top_k: 5
similarity_threshold: 0.4
multi_agent:
skills:
eino_skills:
filesystem_tools: false
```
@ -120,8 +120,11 @@ hitl:
tool_whitelist: [read_file, glob, grep, tool_search]
c2:
enabled: false
agent_runtime:
engine: pi
multi_agent:
eino_callbacks:
enabled: true
mode: log_only
sse_trace_to_client: false
```
配合:
@ -163,7 +166,7 @@ monitor:
external_mcp:
servers: {}
multi_agent:
runtime:
eino_middleware:
tool_search_enable: true
tool_search_min_tools: 20
hitl:

View File

@ -69,24 +69,12 @@ ai:
| `ai.default_channel` | 默认通道 ID。新对话、机器人、批量任务和未显式选择通道的请求使用它。 |
| `ai.channels.<id>` | 通道配置。ID 会归一化为小写、数字和短横线,例如 `Qwen_Max` 会变成 `qwen-max`。 |
| `name` | Web UI 展示名。留空时使用通道 ID。 |
| `provider` | `openai_compatible` 或 `claude`。`openai_compatible` 会在运行时映射为 `openai`;`claude` 使用 Pi 原生 Anthropic Messages API。 |
| `provider` | `openai_compatible` 或 `claude`。`openai_compatible` 会在运行时映射为 `openai`;`claude` 使用 Eino 原生 Anthropic Messages API。 |
| `base_url/api_key/model` | 必填。Base URL 通常需要包含版本路径,如 OpenAI/兼容网关的 `/v1`。 |
| `max_total_tokens` | 上下文压缩、攻击链构建、多代理摘要等共用的总预算。 |
| `max_completion_tokens` | 单次模型输出上限;未填时使用默认值。 |
| `context_window` | 运行时上下文窗口,0 表示未知。保存通道时可自动填入服务报告的窗口,已填写的更小窗口优先。 |
| `context_profile` | 后台策略,默认 `auto`。识别本地服务后记录 `local_auto`。配置文件支持手动 `local`、显式节省 `economy` 和使用运行时参数的 `custom`。 |
| `reasoning` | 该通道的默认推理扩展字段。不同网关支持差异较大,异常时先尝试 `mode: off`。 |
### 自动输入优化
DeepSeek 官方地址、明确的 DeepSeek 推理线路或包含 DeepSeek 的模型名会自动启用输入节省。达到 16 个工具时使用按需发现,默认常驻前 6 个工具、核心工具及显式常驻清单。JSON 回包精简格式空白。有授权的本地读取工具时,超过 8,000 字节的结果保存全文并返回可回读的预览。推理 Token 单列统计且计入输出总量。
保存通道和测试连接会探测 Ollama、llama.cpp、LM Studio、vLLM 和 oMLX 的元数据。oMLX 通过 `owned_by: omlx` 识别,优先读取 `/v1/models/status` 的匹配模型或别名窗口,权限不足时回退到模型列表。普通兼容响应和内网 IP 本身不足以触发本地策略。探测失败可继续保存。
本地输入预算取窗口的 60%,上限 131,072 Token,并预留输出空间。窗口未知时使用 32,768 的保守窗口。工具发现和回包上限按本地窗口收紧,输出字段使用 `max_tokens`。模型只报告架构上限时,新通道保留窗口未知状态。切换模型或服务会清除旧的自动判定。页面在后台应用这些策略。
验证成本时,应比较完整任务的输入、缓存命中、输出及调用次数。工具搜索和分段回读可能增加调用。已有配置文件的显式覆盖继续生效。
### 按提供商和模型关闭推理
使用 `reasoning.mode: off`,或在对话中选择“推理 → 关闭”。实际请求参数按通道区分:
@ -154,9 +142,9 @@ hitl:
```yaml
multi_agent:
enabled: true
robot_default_agent_mode: single
robot_default_agent_mode: eino_single
batch_use_multi_agent: false
skills:
eino_skills:
disable: false
filesystem_tools: true
skill_tool_name: skill
@ -164,7 +152,7 @@ multi_agent:
支持模式:
- `single`:Pi 单代理。
- `eino_single`:Eino 单代理。
- `deep`:DeepAgent 风格多代理。
- `plan_execute`:规划、执行、重规划。
- `supervisor`:主管代理转交子代理。
@ -267,7 +255,7 @@ storage:
| `workspace` | 30 天 | Agent 工作区 `tmp/workspace` |
| `reduction` | 7 天 | 超长工具输出落盘 `tmp/reduction` |
| `conversation_artifacts` | 30 天 | 摘要与超长输入台账 `data/conversation_artifacts` |
| `plantask` | 30 天 | 多代理计划看板 `skills/.pi/plantask` |
| `plantask` | 30 天 | 多代理计划看板 `skills/.eino/plantask` |
| `c2_artifacts` | 30 天 | C2 回传/上传/下发/payload `tmp/c2`(清理 payload 后下载链接失效) |
| `chat_uploads` | 90 天 | 对话上传附件 `chat_uploads` |
| `workflow_checkpoints` | 7 天 | 工作流断点 `data/workflow-checkpoints` |

View File

@ -1,216 +0,0 @@
# 深度测评:持续探索与图记忆
独立于「任务管理」的目标工作台,使用 Pi 执行规划、步骤和验收。侧边栏入口位于「对话」下一行;主页面只展示任务列表及行尾操作;点击任务名称或「详情」进入占满主内容区的任务工作区。新建表单使用右侧抽屉。返回列表、切换页面不会停止后台任务。
## 列表操作与归档
任务行末尾提供「开始 / 继续」「暂停」「详情」「归档」;操作是否可用取决于任务状态及账号权限。开始、暂停在列表内更新状态,不自动打开详情;只有点击详情才进入任务工作区。控制请求使用服务端当前版本,重复点击不会并发提交同一任务的操作。
工作区提供返回列表入口,保留列表筛选、分页和已有深链。攻击面图和探索图使用更大的画布,节点详情可收起;自动刷新、切换视图和画布尺寸变化会保留缩放与位置。「适应画布」查看全图,「整理布局」重新排列节点。长中文标签自动换行,完整内容在节点详情中查看。
点击详情默认进入运行概览。概览展示规划/独立验收阶段、当前意图、工具运行及已有输出、Pi 原生模型/工具/压缩状态、队列计数、最近进展和下次唤醒。数据来自现有执行回执、Pi 事件及任务账本;刷新不会额外调用模型或启动任务。无变化时不重建正文,定向补充的草稿、焦点和阅读位置保留。
概览统计可直接查看明细:累计 Token 进入上下文与用量,状态、规划轮次进入运行记录;意图总数和状态计数进入对应队列。「待核对」同时包含结果不明和资源停止待确认的意图。事实、关联漏洞统计进入全部记录的第一页,清除之前的筛选和来源定位;当前意图提供来源回执、执行会话及可访问资产的入口。这些跳转只读取记录,不触发测评执行。
整条测评受阻与单条意图受阻分别展示。规划器、独立验收或运行环境失败时,测评可能受阻但受阻意图数为 0;页面直接展示最近的任务级受阻事件及时间,并提供运行记录入口。该原因不会被后续执行收尾记录挤掉,旧数据没有受阻事件时沿用已保存摘要。
节点详情默认使用较宽的阅读栏,可拖动图与详情之间的分隔线调整宽度;键盘聚焦分隔线后,左右方向键调整,Home 或双击恢复默认宽度。「展开阅读」将当前节点铺满工作区,点击「返回图」恢复分栏。摘要、执行说明、原始回执和来源分别展示;正文独立滚动,自动刷新保留阅读位置和已展开的来源,切换节点从顶部开始。窄屏改为上下布局,也可展开阅读。
较大图显示缩略导航,可点击定位,也可聚焦后用方向键平移。节点类型和状态、关系颜色帮助区分链路;选中节点显示其相连关系的文字,位于画布外或缩得过小时自动定位到可读尺度。循环引用的回边保留,只在计算层级时避开,避免整组挤成单列。多个目标资产链接在正文中折叠展示,不占据固定底部操作区。全图仍按节点分页,大图概览不能保证每个节点的文字同时清晰,可选中节点或展开关联分支阅读。
资产范围切换、搜索和图操作集中在工具栏,说明与图例可按需展开。未关联资产或搜索无结果时显示明确提示;共享资产记录可展开查看。节点详情按字段显示资产信息,并保留原始记录和来源跳转。
「归档」保留目标、意图、图、回执、事实和漏洞关联,默认列表隐藏,可切换「已归档」查看和恢复。执行中、清理中或结果不明的任务必须先暂停并完成核对,不能直接归档。恢复归档只回到列表,待执行任务需要手动开始;归档记录不会被重启恢复或新事实唤醒。
## 持续执行
新建填写名称和目标即可。「补充限制与排除项」「验收条件」均为选填,留空或仅有空白字符时沿用目标;填写的补充内容会独立保留。表单提供简短说明与填写示例。模型、角色、项目、并行步骤和重启恢复也可选配。保存为草稿,点击「开始 / 继续」才执行。
关联项目后,资产范围就是资产库里该项目的可读资产。对话、批量任务和深度测评使用同一批记录,新建时不再要求选择资产集合。目标或项目授权范围里写明的地址也会写入资产库。补充限制和项目排除名单中的地址不会自动加入。任务中发现的同范围服务和端点写回资产库,并出现在攻击面图、项目黑板和后续规划中。信息收集可以另存一份命名检索结果,只在需要缩小范围时使用。
**任务没有时间窗口、累计 Token、规划轮数、总步骤数或累计执行分段次数上限。** Token 和轮次保留为观测统计,不触发任务结束。任务围绕验收条件推进,直到完成、用户暂停/停止,或需要用户补充信息、核对结果不明的操作。
一个方向停滞时交还规划器换路;暂时没有新方向或验收仍有缺口时保留状态,进入「等待新进展」并定时重评。临时模型故障退避后继续,没有累计重试次数终止条件;认证、权限等需修复的问题会明确显示。等待期间不保持一个空转的模型请求。
单次工具超时、模型上下文容量、每次规划增量和并行工作数仍按执行环境处理。Pi 在轮边界保存一个执行分段,再恢复同一会话,这些边界不构成整个目标任务的累计上限。
旧版本的预算字段会在升级时移除,原「预算耗尽」记录转换为暂停,等待用户继续;升级不会擅自启动旧草稿、暂停或停止的任务。旧客户端创建请求里的预算参数不再生效,`control/budget` 返回 410,请刷新页面。
## 探索图与记忆
「探索图」记录以下节点及其关系:
| 节点 | 来源与用途 |
| --- | --- |
| 目标 | 用户提供的目标、范围、验收条件 |
| 探索步骤 | 规划器的具体方向与依赖 |
| 观察 | 阶段检查点、步骤结果和验收缺口,保留原文 |
| 执行回执 | 实际工具调用结果;失败与结果不明状态分别保留 |
| Pi 摘要 | 原生 `compaction_end` 产生的会话摘要,关联原生会话条目 |
| 历史归档 | 冷历史的引用索引,可展开原步骤和相关证据 |
| 人工线索 | 已保存的用户补充,作为用户输入单独标识 |
步骤通过 `depends_on` 建立执行依赖,通过 `source_ids` 引用启发本次探索的观察、回执或摘要。源节点必须属于同一测评。状态变化和观察节点在同一 SQLite 事务提交;原始调用回执和对应节点也在同一事务提交。
借鉴 ARTEX 的冷热分层:活跃方向及其依赖、证据祖先保持可见。已经完成或撤下、连续多轮不参与活跃链路的历史步骤,按引用折叠为归档节点。新方向再次依赖旧步骤或旧证据时,相关链路会重新显示。折叠不删除原步骤、原始观察或工具结果,不改变完成条件。
归档按真实依赖/证据分支分组,并持久化连续冷却的起始轮次;重新被引用后重新计时。已登记漏洞、目标和人工线索不会因来源步骤归档而隐藏,归档的对外关系标明「经归档」。旧版按 ID 批次建立的归档改标「已替代」,原 ID 和成员仍可展开,不删除历史记录。
默认「主链路」收起观察和工具回执,关系标明「经执行记录」;切换「执行记录」或展开分支可查看原文。分页保留跨页引用节点,当前页最多展示 80 个引用;更多关联会明确计数,节点详情提供独立分页的完整上下游列表。跨页引用与归档投影都是视图,原始节点和边保持不变;显示与导航均遵守漏洞读取权限。
会话摘要由 **Pi 原生压缩**生成并沉淀为图中的记忆节点。业务图的冷分支归档保存成员索引及已有结果摘录,不另起一套模型压缩循环。摘要是模型派生的续接材料,证据仍应回查执行回执。
界面支持平移、缩放、适应画布、节点选择、原文分页及归档展开。大图分页面显示,分页大小仅影响本次展示,不限制总节点数;步骤清单也可分页查看。
Agent 可调用:
- `assessment_graph`:查看当前图,传 `scope` 为归档或步骤节点 ID 时展开关联内容。
- `assessment_node`:按 ID 和字符偏移读取完整节点原文与来源。
- `assessment_memory`:检索步骤、图记忆和原始执行过程,包含被折叠的历史。
- `assessment_trace`:分页读取完整执行过程。
- `assessment_checkpoint`:保存当前观察,同时保留 Pi 原生自定义条目。
- `assessment_result`:提交 completed、blocked 或 continue;完成需引用本任务真实成功调用的回执。
## 验收证据矩阵
创建测评时建议每行填写一条验收条件。原有验收条件按非空行显示;留空并沿用任务目标时,整个目标成为一个验收项。
在任务工作台的「验收证据」中,审阅人可搜索并关联本次测评的事实或原始回执。关联事实会展示该事实引用的同一意图回执。可点击节点打开原文,也可给验收项加复核标记和说明。协作者并发编辑同一项时,较旧的版本无法覆盖已保存的关联。
- **已有证据**表示当前选中的证据包含成功原始回执,且没有待核对的关联。
- **缺证据**表示尚未关联事实或回执,也未标记待复核。
- **待人工复核**涵盖人工标记、推断事实、未成功的回执和已不可用的来源。
阶段报告按相同规则列出每个验收项、事实及其支持回执,并可跳回对应节点。证据状态用于人工审阅,保存矩阵不触发工具调用或任务调度,也不改变系统的任务完成判定。
### 双图联动、端点证据与历史对照
- 从攻击面图选中服务,打开「查看证据路径」可查看本资产关联的意图、事实、原始回执和验收项。探索图的事实节点也能打开同一视图反查资产和验收项。浏览器返回可恢复攻击面图的选择、筛选和画布位置。
- 在「验收证据」中打开「查看局部证据图」,可按条件查看关联事实、可读资产及回执。图按事实分页,相关的归档证据可直接定位。人工验收关联、推断及原始回执使用不同的线条。直接回执缺少可见资产锚点时会单独提示。
- 服务下的「端点证据」可筛选已有观察证据、待人工复核或缺证据。审阅人可为指定端点关联或解除同测评、同服务的事实。端点只有明确关联且仍有成功原始回执的观察事实,才计入已有观察证据。
- 「历次测评」按同一共享资产 ID 显示可读的较早测评、观察时间、证据和待复核验收项。项目和保存的范围文字一致时,页面比较新增观察文本、新增证据端点及本次暂无记录的旧端点。文本改动可能计入新增观察。范围或项目不同的记录保留供人工对照。阶段报告对照最近一条可读的较早测评,并提供端点缺口及历史入口。
## 漏洞管理关联
执行过程中通过 `record_vulnerability` 成功登记的漏洞,按实际执行会话自动关联测评 ID、测评名称、步骤 ID 和步骤标题。只写在检查点或摘要中的观察不会自动生成漏洞。工具和权限沿用当前角色配置。
- **测评 → 漏洞**:在任务工作区的「关联漏洞」中查看本次测评已登记的漏洞,打开漏洞管理详情,或在测评中查看其复现步骤、证据和来源步骤回执。
- **漏洞 → 测评**:漏洞详情显示来源测评和步骤,提供「返回测评步骤」「查看步骤与复现证据」入口。链接会定位具体步骤,不受步骤清单当前分页影响。
- **按任务分组**:漏洞管理的任务视图以测评名称展示,内部以测评 ID 分组;同名测评及相同 ID 的批量任务不会混组。任务名称搜索同时支持测评名称,原 `task_id` 参数仍保留批量任务语义;测评可用 `assessment_id` 筛选。
升级会按已有的可信执行会话补建历史关联,不按标题或标签猜测。关联快照随漏洞保存;删除测评或执行会话后,漏洞及其复现内容仍保留,已删除的测评不提供返回入口。
读取测评和读取漏洞分别检查权限。仅分享测评不会自动分享所有漏洞;仅分享漏洞也不会授予来源测评的访问或执行权限。
## 共享攻击面图、意图队列与事实
任务工作区包含「攻击面图」「探索图」「意图队列」「事实」「关联漏洞」「证据回执」等视图。原步骤 ID 和漏洞返回链接保持兼容。
在「攻击面图」的「攻击面线索」中,可手动登记和编辑 AK/SK、账号凭据、API Key / Token 或其他发现。填写脱敏摘要和发现位置,可选填本次测评的事实 ID 来打开证据路径。密钥、密码和令牌原文保留在原证据位置。
- **攻击面图**从现有资产库投影域名、子域、IP、服务、业务应用和端点。多个测评引用同一资产 ID,不复制一套资产库。共享仍遵守资产权限和测评关联项目;IP 连线表示记录中的关联,不代替 DNS 验证。应用节点来自资产的业务系统字段。关联项目且未指定集合时,项目中的可读资产会自动进入这张图。
- 资产库、信息收集、批量任务和深度测评使用同一批资产记录。任务中属于当前范围的新服务和端点会写回资产库,并自动成为后续意图可引用的目标。仍可从资产库手动补充。端点保存在服务资产下,按资产、HTTP 方法、路径去重;查询值和 Token 不写入端点身份。图按资产分页,选中服务后可分页读取全部端点;意图可跳转目标资产,资产节点可反查针对该资产的意图。
- **意图**沿用步骤记录,新增 `asset_ids` 和 `priority`(1 优先、默认 100)。`source_ids` 保留派生依据,`depends_on` 控制执行前置条件。队列持久化,按优先级、原有顺序调度;不因并发已满而丢弃待办,也不会抢占正在执行的意图。
- worker 第一次执行时保存所锚定资产的原始快照,续跑继续使用该快照,同时重新检查当前资产访问权限。资产删除后保留任务和证据历史,不能静默改打另一个目标。
- **事实**不可原地改写。`observed` 表示有本意图原始执行回执支持的观察;`inferred` 表示依据现象或既有节点作出的推断。回执必须真实存在、成功完成且属于相应测评和意图,不能用 Pi 摘要或漏洞登记回执替代。事实通过「产出/支持/推导」边进入探索图。
- 在攻击面图按「全部关联资产」「已有观察证据」「暂无观察证据」筛选,搜索和分页作用于当前筛选。计数基于同一测评中被 observed 事实引用的可读关联资产,同一个资产只计一次。选中服务节点可查看该资产的事实,并从事实定位具体回执。阶段报告包含相同口径的统计和缺证据清单入口。人工验收仍以具体证据和任务验收条件为准。
每次规划与独立验收均创建新的 **Pi 原生会话**。预取内容包括目标、队列数量、优先待办、在跑意图、近期事实、资产观察计数和有界图视图。完整队列、原文及冷历史通过工具分页读取,不把全部历史重新拼进提示词。
事实、漏洞及关联资产更新会在事务中递增持久版本。调度器合并轮询间隔内的变化,允许 worker 未结束时重新规划;模型调用期间又出现新变化,过时的规划/完成结论不能提交。等待新进展的任务收到变化后可提前唤醒;手动暂停、取消的任务不会因此自动启动。
新增工具:
| 工具 | 用途 |
| --- | --- |
| `assessment_intents` | 按状态分页读取持久队列和优先级 |
| `assessment_assets` | 查询项目/权限范围内的共享攻击面图、原始资产和分页端点 |
| `assessment_anchor_assets` | 补充关联资产库中已有的资产。项目资产和任务中新写入资产库的记录会自动关联,通常不必再手工调用 |
| `assessment_fact` / `assessment_facts` | 写入不可变事实 / 分页读取事实 |
| `assessment_endpoint` | 用本意图的原始回执登记服务端点,需要资产写权限 |
| `assessment_findings` | 读取本测评可访问的漏洞及复现、复核记录 |
| `assessment_review_finding` | 记录另一意图实际复现后的 confirmed/refuted/inconclusive 结论(判 refuted 需给齐五维反证与正常对照组验证) |
| `record_coverage` / `assessment_coverage_ledger` | Worker 记录测试面与风险类别的覆盖结果(含阴性证据与排除理由)/ 读取结构化覆盖账本与待补缺口 |
| `assessment_plan_notes` | 规划器跨轮读写多步串行验证路线草稿(带 revision 乐观锁,Worker 只读) |
| `set_goals` / `set_constraints` | 首次启动前拆解可独立核验的交付子目标与去指代化的任务操作边界(失败自动降级沿用原目标) |
新资产登记继续复用 `create_asset`,写入的是资产库中的项目资产,并自动关联到本次测评。漏洞登记继续复用 `record_vulnerability`。深度测评登记漏洞须传 `evidence_receipt_ids`;普通对话与批量任务保持原来的字段要求。新的测评漏洞先显示已登记、待独立复核;独立复核不能由原报告意图自证,也不能引用原意图回执冒充自己的复现。确认或否定结果同步现有漏洞状态,并保留追加的复核历史。尚有待复核或复核未定的新增漏洞时,测评不能自动验收完成。
这些校验保证来源和执行记录可追溯,不能自动判断每段回显一定支持模型结论,更不承诺零误报。复核者仍须检查完整原文、对照实验及复现条件。历史漏洞会补建「待核对」图节点,不补造回执,也不会自动升级为已验证。
## Pi 与宿主的分工
Pi `SessionManager` 管理会话上下文、原生压缩、工具搜索、Skills、重试和生命周期。固定目标与步骤职责随每段执行保留,最新图态势作为有界自定义消息提供,更多历史通过图工具按需读取。结构化工具桥保留参数/输出 schema、结构化结果、annotations、namespace 和暴露策略,权限与实际执行仍由 Go 宿主处理。
规划、执行、独立验收使用 Pi 会话。规划器每轮从持久态势重建输入,未提交的决定不会作为新计划执行;worker 的执行分段仍恢复同一个 Pi 会话。独立验收结合实际回执判断目标是否完成;模型验收不能替代人工复测。
运行中补充方向先入库,再通过 Pi 原生 `steer()` 投递给活跃执行步骤,恢复后也可回查。协作者需以自己的执行身份继续任务。
意图队列支持单条暂停/继续、优先级调整和定向补充。暂停一条意图只取消其执行上下文,其他意图和规划器继续工作;用户暂停标记持久保存,整任务继续和重启不会自动解除,规划器也不能退休该意图来绕过暂停。继续只恢复这一条的排队状态;整任务若已暂停,仍需手动开始整任务。优先级调整不抢占正在执行的步骤。
「给此意图补充方向」先保存到该意图及探索图,再通过对应 Pi 会话的原生 `steer()` 投递;暂停、排队或尚未绑定会话时保存供续跑使用。定向补充不广播给其他 worker。活跃及自动恢复中的测评只允许当前执行账号定向继续或发送执行指令,协作者可先暂停并以自己的账号继续。
下载的 Markdown 报告包含目标、步骤、事实、人工补充,以及当前账号有权读取的关联漏洞、复现内容和完整复核历史。每条复核绑定其原始回执摘录和可返回测评的链接;摘录不替代完整执行会话。运行中导出属于阶段报告,已登记与已独立确认分别标识。
## 恢复语义
点击「开始 / 继续」后自动规划并执行本测评的待办步骤;点击「暂停」后停止新派发,取消规划器与全部在执行的步骤,等待所管执行资源收尾后显示「已暂停」。自动重试、等待新进展和待恢复状态也可暂停;手动暂停后不会被后台恢复队列或服务重启重新启动。打开页面、查看详情和刷新均不会启动任务。
已停止的测评提供独立的「继续测评」入口,保留已完成步骤、原 Pi 会话及证据;只有用户明确点击才会恢复。仍有结果不明或执行资源尚未确认停止的步骤时,先处理待核对项;仍有待答复问题时进入「待答复」,不派发工作。已完成的测评不能重新执行。
「确认已核对」是独立的核对操作,已停止、已完成的测评也可保存。核对后该步骤从「待核对」筛选中移出,历史记录和原始回执保留,任务保持停止或完成状态。确认窗口打开期间若任务有其他更新,页面会重新读取版本;若该步骤已进入另一轮执行,则要求重新查看回执,避免核对到新的执行。
更新或进程退出若打断停止收尾,重启时会整理残留的执行中意图:可信终态回执沿用,未知结果进入待核对,整条测评保持已停止。资源停止尚未确认或存在待答复问题时不会加入自动执行队列。停止收尾期间,旧页面的暂停请求不能覆盖停止决定,仍在收尾的意图也不能直接归档。
核对列表因处理记录而减少时,分页自动回到仍有记录的一页。控制请求固定绑定点击时的测评;浏览器切换测评后,未提交的请求取消,已经提交的请求结果不会覆盖新页面。
1. 工具派发前提交调用意图,结果落库后才交还 Pi。
2. 已确认回执关联原生助手条目与 tool-call ID。若回执已提交而 Pi 记录未写入就退出,恢复时补回已确认结果。
3. 暂停与停止等待本地执行资源收尾,再从同任务、步骤、会话及工具的终态执行记录核对回执。取消信号本身不等于结果不明;确认已取消的调用保存为取消及错误回执,续跑时交回原 Pi 会话,不伪装为成功。旧版误标的记录在点击开始时同样自动核对。
4. 远端取消未获确认、原始执行回执缺失等情况仍进入待核对,不自动重放。点击待核对状态或详情中的「处理待核对」,可跨分页查看相关步骤、回执及执行会话;人工确认只解除该步骤的核对状态,全部处理完仍需手动开始。
5. 已完成步骤保留,结果明确的中断步骤恢复原 Pi 会话。原会话文件缺失时明确受阻,避免静默从空会话重做。
6. 选择自动恢复时,服务重启可恢复此前正在推进且结果明确的任务;草稿、手动暂停及待核对任务不因此开始。图节点、原生摘要和归档成员均持久保存。
当前调度面向单服务进程。允许范围文字会传给规划与执行,实际工具权限继承角色、平台权限、HITL 和调用拦截;范围文字本身不是网络隔离沙箱。
新数据包括 `deep_assessments`、`deep_assessment_events`、`deep_assessment_calls`、`deep_assessment_nodes`、`deep_assessment_edges`、`deep_assessment_sessions` 和 `vulnerability_assessment_sources`。已有深度测评记录会补建图与会话索引,不恢复已撤回旧模块的 `assessments`/`long_tasks` 历史任务。删除测评会清理其任务、图和调度记录;漏洞来源快照随漏洞保留,执行会话仍按原有会话保留策略处理。
## API 与权限
所有接口需登录,使用 `assessments:read/write/delete` 和 `deep_assessment` 资源范围;执行另校验 `agent:execute` 及会话权限。
| 接口 | 用途 |
| --- | --- |
| `GET /api/deep-assessments/options` | 可用项目、角色与模型渠道 |
| `GET / POST /api/deep-assessments` | 查询列表(`archived=true` 查看归档)/ 创建草稿 |
| `GET / DELETE /api/deep-assessments/:id` | 详情 / 删除非活动测评 |
| `GET /api/deep-assessments/:id?step_limit=50&step_offset=0&runtime=true` | 分页详情与运行概览;`step_order=queue&step_status=needs_review` 定位待核对步骤 |
| `POST /api/deep-assessments/:id/control/:action` | start、continue-stopped、pause、cancel、guidance、answer、retry、reconcile、archive、restore,以及 intent-pause、intent-resume、intent-priority、intent-guidance |
| `GET / POST /api/deep-assessments/:id/assets` | 查看共享/关联攻击面图,或关联资产;`asset_id` 查询服务端点;关联视图支持 `observation=observed` 或 `observation=missing` |
| `GET /api/deep-assessments/:id/intents?status=&offset=0` | 优先级队列和状态计数 |
| `GET /api/deep-assessments/:id/facts?confidence=&offset=0` | 分页读取观察/推断事实,可用 `asset_id` 按可读的关联资产筛选 |
| `GET /api/deep-assessments/:id/acceptance` | 查看验收项、证据关联与当前复核状态 |
| `GET /api/deep-assessments/:id/acceptance/sources?kind=fact&q=&offset=0` | 分页搜索当前测评的可关联事实或回执(`kind=receipt`) |
| `PUT /api/deep-assessments/:id/acceptance/:criterion` | 保存指定验收项的 `fact_ids`、`receipt_ids`、`needs_review`、`review_note` 及当前 `revision` |
| `GET /api/deep-assessments/:id/evidence-path` | 按 `asset_id`、`fact_id` 或 `criterion` 查看分页证据图;结合 `asset_id` 与 `endpoint_id` 查看端点 |
| `GET /api/deep-assessments/:id/evidence-history?asset_id=…` | 分页读取该资产在可读测评中的历史及可比变化 |
| `GET /api/deep-assessments/:id/endpoint-evidence?asset_id=…` | 端点证据状态与筛选;加 `endpoint_id` 浏览可关联事实 |
| `PUT /api/deep-assessments/:id/endpoint-evidence` | 保存 `asset_id`、`endpoint_id`、`fact_id` 与布尔值 `linked` |
| `GET /api/deep-assessments/:id/graph?scope=&view=summary&limit=80&offset=0` | 主链路或 `view=full` 执行记录;包含分页边界计数及引用 |
| `GET /api/deep-assessments/:id/graph/node?node_id=…&offset=0&links_offset=0` | 原文及独立分页的上下游关系 |
| `GET /api/deep-assessments/:id/vulnerabilities?limit=20&offset=0` | 当前账号可读的关联漏洞 |
| `GET /api/deep-assessments/:id/vulnerabilities/:vulnerabilityId` | 属于该测评的漏洞详情和来源步骤 |
| `GET /api/deep-assessments/:id/steps/:stepId` | 单个步骤,用于跨分页定位 |
| `GET /api/deep-assessments/:id/events?after=0` | 增量事件 |
| `GET /api/deep-assessments/:id/receipts?offset=0` | 工具回执,或用 `receipt_id` 查看单条 |
| `GET /api/deep-assessments/:id/report` | 包含当前状态及缺口的阶段报告 |
控制请求携带 `revision`。核对使用 `reconcile`,传 `step_id` 和 `reconciled:true`;资源清理未确认另需 `cleanup_confirmed:true`。兼容旧客户端通过 `retry` 提交核对,但不会自动开始执行。`continue-stopped` 仅用于用户明确继续已停止测评,另检查执行权限。
单条意图操作另传 `step_id`;调整优先级传 `priority`(1–1000),定向补充传 `message`。响应的 `guidance_delivered` 表示是否已投递到当前 Pi 会话;未投递时已保存,后续继续生效。
## 验证边界
隔离回归验证旧预算不生效、超过原步骤/分段上限仍能继续、冷分支折叠与活跃链路恢复、原始 Pi 摘要回查、图来源隔离、重启恢复和真实 Pi SDK 模拟模型闭环。浏览器回归检查无预算表单、图渲染、节点读取、抽屉交互、桌面与手机布局,原批量任务回归仍保留。
这些测试验证执行机制,不等于已完成真实目标的多天效果、发现质量或成本对照试验。

View File

@ -10,7 +10,7 @@
- Python:部分 MCP 服务或工具脚本需要 Python 运行环境。
- SQLite:默认使用文件型数据库,无需单独服务。
- 安全工具:`tools/` 中的 YAML 只是工具定义,实际命令如 `nmap`、`sqlmap`、`nuclei` 仍需安装到系统 PATH。
- 模型服务:至少配置一个 `ai.channels` 通道;`provider: openai_compatible` 适用于 OpenAI 兼容 API,`provider: claude` 使用 Pi 原生 Claude 组件。
- 模型服务:至少配置一个 `ai.channels` 通道;`provider: openai_compatible` 适用于 OpenAI 兼容 API,`provider: claude` 使用 Eino 原生 Claude 组件。
建议目录:
@ -43,8 +43,6 @@ https://127.0.0.1:8080/
自签证书会触发浏览器安全提示,这是本地测试的正常现象。生产环境建议配置真实证书。
自动生成的证书和私钥保存在配置目录下的 `data/tls/self-signed.pem`,后续启动和一键更新都会复用。首次从内存自签版本升级时会生成新的证书。需要轮换时,先停止服务并移走此文件,下次启动会生成新的证书。
`run.sh` 是最常用的启动入口,适合:
- 本机体验。
@ -173,7 +171,7 @@ sudo journalctl -u cyberstrikeai -f
- `config.yaml`
- `data/conversations.db`
- `data/knowledge.db`
- `data/pi-sessions/`
- `data/eino-checkpoints/`
- 自定义 `tools/roles/skills/agents/knowledge_base`
- 上传文件目录 `chat_uploads/`
@ -191,11 +189,9 @@ SQLite 热备份时最好先停止服务,或至少复制 `*.db`、`*.db-wal`
并被页面标出,装好 go 后再点一次「一键更新」即补编译。
细节见 [开发者指南](developer-guide.md) 的「一键更新」一节。
在 macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,点击「一键更新」后,控制台在构建成功时自动切换到新二进制。
构建期间旧服务继续提供服务;切换时连接会短暂中断,页面在新服务应答后自动刷新并沿用仍然有效的登录会话。
刷新后可以在「一键更新」的「运行中的构建」字段核对当前服务的提交号。
这一步不依赖 systemd 或 launchd;长期部署仍建议用守护进程做开机自启和异常恢复。通过 API 或命令行换过
二进制后,可以在支持自动切换的安装上用控制台的「立即重启服务」启用磁盘上的版本。
检测到 systemd/launchd(环境里有对应启动标记)时,"更新完成后退出进程"默认勾选:更新成功后进程退出、
由守护拉起新二进制,页面会在服务回来时自动刷新(会话在内存里,需要重新登录一次)。忘勾、或在命令行
换过二进制时,控制台顶部有常驻横幅和「立即重启服务」补上这一步——不必再登录服务器手动重启。
更新源是 `config.yaml` `update` 段里的**一个仓库地址**(`repo`),也可以直接在控制台「一键更新」页填写保存:
想跟随官方仓库、自己的二开、别人的二开或镜像,改的都是这一处;不写就是官方仓库。**用 Release 包解压安装、
@ -257,7 +253,7 @@ Python 依赖方面:`venv/` 由 `run.sh` 自动创建和管理,保留它就
- 可替换:二进制、`web/`、默认 `tools/roles/skills/agents/docs`。
- 必须保留:`config.yaml`、`data/`、自定义工具/角色/技能/子代理、`knowledge_base/`、`chat_uploads/`。
- `data/pi-sessions/` 是会话数据,应与数据库共同备份,通过对话删除机制清理,不能当作缓存直接删除。临时 workspace、旧 payload 和工具记录按保留策略处理。
- 可清理但要谨慎:`data/eino-checkpoints/`、临时 workspace、旧 payload、旧工具执行记录。
升级时如果覆盖整个目录,应先把自定义目录和 `data/` 移出或备份。很多“升级后配置丢了”的问题,本质是把运行态文件当成发布包的一部分覆盖掉。

View File

@ -11,7 +11,7 @@ internal/handler/ HTTP Handler
internal/database/ SQLite 数据访问
internal/security/ 认证、限流、Shell 执行
internal/mcp/ MCP Server、外部 MCP 管理
internal/multiagent/ Pi 单代理、多代理、中间件
internal/multiagent/ Eino 单代理、多代理、中间件
internal/workflow/ 工作流运行时
internal/knowledge/ 知识库索引与检索
internal/c2/ 内置 C2
@ -41,7 +41,7 @@ go run ./cmd/server --config config.yaml
2. 在 `internal/database/` 增加必要的数据访问。
3. 在 `internal/app/app.go` 构造并注册路由。
4. 如需对外文档,更新 `internal/handler/openapi.go`。
5. 如需前端调用,更新 `web/frontend/src/pages/`。
5. 如需前端调用,更新 `web/static/js/`。
## 一键更新:让安装目录更新它自己的源码
@ -54,7 +54,7 @@ go run ./cmd/server --config config.yaml
| 入口 | 怎么用 |
|---|---|
| 控制台 | 「系统设置 → 一键更新」(`#system-update` 老深链仍可用)。「一键更新」发起任务并轮询进度;支持自动切换的安装默认在构建成功后切到新二进制,页面在服务恢复后自动刷新;另有回滚按钮 |
| 控制台 | 「系统设置 → 一键更新」(`#system-update` 老深链仍可用)。打开这一区只读本机状态、不联网;点「检查更新」才去 fetch;「一键更新」发起任务并轮询进度;"更新完成后退出进程"在检测到守护进程(launchd/systemd 的启动标记)时默认勾选,重启期间页面守着重连、新进程一应答就自动刷新(会话在内存里,刷新后需重新登录);另有回滚按钮 |
| REST | `GET /api/system/update`(磁盘现状,不联网)、`POST /api/system/update/check`(fetch 后报告差集)、`POST /api/system/update/apply`(`202` 返回 `job_id`,用 `GET /api/system/update/job` 轮询)、`POST /api/system/update/rollback` |
| CLI | `./cyberstrike-ai -check-update`、`./cyberstrike-ai -update`、`./cyberstrike-ai -update-rollback`。安装目录 = `--config` 所在目录,未给 `--config` 时是当前目录 |
@ -141,19 +141,21 @@ update:
`rollbackPending` 提示会暂停新更新。保留恢复记录、备份目录和 `.prev`,不要手动删除它们。
如果记录中的二进制哈希无法与现场对应,会拒绝覆盖并保留现场。
### 切换到新二进制
### 重启的两种情形
macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,点击「一键更新」直接发送 `restart: true`,无需二次确认。
只有成功构建并换入二进制才会切换:服务先关闭应用资源,再用相同 PID、启动参数、环境和工作目录执行新二进制。
不支持的启动方式不提供自动切换;REST 显式请求重启时返回 `400`。REST 不传该字段和 CLI 更新都只换磁盘文件。
进程只有在请求显式带 `restart: true`、且启动时装配了重启钩子时才会优雅退出(`Shutdown` 后退出码 0)。
能不能被拉起来取决于外部守护(systemd、`run.sh`),页面如实这么写,而不是承诺一次可能不发生的启动;
没装配钩子时要求重启是 `400`,而不是先停掉服务再自称重启了。
**待生效状态是持久的、可补重启。** 状态接口对比"启动时记下的二进制身份(大小 + 纳秒 mtime)"与磁盘
现值:更新、回滚或 CLI 换过二进制而没重启时,`needsRestart` 为真、`binaryBuiltAt` 给出构建时间,
控制台顶部出现常驻横幅与「立即重启服务」(`POST /api/system/update/restart`;没有待生效版本时
`409 nothing_pending`、有任务在跑 `409`、不支持时 `400`)。控制台根据 `canRestart` 决定能否自动切换。
`409 nothing_pending`、有任务在跑 `409`、没钩子 `400`)。`supervised` 字段来自环境标记(launchd 的
`XPC_SERVICE_NAME`、systemd 的 `INVOCATION_ID`/`JOURNAL_STREAM`),只用来决定勾选框的默认值。
**重启后页面自动刷新。** 控制台每 2 秒通过会话验证接口探测服务启动标记,收到新标记才刷新。
支持会话交接的两个版本之间切换时,有效登录保持原来的到期时间,权限从新进程的 RBAC 存储重新加载。首次从旧版升级时可能需要重新登录。离开控制台则停止探测。
**重启后页面自己回来。** 重启期间控制台换成自恢复视图,每 2 秒探一次状态接口:旧进程还在应答(200)
就继续等;连不上说明正在退出;新进程接客但对旧会话只回 401——这就是"重启已完成"的判据,页面随即
`location.replace` 回 `#system-update` 整页刷新。离开控制台则静默停表,不把已经走开的用户拽回来。
## 数据库
@ -203,7 +205,7 @@ Skill 放在 `skills/<name>/SKILL.md`。用于提供专题能力、流程说明
## 前端开发
前端代码按功能拆分在 `web/frontend/src/pages/`。新增页面或模块时:
前端代码按功能拆分在 `web/static/js/`。新增页面或模块时:
- 复用现有 `apiFetch`、modal、通知、i18n 工具。
- 同步更新 `web/static/i18n/zh-CN.json` 和 `en-US.json`。

View File

@ -1,33 +1,335 @@
# 前端国际化
## CyberStrikeAI 前端国际化方案
前端已迁移为 React + Semi Design 单页应用,国际化由 `web/frontend/src/lib/i18n.jsx` 提供,
词条继续复用后端同目录 `web/static/i18n/*.json`(zh-CN / en-US / ru-RU / ar-SA)。
本文档说明 CyberStrikeAI Web 前端(`web/templates/index.html` + `web/static/js/*.js`)的国际化设计与开发规范,确保在不引入打包工具和不改动后端路由的前提下,实现可扩展、低返工的多语言支持。
## 运行时行为
当前目标:
- 语言偏好保存在 `localStorage['csai_lang']`,未设置时按 `navigator.language` 推断,默认 `zh-CN`。
- 启动时并行加载当前语言、`zh-CN` 兜底与 `en-US`(第三兜底)三份词条;缺失的键按「当前语言 → zh-CN → en-US → 调用方兜底中文」回退。
- 切换语言会更新 `<html lang>`,阿拉伯语自动把 `<html dir>` 设为 `rtl`,并通过 Semi `ConfigProvider` 切换组件语言包。
- 语言切换不会刷新页面;`useT()` 返回的 `t` 会随 Provider 重新渲染。
- **支持中英文切换(zh-CN / en-US)**
- 后续可方便扩展更多语言(如 ja-JP、ko-KR 等)
## 在页面里使用
---
```jsx
const t = useT();
t('vulnerability.title'); // 词条里存在键
t('common.minutesAgo', { n: 5 }); // 支持 {{n}} 插值
t('chat.unknownKey', null, '中文兜底'); // 键缺失时用第三参数
## 一、总体设计原则
- **前端主导的客户端国际化**:所有 UI 文案在浏览器端根据当前语言动态渲染,后端 Go 仅负责结构和数据,不参与语言分发。
- **单一 HTML 模板**:继续使用一份 `index.html` 模板,不为不同语言复制模板文件。
- **文案与逻辑分离**:所有可见文本通过「键值表」管理(多语言 JSON),HTML / JS 只写 key,不直接写中文/英文常量。
- **渐进式改造**:先覆盖 header / 登录 / 侧边栏 / 系统设置等关键区域,其他页面按模块逐步迁移,避免一次性大改动。
- **可回退默认语言**:即使目标语言未完全翻译,也能回退到默认中文,不出现原始 key。
---
## 二、技术选型与目录结构
### 2.1 技术选型
- **i18n 引擎**:使用 [i18next](https://www.i18next.com/) 的浏览器 UMD 版本(通过 CDN 引入),无需打包器。
- **资源格式**:每种语言一份 JSON 文件,采用「域 + 语义」的层级 key 方案,例如:
- `common.ok`
- `nav.dashboard`
- `header.apiDocs`
- `settings.robot.wecom.token`
### 2.2 目录结构
- `web/templates/index.html`
- 页面骨架 + 所有静态文案位置,将逐步改为 `data-i18n` 标记。
- `web/static/js/i18n.js`
- 前端 i18n 初始化与 DOM 应用逻辑(本方案新增)。
- `web/static/i18n/`(新增目录)
- `zh-CN.json`:中文文案(默认语言)
- `en-US.json`:英文文案
- 未来可新增:`ja-JP.json`、`ko-KR.json` 等。
---
## 三、文案组织规范
### 3.1 Key 命名约定
- 采用「**模块.语义**」形式,最多 2–3 级,确保可读性:
- 导航:`nav.dashboard`、`nav.chat`、`nav.settings`
- 头部:`header.title`、`header.apiDocs`、`header.logout`
- 登录:`login.title`、`login.subtitle`、`login.passwordLabel`、`login.submit`
- 仪表盘:`dashboard.title`、`dashboard.refresh`、`dashboard.runningTasks`
- 系统设置:`settings.title`、`settings.nav.basic`、`settings.nav.robot`、`settings.apply`
- 机器人配置:`settings.robot.wecom.enabled`、`settings.robot.wecom.token` 等。
- 尽量按「界面区域」而不是「文件名」划分域,便于非开发人员理解。
### 3.2 JSON 示例
`web/static/i18n/zh-CN.json` 示例:
```json
{
"common": {
"ok": "确定",
"cancel": "取消"
},
"nav": {
"dashboard": "仪表盘",
"chat": "对话",
"infoCollect": "信息收集",
"tasks": "任务管理",
"vulnerabilities": "漏洞管理",
"settings": "系统设置"
},
"header": {
"title": "CyberStrikeAI",
"apiDocs": "API 文档",
"logout": "退出登录",
"language": "界面语言"
},
"login": {
"title": "登录 CyberStrikeAI",
"subtitle": "请输入配置中的访问密码",
"passwordLabel": "密码",
"passwordPlaceholder": "输入登录密码",
"submit": "登录"
}
}
```
要求:
英文文件 `en-US.json` 保持相同 key,不同 value:
1. 可见文案统一走 `t(...)`,第三个参数写中文兜底,避免出现原始 key。
2. 新增词条时同时更新 `web/static/i18n/zh-CN.json` 与 `en-US.json`;`ru-RU`/`ar-SA` 可暂时缺失,靠回退链。
3. 表单校验、Toast、空态文案同样走 `t(...)`。
4. 时间格式化使用 `src/lib/format.js` 的 `formatDateTime/relativeTime`,不要手拼日期。
```json
{
"common": {
"ok": "OK",
"cancel": "Cancel"
},
"nav": {
"dashboard": "Dashboard",
"chat": "Chat",
"infoCollect": "Recon",
"tasks": "Tasks",
"vulnerabilities": "Vulnerabilities",
"settings": "Settings"
},
"header": {
"title": "CyberStrikeAI",
"apiDocs": "API Docs",
"logout": "Sign out",
"language": "Interface language"
},
"login": {
"title": "Sign in to CyberStrikeAI",
"subtitle": "Enter the access password from config",
"passwordLabel": "Password",
"passwordPlaceholder": "Enter password",
"submit": "Sign in"
}
}
```
## 词条组织
> 约定:**新增界面时,必须先定义 i18n key,再在 HTML/JS 中使用 key**,禁止直接写死中文/英文。
---
## 四、HTML 标记规范(data-i18n)
### 4.1 基本规则
- 使用 `data-i18n` 将元素文本与某个 key 绑定:
```html
<span data-i18n="nav.dashboard">仪表盘</span>
```
- 默认行为:脚本会替换元素的 `textContent`。
- 同时翻译属性时,额外使用 `data-i18n-attr`,逗号分隔多个属性名:
```html
<button
class="openapi-doc-btn"
onclick="window.open('/api-docs', '_blank')"
data-i18n="header.apiDocs"
data-i18n-attr="title"
title="API 文档">
<span data-i18n="header.apiDocs">API 文档</span>
</button>
```
### 4.2 默认文本的作用
- HTML 内的中文默认值作为「**无 JS / 初始化前**」的占位内容:
- 页面在 JS 尚未加载完成时不会出现空白或 key。
- JS 初始化后会用当前语言覆盖这些文本。
---
## 五、JavaScript 中的文案规范
### 5.1 全局翻译函数 `t()`
由 `i18n.js` 暴露以下全局函数:
- `window.t(key: string): string`
- 返回当前语言下的翻译文本,若缺失则回退到默认语言,再不行则返回 key 本身。
- `window.changeLanguage(lang: string): Promise<void>`
- 切换语言并刷新页面文案(不会刷新整页)。
示例(以 `web/static/js/settings.js` 为例):
```js
// 之前
alert('加载配置失败: ' + error.message);
// 之后
alert(t('settings.loadConfigFailed') + ': ' + error.message);
```
> 规范:**JS 内所有面向用户的提示、按钮文字、对话框标题都应通过 `t()` 获取**,不直接写死中文/英文。
### 5.2 渐进迁移建议
- 优先改造:
- 频繁弹出的错误提示 / 成功提示;
- 登录相关、系统设置相关文案。
- 低优先级:
- 仅面向运维人员的调试提示,可以暂时保留英文/中文常量。
---
## 六、i18n 初始化与语言切换实现
### 6.1 语言选择策略
- 默认语言:`zh-CN`。
- 优先级(从高到低):
1. `localStorage` 中的用户选择(key:`csai_lang`)。
2. 浏览器 `navigator.language`(`zh` 开头 → `zh-CN`,否则 `en-US`)。
3. 默认 `zh-CN`。
### 6.2 初始化流程(`i18n.js`)
1. 读取初始语言。
2. 初始化 i18next:
- `lng` 为当前语言;
- `fallbackLng` 为 `zh-CN`;
- 资源先留空,采用按需加载。
3. 通过 `fetch` 拉取 `/static/i18n/{lng}.json` 并 `i18next.addResources`。
4. 更新:
- `<html lang="...">` 属性;
- 所有带 `data-i18n` / `data-i18n-attr` 的元素。
5. 暴露 `window.t` 与 `window.changeLanguage`。
### 6.3 DOM 应用逻辑
伪代码:
```js
function applyTranslations(root = document) {
const elements = root.querySelectorAll('[data-i18n]');
elements.forEach(el => {
const key = el.getAttribute('data-i18n');
if (!key) return;
const text = i18next.t(key);
if (text) {
el.textContent = text;
}
const attrList = el.getAttribute('data-i18n-attr');
if (attrList) {
attrList.split(',').map(s => s.trim()).forEach(attr => {
if (!attr) return;
const val = i18next.t(key);
if (val) el.setAttribute(attr, val);
});
}
});
}
```
> 对于由 JS 动态插入的元素,需要在插入后再次调用 `applyTranslations(新容器)`。
---
## 七、语言切换 UI 规范
### 7.1 位置与形态
- 位置:`index.html` header 右侧 `API 文档` 按钮附近(靠近用户头像)。
- 交互形式:
- 一个紧凑的语言切换组件,例如:
- `🌐` 图标 + 当前语言文本(`中文` / `English`)的下拉按钮;
- 下拉内容列出所有可用语言。
### 7.2 示例结构
```html
<div class="lang-switcher">
<button class="btn-secondary lang-switcher-btn" onclick="toggleLangDropdown()" data-i18n="header.language">
<span class="lang-switcher-icon">🌐</span>
<span id="current-lang-label">中文</span>
</button>
<div id="lang-dropdown" class="lang-dropdown" style="display: none;">
<div class="lang-option" data-lang="zh-CN" onclick="onLanguageSelect('zh-CN')">中文</div>
<div class="lang-option" data-lang="en-US" onclick="onLanguageSelect('en-US')">English</div>
</div>
</div>
```
对应 JS(在 `i18n.js` 中):
```js
function onLanguageSelect(lang) {
changeLanguage(lang).then(updateLangLabel).catch(console.error);
closeLangDropdown();
}
function updateLangLabel() {
const labelEl = document.getElementById('current-lang-label');
if (!labelEl) return;
const lang = i18next.language || 'zh-CN';
labelEl.textContent = lang.startsWith('zh') ? '中文' : 'English';
}
```
> 规范:**语言切换只更新文案,不刷新整页,也不修改 URL hash**。
---
## 八、开发流程建议
### 8.1 新增 / 修改界面的流程
1. 设计界面时,先列出所有文案。
2. 在对应语言 JSON 中补充/修改 key 与翻译。
3. 在 HTML 中使用 `data-i18n`,在 JS 中使用 `t('...')`。
4. 在浏览器中切换中英文,确认两种语言显示都正确。
### 8.2 渐进式改造顺序(推荐)
1. **阶段 1(已规划)**
- 引入 i18next 与 `i18n.js`。
- 新建 `zh-CN.json` / `en-US.json`(先覆盖 header / 登录 / 左侧导航)。
- 实现 header 区域语言切换组件。
2. **阶段 2**(已完成)
- 系统设置页面(包括机器人配置页面)全部文案 i18n 化。
- `settings.js` 中的提示与错误信息改用 `t()`。
3. **阶段 3**(进行中)
- 仪表盘、任务管理、漏洞管理、MCP、Skills、Roles 等页面按模块逐步迁移。
4. **阶段 4**
- 清理 JS / HTML 中残留的硬编码中文,统一通过 i18n。
---
## 九、后续扩展新语言
当需要新增语言时:
1. 在 `web/static/i18n/` 中新增 `{lang}.json`,复制现有英文/中文文件结构,补充对应翻译。
2. 在语言切换下拉中添加对应选项,例如:
- `data-lang="ja-JP"` / 文本 `日本語`
3. 无需修改 `i18n.js` 或现有 HTML/JS 逻辑,即可支持新语言。
---
## 十、注意事项与坑点
- **不要复制多份 HTML 模板** 来做多语言,那样维护成本极高,本方案统一由前端 i18n 控制。
- **避免 key 直接用中文/英文句子**,统一采用「模块.语义」短 key,便于 diff 与搜索。
- 避免在 CSS 中写死文本(如 `content: "xxx"`),如确有需要,应通过 JS 设置并走 i18n。
- 对于后端返回的可本地化错误文本(未来可能支持),优先由后端根据 `Accept-Language` 返回对应语言,前端只负责展示。
`web/static/i18n/zh-CN.json` 按业务域分组:`common`、`nav`、`dashboard`、`vulnerability`、`chat`、
`settings`、`knowledge`、`skills`、`roles`、`auth`、`apiDocs` 等。新增分组时保持两级键名
(`<domain>.<key>`),避免深层嵌套影响可读性。

View File

@ -106,7 +106,7 @@ OpenAI 协议后端把这段文字当聊天提示词。TypeSafe Jev 把它当作
- 执行与任务状态查询:`get_tool_execution`、`wait_tool_execution`、`batch_task_list`、`batch_task_get`
- 本地管理元数据查询:`manage_webshell_list`、`c2_event`、`c2_file`
上述内置 MCP 查询仍受 RBAC 和资源范围约束;白名单只跳过 HITL 审批,不扩大访问权限。`list_dir` 仅在实际工具名为该值时有效;Pi 文件系统的目录列表工具名是 `ls`。
上述内置 MCP 查询仍受 RBAC 和资源范围约束;白名单只跳过 HITL 审批,不扩大访问权限。`list_dir` 仅在实际工具名为该值时有效;Eino 文件系统的目录列表工具名是 `ls`。
不建议直接全局白名单:

View File

@ -1,116 +0,0 @@
# HTTP 测试工具代理池
[English](../en-US/http-proxy-pool.md) | [文档首页](README.md)
`http-framework-test` 支持用户提供的代理列表及代理供应商接口。连接失败或响应命中指定状态码时,在次数上限内切换代理;成功代理继续复用连接。默认沿用工具参数。也可在「系统设置 → 代理设置」统一管理此 HTTP 工具的出口。
## 使用
更新工具文件后,在系统设置中应用配置或重启服务以重新加载工具参数。也可以在代理二级菜单保存配置,后续调用立即生效;运行中进程保留启动时快照。
调用 `http-framework-test` 时传入以下参数(MCP 工具参数示例):
```json
{
"url": "https://your-authorized-target.example/health",
"method": "GET",
"proxy_pool": "[\"http://127.0.0.1:8081\",\"http://127.0.0.1:8082\"]",
"proxy_max_attempts": 3,
"proxy_cooldown": "60",
"proxy_fail_status": "403,429",
"response_max_bytes": 8192
}
```
`proxy_pool` 也接受每行一个代理的字符串。支持 `http://host:port`、`https://host:port`、`socks5://host:port` 和省略协议的 `host:port`(按 HTTP 解析);端口必须显式指定。支持 IPv6 方括号及 `user:password@host:port` 认证,凭证中的特殊字符须做 URL 编码。SOCKS 依赖包含在 `requirements.txt` 的 `httpx[http2,socks]` 中。
使用供应商接口自动获取代理时,增加或单独使用:
```json
{
"url": "https://your-authorized-target.example/health",
"proxy_source": "https://your-proxy-provider.example/api/proxies"
}
```
接口返回 UTF-8 文本,每行一个代理,或以下 JSON 格式之一:
```json
["http://127.0.0.1:8081", "127.0.0.1:8082"]
```
```json
{"proxies": ["http://127.0.0.1:8081"]}
```
也支持 `{"data": ["http://127.0.0.1:8081"]}`。列表元素还可为 `{"host":"127.0.0.1","port":8081,"scheme":"http","username":"user","password":"pass"}`(`ip` 可代替 `host`),或 `{"url":"http://127.0.0.1:8081"}`。`scheme` 默认 HTTP,认证字段可省略;结构化凭证自动做 URL 编码。需要其他供应商字段格式时,应由供应商或自建适配接口转换为上述格式。项目不内置公共免费代理来源。
供应商接口在调用开始时拉取一次;每个请求或重定向跳的可用代理耗尽时,最多再拉取一次。新地址与现有地址去重合并,已有冷却记录保留。连接/读取超时为 10 秒,不跟随重定向,响应上限 1 MiB,代理总数上限 256。首次拉取失败时,有静态列表则发出提示并继续使用静态代理;仅配置供应商时结束调用;切换过程中拉取失败则保留最后的 HTTP 失败响应,若还未收到响应则报错。
## 切换与结果
| 参数 | 默认值 | 行为 |
| --- | --- | --- |
| `proxy_pool` | 空 | JSON 字符串数组或换行列表 |
| `proxy_strategy` | `"sticky"` | `sticky` 成功后复用,`round_robin` 轮询并跳过冷却代理 |
| `proxy_source` | 空 | 用户配置的 HTTP(S) 供应商接口,可与列表合用 |
| `proxy_max_attempts` | `3` | 每个请求/重定向跳最多尝试 1–10 个不同代理 |
| `proxy_cooldown` | `"60"` | 失败代理冷却 0–86400 秒 |
| `proxy_fail_status` | `"403,429"` | 逗号分隔的 400–599 状态码,传 `"none"` 禁用状态码切换 |
具体规则:
- 默认保持成功代理;设置 `proxy_strategy="round_robin"` 后,每个请求/重定向跳轮询可用代理;失败后冷却,在剩余可用代理中切换。每个请求或重定向跳内,同一代理最多尝试一次。
- 仅 GET、HEAD、OPTIONS 自动重放。POST、PUT、DELETE 等方法发生错误或命中状态码时保留首次结果;用户显式设置的 `repeat` 仍表示额外执行次数。
- 连接、代理、超时等传输错误可触发上述切换;响应体开始读取后的中断直接报错,不重放部分响应。
- 429 若包含有效且尚未到期的 `Retry-After`,停止自动重放并提示稍后重试。同一工具调用中,对该目标源的后续请求也会被阻止至等待期结束,等待值最多记为 24 小时。
- 最后一次尝试若收到 HTTP 失败响应,保留该响应并返回非零退出码;网络故障或所有代理处于冷却时报告错误。不会回退到直连,也不会运行额外的目标 DNS/TCP/TLS 直连探针。
- stderr 记录尝试编号、代理编号及失败类型;stdout 保留最终响应及最终代理编号。代理池自身诊断不输出代理凭证或供应商 URL。工具调用参数仍沿用平台既有的轨迹、审计与日志规则,带凭证的参数应按敏感配置管理。
## 调研结论与覆盖范围
[#357](https://github.com/AIPentest/CyberStrikeAI/issues/357) 仅提出自动获取代理与被封后切换,未定义供应商、识别方式或工具范围。当前实现从能读取 HTTP 响应的 `http-framework-test` 接入,使 HTTP 和 HTTPS 的切换行为都可验证。
HTTP CONNECT 隧道中的 HTTPS 响应需要由发起请求的客户端解密才能读取,因此单独增加全局转发代理不足以识别全部工具的 HTTPS 封禁响应。HTTPX 的代理与自定义传输接口适合在本工具内完成切换,见 [HTTPX 代理文档](https://www.python-httpx.org/advanced/proxies/)与[传输文档](https://www.python-httpx.org/advanced/transports/)。
403 也可能是业务权限错误,429 也可能按账号或其他维度限流;默认状态码只是可配置的失败策略,不宣称已确认 IP 被封。不匹配状态码的验证码页、HTTP 200 拦截页目前保持原样。重放和等待规则参考 [RFC 9110 §9.2.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-9.2.2) 和 [RFC 6585 §4](https://www.rfc-editor.org/rfc/rfc6585.html#section-4)。
池状态只在单次工具调用内保留,不跨会话共享。其他扫描工具、`exec`、Pi `execute`、外部 MCP、LLM API 连接暂不接入本池;系统设置中的代理页面只管理上述 HTTP 工具。供应商拉取使用独立客户端,开启 TLS 校验,不继承目标请求的 Cookie、Authorization、环境代理或 `allow_insecure`;生产供应商接口建议使用 HTTPS。
## 排错与源码
| 提示 | 处理 |
| --- | --- |
| `Proxy pool exhausted` | 检查代理可达性,等待冷却或更换列表/供应商返回值 |
| `failure policy still matched` | 查看保留的响应;确认是 IP 限制还是正常的权限/限流结果,按需调整 `proxy_fail_status` |
| `Retry-After is still active` | 等待目标指定的时间后再发起调用 |
| `Could not fetch proxy source` | 检查供应商接口网络、认证和 TLS;目标的 `allow_insecure` 不影响供应商连接 |
| `SOCKS support requires ...` | 在工具使用的 Python 环境安装 `httpx[socks]` 或更新 `requirements.txt` 依赖 |
执行代码与 MCP 参数定义位于 [tools/http-framework-test.yaml](../../tools/http-framework-test.yaml),回归场景位于 [scripts/test_http_proxy_pool.py](../../scripts/test_http_proxy_pool.py)。
## 本地验证
```sh
python3 -m pip install 'httpx[http2,socks]>=0.27.0' PyYAML
python3 -m unittest discover -s scripts -p 'test_http_proxy_pool.py' -v
```
测试从 YAML 读取实际执行代码,使用本地 HTTP 代理、CONNECT 隧道及 TLS 服务验证切换、路径保真、重放限制、等待期、供应商刷新与凭证隔离;不访问外部目标或真实供应商。HTTPS 测试需要 `openssl`。
## 系统设置与稳定出口
系统设置 → 代理设置提供三种模式:沿用工具参数、固定代理、代理池。固定模式在不同调用之间持续使用配置的同一代理地址,不做失败切换;需要稳定 IP 的登录态优先选它。池模式可选择复用或轮询,界面默认最短切换间隔 60 秒。间隔同时限制故障切换,尚未到期时保留响应或报错,不提前更换出口。计时只在单次调用内有效;跨调用仍需稳定出口时使用固定模式及供应商的固定 IP 服务。
保存通过既有 `PUT /api/config` 的 `proxy` 段持久化并热应用,只影响以后启动的 `http-framework-test`。`proxy_url`、`proxy_pool`、`proxy_source` 在 GET 响应中整体脱敏;`********` 原样提交会保留已有值,空字符串表示清除。设置页列表每行一个 URL;结构化供应商格式仍可由供应商接口提供。配置示例见 `config.example.yaml` 的 `proxy` 段。受管设置通过该工具专用的进程环境快照传递,不加入命令参数或自动注入模型上下文;它不限制任意 Shell 命令的网络行为。
### 参考项目与采用的做法
| 参考 | 做法与本项目选择 |
| --- | --- |
| [Zyte Sessions](https://docs.zyte.com/zyte-api/usage/features.html#sessions) | IP、Cookie 和连接环境共同影响会话。提供固定出口模式,登录态不默认轮询。 |
| [HTTPX Clients](https://www.python-httpx.org/advanced/clients/) | 复用连接和 Cookie。运行中的调用保持快照,设置变更不拆除已有连接。 |
| [Nuclei](https://docs.projectdiscovery.io/opensource/nuclei/running) | 原生代理选项和请求速率分别配置。其他 Kali 工具使用自身代理与限速能力,不从文本输出猜测封禁并重新启动进程。 |
| [Nmap 代理限制](https://nmap.org/book/man-bypass-firewalls-ids.html) | 代理支持有协议和扫描阶段限制,不能承诺统一 HTTP 环境变量覆盖所有原始报文扫描。未适配工具保持原路由。 |
大模型 API 的流式响应、连接池和提供商重试继续使用既有客户端,不接入扫描代理池;模型侧的账号/Token 限流应走现有退避策略。不同供应商是否要求固定公网 IP 需按其接口约定判断,本功能不会自动改动模型出口或轮询 API 连接。

View File

@ -265,8 +265,8 @@ SSRF 如何验证云元数据访问?
- 知识管理:`internal/knowledge/manager.go`
- 索引流水线:`internal/knowledge/index_pipeline.go`
- 原生分块:`internal/knowledge/splitter.go`
- Eino chunk:`internal/knowledge/chunk_eino.go`
- 检索器:`internal/knowledge/retriever.go`
- 原生检索链:`internal/knowledge/retrieve_chain.go`
- Eino 检索链:`internal/knowledge/eino_retrieve_chain.go`
- rerank:`internal/knowledge/rerank_http.go`
- MCP 工具:`internal/knowledge/tool.go`

View File

@ -93,7 +93,7 @@ HTTP 或 SSE MCP 适合远端或长期运行服务。
```yaml
multi_agent:
runtime:
eino_middleware:
tool_search_enable: true
tool_search_min_tools: 20
tool_search_always_visible: 12
@ -184,6 +184,6 @@ cloud_list_public_buckets
- 外部 MCP Manager:`internal/mcp/external_manager.go`
- 连接恢复:`internal/mcp/connection_recovery.go`
- MCP 工具适配:`internal/agentruntime/mcp_tools.go`
- MCP 工具适配:`internal/einomcp/mcp_tools.go`
- 外部 MCP Handler:`internal/handler/external_mcp.go`
- 工具调用通知:`internal/agentruntime/tool_invoke_notify.go`
- 工具调用通知:`internal/einomcp/tool_invoke_notify.go`

View File

@ -1,76 +0,0 @@
# Pi 原生运行时
CyberStrikeAI 仅使用 Pi 1.7.0(`@earendil-works/pi-coding-agent`、`pi-ai`),Go 保留业务、权限、工具执行和证据管理。个人主仓库为 [Sycun/CyberStrikeAI](https://github.com/Sycun/CyberStrikeAI)。
维护时优先使用当前锁定版本的 Pi SDK 公共接口。只有需要项目权限、业务记录或兼容行为时,才在宿主或 Worker 增加逻辑。
## 构建与使用
需要 Go(版本见 go.mod)和 Node.js >=22.19。
```sh
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```
`run.sh` 和服务自更新的构建步骤都会准备 Pi。构建使用锁文件和 `npm ci --ignore-scripts`;发布到 `runtime/pi/.builds/<源码指纹>/` 后才会被选用。正在运行的 Worker 使用原来的依赖目录;源码回滚时选择对应旧指纹的包。缓存属于构建产物,不提交到 Git。部署时需保留运行时源码和已构建的匹配包,或在目标机器重新构建;只复制 Go 二进制不足以运行 Pi。
```yaml
agent_runtime:
engine: pi
node_path: node
worker_path: ""
session_dir: data/pi-sessions
```
`worker_path` 是管理员的显式覆盖,适合开发或独立打包。留空使用源码指纹校验后的构建包。
源码安装拉取 Worker 修复后,请在该安装目录执行 `bash scripts/build-pi-runtime.sh` 再重启服务。如果设置了 `agent_runtime.worker_path`,请确认它指向新构建。保留原有会话文件:Worker 会在发送 OpenAI 兼容请求时整理被插话打断的工具批次。
模型请求使用 HTTP/1.1,遵循服务进程环境里的 `HTTP_PROXY`、`HTTPS_PROXY` 和 `NO_PROXY`。重定向只允许在原站点内跳转,避免模型凭据外传。
非 OpenAI 官方渠道的 Chat Completions 请求使用 `system` 发送系统指令,避免启用思考后被 Pi 自动改成部分兼容接口不支持的 `developer` 角色。思考参数保持原有配置;主模型、备用模型及后台生成使用同一兼容设置。OpenAI 官方渠道和 Responses/Anthropic 原生协议保留 SDK 的角色处理。
新服务会在接受请求前补建缺失的匹配 Worker 并检查启动握手,因此首次从 Eino 升级时,即使旧更新器只编译 Go,也能准备运行组件。补建需要 Node.js >=22.19、npm 和锁定的 npm 依赖下载渠道;失败会阻止启动并提示修复方法。已有匹配构建包时不再安装依赖。
## 执行边界
- 聊天、机器人、批量任务、工作流 Agent 节点通过统一调度入口进入 Pi。正式单代理路由为 `/api/agent`、模式值为 `single`;旧路由与模式只做输入兼容,执行始终使用 Pi。
- Go 管理每次调用的 Worker,转发流式事件和工具回调;补充指令进入 Pi 原生队列,取消由 Pi 和 Go 分别停止模型请求和宿主工具。同一进程中的相同会话存储串行访问,不同会话独立运行。
- Worker 使用显式模型、内存凭据和资源加载器,不自动发现个人 Pi 配置、全局插件或默认文件/Shell 工具。
- 工具较多时使用 Pi 原生 tool_search 按需加载,减少模型一次接收的工具定义。TaskCreate/Update/Get/List 和 write_todos 继续写入现有对话任务板。
- MCP、文件和 Shell 工具回到 Go,经角色过滤、HITL 和现有执行监控处理。子代理工具集合受主代理集合约束。
- Deep 使用任务委派;Supervisor 提供专家委派和 exit;Plan-Execute 使用计划记录与执行子代理。最终文本仍需通过既有证据验收。
- 上下文窗口和输出上限沿用渠道设置,包括 local profile;输入预算用于 Pi 压缩阈值。压缩后的模型上下文和完整会话记录分别保留。
## 数据与兼容
- 旧配置中的 `agent_runtime.purge` 在加载时忽略,在保存系统设置时移除。
- Pi 的 `SessionManager` 直接读写模型会话及压缩记录。新会话使用固定的 `session.jsonl`;已有会话沿用 `current-session` 指向的原文件,已有证据路径仍可使用。回滚到旧 Worker 时,新格式会话的上下文会从宿主传入的历史重建,原有 Pi 压缩记录不会加载。
- SQLite 保存业务状态、工具记录和交付证据。删除轮次时清除该对话所有模式及子代理的 Pi 会话,并递增数据库会话版本;后续请求从剩余消息重建上下文,旧 Worker 迟到写回的文件不会被恢复。运行中的任务须先停止再删轮次。
- 会话目录变更会在数据库保留历次目录,重启后删除对话或轮次仍会清理新旧目录;清理失败不会报告删除成功。
- 每次实际调用都有独立的运行期传输 ID;模型复用自身的 tool-call ID 不会吞掉新调用。同一个传输 ID 重发时复用已完成结果;不同参数复用同一个传输 ID 会被拒绝。
- 进程中断后,未提交结果的调用标记为结果不确定。系统不把它自动当成成功,也不直接重放它;继续前须核对执行记录。这不是跨所有外部系统的“恰好一次”保证。
- Eino 执行内核、模型适配、桥接和依赖已全部删除。`engine` 只接受 `pi`;旧 `eino_skills`/`eino_middleware` 配置可迁移读取,保存使用 `skills`/`runtime`,旧 callbacks 设置删除。
- Workflow 已使用原生 DAG 和 JSON 检查点。旧 Eino Workflow 二进制检查点不能由新版直接恢复;升级前应完成旧工作流,或导出材料后建立新的 Pi 任务。新检查点记录图指纹和执行中的节点,拒绝用已修改的图或结果不确定的节点自动续跑。
- 知识库使用自身 Document、切分、Embedding HTTP、向量检索、查询扩展和重排流程。向量与表结构保持兼容,新索引准备成功后在事务中替换旧行。
- 本地测试和源码集成不等于真实模型、真实任务的长时验收。当前尚无拒答率、发现率或成本改进的实测结论。
## 回归
```sh
cd runtime/pi
npm ci --ignore-scripts
npm run build
npm test
cd ../..
go test -race ./internal/agentruntime ./internal/multiagent ./internal/workflow ./internal/knowledge
go test ./...
npm run --prefix web/frontend build
```
SDK 集成测试使用本地模拟模型和无副作用的工具夹具,覆盖 OpenAI/Claude 动作建议、审批编辑、子代理工具边界、流式输出、取消、进程中断及备用模型切换。
2026-11-11 已用现有默认模型完成一次隔离回声工具闭环:模型调用 echo,Go 执行后返回 PONG,Pi 正常结束。该验证只使用合成消息和回声工具,未执行安全测试或更改生产服务;不代表长任务、全部模型渠道或效果指标已验收。
新安装示例的 update.repo 指向 Sycun/CyberStrikeAI;现有安装需单独核对更新来源。本次源码迁移不修改运行中的生产配置。

View File

@ -98,7 +98,7 @@ Burp 插件目录包含 Java 源码和构建脚本。典型能力:
- 先 `POST /api/auth/login`,再 `GET /api/auth/validate` 确认会话。
- 保存 `expires_at`,过期后重新登录(无 silent refresh)。
- 优先调用 `/api/agent/stream` 或 `/api/multi-agent/stream`(SSE)。
- 优先调用 `/api/eino-agent/stream` 或 `/api/multi-agent/stream`(SSE)。
- 大文件通过 `/api/chat-uploads` 上传,再在消息中引用。
- 查询结果或漏洞可写入 `/api/vulnerabilities`。
- 项目信息可写入 `/api/projects/:id/facts`。
@ -213,4 +213,4 @@ schema 越具体,HITL 越容易判断风险,Agent 也越不容易发散。
- 捕获:`devtools.js`、`background/service-worker.js`
- OpenAPI:`internal/handler/openapi.go`
- 外部 MCP:`internal/handler/external_mcp.go`
- Web 端认证参考:`web/frontend/src/lib/auth.jsx`
- Web 端认证参考:`web/static/js/auth.js`

View File

@ -8,7 +8,7 @@
- `README.md` 和 `README_CN.md` 的功能说明是否更新。
- `docs/` 是否补充新功能文档。
- `config.example.yaml` 示例是否包含新增配置。
- `config.yaml` 示例是否包含新增配置。
- OpenAPI 是否包含新增接口。
- 中英文 i18n 是否同步。
- 高风险功能是否有安全说明。
@ -25,7 +25,6 @@ go test ./internal/...
```bash
go test ./cmd/...
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```
@ -40,7 +39,6 @@ go build -o cyberstrike-ai ./cmd/server
## 构建
```bash
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```
@ -49,7 +47,7 @@ go build -o cyberstrike-ai ./cmd/server
- `cyberstrike-ai`
- `web/templates/`
- `web/static/`
- `config.example.yaml` 示例。
- `config.yaml` 示例。
- `tools/`
- `roles/`
- `skills/`
@ -159,7 +157,6 @@ SQLite 迁移要考虑:
```bash
go test ./internal/...
go test ./cmd/...
bash scripts/build-pi-runtime.sh
go build -o cyberstrike-ai ./cmd/server
```

View File

@ -603,4 +603,4 @@ curl -X POST "http://localhost:8080/api/robot/test" \
- 各平台均**仅处理文本消息**;其他类型(如图片、语音)会提示暂不支持或忽略。
- 个人微信仅支持**私聊**,不支持群聊 @ 机器人。
- 会话与 Web 端共用同一套数据:`user_binding` 下归属于绑定用户;`service_account` 下归属于服务账号,并由白名单发送者共享。
- 机器人执行与 **Pi 单/多代理** 相同逻辑(`ProcessMessageForRobot`,含进度回调与过程详情入库),仅不向客户端推送 SSE,最后一次性回复个人微信/钉钉/飞书/企业微信。默认 `robot_default_agent_mode: single`。
- 机器人执行与 **Eino 单/多代理** 相同逻辑(`ProcessMessageForRobot`,含进度回调与过程详情入库),仅不向客户端推送 SSE,最后一次性回复个人微信/钉钉/飞书/企业微信。默认 `robot_default_agent_mode: eino_single`。

View File

@ -32,7 +32,7 @@ Web 登录凭据由 RBAC 用户管理(默认内置 `admin` 账号)。建议
- 内置安全执行工具。
- `tools/` 下的 YAML 命令工具。
- Pi Skills 文件系统工具,如 `read_file`、`write_file`、`edit_file`、`execute`。
- Eino Skills 文件系统工具,如 `read_file`、`write_file`、`edit_file`、`execute`。
- 外部 MCP 暴露的工具。
- C2 和 WebShell 相关 MCP 工具。

View File

@ -18,7 +18,7 @@ skills/
SKILL.md
ssrf-testing/
SKILL.md
cyberstrike-pi-demo/
cyberstrike-eino-demo/
SKILL.md
REFERENCE.md
assets/
@ -45,11 +45,11 @@ description: SSRF 漏洞识别、验证、绕过和修复建议流程
## 渐进式披露
Pi Skills 支持按需加载。配置:
Eino Skills 支持按需加载。配置:
```yaml
multi_agent:
skills:
eino_skills:
disable: false
filesystem_tools: true
skill_tool_name: skill
@ -111,7 +111,7 @@ Skill 没被使用:
- `description` 过窄或过模糊。
- 任务没有触发关键词。
- `multi_agent.skills.disable: true`。
- `multi_agent.eino_skills.disable: true`。
- Skill 文件 front matter 格式错误。
Skill 读取太多:
@ -176,5 +176,5 @@ Skill 的核心价值不是“让 Agent 知道一个概念”,而是让 Agent
- Skill 包校验:`internal/skillpackage/validate.go`
- Skill 服务:`internal/skillpackage/service.go`
- Pi Skills 接入:`internal/multiagent/pi_local_tools.go`
- Eino Skills 接入:`internal/multiagent/eino_skills.go`
- Skills Handler:`internal/handler/skills.go`

View File

@ -1,23 +0,0 @@
# 批量任务管理
2026-11-14,任务管理恢复 v1.8.0 的批量队列逻辑及界面,撤回后续目标任务和统一列表改造。旧深度测评实现保持移除,上游 PR #383 保持关闭;新建的独立[深度测评](deep-assessments.md)栏目使用自己的接口与持久调度,批量队列行为保持不变。
## 使用方式
1. 打开「任务管理 → 新建任务」,每行填写一项任务,可设置标题、项目、角色、代理模式、工具审批和并发数。
2. 选择手动执行或 Cron 定时执行;是否立即执行由创建窗口中的选项决定。
3. 队列列表支持状态筛选、关键字搜索和分页。默认每页 10 个队列,可切换为 20、50 或 100。
4. 点击队列打开详情窗口,查看子任务状态、结果和对话;按队列状态提供开始、暂停、继续、重新运行、添加及编辑子任务等操作。
这里执行的是用户提供的任务清单,不再提供独立的目标规划、验收、预算或补充方向控制器。
## 数据与兼容
- 保留原有批量任务、定时配置、子任务结果和执行会话;继续使用 `/api/batch-tasks` 接口。
- 撤回 `/api/tasks` 统一列表及 `/api/long-tasks` 接口、相关权限资源和运行引擎。
- 回退不删除已存在的目标任务或深度测评历史表,也不把它们转成批量队列,不继续执行其中的任务。需要读取这部分历史时,可使用对应历史版本和数据库备份。
- 本次只修改开发版源码并同步个人仓库;运行环境需单独更新,源码回退不等于已经部署。
## 验证边界
使用隔离数据检查原版页面的创建、筛选、分页和详情操作,并运行现有 Go 与前端回归。不会调用真实模型或启动真实目标测试。

View File

@ -65,7 +65,7 @@ go build -o cyberstrike-ai ./cmd/server
重点验证:
- 登录。
- `/api/agent/stream`。
- `/api/eino-agent/stream`。
- `/api/config`。
- `/api/config/tools`。
- `/api/knowledge/search`。
@ -108,15 +108,6 @@ go build -o cyberstrike-ai ./cmd/server
## 前端冒烟
前端是 React 19 + Semi Design 单页应用(`web/frontend`)。构建与产物校验:
```sh
npm ci --prefix web/frontend
npm run --prefix web/frontend build
git status --porcelain web/static/app # 应为空,产物需随源码提交
go test ./internal/app -run TestSPA -count=1
```
修改前端后至少验证:
- 登录和退出。
@ -124,9 +115,8 @@ go test ./internal/app -run TestSPA -count=1
- 新建对话和流式回复。
- 设置页面保存。
- 相关业务页面增删改查。
- 中英文切换与暗色主题。
- 逐个访问 `#/<页面 id>`(清单见 `web/frontend/src/lib/nav.js`),浏览器控制台无 error、无页面异常。
- 深链接可直接打开:`#/chat?conversation=…`、`#/vulnerabilities?id=…`、`#/projects?id=…`、`#/settings?section=…`。
- 中英文切换。
- 浏览器控制台无明显错误。
## 高风险模块测试
@ -159,7 +149,7 @@ C2、WebShell、终端、批量任务只能在授权测试环境验证。测试
- `internal/multiagent/`:测流式、工具调用、摘要、重试、HITL。
- `internal/security/`:测认证、Shell、超时、无输出。
- `internal/database/`:测旧数据兼容。
- `web/frontend/src/pages/chat/`:测对话、过程详情、攻击链、分组。
- `web/static/js/chat.js`:测对话、过程详情、攻击链、分组。
## 测试数据管理

View File

@ -1,27 +1,70 @@
# Pi Token 用量监控
# Token 用量监控:调研与实现
模型用量来自 Pi 返回的 usage,Go 在模型轮次结束后汇总,通过 `agent_usage_summary` 写入现有统计和时间线。辅助 HTTP 调用与供应商账单可能有不同覆盖范围,因此本地统计不等于账户账单。
[English](../en-US/token-usage-monitoring.md)
## 口径
调研时间:2026-10-11。
- 输入总量由 Pi 的 input、cacheRead、cacheWrite 相加;输出使用 output。
- 总量为输入与输出之和;缓存读取和缓存写入已经包含在输入中,不能重复叠加。
- 供应商单独报告的推理 Token 已包含在输出中,面板单列展示。
- 模型调用次数按已观察到的轮次统计,重试会产生新的轮次。
- 未报告的细分不能推断为没有发生。推理 Token 等没有独立字段时,不根据文本长度伪造账单计数。
## 调研结论
## 查看
| 参考 | 官方能力 | 本项目采用的设计 |
| --- | --- | --- |
| [ZCode 使用统计](https://zcode.z.ai/cn/docs/usage-stats) | 本地会话统计与远端编程套餐额度分别展示;支持时间范围、日趋势和模型占比 | 首页增加可展开的本地用量面板,提供 7/30/90 天、日趋势、模型占比与明细 |
| [DeepSeek 上下文缓存](https://api-docs.deepseek.com/guides/kv_cache/) | 响应 usage 的 `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens` 区分输入缓存命中和未命中 | 将命中字段补入 OpenAI 标准缓存读取字段;不把未命中错误映射为缓存写入 |
| [Eino v0.9.21](https://github.com/cloudwego/eino/releases/tag/v0.9.21)、[schema PR #1309](https://github.com/cloudwego/eino/pull/1309) | 稳定版新增 `PromptTokenDetails.CacheWriteTokens`,原有缓存读取、输入、输出、推理字段继续保留 | 使用稳定版的标准字段贯穿流式归并、运行汇总、数据库和 UI |
| [Eino-ext PR #1015](https://github.com/cloudwego/eino-ext/pull/1015) | 模型适配器传递缓存写入计数 | 升级 agenticclaude 0.1.7、agenticopenai 0.2.4 与对应 OpenAI ACL,而非仅升级框架 |
| [Eino 回调与 Trace](https://www.cloudwego.io/docs/eino/quick_start/chapter_06_callback_and_trace/) | 组件回调可收集模型生命周期、用量与耗时 | 保留现有运行事件采集;未来要覆盖所有内部调用,应另外设计统一模型调用账本 |
从首页 Token 卡片进入「系统设置 → Token 用量」,可按周期、项目查看汇总、模型统计和最近记录。在该页搜索并选择会话即可查看单会话用量。接口为 `GET /api/usage/tokens` 与 `GET /api/conversations/:id/token-usage`。
版本已通过 Go module 解析和本地源码确认;未采用 0.10 alpha。DeepSeek 原始字段当前不会自动进入 Eino 的标准缓存读取计数,因此在项目现有兼容 HTTP 层补齐,覆盖普通 JSON 和 SSE 流式响应。已有标准 `cached_tokens` 优先,未知字段使用 RawMessage 保存,避免浮点转换损失数字精度。
已有模型用量表保持兼容。旧时间线用量事件可作为历史记录补齐;新记录仅由原生 Pi 事件生成。原生流式消息只传输增量,完整消息在结束时提交,避免重复累计与逐块重复发送整份内容。
## 统计口径
实现:`internal/multiagent/pi_runner.go`、`internal/database/model_token_usage.go`、前端用量页面。基础模型 usage 语义见 [Pi AI](https://github.com/earendil-works/pi/tree/v1.7.0/packages/ai)。
- `promptTokens`:模型返回的全部输入。
- `completionTokens`:全部输出,包括供应商计入其中的推理。
- `totalTokens`:使用供应商的总量;缺省时由输入加输出补齐。
- `cachedTokens`:输入中的缓存读取部分。
- `cacheWriteTokens`:输入中的缓存写入部分。
- `reasoningTokens`:输出中的推理部分。
- 缓存读取、写入、推理都是细分,不能再加到总量。缓存读取占输入的比例为 `cachedTokens / promptTokens`;没有输入时显示破折号。
- 一个流式模型输出可能多次返回累计计数,沿用按字段取最大值的归并方式,整条输出结束后只加入一次运行汇总。部分输出发生错误时,仍可保留已返回用量。
## DeepSeek
DeepSeek 的未命中输入不等于 Claude 的缓存写入。不能根据文本长度推导账单级计数,也不能根据缺失字段断言供应商未使用缓存。旧记录的新增字段默认为 0,表示未记录该细分。
在 AI 通道的推理设置中,可用 `off` 处理简单问答和格式转换,或用 `auto` 配合 `low` 保留低强度推理。官方接口未指定强度时默认使用 `high`,`medium` 也映射到 `high`。通道的「单次输出上限」通过 `max_tokens` 发送,推理和正文共用额度。对照面板里的输出、推理 Token 和缓存命中率,可比较相同任务在不同强度下的用量。[DeepSeek 推理模式](https://api-docs.deepseek.com/guides/thinking_mode/) · [Chat Completions](https://api-docs.deepseek.com/api/create-chat-completion/)
## 功能入口与数据流
官方接口自动缓存可复用的请求前缀。Pi 按名称固定 MCP 工具定义的顺序,以减少相同工具目录在请求之间的前缀变化。缓存命中以供应商返回的用量为准。[DeepSeek 上下文缓存](https://api-docs.deepseek.com/guides/kv_cache/)
点击首页「Token 用量」卡片进入「系统设置 → Token 用量」,也可直接从设置二级菜单打开。首页卡片显示近 7 天总用量,副标仅显示缓存命中率(缓存读取 Token / 输入 Token),调用次数和每日用量保留在详情页。支持当前项目范围、7/30/90 天切换、八项指标、最多 20 项运行模型排行、每日趋势与完整日明细、最多 20 项最近运行。详情页独立加载,支持手动刷新与请求取消,切换周期不会刷新整个仪表盘;刷新页面可保持该设置分区。
后台默认根据官方 DeepSeek 地址、DeepSeek 线路或模型名自动启用按需工具发现、JSON 回包精简与可回读的大结果预览。用户配置模型后即可使用。验证节省效果时,对照完整任务的输入、输出、缓存命中和调用次数,并检查任务产物与证据完整性。具体阈值见[配置说明](configuration.md#deepseek-输入优化)。
详情页采用四项核心指标(总量、输入、输出、缓存读取占输入)与四项次级指标(调用、缓存读取、缓存写入、推理)的层级布局。趋势可切换总 Token、模型调用与缓存命中率,鼠标悬停或键盘聚焦柱形可查看日期与精确数字;切换图表指标不再请求 API。缓存环形图拆分缓存读取与其余输入,不把缓存或推理再次叠加到总量。模型明细展示占比条,每日数字明细默认折叠,最近运行区分完整与部分记录。统计口径可展开查看。
每日图表沿用 API 返回的服务端日期,只补齐已返回日期之间无记录的空档,不根据浏览器时区猜测查询终点。小屏图表和宽表在自己的区域内横向滚动。没有记录和无法获取统计分别展示空状态与不可用状态。
### UI 调研依据(2026-10-12)
| 参考 | 采用的设计 |
| --- | --- |
| [DeepSeek Context Caching](https://api-docs.deepseek.com/guides/kv_cache/) | 使用其明确的缓存命中/未命中输入定义,设计缓存构成视图;比例按 Token 而非请求次数计算 |
| [LiteLLM Usage](https://docs.litellm.ai/docs/proxy/ui/chat_ui) | 周期选择、核心统计与使用日志分层;本项目保留已有数据范围,不新增无法准确计量的费用或成功率 |
| [Langfuse Custom Dashboards](https://langfuse.com/docs/metrics/features/custom-dashboards) | 将汇总、时间趋势、模型分布拆为独立可读区域,并让趋势指标可切换 |
DeepSeek 和 GLM 控制台的完整页面本轮未能公开读取,因此本轮视觉设计以能核实的开源面板为依据。没有声称复刻它们当前登录后的界面。项目也没有新增供应商账单、预算或节省金额推算。
运行事件 → 流式/非流式用量累加 → `eino_usage_summary` → `process_details` 与 `model_token_usage` → 现有 `/api/usage/tokens`、对话用量接口 → 首页与聊天摘要。
新增 `model_token_usage.cache_write_tokens INTEGER NOT NULL DEFAULT 0`。启动时现有声明式 SQLite schema reconciliation 自动补列;旧数据库无需手工执行迁移。现有事件 ID 幂等写入、外键删除关联和历史回填继续生效。日分组按服务本地时区显示,与首页「今日」边界一致。
面板采用文本节点渲染供应商模型名称,表格在手机上局部横向滚动,提供中文、英文、俄文标签。聊天轮次 tooltip、主对话与 WebShell 时间线均增加缓存写入字段。
## 当前边界与后续方向
统计基于已记录的 Agent 输出事件,包括已有采集链路中的子 Agent,**不是全站 API 请求账本**。摘要压缩、检索 embedding、隐藏的模型调用、没有返回 usage 的请求不能由当前链路完整覆盖;因请求取消丢失最终 usage 的消耗也无法还原。
模型排行按运行配置的模型名称归类,发生 failover 的运行可能混合多个模型,不能据此核算逐模型账单。近期列表每项是运行汇总,不是单次 HTTP 请求;模型调用次数也仅统计返回了非空 usage 的输出。
本次不展示费用或套餐剩余额度。自定义中转渠道和订阅套餐的价格、计费方式不同,token 乘固定单价无法可靠代表费用。下一步如需要完整成本管理,应先建设按请求记录的账本:调用来源、真实供应商与模型、成功/错误/取消、耗时、TTFT、usage 是否返回、价格版本和币种;统一覆盖主/子 Agent、压缩、重试、embedding,单独对接供应商额度接口。
## 验证
- `go test ./...`:全仓通过。
- `node --test web/static/js/*.test.cjs`:295 项通过。
- 针对缓存写入的保存/分组/近期记录、旧 schema 补列、用户可见范围、流式去重和总量回退添加回归测试。
- DeepSeek 普通 JSON/SSE 的缓存字段转换、标准字段优先、错误/终止块保持、超大数值精度验证通过。
- 浏览器使用合成数据验证桌面、390px 手机、深色模式、模型名称转义、空数据与接口不可用状态;没有读取真实运行数据库,也没有调用付费模型。

View File

@ -15,7 +15,7 @@
## 执行模型
普通工具调用仍然对 Pi/Agent 表现为一次标准 tool call,但底层执行分为两段:
普通工具调用仍然对 Eino/Agent 表现为一次标准 tool call,但底层执行分为两段:
```text
Agent 调用工具
@ -67,7 +67,7 @@ partial output 是“已产生输出的有界预览”,不等同于最终 `res
4. 仍未完成时可继续等待,或调用 cancel_tool_execution
```
`tool_wait_timeout_seconds` 适用于内部 MCP、外部 MCP,以及 Pi filesystem 的流式 `execute`。Pi 的 `ls/read_file/write_file/edit_file/glob/grep` 等非流式 filesystem 工具会写入 execution 监控记录,但不作为后台 worker 做软等待续跑。
`tool_wait_timeout_seconds` 适用于内部 MCP、外部 MCP,以及 Eino filesystem 的流式 `execute`。Eino 的 `ls/read_file/write_file/edit_file/glob/grep` 等非流式 filesystem 工具会写入 execution 监控记录,但不作为后台 worker 做软等待续跑。
## 取消和会话清理
@ -98,11 +98,11 @@ agent:
## 输出兜底
系统使用 `multi_agent.runtime.reduction_max_length_for_trunc` 作为统一工具结果上限。当前示例配置为 50000 bytes。
系统使用 `multi_agent.eino_middleware.reduction_max_length_for_trunc` 作为统一工具结果上限。当前示例配置为 50000 bytes。
```yaml
multi_agent:
runtime:
eino_middleware:
reduction_enable: true
reduction_max_length_for_trunc: 50000
```
@ -114,7 +114,7 @@ multi_agent:
| Agent 实际拿到的工具结果 | 使用兜底后的 canonical result |
| DB/监控存储 | 保存同一份 canonical result |
| `get_tool_execution` / `wait_tool_execution` | 读取同一份 canonical result |
| Pi `execute` / filesystem 监控记录 | 完成记录前统一兜底 |
| Eino `execute` / filesystem 监控记录 | 完成记录前统一兜底 |
| 非流式 `exec` stdout/stderr | 源头 bounded buffer |
| 流式 `exec` stdout/stderr | 推送给前端的累计输出也受上限控制 |
| PTY 执行路径 | 同样受上限控制 |
@ -176,7 +176,7 @@ agent:
shell_no_output_timeout_seconds: 1200
multi_agent:
runtime:
eino_middleware:
reduction_enable: true
reduction_max_length_for_trunc: 50000
```
@ -226,13 +226,11 @@ PY
每轮任务有独立 `runId`,本地进程与异步 MCP worker 都通过 context 保留归属。取消 context、工具返回、SSE 断线不等于资源已回收。
- `exec ... &` 与 Pi 后台执行立即返回,但仍属于本轮任务;无任务归属的后台启动被拒绝。前台工具退出时清理遗留子进程,跨工具调用运行的任务应使用显式后台入口。
- `exec ... &` 与 Eino 后台执行立即返回,但仍属于本轮任务;无任务归属的后台启动被拒绝。前台工具退出时清理遗留子进程,跨工具调用运行的任务应使用显式后台入口。
- 完成、失败、超时收尾、用户停止、服务正常关闭都会封闭启动入口、取消 worker、终止进程并等待回收。“中断并继续”保留本轮归属。
- Unix 先等待进程组主动退出,再强制终止并验证。环境变量 `CS_CLEANUP_GRACE`、`CS_CLEANUP_KILL`、`CS_CLEANUP_GUARD` 分别控制主动退出、SIGKILL 后回收和隔离后端的等待时间,接受正的 Go duration(例如 `10s`),未配置或无效时各用 3 秒。普通清理失败保留 `cleanup_failed` 和进程组/worker ID,每 15 秒巡检重试。
- Unix 首先给进程组 3 秒退出宽限期,再强制终止并验证;内核隔离、守护进程退出与 worker 收尾各有有界等待。清理期间仍占用本轮任务;失败保留 `cleanup_failed`、进程组/worker ID,每 15 秒巡检重试。
- 工具 worker 的登记与任务关闭互斥;即使 MCP 使用 `WithoutCancel`,任务也会等待其退出。旧轮次的延迟回调无法接管新轮次的进程或提交新 worker。
Linux 上,直接子进程回收后,只剩僵尸进程的组视为已退出。使用进程组 watchdog 时,若清理超时且组内仍存活的成员均处于 D 态并已有待投递的 SIGKILL,等本地 worker 退出后,任务记为 `cleanup_unconfirmed`。服务日志记录 run ID 和 PGID,进程解除阻塞后由内核处理挂起的信号。cgroup 和 Windows Job Object 仍按后端自身的机制验证清理。
### 操作系统隔离和崩溃回收
| 平台 | 实现 | 崩溃回收与限制 |

View File

@ -1,11 +0,0 @@
# 漏洞报告下载
在漏洞管理列表中,点击每条漏洞右侧的下载图标,弹窗选择 **Markdown(.md)** 或 **Word(.docx)**。选择后下载该条漏洞,取消或按 Esc 不会下载。下载失败时保留弹窗,可重新选择。
Markdown 沿用现有内容、界面语言与文件名。Word 包含所选漏洞的基本信息、描述、前置条件、复现步骤、证据、影响、修复建议和复测记录;保留原始状态,待确认或误报不会改写为已确认漏洞。证据作为纯文本导出,不解析其中的 HTML 或 Markdown,也不自动嵌入截图。
此功能不配置自动生成任务,不修改数据库结构,也不保存额外的报告产物。服务器无需安装 Office、Python 或 Pandoc;查看 Word 文件的软件需要中文字体。
Word 下载使用 `GET /api/vulnerabilities/:id/download?format=docx`,要求 `vulnerability:read` 及对应漏洞的资源访问范围,无需额外的文件管理权限。接口也支持 `format=md`,格式参数不合法返回 400,不存在的记录返回 404,越权请求返回 403。Word 正文限制为 8 MiB,超出时返回生成失败。
原有页面级 Markdown 批量导出保持不变。

View File

@ -248,7 +248,7 @@ jq({{outputs.scan}}, ".severity") == "high"
| 字段 | 说明 | 默认值 |
|------|------|--------|
| Agent 模式 | `single` / `deep` / `plan_execute` / `supervisor` | `single` |
| Agent 模式 | `eino_single` / `deep` / `plan_execute` / `supervisor` | `eino_single` |
| 输入来源 | 上游数据的模板表达式 | `{{previous.output}}` |
| 节点指令 | 本节点要完成的任务描述 | 空 |
| 输出变量名 | 写入 `outputs` 的键名 | `agent_result` |
@ -264,7 +264,7 @@ Agent 节点执行后:
- `previous.output` 更新为本节点响应文本
- 若配置了 **输出变量名**,同时写入 `outputs[输出变量名]`
- Agent 节点通过原生 DAG 调度 Pi 运行时;节点状态与检查点由 Go 保存
- Agent 子图在 Eino 中拆为 `prepare → execute → finalize`,便于 trace 与后续局部 checkpoint
### 5.3 工具(tool)
@ -310,7 +310,7 @@ Agent 节点执行后:
### 5.5 审批(hitl)
人工确认检查点。流程运行到该节点前会通过原生 Workflow 检查点暂停,等待 API 或监控面板审批后恢复。
人工确认检查点。流程运行到该节点前会通过 Eino interrupt/checkpoint 暂停,等待 API 或监控面板审批后恢复。
| 字段 | 说明 | 默认值 |
|------|------|--------|
@ -576,10 +576,10 @@ token 与成本是否存在取决于底层模型/Agent 事件是否上报 usage
| 模块 | 路径 |
|------|------|
| 执行引擎 | `internal/workflow/runner.go` |
| 原生 DAG / checkpoint / HITL | `internal/workflow/native_runtime.go` |
| Eino 编译 / checkpoint / HITL | `internal/workflow/eino_compile.go` |
| 图校验 | `internal/workflow/validation.go` |
| 表达式 / JSONPath / 汇聚 | `internal/workflow/expression.go`、`jsonpath.go`、`join.go` |
| dry-run / replay 数据 | `internal/workflow/dry_run.go`、`internal/handler/workflow_run.go` |
| 画布前端 | `web/frontend/src/pages/workflows/` |
| 画布前端 | `web/static/js/workflows.js` |
| 流程 API | `internal/handler/workflow.go` |
| 角色绑定 | `internal/config/config.go`(`workflow_id` 字段) |

89
go.mod
View File

@ -7,10 +7,19 @@ go 1.25.0
require (
github.com/bwmarrin/discordgo v0.29.0
github.com/bytedance/sonic v1.15.0
github.com/cloudwego/eino v0.9.21
github.com/cloudwego/eino-ext/adk/backend/local v0.2.6
github.com/cloudwego/eino-ext/components/document/loader/file v0.0.0-20260427010451-749e3706378b
github.com/cloudwego/eino-ext/components/document/transformer/splitter/markdown v0.0.0-20260427010451-749e3706378b
github.com/cloudwego/eino-ext/components/document/transformer/splitter/recursive v0.0.0-20260427010451-749e3706378b
github.com/cloudwego/eino-ext/components/embedding/openai v0.0.0-20260427010451-749e3706378b
github.com/cloudwego/eino-ext/components/model/agenticclaude v0.1.7
github.com/cloudwego/eino-ext/components/model/agenticopenai v0.2.4
github.com/cloudwego/eino-ext/components/model/openai v0.1.13
github.com/creack/pty v1.1.24
github.com/disintegration/imaging v1.6.2
github.com/eino-contrib/jsonschema v1.0.3
github.com/gin-gonic/gin v1.9.1
github.com/google/jsonschema-go v0.4.2
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/larksuite/oapi-sdk-go/v3 v3.4.22
@ -22,10 +31,14 @@ require (
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/slack-go/slack v0.27.0
github.com/tencent-connect/botgo v0.2.1
go.opentelemetry.io/otel v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.34.0
go.opentelemetry.io/otel/sdk v1.39.0
go.opentelemetry.io/otel/trace v1.39.0
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.50.0
golang.org/x/net v0.53.0
golang.org/x/sys v0.43.0
golang.org/x/term v0.42.0
golang.org/x/text v0.37.0
golang.org/x/time v0.14.0
@ -33,41 +46,107 @@ require (
)
require (
cloud.google.com/go/auth v0.7.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/anthropics/anthropic-sdk-go v1.56.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.27 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
github.com/aws/smithy-go v1.20.3 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
github.com/buger/jsonparser v1.1.2 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.18-0.20260924031408-10df7cac3f6d // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/evanphx/json-patch v0.5.2 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-resty/resty/v2 v2.6.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/goph/emperror v0.17.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
github.com/invopop/jsonschema v0.14.0 // indirect
github.com/jolestar/go-commons-pool/v2 v2.1.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/klippa-app/go-pdfium v1.19.3 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/meguminnnnnnnnn/go-openai v0.1.6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nikolalohinski/gonja v1.5.3 // indirect
github.com/openai/openai-go/v3 v3.44.0 // indirect
github.com/pb33f/ordered-map/v2 v2.3.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/segmentio/encoding v0.5.4 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect
github.com/standard-webhooks/standard-webhooks/libraries v0.0.1 // indirect
github.com/tetratelabs/wazero v1.11.0 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/yargevad/filepathx v1.0.0 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.2 // indirect
golang.org/x/arch v0.15.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
google.golang.org/api v0.189.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/protobuf v1.36.10 // indirect
)

314
go.sum
View File

@ -1,16 +1,115 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE=
cloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs=
cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=
cloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0 h1:g0EZJwz7xkXQiZAI5xi9f3WWFYBlX1CPTrR+NDToRkQ=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.0/go.mod h1:XCW7KnZet0Opnr7HccfUw1PLc4CjHqpcaxW8DHklNkQ=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o=
github.com/anthropics/anthropic-sdk-go v1.56.0 h1:idVU14wOZ06D0GBNEvuhn927xXmBVEquo0469iDwLsc=
github.com/anthropics/anthropic-sdk-go v1.56.0/go.mod h1:3EfIfmFqxH6rbiLcIP4tPFyXL/IHakx2wDG4OU+TIEI=
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 h1:tW1/Rkad38LA15X4UQtjXZXNKsCgkshC3EbmcUmghTg=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3/go.mod h1:UbnqO+zjqk3uIt9yCACHJ9IVNhyhOCnYk8yA19SAWrM=
github.com/aws/aws-sdk-go-v2/config v1.27.27 h1:HdqgGt1OAP0HkEDDShEl0oSYa9ZZBSOmKpdpsDMdO90=
github.com/aws/aws-sdk-go-v2/config v1.27.27/go.mod h1:MVYamCg76dFNINkZFu4n4RjDixhVr51HLj4ErWzrVwg=
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVOpGPgDSi0I9iAP+UI=
github.com/aws/aws-sdk-go-v2/credentials v1.17.27/go.mod h1:gniiwbGahQByxan6YjQUMcW4Aov6bLC3m+evgcoN4r4=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 h1:KreluoV8FZDEtI6Co2xuNk/UqI9iwMrOx/87PBNIKqw=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11/go.mod h1:SeSUYBLsMYFoRvHE0Tjvn7kbxaUhl75CJi1sbfhMxkU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 h1:HGErhhrxZlQ044RiM+WdoZxp0p+EGM62y3L6pwA4olE=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17/go.mod h1:RkZEx4l0EHYDJpWppMJ3nD9wZJAa8/0lq9aVC+r2UII=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 h1:BXx0ZIxvrJdSgSvKTZ+yRBeSqqgPM89VPlulEcl37tM=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4/go.mod h1:ooyCOXjvJEsUw7x+ZDHeISPMhtwI3ZCB7ggFMcFfWLU=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrAaCYQR72t0wrSBfoesUE=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ=
github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=
github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bugsnag/bugsnag-go v1.4.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/bwmarrin/discordgo v0.29.0 h1:FmWeXFaKUwrcL3Cx65c20bTRW+vOb6k8AnaP+EgjDno=
github.com/bwmarrin/discordgo v0.29.0/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/mockey v1.4.6 h1:pPkAFB6yiaaybvgp7DP1Rj4Ztiew3nsaMizoNkzsvNA=
github.com/bytedance/mockey v1.4.6/go.mod h1:1BPHF9sol5R1ud/+0VEHGQq/+i2lN+GTsr3O2Q9IENY=
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/certifi/gocertifi v0.0.0-20190105021004-abcd57078448/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/cloudwego/eino v0.9.14 h1:suNVibjtkPMiW7csFBdBqN3FRG0nRlCqoGKE7t0UDwY=
github.com/cloudwego/eino v0.9.14/go.mod h1:OBD1mrkfkt/pJa4rkg1P0VnaMeOVl7l8IAdEqY//3IQ=
github.com/cloudwego/eino v0.9.21 h1:kBAyAjsnPq5NDWjt0VdmP9HY/XVUHs05LoeqybudPRQ=
github.com/cloudwego/eino v0.9.21/go.mod h1:OBD1mrkfkt/pJa4rkg1P0VnaMeOVl7l8IAdEqY//3IQ=
github.com/cloudwego/eino-ext/adk/backend/local v0.2.6 h1:pxKAWcveIBWrbz28H2bDAMyJZnhysa9bh2Kh5s7iH7s=
github.com/cloudwego/eino-ext/adk/backend/local v0.2.6/go.mod h1:uJlpYclMA2ScgUlHWHu2om+DDguV2Lzc+TNulWBXqfo=
github.com/cloudwego/eino-ext/components/document/loader/file v0.0.0-20260427010451-749e3706378b h1:GIOC/VnXuSQx79mnQ3HgMvECjtyqvpJipmSUTFFfVsc=
github.com/cloudwego/eino-ext/components/document/loader/file v0.0.0-20260427010451-749e3706378b/go.mod h1:HnxTQxmhuev6zaBl92EHUy/vEDWCuoE/OE4cTiF5JCg=
github.com/cloudwego/eino-ext/components/document/transformer/splitter/markdown v0.0.0-20260427010451-749e3706378b h1:3owjV4nv+XRplavTeqFlCeAV4v7EHR2tIXDqLEmPc38=
github.com/cloudwego/eino-ext/components/document/transformer/splitter/markdown v0.0.0-20260427010451-749e3706378b/go.mod h1:KVOVct4e2BQ7epDONW2QE1qU5+ccoh91FzJTs9vIJj0=
github.com/cloudwego/eino-ext/components/document/transformer/splitter/recursive v0.0.0-20260427010451-749e3706378b h1:j8sj/5QiooV3LWphFDsJvyD/csWwupz+UKXeG+nqiNg=
github.com/cloudwego/eino-ext/components/document/transformer/splitter/recursive v0.0.0-20260427010451-749e3706378b/go.mod h1:9R0RQrQSpg1JaNnRtw7+RfRAAv0HgdE348YnrlZ6coo=
github.com/cloudwego/eino-ext/components/embedding/openai v0.0.0-20260427010451-749e3706378b h1:pOqupZQyc46rw2Z0HeybtTmSMTwqfTrbRuGDuDsNf2A=
github.com/cloudwego/eino-ext/components/embedding/openai v0.0.0-20260427010451-749e3706378b/go.mod h1:zyPrZT2bO6LyRJgVksQowR18jVgyLSvqK93hnO53/Lc=
github.com/cloudwego/eino-ext/components/model/agenticclaude v0.1.3 h1:nfO9jUPhIKTHDPyL7rso6y7Mx8cAmrIgkeJC6KqTuXI=
github.com/cloudwego/eino-ext/components/model/agenticclaude v0.1.3/go.mod h1:/dX1P7HNC7D3/nYLDoXBvdKAFnGS4tBbtJ8NrkaXuUk=
github.com/cloudwego/eino-ext/components/model/agenticclaude v0.1.7 h1:oxvyuAdZLlKSWYrzXwXS63AokgC3TqSljrzCGNRi4JA=
github.com/cloudwego/eino-ext/components/model/agenticclaude v0.1.7/go.mod h1:LsIyLkRviQtfJsGYP6MX9PwqCX4jMtVxR4zR2A7ZB+g=
github.com/cloudwego/eino-ext/components/model/agenticopenai v0.2.1 h1:bIMyUxEZdBEofWbXQCozfGxXCsbyNjpZcRMfW+Kt5u0=
github.com/cloudwego/eino-ext/components/model/agenticopenai v0.2.1/go.mod h1:84jUcVAcmlGDRVX0ExABVJEfrIaplaAeRbjFYW9mzkI=
github.com/cloudwego/eino-ext/components/model/agenticopenai v0.2.4 h1:M5ODiB1UaYV0I/dL2dmgc/HfZ2WUBV0saM9Tkhk2IDg=
github.com/cloudwego/eino-ext/components/model/agenticopenai v0.2.4/go.mod h1:AfLNKxrTFFkJbCWSvOtqKK1ZXEp0hpe26CBQ8GSf5zo=
github.com/cloudwego/eino-ext/components/model/openai v0.1.13 h1:5XHRTiTD5bt9KQrMHcfvuWNklEC3tpm3XHejdozt9vM=
github.com/cloudwego/eino-ext/components/model/openai v0.1.13/go.mod h1:mgIoqYYOc0eECCqvLbEYpOJrQNTNxkwXzSJzFU+v5sQ=
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.18-0.20260527084435-846f52bd97c6 h1:ES/xufN5eqJ3h+9tw/tq6F8kkgnAxBAHVUB6nqKsIDU=
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.18-0.20260527084435-846f52bd97c6/go.mod h1:5Xj74dGrfHo1z7I07Fzp3SlTF7Bt4tss3A2FSt8SqQ4=
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.18-0.20260924031408-10df7cac3f6d h1:FaBHOMj/ZDBmtsI9UMoDMDu9CNZPbjJwK/O26JFuZ8k=
github.com/cloudwego/eino-ext/libs/acl/openai v0.1.18-0.20260924031408-10df7cac3f6d/go.mod h1:6yg0Rv7B3jZCQPc/C5s13PNnVewQdaRxOp2OMru7Yw4=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w=
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
@ -22,14 +121,43 @@ github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/eino-contrib/jsonschema v1.0.3 h1:2Kfsm1xlMV0ssY2nuxshS4AwbLFuqmPmzIjLVJ1Fsp0=
github.com/eino-contrib/jsonschema v1.0.3/go.mod h1:cpnX4SyKjWjGC7iN2EbhxaTdLqGjCi0e9DxpLYxddD4=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA=
github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=
github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4=
github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA=
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI=
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
@ -41,27 +169,46 @@ github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QX
github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
github.com/go-resty/resty/v2 v2.6.0 h1:joIR5PNLM2EFqqESUjCMGXrWmXNHEU9CEiK813oKYS4=
github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@ -70,20 +217,44 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg=
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
github.com/goph/emperror v0.17.2 h1:yLapQcmEsO0ipe9p5TaN22djm3OFV/TfM/fcYP0/J18=
github.com/goph/emperror v0.17.2/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/invopop/jsonschema v0.14.0 h1:MHQqLhvpNUZfw+hM3AZDYK7jxO8FZoQeQM77g8iyZjg=
github.com/invopop/jsonschema v0.14.0/go.mod h1:ygm6C2EaVNMBDPpaPlnOA2pFAxBnxGjFlMZABxm9n2I=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jolestar/go-commons-pool/v2 v2.1.2 h1:E+XGo58F23t7HtZiC/W6jzO2Ux2IccSH/yx4nD+J1CM=
github.com/jolestar/go-commons-pool/v2 v2.1.2/go.mod h1:r4NYccrkS5UqP1YQI1COyTZ9UjPJAAGTUxzcsK1kqhY=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klippa-app/go-pdfium v1.19.3 h1:3UVRNqA6F4XRwKXClYLwM8RMX+J5nmF5m/Kd4QA8dZQ=
github.com/klippa-app/go-pdfium v1.19.3/go.mod h1:9SpxpYVWG1EKkwc3+gFw3ykmaT30IohxxaL58l/97bs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
@ -93,14 +264,26 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/larksuite/oapi-sdk-go/v3 v3.4.22 h1:57daKuslQPX9X3hC2idc5bu8bl2krfsBGWGJ6b5FlD8=
github.com/larksuite/oapi-sdk-go/v3 v3.4.22/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI=
github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/meguminnnnnnnnn/go-openai v0.1.2 h1:iXombGGjqjBrmE9WaSidUhhi3YQhf42QTHvHLMkgvCA=
github.com/meguminnnnnnnnn/go-openai v0.1.2/go.mod h1:qs96ysDmxhE4BZoU45I43zcyfnaYxU3X+aRzLko/htY=
github.com/meguminnnnnnnnn/go-openai v0.1.6 h1:c74nk9F3+/agOd09eHeQt/Ayty4pw54X2Dj5JHdxcys=
github.com/meguminnnnnnnnn/go-openai v0.1.6/go.mod h1:qs96ysDmxhE4BZoU45I43zcyfnaYxU3X+aRzLko/htY=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/modelcontextprotocol/go-sdk v1.3.1 h1:TfqtNKOIWN4Z1oqmPAiWDC2Jq7K9OdJaooe0teoXASI=
github.com/modelcontextprotocol/go-sdk v1.3.1/go.mod h1:DgVX498dMD8UJlseK1S5i1T4tFz2fkBk4xogC3D15nw=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -108,41 +291,79 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/nikolalohinski/gonja v1.5.3 h1:GsA+EEaZDZPGJ8JtpeGN78jidhOlxeJROpqMT9fTj9c=
github.com/nikolalohinski/gonja v1.5.3/go.mod h1:RmjwxNiXAEqcq1HeK5SSMmqFJvKOfTfXhkJv6YBtPa4=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.28.3 h1:4JvMdwtFU0imd8fHx25OJXoDMRexnf8v5NHKYSTTji4=
github.com/onsi/ginkgo/v2 v2.28.3/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.40.0 h1:Vtol0e1MghCD2ZVIilPDIg44XSL9l2QAn8ZNaljWcJc=
github.com/onsi/gomega v1.40.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A=
github.com/openai/openai-go/v3 v3.35.0 h1:109x3epXMSE423KW2euR506GGFezcEt0s87MoWejpH0=
github.com/openai/openai-go/v3 v3.35.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo=
github.com/openai/openai-go/v3 v3.44.0 h1:kkGh+jb/sKfSh5P74Jk5mCRufaQ0q7oH+lq+pNlWjsk=
github.com/openai/openai-go/v3 v3.44.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo=
github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY=
github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkoukk/tiktoken-go v0.1.8 h1:85ENo+3FpWgAACBaEUVp+lctuTcYUO7BtmfhlN/QTRo=
github.com/pkoukk/tiktoken-go v0.1.8/go.mod h1:9NiV+i9mJKGj1rYOT+njbv+ZwA/zJxYdewGl6qVatpg=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rollbar/rollbar-go v1.0.2/go.mod h1:AcFs5f0I+c71bpHlXNNDbOWJiKwjFDtISeXco0L5PKQ=
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0=
github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/slack-go/slack v0.27.0 h1:VWOpUzOK6UAPCCQlFxl79jhv8a/b+GOSJMnWziDJ8B8=
github.com/slack-go/slack v0.27.0/go.mod h1:UEe+jmo9WLlwHB04qsOrTDvqM7Aa4rQL3O5wF3n0hx4=
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f h1:Z2cODYsUxQPofhpYRMQVwWz4yUVpHF+vPi+eUdruUYI=
github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f/go.mod h1:JqzWyvTuI2X4+9wOHmKSQCYxybB/8j6Ko43qVmXDuZg=
github.com/smarty/assertions v1.16.0 h1:EvHNkdRA4QHMrn75NZSoUQ/mAUXAYWfatfB01yTCzfY=
github.com/smarty/assertions v1.16.0/go.mod h1:duaaFdCS0K9dnoM50iyek/eYINOZ64gbh1Xlf6LG7AI=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/standard-webhooks/standard-webhooks/libraries v0.0.1 h1:uOfcYT+3QungH6tIGSVCR/Y3KJmgJiHcojJbMTPDZAI=
github.com/standard-webhooks/standard-webhooks/libraries v0.0.1/go.mod h1:L1MQhA6x4dn9r007T033lsaZMv9EmBAdXyU/+EF40fo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
@ -153,7 +374,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tencent-connect/botgo v0.2.1 h1:+BrTt9Zh+awL28GWC4g5Na3nQaGRWb0N5IctS8WqBCk=
github.com/tencent-connect/botgo v0.2.1/go.mod h1:oO1sG9ybhXNickvt+CVym5khwQ+uKhTR+IhTqEfOVsI=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
@ -161,25 +385,66 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/uouuou/dingtalk-stream-sdk-go v0.0.0-20250626025113-079132acc406 h1:b72HNsEnmTRn7vhWGOfbWHAkA5RbRCk0Pbc56V2WAuY=
github.com/uouuou/dingtalk-stream-sdk-go v0.0.0-20250626025113-079132acc406/go.mod h1:ln3IqPYYocZbYvl9TAOrG/cxGR9xcn4pnZRLdCTEGEU=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc=
github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA=
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 h1:OeNbIYk/2C15ckl7glBlOBp5+WlYsOElzTNmiPW/x60=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0/go.mod h1:7Bept48yIeqxP2OZ9/AqIpYS94h2or0aB4FypJTc8ZM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 h1:BEj3SPM81McUZHYjRS5pEgNgnmzGJ5tRpU5krWnV8Bs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0/go.mod h1:9cKLGBDzI/F3NoHLQGm4ZrYdIHsvGt6ej6hUowxY0J4=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.34.0 h1:jBpDk4HAUsrnVO1FsfCfCOTEc/MkInJmvfCHYLFiT80=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.34.0/go.mod h1:H9LUIM1daaeZaz91vZcfeM0fejXPmgCYE8ZhzqfJuiU=
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
go.yaml.in/yaml/v4 v4.0.0-rc.2 h1:/FrI8D64VSr4HtGIlUtlFMGsm7H7pWTbj6vOLVZcA6s=
go.yaml.in/yaml/v4 v4.0.0-rc.2/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@ -188,18 +453,31 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
@ -209,10 +487,12 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -220,6 +500,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -234,6 +516,7 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -260,6 +543,10 @@ golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
@ -272,12 +559,35 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI=
google.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=
google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
@ -289,10 +599,14 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 KiB

After

Width:  |  Height:  |  Size: 941 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 741 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 KiB

After

Width:  |  Height:  |  Size: 775 KiB

View File

@ -5,6 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"os"
"path/filepath"
"strings"
@ -15,12 +17,14 @@ import (
"cyberstrike-ai/internal/config"
"cyberstrike-ai/internal/mcp"
"cyberstrike-ai/internal/mcp/builtin"
"cyberstrike-ai/internal/openai"
"go.uber.org/zap"
)
// Agent AI代理
type Agent struct {
openAIClient *openai.Client
config *config.OpenAIConfig
agentConfig *config.AgentConfig
mcpServer *mcp.Server
@ -63,7 +67,30 @@ func NewAgent(cfg *config.OpenAIConfig, agentCfg *config.AgentConfig, mcpServer
maxIterations = 30
}
// 配置HTTP Transport,优化连接管理和超时设置
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: 300 * time.Second,
KeepAlive: 300 * time.Second,
}).DialContext,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 10,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 30 * time.Second,
ResponseHeaderTimeout: 60 * time.Minute, // 响应头超时:增加到15分钟,应对大响应
DisableKeepAlives: false, // 启用连接复用
}
// 增加超时时间到30分钟,以支持长时间运行的AI推理
// 特别是当使用流式响应或处理复杂任务时
httpClient := &http.Client{
Timeout: 30 * time.Minute, // 从5分钟增加到30分钟
Transport: transport,
}
llmClient := openai.NewClient(cfg, httpClient, logger)
return &Agent{
openAIClient: llmClient,
config: cfg,
agentConfig: agentCfg,
mcpServer: mcpServer,
@ -88,7 +115,7 @@ type ChatMessage struct {
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
// ToolName 仅 tool 角色:从 Agent/轨迹 JSON 的 name 或 tool_name 恢复,供续跑构造 ToolMessage。
// ToolName 仅 tool 角色:从 Eino/轨迹 JSON 的 name 或 tool_name 恢复,供续跑构造 ToolMessage。
ToolName string `json:"tool_name,omitempty"`
// ReasoningContent 对应 OpenAI/DeepSeek 的 reasoning_content;思考模式 + 工具调用后续跑须回传(见 DeepSeek 文档)。
ReasoningContent string `json:"reasoning_content,omitempty"`
@ -190,11 +217,9 @@ type Tool struct {
// FunctionDefinition 函数定义
type FunctionDefinition struct {
OutputSchema map[string]interface{} `json:"-"`
Annotations map[string]bool `json:"-"`
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters"`
}
// Error OpenAI错误
@ -260,8 +285,8 @@ func (fc *FunctionCall) UnmarshalJSON(data []byte) error {
// ProgressCallback 进度回调函数类型
type ProgressCallback func(eventType, message string, data interface{})
// SystemInstruction returns the native agent prompt, including system_prompt_path overrides.
func (a *Agent) SystemInstruction() string {
// EinoSingleAgentSystemInstruction 供 Eino adk.ChatModelAgent.Instruction 使用(含 system_prompt_path)。
func (a *Agent) EinoSingleAgentSystemInstruction() string {
systemPrompt := DefaultSingleAgentSystemPrompt()
if a.agentConfig != nil {
if p := strings.TrimSpace(a.agentConfig.SystemPromptPath); p != "" {
@ -315,8 +340,7 @@ func (a *Agent) getAvailableTools(roleTools []string) []Tool {
tools = append(tools, Tool{
Type: "function",
Function: FunctionDefinition{
Name: mcpTool.Name,
OutputSchema: mcpTool.OutputSchema, Annotations: mcpTool.Annotations,
Name: mcpTool.Name,
Description: description, // 使用简短描述减少token消耗
Parameters: convertedSchema,
},
@ -342,6 +366,13 @@ func (a *Agent) getAvailableTools(roleTools []string) []Tool {
// 外部工具使用 "mcpName::toolName" 作为toolKey
externalToolKey := externalTool.Name
// 如果指定了角色工具列表,只添加在列表中的工具
if len(roleToolSet) > 0 {
if !roleToolSet[externalToolKey] {
continue // 不在角色工具列表中,跳过
}
}
// 解析工具名称:mcpName::toolName
var mcpName, actualToolName string
if idx := strings.Index(externalTool.Name, "::"); idx > 0 {
@ -387,17 +418,9 @@ func (a *Agent) getAvailableTools(roleTools []string) []Tool {
// 保存名称映射关系(OpenAI格式 -> 原始格式)
extMap[openAIName] = externalTool.Name
// 如果指定了角色工具列表,只添加在列表中的工具
if len(roleToolSet) > 0 {
if !roleToolSet[externalToolKey] {
continue // 不在角色工具列表中,跳过
}
}
tools = append(tools, Tool{
Type: "function",
Function: FunctionDefinition{
OutputSchema: externalTool.OutputSchema, Annotations: externalTool.Annotations,
Name: openAIName, // 使用符合OpenAI规范的名称
Description: description,
Parameters: convertedSchema,
@ -489,13 +512,12 @@ func (a *Agent) convertToOpenAIType(configType string) string {
}
}
// ToolExecutionResult MCP 工具执行结果(供 Agent 桥与监控落库使用)。
// ToolExecutionResult MCP 工具执行结果(供 Eino 桥与监控落库使用)。
type ToolExecutionResult struct {
StructuredContent map[string]interface{}
Result string
ExecutionID string
IsError bool
Blocked bool
Result string
ExecutionID string
IsError bool
Blocked bool
}
func buildToolFailureMessage(toolName, detail string, err error) string {
@ -593,11 +615,10 @@ func (a *Agent) executeToolViaMCP(ctx context.Context, toolName string, args map
resultStr := resultText.String()
return &ToolExecutionResult{
Result: resultStr,
StructuredContent: result.StructuredContent,
ExecutionID: executionID,
IsError: result != nil && result.IsError,
Blocked: result != nil && result.Blocked,
Result: resultStr,
ExecutionID: executionID,
IsError: result != nil && result.IsError,
Blocked: result != nil && result.Blocked,
}, nil
}
@ -733,7 +754,7 @@ func (a *Agent) repairOrphanToolMessages(messages *[]ChatMessage) bool {
return removed
}
// ToolsForRole 返回与单 Agent 循环一致的工具定义(OpenAI function 格式),供 Agent DeepAgent 等编排层绑定 MCP 工具。
// ToolsForRole 返回与单 Agent 循环一致的工具定义(OpenAI function 格式),供 Eino DeepAgent 等编排层绑定 MCP 工具。
func (a *Agent) ToolsForRole(roleTools []string) []Tool {
return a.getAvailableTools(roleTools)
}
@ -784,7 +805,7 @@ func (a *Agent) UnregisterLocalToolExecutionCancel(executionID string) {
}
// RecordLocalToolExecution 将非 CallTool 路径完成的工具调用写入 MCP 监控库(与 CallTool 落库一致),返回 executionId。
// 用于 Agent filesystem execute 等场景,使助手气泡「渗透测试详情」与常规 MCP 一致可点进监控。
// 用于 Eino filesystem execute 等场景,使助手气泡「渗透测试详情」与常规 MCP 一致可点进监控。
func (a *Agent) RecordLocalToolExecution(ctx context.Context, toolName string, args map[string]interface{}, resultText string, invokeErr error) string {
return a.FinishLocalToolExecution(ctx, "", toolName, args, resultText, invokeErr)
}

View File

@ -4,7 +4,7 @@ import (
"cyberstrike-ai/internal/projectprompt"
)
// DefaultSingleAgentSystemPrompt 单代理(Pi / MCP)内置系统提示;可通过 agent.system_prompt_path 覆盖为文件。
// DefaultSingleAgentSystemPrompt 单代理(Eino ADK / MCP)内置系统提示;可通过 agent.system_prompt_path 覆盖为文件。
func DefaultSingleAgentSystemPrompt() string {
return `你是CyberStrikeAI,是一个专业的网络安全渗透测试专家。你可以使用各种安全工具进行自主渗透测试。分析目标并选择最佳测试策略。
@ -102,8 +102,8 @@ func DefaultSingleAgentSystemPrompt() string {
## 技能库(Skills)与知识库
- 技能包位于服务器 skills/ 目录(各子目录 SKILL.md,遵循 agentskills.io);知识库用于向量检索片段,Skills 为可执行工作流指令。
- 本会话通过 MCP 使用知识库与漏洞记录等。Skills 由 Pi skill 工具按需加载(配置 multi_agent.skills;单代理与多代理均可,未启用时无 skill 工具)。
- 需要完整 Skill 工作流但当前无 skill 工具时,请确认已启用 multi_agent.skills,或改用 Deep / Supervisor 等多代理编排(/api/multi-agent/stream)。
- 本会话通过 MCP 使用知识库与漏洞记录等。Skills 由 Eino ADK skill 工具按需加载(配置 multi_agent.eino_skills;单代理与多代理均可,未启用时无 skill 工具)。
- 需要完整 Skill 工作流但当前无 skill 工具时,请确认已启用 multi_agent.eino_skills,或改用 Deep / Supervisor 等多代理编排(/api/multi-agent/stream)。
` + projectprompt.ShellExecExecuteGuidanceSection()
}

View File

@ -1,12 +1,11 @@
package agent
// GeneratedContextTypeKey marks host-created execution templates, separately
// from Agent's own summary/skill transport metadata.
// from Eino's own summary/skill transport metadata.
const GeneratedContextTypeKey = "_csai_generated_context_type"
const PlanExecuteExecutorContext = "plan_execute_executor"
const PlanExecuteReplannerContext = "plan_execute_replanner"
const OutputTruncationContinueContext = "output_truncation_continue"
func IsGeneratedExecutionContext(kind string) bool {
return kind == PlanExecuteExecutorContext || kind == PlanExecuteReplannerContext || kind == OutputTruncationContinueContext
return kind == PlanExecuteExecutorContext || kind == PlanExecuteReplannerContext
}

View File

@ -1,23 +1,15 @@
package agent_test
package agent
import (
"testing"
"cyberstrike-ai/internal/agent"
"cyberstrike-ai/internal/config"
"cyberstrike-ai/internal/knowledge"
"cyberstrike-ai/internal/mcp"
"cyberstrike-ai/internal/mcp/builtin"
"go.uber.org/zap"
"testing"
)
func TestRegisteredKnowledgeToolsAreAvailableToDefaultAndSelectedRoles(t *testing.T) {
logger := zap.NewNop()
mcpServer := mcp.NewServer(logger)
a := agent.NewAgent(&config.OpenAIConfig{APIKey: "test-key", BaseURL: "https://api.test.com/v1", Model: "test-model"},
&config.AgentConfig{MaxIterations: 10}, mcpServer, nil, logger, 10)
knowledge.RegisterKnowledgeTool(mcpServer, nil, nil, logger)
a := setupTestAgent(t)
knowledge.RegisterKnowledgeTool(a.mcpServer, nil, nil, zap.NewNop())
for _, role := range [][]string{nil, {builtin.ToolSearchKnowledgeBase, builtin.ToolListKnowledgeRiskTypes}} {
available := map[string]bool{}
for _, tool := range a.ToolsForRole(role) {
@ -35,4 +27,4 @@ func TestRegisteredKnowledgeToolsAreAvailableToDefaultAndSelectedRoles(t *testin
t.Fatal("role restriction bypassed")
}
}
}
}

View File

@ -16,14 +16,13 @@ const (
StatusCancelled = "cancelled"
StatusAwaitingHITL = "awaiting_hitl"
ReasonVerified = "verified"
ReasonPendingTools = "pending_tool_executions"
ReasonPendingToolsCancelled = "pending_tool_executions_cancelled"
ReasonEmptyResponse = "empty_response"
ReasonAwaitingHITL = "awaiting_hitl"
ReasonFailed = "failed"
ReasonCancelled = "cancelled"
ReasonMissingEvidence = "missing_execution_evidence"
ReasonVerified = "verified"
ReasonPendingTools = "pending_tool_executions"
ReasonEmptyResponse = "empty_response"
ReasonAwaitingHITL = "awaiting_hitl"
ReasonFailed = "failed"
ReasonCancelled = "cancelled"
ReasonMissingEvidence = "missing_execution_evidence"
)
// Decision is the single contract that may promote an agent run to a final
@ -44,8 +43,6 @@ type Decision struct {
ConversationID string `json:"conversationId,omitempty"`
AssistantMessageID string `json:"messageId,omitempty"`
CandidateResponseLen int `json:"candidateResponseLen,omitempty"`
UnfinishedPlanSteps []multiagent.PlanStep `json:"unfinishedPlanSteps,omitempty"`
}
type Input struct {
@ -62,12 +59,6 @@ type Input struct {
func FromRunResult(db *database.DB, result *multiagent.RunResult, in Input) Decision {
if result != nil {
if in.Status == "" && result.RuntimeStatus != "" {
in.Status = result.RuntimeStatus
}
if in.CompletionReason == "" && result.RuntimeCompletionReason != "" {
in.CompletionReason = result.RuntimeCompletionReason
}
if strings.TrimSpace(in.Response) == "" {
in.Response = result.Response
}
@ -77,9 +68,6 @@ func FromRunResult(db *database.DB, result *multiagent.RunResult, in Input) Deci
}
d := Decide(db, in)
if result != nil {
if !d.Finalizable && len(result.UnfinishedPlanSteps) > 0 {
d.UnfinishedPlanSteps = result.UnfinishedPlanSteps
}
result.Finalized = d.Finalized
result.Status = d.Status
result.CompletionReason = d.CompletionReason
@ -120,6 +108,13 @@ func Decide(db *database.DB, in Input) Decision {
d.MissingChecks = append(d.MissingChecks, "workflow is awaiting HITL approval")
return d
}
if isEmptyCandidate(text) {
d.Status = StatusBlocked
d.CompletionReason = ReasonEmptyResponse
d.EvidenceVerified = false
d.MissingChecks = append(d.MissingChecks, "assistant final text is empty or only an empty-response placeholder")
return d
}
switch status {
case StatusInProgress, StatusBlocked, StatusFailed, StatusCancelled, StatusAwaitingHITL:
d.Status = status
@ -127,24 +122,10 @@ func Decide(db *database.DB, in Input) Decision {
if d.CompletionReason == ReasonVerified {
d.CompletionReason = status
}
if (d.CompletionReason == multiagent.ReasonUnfinishedPlan ||
d.CompletionReason == multiagent.ReasonIterationLimit ||
d.CompletionReason == multiagent.ReasonPlanningIterationLimit) && isEmptyCandidate(text) {
d.FinalText = ""
d.CandidateResponseLen = 0
}
d.MissingChecks = append(d.MissingChecks, "agent run status is "+status)
return d
}
if isEmptyCandidate(text) {
d.Status = StatusBlocked
d.CompletionReason = ReasonEmptyResponse
d.EvidenceVerified = false
d.MissingChecks = append(d.MissingChecks, "assistant final text is empty or only an empty-response placeholder")
return d
}
pending := pendingExecutions(db, in.MCPExecutionIDs)
if len(pending) > 0 {
d.Status = StatusInProgress
@ -194,9 +175,6 @@ func ResponsePayload(d Decision, extra map[string]interface{}) map[string]interf
if d.AgentMode != "" {
out["agentMode"] = d.AgentMode
}
if len(d.UnfinishedPlanSteps) > 0 {
out["unfinishedPlanSteps"] = d.UnfinishedPlanSteps
}
for k, v := range extra {
out[k] = v
}

View File

@ -63,7 +63,7 @@ func TestDecideBlocksAwaitingHITLAndEmptyCandidate(t *testing.T) {
t.Fatalf("HITL decision mismatch: %+v", hitl)
}
empty := Decide(nil, Input{Response: "⚠️ Agent 执行完成,但未捕获到助手文本输出。"})
empty := Decide(nil, Input{Response: "⚠️ Eino 执行完成,但未捕获到助手文本输出。"})
if empty.Finalizable || empty.Status != StatusBlocked || empty.CompletionReason != ReasonEmptyResponse {
t.Fatalf("empty candidate decision mismatch: %+v", empty)
}

View File

@ -1,33 +0,0 @@
package agentfinalizer
import (
"testing"
"cyberstrike-ai/internal/multiagent"
)
func TestRuntimeIterationLimitCannotBecomeCompleted(t *testing.T) {
result := &multiagent.RunResult{Response: "Partial report", RuntimeStatus: "blocked", RuntimeCompletionReason: "iteration_limit"}
for i := 0; i < 2; i++ {
decision := FromRunResult(nil, result, Input{})
if decision.Finalizable || decision.Status != "blocked" || decision.CompletionReason != "iteration_limit" {
t.Fatalf("unexpected delivery: %+v", decision)
}
}
}
func TestTruncatedOutputRetainsReasonWithoutFinalText(t *testing.T) {
result := &multiagent.RunResult{RuntimeStatus: StatusBlocked, RuntimeCompletionReason: multiagent.ReasonModelOutputTruncated}
decision := FromRunResult(nil, result, Input{})
if decision.Finalized || decision.Finalizable || decision.Status != StatusBlocked || decision.CompletionReason != multiagent.ReasonModelOutputTruncated {
t.Fatalf("unexpected delivery: %+v", decision)
}
}
func TestTruncatedOutputKeepsCandidateText(t *testing.T) {
result := &multiagent.RunResult{Response: "已生成的前半段", RuntimeStatus: StatusBlocked, RuntimeCompletionReason: multiagent.ReasonModelOutputTruncated}
decision := FromRunResult(nil, result, Input{})
if decision.Finalizable || decision.Finalized || decision.FinalText != "已生成的前半段" || decision.CompletionReason != multiagent.ReasonModelOutputTruncated {
t.Fatalf("unexpected delivery: %+v", decision)
}
}

View File

@ -1,148 +0,0 @@
package agentruntime
import (
"bytes"
"context"
"crypto/sha256"
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
)
func runtimeSourceFiles(root string) ([]string, error) {
files := []string{"package.json", "package-lock.json", "tsconfig.json"}
err := filepath.WalkDir(filepath.Join(root, "src"), func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
if d.Type()&os.ModeSymlink != 0 {
return fmt.Errorf("runtime source must not be a symlink: %s", path)
}
rel, err := filepath.Rel(root, path)
if err != nil {
return err
}
files = append(files, filepath.ToSlash(rel))
return nil
})
sort.Strings(files)
return files, err
}
func SourceFingerprint(root string) (string, error) {
files, err := runtimeSourceFiles(root)
if err != nil {
return "", err
}
h := sha256.New()
for _, file := range files {
b, err := os.ReadFile(filepath.Join(root, filepath.FromSlash(file)))
if err != nil {
return "", err
}
h.Write([]byte(file))
h.Write([]byte{0})
h.Write(b)
h.Write([]byte{0})
}
return fmt.Sprintf("%x", h.Sum(nil)), nil
}
// PreparePiRuntime publishes an immutable source-addressed worker bundle. Source rollback
// selects the prior bundle automatically; an active worker keeps its original dependencies.
func PreparePiRuntime(ctx context.Context, root string) (string, error) {
return preparePiRuntime(ctx, root, "")
}
func preparePiRuntime(ctx context.Context, root, node string) (string, error) {
root, err := filepath.Abs(root)
if err != nil {
return "", err
}
fingerprint, err := SourceFingerprint(root)
if err != nil {
return "", err
}
cache := filepath.Join(root, ".builds")
dest := filepath.Join(cache, fingerprint)
worker := filepath.Join(dest, "dist", "worker.js")
if _, err := os.Stat(filepath.Join(dest, ".ready")); err == nil {
if _, err = os.Stat(worker); err == nil {
return worker, nil
}
}
if err = os.MkdirAll(cache, 0o700); err != nil {
return "", err
}
stage, err := os.MkdirTemp(cache, ".staging-")
if err != nil {
return "", err
}
defer os.RemoveAll(stage)
files, err := runtimeSourceFiles(root)
if err != nil {
return "", err
}
for _, name := range files {
body, err := os.ReadFile(filepath.Join(root, filepath.FromSlash(name)))
if err != nil {
return "", err
}
path := filepath.Join(stage, filepath.FromSlash(name))
if err = os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return "", err
}
if err = os.WriteFile(path, body, 0o600); err != nil {
return "", err
}
}
if node == "" {
node = "node"
}
if node, err = exec.LookPath(node); err != nil {
return "", fmt.Errorf("Pi requires Node.js >=22.19: %w", err)
}
check := exec.CommandContext(ctx, node, "-e", `const [a,b]=process.versions.node.split('.').map(Number);process.exit(a>22||(a===22&&b>=19)?0:1)`)
if err = check.Run(); err != nil {
return "", fmt.Errorf("Pi requires Node.js >=22.19")
}
for _, args := range [][]string{{"ci", "--ignore-scripts", "--no-audit", "--no-fund"}, {"run", "build"}} {
cmd := exec.CommandContext(ctx, "npm", args...)
if runtime.GOOS == "windows" {
cmd = exec.CommandContext(ctx, "cmd.exe", append([]string{"/d", "/c", "npm"}, args...)...)
}
cmd.Dir = stage
cmd.Env = append(os.Environ(), "PATH="+filepath.Dir(node)+string(os.PathListSeparator)+os.Getenv("PATH"))
var output bytes.Buffer
cmd.Stdout = &output
cmd.Stderr = &output
if err = cmd.Run(); err != nil {
msg := strings.TrimSpace(output.String())
if len(msg) > 4000 {
msg = msg[len(msg)-4000:]
}
return "", fmt.Errorf("Pi runtime build failed: %w\n%s", err, msg)
}
}
if _, err = os.Stat(filepath.Join(stage, "dist", "worker.js")); err != nil {
return "", fmt.Errorf("Pi build produced no worker: %w", err)
}
if err = os.WriteFile(filepath.Join(stage, ".ready"), []byte(fingerprint), 0o600); err != nil {
return "", err
}
if err = os.Rename(stage, dest); err != nil {
if _, exists := os.Stat(filepath.Join(dest, ".ready")); exists == nil {
return worker, nil
}
return "", err
}
return worker, nil
}

View File

@ -1,49 +0,0 @@
package agentruntime
import (
"os"
"path/filepath"
"testing"
)
func TestSourceAddressedWorkerRejectsStaleBundleAndSupportsRollback(t *testing.T) {
root := t.TempDir()
t.Chdir(root)
runtimeRoot := filepath.Join(root, "runtime", "pi")
if err := os.MkdirAll(filepath.Join(runtimeRoot, "src"), 0o700); err != nil {
t.Fatal(err)
}
for _, name := range []string{"package.json", "package-lock.json", "tsconfig.json"} {
if err := os.WriteFile(filepath.Join(runtimeRoot, name), []byte("{}"), 0o600); err != nil {
t.Fatal(err)
}
}
source := filepath.Join(runtimeRoot, "src", "worker.ts")
os.WriteFile(source, []byte("version one"), 0o600)
hash, err := SourceFingerprint(runtimeRoot)
if err != nil {
t.Fatal(err)
}
bundle := filepath.Join(runtimeRoot, ".builds", hash)
os.MkdirAll(filepath.Join(bundle, "dist"), 0o700)
os.WriteFile(filepath.Join(bundle, "dist", "worker.js"), []byte("worker"), 0o600)
if _, err := ResolveWorker(""); err == nil {
t.Fatal("unpublished bundle was selected")
}
os.WriteFile(filepath.Join(bundle, ".ready"), []byte(hash), 0o600)
worker, err := ResolveWorker("")
if err != nil {
t.Fatal(err)
}
if worker != filepath.Join(bundle, "dist", "worker.js") {
t.Fatalf("wrong worker: %s", worker)
}
os.WriteFile(source, []byte("version two"), 0o600)
if _, err := ResolveWorker(""); err == nil {
t.Fatal("stale source bundle was selected")
}
os.WriteFile(source, []byte("version one"), 0o600)
if restored, err := ResolveWorker(""); err != nil || restored != worker {
t.Fatalf("rollback lost original bundle: %s %v", restored, err)
}
}

View File

@ -1,123 +0,0 @@
package agentruntime
import (
"context"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
)
const maxRecordBytes = 32 * 1024 * 1024
type Pi struct {
NodePath string
WorkerPath string
}
type runRequest struct {
Request
LegacyProfile json.RawMessage `json:"profile"`
}
type record struct {
Type string `json:"type"`
Version int `json:"version,omitempty"`
KeepAlive bool `json:"keepAlive,omitempty"`
Request *runRequest `json:"request,omitempty"`
Event *Event `json:"event,omitempty"`
Call *ToolCall `json:"call,omitempty"`
Result *Result `json:"result,omitempty"`
Error string `json:"error,omitempty"`
SDKVersion string `json:"sdkVersion,omitempty"`
}
// ResolveWorker supports source installs and release bundles without relying on PATH for scripts.
func ResolveWorker(configured string) (string, error) {
if configured != "" {
path, err := filepath.Abs(configured)
if err != nil {
return "", err
}
if st, err := os.Stat(path); err != nil || !st.Mode().IsRegular() {
return "", fmt.Errorf("Pi worker does not exist: %s", path)
}
return path, nil
}
for _, path := range workerCandidates() {
root := filepath.Dir(filepath.Dir(path))
if fingerprint, err := SourceFingerprint(root); err == nil {
bundle := filepath.Join(root, ".builds", fingerprint)
if _, err = os.Stat(filepath.Join(bundle, ".ready")); err == nil {
if _, err = os.Stat(filepath.Join(bundle, "dist", "worker.js")); err == nil {
return filepath.Join(bundle, "dist", "worker.js"), nil
}
}
continue
}
if st, err := os.Stat(path); err == nil && st.Mode().IsRegular() {
return path, nil
}
}
return "", errors.New("Pi worker missing; run bash scripts/build-pi-runtime.sh, or configure agent_runtime.worker_path")
}
func workerCandidates() []string {
var candidates []string
if exe, err := os.Executable(); err == nil {
candidates = append(candidates, filepath.Join(filepath.Dir(exe), "runtime/pi/dist/worker.js"))
}
if cwd, err := os.Getwd(); err == nil {
candidates = append(candidates, filepath.Join(cwd, "runtime/pi/dist/worker.js"))
// Package tests and developer commands may run below the repository root.
for dir := cwd; dir != filepath.Dir(dir); dir = filepath.Dir(dir) {
if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
candidates = append(candidates, filepath.Join(dir, "runtime/pi/dist/worker.js"))
break
}
}
}
return candidates
}
// Run reuses a warm pooled worker when one is healthy, otherwise starts a fresh
// process. Tool execution stays in the host. A worker only returns to the pool
// after a clean result with no cancel, timeout or protocol error.
func (p Pi) Run(ctx context.Context, req Request, execute ToolExecutor, emit func(Event), bind func(Control) func()) (*Result, error) {
if err := ctx.Err(); err != nil {
return nil, err
}
if req.WorkingDir == "" {
var err error
req.WorkingDir, err = os.Getwd()
if err != nil {
return nil, err
}
}
release, err := acquireSession(ctx, req.SessionDir)
if err != nil {
return nil, err
}
defer release()
workerPath, err := ResolveWorker(p.WorkerPath)
if err != nil {
return nil, err
}
node := p.NodePath
if node == "" {
node = "node"
}
w, err := pool.acquire(ctx, node, workerPath)
if err != nil {
return nil, err
}
res, runErr := w.run(ctx, req, execute, emit, bind)
w.runs++
if runErr == nil && ctx.Err() == nil && !w.writeFailed.Load() && len(w.incoming) == 0 && w.runs < poolMaxRunsPerWorker {
pool.release(node, workerPath, w)
} else {
w.destroy()
}
return res, runErr
}

Some files were not shown because too many files have changed in this diff Show More