@farmslot/agent-runtime 0.40.1 → 0.42.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 (85) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/native/account-profiles.d.ts +1 -0
  3. package/dist/native/account-profiles.d.ts.map +1 -1
  4. package/dist/native/account-profiles.js +17 -1
  5. package/dist/native/account-profiles.js.map +1 -1
  6. package/dist/native/acp.d.ts.map +1 -1
  7. package/dist/native/acp.js +14 -0
  8. package/dist/native/acp.js.map +1 -1
  9. package/dist/native/claude.d.ts.map +1 -1
  10. package/dist/native/claude.js +52 -1
  11. package/dist/native/claude.js.map +1 -1
  12. package/dist/native/client.d.ts +2 -1
  13. package/dist/native/client.d.ts.map +1 -1
  14. package/dist/native/client.js +9 -0
  15. package/dist/native/client.js.map +1 -1
  16. package/dist/native/codex.d.ts.map +1 -1
  17. package/dist/native/codex.js +33 -5
  18. package/dist/native/codex.js.map +1 -1
  19. package/dist/native/host.js +3 -0
  20. package/dist/native/host.js.map +1 -1
  21. package/dist/native/ipc.d.ts +7 -1
  22. package/dist/native/ipc.d.ts.map +1 -1
  23. package/dist/native/ipc.js +12 -0
  24. package/dist/native/ipc.js.map +1 -1
  25. package/dist/native/manager.d.ts +2 -1
  26. package/dist/native/manager.d.ts.map +1 -1
  27. package/dist/native/manager.js +55 -3
  28. package/dist/native/manager.js.map +1 -1
  29. package/dist/native/observation.d.ts +9 -3
  30. package/dist/native/observation.d.ts.map +1 -1
  31. package/dist/native/observation.js +149 -42
  32. package/dist/native/observation.js.map +1 -1
  33. package/dist/native/opencode.d.ts.map +1 -1
  34. package/dist/native/opencode.js +16 -0
  35. package/dist/native/opencode.js.map +1 -1
  36. package/dist/native/pi.d.ts.map +1 -1
  37. package/dist/native/pi.js +9 -0
  38. package/dist/native/pi.js.map +1 -1
  39. package/dist/native/process-tree.d.ts +4 -4
  40. package/dist/native/process-tree.d.ts.map +1 -1
  41. package/dist/native/process-tree.js +82 -20
  42. package/dist/native/process-tree.js.map +1 -1
  43. package/dist/native/process.d.ts.map +1 -1
  44. package/dist/native/process.js +7 -9
  45. package/dist/native/process.js.map +1 -1
  46. package/dist/native/registry.d.ts.map +1 -1
  47. package/dist/native/registry.js +11 -17
  48. package/dist/native/registry.js.map +1 -1
  49. package/dist/native/service.d.ts.map +1 -1
  50. package/dist/native/service.js +11 -0
  51. package/dist/native/service.js.map +1 -1
  52. package/dist/native/storage.d.ts +1 -0
  53. package/dist/native/storage.d.ts.map +1 -1
  54. package/dist/native/storage.js +16 -3
  55. package/dist/native/storage.js.map +1 -1
  56. package/dist/native/supervisor.js +12 -5
  57. package/dist/native/supervisor.js.map +1 -1
  58. package/dist/native/types.d.ts +5 -1
  59. package/dist/native/types.d.ts.map +1 -1
  60. package/dist/native/workspace.d.ts.map +1 -1
  61. package/dist/native/workspace.js +15 -1
  62. package/dist/native/workspace.js.map +1 -1
  63. package/dist/task-init/branch-update.d.ts +23 -3
  64. package/dist/task-init/branch-update.d.ts.map +1 -1
  65. package/dist/task-init/branch-update.js +99 -5
  66. package/dist/task-init/branch-update.js.map +1 -1
  67. package/dist/task-init/execution-provenance.d.ts +2 -0
  68. package/dist/task-init/execution-provenance.d.ts.map +1 -1
  69. package/dist/task-init/execution-provenance.js +43 -13
  70. package/dist/task-init/execution-provenance.js.map +1 -1
  71. package/dist/task-init/pin.d.ts +3 -1
  72. package/dist/task-init/pin.d.ts.map +1 -1
  73. package/dist/task-init/pin.js +13 -3
  74. package/dist/task-init/pin.js.map +1 -1
  75. package/dist/task-init/task-document.d.ts.map +1 -1
  76. package/dist/task-init/task-document.js +2 -1
  77. package/dist/task-init/task-document.js.map +1 -1
  78. package/dist/task-init/write.d.ts +27 -0
  79. package/dist/task-init/write.d.ts.map +1 -1
  80. package/dist/task-init/write.js +38 -2
  81. package/dist/task-init/write.js.map +1 -1
  82. package/package.json +4 -3
  83. package/scripts/branch-update.mjs +6 -3
  84. package/scripts/review-terminal.cjs +20 -17
  85. package/scripts/workspace-trust.cjs +35 -0
@@ -123,31 +123,17 @@ async function main() {
123
123
  readOnlyRoots: [
124
124
  cwd,
125
125
  fs.realpathSync(gitRoot),
126
- ...(input.support ? [fs.realpathSync(input.support)] : []),
126
+ ...(input.readOnlyRoots ?? (input.support ? [input.support] : [])).map((root) =>
127
+ fs.realpathSync(root),
128
+ ),
127
129
  ],
128
130
  writableRoots: [task],
129
131
  };
130
- const runtimeRoots = input.runtimeRoots.map((root) =>
131
- root.replace(/^~(?=\/|$)/, process.env.HOME),
132
- );
133
- const {
134
- workspaceTrustByRunner,
135
- reviewConfigurationRootsByRunner,
136
- terminalReviewRefusalByRunner,
137
- } = require('./workspace-trust.cjs');
138
- if (terminalReviewRefusalByRunner[input.runner])
139
- throw new Error(terminalReviewRefusalByRunner[input.runner]);
140
- const guard = await sandbox(
141
- policy,
142
- runtimeRoots,
143
- reviewConfigurationRootsByRunner[input.runner]?.(cwd) ?? [],
144
- );
145
132
  const promptFile = path.join(task, '.terminal-prompt.txt');
146
133
  fs.writeFileSync(promptFile, input.prompt, { mode: 0o600 });
147
134
  const environment = {
148
135
  ...process.env,
149
136
  ...input.environment.set,
150
- TMPDIR: guard.temporaryDirectory,
151
137
  DISABLE_OMX: '1',
152
138
  DISABLE_OMC: '1',
153
139
  };
@@ -159,6 +145,23 @@ async function main() {
159
145
  'FARMSLOT_GATEWAY_PASSWORD',
160
146
  ])
161
147
  delete environment[key];
148
+ const {
149
+ workspaceTrustByRunner,
150
+ reviewConfigurationRootsByRunner,
151
+ terminalReviewRefusalByRunner,
152
+ reviewRuntimeRootsByRunner,
153
+ } = require('./workspace-trust.cjs');
154
+ if (terminalReviewRefusalByRunner[input.runner])
155
+ throw new Error(terminalReviewRefusalByRunner[input.runner]);
156
+ const runtimeRoots = (
157
+ reviewRuntimeRootsByRunner[input.runner]?.(environment) ?? input.runtimeRoots
158
+ ).map((root) => root.replace(/^~(?=\/|$)/, environment.HOME));
159
+ const guard = await sandbox(
160
+ policy,
161
+ runtimeRoots,
162
+ reviewConfigurationRootsByRunner[input.runner]?.(cwd) ?? [],
163
+ );
164
+ environment.TMPDIR = guard.temporaryDirectory;
162
165
  environment.FARMSLOT_SIGNAL_ATTEMPT_ID = require('node:crypto').randomUUID();
163
166
  // This helper accepts only the gateway's farm review launch, after identity and source-policy checks.
164
167
  workspaceTrustByRunner[input.runner]?.(cwd, environment, undefined, {
@@ -202,6 +202,32 @@ function trustClaudeWorkspace(cwd, env = process.env, owner) {
202
202
  function codexWorkspaceTrustConfig(cwd, trust) {
203
203
  return `projects={${JSON.stringify(cwd)}={trust_level=${JSON.stringify(trust)}}}`;
204
204
  }
205
+ // Both native hosts and frozen terminal bundles resolve storage on the execution node.
206
+ const reviewRuntimeRootsByRunner = {
207
+ codex: (env) => [codexHome(env)],
208
+ claude: (env) => [
209
+ env.CLAUDE_CONFIG_DIR || path.join(home(env), '.claude'),
210
+ ...(typeof process.getuid === 'function'
211
+ ? [path.join('/tmp', `claude-${process.getuid()}`)]
212
+ : []),
213
+ ],
214
+ cursor: (env) => [
215
+ path.join(home(env), '.cursor'),
216
+ path.join(home(env), 'Library/Caches/cursor-compile-cache'),
217
+ path.join(home(env), 'Library/Application Support/Cursor'),
218
+ ...(typeof process.getuid === 'function'
219
+ ? [path.join('/tmp', `cursor-agent-persist-${process.getuid()}`)]
220
+ : []),
221
+ ],
222
+ grok: (env) => [grokHome(env)],
223
+ pi: (env) => [env.PI_CODING_AGENT_DIR || path.join(home(env), '.pi/agent')],
224
+ opencode: (env) => [
225
+ path.join(env.XDG_DATA_HOME || path.join(home(env), '.local/share'), 'opencode'),
226
+ path.join(env.XDG_CACHE_HOME || path.join(home(env), '.cache'), 'opencode'),
227
+ path.join(env.XDG_STATE_HOME || path.join(home(env), '.local/state'), 'opencode'),
228
+ path.join(env.XDG_CONFIG_HOME || path.join(home(env), '.config'), 'opencode'),
229
+ ],
230
+ };
205
231
  const reviewConfigurationRoots = (cwd) =>
206
232
  [
207
233
  '.grok/config.toml',
@@ -218,6 +244,10 @@ const reviewConfigurationRoots = (cwd) =>
218
244
  '.mcp.json',
219
245
  '.lsp.json',
220
246
  '.envrc',
247
+ '.pi',
248
+ '.opencode',
249
+ 'opencode.json',
250
+ 'opencode.jsonc',
221
251
  ].map((name) => path.join(fs.realpathSync(cwd), name));
222
252
  // What a Grok review may write in its home: its sessions and logs, and the bytes of the sign-in
223
253
  // lock that a token refresh takes. Everything else stays read-only: hooks, configuration, policy,
@@ -239,10 +269,13 @@ const reviewConfigurationRootsByRunner = {
239
269
  grok: reviewConfigurationRoots,
240
270
  claude: reviewConfigurationRoots,
241
271
  cursor: reviewConfigurationRoots,
272
+ pi: reviewConfigurationRoots,
273
+ opencode: reviewConfigurationRoots,
242
274
  };
243
275
 
244
276
  // The review sandbox denies repository configuration. Exclude it before Claude
245
277
  // tries to read it, rather than prompting on EPERM before accepting the task.
278
+ const piReadOnlyReviewArgs = ['--no-approve'];
246
279
  const claudeReadOnlyReviewArgs = [
247
280
  '--setting-sources',
248
281
  'user',
@@ -251,6 +284,8 @@ const claudeReadOnlyReviewArgs = [
251
284
  ];
252
285
 
253
286
  module.exports = {
287
+ reviewRuntimeRootsByRunner,
288
+ piReadOnlyReviewArgs,
254
289
  claudeReadOnlyReviewArgs,
255
290
  codexHome,
256
291
  grokHome,