operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (289) hide show
  1. package/dist/agent/agent.d.ts +8 -7
  2. package/dist/agent/compose-hooks.d.ts +10 -1
  3. package/dist/agent/compose-hooks.js +61 -6
  4. package/dist/agent/concurrency.js +1 -1
  5. package/dist/agent/context-report.d.ts +2 -2
  6. package/dist/agent/durable-state.d.ts +22 -0
  7. package/dist/agent/durable-state.js +54 -0
  8. package/dist/agent/index.d.ts +2 -2
  9. package/dist/agent/index.js +1 -1
  10. package/dist/agent/instruction-context.d.ts +6 -6
  11. package/dist/agent/instruction-context.js +23 -23
  12. package/dist/agent/profile-builtins.js +1 -1
  13. package/dist/agent/run-support.d.ts +1 -1
  14. package/dist/agent/run-support.js +6 -5
  15. package/dist/agent/runner.d.ts +25 -22
  16. package/dist/agent/runner.js +217 -121
  17. package/dist/agent/session.d.ts +262 -156
  18. package/dist/agent/session.js +590 -418
  19. package/dist/agent/subagent-tools.js +3 -3
  20. package/dist/agent/subagent.js +28 -13
  21. package/dist/agent/toolset.d.ts +1 -0
  22. package/dist/agent/toolset.js +13 -7
  23. package/dist/agent/workflow/journal.d.ts +2 -2
  24. package/dist/agent/workflow/journal.js +2 -2
  25. package/dist/agent/workflow/manager.d.ts +1 -1
  26. package/dist/agent/workflow/manager.js +1 -1
  27. package/dist/agent/workflow/prompt.js +2 -2
  28. package/dist/agent/workflow/sandbox.d.ts +1 -1
  29. package/dist/agent/workflow/sandbox.js +1 -1
  30. package/dist/agent/workflow/tool.js +30 -43
  31. package/dist/agent/worktree.d.ts +8 -8
  32. package/dist/agent/worktree.js +15 -15
  33. package/dist/capabilities/assembler.d.ts +29 -5
  34. package/dist/capabilities/assembler.js +85 -9
  35. package/dist/capabilities/background/code-task.d.ts +43 -0
  36. package/dist/capabilities/background/code-task.js +75 -0
  37. package/dist/capabilities/background/command-task.d.ts +9 -2
  38. package/dist/capabilities/background/command-task.js +22 -6
  39. package/dist/capabilities/background/index.d.ts +6 -1
  40. package/dist/capabilities/background/index.js +26 -20
  41. package/dist/capabilities/background/manager.d.ts +57 -1
  42. package/dist/capabilities/background/manager.js +210 -45
  43. package/dist/capabilities/background/persist-disk.d.ts +1 -1
  44. package/dist/capabilities/background/persist-disk.js +1 -1
  45. package/dist/capabilities/background/persist.js +4 -2
  46. package/dist/capabilities/background/projections.d.ts +16 -0
  47. package/dist/capabilities/background/projections.js +86 -0
  48. package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
  49. package/dist/capabilities/background/stall-watchdog.js +85 -0
  50. package/dist/capabilities/background/task.d.ts +8 -7
  51. package/dist/capabilities/background/tools.js +33 -7
  52. package/dist/capabilities/capability-data.d.ts +52 -0
  53. package/dist/capabilities/capability-data.js +88 -0
  54. package/dist/capabilities/capability-state.d.ts +2 -4
  55. package/dist/capabilities/capability-state.js +5 -23
  56. package/dist/capabilities/capability.d.ts +203 -38
  57. package/dist/capabilities/compaction/index.js +10 -4
  58. package/dist/capabilities/compaction/service.d.ts +20 -5
  59. package/dist/capabilities/compaction/service.js +27 -11
  60. package/dist/capabilities/goal/goal-store.d.ts +76 -12
  61. package/dist/capabilities/goal/goal-store.js +137 -53
  62. package/dist/capabilities/goal/index.d.ts +1 -1
  63. package/dist/capabilities/goal/index.js +30 -7
  64. package/dist/capabilities/index.d.ts +9 -6
  65. package/dist/capabilities/index.js +4 -3
  66. package/dist/capabilities/plan/index.js +22 -5
  67. package/dist/capabilities/plan/plan-mode.d.ts +30 -9
  68. package/dist/capabilities/plan/plan-mode.js +57 -32
  69. package/dist/capabilities/plan/tools.js +1 -1
  70. package/dist/capabilities/skills/flow-provider.js +3 -3
  71. package/dist/capabilities/skills/index.d.ts +13 -1
  72. package/dist/capabilities/skills/index.js +30 -21
  73. package/dist/capabilities/skills/parser.d.ts +2 -2
  74. package/dist/capabilities/skills/parser.js +3 -3
  75. package/dist/capabilities/skills/registry.d.ts +5 -6
  76. package/dist/capabilities/skills/registry.js +6 -9
  77. package/dist/capabilities/skills/scanner.d.ts +3 -3
  78. package/dist/capabilities/skills/scanner.js +14 -14
  79. package/dist/capabilities/skills/service.d.ts +2 -1
  80. package/dist/capabilities/skills/service.js +3 -3
  81. package/dist/capabilities/skills/skill-tool.d.ts +2 -0
  82. package/dist/capabilities/skills/skill-tool.js +1 -1
  83. package/dist/capabilities/task/index.js +2 -1
  84. package/dist/capabilities/task/persist-disk.d.ts +1 -1
  85. package/dist/capabilities/task/persist-disk.js +1 -1
  86. package/dist/capabilities/task/persist.js +1 -1
  87. package/dist/capabilities/todo/index.js +11 -6
  88. package/dist/capabilities/todo/injector.js +2 -1
  89. package/dist/capabilities/todo/todo-store.d.ts +28 -7
  90. package/dist/capabilities/todo/todo-store.js +44 -11
  91. package/dist/capabilities/todo/tools.js +8 -3
  92. package/dist/capabilities/tool-provider.d.ts +3 -3
  93. package/dist/capabilities/user-hooks/engine.d.ts +3 -3
  94. package/dist/capabilities/user-hooks/engine.js +7 -7
  95. package/dist/capabilities/user-hooks/index.js +2 -1
  96. package/dist/capabilities/workflow/index.d.ts +5 -3
  97. package/dist/capabilities/workflow/index.js +3 -2
  98. package/dist/commands/index.js +34 -32
  99. package/dist/config/index.d.ts +1 -1
  100. package/dist/config/provider-manager.js +0 -28
  101. package/dist/config/schema.d.ts +53 -4
  102. package/dist/config/schema.js +53 -1
  103. package/dist/events/events.d.ts +43 -11
  104. package/dist/events/events.js +1 -0
  105. package/dist/events/index.d.ts +2 -2
  106. package/dist/events/index.js +1 -1
  107. package/dist/events/projection.d.ts +49 -1
  108. package/dist/events/projection.js +144 -19
  109. package/dist/events/publisher.js +2 -21
  110. package/dist/home.d.ts +1 -1
  111. package/dist/home.js +1 -1
  112. package/dist/index.d.ts +3 -2
  113. package/dist/index.js +2 -1
  114. package/dist/internal.d.ts +5 -2
  115. package/dist/internal.js +5 -2
  116. package/dist/llm/define-model.d.ts +4 -0
  117. package/dist/llm/define-model.js +63 -25
  118. package/dist/llm/index.d.ts +1 -0
  119. package/dist/llm/index.js +1 -0
  120. package/dist/llm/model.d.ts +2 -0
  121. package/dist/llm/provider.d.ts +17 -0
  122. package/dist/llm/provider.js +14 -0
  123. package/dist/llm/retry.js +1 -1
  124. package/dist/loop/context.d.ts +21 -1
  125. package/dist/loop/context.js +47 -9
  126. package/dist/loop/events.d.ts +5 -1
  127. package/dist/loop/index.d.ts +2 -2
  128. package/dist/loop/index.js +1 -1
  129. package/dist/loop/interruption.d.ts +9 -4
  130. package/dist/loop/interruption.js +11 -25
  131. package/dist/loop/run-turn.d.ts +16 -3
  132. package/dist/loop/run-turn.js +13 -4
  133. package/dist/loop/steer.d.ts +78 -12
  134. package/dist/loop/steer.js +101 -38
  135. package/dist/loop/tool-call.d.ts +13 -2
  136. package/dist/loop/tool-call.js +135 -5
  137. package/dist/loop/turn-step.d.ts +13 -2
  138. package/dist/loop/turn-step.js +29 -7
  139. package/dist/loop/types.d.ts +6 -0
  140. package/dist/mcp/auth-tool.d.ts +3 -1
  141. package/dist/mcp/auth-tool.js +2 -2
  142. package/dist/mcp/capability.d.ts +13 -0
  143. package/dist/mcp/capability.js +36 -17
  144. package/dist/mcp/config-loader.d.ts +5 -5
  145. package/dist/mcp/config-loader.js +17 -17
  146. package/dist/mcp/credentials.d.ts +35 -0
  147. package/dist/mcp/credentials.js +2 -0
  148. package/dist/mcp/filter.d.ts +2 -2
  149. package/dist/mcp/index.d.ts +4 -3
  150. package/dist/mcp/index.js +1 -1
  151. package/dist/mcp/manager.d.ts +108 -6
  152. package/dist/mcp/manager.js +262 -18
  153. package/dist/mcp/oauth/callback-server.d.ts +10 -1
  154. package/dist/mcp/oauth/callback-server.js +82 -16
  155. package/dist/mcp/oauth/index.d.ts +2 -2
  156. package/dist/mcp/oauth/provider.d.ts +18 -0
  157. package/dist/mcp/oauth/provider.js +31 -1
  158. package/dist/mcp/oauth/service.d.ts +9 -3
  159. package/dist/mcp/oauth/service.js +29 -4
  160. package/dist/mcp/sdk-transport.js +1 -1
  161. package/dist/mcp/server.js +1 -1
  162. package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
  163. package/dist/permission/auto-approver/prompts-data.js +1 -1
  164. package/dist/permission/manager.d.ts +5 -3
  165. package/dist/permission/manager.js +7 -3
  166. package/dist/permission/policies.d.ts +2 -2
  167. package/dist/permission/policies.js +4 -4
  168. package/dist/plugins/fields.d.ts +14 -0
  169. package/dist/plugins/fields.js +30 -0
  170. package/dist/plugins/hooks.d.ts +2 -2
  171. package/dist/plugins/hooks.js +12 -12
  172. package/dist/plugins/index.js +1 -0
  173. package/dist/plugins/manager.d.ts +8 -3
  174. package/dist/plugins/manager.js +18 -7
  175. package/dist/plugins/manifest.d.ts +2 -2
  176. package/dist/plugins/manifest.js +101 -91
  177. package/dist/plugins/marketplace.js +76 -57
  178. package/dist/plugins/store.d.ts +3 -3
  179. package/dist/plugins/store.js +6 -6
  180. package/dist/protocol/index.d.ts +1 -1
  181. package/dist/store/catalog-store.d.ts +4 -1
  182. package/dist/store/catalog-store.js +5 -1
  183. package/dist/store/checkpointing-store.d.ts +41 -0
  184. package/dist/store/checkpointing-store.js +86 -0
  185. package/dist/store/disk-store.d.ts +8 -0
  186. package/dist/store/disk-store.js +127 -5
  187. package/dist/store/index.d.ts +3 -2
  188. package/dist/store/index.js +2 -1
  189. package/dist/store/log-store.d.ts +9 -1
  190. package/dist/store/log-store.js +68 -4
  191. package/dist/store/migrate.d.ts +8 -2
  192. package/dist/store/migrate.js +9 -2
  193. package/dist/store/origin.d.ts +31 -6
  194. package/dist/store/origin.js +0 -14
  195. package/dist/store/pg.d.ts +1 -0
  196. package/dist/store/pg.js +37 -2
  197. package/dist/store/redis.d.ts +1 -0
  198. package/dist/store/redis.js +30 -0
  199. package/dist/store/repository.d.ts +13 -1
  200. package/dist/store/repository.js +45 -2
  201. package/dist/store/session-catalog.d.ts +4 -0
  202. package/dist/store/session-catalog.js +6 -0
  203. package/dist/store/storage.js +3 -0
  204. package/dist/store/store.d.ts +97 -34
  205. package/dist/store/store.js +64 -10
  206. package/dist/telemetry/appender.d.ts +43 -0
  207. package/dist/telemetry/appender.js +46 -0
  208. package/dist/telemetry/events.d.ts +142 -0
  209. package/dist/telemetry/events.js +141 -0
  210. package/dist/telemetry/index.d.ts +10 -0
  211. package/dist/telemetry/index.js +6 -0
  212. package/dist/telemetry/projection.d.ts +23 -0
  213. package/dist/telemetry/projection.js +185 -0
  214. package/dist/telemetry/redact.d.ts +20 -0
  215. package/dist/telemetry/redact.js +40 -0
  216. package/dist/telemetry/service.d.ts +49 -0
  217. package/dist/telemetry/service.js +137 -0
  218. package/dist/testing.d.ts +58 -0
  219. package/dist/testing.js +123 -0
  220. package/dist/tool/background.d.ts +9 -6
  221. package/dist/tool/background.js +7 -1
  222. package/dist/tool/builtin/ask-user-question.js +6 -5
  223. package/dist/tool/builtin/bash.d.ts +6 -0
  224. package/dist/tool/builtin/bash.js +79 -42
  225. package/dist/tool/builtin/edit.js +82 -109
  226. package/dist/tool/builtin/glob.js +13 -13
  227. package/dist/tool/builtin/grep.js +13 -13
  228. package/dist/tool/builtin/read.js +25 -15
  229. package/dist/tool/builtin/write.js +49 -33
  230. package/dist/tool/define.d.ts +14 -8
  231. package/dist/tool/define.js +8 -2
  232. package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
  233. package/dist/tool/{machine-base.js → environment-base.js} +45 -119
  234. package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
  235. package/dist/tool/{machine-local.js → environment-local.js} +60 -81
  236. package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
  237. package/dist/tool/{machine-null.js → environment-null.js} +9 -9
  238. package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
  239. package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
  240. package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
  241. package/dist/tool/environment.js +2 -0
  242. package/dist/tool/file-freshness.d.ts +33 -19
  243. package/dist/tool/file-freshness.js +39 -30
  244. package/dist/tool/filesystem-tools.d.ts +1 -1
  245. package/dist/tool/filesystem-tools.js +1 -1
  246. package/dist/tool/git-context.d.ts +2 -2
  247. package/dist/tool/git-context.js +8 -8
  248. package/dist/tool/index.d.ts +12 -12
  249. package/dist/tool/index.js +12 -10
  250. package/dist/tool/policies/path-access.d.ts +4 -4
  251. package/dist/tool/policies/path-access.js +12 -12
  252. package/dist/tool/questions.d.ts +8 -0
  253. package/dist/tool/search/catalog.d.ts +37 -0
  254. package/dist/tool/search/catalog.js +182 -0
  255. package/dist/tool/search/deferral.d.ts +3 -2
  256. package/dist/tool/search/loaded.d.ts +32 -0
  257. package/dist/tool/search/loaded.js +96 -0
  258. package/dist/tool/search/search-tool.d.ts +2 -6
  259. package/dist/tool/search/search-tool.js +16 -15
  260. package/dist/tool/shell-env.js +4 -0
  261. package/dist/tool/support/bash-paths.js +38 -7
  262. package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
  263. package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
  264. package/dist/tool/support/git-worktree.d.ts +3 -3
  265. package/dist/tool/support/git-worktree.js +6 -6
  266. package/dist/tool/support/rg-locator.d.ts +6 -6
  267. package/dist/tool/support/rg-locator.js +6 -6
  268. package/dist/tool/support/ripgrep-run.d.ts +5 -5
  269. package/dist/tool/support/ripgrep-run.js +3 -3
  270. package/dist/tool/support/tool-path.d.ts +3 -3
  271. package/dist/tool/support/tool-path.js +7 -7
  272. package/dist/tool/types.d.ts +54 -10
  273. package/dist/tool/web/fetch-url.js +1 -1
  274. package/dist/tool/web/web-search.js +1 -1
  275. package/dist/tool/workspace-spec.d.ts +3 -3
  276. package/dist/tool/workspace-spec.js +27 -27
  277. package/dist/tracing/bridge.d.ts +9 -1
  278. package/dist/tracing/bridge.js +307 -77
  279. package/dist/tracing/index.d.ts +2 -2
  280. package/dist/tracing/otel.d.ts +28 -1
  281. package/dist/tracing/otel.js +150 -38
  282. package/dist/tracing/processor.d.ts +22 -0
  283. package/dist/tracing/processor.js +2 -0
  284. package/dist/tracing/spans.d.ts +54 -0
  285. package/dist/tracing/spans.js +5 -0
  286. package/package.json +6 -2
  287. package/dist/tool/machine.js +0 -15
  288. package/dist/tool/search/activation.d.ts +0 -13
  289. package/dist/tool/search/activation.js +0 -31
@@ -60,7 +60,7 @@ export interface ByteRange {
60
60
  export type DecodeErrors = "strict" | "replace" | "ignore";
61
61
  export type OsKind = "Linux" | "Darwin" | "Windows" | (string & {});
62
62
  export type ShellName = "bash" | "zsh" | "sh" | "powershell" | "cmd" | (string & {});
63
- export interface Environment {
63
+ export interface OsInfo {
64
64
  readonly osKind: OsKind;
65
65
  readonly osArch: string;
66
66
  readonly osVersion: string;
@@ -95,11 +95,11 @@ export interface DirEntry {
95
95
  readonly kind: FileKind;
96
96
  }
97
97
  /**
98
- * Version stamp for optimistic-concurrency writes. mtime and nothing else
99
- * (local-first): on hosts with a reliable mtime the check is free; hosts
100
- * without one (some sandbox vendors) leave `mtimeMs` undefined, and every
101
- * check there falls back to content comparison (see FileFreshnessLedger).
102
- * No hashing anywhere.
98
+ * Version stamp for the session's read-state record (see FileFreshnessLedger).
99
+ * mtime and nothing else (local-first): on hosts with a reliable mtime the check
100
+ * is free; hosts without one (some sandbox vendors) leave `mtimeMs` undefined,
101
+ * and every check there falls back to content comparison, done on a digest
102
+ * (`hashFileContent`) so neither side retains the text.
103
103
  *
104
104
  * Size deliberately plays no part. It only ever ruled on cases the mtime had
105
105
  * already decided, except for one it decided WRONG: an mtime-less backend
@@ -117,38 +117,19 @@ export interface WriteTextOptions {
117
117
  /** Line-ending style to restore on write; `data` is LF-normalized. Default LF. */
118
118
  readonly lineEndings?: "LF" | "CRLF";
119
119
  }
120
- export interface WriteTextIfUnchangedOptions extends WriteTextOptions {
121
- /**
122
- * Expected pre-write state (REQUIRED — the name must not lie; an unconditional
123
- * write is {@link Machine.writeText}):
124
- * - FileVersion: file must still match (mtime-first); mismatch throws StaleFileError.
125
- * - "must-not-exist": create-new semantics; an existing file throws FileExistsError.
126
- */
127
- readonly expected: FileVersion | "must-not-exist";
128
- /**
129
- * Prior full content (LF-normalized) for false-positive review when the mtime moved
130
- * or is unavailable. Omit to treat any mtime change as a conflict.
131
- */
132
- readonly expectedContent?: string;
133
- }
134
120
  export interface WriteTextResult {
135
121
  readonly bytesWritten: number;
136
- }
137
- export interface WriteFileResult {
138
- readonly bytesWritten: number;
139
- /** Post-write version, for the caller to record in its ledger. */
140
- readonly version: FileVersion;
141
- }
142
- export declare class StaleFileError extends Error {
143
- readonly code = "FILE_MODIFIED_SINCE_READ";
144
- constructor(message?: string);
145
- }
146
- export declare class FileExistsError extends Error {
147
- readonly code = "FILE_ALREADY_EXISTS";
148
- constructor(message?: string);
122
+ /**
123
+ * The version this write produced — present ONLY when the backend already knew it
124
+ * (LocalEnvironment: one stat syscall). `undefined` everywhere a round trip would be
125
+ * needed to learn it, which is why it is optional rather than a promise: the caller
126
+ * records what it got, and a versionless record is decided by content instead
127
+ * (see FileFreshnessLedger). Never stat here just to fill it in.
128
+ */
129
+ readonly version?: FileVersion;
149
130
  }
150
131
  /**
151
- * Handle to the machine the workspace lives on.
132
+ * Handle to the environment the workspace lives on.
152
133
  *
153
134
  * Not a filesystem abstraction: files, processes and path/OS semantics are one
154
135
  * contract precisely because they must agree — a command started by `run` sees
@@ -158,17 +139,18 @@ export declare class FileExistsError extends Error {
158
139
  * - `run` is the universal primitive — the single way anything executes, from a
159
140
  * one-shot `git status` to a background build. Search-shaped operations (grep,
160
141
  * glob) run a uniform binary through it rather than getting their own member.
161
- * - File I/O is three members: `readBytes` (every read, whole file or a byte
162
- * window), and two write contracts that are deliberately separate so each
163
- * name is honest: `writeText` ("just write" — no staleness check, no stats,
164
- * no version) and `writeTextIfUnchanged` (compare-and-swap for the
165
- * read-before-write tool path; `expected` is required by the type).
142
+ * - File I/O is `readBytes` (every read, whole file or a byte window) plus two
143
+ * unconditional writes, `writeText` and `writeBytes`. There is deliberately NO
144
+ * compare-and-swap write: the read-before-write safety the tools need is decided
145
+ * against the session's read-state record (FileFreshnessLedger) BEFORE the write,
146
+ * and no backend but the local one can make the compare and the write one step
147
+ * anyway — a CAS member could only have promised what it does not deliver.
166
148
  * - `realpath` exists for symlink anti-bypass: path-access
167
149
  * checks canonicalize before prefix-matching. The threat model is the tool
168
150
  * call escaping the workspace, not the backend lying — so a `readlink -f` run
169
151
  * through `run` is as authoritative as the backend's own FS view.
170
152
  *
171
- * Implementations extend {@link BaseMachine} (machine-base.ts):
153
+ * Implementations extend {@link BaseEnvironment} (environment-base.ts):
172
154
  * it derives the high-level operations from a small SPI so a new backend only
173
155
  * writes the dumb primitives, and overrides them only where it can do better
174
156
  * (single round trip, true atomicity, bounded-memory streaming).
@@ -178,9 +160,9 @@ export declare class FileExistsError extends Error {
178
160
  * by the user's workspace goes through the host; content owned by the agent's
179
161
  * session goes through the store.
180
162
  */
181
- export interface Machine {
163
+ export interface Environment {
182
164
  readonly name: string;
183
- readonly osEnv: Environment;
165
+ readonly osInfo: OsInfo;
184
166
  pathClass(): "posix" | "win32";
185
167
  normpath(path: string): string;
186
168
  gethome(): string;
@@ -193,24 +175,24 @@ export interface Machine {
193
175
  */
194
176
  additionalDirs?(): readonly string[];
195
177
  /**
196
- * Return a sibling machine rooted at `cwd`, sharing this machine's backend
197
- * resources (the same ssh connection / sandbox session / local machine) — only
178
+ * Return a sibling environment rooted at `cwd`, sharing this environment's backend
179
+ * resources (the same ssh connection / sandbox session / local environment) — only
198
180
  * the working directory differs. Purely structural and cheap (no I/O); the
199
181
  * symmetric counterpart of `getcwd()`. Callers that need an isolated workspace
200
182
  * (e.g. a git worktree for a subagent) build it on top of this rather than the
201
- * machine knowing anything about isolation. A relative `cwd` resolves against
202
- * the current one. Never mutates this machine, so re-rooting one copy can't
183
+ * environment knowing anything about isolation. A relative `cwd` resolves against
184
+ * the current one. Never mutates this environment, so re-rooting one copy can't
203
185
  * clobber the cwd of another that shares the same connection.
204
186
  */
205
- withCwd(cwd: string): Machine;
187
+ withCwd(cwd: string): Environment;
206
188
  /**
207
- * Public URL for a port listening inside this machine, or `undefined` when the backend
189
+ * Public URL for a port listening inside this environment, or `undefined` when the backend
208
190
  * has no way to expose one (local, ssh, a sandbox without port forwarding). A dev server
209
191
  * the agent just started is only useful if someone can reach it, and only the backend
210
192
  * knows the mapping — E2B's `getHost`, a vendor tunnel, and so on.
211
193
  *
212
- * This is an OPERATION on a running machine, not workspace lifecycle: it answers a
213
- * question about a machine we were handed, and never creates or destroys anything.
194
+ * This is an OPERATION on a running environment, not workspace lifecycle: it answers a
195
+ * question about an environment we were handed, and never creates or destroys anything.
214
196
  * `undefined` rather than a throw, so a caller writes one code path.
215
197
  */
216
198
  exposedPortUrl?(port: number): Promise<string | undefined>;
@@ -227,7 +209,7 @@ export interface Machine {
227
209
  * `onOutput`, learn how it ended from the resolved result. That is exactly what the
228
210
  * background-task machinery does.
229
211
  *
230
- * `BaseMachine` derives it from a process-spawning SPI, so local and SSH backends get it
212
+ * `BaseEnvironment` derives it from a process-spawning SPI, so local and SSH backends get it
231
213
  * for free; backends with native support (a vendor `timeoutMs` + `kill`) override it.
232
214
  */
233
215
  run(argv: readonly string[], options?: RunCommandOptions): Promise<RunCommandResult>;
@@ -241,7 +223,7 @@ export interface Machine {
241
223
  *
242
224
  * Entries carry their `kind` because every backend's readdir already knows it — handing
243
225
  * back bare names would force callers into a stat per entry, which is free locally and
244
- * seconds of serial round trips on a remote machine. `kind` is lstat semantics; resolve
226
+ * seconds of serial round trips on a remote environment. `kind` is lstat semantics; resolve
245
227
  * `"symlink"` entries with `fileInfo` when the target kind matters (see `DirEntry`).
246
228
  */
247
229
  listDir(path: string): Promise<readonly DirEntry[]>;
@@ -251,7 +233,6 @@ export interface Machine {
251
233
  * directory is always OK (`existOk` is implied and effectively ignored).
252
234
  * - `existOk: true` (with `parents` unset/false) — an existing DIRECTORY at `path` is
253
235
  * OK; anything else occupying the path (a file) must still throw EEXIST.
254
- * (Known deviation: `SshMachine` currently passes a file occupant through.)
255
236
  * - neither — plain mkdir: throws if `path` exists or its parent is missing.
256
237
  */
257
238
  mkdir(path: string, options?: {
@@ -275,31 +256,21 @@ export interface Machine {
275
256
  * through a shell.
276
257
  */
277
258
  writeBytes(path: string, data: Buffer): Promise<void>;
278
- /** Unconditional text write — no staleness check, no stat round trips, no version stamp. */
279
- writeText(path: string, data: string, options?: WriteTextOptions): Promise<WriteTextResult>;
280
259
  /**
281
- * Compare-and-swap text write for the read-before-write tool path (Edit/Write + ledger).
260
+ * Unconditional text write — no staleness check, no stat round trips, no version stamp.
282
261
  *
283
- * What "if unchanged" guarantees is TIERED — this is optimistic concurrency over
284
- * backends without a CAS primitive, not an atomic instruction:
285
- * - Same-process writers: fully serialized per file (BaseMachine's path lock;
286
- * LocalMachine's synchronous critical section). Two concurrent calls cannot
287
- * interleave their compare and write, and the returned `version` is the one
288
- * this write produced, not a later sibling's.
289
- * - External writers (other processes, remote users): the compare and the write
290
- * are separate operations. LocalMachine's gap is sub-millisecond; remote
291
- * backends' is ~1 round trip (SFTP and sandbox file APIs have no CAS). An
292
- * external write landing inside that window is silently overwritten — the
293
- * protocol ceiling, documented rather than papered over.
294
- * - `expected: "must-not-exist"` on SshMachine is the exception: strictly atomic
295
- * (server-enforced SFTP EXCL create), even against external writers.
262
+ * `lineEndings: "CRLF"` normalizes to LF first and then joins, so text that ALREADY contains
263
+ * `\r\n` — which model output routinely does, having just read a CRLF file — comes out with
264
+ * `\r\n` rather than `\r\r\n`. Backends share one implementation of this; a backend
265
+ * overriding `writeText` must keep the same two-step.
296
266
  *
297
- * Errors: {@link StaleFileError} — the file changed, OR the backend could not
298
- * establish that it hadn't (no mtime and no `expectedContent` to review against;
299
- * unverifiable is refused, not waved through); {@link FileExistsError} —
300
- * "must-not-exist" violated.
267
+ * Whether the file lands all-at-once is a BACKEND property, not a promise of this
268
+ * contract: LocalEnvironment swaps a sibling temp file into place (free there, and it
269
+ * keeps symlink/mode semantics), remote backends write straight to the target
270
+ * because staging a temp file and renaming it costs round trips on every write to
271
+ * narrow a window nothing in the tool path depends on.
301
272
  */
302
- writeTextIfUnchanged(path: string, data: string, options: WriteTextIfUnchangedOptions): Promise<WriteFileResult>;
273
+ writeText(path: string, data: string, options?: WriteTextOptions): Promise<WriteTextResult>;
303
274
  /**
304
275
  * Canonicalize symlinks (security: path-access checks must canonicalize before
305
276
  * prefix-matching). Derived default is `readlink -f` on posix / normpath on
@@ -308,26 +279,26 @@ export interface Machine {
308
279
  */
309
280
  realpath(path: string): Promise<string>;
310
281
  }
311
- export interface MachineOpenContext {
282
+ export interface EnvironmentOpenContext {
312
283
  readonly sessionId: string;
313
284
  readonly signal: AbortSignal;
314
285
  }
315
286
  /**
316
- * Lazy, per-session way to hand a session its {@link Machine} — for hosts that can only
287
+ * Lazy, per-session way to hand a session its {@link Environment} — for hosts that can only
317
288
  * build one once they know the session (or that must `await` a connection). Pass a
318
- * `Machine` directly whenever one already exists; that is the common case.
289
+ * `Environment` directly whenever one already exists; that is the common case.
319
290
  *
320
291
  * Sandbox LIFECYCLE — creating, snapshotting, pausing, destroying — deliberately lives
321
292
  * outside this framework. A sandbox is typically a user- or workspace-scoped resource
322
293
  * whose lifetime spans many sessions (new, resumed and forked alike), so the layer that
323
294
  * knows when a user is actually done is the host, not a session. The host creates the
324
- * sandbox, hands the machine in, and disposes of it on its own terms; everything here
325
- * only ever OPERATES a machine it was given — which is also why this type has no
326
- * teardown half: a factory that mints a machine per session has nowhere to release it.
295
+ * sandbox, hands the environment in, and disposes of it on its own terms; everything here
296
+ * only ever OPERATES an environment it was given — which is also why this type has no
297
+ * teardown half: a factory that mints an environment per session has nowhere to release it.
327
298
  *
328
299
  * The concrete thing this buys: nothing in a session's durable state points at a sandbox,
329
300
  * so forking a session cannot silently make two sessions share one workspace, and closing
330
301
  * one session cannot pull the sandbox out from under the others.
331
302
  */
332
- export type MachineFactory = (ctx: MachineOpenContext) => Machine | Promise<Machine>;
333
- //# sourceMappingURL=machine.d.ts.map
303
+ export type EnvironmentFactory = (ctx: EnvironmentOpenContext) => Environment | Promise<Environment>;
304
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=environment.js.map
@@ -9,30 +9,27 @@
9
9
  * by the loop. Keys are host-canonical absolute paths.
10
10
  *
11
11
  * Freshness is mtime-first (local-first): when both sides have an mtime and it
12
- * matches, the file is fresh with zero extra I/O. Content comparison — against the
13
- * retained prior text, no hashing — runs only when the mtime moved (false-positive
14
- * review: cloud sync / antivirus / Windows) or is unavailable (mtime-less sandbox
15
- * backends).
16
- */
17
- import type { FileVersion, LineEndings } from "./machine.ts";
18
- /**
19
- * Above this, content is not retained (version-only record) — freshness then degrades to
20
- * conservative-stale on mtime change.
12
+ * matches, the file is fresh with zero extra I/O. Content comparison runs only when
13
+ * the mtime moved (false-positive review: cloud sync / antivirus / Windows) or is
14
+ * unavailable (mtime-less sandbox backends), and compares a digest of the text the
15
+ * record was taken from — the text itself is never retained, so a record costs the
16
+ * same for a 1 KB file and a 10 MB one.
21
17
  *
22
- * It bounds the WRITE path, not the read path. A read can only retain content when it read
23
- * the file whole, which the Read tool's own output caps already keep far below this. A write
24
- * has no such ceiling: `recordWrite` retains whatever the model just produced, and nothing
25
- * stops that from being a multi-megabyte generated file.
18
+ * Bounded as an LRU: an agent that has touched more than {@link LEDGER_MAX_ENTRIES}
19
+ * files forgets the least recently used, which then reads as "not read yet" — the
20
+ * conservative direction.
26
21
  */
27
- export declare const CONTENT_RETENTION_MAX_BYTES: number;
22
+ import type { FileVersion, LineEndings } from "./environment.ts";
23
+ /** Default record cap of a {@link FileFreshnessLedger}. */
24
+ export declare const LEDGER_MAX_ENTRIES = 5000;
28
25
  export declare const FILE_NOT_READ_MESSAGE = "File has not been read yet. Read it first before writing to it.";
29
26
  export declare const FILE_MODIFIED_MESSAGE = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.";
30
27
  export declare const FILE_UNCHANGED_STUB = "File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current; refer to that instead of re-reading.";
31
28
  export interface FileReadRecord {
32
29
  readonly version: FileVersion;
33
- /** Full text (LF-normalized, BOM-stripped) retained for full reads within the size cap. */
34
- readonly content?: string;
35
- /** True when the read had no offset/limit. Partial reads never pass content review. */
30
+ /** {@link hashFileContent} of the full text (LF-normalized, BOM-stripped); full reads only. */
31
+ readonly contentHash?: string;
32
+ /** True when the read covered the whole file. Partial reads never pass content review. */
36
33
  readonly fullRead: boolean;
37
34
  readonly range?: {
38
35
  readonly lineOffset: number;
@@ -50,17 +47,34 @@ export type FreshnessVerdict = {
50
47
  } | {
51
48
  readonly kind: "stale";
52
49
  };
50
+ /** What a reader hands the ledger: the record, with the text in place of its digest. */
51
+ export type RecordReadInput = Omit<FileReadRecord, "contentHash"> & {
52
+ /** Full text (LF-normalized, BOM-stripped) — hashed, not retained. Pass only for full reads. */
53
+ readonly content?: string;
54
+ };
53
55
  export interface RecordWriteOptions {
56
+ /**
57
+ * Post-write version, when the caller happens to have one. Omitted by the write
58
+ * path on purpose: a stat after every write costs a round trip on remote backends
59
+ * to record an mtime the next check does not need — a versionless record is
60
+ * decided by {@link RecordWriteOptions.content}'s digest, which Edit compares for
61
+ * free against the text it must read anyway.
62
+ */
63
+ readonly version?: FileVersion;
64
+ /** The written text (LF-normalized, BOM-stripped) — hashed, not retained. */
54
65
  readonly content?: string;
55
66
  readonly lineEndings?: LineEndings;
56
67
  readonly encoding?: BufferEncoding;
57
68
  }
58
69
  export declare class FileFreshnessLedger {
59
70
  private readonly records;
60
- recordRead(path: string, record: FileReadRecord): void;
71
+ private readonly maxEntries;
72
+ constructor(maxEntries?: number);
73
+ recordRead(path: string, input: RecordReadInput): void;
61
74
  /** A successful write makes the writer the last reader. */
62
- recordWrite(path: string, version: FileVersion, options?: RecordWriteOptions): void;
75
+ recordWrite(path: string, options?: RecordWriteOptions): void;
63
76
  get(path: string): FileReadRecord | undefined;
77
+ private put;
64
78
  delete(path: string): void;
65
79
  clear(): void;
66
80
  get size(): number;
@@ -1,45 +1,54 @@
1
- // Same predicate the Machine-side check uses (BaseMachine.assertUnchanged) — the two
1
+ // Same predicate the Environment-side check uses (BaseEnvironment.assertUnchanged) — the two
2
2
  // run at different moments and must never disagree about what "unchanged" means.
3
- import { fileVersionsMatch } from "./support/machine-ops.js";
4
- /**
5
- * Above this, content is not retained (version-only record) — freshness then degrades to
6
- * conservative-stale on mtime change.
7
- *
8
- * It bounds the WRITE path, not the read path. A read can only retain content when it read
9
- * the file whole, which the Read tool's own output caps already keep far below this. A write
10
- * has no such ceiling: `recordWrite` retains whatever the model just produced, and nothing
11
- * stops that from being a multi-megabyte generated file.
12
- */
13
- export const CONTENT_RETENTION_MAX_BYTES = 10 * 1024 * 1024;
3
+ import { fileVersionsMatch, hashFileContent } from "./support/environment-ops.js";
4
+ /** Default record cap of a {@link FileFreshnessLedger}. */
5
+ export const LEDGER_MAX_ENTRIES = 5000;
14
6
  export const FILE_NOT_READ_MESSAGE = "File has not been read yet. Read it first before writing to it.";
15
7
  export const FILE_MODIFIED_MESSAGE = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.";
16
8
  export const FILE_UNCHANGED_STUB = "File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current; refer to that instead of re-reading.";
17
- function clampContent(record) {
18
- if (record.content === undefined)
19
- return record;
20
- if (Buffer.byteLength(record.content, "utf8") <= CONTENT_RETENTION_MAX_BYTES)
21
- return record;
22
- const { content: _dropped, ...rest } = record;
23
- return rest;
24
- }
25
9
  export class FileFreshnessLedger {
10
+ // Map iteration order is insertion order: re-inserting on every touch keeps the
11
+ // least recently used entry first.
26
12
  records = new Map();
27
- recordRead(path, record) {
28
- this.records.set(path, clampContent(record));
13
+ maxEntries;
14
+ constructor(maxEntries = LEDGER_MAX_ENTRIES) {
15
+ this.maxEntries = maxEntries;
16
+ }
17
+ recordRead(path, input) {
18
+ const { content, ...rest } = input;
19
+ this.put(path, { ...rest, ...(content !== undefined ? { contentHash: hashFileContent(content) } : {}) });
29
20
  }
30
21
  /** A successful write makes the writer the last reader. */
31
- recordWrite(path, version, options = {}) {
32
- this.records.set(path, clampContent({
33
- version,
22
+ recordWrite(path, options = {}) {
23
+ this.put(path, {
24
+ // No version: "the backend has no mtime for this" and "we did not spend a stat
25
+ // to learn it" reach the freshness check as the same thing — unverifiable by
26
+ // mtime, decided by content. One rule, not two.
27
+ version: options.version ?? {},
34
28
  fullRead: true,
35
29
  lineEndings: options.lineEndings ?? "LF",
36
30
  encoding: options.encoding ?? "utf8",
37
31
  readAt: Date.now(),
38
- ...(options.content !== undefined ? { content: options.content } : {}),
39
- }));
32
+ ...(options.content !== undefined ? { contentHash: hashFileContent(options.content) } : {}),
33
+ });
40
34
  }
41
35
  get(path) {
42
- return this.records.get(path);
36
+ const record = this.records.get(path);
37
+ if (record !== undefined) {
38
+ this.records.delete(path);
39
+ this.records.set(path, record);
40
+ }
41
+ return record;
42
+ }
43
+ put(path, record) {
44
+ this.records.delete(path);
45
+ this.records.set(path, record);
46
+ while (this.records.size > this.maxEntries) {
47
+ const oldest = this.records.keys().next().value;
48
+ if (oldest === undefined)
49
+ break;
50
+ this.records.delete(oldest);
51
+ }
43
52
  }
44
53
  delete(path) {
45
54
  this.records.delete(path);
@@ -57,9 +66,9 @@ export async function checkFreshness(input) {
57
66
  return { kind: "not-read" };
58
67
  if (fileVersionsMatch(record.version, input.current))
59
68
  return { kind: "fresh" };
60
- if (record.fullRead && record.content !== undefined && input.currentContent !== undefined) {
69
+ if (record.fullRead && record.contentHash !== undefined && input.currentContent !== undefined) {
61
70
  const currentText = await input.currentContent();
62
- if (currentText !== undefined && currentText === record.content)
71
+ if (currentText !== undefined && hashFileContent(currentText) === record.contentHash)
63
72
  return { kind: "fresh" };
64
73
  }
65
74
  return { kind: "stale" };
@@ -7,7 +7,7 @@ export interface FilesystemToolsOptions {
7
7
  readonly mode?: "all" | "readonly";
8
8
  }
9
9
  /**
10
- * The standard machine-backed builtin tools as a single array — convenience
10
+ * The standard environment-backed builtin tools as a single array — convenience
11
11
  * sugar for assembling an agent's toolset (`tools: filesystemTools()`). It is
12
12
  * NOT a capability or a new mechanism: these are the same tools exported
13
13
  * individually from this package. Omit it entirely for a no-filesystem agent.
@@ -5,7 +5,7 @@ import { grepTool } from "./builtin/grep.js";
5
5
  import { readTool } from "./builtin/read.js";
6
6
  import { writeTool } from "./builtin/write.js";
7
7
  /**
8
- * The standard machine-backed builtin tools as a single array — convenience
8
+ * The standard environment-backed builtin tools as a single array — convenience
9
9
  * sugar for assembling an agent's toolset (`tools: filesystemTools()`). It is
10
10
  * NOT a capability or a new mechanism: these are the same tools exported
11
11
  * individually from this package. Omit it entirely for a no-filesystem agent.
@@ -1,4 +1,4 @@
1
- import type { Machine } from "./machine.ts";
1
+ import type { Environment } from "./environment.ts";
2
2
  export interface GitContextOptions {
3
3
  readonly maxDirtyFiles?: number;
4
4
  readonly recentCommits?: number;
@@ -13,7 +13,7 @@ export interface GitContext {
13
13
  readonly dirtyCount: number;
14
14
  readonly recentCommits: readonly string[];
15
15
  }
16
- export declare function collectGitContext(machine: Machine, cwd: string, options?: GitContextOptions): Promise<GitContext>;
16
+ export declare function collectGitContext(environment: Environment, cwd: string, options?: GitContextOptions): Promise<GitContext>;
17
17
  export declare function formatGitContext(ctx: GitContext): string;
18
18
  export declare function sanitizeRemoteUrl(remoteUrl: string): string | null;
19
19
  export declare function parseProjectName(remoteUrl: string): string | null;
@@ -3,17 +3,17 @@ const DEFAULT_MAX_DIRTY_FILES = 20;
3
3
  const DEFAULT_RECENT_COMMITS = 3;
4
4
  const MAX_COMMIT_LINE_LENGTH = 200;
5
5
  const ALLOWED_HOSTS = ["github.com", "gitlab.com", "gitee.com", "bitbucket.org", "codeberg.org", "git.sr.ht"];
6
- export async function collectGitContext(machine, cwd, options = {}) {
6
+ export async function collectGitContext(environment, cwd, options = {}) {
7
7
  const maxDirty = options.maxDirtyFiles ?? DEFAULT_MAX_DIRTY_FILES;
8
8
  const nCommits = options.recentCommits ?? DEFAULT_RECENT_COMMITS;
9
- if ((await runGit(machine, cwd, ["rev-parse", "--is-inside-work-tree"])) === null) {
9
+ if ((await runGit(environment, cwd, ["rev-parse", "--is-inside-work-tree"])) === null) {
10
10
  return { isRepo: false, cwd, dirtyFiles: [], dirtyCount: 0, recentCommits: [] };
11
11
  }
12
12
  const [remoteRaw, branchRaw, dirtyRaw, logRaw] = await Promise.all([
13
- runGit(machine, cwd, ["remote", "get-url", "origin"]),
14
- runGit(machine, cwd, ["branch", "--show-current"]),
15
- runGit(machine, cwd, ["status", "--porcelain"]),
16
- runGit(machine, cwd, ["log", `-${String(nCommits)}`, "--format=%h %s"]),
13
+ runGit(environment, cwd, ["remote", "get-url", "origin"]),
14
+ runGit(environment, cwd, ["branch", "--show-current"]),
15
+ runGit(environment, cwd, ["status", "--porcelain"]),
16
+ runGit(environment, cwd, ["log", `-${String(nCommits)}`, "--format=%h %s"]),
17
17
  ]);
18
18
  const remote = remoteRaw !== null ? (sanitizeRemoteUrl(remoteRaw) ?? undefined) : undefined;
19
19
  const project = remote !== undefined ? (parseProjectName(remote) ?? undefined) : undefined;
@@ -105,8 +105,8 @@ function tryUrlPath(remoteUrl) {
105
105
  * the backend enforces it with its own kill (and a backend that cannot reports `timedOut`
106
106
  * without pretending it stopped anything).
107
107
  */
108
- async function runGit(machine, cwd, args) {
109
- const result = await machine.run(["git", "-C", cwd, ...args], { timeoutMs: GIT_TIMEOUT_MS }).catch(() => undefined);
108
+ async function runGit(environment, cwd, args) {
109
+ const result = await environment.run(["git", "-C", cwd, ...args], { timeoutMs: GIT_TIMEOUT_MS }).catch(() => undefined);
110
110
  if (result === undefined || result.timedOut || result.exitCode !== 0)
111
111
  return null;
112
112
  return result.stdout.trim();
@@ -1,22 +1,21 @@
1
1
  export type * from "./types.ts";
2
2
  export { ToolAccesses } from "./access.ts";
3
- export type { Machine, MachineFactory, MachineOpenContext, DecodeErrors, Environment, OsKind, ShellName, } from "./machine.ts";
4
- export { StaleFileError, FileExistsError } from "./machine.ts";
5
- export type { ByteRange, RunCommandResult, DirEntry, OutputChunk, RunCommandOptions, FileInfo, FileKind, FileVersion, LineEndings, WriteTextOptions, WriteTextResult, WriteTextIfUnchangedOptions, WriteFileResult, } from "./machine.ts";
6
- export { BaseMachine } from "./machine-base.ts";
7
- export type { SpawnedProcess } from "./machine-base.ts";
3
+ export type { Environment, EnvironmentFactory, EnvironmentOpenContext, DecodeErrors, OsInfo, OsKind, ShellName, } from "./environment.ts";
4
+ export type { ByteRange, RunCommandResult, DirEntry, OutputChunk, RunCommandOptions, FileInfo, FileKind, FileVersion, LineEndings, WriteTextOptions, WriteTextResult, } from "./environment.ts";
5
+ export { BaseEnvironment } from "./environment-base.ts";
6
+ export type { SpawnedProcess } from "./environment-base.ts";
8
7
  export { materializeWorkspace, describeWorkspace, WorkspaceMaterializeError } from "./workspace-spec.ts";
9
8
  export type { HostReader, MaterializeOptions, WorkspaceEntry, WorkspaceSpec } from "./workspace-spec.ts";
10
- export { FileFreshnessLedger, checkFreshness, CONTENT_RETENTION_MAX_BYTES, FILE_NOT_READ_MESSAGE, FILE_MODIFIED_MESSAGE, FILE_UNCHANGED_STUB, } from "./file-freshness.ts";
11
- export type { FileReadRecord, FreshnessVerdict, RecordWriteOptions, CheckFreshnessInput } from "./file-freshness.ts";
12
- export { LocalMachine, detectEnvironment } from "./machine-local.ts";
13
- export { NullMachine } from "./machine-null.ts";
9
+ export { FileFreshnessLedger, checkFreshness, LEDGER_MAX_ENTRIES, FILE_NOT_READ_MESSAGE, FILE_MODIFIED_MESSAGE, FILE_UNCHANGED_STUB, } from "./file-freshness.ts";
10
+ export type { FileReadRecord, FreshnessVerdict, RecordReadInput, RecordWriteOptions, CheckFreshnessInput } from "./file-freshness.ts";
11
+ export { LocalEnvironment, detectOsInfo } from "./environment-local.ts";
12
+ export { NullEnvironment } from "./environment-null.ts";
14
13
  export { nonInteractiveShellEnv, proxyEnv, PROXY_ENV_VARS } from "./shell-env.ts";
15
14
  export type { NonInteractiveEnvOptions } from "./shell-env.ts";
16
15
  export { collectGitContext, formatGitContext, sanitizeRemoteUrl, parseProjectName } from "./git-context.ts";
17
16
  export type { GitContext, GitContextOptions } from "./git-context.ts";
18
- export { SshMachine } from "./machine-ssh.ts";
19
- export type { SshMachineOptions, SshMachineExtraOptions } from "./machine-ssh.ts";
17
+ export { SshEnvironment } from "./environment-ssh.ts";
18
+ export type { SshEnvironmentOptions, SshEnvironmentExtraOptions } from "./environment-ssh.ts";
20
19
  export type { BackgroundSpawner } from "./background.ts";
21
20
  export { askUser } from "./ask.ts";
22
21
  export { defineTool, tool } from "./define.ts";
@@ -26,7 +25,7 @@ export { writeTool } from "./builtin/write.ts";
26
25
  export { editTool } from "./builtin/edit.ts";
27
26
  export { readTool } from "./builtin/read.ts";
28
27
  export { globTool } from "./builtin/glob.ts";
29
- export { bashTool } from "./builtin/bash.ts";
28
+ export { bashTool, prepareBackgroundLog } from "./builtin/bash.ts";
30
29
  export { grepTool } from "./builtin/grep.ts";
31
30
  export { askUserQuestionTool } from "./builtin/ask-user-question.ts";
32
31
  export type { QuestionOption, QuestionItem, QuestionRequest, QuestionAnswerValue, QuestionAnswers, QuestionAnswerMethod, QuestionResponse, QuestionResult, QuestionResponder, } from "./questions.ts";
@@ -34,4 +33,5 @@ export type { QuestionSpawnOptions } from "./background.ts";
34
33
  export { filesystemTools } from "./filesystem-tools.ts";
35
34
  export type { FilesystemToolsOptions } from "./filesystem-tools.ts";
36
35
  export * from "./web/index.ts";
36
+ export { searchDeferredTools } from "./search/deferral.ts";
37
37
  //# sourceMappingURL=index.d.ts.map
@@ -1,24 +1,23 @@
1
1
  export { ToolAccesses } from "./access.js";
2
- export { StaleFileError, FileExistsError } from "./machine.js";
3
- // ── Writing a Machine backend ────────────────────────────────────────────────
4
- // Everything above is the CALLER's surface: `Machine` and the shapes its methods take and
2
+ // ── Writing an Environment backend ────────────────────────────────────────────────
3
+ // Everything above is the CALLER's surface: `Environment` and the shapes its methods take and
5
4
  // return. What follows is the IMPLEMENTER's, and only a backend author needs it.
6
5
  //
7
- // Extend `BaseMachine` and it derives the high-level operations for you. Its process SPI —
6
+ // Extend `BaseEnvironment` and it derives the high-level operations for you. Its process SPI —
8
7
  // `spawn`, returning a `SpawnedProcess` — is what gets you `run` for free, and is optional:
9
8
  // a transport with no OS process (a sandbox HTTP API, as in `operon-sandbox`) omits it and
10
9
  // overrides `run` natively instead. Nothing outside the class hierarchy calls either one.
11
- export { BaseMachine } from "./machine-base.js";
10
+ export { BaseEnvironment } from "./environment-base.js";
12
11
  export { materializeWorkspace, describeWorkspace, WorkspaceMaterializeError } from "./workspace-spec.js";
13
12
  // Low-level file-op helpers (readTextFile / decodeText / …) are on
14
13
  // `operon-agents-core/internal`.
15
- export { FileFreshnessLedger, checkFreshness, CONTENT_RETENTION_MAX_BYTES, FILE_NOT_READ_MESSAGE, FILE_MODIFIED_MESSAGE, FILE_UNCHANGED_STUB, } from "./file-freshness.js";
14
+ export { FileFreshnessLedger, checkFreshness, LEDGER_MAX_ENTRIES, FILE_NOT_READ_MESSAGE, FILE_MODIFIED_MESSAGE, FILE_UNCHANGED_STUB, } from "./file-freshness.js";
16
15
  // Bash permission-rule matching helpers are on `operon-agents-core/internal`.
17
- export { LocalMachine, detectEnvironment } from "./machine-local.js";
18
- export { NullMachine } from "./machine-null.js";
16
+ export { LocalEnvironment, detectOsInfo } from "./environment-local.js";
17
+ export { NullEnvironment } from "./environment-null.js";
19
18
  export { nonInteractiveShellEnv, proxyEnv, PROXY_ENV_VARS } from "./shell-env.js";
20
19
  export { collectGitContext, formatGitContext, sanitizeRemoteUrl, parseProjectName } from "./git-context.js";
21
- export { SshMachine } from "./machine-ssh.js";
20
+ export { SshEnvironment } from "./environment-ssh.js";
22
21
  export { askUser } from "./ask.js";
23
22
  export { defineTool, tool } from "./define.js";
24
23
  export { globApproval } from "./support/tool-path.js";
@@ -26,9 +25,12 @@ export { writeTool } from "./builtin/write.js";
26
25
  export { editTool } from "./builtin/edit.js";
27
26
  export { readTool } from "./builtin/read.js";
28
27
  export { globTool } from "./builtin/glob.js";
29
- export { bashTool } from "./builtin/bash.js";
28
+ export { bashTool, prepareBackgroundLog } from "./builtin/bash.js";
30
29
  export { grepTool } from "./builtin/grep.js";
31
30
  export { askUserQuestionTool } from "./builtin/ask-user-question.js";
32
31
  export { filesystemTools } from "./filesystem-tools.js";
33
32
  export * from "./web/index.js";
33
+ // The keyword search behind SearchTool, for other surfaces that look tools up by intent
34
+ // (Code Mode's `searchTools`).
35
+ export { searchDeferredTools } from "./search/deferral.js";
34
36
  //# sourceMappingURL=index.js.map