@inbrowser/agent 0.0.0-placeholder → 0.2.0

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 (267) hide show
  1. package/AGENTS.md +270 -0
  2. package/LICENSE +21 -0
  3. package/README.md +117 -2
  4. package/bin/agent.ts +10 -0
  5. package/dist/cli/commands/describe.d.ts +14 -0
  6. package/dist/cli/commands/describe.d.ts.map +1 -0
  7. package/dist/cli/commands/describe.js +179 -0
  8. package/dist/cli/commands/describe.js.map +1 -0
  9. package/dist/cli/commands/events.d.ts +21 -0
  10. package/dist/cli/commands/events.d.ts.map +1 -0
  11. package/dist/cli/commands/events.js +59 -0
  12. package/dist/cli/commands/events.js.map +1 -0
  13. package/dist/cli/commands/fleet.d.ts +15 -0
  14. package/dist/cli/commands/fleet.d.ts.map +1 -0
  15. package/dist/cli/commands/fleet.js +149 -0
  16. package/dist/cli/commands/fleet.js.map +1 -0
  17. package/dist/cli/commands/help.d.ts +15 -0
  18. package/dist/cli/commands/help.d.ts.map +1 -0
  19. package/dist/cli/commands/help.js +93 -0
  20. package/dist/cli/commands/help.js.map +1 -0
  21. package/dist/cli/commands/migrate.d.ts +27 -0
  22. package/dist/cli/commands/migrate.d.ts.map +1 -0
  23. package/dist/cli/commands/migrate.js +109 -0
  24. package/dist/cli/commands/migrate.js.map +1 -0
  25. package/dist/cli/commands/run.d.ts +38 -0
  26. package/dist/cli/commands/run.d.ts.map +1 -0
  27. package/dist/cli/commands/run.js +535 -0
  28. package/dist/cli/commands/run.js.map +1 -0
  29. package/dist/cli/commands/schema.d.ts +8 -0
  30. package/dist/cli/commands/schema.d.ts.map +1 -0
  31. package/dist/cli/commands/schema.js +12 -0
  32. package/dist/cli/commands/schema.js.map +1 -0
  33. package/dist/cli/commands/serve.d.ts +39 -0
  34. package/dist/cli/commands/serve.d.ts.map +1 -0
  35. package/dist/cli/commands/serve.js +65 -0
  36. package/dist/cli/commands/serve.js.map +1 -0
  37. package/dist/cli/commands/undo.d.ts +36 -0
  38. package/dist/cli/commands/undo.d.ts.map +1 -0
  39. package/dist/cli/commands/undo.js +132 -0
  40. package/dist/cli/commands/undo.js.map +1 -0
  41. package/dist/cli/fixtures.d.ts +17 -0
  42. package/dist/cli/fixtures.d.ts.map +1 -0
  43. package/dist/cli/fixtures.js +107 -0
  44. package/dist/cli/fixtures.js.map +1 -0
  45. package/dist/cli/hardening.d.ts +39 -0
  46. package/dist/cli/hardening.d.ts.map +1 -0
  47. package/dist/cli/hardening.js +68 -0
  48. package/dist/cli/hardening.js.map +1 -0
  49. package/dist/cli/index.d.ts +28 -0
  50. package/dist/cli/index.d.ts.map +1 -0
  51. package/dist/cli/index.js +19 -0
  52. package/dist/cli/index.js.map +1 -0
  53. package/dist/cli/llm/openrouter.d.ts +33 -0
  54. package/dist/cli/llm/openrouter.d.ts.map +1 -0
  55. package/dist/cli/llm/openrouter.js +285 -0
  56. package/dist/cli/llm/openrouter.js.map +1 -0
  57. package/dist/cli/main.d.ts +32 -0
  58. package/dist/cli/main.d.ts.map +1 -0
  59. package/dist/cli/main.js +106 -0
  60. package/dist/cli/main.js.map +1 -0
  61. package/dist/cli/output.d.ts +36 -0
  62. package/dist/cli/output.d.ts.map +1 -0
  63. package/dist/cli/output.js +95 -0
  64. package/dist/cli/output.js.map +1 -0
  65. package/dist/cli/parse.d.ts +26 -0
  66. package/dist/cli/parse.d.ts.map +1 -0
  67. package/dist/cli/parse.js +160 -0
  68. package/dist/cli/parse.js.map +1 -0
  69. package/dist/cli/session-log.d.ts +34 -0
  70. package/dist/cli/session-log.d.ts.map +1 -0
  71. package/dist/cli/session-log.js +52 -0
  72. package/dist/cli/session-log.js.map +1 -0
  73. package/dist/cli/spec.d.ts +62 -0
  74. package/dist/cli/spec.d.ts.map +1 -0
  75. package/dist/cli/spec.js +510 -0
  76. package/dist/cli/spec.js.map +1 -0
  77. package/dist/cli/ui/RunView.d.ts +134 -0
  78. package/dist/cli/ui/RunView.d.ts.map +1 -0
  79. package/dist/cli/ui/RunView.js +341 -0
  80. package/dist/cli/ui/RunView.js.map +1 -0
  81. package/dist/diagnostics/index.d.ts +5 -0
  82. package/dist/diagnostics/index.d.ts.map +1 -0
  83. package/dist/diagnostics/index.js +3 -0
  84. package/dist/diagnostics/index.js.map +1 -0
  85. package/dist/diagnostics/timing.d.ts +48 -0
  86. package/dist/diagnostics/timing.d.ts.map +1 -0
  87. package/dist/diagnostics/timing.js +85 -0
  88. package/dist/diagnostics/timing.js.map +1 -0
  89. package/dist/diagnostics/truthfulness.d.ts +36 -0
  90. package/dist/diagnostics/truthfulness.d.ts.map +1 -0
  91. package/dist/diagnostics/truthfulness.js +180 -0
  92. package/dist/diagnostics/truthfulness.js.map +1 -0
  93. package/dist/dispatch-memoization.d.ts +84 -0
  94. package/dist/dispatch-memoization.d.ts.map +1 -0
  95. package/dist/dispatch-memoization.js +197 -0
  96. package/dist/dispatch-memoization.js.map +1 -0
  97. package/dist/eval/comparison-report.d.ts +164 -0
  98. package/dist/eval/comparison-report.d.ts.map +1 -0
  99. package/dist/eval/comparison-report.js +316 -0
  100. package/dist/eval/comparison-report.js.map +1 -0
  101. package/dist/eval/fixture.d.ts +74 -0
  102. package/dist/eval/fixture.d.ts.map +1 -0
  103. package/dist/eval/fixture.js +217 -0
  104. package/dist/eval/fixture.js.map +1 -0
  105. package/dist/eval/index.d.ts +13 -0
  106. package/dist/eval/index.d.ts.map +1 -0
  107. package/dist/eval/index.js +7 -0
  108. package/dist/eval/index.js.map +1 -0
  109. package/dist/eval/load-node.d.ts +16 -0
  110. package/dist/eval/load-node.d.ts.map +1 -0
  111. package/dist/eval/load-node.js +58 -0
  112. package/dist/eval/load-node.js.map +1 -0
  113. package/dist/eval/metric-collector.d.ts +209 -0
  114. package/dist/eval/metric-collector.d.ts.map +1 -0
  115. package/dist/eval/metric-collector.js +293 -0
  116. package/dist/eval/metric-collector.js.map +1 -0
  117. package/dist/eval/run-record.d.ts +76 -0
  118. package/dist/eval/run-record.d.ts.map +1 -0
  119. package/dist/eval/run-record.js +32 -0
  120. package/dist/eval/run-record.js.map +1 -0
  121. package/dist/eval/runner.d.ts +140 -0
  122. package/dist/eval/runner.d.ts.map +1 -0
  123. package/dist/eval/runner.js +310 -0
  124. package/dist/eval/runner.js.map +1 -0
  125. package/dist/eval/spec-framework.d.ts +113 -0
  126. package/dist/eval/spec-framework.d.ts.map +1 -0
  127. package/dist/eval/spec-framework.js +100 -0
  128. package/dist/eval/spec-framework.js.map +1 -0
  129. package/dist/eval/spec-helpers.d.ts +245 -0
  130. package/dist/eval/spec-helpers.d.ts.map +1 -0
  131. package/dist/eval/spec-helpers.js +605 -0
  132. package/dist/eval/spec-helpers.js.map +1 -0
  133. package/dist/events/codec.d.ts +79 -0
  134. package/dist/events/codec.d.ts.map +1 -0
  135. package/dist/events/codec.js +142 -0
  136. package/dist/events/codec.js.map +1 -0
  137. package/dist/events/log-core.d.ts +76 -0
  138. package/dist/events/log-core.d.ts.map +1 -0
  139. package/dist/events/log-core.js +73 -0
  140. package/dist/events/log-core.js.map +1 -0
  141. package/dist/events/log.d.ts +60 -0
  142. package/dist/events/log.d.ts.map +1 -0
  143. package/dist/events/log.js +193 -0
  144. package/dist/events/log.js.map +1 -0
  145. package/dist/events/replay.d.ts +106 -0
  146. package/dist/events/replay.d.ts.map +1 -0
  147. package/dist/events/replay.js +137 -0
  148. package/dist/events/replay.js.map +1 -0
  149. package/dist/events/wrap.d.ts +100 -0
  150. package/dist/events/wrap.d.ts.map +1 -0
  151. package/dist/events/wrap.js +141 -0
  152. package/dist/events/wrap.js.map +1 -0
  153. package/dist/index.d.ts +73 -0
  154. package/dist/index.d.ts.map +1 -0
  155. package/dist/index.js +47 -0
  156. package/dist/index.js.map +1 -0
  157. package/dist/llm-adapter.d.ts +96 -0
  158. package/dist/llm-adapter.d.ts.map +1 -0
  159. package/dist/llm-adapter.js +132 -0
  160. package/dist/llm-adapter.js.map +1 -0
  161. package/dist/mcp/serve.d.ts +70 -0
  162. package/dist/mcp/serve.d.ts.map +1 -0
  163. package/dist/mcp/serve.js +154 -0
  164. package/dist/mcp/serve.js.map +1 -0
  165. package/dist/metrics/runs.d.ts +58 -0
  166. package/dist/metrics/runs.d.ts.map +1 -0
  167. package/dist/metrics/runs.js +99 -0
  168. package/dist/metrics/runs.js.map +1 -0
  169. package/dist/metrics.d.ts +38 -0
  170. package/dist/metrics.d.ts.map +1 -0
  171. package/dist/metrics.js +123 -0
  172. package/dist/metrics.js.map +1 -0
  173. package/dist/node.d.ts +23 -0
  174. package/dist/node.d.ts.map +1 -0
  175. package/dist/node.js +23 -0
  176. package/dist/node.js.map +1 -0
  177. package/dist/planner-executor.d.ts +132 -0
  178. package/dist/planner-executor.d.ts.map +1 -0
  179. package/dist/planner-executor.js +274 -0
  180. package/dist/planner-executor.js.map +1 -0
  181. package/dist/session.d.ts +10 -0
  182. package/dist/session.d.ts.map +1 -0
  183. package/dist/session.js +179 -0
  184. package/dist/session.js.map +1 -0
  185. package/dist/skill-catalog.d.ts +81 -0
  186. package/dist/skill-catalog.d.ts.map +1 -0
  187. package/dist/skill-catalog.js +388 -0
  188. package/dist/skill-catalog.js.map +1 -0
  189. package/dist/skill-router.d.ts +95 -0
  190. package/dist/skill-router.d.ts.map +1 -0
  191. package/dist/skill-router.js +130 -0
  192. package/dist/skill-router.js.map +1 -0
  193. package/dist/storage.d.ts +14 -0
  194. package/dist/storage.d.ts.map +1 -0
  195. package/dist/storage.js +58 -0
  196. package/dist/storage.js.map +1 -0
  197. package/dist/strategy.d.ts +45 -0
  198. package/dist/strategy.d.ts.map +1 -0
  199. package/dist/strategy.js +520 -0
  200. package/dist/strategy.js.map +1 -0
  201. package/dist/tools.d.ts +40 -0
  202. package/dist/tools.d.ts.map +1 -0
  203. package/dist/tools.js +147 -0
  204. package/dist/tools.js.map +1 -0
  205. package/dist/types/agent.d.ts +94 -0
  206. package/dist/types/agent.d.ts.map +1 -0
  207. package/dist/types/agent.js +17 -0
  208. package/dist/types/agent.js.map +1 -0
  209. package/dist/types/capabilities.d.ts +17 -0
  210. package/dist/types/capabilities.d.ts.map +1 -0
  211. package/dist/types/capabilities.js +13 -0
  212. package/dist/types/capabilities.js.map +1 -0
  213. package/dist/types/chat.d.ts +74 -0
  214. package/dist/types/chat.d.ts.map +1 -0
  215. package/dist/types/chat.js +10 -0
  216. package/dist/types/chat.js.map +1 -0
  217. package/dist/types/events.d.ts +115 -0
  218. package/dist/types/events.d.ts.map +1 -0
  219. package/dist/types/events.js +30 -0
  220. package/dist/types/events.js.map +1 -0
  221. package/dist/types/llm.d.ts +89 -0
  222. package/dist/types/llm.d.ts.map +1 -0
  223. package/dist/types/llm.js +12 -0
  224. package/dist/types/llm.js.map +1 -0
  225. package/dist/types/metrics.d.ts +34 -0
  226. package/dist/types/metrics.d.ts.map +1 -0
  227. package/dist/types/metrics.js +10 -0
  228. package/dist/types/metrics.js.map +1 -0
  229. package/dist/types/observer.d.ts +41 -0
  230. package/dist/types/observer.d.ts.map +1 -0
  231. package/dist/types/observer.js +41 -0
  232. package/dist/types/observer.js.map +1 -0
  233. package/dist/types/project-context.d.ts +18 -0
  234. package/dist/types/project-context.d.ts.map +1 -0
  235. package/dist/types/project-context.js +11 -0
  236. package/dist/types/project-context.js.map +1 -0
  237. package/dist/types/runtime.d.ts +71 -0
  238. package/dist/types/runtime.d.ts.map +1 -0
  239. package/dist/types/runtime.js +21 -0
  240. package/dist/types/runtime.js.map +1 -0
  241. package/dist/types/session.d.ts +103 -0
  242. package/dist/types/session.d.ts.map +1 -0
  243. package/dist/types/session.js +11 -0
  244. package/dist/types/session.js.map +1 -0
  245. package/dist/types/storage.d.ts +20 -0
  246. package/dist/types/storage.d.ts.map +1 -0
  247. package/dist/types/storage.js +41 -0
  248. package/dist/types/storage.js.map +1 -0
  249. package/dist/types/strategy.d.ts +124 -0
  250. package/dist/types/strategy.d.ts.map +1 -0
  251. package/dist/types/strategy.js +10 -0
  252. package/dist/types/strategy.js.map +1 -0
  253. package/dist/types/tools.d.ts +154 -0
  254. package/dist/types/tools.d.ts.map +1 -0
  255. package/dist/types/tools.js +11 -0
  256. package/dist/types/tools.js.map +1 -0
  257. package/dist/types/trace.d.ts +175 -0
  258. package/dist/types/trace.d.ts.map +1 -0
  259. package/dist/types/trace.js +26 -0
  260. package/dist/types/trace.js.map +1 -0
  261. package/dist/types/workspace.d.ts +29 -0
  262. package/dist/types/workspace.d.ts.map +1 -0
  263. package/dist/types/workspace.js +18 -0
  264. package/dist/types/workspace.js.map +1 -0
  265. package/package.json +45 -14
  266. package/skills/agent-cli.md +218 -0
  267. package/index.js +0 -2
package/AGENTS.md ADDED
@@ -0,0 +1,270 @@
1
+ # AGENTS.md — `@inbrowser/agent`
2
+
3
+ This file is for AI agents driving the `agent` CLI. Read it before
4
+ your first invocation. Invariants are listed first; rationale and
5
+ worked examples follow.
6
+
7
+ ## Invariants (always-do)
8
+
9
+ 1. **Pipe NDJSON.** The CLI auto-selects `--output ndjson` when stdout
10
+ is not a TTY. Parse each line as a JSON object. Never grep prose.
11
+ 2. **Use `--json -` for mutating commands** when the input contains
12
+ anything non-trivial (newlines, JSON, long prompts). The raw
13
+ payload maps 1:1 to the run signature — no flag translation loss.
14
+ 3. **Use `--dry-run` first** when you're about to mutate state. `run`
15
+ and `fleet` honor it; the response is a single `dry_run_plan`
16
+ event you can inspect before re-invoking without the flag.
17
+ 4. **Filter with `--fields`** when you only need a slice of each
18
+ event. Example: `--fields ts,type,sessionId,ok,summary`. Saves
19
+ tokens proportional to event payload size.
20
+ 5. **Trust `--help --json` (or pipe to `cat`).** When stdout is not a
21
+ TTY, `agent help <command>` emits a structured object. When it
22
+ is, you get prose. The structure is the contract.
23
+ 6. **Treat `session_end` as the source of truth.** Its `totals` field
24
+ has the canonical cost / tokens summary; everything before it can
25
+ be transient.
26
+
27
+ ## Don't (anti-patterns)
28
+
29
+ - Don't parse text output. It's for humans. The TTY format is not
30
+ versioned.
31
+ - Don't infer the schema from `--help`. Call `agent schema` or
32
+ `agent describe` and cache the result.
33
+ - Don't write session ids by hand if you can let the CLI generate
34
+ them. Generated ids are guaranteed to pass hardening.
35
+ - Don't pass paths with `..` or URL-encoded segments. The hardening
36
+ layer rejects them and you'll burn a turn on the retry.
37
+
38
+ ## Workflow patterns
39
+
40
+ ### Run a single session, capture totals
41
+
42
+ ```bash
43
+ agent run --json - <<'EOF'
44
+ {"prompt": "build a chess board", "scenario": "write-rules", "maxTurns": 4}
45
+ EOF
46
+ ```
47
+
48
+ Or programmatically: take the last NDJSON line, parse it, and read
49
+ `totals.tokensTotal` and `totals.costUsd`.
50
+
51
+ ### Discover the schema
52
+
53
+ ```bash
54
+ agent schema # full CliSpec
55
+ agent describe --target events # NDJSON event catalog only
56
+ ```
57
+
58
+ The schema's `commands[*].options[*]` includes the same `validate`
59
+ rules the parser enforces — you can pre-validate inputs in your
60
+ agent before invoking.
61
+
62
+ ### Validate without side effects
63
+
64
+ ```bash
65
+ agent run --prompt "$PROMPT" --dry-run
66
+ agent fleet --size 10 --dry-run
67
+ ```
68
+
69
+ Each emits exactly one `dry_run_plan` event.
70
+
71
+ ### Run many sessions in parallel
72
+
73
+ ```bash
74
+ agent fleet --size 10
75
+ ```
76
+
77
+ The `fleet_summary` event at the end reports per-session totals plus
78
+ an `isolated` boolean. Treat `isolated: false` as a hard failure.
79
+
80
+ ## Per-session logs
81
+
82
+ Every `run` writes its full event stream to:
83
+
84
+ ```
85
+ ~/.pyric/sessions/<sessionId>.ndjson
86
+ ```
87
+
88
+ Last line is always `session_end` with totals. Tail with:
89
+
90
+ ```bash
91
+ tail -1 ~/.pyric/sessions/<sessionId>.ndjson | jq '.totals'
92
+ ```
93
+
94
+ Override with `--log-dir <abs-path>`. Disable with `--no-log`.
95
+
96
+ ## Wrap on the producer, NOT on the consumer
97
+
98
+ **Critical invariant for anyone using `wrapMutating()` + `replayEvents()`.**
99
+
100
+ Wrap your handlers on the system that **produces** the log (the dev
101
+ environment, the agent session that generates mutations). Do NOT
102
+ wrap on the system that **consumes** the log via `replayEvents`. If
103
+ you do, each replayed event spawns its own plan+commit cascade on
104
+ the target log — and a subsequent replay run would try to re-replay
105
+ those, ad infinitum.
106
+
107
+ ```
108
+ DEV (producer) PROD (replay consumer)
109
+ ────────────── ──────────────────────
110
+ wrapMutating(setDoc, { log, ... }) setDoc ← bare!
111
+ deleteDoc ← bare!
112
+ ```
113
+
114
+ `isWrappedHandler(handler)` returns `true` for any output of
115
+ `wrapMutating`. Use it to assert your prod registry is safe before
116
+ calling `replayEvents` against it.
117
+
118
+ ## Non-JSON-safe types — use a codec
119
+
120
+ `wrapMutating` stores `args`, `before`, `after` in the log. The
121
+ default `JSON.stringify` is lossy for the exact types real Firebase
122
+ code uses (`Timestamp`, `FieldValue.serverTimestamp()`,
123
+ `DocumentReference`, `Date`, `Uint8Array`, `bigint`). Without a
124
+ codec, replay can silently write the wrong types to prod.
125
+
126
+ The shipped default `defaultEventValueCodec` handles the universal
127
+ non-JSON types — `Date`, `Uint8Array`, `bigint` — via tagged
128
+ envelopes. For Firestore-specific types, compose your own codec on
129
+ top using `walkValue`:
130
+
131
+ ```ts
132
+ import { composeCodecs, defaultEventValueCodec, openEventLog, walkValue, type EventValueCodec, ENVELOPE_KEY } from '@inbrowser/agent';
133
+ import { Timestamp } from 'firebase-admin/firestore';
134
+
135
+ const firestoreCodec: EventValueCodec = {
136
+ encode: (v) => walkValue(v, (n) => {
137
+ if (n instanceof Timestamp) return { [ENVELOPE_KEY]: 'Timestamp', seconds: n.seconds, nanoseconds: n.nanoseconds };
138
+ return undefined;
139
+ }),
140
+ decode: (v) => walkValue(v, (n) => {
141
+ if (typeof n === 'object' && n !== null && (n as any).__pyric === 'Timestamp') {
142
+ return new Timestamp((n as any).seconds, (n as any).nanoseconds);
143
+ }
144
+ return undefined;
145
+ }),
146
+ };
147
+
148
+ const codec = composeCodecs(firestoreCodec, defaultEventValueCodec);
149
+ const log = openEventLog({ projectId: 'my-app', codec });
150
+ // Pass the same codec to `openEventLog` on the prod side so decode matches.
151
+ ```
152
+
153
+ `identityCodec` is also available for tests / when args are known
154
+ JSON-clean (slightly cheaper since it skips the walk).
155
+
156
+ ## Per-project event log (observability + undo)
157
+
158
+ Distinct from the per-session log above. Every **mutating tool** that
159
+ wraps itself in `wrapMutating()` from `@inbrowser/agent` emits one or more
160
+ events to:
161
+
162
+ ```
163
+ ~/.pyric/projects/<projectId>/events.ndjson
164
+ ```
165
+
166
+ Each event has a stable id, a phase (`plan` | `commit` | `rollback`),
167
+ a target (`{kind, path}`), optional `before`/`after` snapshots, and —
168
+ when the API permits rollback — a `reverseOp` (`{tool, args}`) that
169
+ `agent undo` can invoke.
170
+
171
+ Read the log:
172
+
173
+ ```bash
174
+ agent events --project my-app # full log
175
+ agent events --project my-app --phase commit # just commits
176
+ agent events --project my-app --tool writeRules # one tool
177
+ agent events --project my-app --session sess-2026-05-11-abc # one session
178
+ agent events --project my-app --since 2026-05-11T00:00:00Z # time range
179
+ ```
180
+
181
+ Reverse a commit:
182
+
183
+ ```bash
184
+ agent undo --project my-app --event <id> --dry-run # show plan
185
+ agent undo --project my-app --event <id> # record rollback
186
+ ```
187
+
188
+ Important:
189
+ - `agent undo` **does not invoke the reverse tool itself.** It records
190
+ a `rollback` event referencing the original and surfaces the
191
+ recorded `reverseOp`. Your host (the playground, a specialized-agent
192
+ process) is responsible for dispatching the tool — the CLI is a
193
+ controller surface, not a Firebase admin runtime.
194
+ - Events with `reversible: false` are rejected up front with the
195
+ recorded `irreversibleReason`.
196
+ - Idempotent — undoing the same event twice returns `AlreadyUndone`
197
+ (exit 64), never double-rolls.
198
+
199
+ ## Forward replay (dev → prod migrations)
200
+
201
+ The same log that powers `agent undo` is a forward-replayable migration
202
+ record. Every `commit` event carries the original `args`, so a different
203
+ `ToolDispatch` can re-execute the same operations against a different
204
+ environment (typical case: `dev` simulator log → live Firestore).
205
+
206
+ CLI surface (planning only):
207
+
208
+ ```bash
209
+ # Plan: list every replayable commit (NDJSON, one `migrate_plan` per event).
210
+ agent migrate --project my-app
211
+
212
+ # Filter: from a known anchor, restricted to specific tools.
213
+ agent migrate --project my-app --since-event <id> --tools setDoc,writeRules
214
+
215
+ # Record an intent marker the host can pick up.
216
+ agent migrate --project my-app --record
217
+ ```
218
+
219
+ Host surface (actually replays):
220
+
221
+ ```ts
222
+ import { openEventLog, replayEvents } from '@inbrowser/agent';
223
+
224
+ const log = openEventLog({ projectId: 'my-app' }); // dev log
225
+ const dispatch = buildProdToolDispatch(); // your prod registry
226
+ for await (const ev of replayEvents({ log, dispatch, toolContext })) {
227
+ if (ev.type === 'error') break;
228
+ }
229
+ ```
230
+
231
+ Important:
232
+ - Same controller/runtime split as `agent undo`: the CLI does NOT
233
+ invoke tools. It records intent + lists the plan; the host calls
234
+ `replayEvents()` against its production registry.
235
+ - Idempotent across re-runs. Each successfully-applied event gets a
236
+ `migrate_applied` marker; a re-run skips events whose marker is
237
+ already present.
238
+ - Legacy events (no `args` field — emitted before the field was added)
239
+ are skipped by default. Pass `legacyEventPolicy: 'abort'` to fail
240
+ loudly instead.
241
+ - Reverse direction is `agent undo`; forward direction is `replayEvents()`.
242
+ They share the same log.
243
+
244
+ ## Exit codes
245
+
246
+ | Code | Meaning |
247
+ | ---- | ------------------------------------------- |
248
+ | 0 | Success |
249
+ | 1 | Runtime error (session-level) |
250
+ | 2 | Unhandled exception (CLI bug — file a bug) |
251
+ | 64 | Usage error or input hardening rejection |
252
+
253
+ ## Scoring (per agent-dx-cli-scale)
254
+
255
+ | Axis | Score | Notes |
256
+ | ------------------------------------- | ----- | ------------------------------------------------------------------------------ |
257
+ | 1. Machine-Readable Output | 3 | NDJSON streaming default in non-TTY; JSON errors; structured everywhere. |
258
+ | 2. Raw Payload Input | 3 | `--json -` (stdin) or `--json <file>` for `run`; payload mirrors handler sig. |
259
+ | 3. Schema Introspection | 2 | `agent schema`, `agent describe`, `--help --json`. All commands covered. |
260
+ | 4. Context Window Discipline | 3 | `--fields` allowlist + per-event NDJSON streaming + `agent events` filters. |
261
+ | 5. Input Hardening | 3 | Rejects control chars, `..`, `%2e`, `?`, `#`, oversized strings; path sandbox. |
262
+ | 6. Safety Rails | 3 | `--dry-run` on `run`/`fleet`/`undo`; idempotent undo + replay; irreversible-event gate. |
263
+ | 7. Agent Knowledge Packaging | 2 | This file + `skills/agent-cli.md`. Versioned with the package. |
264
+ | **Total** | **19** | **Agent-first** |
265
+
266
+ The event log lifts the score on axes 4 and 6: it gives agents a
267
+ typed substrate to audit, reverse, and replay mutations without
268
+ re-scraping provider APIs. `agent migrate` extends the
269
+ controller/runtime split (CLI plans, host dispatches) that `agent undo`
270
+ established — same shape, opposite direction.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David East
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # agent.js
1
+ # `@inbrowser/agent`
2
2
 
3
- Browser-native agent runtime. Coming soon.
3
+ Agent runtime + agent-friendly CLI in one package. Three consumer surfaces:
4
+
5
+ - **Library** — `import { createAgentSession, createToolRegistry, ... }`. Pure TypeScript, no React, no DOM, no fetch. The playground UI consumes the same primitives.
6
+ - **CLI** — the `agent` binary. NDJSON output by default, `--json` stdin, `--dry-run`, schema introspection, automatic session logs.
7
+ - **MCP server** — `agent serve` exposes agent tools over stdio so external LLM hosts (Claude Desktop, others) can drive them as MCP tools.
8
+
9
+ The library is browser-safe; the CLI and MCP server are Node-only.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ bun add @inbrowser/agent
15
+ # or
16
+ npm install @inbrowser/agent
17
+ ```
18
+
19
+ The `agent` binary lands in `./node_modules/.bin/`.
20
+
21
+ ## A 30-second example
22
+
23
+ ### Library
24
+
25
+ ```ts
26
+ import {
27
+ createAgentSession,
28
+ createReactLoopStrategy,
29
+ createToolRegistry,
30
+ createDispatch,
31
+ createMetricsCollector,
32
+ } from '@inbrowser/agent';
33
+
34
+ const session = createAgentSession({
35
+ strategy: createReactLoopStrategy(),
36
+ llm: yourLlmClient,
37
+ tools: createDispatch(createToolRegistry()),
38
+ toolContext: () => ({ workspace, runtime, sandbox, lint, signal: new AbortController().signal }),
39
+ metrics: createMetricsCollector(),
40
+ history: [],
41
+ id: 'sess-1',
42
+ systemPromptBuilder: (workspace, runtime) => '…',
43
+ });
44
+
45
+ for await (const event of session.submit('hello')) {
46
+ // SessionEvent stream — apply to your store / UI / log
47
+ }
48
+ ```
49
+
50
+ ### CLI
51
+
52
+ ```bash
53
+ # Headless single session — text in TTY, NDJSON when piped.
54
+ agent run "build a chess rule set"
55
+
56
+ # JSON payload via stdin.
57
+ echo '{"prompt": "reset rules"}' | agent run --json -
58
+
59
+ # 10 isolated sessions in parallel.
60
+ agent fleet --size 10
61
+ ```
62
+
63
+ ### MCP server
64
+
65
+ ```bash
66
+ # Expose agent tools over stdio for an external host.
67
+ agent serve --project my-project
68
+ ```
69
+
70
+ ### CLI commands
71
+
72
+ | Command | Purpose |
73
+ |---------|---------|
74
+ | `run` | Headless single session — text in a TTY, NDJSON when piped |
75
+ | `fleet` | Run N isolated sessions in parallel |
76
+ | `serve` | Expose agent tools over MCP stdio |
77
+ | `events` | Inspect a session's event log |
78
+ | `undo` | Roll back the last mutating operation via the event log |
79
+ | `describe` | Print tool schemas / session metadata |
80
+ | `schema` | Emit machine-readable schema introspection |
81
+ | `migrate` | Migrate session logs / event-log format |
82
+ | `version`, `help` | Version string and usage |
83
+
84
+ ## Subpath exports
85
+
86
+ | Entry | Surface |
87
+ |-------|---------|
88
+ | `@inbrowser/agent` | Browser-safe library — `createAgentSession`, `createToolRegistry`, strategies, metrics, storage adapters, event utilities |
89
+ | `@inbrowser/agent/cli` | Node-only CLI internals — `main`, command handlers, arg parsing, the `CLI_SPEC` |
90
+ | `@inbrowser/agent/node` | Node-only event-log writer — `openEventLog`, `buildRollbackEvent`, id generation |
91
+
92
+ ## Where to go next
93
+
94
+ Documentation is organised under [`docs/`](./docs/) following the [Diataxis](https://diataxis.fr/) framework:
95
+
96
+ | If you want to | Read |
97
+ |---|---|
98
+ | Follow a complete lesson | [Tutorials](./docs/tutorials/) |
99
+ | Accomplish a specific task | [How-to guides](./docs/how-to/) |
100
+ | Look up a function, event, or CLI flag | [Reference](./docs/reference/) |
101
+ | Understand the design choices | [Explanation](./docs/explanation/) |
102
+
103
+ ### Starting points by role
104
+
105
+ - **Building an agent in code?** Start with [Drive a session from your code](./docs/tutorials/01-drive-a-session-from-code.md).
106
+ - **Running the CLI?** Start with [Run the agent CLI](./docs/tutorials/02-run-the-agent-cli.md).
107
+ - **Exposing tools to an external host?** Start with [Serve agents over MCP](./docs/tutorials/03-serve-agents-over-mcp.md).
108
+ - **Implementing a new LLM provider?** See [Implement a custom `LlmClient`](./docs/how-to/implement-llm-client.md).
109
+
110
+ ## Position in the stack
111
+
112
+ `@inbrowser/agent` is the agent runtime — independent of domain packages. Hosts compose it with their own `AgentDefinition`s; the bare CLI ships zero built-ins.
113
+
114
+ See [Inference vs inverse architectures](./docs/explanation/inference-vs-inverse.md) for the two distinct consumer modes.
115
+
116
+ ## Licence
117
+
118
+ Same as the parent workspace.
package/bin/agent.ts ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * `agent` CLI entry. All logic lives in `src/cli/` so the package
4
+ * can be both `import { main } from '@inbrowser/agent/cli'` and a
5
+ * shebang-runnable binary. Treat this file as a one-liner.
6
+ */
7
+ import { main } from '../src/cli/main.js';
8
+
9
+ const code = await main();
10
+ process.exit(code);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `agent describe` — emit machine-readable descriptions of CLI subjects.
3
+ * Targets:
4
+ * - commands: the subcommand tree from `spec.ts`
5
+ * - scenarios: scripted LLM fixtures + their turn shapes
6
+ * - events: the NDJSON event-type catalog the CLI emits
7
+ * - all: a single combined object (default)
8
+ *
9
+ * Always emits exactly one event so it's safe to pipe through `jq`.
10
+ */
11
+ import type { Emitter } from '../output.js';
12
+ import type { ParsedArgs } from '../parse.js';
13
+ export declare function describeCommand(args: ParsedArgs, emit: Emitter): number;
14
+ //# sourceMappingURL=describe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/describe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgJ9C,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CA2BvE"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * `agent describe` — emit machine-readable descriptions of CLI subjects.
3
+ * Targets:
4
+ * - commands: the subcommand tree from `spec.ts`
5
+ * - scenarios: scripted LLM fixtures + their turn shapes
6
+ * - events: the NDJSON event-type catalog the CLI emits
7
+ * - all: a single combined object (default)
8
+ *
9
+ * Always emits exactly one event so it's safe to pipe through `jq`.
10
+ */
11
+ import { CLI_SPEC } from '../spec.js';
12
+ const SCENARIOS = [
13
+ {
14
+ id: 'echo',
15
+ description: 'Echoes the user prompt back as text. Single turn, no tool calls.',
16
+ turns: 1,
17
+ },
18
+ {
19
+ id: 'write-rules',
20
+ description: 'Two-turn flow: turn 0 emits a tool_call (writeRules), turn 1 emits a summary text response.',
21
+ turns: 2,
22
+ },
23
+ ];
24
+ const EVENTS = [
25
+ {
26
+ type: 'session_start',
27
+ whenEmitted: 'first event of every run',
28
+ fields: ['ts', 'sessionId', 'scenario', 'maxTurns'],
29
+ },
30
+ {
31
+ type: 'turn_start',
32
+ whenEmitted: 'beginning of each agent turn',
33
+ fields: ['ts', 'sessionId', 'turn'],
34
+ },
35
+ {
36
+ type: 'thinking',
37
+ whenEmitted: 'streaming reasoning chunk (if provided)',
38
+ fields: ['ts', 'sessionId', 'chunk'],
39
+ },
40
+ {
41
+ type: 'text',
42
+ whenEmitted: 'streaming assistant text chunk',
43
+ fields: ['ts', 'sessionId', 'chunk'],
44
+ },
45
+ {
46
+ type: 'tool_call',
47
+ whenEmitted: 'agent invokes a tool',
48
+ fields: ['ts', 'sessionId', 'name', 'callId', 'args'],
49
+ },
50
+ {
51
+ type: 'tool_result',
52
+ whenEmitted: 'tool dispatch finishes',
53
+ fields: ['ts', 'sessionId', 'callId', 'ok', 'summary'],
54
+ },
55
+ {
56
+ type: 'workspace_changed',
57
+ whenEmitted: 'tool result patches the workspace',
58
+ fields: ['ts', 'sessionId', 'rulesLength', 'codeLength'],
59
+ },
60
+ {
61
+ type: 'turn_end',
62
+ whenEmitted: 'turn metrics finalized',
63
+ fields: ['ts', 'sessionId', 'turn', 'metrics'],
64
+ },
65
+ {
66
+ type: 'sandbox_event',
67
+ whenEmitted: 'sandbox observer event',
68
+ fields: ['ts', 'sessionId', 'kind', 'detail'],
69
+ },
70
+ {
71
+ type: 'strategy_event',
72
+ whenEmitted: 'strategy-level milestone',
73
+ fields: ['ts', 'sessionId', 'name', 'data'],
74
+ },
75
+ {
76
+ type: 'session_error',
77
+ whenEmitted: 'session-level error from the strategy',
78
+ fields: ['ts', 'sessionId', 'message'],
79
+ },
80
+ {
81
+ type: 'session_end',
82
+ whenEmitted: 'last event of every run, carries totals',
83
+ fields: ['ts', 'sessionId', 'totals', 'logPath', 'exit'],
84
+ },
85
+ {
86
+ type: 'fleet_start',
87
+ whenEmitted: 'agent fleet, before launching members',
88
+ fields: ['ts', 'size', 'members'],
89
+ },
90
+ {
91
+ type: 'fleet_summary',
92
+ whenEmitted: 'agent fleet, after all members complete',
93
+ fields: ['ts', 'size', 'elapsedMs', 'isolated', 'aggregateTokens', 'results'],
94
+ },
95
+ {
96
+ type: 'dry_run_plan',
97
+ whenEmitted: 'when --dry-run is set; replaces all runtime events',
98
+ fields: ['ts', 'command', 'sessionId?', 'scenario?', 'logPath?'],
99
+ },
100
+ {
101
+ type: 'undo_plan',
102
+ whenEmitted: '`agent undo --dry-run`: plan only, no rollback recorded',
103
+ fields: ['ts', 'eventId', 'originalTool', 'target', 'reverseOp'],
104
+ },
105
+ {
106
+ type: 'undo_recorded',
107
+ whenEmitted: '`agent undo`: rollback event appended to the log',
108
+ fields: ['ts', 'rollbackEventId', 'eventId', 'reverseOp', 'nextStep'],
109
+ },
110
+ {
111
+ type: 'migrate_plan',
112
+ whenEmitted: '`agent migrate`: one per replayable commit (the forward direction)',
113
+ fields: ['ts', 'eventId', 'tool', 'target', 'args'],
114
+ },
115
+ {
116
+ type: 'migrate_summary',
117
+ whenEmitted: '`agent migrate` (no --record): final summary line',
118
+ fields: ['ts', 'plannedCount', 'skippedLegacy'],
119
+ },
120
+ {
121
+ type: 'migrate_intent_recorded',
122
+ whenEmitted: '`agent migrate --record`: intent marker appended to log',
123
+ fields: ['ts', 'intentEventId', 'plannedCount', 'nextStep'],
124
+ },
125
+ {
126
+ type: 'mutation_event',
127
+ whenEmitted: '`agent events`: every line is one MutationEvent from the project log',
128
+ fields: [
129
+ 'id',
130
+ 'ts',
131
+ 'agent',
132
+ 'sessionId',
133
+ 'tool',
134
+ 'args?',
135
+ 'phase',
136
+ 'target',
137
+ 'before?',
138
+ 'after?',
139
+ 'reversible',
140
+ 'reverseOp?',
141
+ 'metadata?',
142
+ ],
143
+ },
144
+ {
145
+ type: 'error',
146
+ whenEmitted: 'CLI-level error (parsing, hardening, file resolution)',
147
+ fields: ['ts', 'name', 'message', 'field?', 'reason?'],
148
+ },
149
+ ];
150
+ export function describeCommand(args, emit) {
151
+ const target = args.options['target'] ?? 'all';
152
+ const payload = (() => {
153
+ if (target === 'commands')
154
+ return { commands: CLI_SPEC.commands };
155
+ if (target === 'scenarios')
156
+ return { scenarios: SCENARIOS };
157
+ if (target === 'events')
158
+ return { events: EVENTS };
159
+ return {
160
+ cli: { name: CLI_SPEC.name, version: CLI_SPEC.version, description: CLI_SPEC.description },
161
+ commands: CLI_SPEC.commands,
162
+ globalOptions: CLI_SPEC.globalOptions,
163
+ scenarios: SCENARIOS,
164
+ events: EVENTS,
165
+ };
166
+ })();
167
+ emit.event({ type: 'describe', target, ...payload }, () => {
168
+ if (target === 'commands' || target === 'all') {
169
+ return CLI_SPEC.commands.map((c) => `${c.name.padEnd(10)} ${c.description}`).join('\n');
170
+ }
171
+ if (target === 'scenarios') {
172
+ return SCENARIOS.map((s) => `${s.id.padEnd(14)} ${s.description}`).join('\n');
173
+ }
174
+ return EVENTS.map((e) => `${e.type.padEnd(20)} ${e.whenEmitted}`).join('\n');
175
+ });
176
+ emit.finish();
177
+ return 0;
178
+ }
179
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.js","sourceRoot":"","sources":["../../../src/cli/commands/describe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,SAAS,GAAG;IAChB;QACE,EAAE,EAAE,MAAM;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AAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `agent events` — read + filter the per-project mutation event log.
3
+ *
4
+ * Emits one event per NDJSON line. Field filtering (`--fields`)
5
+ * applies to each event. Read-only — never appends.
6
+ *
7
+ * Bookkeeping markers (`migrate_applied`, `migrate_intent`) are
8
+ * **excluded by default** so users querying "what changed?" don't
9
+ * see audit-of-the-audit rows mixed in. Pass `--include-bookkeeping`
10
+ * to opt back in.
11
+ */
12
+ import { openEventLog } from '../../events/log.js';
13
+ import type { Emitter } from '../output.js';
14
+ import type { ParsedArgs } from '../parse.js';
15
+ export interface EventsCommandIO {
16
+ emit: Emitter;
17
+ /** Injectable for tests; defaults to `openEventLog`. */
18
+ openLog?: typeof openEventLog;
19
+ }
20
+ export declare function eventsCommand(args: ParsedArgs, io: EventsCommandIO): number;
21
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,YAAY,CAAC;CAC/B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,GAAG,MAAM,CA+C3E"}