@chengchenccc/oh-my-agent 0.1.1-rc.1

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 (276) hide show
  1. package/README.md +79 -0
  2. package/dist/cli/args.d.ts +24 -0
  3. package/dist/cli/args.d.ts.map +1 -0
  4. package/dist/cli/args.js +120 -0
  5. package/dist/cli/initial-input.d.ts +32 -0
  6. package/dist/cli/initial-input.d.ts.map +1 -0
  7. package/dist/cli/initial-input.js +131 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +3 -0
  11. package/dist/core/__fixtures__/echo-model.d.ts +6 -0
  12. package/dist/core/__fixtures__/echo-model.d.ts.map +1 -0
  13. package/dist/core/__fixtures__/echo-model.js +10 -0
  14. package/dist/core/__fixtures__/mcp-echo-server.d.ts +2 -0
  15. package/dist/core/__fixtures__/mcp-echo-server.d.ts.map +1 -0
  16. package/dist/core/__fixtures__/mcp-echo-server.js +54 -0
  17. package/dist/core/agent-runtime.d.ts +21 -0
  18. package/dist/core/agent-runtime.d.ts.map +1 -0
  19. package/dist/core/agent-runtime.js +14 -0
  20. package/dist/core/memory/autonomous-memory.d.ts +21 -0
  21. package/dist/core/memory/autonomous-memory.d.ts.map +1 -0
  22. package/dist/core/memory/autonomous-memory.js +202 -0
  23. package/dist/core/persistence/in-memory-session-store.d.ts +3 -0
  24. package/dist/core/persistence/in-memory-session-store.d.ts.map +1 -0
  25. package/dist/core/persistence/in-memory-session-store.js +109 -0
  26. package/dist/core/persistence/session-store.contract.d.ts +5 -0
  27. package/dist/core/persistence/session-store.contract.d.ts.map +1 -0
  28. package/dist/core/persistence/session-store.contract.js +183 -0
  29. package/dist/core/persistence/session-store.d.ts +33 -0
  30. package/dist/core/persistence/session-store.d.ts.map +1 -0
  31. package/dist/core/persistence/session-store.js +22 -0
  32. package/dist/core/persistence/session-tree.d.ts +49 -0
  33. package/dist/core/persistence/session-tree.d.ts.map +1 -0
  34. package/dist/core/persistence/session-tree.js +1 -0
  35. package/dist/core/plugins/plugin-code.d.ts +13 -0
  36. package/dist/core/plugins/plugin-code.d.ts.map +1 -0
  37. package/dist/core/plugins/plugin-code.js +62 -0
  38. package/dist/core/plugins/plugin-marketplace.d.ts +72 -0
  39. package/dist/core/plugins/plugin-marketplace.d.ts.map +1 -0
  40. package/dist/core/plugins/plugin-marketplace.js +340 -0
  41. package/dist/core/plugins/plugin-resolve.d.ts +32 -0
  42. package/dist/core/plugins/plugin-resolve.d.ts.map +1 -0
  43. package/dist/core/plugins/plugin-resolve.js +101 -0
  44. package/dist/core/plugins/plugin-trust.d.ts +24 -0
  45. package/dist/core/plugins/plugin-trust.d.ts.map +1 -0
  46. package/dist/core/plugins/plugin-trust.js +89 -0
  47. package/dist/core/runtime/agent-event.d.ts +98 -0
  48. package/dist/core/runtime/agent-event.d.ts.map +1 -0
  49. package/dist/core/runtime/agent-event.js +1 -0
  50. package/dist/core/runtime/agent-loop.d.ts +142 -0
  51. package/dist/core/runtime/agent-loop.d.ts.map +1 -0
  52. package/dist/core/runtime/agent-loop.js +1008 -0
  53. package/dist/core/runtime/approval.d.ts +23 -0
  54. package/dist/core/runtime/approval.d.ts.map +1 -0
  55. package/dist/core/runtime/approval.js +25 -0
  56. package/dist/core/runtime/compaction.d.ts +22 -0
  57. package/dist/core/runtime/compaction.d.ts.map +1 -0
  58. package/dist/core/runtime/compaction.js +90 -0
  59. package/dist/core/runtime/context-estimate.d.ts +42 -0
  60. package/dist/core/runtime/context-estimate.d.ts.map +1 -0
  61. package/dist/core/runtime/context-estimate.js +34 -0
  62. package/dist/core/runtime/create-runtime.d.ts +81 -0
  63. package/dist/core/runtime/create-runtime.d.ts.map +1 -0
  64. package/dist/core/runtime/create-runtime.js +250 -0
  65. package/dist/core/runtime/fake-provider.d.ts +3 -0
  66. package/dist/core/runtime/fake-provider.d.ts.map +1 -0
  67. package/dist/core/runtime/fake-provider.js +87 -0
  68. package/dist/core/runtime/logger.d.ts +13 -0
  69. package/dist/core/runtime/logger.d.ts.map +1 -0
  70. package/dist/core/runtime/logger.js +38 -0
  71. package/dist/core/runtime/loop-input.d.ts +39 -0
  72. package/dist/core/runtime/loop-input.d.ts.map +1 -0
  73. package/dist/core/runtime/loop-input.js +38 -0
  74. package/dist/core/runtime/message-cache.d.ts +16 -0
  75. package/dist/core/runtime/message-cache.d.ts.map +1 -0
  76. package/dist/core/runtime/message-cache.js +23 -0
  77. package/dist/core/runtime/model-catalog.d.ts +10 -0
  78. package/dist/core/runtime/model-catalog.d.ts.map +1 -0
  79. package/dist/core/runtime/model-catalog.js +14 -0
  80. package/dist/core/runtime/plugin-runtime.d.ts +41 -0
  81. package/dist/core/runtime/plugin-runtime.d.ts.map +1 -0
  82. package/dist/core/runtime/plugin-runtime.js +1 -0
  83. package/dist/core/runtime/plugin.d.ts +86 -0
  84. package/dist/core/runtime/plugin.d.ts.map +1 -0
  85. package/dist/core/runtime/plugin.js +23 -0
  86. package/dist/core/runtime/process-tree.d.ts +12 -0
  87. package/dist/core/runtime/process-tree.d.ts.map +1 -0
  88. package/dist/core/runtime/process-tree.js +40 -0
  89. package/dist/core/runtime/prompt.d.ts +23 -0
  90. package/dist/core/runtime/prompt.d.ts.map +1 -0
  91. package/dist/core/runtime/prompt.js +29 -0
  92. package/dist/core/runtime/prompts.d.ts +16 -0
  93. package/dist/core/runtime/prompts.d.ts.map +1 -0
  94. package/dist/core/runtime/prompts.js +36 -0
  95. package/dist/core/runtime/retry.d.ts +20 -0
  96. package/dist/core/runtime/retry.d.ts.map +1 -0
  97. package/dist/core/runtime/retry.js +60 -0
  98. package/dist/core/runtime/run-runtime.d.ts +93 -0
  99. package/dist/core/runtime/run-runtime.d.ts.map +1 -0
  100. package/dist/core/runtime/run-runtime.js +664 -0
  101. package/dist/core/runtime/runtime-catalog.d.ts +12 -0
  102. package/dist/core/runtime/runtime-catalog.d.ts.map +1 -0
  103. package/dist/core/runtime/runtime-catalog.js +89 -0
  104. package/dist/core/runtime/stream-rules.d.ts +9 -0
  105. package/dist/core/runtime/stream-rules.d.ts.map +1 -0
  106. package/dist/core/runtime/stream-rules.js +44 -0
  107. package/dist/core/runtime/title.d.ts +7 -0
  108. package/dist/core/runtime/title.d.ts.map +1 -0
  109. package/dist/core/runtime/title.js +114 -0
  110. package/dist/core/runtime/todo.d.ts +16 -0
  111. package/dist/core/runtime/todo.d.ts.map +1 -0
  112. package/dist/core/runtime/todo.js +40 -0
  113. package/dist/core/runtime/tool-filter.d.ts +12 -0
  114. package/dist/core/runtime/tool-filter.d.ts.map +1 -0
  115. package/dist/core/runtime/tool-filter.js +23 -0
  116. package/dist/core/runtime/tool-pruning.d.ts +29 -0
  117. package/dist/core/runtime/tool-pruning.d.ts.map +1 -0
  118. package/dist/core/runtime/tool-pruning.js +105 -0
  119. package/dist/core/session/input-history.d.ts +8 -0
  120. package/dist/core/session/input-history.d.ts.map +1 -0
  121. package/dist/core/session/input-history.js +41 -0
  122. package/dist/core/session/session-file.d.ts +84 -0
  123. package/dist/core/session/session-file.d.ts.map +1 -0
  124. package/dist/core/session/session-file.js +392 -0
  125. package/dist/core/session/session-loop.d.ts +33 -0
  126. package/dist/core/session/session-loop.d.ts.map +1 -0
  127. package/dist/core/session/session-loop.js +30 -0
  128. package/dist/core/settings/project-settings.d.ts +46 -0
  129. package/dist/core/settings/project-settings.d.ts.map +1 -0
  130. package/dist/core/settings/project-settings.js +85 -0
  131. package/dist/core/settings/workspace-context.d.ts +10 -0
  132. package/dist/core/settings/workspace-context.d.ts.map +1 -0
  133. package/dist/core/settings/workspace-context.js +48 -0
  134. package/dist/core/tools/agent-fs-like.d.ts +15 -0
  135. package/dist/core/tools/agent-fs-like.d.ts.map +1 -0
  136. package/dist/core/tools/agent-fs-like.js +4 -0
  137. package/dist/core/tools/ask-question.d.ts +5 -0
  138. package/dist/core/tools/ask-question.d.ts.map +1 -0
  139. package/dist/core/tools/ask-question.js +51 -0
  140. package/dist/core/tools/bash.d.ts +5 -0
  141. package/dist/core/tools/bash.d.ts.map +1 -0
  142. package/dist/core/tools/bash.js +109 -0
  143. package/dist/core/tools/eval.d.ts +10 -0
  144. package/dist/core/tools/eval.d.ts.map +1 -0
  145. package/dist/core/tools/eval.js +83 -0
  146. package/dist/core/tools/file-tools.d.ts +18 -0
  147. package/dist/core/tools/file-tools.d.ts.map +1 -0
  148. package/dist/core/tools/file-tools.js +249 -0
  149. package/dist/core/tools/glob.d.ts +5 -0
  150. package/dist/core/tools/glob.d.ts.map +1 -0
  151. package/dist/core/tools/glob.js +54 -0
  152. package/dist/core/tools/grep.d.ts +5 -0
  153. package/dist/core/tools/grep.d.ts.map +1 -0
  154. package/dist/core/tools/grep.js +61 -0
  155. package/dist/core/tools/index.d.ts +14 -0
  156. package/dist/core/tools/index.d.ts.map +1 -0
  157. package/dist/core/tools/index.js +14 -0
  158. package/dist/core/tools/ls-tree.d.ts +10 -0
  159. package/dist/core/tools/ls-tree.d.ts.map +1 -0
  160. package/dist/core/tools/ls-tree.js +177 -0
  161. package/dist/core/tools/mcp-mount.d.ts +63 -0
  162. package/dist/core/tools/mcp-mount.d.ts.map +1 -0
  163. package/dist/core/tools/mcp-mount.js +287 -0
  164. package/dist/core/tools/read-image.d.ts +6 -0
  165. package/dist/core/tools/read-image.d.ts.map +1 -0
  166. package/dist/core/tools/read-image.js +98 -0
  167. package/dist/core/tools/skill.d.ts +11 -0
  168. package/dist/core/tools/skill.d.ts.map +1 -0
  169. package/dist/core/tools/skill.js +65 -0
  170. package/dist/core/tools/skills.d.ts +10 -0
  171. package/dist/core/tools/skills.d.ts.map +1 -0
  172. package/dist/core/tools/skills.js +116 -0
  173. package/dist/core/tools/todo-store.d.ts +8 -0
  174. package/dist/core/tools/todo-store.d.ts.map +1 -0
  175. package/dist/core/tools/todo-store.js +100 -0
  176. package/dist/core/tools/todo.d.ts +8 -0
  177. package/dist/core/tools/todo.d.ts.map +1 -0
  178. package/dist/core/tools/todo.js +91 -0
  179. package/dist/core/tools/url-guard.d.ts +12 -0
  180. package/dist/core/tools/url-guard.d.ts.map +1 -0
  181. package/dist/core/tools/url-guard.js +58 -0
  182. package/dist/core/tools/web-ports-std.d.ts +6 -0
  183. package/dist/core/tools/web-ports-std.d.ts.map +1 -0
  184. package/dist/core/tools/web-ports-std.js +145 -0
  185. package/dist/core/tools/web-ports.d.ts +56 -0
  186. package/dist/core/tools/web-ports.d.ts.map +1 -0
  187. package/dist/core/tools/web-ports.js +62 -0
  188. package/dist/core/tools/workspace-sandbox.d.ts +20 -0
  189. package/dist/core/tools/workspace-sandbox.d.ts.map +1 -0
  190. package/dist/core/tools/workspace-sandbox.js +84 -0
  191. package/dist/core/workflow/subagent-registry.d.ts +40 -0
  192. package/dist/core/workflow/subagent-registry.d.ts.map +1 -0
  193. package/dist/core/workflow/subagent-registry.js +118 -0
  194. package/dist/core/workflow/workflow-evaluator.d.ts +23 -0
  195. package/dist/core/workflow/workflow-evaluator.d.ts.map +1 -0
  196. package/dist/core/workflow/workflow-evaluator.js +21 -0
  197. package/dist/core/workflow/workflow-executor.d.ts +108 -0
  198. package/dist/core/workflow/workflow-executor.d.ts.map +1 -0
  199. package/dist/core/workflow/workflow-executor.js +549 -0
  200. package/dist/core/workflow/workflow-tools.d.ts +50 -0
  201. package/dist/core/workflow/workflow-tools.d.ts.map +1 -0
  202. package/dist/core/workflow/workflow-tools.js +217 -0
  203. package/dist/index.d.ts +14 -0
  204. package/dist/index.d.ts.map +1 -0
  205. package/dist/index.js +13 -0
  206. package/dist/main.d.ts +9 -0
  207. package/dist/main.d.ts.map +1 -0
  208. package/dist/main.js +97 -0
  209. package/dist/modes/json-mode.d.ts +5 -0
  210. package/dist/modes/json-mode.d.ts.map +1 -0
  211. package/dist/modes/json-mode.js +46 -0
  212. package/dist/modes/print-mode.d.ts +20 -0
  213. package/dist/modes/print-mode.d.ts.map +1 -0
  214. package/dist/modes/print-mode.js +82 -0
  215. package/dist/modes/rpc/jsonl.d.ts +23 -0
  216. package/dist/modes/rpc/jsonl.d.ts.map +1 -0
  217. package/dist/modes/rpc/jsonl.js +88 -0
  218. package/dist/modes/rpc/rpc-mode.d.ts +18 -0
  219. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
  220. package/dist/modes/rpc/rpc-mode.js +326 -0
  221. package/dist/modes/tui/settings-overlay.d.ts +23 -0
  222. package/dist/modes/tui/settings-overlay.d.ts.map +1 -0
  223. package/dist/modes/tui/settings-overlay.js +136 -0
  224. package/dist/modes/tui/tui-commands-session.d.ts +3 -0
  225. package/dist/modes/tui/tui-commands-session.d.ts.map +1 -0
  226. package/dist/modes/tui/tui-commands-session.js +191 -0
  227. package/dist/modes/tui/tui-commands.d.ts +52 -0
  228. package/dist/modes/tui/tui-commands.d.ts.map +1 -0
  229. package/dist/modes/tui/tui-commands.js +373 -0
  230. package/dist/modes/tui/tui-components.d.ts +81 -0
  231. package/dist/modes/tui/tui-components.d.ts.map +1 -0
  232. package/dist/modes/tui/tui-components.js +248 -0
  233. package/dist/modes/tui/tui-format.d.ts +65 -0
  234. package/dist/modes/tui/tui-format.d.ts.map +1 -0
  235. package/dist/modes/tui/tui-format.js +246 -0
  236. package/dist/modes/tui/tui-frame-provider.d.ts +16 -0
  237. package/dist/modes/tui/tui-frame-provider.d.ts.map +1 -0
  238. package/dist/modes/tui/tui-frame-provider.js +31 -0
  239. package/dist/modes/tui/tui-interactive.d.ts +16 -0
  240. package/dist/modes/tui/tui-interactive.d.ts.map +1 -0
  241. package/dist/modes/tui/tui-interactive.js +123 -0
  242. package/dist/modes/tui/tui-io.d.ts +12 -0
  243. package/dist/modes/tui/tui-io.d.ts.map +1 -0
  244. package/dist/modes/tui/tui-io.js +620 -0
  245. package/dist/modes/tui/tui-mode.d.ts +120 -0
  246. package/dist/modes/tui/tui-mode.d.ts.map +1 -0
  247. package/dist/modes/tui/tui-mode.js +391 -0
  248. package/dist/modes/tui/tui-render.d.ts +54 -0
  249. package/dist/modes/tui/tui-render.d.ts.map +1 -0
  250. package/dist/modes/tui/tui-render.js +399 -0
  251. package/dist/modes/tui/tui-slash.d.ts +12 -0
  252. package/dist/modes/tui/tui-slash.d.ts.map +1 -0
  253. package/dist/modes/tui/tui-slash.js +64 -0
  254. package/dist/modes/tui/tui-tool-render.d.ts +6 -0
  255. package/dist/modes/tui/tui-tool-render.d.ts.map +1 -0
  256. package/dist/modes/tui/tui-tool-render.js +79 -0
  257. package/dist/modes/tui/tui-transcript-reconciler.d.ts +25 -0
  258. package/dist/modes/tui/tui-transcript-reconciler.d.ts.map +1 -0
  259. package/dist/modes/tui/tui-transcript-reconciler.js +97 -0
  260. package/dist/modes/tui/view-state.d.ts +67 -0
  261. package/dist/modes/tui/view-state.d.ts.map +1 -0
  262. package/dist/modes/tui/view-state.js +353 -0
  263. package/dist/prompts/agents/subagent.md +26 -0
  264. package/dist/prompts/system/base.md +20 -0
  265. package/dist/prompts/system/memory.md +23 -0
  266. package/dist/prompts/system/safety.md +12 -0
  267. package/dist/protocol/index.d.ts +5 -0
  268. package/dist/protocol/index.d.ts.map +1 -0
  269. package/dist/protocol/index.js +2 -0
  270. package/dist/protocol/mapping.d.ts +25 -0
  271. package/dist/protocol/mapping.d.ts.map +1 -0
  272. package/dist/protocol/mapping.js +115 -0
  273. package/dist/protocol/transport.d.ts +1396 -0
  274. package/dist/protocol/transport.d.ts.map +1 -0
  275. package/dist/protocol/transport.js +170 -0
  276. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @chengchenccc/oh-my-agent
2
+
3
+ Oma 是本仓库自研的 Agent 执行引擎:既可**独立交互式 TUI**(默认 `oma` 进入终端界面),也可作为无 UI 的一次性 CLI 被 Product Backend 的 Adapter(`@chengchenccc/adapter-oma-agent`)按**每个 Agent Run** spawn 一次。
4
+
5
+ ```text
6
+ Product Backend → Agent Run → Adapter → spawn oma --mode rpc
7
+ → per-Run Runtime → BackendRunOutcome → stdout → child 退出
8
+ ```
9
+
10
+ **不是 daemon**:一个 Run = 一个子进程 = 一个 Runtime = 一个 outcome。没有常驻进程、没有 session supervisor、没有 worker pool。
11
+
12
+ ## TUI
13
+
14
+ 用 `oma`(或 `oma --session <id>`)在终端直接开始交互式会话。
15
+
16
+ - 流式渲染 assistant / tool 事件
17
+ - `ctrl+t` 展开 thinking,`ctrl+o` 展开 tool 详情
18
+ - mermaid fence 渲染为终端 ASCII 图
19
+ - `/resume` 列表/恢复 session,`/fork <n>` 分支
20
+ - 模型选择持久化到项目级 `.oma/settings.json`(standalone TUI 专用;backend→oma 仍以 `agent.yml` 为默认,可被 run 参数覆盖)
21
+ - composer loader 实时摘要当前动作(tool intent / thinking 首行)
22
+
23
+ | Real session | Tools | Mermaid |
24
+ |---|---|---|
25
+ | <img src="../../docs/screenshots/oma-tui-real.png" width="280" alt="Oma TUI real session" /> | <img src="../../docs/screenshots/oma-tui-tools.png" width="280" alt="Oma TUI tools" /> | <img src="../../docs/screenshots/oma-tui-mermaid.png" width="280" alt="Oma TUI mermaid" /> |
26
+
27
+ ## CLI 模式
28
+
29
+ | 模式 | 用途 |
30
+ |---|---|
31
+ | `tui` | 默认;交互式终端会话(一个进程 = N 个 Run 共享一个 session 文件) |
32
+ | `print` | 一次 Run;stdout 只有 final assistant text;stderr 日志;非零退出码表示失败 |
33
+ | `json` | 一次 Run;stdout 全部事件 JSONL + 恰好一个 terminal outcome 行 |
34
+ | `rpc` | 每 Run 一次 `execute` + 可选的 `steer`/`abort`;命令走 stdin,`event`/`outcome`/`response` 走 stdout(严格 LF JSONL,stdout 只承载协议) |
35
+
36
+ `--mode rpc` 是 Adapter 使用的模式。协议 schema 与事件/outcome mapping 定义在契约包 `@chengchenccc/agent-backend`,两侧共用同一份。
37
+
38
+ ## Runtime
39
+
40
+ `createOmaRuntime()`(`src/core/create-runtime.ts`)构造一个 Runtime = 一个 Run:
41
+
42
+ - `run(input)` 返回唯一 segment,其 `outcome` 是 Run 的唯一终态;
43
+ - `steer(input)` 注入 live loop;`stop()` 中止;
44
+ - `close()` 拆除 MCP clients 与 SessionStore。
45
+
46
+ Runtime 内部由 `packages/agent` 提供:OmaSession(model/tool loop、retry、compaction、插件、todo)与 in-memory SessionStore。seed 时把 **full Product history + meta + input** 原子写入,Run 结束即销毁。
47
+
48
+ ## 运行
49
+
50
+ ```bash
51
+ bun run --cwd apps/oh-my-agent dev -- -p "hello" # source CLI (dev)
52
+ bun apps/oh-my-agent/src/cli.ts -p "hello" # source CLI, direct
53
+
54
+ bun run --cwd apps/oh-my-agent build # → dist/cli.js (executable)
55
+ apps/oh-my-agent/dist/cli.js -p "hello" # built binary
56
+
57
+ cd apps/oh-my-agent && bun link # optional local install
58
+ oma -p "hello" # then run from anywhere
59
+ oma # standalone interactive TUI
60
+ ```
61
+
62
+ - 正常由 Backend 通过 `OMA_BIN` spawn(生产:构建后的 `dist/cli.js` 绝对路径;未配置时 Backend 自动用 Bun + 源码入口,dev 无需全局安装或 `bun link`)。
63
+ - `dist/cli.js` 带 `#!/usr/bin/env bun` shebang,构建脚本会设置可执行位。
64
+
65
+ ## 目录
66
+
67
+ ```
68
+ src/
69
+ cli.ts 可执行入口(shebang + runCli())
70
+ main.ts main()/runCli():参数解析、模式分发、退出码(无 process.exit)
71
+ cli/ print/json 模式、初始输入构建、CLI 测试
72
+ modes/ tui / print / json / rpc 模式
73
+ core/ create-runtime.ts(per-Run Runtime 装配)、project-settings.ts(.oma/settings.json)、fake-provider(测试)
74
+ ```
75
+
76
+ ## 相关文档
77
+
78
+ - [架构 Wiki — Oma](docs/architecture/runtime/oma.md)
79
+ - [Agent Backend 协议](docs/architecture/execution/agent-backend.md)
@@ -0,0 +1,24 @@
1
+ export type CliMode = "print" | "json" | "rpc" | "tui";
2
+ export interface CliArgs {
3
+ mode: CliMode;
4
+ /** True when -p/--mode was given explicitly; a bare positional prompt
5
+ * keeps this false so main() can open the TUI with it prefilled. */
6
+ modeExplicit: boolean;
7
+ prompt: string;
8
+ listModels: boolean;
9
+ /** Canonical `<provider>/<model>` id; undefined = first available model. */
10
+ model?: string;
11
+ /** Resume a session file by id (TUI mode). */
12
+ session?: string;
13
+ /** Tool filter: comma-separated tool names or groups. Plain names form a
14
+ * whitelist (ONLY those tools run); `!name` entries form a blacklist
15
+ * (all but those). Applied to the FINAL tool table (native + MCP +
16
+ * plugin) at Run assembly. */
17
+ tools?: string;
18
+ }
19
+ export declare class UsageError extends Error {
20
+ }
21
+ /** Parse argv SYNTAX only: whether a run actually has an input (prompt or
22
+ * piped stdin) is decided in main() after stdin is read. */
23
+ export declare function parseArgs(argv: readonly string[]): CliArgs;
24
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,OAAO,CAAC;IACd;yEACqE;IACrE,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;mCAG+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,UAAW,SAAQ,KAAK;CAAG;AA0BxC;6DAC6D;AAC7D,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CA6E1D"}
@@ -0,0 +1,120 @@
1
+ export class UsageError extends Error {
2
+ }
3
+ const USAGE = `oma - Oma coding agent
4
+
5
+ Usage:
6
+ oma interactive TUI (default in a terminal)
7
+ oma --session <id> resume a session in the TUI
8
+ oma -p "<prompt>" print mode: one Run, final text on stdout
9
+ oma "<prompt>" print mode shorthand
10
+ oma --mode json "<prompt>" json mode: all events + one outcome as JSONL
11
+ oma --mode rpc rpc mode: stdin/stdout JSONL protocol
12
+ oma --list-models print the model catalog as JSON
13
+ oma --model <provider/model> -p "<prompt>"
14
+ pick a model by canonical id
15
+ (default: first available model)
16
+ oma --tools todo_write,read -p "..." only these tools enter the Run
17
+ oma --tools '!todo_write' -p "..." all tools except todo_write
18
+
19
+ Piped stdin (print/json modes):
20
+ cat file | oma -p "Review"
21
+ git diff | oma --mode json "Review"
22
+ cat error.log | oma -p (stdin only)
23
+ `;
24
+ const MODES = ["print", "json", "rpc", "tui"];
25
+ /** Parse argv SYNTAX only: whether a run actually has an input (prompt or
26
+ * piped stdin) is decided in main() after stdin is read. */
27
+ export function parseArgs(argv) {
28
+ const args = {
29
+ mode: "print",
30
+ modeExplicit: false,
31
+ prompt: "",
32
+ listModels: false,
33
+ };
34
+ const positional = [];
35
+ let modeFlag = null;
36
+ let i = 0;
37
+ while (i < argv.length) {
38
+ const arg = argv[i];
39
+ if (arg === "-p") {
40
+ modeFlag = "print";
41
+ args.modeExplicit = true;
42
+ }
43
+ else if (arg === "--mode") {
44
+ const value = argv[i + 1];
45
+ if (!value || !MODES.includes(value)) {
46
+ throw new UsageError(`--mode requires one of: ${MODES.join(" | ")}`);
47
+ }
48
+ modeFlag = value;
49
+ args.modeExplicit = true;
50
+ i++;
51
+ }
52
+ else if (arg.startsWith("--mode=")) {
53
+ const value = arg.slice("--mode=".length);
54
+ if (!MODES.includes(value)) {
55
+ throw new UsageError(`--mode requires one of: ${MODES.join(" | ")}`);
56
+ }
57
+ modeFlag = value;
58
+ args.modeExplicit = true;
59
+ }
60
+ else if (arg === "--list-models") {
61
+ args.listModels = true;
62
+ }
63
+ else if (arg === "--model") {
64
+ const value = argv[i + 1];
65
+ if (!value || value.startsWith("-")) {
66
+ throw new UsageError("--model requires a canonical <provider>/<model> id");
67
+ }
68
+ args.model = value;
69
+ i++;
70
+ }
71
+ else if (arg.startsWith("--model=")) {
72
+ const value = arg.slice("--model=".length);
73
+ if (!value)
74
+ throw new UsageError("--model requires a canonical <provider>/<model> id");
75
+ args.model = value;
76
+ }
77
+ else if (arg === "--session") {
78
+ const value = argv[i + 1];
79
+ if (!value || value.startsWith("-")) {
80
+ throw new UsageError("--session requires a session id");
81
+ }
82
+ args.session = value;
83
+ i++;
84
+ }
85
+ else if (arg.startsWith("--session=")) {
86
+ const value = arg.slice("--session=".length);
87
+ if (!value)
88
+ throw new UsageError("--session requires a session id");
89
+ args.session = value;
90
+ }
91
+ else if (arg === "--tools") {
92
+ const value = argv[i + 1];
93
+ if (!value || value.startsWith("-")) {
94
+ throw new UsageError("--tools requires a comma-separated tool list");
95
+ }
96
+ args.tools = value;
97
+ i++;
98
+ }
99
+ else if (arg.startsWith("--tools=")) {
100
+ const value = arg.slice("--tools=".length);
101
+ if (!value)
102
+ throw new UsageError("--tools requires a comma-separated tool list");
103
+ args.tools = value;
104
+ }
105
+ else if (arg === "--help" || arg === "-h") {
106
+ throw new UsageError(USAGE);
107
+ }
108
+ else if (arg.startsWith("-")) {
109
+ throw new UsageError(`unknown option: ${arg}\n\n${USAGE}`);
110
+ }
111
+ else {
112
+ positional.push(arg);
113
+ }
114
+ i++;
115
+ }
116
+ if (modeFlag)
117
+ args.mode = modeFlag;
118
+ args.prompt = positional.join(" ");
119
+ return args;
120
+ }
@@ -0,0 +1,32 @@
1
+ import type { BackendRunInput } from "@chengchenccc/agent-contract";
2
+ import type { ModelRuntime } from "@chengchenccc/ai";
3
+ /** Standalone skill roots (the Product passes its own via the run snapshot):
4
+ * `<workspace>/.oma/skills` first, then the user-global `<agentDir>/skills`.
5
+ * `skills` in `.oma/settings.json` overrides the defaults (absolute paths,
6
+ * or relative to the workspace root). The `enableClaude` / `enableCodex` /
7
+ * `enableAgents` toggles add Claude / Codex / agent skill dirs to the
8
+ * defaults. Only existing directories are returned. */
9
+ export declare function resolveStandaloneSkillRoots(workspaceRoot: string): string[];
10
+ /** Read piped stdin for print/json one-shot runs. Returns undefined when
11
+ * stdin is a TTY or carries only whitespace. RPC mode NEVER calls this: its
12
+ * stdin is the JSONL command stream. */
13
+ export declare function readPipedStdin(stream?: ReadableStream<Uint8Array>): Promise<string | undefined>;
14
+ /** Merge the CLI prompt with piped stdin: stdin comes FIRST, then a blank
15
+ * line, then the instruction (the classic `git diff | cli -p "review"`
16
+ * shape). Whitespace-only parts are dropped. */
17
+ export declare function mergeInitialInput(input: {
18
+ prompt?: string;
19
+ piped?: string;
20
+ }): string;
21
+ /** Build the BackendRunInput for a one-shot CLI run: current cwd as the
22
+ * workspace, empty Product history, the requested model (canonical
23
+ * `<provider>/<model>` id) or the first available model, no Product Tools,
24
+ * no system prompt. */
25
+ export declare function buildCliRunInput(opts: {
26
+ prompt: string;
27
+ workspaceRoot: string;
28
+ modelRuntime: ModelRuntime;
29
+ /** Canonical `<provider>/<model>` id; undefined = first available. */
30
+ modelId?: string;
31
+ }): Promise<BackendRunInput<"oma">>;
32
+ //# sourceMappingURL=initial-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initial-input.d.ts","sourceRoot":"","sources":["../../src/cli/initial-input.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD;;;;;wDAKwD;AACxD,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAqC3E;AAMD;;yCAEyC;AACzC,wBAAsB,cAAc,CAClC,MAAM,GAAE,cAAc,CAAC,UAAU,CAAsB,GACtD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAED;;iDAEiD;AACjD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAKpF;AAED;;;wBAGwB;AACxB,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAqClC"}
@@ -0,0 +1,131 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { existsSync, statSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { isAbsolute, join } from "node:path";
5
+ import { enabledPluginSkillRoots } from "../core/plugins/plugin-marketplace.js";
6
+ import { buildSystemPrompt, readMemorySummary } from "../core/runtime/prompts.js";
7
+ import { agentDir } from "../core/session/session-file.js";
8
+ import { loadProjectSettings } from "../core/settings/project-settings.js";
9
+ import { readWorkspaceSystemPrompt } from "../core/settings/workspace-context.js";
10
+ import { UsageError } from "./args.js";
11
+ /** Standalone skill roots (the Product passes its own via the run snapshot):
12
+ * `<workspace>/.oma/skills` first, then the user-global `<agentDir>/skills`.
13
+ * `skills` in `.oma/settings.json` overrides the defaults (absolute paths,
14
+ * or relative to the workspace root). The `enableClaude` / `enableCodex` /
15
+ * `enableAgents` toggles add Claude / Codex / agent skill dirs to the
16
+ * defaults. Only existing directories are returned. */
17
+ export function resolveStandaloneSkillRoots(workspaceRoot) {
18
+ const settings = loadProjectSettings(workspaceRoot);
19
+ const configured = settings.skills;
20
+ const candidates = [];
21
+ if (configured && configured.length > 0) {
22
+ for (const p of configured) {
23
+ candidates.push(isAbsolute(p) ? p : join(workspaceRoot, p));
24
+ }
25
+ }
26
+ else {
27
+ candidates.push(join(workspaceRoot, ".oma", "skills"));
28
+ candidates.push(join(agentDir(), "skills"));
29
+ if (settings.enableClaude) {
30
+ candidates.push(join(workspaceRoot, ".claude", "skills"), join(homedir(), ".claude", "skills"));
31
+ }
32
+ if (settings.enableCodex) {
33
+ candidates.push(join(workspaceRoot, ".codex", "skills"), join(homedir(), ".codex", "skills"));
34
+ }
35
+ if (settings.enableAgents) {
36
+ candidates.push(join(workspaceRoot, ".agent", "skills"), join(workspaceRoot, ".agents", "skills"), join(homedir(), ".agent", "skills"), join(homedir(), ".agents", "skills"));
37
+ }
38
+ }
39
+ const roots = [];
40
+ for (const dir of candidates) {
41
+ if (existsSync(dir) && statSync(dir).isDirectory())
42
+ roots.push(dir);
43
+ }
44
+ for (const dir of enabledPluginSkillRoots(workspaceRoot)) {
45
+ if (!roots.includes(dir))
46
+ roots.push(dir);
47
+ }
48
+ return roots;
49
+ }
50
+ /** One-shot CLI stdin bound: a hostile `cat huge-file | oma -p`
51
+ * must not balloon memory. */
52
+ const MAX_STDIN_BYTES = 16 * 1024 * 1024;
53
+ /** Read piped stdin for print/json one-shot runs. Returns undefined when
54
+ * stdin is a TTY or carries only whitespace. RPC mode NEVER calls this: its
55
+ * stdin is the JSONL command stream. */
56
+ export async function readPipedStdin(stream = Bun.stdin.stream()) {
57
+ if (process.stdin.isTTY)
58
+ return undefined;
59
+ const reader = stream.getReader();
60
+ const decoder = new TextDecoder();
61
+ let text = "";
62
+ let bytes = 0;
63
+ try {
64
+ for (;;) {
65
+ const { done, value } = await reader.read();
66
+ if (done)
67
+ break;
68
+ bytes += value.length;
69
+ if (bytes > MAX_STDIN_BYTES) {
70
+ throw new UsageError("piped stdin exceeds 16 MiB");
71
+ }
72
+ text += decoder.decode(value, { stream: true });
73
+ }
74
+ text += decoder.decode();
75
+ }
76
+ finally {
77
+ reader.releaseLock();
78
+ }
79
+ const trimmed = text.trim();
80
+ return trimmed || undefined;
81
+ }
82
+ /** Merge the CLI prompt with piped stdin: stdin comes FIRST, then a blank
83
+ * line, then the instruction (the classic `git diff | cli -p "review"`
84
+ * shape). Whitespace-only parts are dropped. */
85
+ export function mergeInitialInput(input) {
86
+ const parts = [input.piped?.trim(), input.prompt?.trim()].filter((part) => Boolean(part));
87
+ return parts.join("\n\n");
88
+ }
89
+ /** Build the BackendRunInput for a one-shot CLI run: current cwd as the
90
+ * workspace, empty Product history, the requested model (canonical
91
+ * `<provider>/<model>` id) or the first available model, no Product Tools,
92
+ * no system prompt. */
93
+ export async function buildCliRunInput(opts) {
94
+ const catalog = await opts.modelRuntime.getCatalog();
95
+ const model = opts.modelId
96
+ ? catalog.models.find((m) => `${m.providerId}/${m.modelId}` === opts.modelId)
97
+ : catalog.models.find((m) => m.available !== false);
98
+ if (opts.modelId && !model) {
99
+ throw new Error(`model not found in catalog: ${opts.modelId}`);
100
+ }
101
+ if (opts.modelId && model && model.available === false) {
102
+ throw new Error(`model unavailable: ${opts.modelId}`);
103
+ }
104
+ if (!model) {
105
+ throw new Error("no available model in the catalog (check provider credentials)");
106
+ }
107
+ const modelId = `${model.providerId}/${model.modelId}`;
108
+ const runId = `cli-${randomUUID()}`;
109
+ const skillRoots = resolveStandaloneSkillRoots(opts.workspaceRoot);
110
+ const input = {
111
+ input: {
112
+ inputId: `cli-in-${randomUUID()}`,
113
+ message: { role: "user", text: opts.prompt },
114
+ },
115
+ run: {
116
+ runId,
117
+ model: { backendKind: "oma", modelId },
118
+ systemPrompt: buildSystemPrompt({
119
+ workspacePrompt: readWorkspaceSystemPrompt(opts.workspaceRoot),
120
+ memorySummary: readMemorySummary(opts.workspaceRoot),
121
+ cwd: opts.workspaceRoot,
122
+ }),
123
+ configRevision: 0,
124
+ },
125
+ workspace: { root: opts.workspaceRoot, access: "read_write" },
126
+ // Standalone agent: no product conversation/agent/branch identity.
127
+ };
128
+ if (skillRoots.length === 0)
129
+ return input;
130
+ return { ...input, run: { ...input.run, skillRoots } };
131
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ import { runCli } from "./main.js";
3
+ await runCli();
@@ -0,0 +1,6 @@
1
+ import type { AIMessageChunk } from "@chengchenccc/message";
2
+ /** Deterministic scripted model stream: yields one assistant text chunk, a
3
+ * usage record, and end_turn - the minimal shape the agent loop needs to
4
+ * complete a turn. */
5
+ export declare function createEchoModelStream(text: string): () => AsyncIterable<AIMessageChunk>;
6
+ //# sourceMappingURL=echo-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo-model.d.ts","sourceRoot":"","sources":["../../../src/core/__fixtures__/echo-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;uBAEuB;AACvB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,CAMvF"}
@@ -0,0 +1,10 @@
1
+ /** Deterministic scripted model stream: yields one assistant text chunk, a
2
+ * usage record, and end_turn - the minimal shape the agent loop needs to
3
+ * complete a turn. */
4
+ export function createEchoModelStream(text) {
5
+ return async function* () {
6
+ yield { delta: { type: "text", text } };
7
+ yield { usage: { input: 10, output: 3, cacheRead: 1, cacheCreate: 0 } };
8
+ yield { stopReason: "end_turn" };
9
+ };
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mcp-echo-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-echo-server.d.ts","sourceRoot":"","sources":["../../../src/core/__fixtures__/mcp-echo-server.ts"],"names":[],"mappings":""}
@@ -0,0 +1,54 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
4
+ /** Deterministic stdio MCP server for contract tests. Echoes the tool name +
5
+ * the TOP-LEVEL `_meta.identity` it received (the production wire shape:
6
+ * identity rides in call params._meta, never inside arguments), so a test
7
+ * can assert the wire binding of descriptor.name and identity propagation
8
+ * without a Product backend.
9
+ *
10
+ * Modes by `echo` value:
11
+ * - "fail": the call rejects (server error) - failure path.
12
+ * - "slow": the call sleeps 30s - lets a test abort/stop mid-call. */
13
+ const server = new Server({ name: "echo-server", version: "1.0.0" }, { capabilities: { tools: {} } });
14
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
15
+ // MCP_ECHO_TOOLS=todo_write,history_recent renames the offered tools
16
+ // (tests inject "backend-like" product tools); default stays "echo".
17
+ const names = (process.env.MCP_ECHO_TOOLS ?? "echo").split(",").filter(Boolean);
18
+ return {
19
+ tools: names.map((name) => ({
20
+ name,
21
+ description: `Echo ${name}`,
22
+ inputSchema: { type: "object" },
23
+ })),
24
+ };
25
+ });
26
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
27
+ const name = req.params.name;
28
+ const args = (req.params.arguments ?? {});
29
+ const params = req.params;
30
+ if (typeof args.echo === "string" && args.echo.startsWith("slow")) {
31
+ // "slow" sleeps 30s (default); "slow:<ms>" overrides for in-process
32
+ // child-process tests so an aborted call doesn't linger a full 30s. Duration
33
+ // travels in-band because the SDK child env is a safe-list, not the
34
+ // parent's full env.
35
+ const ms = Number(args.echo.split(":")[1] ?? 30_000);
36
+ await new Promise((r) => setTimeout(r, ms));
37
+ }
38
+ if (args.echo === "fail") {
39
+ throw new Error("echo failed on purpose");
40
+ }
41
+ return {
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: JSON.stringify({
46
+ name,
47
+ meta: params._meta ?? null,
48
+ echo: args.echo ?? null,
49
+ }),
50
+ },
51
+ ],
52
+ };
53
+ });
54
+ await server.connect(new StdioServerTransport());
@@ -0,0 +1,21 @@
1
+ export { createInMemorySessionStore } from "./persistence/in-memory-session-store.js";
2
+ export type { AppendBatchInput, AppendBatchResult, SessionStore, } from "./persistence/session-store.js";
3
+ export type { CodingSessionEntry, CodingSessionMetadata, CodingSessionOperation, CodingSessionSnapshot, CompactionEntry, MessageEntry, TodoStateEntry, } from "./persistence/session-tree.js";
4
+ export type { AgentLoopListener, OmaLoopEvent } from "./runtime/agent-event.js";
5
+ export type { ContextBudget, ContextSummarizer, OmaLoopResult, OmaSession, OmaSessionOptions, StreamRule, } from "./runtime/agent-loop.js";
6
+ export { createOmaSession } from "./runtime/agent-loop.js";
7
+ export type { CompactionResult } from "./runtime/compaction.js";
8
+ export { compactSession } from "./runtime/compaction.js";
9
+ export { estimateContextTokens, isSilentContextOverflow, type TurnUsage, type UsageAnchor, usageTotalTokens, } from "./runtime/context-estimate.js";
10
+ export type { CodingLoopInput, LoopInputDeps, LoopInputResult } from "./runtime/loop-input.js";
11
+ export { buildLoopInput } from "./runtime/loop-input.js";
12
+ export type { MetaSectionProvider, Plugin, PluginHooks, PluginTool } from "./runtime/plugin.js";
13
+ export { collectTools, renderMeta, validatePlugins } from "./runtime/plugin.js";
14
+ export type { PluginRuntime } from "./runtime/plugin-runtime.js";
15
+ export type { LoopMetaInput } from "./runtime/prompt.js";
16
+ export { renderLoopMeta } from "./runtime/prompt.js";
17
+ export type { RetryOptions } from "./runtime/retry.js";
18
+ export { retryStream } from "./runtime/retry.js";
19
+ export type { TodoItem, TodoState } from "./runtime/todo.js";
20
+ export { readTodo, updateTodo, writeTodo } from "./runtime/todo.js";
21
+ //# sourceMappingURL=agent-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runtime.d.ts","sourceRoot":"","sources":["../../src/core/agent-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,GACb,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,GACf,MAAM,+BAA+B,CAAC;AAGvC,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAChF,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChF,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,14 @@
1
+ // Phase 2: Oma Runtime
2
+ //
3
+ // Persistence
4
+ export { createInMemorySessionStore } from "./persistence/in-memory-session-store.js";
5
+ export { createOmaSession } from "./runtime/agent-loop.js";
6
+ // Compaction + retry
7
+ export { compactSession } from "./runtime/compaction.js";
8
+ export { estimateContextTokens, isSilentContextOverflow, usageTotalTokens, } from "./runtime/context-estimate.js";
9
+ export { buildLoopInput } from "./runtime/loop-input.js";
10
+ export { collectTools, renderMeta, validatePlugins } from "./runtime/plugin.js";
11
+ export { renderLoopMeta } from "./runtime/prompt.js";
12
+ export { retryStream } from "./runtime/retry.js";
13
+ // Todo
14
+ export { readTodo, updateTodo, writeTodo } from "./runtime/todo.js";
@@ -0,0 +1,21 @@
1
+ import type { ModelRuntime } from "@chengchenccc/ai";
2
+ import { type Message } from "@chengchenccc/message";
3
+ export interface AutonomousMemoryInput {
4
+ modelRuntime: ModelRuntime;
5
+ /** Canonical "<provider>/<model>" of the Run's model. */
6
+ modelId: string;
7
+ workspaceRoot: string;
8
+ runId: string;
9
+ messages: readonly Message[];
10
+ compactions: readonly string[];
11
+ }
12
+ /** Result of one memory-learn pass. `ran` is true when the pipeline made
13
+ * its extraction call (facts may still dedup to zero); false when disabled,
14
+ * empty, or failed — best-effort semantics, never throws. Surfaces use it
15
+ * for the omp-style "learn" indicator. */
16
+ export interface MemoryLearnResult {
17
+ readonly ran: boolean;
18
+ readonly freshFacts: number;
19
+ }
20
+ export declare function extractAutonomousMemory(input: AutonomousMemoryInput): Promise<MemoryLearnResult>;
21
+ //# sourceMappingURL=autonomous-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autonomous-memory.d.ts","sourceRoot":"","sources":["../../../src/core/memory/autonomous-memory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AA2DlE,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,YAAY,CAAC;IAC3B,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAED;;;0CAG0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA+C5B"}