XiuChengWu d533d0a30e Refactor syscall modules to use async/await patterns
- Updated `DisplaySyscall` to use `tokio::io::AsyncWriteExt` for asynchronous text output.
- Refactored `FsSyscall` to read files asynchronously with offset and length handling.
- Modified `MemorySyscall` to use `tokio::task::spawn_blocking` for database operations, allowing async access to SQLite.
- Enhanced `NetworkSyscall` to utilize `reqwest` for HTTP requests, replacing the previous `curl` command execution.
- Improved `ProcessSyscall` to manage subprocesses with async tasks for stdin, stdout, and stderr handling.
- Updated `TimerSyscall` to simplify timer management.
- Adjusted plugin implementations for better async support and error handling.
- Added `tokio-stream` and `tracing-subscriber` dependencies to `Cargo.toml` for enhanced async stream handling and logging.
2026-06-10 01:26:46 +08:00
2026-06-09 15:09:56 +08:00
2026-06-09 15:09:56 +08:00
2026-06-09 15:09:56 +08:00

Agentsd

AI Agent 的 init 系统 + 内核。对标 Linux 内核 + systemd。

状态:设计草案

对标

Linux Agentsd 说明
内核 syscall 表 9 个 syscall 接口 进程与硬件之间的抽象层
设备驱动 (.ko) 系统插件 实现 syscall(如 alsa = audio 驱动)
systemd unit 插件(basic / standard) 声明依赖、由 init 管理生命周期
systemd(PID 1) agentsd 进程 启动排序、依赖解析、看门狗、日志
D-Bus gRPC over TCP(后续切 UDS/Named Pipe) 进程间通信总线
/dev syscall 接口 插件访问能力的统一入口
cgroup / seccomp 权限白名单 访问控制

架构

标准插件 ← 对标 systemd 管理的应用服务(nginx、docker...)
基础插件 ← 对标 systemd 管理的基础服务(udevd、resolved...)
系统插件 ← 对标 Linux 内核模块 / 设备驱动(.ko)
───────────────────────────────────────
agentsd  ← 对标 Linux 内核 + systemd(PID 1)

9 个系统调用

# syscall Linux 类比
1 Display write(stdout) / framebuffer
2 Audio /dev/snd (ALSA)
3 FS open / read / write / stat / inotify
4 Memory mmap / shmem(面向结构化数据)
5 Network socket / connect / send / recv
6 Process fork / exec / wait / kill
7 Timer timer_create / timerfd
8 HID /dev/input + /dev/fb
9 Input read(stdin) / evdev

三种插件

类型 Linux 类比 通信 依赖
系统插件 内核模块 / 驱动 FFI
基础插件 基础 daemon gRPC/TCP(后续 UDS/Named Pipe) 只 syscall
标准插件 应用服务 gRPC/TCP(后续 UDS/Named Pipe) syscall + 其他插件

agentsd 作为 PID 1 的职责

职责 systemd 对标
启动排序 unit ordering (After/Before)
看门狗 Restart=always
依赖解析 Requires / Wants
日志收集 journald
资源控制 cgroup + seccomp
状态查询 systemctl status
热更新 systemctl reload

文档

文档 内容
01-内核系统调用.md 9 个 syscall 定义(= 内核 syscall 表)
02-插件模型.md 三层插件 + gRPC + 权限(= 驱动 + unit + D-Bus)
03-实施路线.md 阶段进度
04-项目结构.md 代码目录 + 构建说明

当前状态

阶段 1 已完成:内核骨架可运行,9 个 syscall gRPC service + PluginBridge 已注册,Python 测试插件验证全链路通过。默认运行数据写入程序所在目录的 data/ 文件夹。plugins/ai_test 提供手动 AI 验证插件,默认不开启/不自动加载。Release 二进制约 6.1MB。

手动验证

cargo build --release
RUST_LOG=agentsd=info ./target/release/agentsd.exe
python plugins/ai_test/ai_test_plugin.py

plugins/ai_test/plugin.yaml 中设置了 enabled: falseautoload: false,未来实现插件自动加载时应默认跳过它。

Description
No description provided
Readme 262 KiB
Languages
Rust 58.9%
Python 41.1%