amness 0.0.0-stage → 0.1.2

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 (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -2
  3. package/dist/cli/acpcli.d.ts +7 -0
  4. package/dist/cli/acpcli.js +14 -0
  5. package/dist/cli/amness.d.ts +2 -0
  6. package/dist/cli/amness.js +694 -0
  7. package/dist/cli/benchcli.d.ts +5 -0
  8. package/dist/cli/benchcli.js +160 -0
  9. package/dist/cli/config.d.ts +79 -0
  10. package/dist/cli/config.js +111 -0
  11. package/dist/cli/demo.d.ts +13 -0
  12. package/dist/cli/demo.js +44 -0
  13. package/dist/cli/detect.d.ts +2 -0
  14. package/dist/cli/detect.js +20 -0
  15. package/dist/cli/evalcli.d.ts +15 -0
  16. package/dist/cli/evalcli.js +198 -0
  17. package/dist/cli/format.d.ts +5 -0
  18. package/dist/cli/format.js +55 -0
  19. package/dist/cli/headless.d.ts +2 -0
  20. package/dist/cli/headless.js +169 -0
  21. package/dist/cli/keystore.d.ts +9 -0
  22. package/dist/cli/keystore.js +108 -0
  23. package/dist/cli/model.d.ts +11 -0
  24. package/dist/cli/model.js +19 -0
  25. package/dist/cli/plugincli.d.ts +2 -0
  26. package/dist/cli/plugincli.js +176 -0
  27. package/dist/cli/schedulecli.d.ts +2 -0
  28. package/dist/cli/schedulecli.js +66 -0
  29. package/dist/cli/state.d.ts +11 -0
  30. package/dist/cli/state.js +19 -0
  31. package/dist/cli/tui/ansi.d.ts +38 -0
  32. package/dist/cli/tui/ansi.js +142 -0
  33. package/dist/cli/tui/app.d.ts +328 -0
  34. package/dist/cli/tui/app.js +1358 -0
  35. package/dist/cli/tui/blocks.d.ts +151 -0
  36. package/dist/cli/tui/blocks.js +128 -0
  37. package/dist/cli/tui/brand.d.ts +9 -0
  38. package/dist/cli/tui/brand.js +16 -0
  39. package/dist/cli/tui/canvas.d.ts +92 -0
  40. package/dist/cli/tui/canvas.js +199 -0
  41. package/dist/cli/tui/cards.d.ts +44 -0
  42. package/dist/cli/tui/cards.js +215 -0
  43. package/dist/cli/tui/clipboard.d.ts +5 -0
  44. package/dist/cli/tui/clipboard.js +29 -0
  45. package/dist/cli/tui/commands.d.ts +10 -0
  46. package/dist/cli/tui/commands.js +650 -0
  47. package/dist/cli/tui/complete.d.ts +39 -0
  48. package/dist/cli/tui/complete.js +113 -0
  49. package/dist/cli/tui/custom.d.ts +9 -0
  50. package/dist/cli/tui/custom.js +34 -0
  51. package/dist/cli/tui/diffview.d.ts +25 -0
  52. package/dist/cli/tui/diffview.js +130 -0
  53. package/dist/cli/tui/editor.d.ts +60 -0
  54. package/dist/cli/tui/editor.js +230 -0
  55. package/dist/cli/tui/full.d.ts +86 -0
  56. package/dist/cli/tui/full.js +630 -0
  57. package/dist/cli/tui/keys.d.ts +31 -0
  58. package/dist/cli/tui/keys.js +134 -0
  59. package/dist/cli/tui/markdown.d.ts +37 -0
  60. package/dist/cli/tui/markdown.js +155 -0
  61. package/dist/cli/tui/mentions.d.ts +15 -0
  62. package/dist/cli/tui/mentions.js +48 -0
  63. package/dist/cli/tui/modal.d.ts +26 -0
  64. package/dist/cli/tui/modal.js +107 -0
  65. package/dist/cli/tui/overlays.d.ts +98 -0
  66. package/dist/cli/tui/overlays.js +237 -0
  67. package/dist/cli/tui/pager.d.ts +15 -0
  68. package/dist/cli/tui/pager.js +66 -0
  69. package/dist/cli/tui/pricing.d.ts +9 -0
  70. package/dist/cli/tui/pricing.js +23 -0
  71. package/dist/cli/tui/rich.d.ts +16 -0
  72. package/dist/cli/tui/rich.js +72 -0
  73. package/dist/cli/tui/screen.d.ts +30 -0
  74. package/dist/cli/tui/screen.js +62 -0
  75. package/dist/cli/tui/session.d.ts +77 -0
  76. package/dist/cli/tui/session.js +103 -0
  77. package/dist/cli/tui/sidebar.d.ts +84 -0
  78. package/dist/cli/tui/sidebar.js +114 -0
  79. package/dist/cli/tui/text.d.ts +15 -0
  80. package/dist/cli/tui/text.js +94 -0
  81. package/dist/cli/tui/theme.d.ts +59 -0
  82. package/dist/cli/tui/theme.js +148 -0
  83. package/dist/cli/tui/themes.d.ts +56 -0
  84. package/dist/cli/tui/themes.js +80 -0
  85. package/dist/cli/tui/tokens.d.ts +39 -0
  86. package/dist/cli/tui/tokens.js +71 -0
  87. package/dist/cli/tui/view.d.ts +60 -0
  88. package/dist/cli/tui/view.js +178 -0
  89. package/dist/cli/ui.d.ts +34 -0
  90. package/dist/cli/ui.js +224 -0
  91. package/dist/src/acp.d.ts +28 -0
  92. package/dist/src/acp.js +111 -0
  93. package/dist/src/agents.d.ts +23 -0
  94. package/dist/src/agents.js +71 -0
  95. package/dist/src/anthropic.d.ts +30 -0
  96. package/dist/src/anthropic.js +91 -0
  97. package/dist/src/approver.d.ts +15 -0
  98. package/dist/src/approver.js +40 -0
  99. package/dist/src/bench.d.ts +67 -0
  100. package/dist/src/bench.js +201 -0
  101. package/dist/src/bundle.d.ts +36 -0
  102. package/dist/src/bundle.js +55 -0
  103. package/dist/src/chaos.d.ts +15 -0
  104. package/dist/src/chaos.js +26 -0
  105. package/dist/src/code.d.ts +187 -0
  106. package/dist/src/code.js +590 -0
  107. package/dist/src/codeindex.d.ts +65 -0
  108. package/dist/src/codeindex.js +300 -0
  109. package/dist/src/deep.d.ts +62 -0
  110. package/dist/src/deep.js +177 -0
  111. package/dist/src/diff.d.ts +8 -0
  112. package/dist/src/diff.js +74 -0
  113. package/dist/src/dynamic.d.ts +42 -0
  114. package/dist/src/dynamic.js +133 -0
  115. package/dist/src/embed.d.ts +8 -0
  116. package/dist/src/embed.js +25 -0
  117. package/dist/src/evalcases.d.ts +11 -0
  118. package/dist/src/evalcases.js +196 -0
  119. package/dist/src/evals.d.ts +197 -0
  120. package/dist/src/evals.js +340 -0
  121. package/dist/src/gitflow.d.ts +27 -0
  122. package/dist/src/gitflow.js +56 -0
  123. package/dist/src/grade.d.ts +42 -0
  124. package/dist/src/grade.js +96 -0
  125. package/dist/src/guidance.d.ts +15 -0
  126. package/dist/src/guidance.js +68 -0
  127. package/dist/src/hardcases.d.ts +2 -0
  128. package/dist/src/hardcases.js +94 -0
  129. package/dist/src/harness.d.ts +411 -0
  130. package/dist/src/harness.js +725 -0
  131. package/dist/src/hooks.d.ts +44 -0
  132. package/dist/src/hooks.js +116 -0
  133. package/dist/src/images.d.ts +13 -0
  134. package/dist/src/images.js +27 -0
  135. package/dist/src/index.d.ts +57 -0
  136. package/dist/src/index.js +57 -0
  137. package/dist/src/ledger.d.ts +58 -0
  138. package/dist/src/ledger.js +78 -0
  139. package/dist/src/live.d.ts +16 -0
  140. package/dist/src/live.js +80 -0
  141. package/dist/src/lsp.d.ts +31 -0
  142. package/dist/src/lsp.js +147 -0
  143. package/dist/src/memory.d.ts +128 -0
  144. package/dist/src/memory.js +390 -0
  145. package/dist/src/metrics.d.ts +3 -0
  146. package/dist/src/metrics.js +42 -0
  147. package/dist/src/mining.d.ts +49 -0
  148. package/dist/src/mining.js +126 -0
  149. package/dist/src/openai.d.ts +50 -0
  150. package/dist/src/openai.js +307 -0
  151. package/dist/src/parallel.d.ts +66 -0
  152. package/dist/src/parallel.js +135 -0
  153. package/dist/src/patch.d.ts +45 -0
  154. package/dist/src/patch.js +219 -0
  155. package/dist/src/permissions.d.ts +46 -0
  156. package/dist/src/permissions.js +245 -0
  157. package/dist/src/plugins.d.ts +148 -0
  158. package/dist/src/plugins.js +225 -0
  159. package/dist/src/pluginscan.d.ts +8 -0
  160. package/dist/src/pluginscan.js +20 -0
  161. package/dist/src/procs.d.ts +41 -0
  162. package/dist/src/procs.js +94 -0
  163. package/dist/src/profiles.d.ts +36 -0
  164. package/dist/src/profiles.js +61 -0
  165. package/dist/src/progress.d.ts +29 -0
  166. package/dist/src/progress.js +75 -0
  167. package/dist/src/prompts.d.ts +10 -0
  168. package/dist/src/prompts.js +28 -0
  169. package/dist/src/ratelimit.d.ts +34 -0
  170. package/dist/src/ratelimit.js +116 -0
  171. package/dist/src/replay.d.ts +25 -0
  172. package/dist/src/replay.js +99 -0
  173. package/dist/src/review.d.ts +20 -0
  174. package/dist/src/review.js +49 -0
  175. package/dist/src/route.d.ts +9 -0
  176. package/dist/src/route.js +30 -0
  177. package/dist/src/router.d.ts +61 -0
  178. package/dist/src/router.js +126 -0
  179. package/dist/src/sandbox.d.ts +13 -0
  180. package/dist/src/sandbox.js +68 -0
  181. package/dist/src/schedule.d.ts +20 -0
  182. package/dist/src/schedule.js +59 -0
  183. package/dist/src/schema.d.ts +13 -0
  184. package/dist/src/schema.js +36 -0
  185. package/dist/src/secrets.d.ts +10 -0
  186. package/dist/src/secrets.js +41 -0
  187. package/dist/src/shell.d.ts +34 -0
  188. package/dist/src/shell.js +95 -0
  189. package/dist/src/skills.d.ts +20 -0
  190. package/dist/src/skills.js +112 -0
  191. package/dist/src/snapshot.d.ts +20 -0
  192. package/dist/src/snapshot.js +93 -0
  193. package/dist/src/stats.d.ts +24 -0
  194. package/dist/src/stats.js +62 -0
  195. package/dist/src/strategies.d.ts +16 -0
  196. package/dist/src/strategies.js +35 -0
  197. package/dist/src/suites.d.ts +30 -0
  198. package/dist/src/suites.js +112 -0
  199. package/dist/src/trace.d.ts +63 -0
  200. package/dist/src/trace.js +153 -0
  201. package/dist/src/tune.d.ts +38 -0
  202. package/dist/src/tune.js +49 -0
  203. package/dist/src/web.d.ts +19 -0
  204. package/dist/src/web.js +56 -0
  205. package/dist/src/worktree.d.ts +24 -0
  206. package/dist/src/worktree.js +85 -0
  207. package/docs/agent-loop.md +222 -0
  208. package/docs/architecture.md +228 -0
  209. package/docs/bench.md +292 -0
  210. package/docs/budgets.md +185 -0
  211. package/docs/build-your-own-harness.md +424 -0
  212. package/docs/cookbook.md +375 -0
  213. package/docs/development.md +150 -0
  214. package/docs/evaluation.md +450 -0
  215. package/docs/features.md +1320 -0
  216. package/docs/getting-started.md +205 -0
  217. package/docs/headless.md +188 -0
  218. package/docs/images/approval.png +0 -0
  219. package/docs/images/chat.png +0 -0
  220. package/docs/images/daylight.png +0 -0
  221. package/docs/images/loop.png +0 -0
  222. package/docs/images/palette.png +0 -0
  223. package/docs/images/running.png +0 -0
  224. package/docs/images/subagent-done.png +0 -0
  225. package/docs/images/subagent-running.png +0 -0
  226. package/docs/images/welcome.png +0 -0
  227. package/docs/index.md +25 -0
  228. package/docs/library.md +267 -0
  229. package/docs/plugins.md +691 -0
  230. package/docs/providers.md +175 -0
  231. package/docs/safety.md +250 -0
  232. package/docs/usage.md +348 -0
  233. package/docs/why.md +155 -0
  234. package/docs/writing-guide.md +39 -0
  235. package/package.json +66 -4
@@ -0,0 +1,267 @@
1
+ # Use it as a library
2
+
3
+ This page shows you how to use the Amness agent loop inside your own TypeScript program, without the terminal chat.
4
+
5
+ In this page you will learn:
6
+
7
+ - how to install the library and run a coding agent
8
+ - how to add your own tool and ask for approval
9
+ - how to set a budget, rules, hooks and a sandbox
10
+ - how to run the research agent and an evaluation
11
+
12
+ Everything is exported from `src/index.ts`. The code samples on this page were type-checked against the real types in `src/harness.ts` and `src/code.ts`. They were not run against a live model.
13
+
14
+ ## Install the library
15
+
16
+ **What it is.** Amness runs TypeScript directly with Node.js type stripping. You need Node.js 22.18 or newer.
17
+
18
+ **Why you would use it.** You get the same guards as the chat (argument checks, verify gate, loop guard, budgets) inside a script, a server or a test.
19
+
20
+ **How to use it.**
21
+
22
+ 1. Install the package in your own project:
23
+
24
+ ```bash
25
+ npm install amness
26
+ ```
27
+
28
+ 2. Import what you need:
29
+
30
+ ```ts
31
+ import { createCodeAgent, openai } from "amness";
32
+ ```
33
+
34
+ To use the latest `main` before it is released, clone the repository, run `npm install && npm run build && npm pack`, and install the tarball it makes with `npm install ../Amness/amness-<version>.tgz`. You can also import the source directly, because Node.js can run `.ts` files: `import { createCodeAgent, openai } from "../Amness/src/index.ts";`.
35
+
36
+ The CI job `package` packs the tarball, installs it in a new folder, and checks that `import("amness")` works.
37
+
38
+ **Limits.** The Claude adapter uses the optional dependency `@anthropic-ai/sdk`, which `npm install amness` adds for you (if it is missing, run `npm install @anthropic-ai/sdk`). The OpenAI adapter uses plain `fetch` and has no dependency.
39
+
40
+ ## Run a coding agent
41
+
42
+ **What it is.** `createCodeAgent` gives you an agent with file tools, a shell tool, memory and all guards. It works in one folder (`cwd`).
43
+
44
+ **How to use it.**
45
+
46
+ 1. Create a file `fix.ts`:
47
+
48
+ ```ts
49
+ import { createCodeAgent, openai } from "amness";
50
+
51
+ const agent = createCodeAgent({
52
+ model: openai({ model: "gpt-6.1-sol", effort: "high" }),
53
+ cwd: "./my-repo",
54
+ verify: "npm test", // "done" must be proven by this command
55
+ approve: ({ name, args, reason }) => false, // deny risky calls
56
+ });
57
+
58
+ const result = await agent.run("fix the failing test");
59
+ console.log(result.finished, result.text);
60
+ ```
61
+
62
+ 2. Set your key and run it:
63
+
64
+ ```bash
65
+ export OPENAI_API_KEY=sk-...
66
+ node fix.ts
67
+ ```
68
+
69
+ **Example.** If the tests pass after the fix, you see `true` and the summary the agent wrote. If the agent runs out of steps, you see `false` and a text that starts with `stopped:`.
70
+
71
+ **What `run` returns.** An object with `text`, `finished`, `steps`, `tokens`, `messages` and, when it stopped early, `stopped` (`"budget"`, `"maxSteps"`, `"aborted"`, `"stuck"` or `"blocked"`).
72
+
73
+ **Limits and common problems.**
74
+
75
+ - `approve` is called before every risky tool call. It must return `true`, `false`, or a string. A string is a denial that the agent reads. If you give no `approve`, risky calls are denied.
76
+ - Without `permissions: { mode }`, edits do not ask. Only shell commands on the risk list ask. For the chat behavior, pass `permissions: { mode: () => "default" }`. Modes are `"default"`, `"acceptEdits"`, `"plan"` and `"yolo"`.
77
+ - The default step limit is 40 (60 when `chat: true`). Change it with `maxSteps`.
78
+ - Memory is on by default. It writes to `.amness/memory` in `cwd` and to `~/.amness/memory`. Pass `memory: false` for a clean run.
79
+
80
+ ## Add your own tool
81
+
82
+ **What it is.** A tool is an object made with `defineTool`. The model calls it by name. The `schema` is a JSON schema. Amness validates the arguments before `run` is called.
83
+
84
+ **How to use it.**
85
+
86
+ ```ts
87
+ import { createHarness, defineTool, openai } from "amness";
88
+
89
+ const orders: Record<string, string> = { "42": "shipped" };
90
+
91
+ const lookup = defineTool<{ id: string }>({
92
+ name: "lookup",
93
+ description: "Look up the status of an order",
94
+ schema: { type: "object", required: ["id"], properties: { id: { type: "string" } } },
95
+ run: ({ id }) => orders[id] ?? "unknown order",
96
+ readOnly: true, // changes nothing, so it may run in parallel
97
+ });
98
+
99
+ const h = createHarness({
100
+ model: openai(),
101
+ tools: [lookup],
102
+ verify: () => true,
103
+ onEvent: (e) => console.error(e.kind),
104
+ });
105
+ const r = await h.run("What is the status of order 42?");
106
+ console.log(r.text);
107
+ ```
108
+
109
+ The flags on a tool:
110
+
111
+ | Flag | Meaning |
112
+ |---|---|
113
+ | `readOnly` | Changes nothing. Safe in plan mode and in parallel |
114
+ | `risky` | `true`, or a function that returns `true` or a reason text. The call needs `approve` |
115
+ | `untrusted` | The output comes from outside. It is wrapped as data, and shell commands that copy from it need approval |
116
+ | `deferred` | Hidden until the model finds it with `tool_search`. Good when you have many tools |
117
+ | `when` | Shows the tool only while the function returns `true` |
118
+
119
+ **Limits.** Without `approve`, `createHarness` denies every risky tool call. `createHarness` has no file or shell tools. Use `createCodeAgent` for those, and pass your tools with `tools: [...]`.
120
+
121
+ ## Set a budget, rules, hooks and a sandbox
122
+
123
+ **How to use it.**
124
+
125
+ ```ts
126
+ import { Budget, Hooks, Permissions, createCodeAgent, openai } from "amness";
127
+
128
+ const cwd = "./my-repo";
129
+ const budget = new Budget({ maxTokens: 200_000, maxMs: 10 * 60_000 });
130
+
131
+ const agent = createCodeAgent({
132
+ model: openai(),
133
+ cwd,
134
+ budget,
135
+ sandbox: "workspace", // "off" | "workspace" | "strict"
136
+ rules: new Permissions({ deny: ["sh(git push*)", "edit(.env)"] }, cwd),
137
+ hooks: Hooks.load(cwd, { trustProject: false }), // only your ~/.amness/hooks.json
138
+ check: "npx tsc --noEmit", // runs after each edit
139
+ approve: () => false,
140
+ });
141
+
142
+ const r = await agent.run("add a --verbose flag");
143
+ console.log(r.finished, budget.tokens);
144
+ ```
145
+
146
+ **Limits and common problems.**
147
+
148
+ - `rules` replaces the default. The built-in floor still applies when you pass your own `Permissions`. Passing `rules: false` switches the floor off too.
149
+ - `Hooks.load(cwd, { trustProject: true })` runs the commands in the project's `.amness/hooks.json`. Do this only for code you trust.
150
+ - If you ask for a sandbox that is not available (for example on Windows), shell commands fail with an error. They do not run unprotected.
151
+ - `taint` (`"ask"`, `"deny"` or `"off"`) and `redact` (`true` or `false`) control the text checks. See [Safety and privacy](safety.md).
152
+ - Call `await agent.procs?.dispose()` when you are done, so background processes stop.
153
+
154
+ ## Choose a model
155
+
156
+ A model is a function `(messages, tools, opts) => Promise<Message>`.
157
+
158
+ ```ts
159
+ import { anthropic, openai } from "amness";
160
+
161
+ const gpt = openai({ model: "gpt-6.1-sol" });
162
+ const local = openai({ baseUrl: "http://localhost:11434/v1", model: "qwen2.5-coder:7b" });
163
+ const claude = anthropic({ model: "claude-opus-5-5" }); // needs @anthropic-ai/sdk
164
+ ```
165
+
166
+ To add another provider, write one function that returns a `Message` (`{ role: "assistant", content, tool_calls? }`) and, if you can, `usage`. If the provider gives no token counts, Amness estimates them (about 4 characters per token).
167
+
168
+ ## Continue, stop and resume a run
169
+
170
+ - `checkpointFile: "state.json"` saves the transcript every turn. Later, `agent.run(task, { resume: true })` continues from it.
171
+ - `signal: controller.signal` stops the run at the next safe point.
172
+ - `agent.followUp(result, "now also update the docs")` continues the same conversation.
173
+ - `agent.exportBundle(result, "session.json")` saves a portable session. `agent.run(task, { bundle: "session.json" })` continues it on another machine.
174
+
175
+ ## Get checked JSON from a model
176
+
177
+ `createHarness(...).extract(prompt, schema)` asks for JSON and checks it against a schema. It sends validation errors back and tries up to 3 times. It throws an error if the JSON is still wrong.
178
+
179
+ ```ts
180
+ import { createHarness, openai } from "amness";
181
+
182
+ const h = createHarness({ model: openai() });
183
+ const data = await h.extract<{ name: string; age: number }>(
184
+ "Ada Lovelace was 36 when she died.",
185
+ { type: "object", required: ["name", "age"], properties: { name: { type: "string" }, age: { type: "integer" } } },
186
+ );
187
+ console.log(data.name, data.age);
188
+ ```
189
+
190
+ ## Run the research agent
191
+
192
+ `createDeepAgent` plans, sends work to subagents, searches the web and writes `/report.md`. It rejects a report that cites URLs the agents never saw.
193
+
194
+ ```ts
195
+ import { createDeepAgent, openai } from "amness";
196
+
197
+ const agent = createDeepAgent({
198
+ model: openai(),
199
+ dir: ".amness", // files persist between runs
200
+ });
201
+ const r = await agent.run("Compare two ways to cache HTTP responses in Node.js");
202
+ console.log(r.report ?? r.text);
203
+ ```
204
+
205
+ It uses `TAVILY_API_KEY` for search when set. Otherwise it reads DuckDuckGo's HTML page, which can break. Search queries and page requests leave your machine. See [Safety and privacy](safety.md).
206
+
207
+ ## Attach an MCP server
208
+
209
+ ```ts
210
+ import { createCodeAgent, loadMcp, openai } from "amness";
211
+
212
+ const mcp = await loadMcp("npx", ["-y", "@modelcontextprotocol/server-filesystem", "."]);
213
+ const agent = createCodeAgent({ model: openai(), cwd: ".", tools: mcp.tools, approve: () => false });
214
+ await agent.run("list the files");
215
+ mcp.close();
216
+ ```
217
+
218
+ Tools from the server get the prefix of the command name, then `__`, then the tool name. Tools that the server marks as changing things need approval. The server gets your full environment, and the output is treated as untrusted.
219
+
220
+ ## Compare harness variants
221
+
222
+ `evaluate` runs tasks with different harness settings and gives a table. A `Case` has `files`, a `task`, and a held-out `check` that the agent never sees.
223
+
224
+ ```ts
225
+ import { codeVariants, evaluate, openai, type Case } from "amness";
226
+
227
+ const cases: Case[] = [{
228
+ name: "rename-word",
229
+ files: { "a.txt": "one\n" },
230
+ task: "Change the text in a.txt from 'one' to 'two'.",
231
+ check: (dir) => import("node:fs").then((fs) => fs.readFileSync(`${dir}/a.txt`, "utf8").trim() === "two"),
232
+ }];
233
+
234
+ const { table } = await evaluate(cases, codeVariants(openai()), { trials: 3 });
235
+ console.log(table);
236
+ ```
237
+
238
+ This calls the model many times and costs money. For statistics and ablations, use the command line. See [Evaluating the harness](evaluation.md).
239
+
240
+ ## Examples in the repository
241
+
242
+ | File | What it shows |
243
+ |---|---|
244
+ | `examples/code.ts` | A coding agent with a terminal approval prompt, `--verify`, `--resume`, `--self-extend` and `--mcp` |
245
+ | `examples/research.ts` | The research agent |
246
+ | `examples/eval.ts` | A pass-rate table with `codeVariants` |
247
+ | `examples/cases.ts` | The built-in evaluation cases |
248
+ | `examples/plugins/house-rules.ts` | A plugin with hooks, a tool, a case and variants |
249
+
250
+ Run one with Node.js, for example:
251
+
252
+ ```bash
253
+ OPENAI_API_KEY=sk-... node examples/code.ts ./my-repo "fix the failing test" --verify "npm test"
254
+ ```
255
+
256
+ ## Related pages
257
+
258
+ - [The agent loop](agent-loop.md) for what the loop does each turn
259
+ - [Plugins](plugins.md) for rules you can load without changing code
260
+ - [Safety and privacy](safety.md) for approval, rules and the sandbox
261
+ - [Budgets and subagents](budgets.md) for `Budget`
262
+
263
+ ## Next steps
264
+
265
+ - Try the examples: [Cookbook](cookbook.md)
266
+ - Measure a change: [Evaluating the harness](evaluation.md)
267
+ - Understand the layers: [Architecture](architecture.md)