Digital Twin Proxy如何将网络流量转化为AI智能体个人记忆?
Digital Twin Proxy is an open-source forward proxy that transforms web browsing traffic into structured personal memory for AI agents through LLM-powered analysis, enabling context engineering for more personalized and intelligent agentic applications.
原文翻译: Digital Twin Proxy 是一个开源正向代理,通过大语言模型驱动的分析,将网络浏览流量转化为AI代理的结构化个人记忆,为更个性化和智能的代理应用实现上下文工程。
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。: A Forward Proxy for Transforming Network Traffic into Personal Memory for AI Agents
将网页浏览活动转化为AI智能体的个人记忆。
Turn web browsing into personal memory for AI agents.
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 能够记录网络流量,并利用本地或远程的大型语言模型(LLM)来分析您的浏览模式。该项目专为开发者、研究人员以及任何希望通过AI视角理解自身在线活动的用户而设计。
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 logs web traffic and uses a local or remote large language model (LLM) to generate an analysis of your browsing patterns. It's designed for developers, researchers, and anyone interested in understanding their online activity through the lens of AI.
核心特性
Key Features
- HTTP/S 流量记录:捕获通过代理发起的所有网络请求。
HTTP/S Traffic Logging: Captures all web requests made through the proxy.
- 具备自主性的内容感知分析:利用LLM不仅分析流量模式,还能自主决定抓取哪些页面进行更深入的分析。
Agentic, Content-Aware Analysis: Uses an LLM to not only analyze traffic patterns but also to decide which pages to fetch and analyze in more depth.
- 灵活的运行模式:可在后台持续运行、记录流量,或执行一次性分析。
Flexible Operation Modes: Run in the background, log traffic continuously, or perform one-off analysis.
- 高度可定制:可轻松更改AI模型、分析间隔等设置。
Customizable: Easily change the AI model, analysis interval, and other settings.
- 兼容OpenAI API:可与任何OpenAI兼容的API协同工作,包括本地服务(如OllamaA tool for running and managing AI models locally, supporting DeepSeek and other models.、LM StudioA powerful local large model management tool that supports multiple model formats for desktop deployment.)和远程服务(如OpenAI、Groq等)。
OpenAI-Compatible: Works with any OpenAI-compatible API, including local providers like OllamaA tool for running and managing AI models locally, supporting DeepSeek and other models. and LM StudioA powerful local large model management tool that supports multiple model formats for desktop deployment., as well as remote services like OpenAI, Groq, etc.
- 注重隐私保护:通过使用本地LLM,确保您的浏览历史保持私密,不会发送给任何第三方服务。
Privacy-Focused: By using a local LLM, you can ensure that your browsing history remains private and is not sent to any third-party service.
关于隐私的说明
A Note on Privacy
本应用旨在处理您的个人浏览历史。因此,我们强烈建议使用本地大型语言模型(LLM)服务,例如 Ollama、LM Studio、vLLM 或 TGI。通过在您自己的机器上运行LLM,可以确保您的浏览数据保持私密,永远不会发送给第三方服务。
This application is designed to work with your personal browsing history. As such, we strongly recommend using a local large language model (LLM) provider like Ollama, LM Studio, vLLM, or TGI. By running the LLM on your own machine, you can ensure that your browsing data remains private and is never sent to a third-party service.
虽然您可以使用任何OpenAI兼容的API,但请注意将浏览数据发送到远程服务可能带来的隐私影响。
While you can use any OpenAI-compatible API, please be aware of the privacy implications of sending your browsing data to a remote service.
为智能体应用提供上下文
Context for Agentic Applications
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 的主要输出是结构化的网络流量日志以及AI生成的分析报告。这些数据可以作为其他智能体应用强大的实时上下文来源。
The primary output of Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 is a structured log of your web traffic, along with AI-generated analysis. This data can serve as a powerful source of real-time context for other agentic applications.
通过提供近期浏览历史的分析,您可以为其他AI智能体构建一个信息更丰富的上下文窗口,使其能够:
By providing an analysis of recent browsing history, you can engineer a more informed context window for other AI agents, enabling them to:
- 个性化响应:智能体可以根据您当前的任务和兴趣调整其行为。
Personalize responses: An agent can tailor its behavior based on your current tasks and interests.
- 预判需求:智能体可以根据您正在访问的网站主动提供帮助。
Anticipate needs: An agent can proactively offer assistance based on the websites you are visiting.
- 优化工具使用:智能体可以更好地理解您的工作背景,从而选择正确的工具。
Improve tool usage: An agent can better understand the context of your work and select the right tools for the job.
这种“上下文工程通过分析和结构化个人数据(如浏览历史),为AI代理设计和提供更丰富、相关的上下文信息,以提升其个性化响应和智能决策能力的过程。”的过程使您能够创建更强大、更个性化的AI体验。
This process of "context engineering" allows you to create a more powerful and personalized AI experience.
工作原理
How It Works
该代理通过将浏览器流量路由到本地Squid实例来工作。应用程序随后使用AI智能体分析流量,并决定抓取和分析哪些页面。
The proxy operates by routing your browser's traffic through a local Squid instance. The application then uses an AI agent to analyze the traffic and decide which pages to fetch and analyze further.
浏览器 → Squid 代理 (端口 8888) → 互联网
↓
访问日志
↓
Digital Twin Proxy 应用 → OpenAI兼容API → 决定抓取内容 → 抓取页面内容 → OpenAI兼容API → 分析
Browser → Squid Proxy (port 8888) → Internet ↓ Access Logs ↓ Digital Twin Proxy App → OpenAI-compatible API → Decides to fetch content → Fetches Page Content → OpenAI-compatible API → Analysis
- 流量拦截:您的浏览器被配置为将所有HTTP和HTTPS请求发送到端口8888上的Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。监听器。
Traffic Interception: Your browser is configured to send all HTTP and HTTPS requests to the Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 listener on port 8888.
- 日志记录:由Squid驱动的代理记录每个请求的URL和主机。
Logging: The proxy, powered by Squid, logs every request's URL and host.
- 自主分析:
digital-twin-proxy应用程序通过OpenAI兼容的API将访问过的URL列表发送给LLM。LLM随后扮演智能体的角色,决定哪些URL值得进一步查看。Agentic Analysis: The
digital-twin-proxyapplication sends the list of visited URLs to an LLM via an OpenAI-compatible API. The LLM then acts as an agent, deciding which URLs are interesting enough to warrant a deeper look. - 内容抓取:如果智能体决定调查某个URL,它会使用工具抓取该页面的内容。
Content Fetching: If the agent decides to investigate a URL, it uses a tool to fetch the content of that page.
- 深度分析:智能体随后分析抓取到的页面内容,生成对您浏览模式更深入、更有意义的总结。
In-Depth Analysis: The agent then analyzes the content of the fetched page to generate a more in-depth and meaningful summary of your browsing patterns.
快速开始
Getting Started
先决条件
Prerequisites
- Rust 工具链
Rust toolchain
- Squid 代理
Squid proxy
- 通过 OpenAI兼容API遵循OpenAI API接口规范的应用程序编程接口,允许工具与各种大语言模型服务(包括本地和远程)进行交互。 访问LLM。我们推荐本地服务,如 Ollama、LM Studio、vLLM 或 TGI。
LLM access via OpenAI-compatible API. We recommend local service like Ollama, LM Studio, vLLM, or TGI.
安装
Installation
克隆仓库并构建项目:
Clone the repository and build the project:
git clone https://github.com/kstonekuan/digital-twin-proxy.git
cd digital-twin-proxy
cargo build --release
构建后的二进制文件位于 target/release/digital-twin-proxy。
The binary will be located at
target/release/digital-twin-proxy.
配置
Configuration
1. 配置浏览器
1. Configure Your Browser
将浏览器的HTTP和HTTPS代理设置为 127.0.0.1:8888。
Set your browser's HTTP and HTTPS proxy to
127.0.0.1:8888.
2. 配置API端点
2. Configure the API Endpoint
您可以通过三种方法配置应用程序(按优先级排序):
You can configure the application using three methods (in order of priority):
- 命令行参数(最高优先级)
Command-line flags (highest priority)
- 环境变量
Environment variables
.env文件(最低优先级).envfile (lowest priority)
可用配置选项
Available Configuration Options
| 选项 | 环境变量 | CLI 参数 | 默认值 | 描述 |
|---|---|---|---|---|
| API 基础 URL | API_BASE |
--api-base |
(必填) | OpenAI兼容API遵循OpenAI API接口规范的应用程序编程接口,允许工具与各种大语言模型服务(包括本地和远程)进行交互。端点 |
| API 密钥 | API_KEY |
--api-key |
(可选) | 服务的API密钥 |
| 模型 | MODEL |
--model |
gpt-oss:20b |
使用的LLM模型 |
| 后台分析间隔 | AMBIENT_INTERVAL |
--interval |
30 |
分析间隔秒数(后台模式) |
| 最大分析条目数 | MAX_ANALYSIS_ITEMS |
--max-items |
500 |
每批次分析的最大URL数量 |
Option Environment Variable CLI Flag Default Description API Base URL API_BASE--api-base(required) OpenAI-compatible API endpoint API Key API_KEY--api-key(optional) API key for the service Model MODEL--modelgpt-oss:20bLLM model to use Ambient Interval AMBIENT_INTERVAL--interval30Seconds between analyses (ambient mode) Max Analysis Items MAX_ANALYSIS_ITEMS--max-items500Maximum URLs to analyze per batch
配置方法
Configuration Methods
方法一:使用 .env 文件:
Method 1: Using a
.envfile:
复制示例配置文件并进行编辑:
Copy the example configuration and edit it:
cp .env.example .env
# 编辑 .env 文件,填入您的配置值
cp .env.example .env # Edit .env with your values
示例 .env 文件:
Example
.envfile:
API_BASE=http://localhost:11434/v1
API_KEY=your-api-key-if-needed
MODEL=gpt-oss:20b
AMBIENT_INTERVAL=60
MAX_ANALYSIS_ITEMS=1000
方法二:使用环境变量:
Method 2: Using environment variables:
export API_BASE=http://localhost:11434/v1
export MODEL=gpt-oss:20b
./digital-twin-proxy analyze --since 1h
方法三:使用命令行参数:
Method 3: Using command-line flags:
./digital-twin-proxy analyze \
--since 1h \
--api-base http://localhost:11434/v1 \
--model gpt-oss:20b \
--max-items 1000
3. 验证
3. Verify
在日志模式下启动代理并访问一个网站。
Start the proxy in logging mode and visit a website.
# 终端 1: 启动代理
./target/release/digital-twin-proxy log
# 终端 2: 跟踪日志
tail -f ~/.local/share/ai-proxy/log.ndjson
您应该能看到代表您网络流量的JSON对象。
You should see JSON objects representing your web traffic.
使用方法
Usage
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 有三个主要命令:
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 has three main commands:
log:启动代理,仅记录流量。log: Start the proxy and only log traffic.analyze:对指定时间段内记录的流量执行一次性、内容感知的分析。analyze: Perform a one-shot, content-aware analysis of traffic logged since a given duration.ambient:运行代理,并在后台定期对流量进行内容感知分析。ambient: Run the proxy and periodically perform content-aware analysis of traffic in the background.
示例:
Examples:
# 仅记录流量,不进行分析
./digital-twin-proxy log
# 使用本地Ollama模型分析过去一小时的流量
./digital-twin-proxy analyze --since 1h --model gpt-oss:20b --api-base http://localhost:11434/v1
# 在后台模式下运行,每5分钟使用OpenAI API分析一次
./digital-twin-proxy ambient --interval 300 --model gpt-5 --api-base https://api.openai.com/v1 --api-key $OPENAI_API_KEY
# Log traffic without analysis ./digital-twin-proxy log # Analyze traffic from the last hour with a local Ollama model ./digital-twin-proxy analyze --since 1h --model gpt-oss:20b --api-base http://localhost:11434/v1 # Run in ambient mode, analyzing every 5 minutes with the OpenAI API ./digital-twin-proxy ambient --interval 300 --model gpt-5 --api-base https://api.openai.com/v1 --api-key $OPENAI_API_KEY
未来规划
Planned Features
MCP 服务器
MCP Server
我们将很快把来自您数字孪生的上下文作为MCP服务器模型上下文协议服务器,允许开发者通过标准化接口暴露智能体、工具和其他资源,增强生态兼容性。暴露出来,以支持AI智能体。
We will soon expose the context from your digital twin as an MCP server to support AI agents.
浏览器内上下文注入
In-Browser Context Injection
为了创造更具交互性和个性化的网页体验,我们正在开发一项功能,能够将实时上下文直接注入到您的浏览器中,供任何智能体AI应用(如ChatGPT、Perplexity等)访问您的数字孪生。
To create a more interactive and personalized web experience, we are developing a feature to inject real-time context directly into your browser for any agentic AI app (ChatGPT, Perplexity, etc.) to access your digital twin.
总结
Conclusion
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 项目展示了一种创新的方法,将日常网络活动转化为可供AI系统利用的结构化、有意义的上下文。通过结合传统的网络代理技术与现代大型语言模型的自主分析能力,它为构建更个性化、更智能的AI助手铺平了道路。其强调本地化处理和隐私保护的设计理念,也使其在日益关注数据安全的今天显得尤为可贵。对于希望探索AI智能体个性化上下文构建的开发者而言,这是一个极具潜力的起点。
The Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 project demonstrates an innovative approach to transforming everyday web activity into structured, meaningful context for AI systems. By combining traditional web proxy technology with the autonomous analytical capabilities of modern large language models, it paves the way for building more personalized and intelligent AI assistants. Its design philosophy, emphasizing local processing and privacy protection, makes it particularly valuable in today's climate of heightened data security concerns. For developers looking to explore the construction of personalized context for AI agents, this represents a promising starting point.
常见问题(FAQ)
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 如何保护我的浏览隐私?
项目强烈建议使用本地LLM服务(如OllamaA tool for running and managing AI models locally, supporting DeepSeek and other models.、LM StudioA powerful local large model management tool that supports multiple model formats for desktop deployment.),确保浏览数据在本地处理,不会发送给第三方服务,从而保护隐私。
这个代理能为我的AI智能体提供什么帮助?
它能将您的网络浏览流量转化为结构化个人记忆和AI分析报告,为其他智能体应用提供实时上下文,实现个性化响应和需求预判。
Digital Twin Proxy一个开源正向代理工具,通过捕获和分析网络浏览流量,将其转化为AI代理可用的结构化个人记忆,实现上下文工程。 支持哪些AI模型服务?
兼容任何OpenAI兼容的API,包括本地服务(OllamaA tool for running and managing AI models locally, supporting DeepSeek and other models.、LM StudioA powerful local large model management tool that supports multiple model formats for desktop deployment.)和远程服务(OpenAI、Groq等),用户可灵活选择配置。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。