mio-agent-runtime 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +167 -234
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,309 +1,242 @@
1
- # Mio Agent Runtime
1
+ # mio-agent-runtime
2
2
 
3
- > 让所有 AI Agent 共享记忆、观察行为、积累经验——安装一次,无感增强。
3
+ > Your AI agents forget everything between sessions. Mio fixes that.
4
4
 
5
- Mio 是 **Agent Control Plane**:不替代任何 Agent,而是为它们提供统一的智能层。
6
- 安装到 Codex、OpenCode、Hermes、WorkBuddy 后,所有 Agent 的决策、错误和结果自动进入共享记忆,跨 Agent 复用经验。
5
+ Mio is a drop-in intelligence layer for Codex, OpenCode, Hermes, and WorkBuddy. Install once, and every agent you use starts remembering decisions, learning from mistakes, and sharing experience across tools — without any workflow changes.
7
6
 
8
7
  ```
9
- ┌─────────────────────────────────────────────┐
10
- │ 用户的日常工具 │
11
- │ Codex · OpenCode · Hermes · WorkBuddy │
12
- └──────────────────┬──────────────────────────┘
13
- │ MCP
14
- ┌─────────┴─────────┐
15
- │ Mio Intelligence │
16
- │ │
17
- │ Memory │ 决策、上下文、问题记录
18
- │ Observer │ 被动观察 Agent 行为
19
- │ Policy │ 高风险操作拦截
20
- │ Experience │ 跨 Agent 经验复用
21
- │ Ideas │ 记忆驱动的创意生成
22
- │ Evolution │ 生态级优化建议
23
- └───────────────────┘
8
+ Codex ─┐
9
+ OpenCode ─┤── MCP ──> Mio Intelligence Core
10
+ Hermes ─┘ ├─ Memory decisions, context, problems
11
+ ├─ Observer passive session monitoring
12
+ ├─ Policy risk checks before dangerous ops
13
+ ├─ Experience cross-agent knowledge transfer
14
+ ├─ Ideas memory-powered idea generation
15
+ └─ Evolution ecosystem-level optimization
24
16
  ```
25
17
 
26
18
  ---
27
19
 
28
- ## 快速开始
20
+ ## Install
29
21
 
30
22
  ```bash
31
- # 1. 全局安装
32
23
  npm install -g mio-agent-runtime
33
-
34
- # 2. 初始化
35
24
  mio init
36
-
37
- # 3. 接入你使用的 Agent(可多选)
38
- mio install codex # Codex Desktop / CLI
39
- mio install opencode # OpenCode
40
- mio install hermes # Hermes (Nous)
41
- mio install workbuddy # WorkBuddy
42
-
43
- # 4. 查看状态
25
+ mio install codex # or: opencode, hermes, workbuddy
44
26
  mio status
45
27
  ```
46
28
 
47
- 安装完成后**重启对应 Agent**,Mio 即自动生效。无需改变任何使用习惯。
29
+ Restart your agent after install. That's it.
48
30
 
49
31
  ---
50
32
 
51
- ## 核心能力
33
+ ## What it actually does
52
34
 
53
- ### 记忆 — `mio.memory.*`
35
+ **Without Mio**, every agent starts from zero each session. Your Codex forgets why you chose Postgres over Redis. Your OpenCode re-discovers the same config bug. Your WorkBuddy re-reads the same ADR you already explained.
54
36
 
55
- | 工具 | 功能 |
56
- |------|------|
57
- | `mio.memory.record` | 记录决策、上下文、问题、笔记 |
58
- | `mio.memory.query` | 按关键词/标签/类型检索历史记忆 |
59
- | `mio.memory.analyze` | 分析记忆质量:类型分布、重复检测、低质量记录 |
60
- | `mio.memory.archive` | 归档不再需要的记忆(可恢复) |
61
- | `mio.memory.migrate` | 在项目级和全局级之间迁移记忆 |
37
+ **With Mio**, the first agent to solve a problem records the solution. The next agent — any agent — finds it automatically.
62
38
 
63
- ### 观察 — `mio.observer.*`
39
+ ```
40
+ Session 1 (Codex) Session 2 (OpenCode)
41
+ ───────────────── ──────────────────
42
+ "Why not Redis?" "How should we cache?"
43
+ → records decision → queries memory
44
+ → Mio saves it → finds the Redis answer
45
+ → skips the dead end
46
+ ```
64
47
 
65
- | 工具 | 功能 |
66
- |------|------|
67
- | `mio.observer.ingest` | 上报 Agent 事件:工具调用、错误、重试、任务结果 |
68
- | `mio.observer.subscribe` | 订阅特定项目/事件类型的实时通知 |
69
- | `mio.observer.digest` | 拉取自上次以来的新事件 |
48
+ ---
70
49
 
71
- ### 策略 — `mio.policy.*`
50
+ ## CLI Reference
72
51
 
73
- | 工具 | 功能 |
74
- |------|------|
75
- | `mio.policy.check` | 执行高风险操作前检查历史失败率和风险等级 |
52
+ | Command | Description |
53
+ |---------|-------------|
54
+ | `mio init` | Create `~/.mio-intelligence` and default config |
55
+ | `mio install <host>` | Wire MCP + rules + observer into a host |
56
+ | `mio mcp` | Start MCP server (stdio, for agent integration) |
57
+ | `mio status` | Show runtime state, adapter status, observer PID |
58
+ | `mio agents` | List installed hosts |
59
+ | `mio observe` | Foreground session monitor (Ctrl+C to stop) |
60
+ | `mio observe --start` | Start background observer daemon |
61
+ | `mio observe --stop` | Stop background daemon |
62
+ | `mio observe --status` | Check daemon state |
63
+ | `mio observe --once` | Run one collection cycle |
64
+ | `mio --json <cmd>` | Any command outputs JSON |
76
65
 
77
- ### 经验 — `mio.experience.*`
66
+ **What `mio install` does under the hood:**
78
67
 
79
- | 工具 | 功能 |
80
- |------|------|
81
- | `mio.experience.reuse` | 记录一次跨 Agent 经验复用(来源→目标→是否改善结果) |
82
- | `mio.experience.confirm` | 人工确认自动声明的复用记录 |
83
- | `mio.experience.list` | 查询复用证据,按状态/Agent 过滤 |
68
+ ```
69
+ mio install codex
70
+ |
71
+ +-- Writes MCP server config to ~/.codex/config.json
72
+ +-- Injects usage rules into AGENTS.md
73
+ +-- Backfills last 24h of session history
74
+ +-- Starts background passive observer
75
+ ```
84
76
 
85
- ### 任务 — `mio.task.*`
77
+ ---
86
78
 
87
- | 工具 | 功能 |
88
- |------|------|
89
- | `mio.task.route` | 根据历史经验为任务推荐最佳 Agent |
90
- | `mio.task.record_outcome` | 记录任务执行结果(成功/失败/中止) |
79
+ ## MCP Tools (22 tools)
91
80
 
92
- ### Agent — `mio.agent.*`
81
+ ### Memory
93
82
 
94
- | 工具 | 功能 |
95
- |------|------|
96
- | `mio.agent.register` | 注册 Agent 元数据(名称、能力、宿主) |
97
- | `mio.agent.list` | 列出已注册的 Agent |
98
- | `mio.agent.report` | 查询指定 Agent 的能力报告和行为摘要 |
83
+ | Tool | Required | Optional | Description |
84
+ |------|----------|----------|-------------|
85
+ | `mio.memory.record` | `content` | `kind`, `tags`, `project`, `scope`, `source` | Save a decision, context, problem, or note |
86
+ | `mio.memory.query` | `query` | `project`, `limit`, `kind`, `tags`, `scope` | Search memory by keyword, tag, or type |
87
+ | `mio.memory.analyze` | — | `project`, `limit` | Audit quality: duplicates, low-quality, type distribution |
88
+ | `mio.memory.archive` | `ids` | `project`, `restore`, `reason` | Archive records (recoverable) |
89
+ | `mio.memory.migrate` | `ids`, `scope` | `project`, `reason` | Move between project and global layers |
99
90
 
100
- ### 创意 — `mio.idea.*`
91
+ ### Observer
101
92
 
102
- | 工具 | 功能 |
103
- |------|------|
104
- | `mio.idea.generate` | 基于记忆库,用 SCAMPER / 类比 / 第一性原理 / 随机刺激 / 约束反转 五种策略生成创意 |
105
- | `mio.idea.list` | 查询已保存的创意,按目标/策略/时间段过滤 |
93
+ | Tool | Required | Optional | Description |
94
+ |------|----------|----------|-------------|
95
+ | `mio.observer.ingest` | `trace_id`, `event_type` | `payload`, `outcome`, `agent`, `host`, `project` | Report tool calls, errors, retries, task outcomes |
96
+ | `mio.observer.subscribe` | — | `eventTypes`, `project`, `topic`, `ttlDays` | Subscribe to event stream by type/project |
97
+ | `mio.observer.digest` | — | `project`, `eventTypes`, `limit` | Pull new events since last digest |
106
98
 
107
- ### 进化 — `mio.evolution.*`
99
+ ### Policy
108
100
 
109
- | 工具 | 功能 |
110
- |------|------|
111
- | `mio.evolution.report` | 生成生态系统分析报告 |
112
- | `mio.evolution.suggest` | 输出可执行的优化建议(带 nextAction 和 impact) |
101
+ | Tool | Required | Optional | Description |
102
+ |------|----------|----------|-------------|
103
+ | `mio.policy.check` | `action` | `project`, `context` | Pre-flight risk check against historical failure data |
113
104
 
114
- ### 验证 — `mio.phase0.*`
105
+ ### Experience
115
106
 
116
- | 工具 | 功能 |
117
- |------|------|
118
- | `mio.phase0.report` | 生成 Phase 0 跨 Agent 验证报告(JSON / Markdown) |
107
+ | Tool | Required | Optional | Description |
108
+ |------|----------|----------|-------------|
109
+ | `mio.experience.reuse` | `sourceAgent`, `targetAgent`, `experienceId`, `reuse`, `behaviorChanged`, `outcomeImproved` | `notes`, `project` | Record cross-agent experience reuse with evidence |
110
+ | `mio.experience.confirm` | `id` | `confirmedBy`, `notes`, `outcomeImproved` | Human-confirm an auto-claimed reuse record |
111
+ | `mio.experience.list` | — | `status`, `targetAgent`, `limit`, `project` | Query reuse evidence, filter by status |
119
112
 
120
- ---
113
+ ### Task
121
114
 
122
- ## 支持的 Agent 宿主
115
+ | Tool | Required | Optional | Description |
116
+ |------|----------|----------|-------------|
117
+ | `mio.task.route` | `task` | `project`, `scope`, `limit` | Recommend best agent for a task based on history |
118
+ | `mio.task.record_outcome` | — | (event-based) | Record task success/failure/abort |
123
119
 
124
- ### Codex (OpenAI)
120
+ ### Agent
125
121
 
126
- - **接入方式**:修改 `~/.codex/config.json`,注入 `mcpServers.mio`
127
- - **工作流增强**:AGENTS.md 规则注入 → Agent 自动在决策前后调用 Mio
128
- - **被动观察**:不依赖,Codex 默认主动调用 MCP 工具
122
+ | Tool | Required | Optional | Description |
123
+ |------|----------|----------|-------------|
124
+ | `mio.agent.register` | — | (metadata) | Register agent capabilities and host |
125
+ | `mio.agent.list` | — | — | List registered agents |
126
+ | `mio.agent.report` | — | (agent ID) | Query agent behavior summary |
129
127
 
130
- ### OpenCode
128
+ ### Ideas
131
129
 
132
- - **接入方式**:修改 `~/.config/opencode/opencode.json`(MCP)+ `~/.config/opencode/AGENTS.md`(规则)
133
- - **被动观察**:`mio observe` 通过 `opencode db` 增量读取会话数据库,自动提取任务结果和工具错误,写回 `<workspace>/AGENTS.md` 的 `MIO_CONTEXT` 块
134
- - **增量机制**:按 `part` 表的 `rowid` 游标,只传输 `text` / `tool` 类型,首次只回填 24h 内数据
130
+ | Tool | Required | Optional | Description |
131
+ |------|----------|----------|-------------|
132
+ | `mio.idea.generate` | `goal` | `context`, `constraints` | Generate ideas using 5 strategies: SCAMPER, analogy, first-principles, random-stimulus, constraint-inversion |
133
+ | `mio.idea.list` | — | `goal`, `strategy`, `period` | Query saved ideas |
135
134
 
136
- ### Hermes (Nous)
135
+ ### Evolution
137
136
 
138
- - **接入方式**:`hermes mcp add mio-intelligence --command node --args <server>`
139
- - **被动观察**:增量读取 `<LocalAppData>/hermes/state.db`(`messages.id` 自增游标),无需调用 hermes CLI
140
- - **写回策略**:仅当会话发生在真实 git 仓库时写回 `AGENTS.md`,避免污染用户主目录
137
+ | Tool | Required | Optional | Description |
138
+ |------|----------|----------|-------------|
139
+ | `mio.evolution.report` | — | `project` | Ecosystem analysis report |
140
+ | `mio.evolution.suggest` | — | `project` | Actionable optimization suggestions with nextAction + impact |
141
141
 
142
- ### WorkBuddy
142
+ ### Validation
143
143
 
144
- - **接入方式**:写入 `~/.workbuddy/mcp.json` + `~/.workbuddy/mcp-approvals.json`
145
- - **规则注入**:写入 `~/.workbuddy/CODEBUDDY.md`(用户级)+ `<workspace>/AGENTS.md`(项目级)
146
- - **被动观察**:监听 `~/.workbuddy/projects/**/*.jsonl`,自动提取任务结果,写回 `<workspace>/.workbuddy/memory/YYYY-MM-DD.md`
147
-
148
- > 所有宿主的被动观察器共享同一套 schema,数据统一存入 `MIO_HOME`,实现跨 Agent 经验复用。
144
+ | Tool | Required | Optional | Description |
145
+ |------|----------|----------|-------------|
146
+ | `mio.phase0.report` | — | `project`, `format` | Cross-agent value validation report (JSON / Markdown) |
149
147
 
150
148
  ---
151
149
 
152
- ## 被动观察器
153
-
154
- 被动观察器是 Mio 的核心差异化能力:**不依赖 Agent 主动调用,自动采集行为数据。**
155
-
156
- ```text
157
- Agent 会话日志
158
- ↓
159
- mio observe
160
- ↓
161
- ┌──────────────────┐
162
- │ 提取 task_outcome │
163
- │ 提取 tool error │
164
- │ 生成任务摘要 │
165
- └────────┬─────────┘
166
- ↓
167
- MIO_HOME/traces.jsonl ← 统一行为数据
168
- MIO_HOME/memory.jsonl ← 自动记忆
169
- ↓
170
- 写回 Agent 原生记忆文件 ← 单 Agent 闭环
171
- ```
172
-
173
- ### 后台守护进程
174
-
175
- ```bash
176
- mio observe --start # 启动后台守护
177
- mio observe --stop # 停止
178
- mio observe --status # 查看状态
179
- mio observe --once # 执行一次采集周期
180
- mio observe # 前台持续监听(Ctrl+C 停止)
181
- ```
150
+ ## Supported Hosts
182
151
 
183
- ### 增量与去重
152
+ | Host | Config Location | Observer Method | Write-back |
153
+ |------|----------------|-----------------|------------|
154
+ | **Codex** | `~/.codex/config.json` | Not needed (agent calls MCP directly) | AGENTS.md rules |
155
+ | **OpenCode** | `~/.config/opencode/opencode.json` | `opencode db` incremental read | `MIO_CONTEXT` block in AGENTS.md |
156
+ | **Hermes** | `hermes mcp add` | `state.db` cursor (no CLI needed) | AGENTS.md (git repos only) |
157
+ | **WorkBuddy** | `~/.workbuddy/mcp.json` | Tails `projects/**/*.jsonl` | `CODEBUDDY.md` + workspace AGENTS.md |
184
158
 
185
- - 已处理的文件偏移记录在 `MIO_HOME/observe-state.json`,不会重复写入
186
- - 只回填最近 24h 内更新的会话,避免历史灌入
159
+ ### How passive observation works
187
160
 
188
- ---
161
+ Most agents don't call memory tools on their own, even when rules are injected. The passive observer solves this by reading session logs directly:
189
162
 
190
- ## CLI 命令
191
-
192
- ```text
193
- mio init 初始化 MIO_HOME 目录结构
194
- mio mcp 启动 MCP Server(stdio 模式,供 Agent 调用)
195
- mio install <host> 接入指定 Agent(codex|opencode|workbuddy|hermes)
196
- mio status 显示运行时状态和所有 Adapter 状态
197
- mio agents 列出已安装的 Agent
198
- mio observe 观察器管理(见上方)
199
- mio --json status 机器可读的状态输出
200
- mio --json agents 机器可读的 Agent 列表
201
163
  ```
202
-
203
- ### `mio install` 做了什么
204
-
205
- ```text
206
- mio install codex
207
- │
208
- ├── 修改 ~/.codex/config.json → 添加 mio MCP Server
209
- ├── 注入 AGENTS.md 规则 → Agent 自动调用 Mio
210
- ├── 执行一次历史回填 → 被动观察已有会话
211
- └── 启动后台观察器 → 持续采集
164
+ Agent session logs
165
+ |
166
+ mio observe (background daemon)
167
+ |
168
+ +-- Extracts task_outcome, errors, summaries
169
+ +-- Writes to MIO_HOME/traces.jsonl + memory.jsonl
170
+ +-- Writes summary back to agent's native memory file
171
+ |
172
+ Next session: agent sees Mio's notes without calling any tool
212
173
  ```
213
174
 
175
+ - **Incremental**: file offsets tracked in `observe-state.json`, no duplicates
176
+ - **Scoped**: only backfills sessions updated in last 24h
177
+ - **Per-host**: each adapter reads its own format (JSONL / SQLite / DB CLI)
178
+
214
179
  ---
215
180
 
216
- ## MIO_HOME 目录结构
181
+ ## MIO_HOME
217
182
 
218
- 默认 `~/.mio-intelligence`,可通过 `MIO_HOME` 环境变量覆盖。
183
+ Default: `~/.mio-intelligence` (override with `MIO_HOME` env var).
219
184
 
220
- ```text
185
+ ```
221
186
  ~/.mio-intelligence/
222
- ├── config.json 运行时配置(已安装的 Agent 列表)
223
- ├── memory.jsonl 记忆存储(决策、上下文、问题)
224
- ├── traces.jsonl 行为追踪(任务结果、工具调用)
225
- ├── experience-reuse.jsonl 跨 Agent 经验复用记录
226
- ├── ideas.jsonl 生成的创意想法
227
- ├── suggestions.jsonl 进化建议
228
- ├── observe-state.json 观察器增量游标
229
- ├── observe.pid 后台观察器进程 ID
230
- └── logs/ 运行日志
187
+ config.json runtime config + installed hosts
188
+ memory.jsonl decisions, context, problems
189
+ traces.jsonl agent behavior events
190
+ experience-reuse.jsonl cross-agent reuse evidence
191
+ ideas.jsonl generated ideas
192
+ suggestions.jsonl evolution suggestions
193
+ observe-state.json observer increment cursors
194
+ observe.pid background daemon PID
195
+ logs/ runtime logs
231
196
  ```
232
197
 
233
198
  ---
234
199
 
235
- ## 架构定位
236
-
237
- Mio 不是又一个 AI 助手,而是 **Agent 的控制平面**。
238
-
239
- ```text
240
- 传统模式(每个 Agent 独立):
241
-
242
- Codex OpenCode Hermes WorkBuddy
243
- (各自记忆) (各自记忆) (各自记忆) (各自记忆)
244
-
245
- Mio 模式(统一智能层):
200
+ ## Architecture
246
201
 
247
- Codex OpenCode Hermes WorkBuddy
248
- \ | / /
249
- └───────┴────────┴──────────┘
250
- |
251
- Mio Intelligence
252
- ┌──────┴──────┐
253
- │ Memory │ 跨 Agent 共享
254
- │ Observer │ 行为自动采集
255
- │ Policy │ 风险统一管理
256
- │ Experience │ 复用证据链
257
- │ Ideas │ 记忆驱动创意
258
- │ Evolution │ 生态优化
259
- └─────────────┘
260
202
  ```
261
-
262
- ### 核心差异
263
-
264
- | 维度 | Agent Memory | Mio Control Plane |
265
- |------|-------------|-------------------|
266
- | 作用域 | 单 Agent | 多 Agent 生态 |
267
- | 数据采集 | 依赖 Agent 主动调用 | 被动观察 + 主动调用 |
268
- | 经验流动 | 无 | 跨 Agent 复用 + 证据验证 |
269
- | 风险管理 | 无 | 统一策略检查 |
270
- | 优化对象 | 单个 Agent 的记忆 | 整个 Agent 生态的质量和效率 |
271
-
272
- ---
273
-
274
- ## 版本要求
275
-
276
- | 版本 | 能力 |
277
- |------|------|
278
- | `< 0.3.6` | 仅主动 MCP 规则注入 |
279
- | `≥ 0.3.6` | 被动观察 + 无感存取 |
280
- | `≥ 0.5.0` | 创意生成 + 进化建议 |
281
-
282
- ```bash
283
- npm install -g mio-agent-runtime@latest
203
+ Before Mio:
204
+
205
+ Codex ──── (forgets everything)
206
+ OpenCode ── (starts from zero)
207
+ Hermes ──── (isolated memory)
208
+ WorkBuddy ─ (no continuity)
209
+
210
+ After Mio:
211
+
212
+ Codex ─┐
213
+ OpenCode ─┤ Mio Intelligence Core
214
+ Hermes ─┼────> + Memory ........... shared knowledge base
215
+ WorkBuddy ─┘ + Observer ......... automatic data collection
216
+ + Policy ........... risk management
217
+ + Experience ........ cross-agent reuse with evidence
218
+ + Ideas ............ memory-powered creativity
219
+ + Evolution ........ ecosystem optimization
284
220
  ```
285
221
 
286
- ---
287
-
288
- ## 开发
222
+ | | Standalone Agent Memory | Mio Control Plane |
223
+ |---|---|---|
224
+ | **Scope** | Single agent | Multi-agent ecosystem |
225
+ | **Collection** | Agent must call tools | Passive observation + active calls |
226
+ | **Knowledge flow** | Isolated | Shared with reuse evidence |
227
+ | **Risk management** | None | Unified policy checks |
228
+ | **Optimization** | Per-agent | Ecosystem-wide |
289
229
 
290
- ```bash
291
- git clone https://github.com/your-org/akemi-mio.git
292
- cd akemi-mio
293
- node --check server/mio-intelligence-mcp/index.js # 语法检查
294
- npm run check # 全量检查
295
- ```
230
+ ---
296
231
 
297
- ### 发布流程
232
+ ## Version History
298
233
 
299
- ```bash
300
- # 1. 编辑 server/mio-intelligence-mcp/index.js
301
- # 2. 复制到 npm 包目录
302
- cp server/mio-intelligence-mcp/index.js tmp/mio-agent-runtime/package/server/mio-intelligence-mcp/index.js
303
- # 3. 更新版本号
304
- # 4. 发布
305
- cd tmp/mio-agent-runtime/package && npm publish
306
- ```
234
+ | Version | Milestone |
235
+ |---------|-----------|
236
+ | < 0.3.6 | Active MCP rule injection only |
237
+ | >= 0.3.6 | Passive observation + seamless read/write |
238
+ | >= 0.5.0 | Idea generation + evolution suggestions |
239
+ | >= 0.5.6 | Rewritten documentation |
307
240
 
308
241
  ---
309
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",