README
🚀 flyto-core
flyto-core 是一个可调试的自动化引擎,它能对每一步操作进行追踪,并支持从任意点开始重放,极大提升了自动化流程的调试和执行效率。
🚀 快速开始
你可以在 30 秒内体验 flyto-core:
pip install flyto-core[browser] && playwright install chromium
flyto recipe competitor-intel --url https://github.com/pricing
执行上述命令后,会看到如下执行结果:
Step 1/12 browser.launch ✓ 420ms
Step 2/12 browser.goto ✓ 1,203ms
Step 3/12 browser.evaluate ✓ 89ms
Step 4/12 browser.screenshot ✓ 1,847ms → saved intel-desktop.png
Step 5/12 browser.viewport ✓ 12ms → 390×844
Step 6/12 browser.screenshot ✓ 1,621ms → saved intel-mobile.png
Step 7/12 browser.viewport ✓ 8ms → 1280×720
Step 8/12 browser.performance ✓ 5,012ms → Web Vitals captured
Step 9/12 browser.evaluate ✓ 45ms
Step 10/12 browser.evaluate ✓ 11ms
Step 11/12 file.write ✓ 3ms → saved intel-report.json
Step 12/12 browser.close ✓ 67ms
✓ Done in 10.3s — 12/12 steps passed
执行完成后,会完成截图捕获、性能指标提取以及 JSON 报告保存,并且每一步操作都有详细追踪。
✨ 主要特性
- 执行追踪:对每一步操作进行结构化记录,包含输入、输出、时间和状态。
- 重放功能:可使用原始(或修改后)的上下文从任意步骤重新执行。
- 断点设置:能在任意步骤暂停执行,检查状态后继续。
- 证据快照:在每个步骤边界前后保存完整状态。
- 数据溯源:跟踪跨步骤的数据流,构建依赖图。
- 超时保护:支持可配置的工作流级别和每步超时保护。
📦 安装指南
pip install flyto-core # 安装核心引擎、CLI 和 MCP 服务器
pip install flyto-core[browser] # 安装浏览器自动化功能(Playwright)
playwright install chromium # 一次性浏览器设置
💻 使用示例
基础用法
以下是使用 flyto-core 进行竞争定价分析的示例:
name: Competitor Intel
steps:
- id: launch
module: browser.launch
- id: navigate
module: browser.goto
params: { url: "{{url}}" }
- id: prices
module: browser.evaluate
params:
script: |
JSON.stringify([
...document.querySelectorAll(
'[class*="price"]'
)
].map(e => e.textContent.trim()))
- id: desktop_shot
module: browser.screenshot
params: { path: desktop.png, full_page: true }
- id: mobile
module: browser.viewport
params: { width: 390, height: 844 }
- id: mobile_shot
module: browser.screenshot
params: { path: mobile.png, full_page: true }
- id: perf
module: browser.performance
- id: save
module: file.write
params:
path: report.json
content: "${prices.result}"
- id: close
module: browser.close
高级用法
当第 8 步执行失败时,可使用以下命令从第 8 步开始重放:
flyto replay --from-step 8
这样步骤 1 - 7 会立即执行,仅重新执行第 8 步,并且会保留完整上下文。
📚 详细文档
3 个立即尝试的配方
# 竞争定价分析:截图、Web Vitals 数据和 JSON 报告
flyto recipe competitor-intel --url https://competitor.com/pricing
# 全站审计:SEO、可访问性和性能
flyto recipe full-audit --url https://your-site.com
# 网页数据抓取并导出为 CSV
flyto recipe scrape-to-csv --url https://news.ycombinator.com --selector ".titleline a"
每个配方都有执行追踪,每次运行都可重放。查看所有 32 个配方 →
412 个模块,78 个类别
| 类别 | 数量 | 示例 |
|----------|-------|----------|
| browser.* | 38 | launch, goto, click, extract, screenshot, fill forms, wait |
| flow.* | 24 | switch, loop, branch, parallel, retry, circuit breaker, rate limit |
| array.* | 15 | filter, sort, map, reduce, unique, chunk, flatten |
| string.* | 11 | reverse, uppercase, split, replace, trim, slugify, template |
| api.* | 11 | OpenAI, Anthropic, Gemini, Notion, Slack, Telegram |
| object.* | 10 | keys, values, merge, pick, omit, get, set, flatten |
| image.* | 9 | resize, convert, crop, rotate, watermark, OCR, compress |
| data.* | 8 | json/xml/yaml/csv parse and generate |
| file.* | 8 | read, write, copy, move, delete, exists, edit, diff |
| stats.* | 8 | mean, median, percentile, correlation, standard deviation |
| validate.* | 7 | email, url, json, phone, credit card |
| docker.* | 6 | run, ps, logs, stop, build, inspect |
| archive.* | 6 | zip create/extract, tar create/extract, gzip, gunzip |
| math.* | 6 | calculate, round, ceil, floor, power, abs |
| k8s.* | 5 | get_pods, apply, logs, scale, describe |
| crypto.* | 4 | AES encrypt/decrypt, JWT create/verify |
| network.* | 4 | ping, traceroute, whois, port scan |
| pdf.* | 4 | parse, extract text, merge, compress |
| aws.s3.* | 4 | upload, download, list, delete |
| google.* | 4 | Gmail send/search, Calendar create/list events |
| cache.* | 4 | get, set, delete, clear (memory + Redis) |
| ssh.* | 3 | remote exec, SFTP upload, SFTP download |
| git.* | 3 | clone, commit, diff |
| sandbox.* | 3 | execute Python, Shell, JavaScript |
| dns.* | 1 | DNS lookup (A, AAAA, MX, CNAME, TXT, NS) |
| monitor.* | 1 | HTTP health check with SSL cert verification |
查看 完整模块目录 以获取每个模块、参数和描述的详细信息。
与其他工具的区别
| 对比项 | Playwright / Selenium | Shell 脚本 | flyto-core |
|-|----------------------|---------------|------------|
| 第 8 步失败 | 重新运行整个流程 | 重新运行整个流程 | flyto replay --from-step 8 |
| 第 3 步发生了什么 | 添加 print() 并重新运行 | 添加 echo 并重新运行 | 完整追踪:输入、输出、时间 |
| 浏览器、API 和文件 I/O | 编写胶水代码 | 使用 3 种语言 | 所有功能内置 |
| 与团队共享 | "克隆我的仓库" | "克隆我的仓库" | pip install flyto-core |
| 在 CI 中运行 | 用 pytest/bash 包装 | 不稳定 | flyto run workflow.yaml |
使用方式
CLI — 从终端运行工作流
# 运行内置配方
flyto recipe site-audit --url https://example.com
# 运行自己的 YAML 工作流
flyto run my-workflow.yaml
# 列出所有配方
flyto recipes
MCP Server — 适用于 Claude Code、Cursor、Windsurf
pip install flyto-core
claude mcp add flyto-core -- python -m core.mcp_server
或者添加到你的 MCP 配置中:
{
"mcpServers": {
"flyto-core": {
"command": "python",
"args": ["-m", "core.mcp_server"]
}
}
}
这样你的 AI 就能将所有模块作为工具使用。
HTTP API — 用于集成和远程执行
pip install flyto-core[api]
flyto serve
# ✓ flyto-core running on 127.0.0.1:8333
| 端点 | 用途 |
|----------|---------|
| POST /v1/workflow/run | 执行带有证据和追踪的工作流 |
| POST /v1/workflow/{id}/replay/{step} | 从任意步骤重放 |
| POST /v1/execute | 执行单个模块 |
| GET /v1/modules | 发现所有模块 |
| POST /mcp | MCP 可流式 HTTP 传输 |
Python API — 用于编程式使用
import asyncio
from core.modules.registry import ModuleRegistry
async def main():
result = await ModuleRegistry.execute(
"string.reverse",
params={"text": "Hello"},
context={}
)
print(result) # {"ok": True, "data": {"result": "olleH"}}
asyncio.run(main())
30 + 内置配方
无需编写代码,每个配方都是一个 YAML 工作流模板:
flyto recipes # 列出所有配方
# 审计与测试
flyto recipe full-audit --url https://example.com
flyto recipe competitor-intel --url https://github.com/pricing
flyto recipe site-audit --url https://example.com
flyto recipe web-perf --url https://example.com
flyto recipe login-test --url https://myapp.com/login --username user --password pass --success_selector .dashboard
flyto recipe form-fill --url https://myapp.com/form --data '{"email":"test@example.com"}'
# 浏览器自动化
flyto recipe screenshot --url https://example.com
flyto recipe responsive-report --url https://example.com
flyto recipe page-to-pdf --url https://example.com
flyto recipe visual-snapshot --url https://example.com
flyto recipe webpage-archive --url https://example.com
flyto recipe scrape-page --url https://example.com --selector h1
flyto recipe scrape-links --url https://example.com
flyto recipe scrape-table --url https://en.wikipedia.org/wiki/YAML --selector .wikitable
flyto recipe stock-price --symbol AAPL
# 数据与图像
flyto recipe ocr --input scan.png
flyto recipe csv-to-json --input data.csv
flyto recipe image-resize --input photo.jpg --width 800
flyto recipe image-convert --input photo.png --format webp
# 网络与 DevOps
flyto recipe port-scan --host example.com
flyto recipe whois --domain example.com
flyto recipe monitor-site --url https://myapp.com
flyto recipe docker-ps
flyto recipe git-changelog
# 集成
flyto recipe scrape-to-slack --url https://example.com --selector h1 --webhook $SLACK_URL
flyto recipe github-issue --url https://example.com --owner me --repo my-app --title "Bug" --token $GITHUB_TOKEN
每个配方都是一个 YAML 工作流模板。运行 flyto recipe <name> --help 可查看完整选项。查看 docs/RECIPES.md 以获取完整文档。
编写自己的工作流
配方只是 YAML 文件,你可以编写自己的工作流:
name: price-monitor
steps:
- id: open
module: browser.launch
params: { headless: true }
- id: page
module: browser.goto
params: { url: "https://competitor.com/pricing" }
- id: prices
module: browser.evaluate
params:
script: |
JSON.stringify([...document.querySelectorAll('.price')].map(e => e.textContent))
- id: save
module: file.write
params: { path: "prices.json", content: "${prices.result}" }
- id: close
module: browser.close
flyto run price-monitor.yaml
每次运行都会生成执行追踪和状态快照。如果第 3 步失败,可从第 3 步重放,无需重新运行整个流程。
模块作者指南
from core.modules.registry import register_module
from core.modules.schema import compose, presets
@register_module(
module_id='string.reverse',
version='1.0.0',
category='string',
label='Reverse String',
description='Reverse the characters in a string',
params_schema=compose(presets.INPUT_TEXT(required=True)),
output_schema={'result': {'type': 'string', 'description': 'Reversed string'}},
)
async def string_reverse(context):
text = str(context['params']['text'])
return {'ok': True, 'data': {'result': text[::-1]}}
查看 模块规范 以获取完整指南。
贡献代码
我们欢迎贡献!查看 CONTRIBUTING.md 以获取贡献指南。
安全问题
通过 security@flyto.dev 报告安全漏洞。查看 SECURITY.md 以获取我们的安全策略。
📄 许可证
Apache 许可证 2.0 — 个人和商业使用均免费。
桌面 GUI 可在 flyto2.com 获取。
Scan to join WeChat group