agenticreplay 0.0.0-stage → 0.1.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 (534) hide show
  1. package/.dockerignore +11 -0
  2. package/.gitattributes +19 -0
  3. package/.github/workflows/ci.yml +146 -0
  4. package/.grok-plugin/plugin.json +12 -0
  5. package/.mcp.json +8 -0
  6. package/.prettierignore +4 -0
  7. package/.prettierrc.json +1 -0
  8. package/CONTRIBUTING.md +106 -0
  9. package/Dockerfile +30 -0
  10. package/LICENSE +201 -0
  11. package/MAINTAINERS.md +24 -0
  12. package/README.md +939 -2
  13. package/RELEASING.md +183 -0
  14. package/SECURITY.md +149 -0
  15. package/capture/CAPTURE-RUNBOOK.md +271 -0
  16. package/capture/CURSOR-HTTP2.md +226 -0
  17. package/capture/README.md +349 -0
  18. package/capture/capture-run.gif +0 -0
  19. package/capture/capture.mjs +1883 -0
  20. package/capture/fable-capture.gif +0 -0
  21. package/capture/fable-capture.mp4 +0 -0
  22. package/capture/muse-shim.mjs +114 -0
  23. package/capture/render-run.mjs +125 -0
  24. package/capture/render.mjs +228 -0
  25. package/companion-kiokuko-dsh.patch +7806 -0
  26. package/docs/agenticreplay-acceptance.md +135 -0
  27. package/docs/architecture.md +160 -0
  28. package/docs/chain-card.png +0 -0
  29. package/docs/compare-card.png +0 -0
  30. package/docs/demo-cli.gif +0 -0
  31. package/docs/demo-viewer.gif +0 -0
  32. package/docs/fidelity.md +16 -0
  33. package/docs/good-first-issues.md +78 -0
  34. package/docs/graph-card.png +0 -0
  35. package/docs/how-to/compare-models-on-the-same-failure.md +58 -0
  36. package/docs/how-to/debug-a-failing-agent-run.md +127 -0
  37. package/docs/how-to/why-did-my-agent-delete-my-file.md +92 -0
  38. package/docs/i18n/README.ar.md +597 -0
  39. package/docs/i18n/README.de.md +648 -0
  40. package/docs/i18n/README.es.md +642 -0
  41. package/docs/i18n/README.fr.md +649 -0
  42. package/docs/i18n/README.ja.md +608 -0
  43. package/docs/i18n/README.ko.md +598 -0
  44. package/docs/i18n/README.zh-CN.md +574 -0
  45. package/docs/integrations.md +628 -0
  46. package/docs/launch-path.md +215 -0
  47. package/docs/media/README.md +101 -0
  48. package/docs/media/sync-transcript.txt +18 -0
  49. package/docs/media/transcript.txt +29 -0
  50. package/docs/opencode-capture.md +137 -0
  51. package/docs/plugins.md +250 -0
  52. package/docs/proposals/action-graph-and-reasoning.md +354 -0
  53. package/docs/sync-card.png +0 -0
  54. package/docs/validation.md +52 -0
  55. package/docs/viewer-timeline.png +0 -0
  56. package/examples/traces/README.md +50 -0
  57. package/examples/traces/run_9f2c14a03b71/blobs/1b/1b694f32b8c582ace6b35ad64050e532fb3ee3ecc1a2763a82cf42ad0f2a3dd0 +10 -0
  58. package/examples/traces/run_9f2c14a03b71/blobs/51/517b5b8ec6c3b13121dbaec61784e2a024247c7c4efd9ba068b582ee57bd2764 +4 -0
  59. package/examples/traces/run_9f2c14a03b71/blobs/5b/5bba1bd069013d86363f69c00c1ae77c84c4e113aeeb7431c8141af4fed76860 +7 -0
  60. package/examples/traces/run_9f2c14a03b71/blobs/84/84247e7b385fd5f99a6728a509838e52ef963af92f44ef6eccbed6910de1438d +10 -0
  61. package/examples/traces/run_9f2c14a03b71/blobs/ac/ac9b4be9bdf7fe63c7b5135e2d14c4c0745a48771e733804869790590455f8e8 +7 -0
  62. package/examples/traces/run_9f2c14a03b71/events.jsonl +31 -0
  63. package/examples/traces/run_9f2c14a03b71/manifest.json +46 -0
  64. package/examples/traces/run_9f2c14a03b71/redactions.json +17 -0
  65. package/llms.txt +26 -0
  66. package/package.json +28 -4
  67. package/packages/adapters/fixtures/harness/claude-code.json +12 -0
  68. package/packages/adapters/fixtures/harness/codex.json +10 -0
  69. package/packages/adapters/fixtures/harness/cursor.json +10 -0
  70. package/packages/adapters/fixtures/harness/exec.json +10 -0
  71. package/packages/adapters/fixtures/harness/generic-openai.json +14 -0
  72. package/packages/adapters/fixtures/harness/goose.json +14 -0
  73. package/packages/adapters/fixtures/harness/grok.json +18 -0
  74. package/packages/adapters/fixtures/harness/hermes.json +10 -0
  75. package/packages/adapters/fixtures/harness/indexrag.json +21 -0
  76. package/packages/adapters/fixtures/harness/kilo.json +10 -0
  77. package/packages/adapters/fixtures/harness/mcode.json +10 -0
  78. package/packages/adapters/fixtures/harness/mimo.json +10 -0
  79. package/packages/adapters/fixtures/harness/node.json +22 -0
  80. package/packages/adapters/fixtures/harness/openclaw.json +21 -0
  81. package/packages/adapters/fixtures/harness/opencode.json +20 -0
  82. package/packages/adapters/fixtures/harness/qwen.json +20 -0
  83. package/packages/adapters/fixtures/harness/zcode.json +10 -0
  84. package/packages/adapters/package.json +29 -0
  85. package/packages/adapters/src/claude-code.ts +109 -0
  86. package/packages/adapters/src/codex.ts +135 -0
  87. package/packages/adapters/src/contract.ts +531 -0
  88. package/packages/adapters/src/cursor.ts +76 -0
  89. package/packages/adapters/src/detect.ts +132 -0
  90. package/packages/adapters/src/env.ts +118 -0
  91. package/packages/adapters/src/exec.ts +59 -0
  92. package/packages/adapters/src/generic-openai.ts +36 -0
  93. package/packages/adapters/src/goose.ts +87 -0
  94. package/packages/adapters/src/grok.ts +60 -0
  95. package/packages/adapters/src/hermes.ts +92 -0
  96. package/packages/adapters/src/index.ts +24 -0
  97. package/packages/adapters/src/indexrag.ts +254 -0
  98. package/packages/adapters/src/kilo.ts +39 -0
  99. package/packages/adapters/src/mcode.ts +392 -0
  100. package/packages/adapters/src/mcp-config.ts +84 -0
  101. package/packages/adapters/src/mimo.ts +44 -0
  102. package/packages/adapters/src/node.ts +71 -0
  103. package/packages/adapters/src/openclaw.ts +50 -0
  104. package/packages/adapters/src/opencode-api-bases.ts +200 -0
  105. package/packages/adapters/src/opencode-capture.ts +164 -0
  106. package/packages/adapters/src/opencode-catalog.ts +44 -0
  107. package/packages/adapters/src/opencode-config.ts +209 -0
  108. package/packages/adapters/src/opencode.ts +257 -0
  109. package/packages/adapters/src/qwen.ts +113 -0
  110. package/packages/adapters/src/registry.ts +121 -0
  111. package/packages/adapters/src/scaffold.ts +173 -0
  112. package/packages/adapters/src/session.ts +138 -0
  113. package/packages/adapters/src/zcode.ts +440 -0
  114. package/packages/adapters/test/adapters.test.ts +666 -0
  115. package/packages/adapters/test/contract.test.ts +601 -0
  116. package/packages/adapters/test/exec-adapter.test.ts +114 -0
  117. package/packages/adapters/test/harness-versions.test.ts +220 -0
  118. package/packages/adapters/test/indexrag.test.ts +192 -0
  119. package/packages/adapters/test/mcode.test.ts +678 -0
  120. package/packages/adapters/test/mcp-config.test.ts +118 -0
  121. package/packages/adapters/test/named-agents.test.ts +262 -0
  122. package/packages/adapters/test/node-adapter.test.ts +98 -0
  123. package/packages/adapters/test/opencode-capture.test.ts +137 -0
  124. package/packages/adapters/test/opencode-catalog.test.ts +178 -0
  125. package/packages/adapters/test/opencode-config.test.ts +63 -0
  126. package/packages/adapters/test/scaffold.test.ts +156 -0
  127. package/packages/adapters/test/session.test.ts +368 -0
  128. package/packages/adapters/test/zcode.test.ts +497 -0
  129. package/packages/adapters/tsconfig.json +16 -0
  130. package/packages/cli/README.md +92 -0
  131. package/packages/cli/package.json +51 -0
  132. package/packages/cli/quickstart/project/agent.mjs +128 -0
  133. package/packages/cli/quickstart/project/package.json +8 -0
  134. package/packages/cli/quickstart/project/src/schedule.js +41 -0
  135. package/packages/cli/quickstart/project/test/schedule.test.js +25 -0
  136. package/packages/cli/quickstart/responses.json +8 -0
  137. package/packages/cli/quickstart/trace/blobs/f7/f7c1592306093f65f441d2afd5f496b7635b7e18f5c15f55b11f71f0b552a118 +1 -0
  138. package/packages/cli/quickstart/trace/events.jsonl +28 -0
  139. package/packages/cli/quickstart/trace/fs/HEAD +1 -0
  140. package/packages/cli/quickstart/trace/fs/config +11 -0
  141. package/packages/cli/quickstart/trace/fs/description +1 -0
  142. package/packages/cli/quickstart/trace/fs/index +0 -0
  143. package/packages/cli/quickstart/trace/fs/info/exclude +11 -0
  144. package/packages/cli/quickstart/trace/fs/objects/02/33ebdbbb73bcf40bde830c1c0247770ff79a1e +0 -0
  145. package/packages/cli/quickstart/trace/fs/objects/1b/1f956f306fe2c66611dd9e280e7fd2dce1ecda +0 -0
  146. package/packages/cli/quickstart/trace/fs/objects/1c/c77eaef0608e088283cb62876b80be9473edce +0 -0
  147. package/packages/cli/quickstart/trace/fs/objects/20/0c1f7a4be93b037ff27cea57853a738fcbf744 +0 -0
  148. package/packages/cli/quickstart/trace/fs/objects/21/db957dce36dbbd1606f61034f293dd55030056 +0 -0
  149. package/packages/cli/quickstart/trace/fs/objects/34/522daa46d0e3f8db09ec7d874fa6f05cbcdabf +0 -0
  150. package/packages/cli/quickstart/trace/fs/objects/5a/beaaf5271dcc3a134a7abd451b24d3dd179c39 +0 -0
  151. package/packages/cli/quickstart/trace/fs/objects/6e/09705485d5039e582022ef6a67829d940a013a +0 -0
  152. package/packages/cli/quickstart/trace/fs/objects/74/d8ed3a71638b5935220ef5454fe33835ad8351 +0 -0
  153. package/packages/cli/quickstart/trace/fs/objects/9f/db6ace4a4410e535a2aef50e653e46a4c3694a +0 -0
  154. package/packages/cli/quickstart/trace/fs/objects/a4/371e26fb48bece62891a54e4374895fba69f0d +0 -0
  155. package/packages/cli/quickstart/trace/fs/objects/dc/ce73b49d570b895ff25fc4f219a7976e527a08 +0 -0
  156. package/packages/cli/quickstart/trace/fs/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  157. package/packages/cli/quickstart/trace/fs/objects/f3/b5f9b41e53124ae9b7b299cac121680e5747fb +0 -0
  158. package/packages/cli/quickstart/trace/manifest.json +44 -0
  159. package/packages/cli/quickstart/trace/redactions.json +23 -0
  160. package/packages/cli/src/agent-spans.ts +752 -0
  161. package/packages/cli/src/api.ts +275 -0
  162. package/packages/cli/src/archive.ts +264 -0
  163. package/packages/cli/src/args.ts +207 -0
  164. package/packages/cli/src/attach.ts +178 -0
  165. package/packages/cli/src/capture-limits.ts +21 -0
  166. package/packages/cli/src/cli.ts +4 -0
  167. package/packages/cli/src/commands/attach.ts +441 -0
  168. package/packages/cli/src/commands/compare.ts +218 -0
  169. package/packages/cli/src/commands/doctor.ts +447 -0
  170. package/packages/cli/src/commands/gc.ts +372 -0
  171. package/packages/cli/src/commands/inspect.ts +482 -0
  172. package/packages/cli/src/commands/quickstart.ts +479 -0
  173. package/packages/cli/src/commands/record.ts +1069 -0
  174. package/packages/cli/src/commands/replay.ts +2289 -0
  175. package/packages/cli/src/commands/scrub.ts +865 -0
  176. package/packages/cli/src/commands/setup.ts +294 -0
  177. package/packages/cli/src/commands/sync.ts +1429 -0
  178. package/packages/cli/src/config.ts +182 -0
  179. package/packages/cli/src/exchange-events.ts +369 -0
  180. package/packages/cli/src/flags.ts +316 -0
  181. package/packages/cli/src/fs-events.ts +103 -0
  182. package/packages/cli/src/index.ts +17 -0
  183. package/packages/cli/src/main.ts +419 -0
  184. package/packages/cli/src/mcp-server.ts +314 -0
  185. package/packages/cli/src/mcp.ts +350 -0
  186. package/packages/cli/src/out.ts +350 -0
  187. package/packages/cli/src/rasterize.ts +205 -0
  188. package/packages/cli/src/serial.ts +38 -0
  189. package/packages/cli/src/share-card.ts +514 -0
  190. package/packages/cli/src/snapshot.ts +80 -0
  191. package/packages/cli/src/tls-capture.ts +688 -0
  192. package/packages/cli/src/upstream.ts +75 -0
  193. package/packages/cli/src/version.ts +21 -0
  194. package/packages/cli/test/agent-spans-drain.test.ts +157 -0
  195. package/packages/cli/test/agent-spans-race.test.ts +97 -0
  196. package/packages/cli/test/agent-spans.test.ts +1032 -0
  197. package/packages/cli/test/api.test.ts +178 -0
  198. package/packages/cli/test/archive.test.ts +143 -0
  199. package/packages/cli/test/args.test.ts +164 -0
  200. package/packages/cli/test/attach-command.test.ts +356 -0
  201. package/packages/cli/test/attach.test.ts +198 -0
  202. package/packages/cli/test/capture-oracle.test.ts +160 -0
  203. package/packages/cli/test/capture-warning.test.ts +215 -0
  204. package/packages/cli/test/chain-card.test.ts +190 -0
  205. package/packages/cli/test/claude-capture.test.ts +242 -0
  206. package/packages/cli/test/compare.test.ts +329 -0
  207. package/packages/cli/test/config-permission-failure.test.ts +41 -0
  208. package/packages/cli/test/config.test.ts +239 -0
  209. package/packages/cli/test/declared-inside-replay.test.ts +170 -0
  210. package/packages/cli/test/doctor.test.ts +276 -0
  211. package/packages/cli/test/e2e.test.ts +1230 -0
  212. package/packages/cli/test/exchange-events.test.ts +345 -0
  213. package/packages/cli/test/failure-lines.test.ts +47 -0
  214. package/packages/cli/test/fixtures/deaf-agent.mjs +11 -0
  215. package/packages/cli/test/fixtures/embedding-agent.mjs +32 -0
  216. package/packages/cli/test/fixtures/fake-agent.mjs +114 -0
  217. package/packages/cli/test/fixtures/fake-model.mjs +105 -0
  218. package/packages/cli/test/fixtures/gateway-agent.mjs +20 -0
  219. package/packages/cli/test/fixtures/ide-parent.mjs +34 -0
  220. package/packages/cli/test/fixtures/mcp-agent.mjs +64 -0
  221. package/packages/cli/test/fixtures/proxy-call.mjs +105 -0
  222. package/packages/cli/test/fixtures/responses-agent.mjs +82 -0
  223. package/packages/cli/test/fixtures/responses-model.mjs +94 -0
  224. package/packages/cli/test/fixtures/tls-agent.mjs +35 -0
  225. package/packages/cli/test/fixtures/vercel-agent.mjs +81 -0
  226. package/packages/cli/test/flag-values.test.ts +162 -0
  227. package/packages/cli/test/flags.test.ts +313 -0
  228. package/packages/cli/test/fork-provenance.test.ts +224 -0
  229. package/packages/cli/test/fork-tls.test.ts +190 -0
  230. package/packages/cli/test/gateway-e2e.test.ts +110 -0
  231. package/packages/cli/test/gc.test.ts +531 -0
  232. package/packages/cli/test/generated-esm.test.ts +87 -0
  233. package/packages/cli/test/graph-card.test.ts +249 -0
  234. package/packages/cli/test/graph-command.test.ts +258 -0
  235. package/packages/cli/test/grok-bot-e2e.test.ts +349 -0
  236. package/packages/cli/test/inspect.test.ts +412 -0
  237. package/packages/cli/test/intercept-failures.test.ts +74 -0
  238. package/packages/cli/test/json-only.test.ts +88 -0
  239. package/packages/cli/test/json-output.test.ts +221 -0
  240. package/packages/cli/test/list-gateway.test.ts +770 -0
  241. package/packages/cli/test/mcp-capture.test.ts +498 -0
  242. package/packages/cli/test/mcp-server.test.ts +315 -0
  243. package/packages/cli/test/nested-repo-replay.test.ts +972 -0
  244. package/packages/cli/test/no-credential-in-attrs.test.ts +255 -0
  245. package/packages/cli/test/opencode-capture.test.ts +422 -0
  246. package/packages/cli/test/opencode-catalog-capture.test.ts +175 -0
  247. package/packages/cli/test/out.test.ts +491 -0
  248. package/packages/cli/test/pinned-fetch.test.ts +154 -0
  249. package/packages/cli/test/prompt-scrub.test.ts +132 -0
  250. package/packages/cli/test/publish-order.test.ts +87 -0
  251. package/packages/cli/test/quickstart.test.ts +579 -0
  252. package/packages/cli/test/rasterize.test.ts +86 -0
  253. package/packages/cli/test/record-detection.test.ts +156 -0
  254. package/packages/cli/test/record-teardown.test.ts +203 -0
  255. package/packages/cli/test/replay-putback.test.ts +242 -0
  256. package/packages/cli/test/replay-spill.test.ts +116 -0
  257. package/packages/cli/test/replay-teardown.test.ts +143 -0
  258. package/packages/cli/test/replay-trace.test.ts +199 -0
  259. package/packages/cli/test/replay-transport.test.ts +113 -0
  260. package/packages/cli/test/reset-roots.test.ts +67 -0
  261. package/packages/cli/test/responses-e2e.test.ts +119 -0
  262. package/packages/cli/test/retrieval-context.test.ts +168 -0
  263. package/packages/cli/test/review-regressions.test.ts +168 -0
  264. package/packages/cli/test/route-decision.test.ts +134 -0
  265. package/packages/cli/test/run-dir-sidecars.test.ts +779 -0
  266. package/packages/cli/test/scrub.test.ts +936 -0
  267. package/packages/cli/test/serial.test.ts +65 -0
  268. package/packages/cli/test/setup.test.ts +535 -0
  269. package/packages/cli/test/share-card.test.ts +135 -0
  270. package/packages/cli/test/shell-capture.test.ts +184 -0
  271. package/packages/cli/test/shell-frames-drain.test.ts +91 -0
  272. package/packages/cli/test/snapshot-retry.test.ts +54 -0
  273. package/packages/cli/test/support-claims.test.ts +127 -0
  274. package/packages/cli/test/sync-credentials.test.ts +177 -0
  275. package/packages/cli/test/sync.test.ts +1709 -0
  276. package/packages/cli/test/tls-intercept.test.ts +548 -0
  277. package/packages/cli/test/upstream-visible.test.ts +314 -0
  278. package/packages/cli/test/vercel-sdk-e2e.test.ts +105 -0
  279. package/packages/cli/test/version.test.ts +20 -0
  280. package/packages/cli/tsconfig.json +40 -0
  281. package/packages/core/package.json +26 -0
  282. package/packages/core/src/blobs.ts +109 -0
  283. package/packages/core/src/fetch.ts +48 -0
  284. package/packages/core/src/graph.ts +450 -0
  285. package/packages/core/src/index.ts +8 -0
  286. package/packages/core/src/paths.ts +180 -0
  287. package/packages/core/src/private-files.ts +394 -0
  288. package/packages/core/src/reader.ts +175 -0
  289. package/packages/core/src/redaction.ts +826 -0
  290. package/packages/core/src/writer.ts +467 -0
  291. package/packages/core/test/blobs.test.ts +170 -0
  292. package/packages/core/test/capture-contract.test.ts +179 -0
  293. package/packages/core/test/data-uri-redaction.test.ts +758 -0
  294. package/packages/core/test/graph.test.ts +520 -0
  295. package/packages/core/test/integration.test.ts +148 -0
  296. package/packages/core/test/paths-permission-failure.test.ts +53 -0
  297. package/packages/core/test/paths.test.ts +339 -0
  298. package/packages/core/test/private-files-owner.test.ts +77 -0
  299. package/packages/core/test/private-files-scratch-race.test.ts +62 -0
  300. package/packages/core/test/private-files.test.ts +251 -0
  301. package/packages/core/test/reader.test.ts +271 -0
  302. package/packages/core/test/redaction.test.ts +525 -0
  303. package/packages/core/test/writer.test.ts +531 -0
  304. package/packages/core/tsconfig.json +6 -0
  305. package/packages/fs-capture/package.json +25 -0
  306. package/packages/fs-capture/src/capture.ts +193 -0
  307. package/packages/fs-capture/src/git.ts +131 -0
  308. package/packages/fs-capture/src/index.ts +3 -0
  309. package/packages/fs-capture/src/shadow.ts +751 -0
  310. package/packages/fs-capture/test/capture.test.ts +241 -0
  311. package/packages/fs-capture/test/git.test.ts +118 -0
  312. package/packages/fs-capture/test/helpers.ts +28 -0
  313. package/packages/fs-capture/test/shadow.test.ts +1058 -0
  314. package/packages/fs-capture/tsconfig.json +6 -0
  315. package/packages/mcp-shim/package.json +26 -0
  316. package/packages/mcp-shim/src/cli.ts +372 -0
  317. package/packages/mcp-shim/src/framing.ts +106 -0
  318. package/packages/mcp-shim/src/index.ts +4 -0
  319. package/packages/mcp-shim/src/mock.ts +194 -0
  320. package/packages/mcp-shim/src/shim.ts +126 -0
  321. package/packages/mcp-shim/test/cli.test.ts +489 -0
  322. package/packages/mcp-shim/test/framing.test.ts +143 -0
  323. package/packages/mcp-shim/test/mock.test.ts +200 -0
  324. package/packages/mcp-shim/test/shim.test.ts +287 -0
  325. package/packages/mcp-shim/tsconfig.json +5 -0
  326. package/packages/node-instrument/package.json +23 -0
  327. package/packages/node-instrument/src/capture.ts +505 -0
  328. package/packages/node-instrument/src/index.ts +3 -0
  329. package/packages/node-instrument/src/install.ts +186 -0
  330. package/packages/node-instrument/src/rewrite.ts +66 -0
  331. package/packages/node-instrument/test/capture.test.ts +423 -0
  332. package/packages/node-instrument/test/install.test.ts +427 -0
  333. package/packages/node-instrument/test/rewrite.test.ts +85 -0
  334. package/packages/node-instrument/tsconfig.json +9 -0
  335. package/packages/plugin-api/package.json +22 -0
  336. package/packages/plugin-api/src/canonical.ts +73 -0
  337. package/packages/plugin-api/src/index.ts +2 -0
  338. package/packages/plugin-api/src/plugins.ts +265 -0
  339. package/packages/plugin-api/test/canonical.test.ts +58 -0
  340. package/packages/plugin-api/tsconfig.json +5 -0
  341. package/packages/providers/package.json +26 -0
  342. package/packages/providers/src/index.ts +34 -0
  343. package/packages/providers/src/pricing.ts +140 -0
  344. package/packages/providers/src/translate/anthropic.ts +620 -0
  345. package/packages/providers/src/translate/openai-responses.ts +638 -0
  346. package/packages/providers/src/translate/openai.ts +630 -0
  347. package/packages/providers/src/translate/sse.ts +99 -0
  348. package/packages/providers/src/translate/util.ts +111 -0
  349. package/packages/providers/test/anthropic-translate.test.ts +687 -0
  350. package/packages/providers/test/openai-responses-translate.test.ts +377 -0
  351. package/packages/providers/test/openai-translate.test.ts +884 -0
  352. package/packages/providers/test/pricing.test.ts +171 -0
  353. package/packages/providers/tsconfig.json +6 -0
  354. package/packages/proxy/package.json +28 -0
  355. package/packages/proxy/src/ca.ts +376 -0
  356. package/packages/proxy/src/der.ts +152 -0
  357. package/packages/proxy/src/dialects.ts +413 -0
  358. package/packages/proxy/src/forward.ts +64 -0
  359. package/packages/proxy/src/index.ts +8 -0
  360. package/packages/proxy/src/intercept.ts +1554 -0
  361. package/packages/proxy/src/matching.ts +1056 -0
  362. package/packages/proxy/src/retrieval.ts +290 -0
  363. package/packages/proxy/src/server.ts +2875 -0
  364. package/packages/proxy/src/tls-hosts.ts +205 -0
  365. package/packages/proxy/test/beta-headers.test.ts +39 -0
  366. package/packages/proxy/test/ca.test.ts +146 -0
  367. package/packages/proxy/test/forward.test.ts +306 -0
  368. package/packages/proxy/test/hop-by-hop.test.ts +118 -0
  369. package/packages/proxy/test/image-matching.test.ts +129 -0
  370. package/packages/proxy/test/indexing-concurrency.test.ts +224 -0
  371. package/packages/proxy/test/lookahead.test.ts +160 -0
  372. package/packages/proxy/test/malformed-body.test.ts +73 -0
  373. package/packages/proxy/test/matching.test.ts +822 -0
  374. package/packages/proxy/test/passthrough.test.ts +599 -0
  375. package/packages/proxy/test/recorded-upstream.test.ts +253 -0
  376. package/packages/proxy/test/responses-dialect.test.ts +239 -0
  377. package/packages/proxy/test/retrieval.test.ts +589 -0
  378. package/packages/proxy/test/server.test.ts +1281 -0
  379. package/packages/proxy/test/tls-hosts.test.ts +190 -0
  380. package/packages/proxy/test/tls-intercept.test.ts +1769 -0
  381. package/packages/proxy/tsconfig.json +22 -0
  382. package/packages/schema/package.json +28 -0
  383. package/packages/schema/schema/event.schema.json +144 -0
  384. package/packages/schema/schema/manifest.schema.json +184 -0
  385. package/packages/schema/src/constants.ts +73 -0
  386. package/packages/schema/src/index.ts +3 -0
  387. package/packages/schema/src/types.ts +103 -0
  388. package/packages/schema/src/validate.ts +60 -0
  389. package/packages/schema/test/schema-parity.test.ts +116 -0
  390. package/packages/schema/tsconfig.json +5 -0
  391. package/packages/shell-shim/package.json +26 -0
  392. package/packages/shell-shim/src/index.ts +3 -0
  393. package/packages/shell-shim/src/install.ts +406 -0
  394. package/packages/shell-shim/src/resolve.ts +98 -0
  395. package/packages/shell-shim/src/runner-bin.ts +4 -0
  396. package/packages/shell-shim/src/runner.ts +149 -0
  397. package/packages/shell-shim/test/resolve.test.ts +125 -0
  398. package/packages/shell-shim/test/shim.test.ts +548 -0
  399. package/packages/shell-shim/test/transport-race.test.ts +109 -0
  400. package/packages/shell-shim/tsconfig.json +13 -0
  401. package/packages/viewer/package.json +25 -0
  402. package/packages/viewer/src/bundle.ts +36 -0
  403. package/packages/viewer/src/client/main.ts +248 -0
  404. package/packages/viewer/src/credit.ts +24 -0
  405. package/packages/viewer/src/css.ts +409 -0
  406. package/packages/viewer/src/export.ts +38 -0
  407. package/packages/viewer/src/html.ts +356 -0
  408. package/packages/viewer/src/index.ts +16 -0
  409. package/packages/viewer/src/render.ts +791 -0
  410. package/packages/viewer/src/serve.ts +150 -0
  411. package/packages/viewer/src/trace-dir.ts +140 -0
  412. package/packages/viewer/test/bundle.test.ts +47 -0
  413. package/packages/viewer/test/client.test.ts +378 -0
  414. package/packages/viewer/test/export.test.ts +131 -0
  415. package/packages/viewer/test/fixtures.ts +69 -0
  416. package/packages/viewer/test/html.test.ts +453 -0
  417. package/packages/viewer/test/playback.test.ts +54 -0
  418. package/packages/viewer/test/render.test.ts +714 -0
  419. package/packages/viewer/test/serve.test.ts +125 -0
  420. package/packages/viewer/tsconfig.json +6 -0
  421. package/prompt/AIDER/deepseek-v4-1-flash-system-prompt.md +29 -0
  422. package/prompt/CLAUDECODE/claude-fable-5-1-print-system-prompt.md +127 -0
  423. package/prompt/CLAUDECODE/claude-fable-5-1-system-prompt.md +169 -0
  424. package/prompt/CLAUDECODE/claude-opus-4-8-system-prompt.md +131 -0
  425. package/prompt/CLAUDECODE/claude-opus-5-system-prompt.md +149 -0
  426. package/prompt/CLINE/openai-gpt-4o-mini-system-prompt.md +37 -0
  427. package/prompt/CODEX/gpt-5-6-luna-system-prompt.md +183 -0
  428. package/prompt/CODEX/gpt-5-6-sol-system-prompt.md +218 -0
  429. package/prompt/CODEX/gpt-6-1-sol-system-prompt.md +242 -0
  430. package/prompt/CODEX/gpt-6-astra-system-prompt.md +170 -0
  431. package/prompt/CODEX/gpt-6-luna-system-prompt.md +223 -0
  432. package/prompt/CODEX/gpt-6-sol-system-prompt.md +226 -0
  433. package/prompt/CRUSH/deepseek-v4-1-flash-system-prompt.md +472 -0
  434. package/prompt/CURSOR/grok-4-5-high-system-prompt.md +40 -0
  435. package/prompt/DSH/deepseek-flash-system-prompt.md +31 -0
  436. package/prompt/GEMINICLI/gemini-3-5-flash-system-prompt.md +168 -0
  437. package/prompt/GOOSE/deepseek-v4-1-flash-system-prompt.md +180 -0
  438. package/prompt/HACKERAI/openai-gpt-4o-mini-system-prompt.md +70 -0
  439. package/prompt/HERMES/nemotron-3-5-lightning-free-system-prompt.md +111 -0
  440. package/prompt/KILOCODE/kilo-auto-free-system-prompt.md +129 -0
  441. package/prompt/MCODE/deepseek-deepseek-v4-flash-free-coding-system-prompt.md +128 -0
  442. package/prompt/MCODE/deepseek-deepseek-v4-flash-free-tui-system-prompt.md +119 -0
  443. package/prompt/MCODE/deepseek-deepseek-v4-flash-free-work-system-prompt.md +140 -0
  444. package/prompt/MIMOCODE/mimo-v2-5-pro-system-prompt.md +411 -0
  445. package/prompt/MIMOCODE/mimo-v2-5-system-prompt.md +411 -0
  446. package/prompt/MUSECODE/muse-spark-1-3-system-prompt.md +78 -0
  447. package/prompt/OPENCLAW/gpt-5-6-sol-system-prompt.md +333 -0
  448. package/prompt/OPENCODE/big-pickle-system-prompt.md +114 -0
  449. package/prompt/OPENCODE/gpt-5-6-sol-system-prompt.md +126 -0
  450. package/prompt/OPENCODE/ling-3-0-flash-fin-free-system-prompt.md +114 -0
  451. package/prompt/OPENCODE/mimo-v2-5-free-system-prompt.md +114 -0
  452. package/prompt/OPENCODE/muse-spark-1-2-contributor-free-system-prompt.md +84 -0
  453. package/prompt/OPENCODE/nemotron-3-5-lightning-free-system-prompt.md +114 -0
  454. package/prompt/OPENCODE/nemotron-3-ultra-free-system-prompt.md +114 -0
  455. package/prompt/PI/openai-gpt-4o-mini-system-prompt.md +31 -0
  456. package/prompt/QWENCODE/gpt-5-6-sol-system-prompt.md +290 -0
  457. package/prompt/ZCODE/glm-4-6-system-prompt.md +91 -0
  458. package/python/README.md +132 -0
  459. package/python/agenticreplay_trace/__init__.py +58 -0
  460. package/python/agenticreplay_trace/graph.py +137 -0
  461. package/python/agenticreplay_trace/models.py +491 -0
  462. package/python/agenticreplay_trace/py.typed +0 -0
  463. package/python/agenticreplay_trace/reader.py +295 -0
  464. package/python/conftest.py +12 -0
  465. package/python/examples/analyze.py +114 -0
  466. package/python/pyproject.toml +45 -0
  467. package/python/tests/conftest.py +102 -0
  468. package/python/tests/test_capture_contract.py +24 -0
  469. package/python/tests/test_conformance.py +235 -0
  470. package/python/tests/test_examples.py +60 -0
  471. package/python/tests/test_graph.py +247 -0
  472. package/python/tests/test_models.py +342 -0
  473. package/python/tests/test_reader.py +423 -0
  474. package/python-langgraph/README.md +159 -0
  475. package/python-langgraph/agenticreplay_langgraph/__init__.py +21 -0
  476. package/python-langgraph/agenticreplay_langgraph/handler.py +317 -0
  477. package/python-langgraph/agenticreplay_langgraph/hook.py +168 -0
  478. package/python-langgraph/pyproject.toml +35 -0
  479. package/python-langgraph/tests/test_handler.py +370 -0
  480. package/python-langgraph/tests/test_integration.py +484 -0
  481. package/python-openai-agents/README.md +145 -0
  482. package/python-openai-agents/agenticreplay_openai_agents/__init__.py +11 -0
  483. package/python-openai-agents/agenticreplay_openai_agents/processor.py +331 -0
  484. package/python-openai-agents/pyproject.toml +34 -0
  485. package/python-openai-agents/tests/test_processor.py +457 -0
  486. package/scripts/check-neutrality.mjs +62 -0
  487. package/scripts/codex-client-acceptance.mjs +133 -0
  488. package/scripts/conformance.mjs +245 -0
  489. package/scripts/fidelity.mjs +170 -0
  490. package/scripts/hermes-client-acceptance.mjs +158 -0
  491. package/scripts/host-client-acceptance.mjs +732 -0
  492. package/scripts/installed-smoke.mjs +316 -0
  493. package/scripts/publish-order.mjs +96 -0
  494. package/scripts/regenerate-quickstart.mjs +79 -0
  495. package/scripts/render-cards.mjs +178 -0
  496. package/scripts/render-demo.mjs +139 -0
  497. package/scripts/render-sync-card.mjs +96 -0
  498. package/scripts/set-version.mjs +152 -0
  499. package/scripts/set-version.test.ts +220 -0
  500. package/scripts/sync-server-json.mjs +13 -0
  501. package/scripts/update-opencode-api-bases.mjs +29 -0
  502. package/server.json +28 -0
  503. package/skills/agenticreplay-replay/SKILL.md +211 -0
  504. package/spec/agenticreplay-trace-v0.md +223 -0
  505. package/test/integrations/README.md +133 -0
  506. package/test/integrations/agents/ai_sdk_openai.mjs +24 -0
  507. package/test/integrations/agents/anthropic_sdk.py +10 -0
  508. package/test/integrations/agents/browser_use_agent.py +24 -0
  509. package/test/integrations/agents/crewai_agent.py +44 -0
  510. package/test/integrations/agents/crewai_model_names.py +72 -0
  511. package/test/integrations/agents/hardcoded_origin.mjs +13 -0
  512. package/test/integrations/agents/haystack_pipeline.py +28 -0
  513. package/test/integrations/agents/haystack_rag.py +35 -0
  514. package/test/integrations/agents/langgraph_agent.py +54 -0
  515. package/test/integrations/agents/langgraph_nodes.py +62 -0
  516. package/test/integrations/agents/litellm_agent.py +11 -0
  517. package/test/integrations/agents/llama_index_agent.py +27 -0
  518. package/test/integrations/agents/llama_index_model_names.py +67 -0
  519. package/test/integrations/agents/mastra_agent.mjs +20 -0
  520. package/test/integrations/agents/mcp_agent.py +44 -0
  521. package/test/integrations/agents/mcp_server.py +20 -0
  522. package/test/integrations/agents/openai_agents_handoff.py +52 -0
  523. package/test/integrations/agents/openai_agents_sdk.py +29 -0
  524. package/test/integrations/agents/openai_async.py +17 -0
  525. package/test/integrations/agents/openai_sdk.py +10 -0
  526. package/test/integrations/agents/openhands_agent.py +34 -0
  527. package/test/integrations/agents/rag_pipeline.py +79 -0
  528. package/test/integrations/agents/vision_agent.py +63 -0
  529. package/test/integrations/run.mjs +719 -0
  530. package/test/integrations/stub-origin.mjs +229 -0
  531. package/tsconfig.base.json +20 -0
  532. package/tsconfig.json +41 -0
  533. package/vitest.config.ts +39 -0
  534. package/vitest.setup.ts +25 -0
@@ -0,0 +1,457 @@
1
+ """The processor's two obligations: be inert when it should be, and never break the run.
2
+
3
+ Both are load-bearing rather than defensive. This package is installed by `agenticreplay record` into *every*
4
+ Python process a recording starts — including `python --version` — so "does nothing" is the common
5
+ case and has to be the reliable one.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import datetime
11
+ import json
12
+ import time
13
+ import os
14
+
15
+ import pytest
16
+
17
+ from agenticreplay_openai_agents import KEEP_ENV, SPANS_ENV, AgenticReplayTracingProcessor, install
18
+
19
+
20
+ class FakeSpanData:
21
+ def __init__(self, payload):
22
+ self._payload = payload
23
+
24
+ def export(self):
25
+ return self._payload
26
+
27
+
28
+ class HandoffSpanData(FakeSpanData):
29
+ """Named to match the SDK's class, because the processor keys off the class name."""
30
+
31
+
32
+ class ResponseSpanData(FakeSpanData):
33
+ pass
34
+
35
+
36
+ class AgentSpanData(FakeSpanData):
37
+ pass
38
+
39
+
40
+ class FunctionSpanData(FakeSpanData):
41
+ pass
42
+
43
+
44
+ class CustomSpanData(FakeSpanData):
45
+ pass
46
+
47
+
48
+ class FakeSpan:
49
+ def __init__(self, data):
50
+ self.span_data = data
51
+ self.span_id = "span_1"
52
+ self.parent_id = None
53
+ self.trace_id = "trace_1"
54
+ self.started_at = "2026-09-10T03:46:03.483810+00:00"
55
+ self.ended_at = "2026-09-10T03:46:03.500000+00:00"
56
+ self.error = None
57
+
58
+
59
+ def read(path):
60
+ with open(path, encoding="utf-8") as f:
61
+ return [json.loads(line) for line in f if line.strip()]
62
+
63
+
64
+ def test_inert_without_the_environment_variable(monkeypatch, tmp_path):
65
+ monkeypatch.delenv(SPANS_ENV, raising=False)
66
+ processor = AgenticReplayTracingProcessor()
67
+ assert processor.active is False
68
+ # And writing must be a no-op rather than an error: the SDK calls these unconditionally.
69
+ processor.on_span_end(FakeSpan(HandoffSpanData({"from_agent": "A", "to_agent": "B"})))
70
+ assert not list(tmp_path.iterdir())
71
+
72
+
73
+ def test_install_is_false_and_quiet_when_not_recording(monkeypatch):
74
+ monkeypatch.delenv(SPANS_ENV, raising=False)
75
+ assert install() is False
76
+
77
+
78
+ def test_writes_a_handoff(tmp_path):
79
+ out = tmp_path / "spans.jsonl"
80
+ processor = AgenticReplayTracingProcessor(str(out))
81
+ processor.on_span_end(FakeSpan(HandoffSpanData({"from_agent": "Triage", "to_agent": "Billing"})))
82
+ records = read(out)
83
+ assert len(records) == 1
84
+ assert records[0]["type"] == "HandoffSpanData"
85
+ assert records[0]["data"] == {"from_agent": "Triage", "to_agent": "Billing"}
86
+
87
+
88
+ def test_drops_what_the_proxy_already_has(tmp_path):
89
+ # Not an optimisation: the proxy holds these exchanges byte for byte, and a second, lossier copy
90
+ # in the same trace is worse than none.
91
+ out = tmp_path / "spans.jsonl"
92
+ processor = AgenticReplayTracingProcessor(str(out))
93
+ processor.on_span_end(FakeSpan(ResponseSpanData({"response": "..."})))
94
+ assert not out.exists() or read(out) == []
95
+
96
+
97
+ def test_a_span_that_will_not_serialise_does_not_raise(tmp_path):
98
+ class Hostile:
99
+ def __repr__(self):
100
+ raise RuntimeError("even repr fails")
101
+
102
+ out = tmp_path / "spans.jsonl"
103
+ processor = AgenticReplayTracingProcessor(str(out))
104
+ # Must not propagate. The SDK calls this from inside the run; an exception here would surface as
105
+ # the agent failing, which is the one thing a debugging aid must never cause.
106
+ processor.on_span_end(FakeSpan(HandoffSpanData({"bad": Hostile()})))
107
+
108
+
109
+ def test_an_unwritable_path_does_not_raise(tmp_path):
110
+ processor = AgenticReplayTracingProcessor(str(tmp_path / "no-such-dir" / "spans.jsonl"))
111
+ processor.on_span_end(FakeSpan(HandoffSpanData({"from_agent": "A", "to_agent": "B"})))
112
+
113
+
114
+ @pytest.mark.skipif(
115
+ os.environ.get("AGENTICREPLAY_SKIP_SDK_TESTS") == "1", reason="asked to skip SDK-dependent tests"
116
+ )
117
+ def test_install_replaces_the_default_exporter(monkeypatch, tmp_path):
118
+ """The reason `install` replaces rather than appends.
119
+
120
+ It runs before the user's first statement, when the only registered processor is the SDK's own
121
+ exporter to OpenAI. Leaving that in place would mean a second egress out of every recorded run.
122
+ """
123
+ agents = pytest.importorskip("agents")
124
+ monkeypatch.setenv(SPANS_ENV, str(tmp_path / "spans.jsonl"))
125
+ monkeypatch.delenv(KEEP_ENV, raising=False)
126
+
127
+ installed: list = []
128
+ monkeypatch.setattr(agents, "set_trace_processors", lambda ps: installed.append(("set", ps)))
129
+ monkeypatch.setattr(agents, "add_trace_processor", lambda p: installed.append(("add", p)))
130
+
131
+ assert install() is True
132
+ assert installed and installed[0][0] == "set"
133
+
134
+
135
+ @pytest.mark.skipif(
136
+ os.environ.get("AGENTICREPLAY_SKIP_SDK_TESTS") == "1", reason="asked to skip SDK-dependent tests"
137
+ )
138
+ def test_keep_export_appends_instead(monkeypatch, tmp_path):
139
+ agents = pytest.importorskip("agents")
140
+ monkeypatch.setenv(SPANS_ENV, str(tmp_path / "spans.jsonl"))
141
+ monkeypatch.setenv(KEEP_ENV, "1")
142
+
143
+ installed: list = []
144
+ monkeypatch.setattr(agents, "set_trace_processors", lambda ps: installed.append(("set", ps)))
145
+ monkeypatch.setattr(agents, "add_trace_processor", lambda p: installed.append(("add", p)))
146
+
147
+ assert install() is True
148
+ assert installed and installed[0][0] == "add"
149
+
150
+ # ── what reaches the file, and what does not ──────────────────────────────────────────────────────
151
+ #
152
+ # The file is written by the agent's own interpreter, so nothing agenticreplay owns can redact it on the way
153
+ # in. That leaves one control: do not write it. These pin the allow-list in both directions, because
154
+ # a list that let everything through and a list that let nothing through would both have passed the
155
+ # suite this replaced.
156
+
157
+
158
+ def _one_record(tmp_path, span, monkeypatch=None):
159
+ path = tmp_path / "spans.jsonl"
160
+ p = AgenticReplayTracingProcessor(str(path))
161
+ p.on_span_end(span)
162
+ if not path.exists():
163
+ return None
164
+ lines = [l for l in path.read_text(encoding="utf-8").splitlines() if l]
165
+ return json.loads(lines[0]) if lines else None
166
+
167
+
168
+ SECRET = "sk-canary0123456789abcdefghijklmn"
169
+
170
+
171
+ @pytest.mark.parametrize("data", [FunctionSpanData, CustomSpanData])
172
+ def test_a_span_type_nothing_reads_is_not_written_at_all(tmp_path, data):
173
+ """The reader maps three span types. The other span types carry the payload.
174
+
175
+ `FunctionSpanData` holds a tool's input, output and `mcp_data`; `CustomSpanData` holds whatever
176
+ the user put in it. Both used to be written verbatim, and `eventForSpan` threw both away -- so
177
+ the file carried material the trace never kept and nothing could remove.
178
+ """
179
+ span = FakeSpan(data({"name": "run_shell", "output": SECRET, "mcp_data": {"key": SECRET}}))
180
+ assert _one_record(tmp_path, span) is None
181
+
182
+
183
+ def test_an_allowed_span_carries_only_the_fields_the_reader_reads(tmp_path):
184
+ span = FakeSpan(
185
+ AgentSpanData(
186
+ {
187
+ "name": "Triage",
188
+ "handoffs": ["Billing"],
189
+ "tools": ["run_shell"],
190
+ "output_type": "str",
191
+ # Not in the list, so not written -- the SDK is free to add fields and this file is
192
+ # not free to carry them.
193
+ "instructions": SECRET,
194
+ }
195
+ )
196
+ )
197
+ record = _one_record(tmp_path, span)
198
+ assert record is not None
199
+ assert set(record["data"]) == {"name", "handoffs", "tools", "output_type"}
200
+ assert SECRET not in json.dumps(record)
201
+
202
+
203
+ def test_the_error_object_is_never_written(tmp_path):
204
+ """`SpanError.data` is a free-form dict: a tool's input, an API error echoed back.
205
+
206
+ Nothing read it -- `AgentSpan.error` is declared on the reader side and never used -- so writing
207
+ it was payload for no reader at all.
208
+ """
209
+ span = FakeSpan(HandoffSpanData({"from_agent": "a", "to_agent": "b"}))
210
+ span.error = {"message": "boom", "data": {"echoed": SECRET}}
211
+ record = _one_record(tmp_path, span)
212
+ assert record is not None
213
+ assert "error" not in record
214
+ assert SECRET not in json.dumps(record)
215
+
216
+
217
+ def test_a_payload_that_will_not_export_costs_the_span_and_not_the_run(tmp_path):
218
+ # Named for an allowed type, or the allow-list would be what dropped it and this would pass
219
+ # without exercising the export guard at all.
220
+ class GuardrailSpanData(FakeSpanData):
221
+ def export(self):
222
+ raise RuntimeError("no")
223
+
224
+ record = _one_record(tmp_path, FakeSpan(GuardrailSpanData(None)))
225
+ # Written, because the span type is one the reader wants; empty, because nothing could be read.
226
+ assert record is not None and record["data"] == {}
227
+
228
+ # ── what one payload may cost ─────────────────────────────────────────────────────────────────────
229
+ #
230
+ # This runs inside the agent's own process, on the SDK's callback. It used to walk every *path*
231
+ # through a payload rather than every node, so shared sub-objects cost 2^n and a reference cycle cost
232
+ # everything: `on_span_end` hung with no error and no output, which is the one thing the module's
233
+ # docstrings promise cannot happen. Doing nothing would have been safer — `json.dumps` rejects a
234
+ # circular reference in microseconds.
235
+
236
+
237
+ def test_a_payload_that_refers_to_itself_is_described_rather_than_followed(tmp_path):
238
+ cycle = {}
239
+ cycle["a"] = cycle
240
+ cycle["b"] = cycle # branching, which is what made it explode rather than merely recurse
241
+ record = _one_record(
242
+ tmp_path,
243
+ FakeSpan(AgentSpanData({"name": cycle, "handoffs": [], "tools": [], "output_type": "s"})),
244
+ )
245
+ assert record is not None
246
+ assert "<circular>" in json.dumps(record["data"])
247
+
248
+
249
+ def test_a_payload_larger_than_the_budget_is_truncated_rather_than_written(tmp_path):
250
+ # Comfortably past _MAX_NODES, and linear either way, so this is fast whether or not the bound
251
+ # is there — it is the truncation marker that is being asserted, not a stopwatch.
252
+ wide = [{"n": i} for i in range(20_000)]
253
+ record = _one_record(
254
+ tmp_path,
255
+ FakeSpan(AgentSpanData({"name": wide, "handoffs": [], "tools": [], "output_type": "s"})),
256
+ )
257
+ assert record is not None
258
+ assert "<truncated>" in json.dumps(record["data"])
259
+
260
+
261
+ def test_shared_sub_objects_do_not_cost_a_path_each(tmp_path):
262
+ """Forty shared diamonds, no cycle anywhere. This did not return in twenty seconds."""
263
+ node = "leaf"
264
+ for _ in range(40):
265
+ node = {"l": node, "r": node}
266
+ started = time.monotonic()
267
+ record = _one_record(
268
+ tmp_path,
269
+ FakeSpan(AgentSpanData({"name": node, "handoffs": [], "tools": [], "output_type": "s"})),
270
+ )
271
+ elapsed = time.monotonic() - started
272
+ assert record is not None
273
+ # Generous by three orders of magnitude against the 2^40 it was; the claim is the shape of the
274
+ # curve, not a stopwatch.
275
+ assert elapsed < 10, f"describing a shared structure took {elapsed:.1f}s"
276
+
277
+
278
+ def test_an_ordinary_payload_is_still_written_whole(tmp_path):
279
+ payload = {"a": {"b": {"c": [1, 2, {"d": "ok"}]}}}
280
+ record = _one_record(
281
+ tmp_path,
282
+ FakeSpan(AgentSpanData({"name": payload, "handoffs": [], "tools": [], "output_type": "s"})),
283
+ )
284
+ assert record is not None
285
+ assert record["data"]["name"] == payload
286
+
287
+
288
+ def test_a_datetime_timestamp_is_written_as_iso(tmp_path):
289
+ """The reader parses these with `Date.parse`, and the SDK hands over whatever it hands over.
290
+
291
+ Every supported version of openai-agents stores `util.time_iso()`, which is already a string,
292
+ so this is not today's behaviour being pinned — it is the failure mode if that ever changes.
293
+ The whole record would fail to serialise, the write path would swallow it, and a run would
294
+ capture no spans at all while `trace.start` and `trace.end` kept landing, so nothing about the
295
+ file would look wrong.
296
+
297
+ `str(datetime)` is not the answer either: it puts a space where the `T` belongs. Hence asking
298
+ the value for its own ISO form rather than leaving it to `default=str`.
299
+ """
300
+ out = tmp_path / "spans.jsonl"
301
+ processor = AgenticReplayTracingProcessor(str(out))
302
+ span = FakeSpan(HandoffSpanData({"from_agent": "Triage", "to_agent": "Billing"}))
303
+ span.started_at = datetime.datetime(
304
+ 2026, 9, 10, 3, 46, 3, 483810, tzinfo=datetime.timezone.utc
305
+ )
306
+ span.ended_at = datetime.datetime(2026, 9, 10, 3, 46, 3, 500000, tzinfo=datetime.timezone.utc)
307
+
308
+ processor.on_span_end(span)
309
+
310
+ records = read(out)
311
+ assert len(records) == 1, "a span whose timestamps are datetimes was dropped entirely"
312
+ assert records[0]["started_at"] == "2026-09-10T03:46:03.483810+00:00"
313
+ assert records[0]["ended_at"] == "2026-09-10T03:46:03.500000+00:00"
314
+ assert processor._dropped == 0
315
+
316
+
317
+ def test_a_value_json_cannot_take_costs_that_field_and_nothing_else(tmp_path):
318
+ """The other half of the same guarantee, for a field that has no ISO form to ask for."""
319
+
320
+ class Unserialisable:
321
+ def __repr__(self):
322
+ return "<unserialisable>"
323
+
324
+ out = tmp_path / "spans.jsonl"
325
+ processor = AgenticReplayTracingProcessor(str(out))
326
+ span = FakeSpan(HandoffSpanData({"from_agent": "Triage", "to_agent": "Billing"}))
327
+ span.started_at = Unserialisable()
328
+
329
+ processor.on_span_end(span)
330
+
331
+ records = read(out)
332
+ assert len(records) == 1, "one unserialisable field took the whole span with it"
333
+ assert records[0]["data"] == {"from_agent": "Triage", "to_agent": "Billing"}
334
+ assert processor._dropped == 0
335
+
336
+
337
+ def test_every_record_begins_with_kind(tmp_path):
338
+ """The CLI's reader anchors its recovery of a torn line on these bytes.
339
+
340
+ Every Python process the run starts appends to this file — the lock above is per-process — so a
341
+ short write can leave part of a record with the next process's bytes on the end of it. Getting
342
+ the whole record back out of such a line means finding where one begins, and the only thing on
343
+ the line that can say so is the first key. `json.dumps` keeps insertion order, and every record
344
+ here is built with `kind` first; this is the half of that agreement that lives on this side.
345
+ """
346
+ out = tmp_path / "spans.jsonl"
347
+ processor = AgenticReplayTracingProcessor(str(out))
348
+ processor.on_trace_start(object())
349
+ processor.on_span_end(FakeSpan(HandoffSpanData({"from_agent": "A", "to_agent": "B"})))
350
+ processor.on_trace_end(object())
351
+
352
+ lines = out.read_text(encoding="utf-8").splitlines()
353
+ assert lines, "the processor wrote nothing, so this proves nothing"
354
+ for line in lines:
355
+ assert line.startswith('{"kind":'), line[:24]
356
+
357
+
358
+ # ── saying what was lost ──────────────────────────────────────────────────────────────────────────
359
+ #
360
+ # `_dropped` was counted from the first version and read by nothing, so the two failures `_write`
361
+ # deliberately swallows reached the trace as an absence. Swallowing them is right — a debugger must
362
+ # not be able to fail a run — but staying quiet about them is the shape this project keeps finding:
363
+ # a capture layer reporting success while something it held is gone.
364
+
365
+
366
+ def _wedge(processor):
367
+ """Cost the processor one record, through the guard that really drops them.
368
+
369
+ A non-string key is one of the few things that still defeats `json.dumps` here: `default=` is
370
+ consulted for values and never for keys. Going through `_write` rather than setting the counter
371
+ means the test fails if the guard stops counting.
372
+ """
373
+ processor._write({"kind": "span", (1, 2): "x"})
374
+
375
+
376
+ def test_nothing_lost_says_nothing(tmp_path):
377
+ """The common case, and the one a spurious line would be most annoying in."""
378
+ out = tmp_path / "spans.jsonl"
379
+ processor = AgenticReplayTracingProcessor(str(out))
380
+ processor.on_span_end(FakeSpan(HandoffSpanData({"from_agent": "Triage", "to_agent": "Billing"})))
381
+
382
+ processor.shutdown()
383
+
384
+ kinds = [r["kind"] for r in read(out)]
385
+ assert kinds == ["span"], "shutdown invented a loss on a run that had none"
386
+
387
+
388
+ def test_a_record_that_could_not_be_written_is_reported_at_shutdown(tmp_path):
389
+ out = tmp_path / "spans.jsonl"
390
+ processor = AgenticReplayTracingProcessor(str(out))
391
+
392
+ _wedge(processor)
393
+ assert processor._dropped == 1
394
+ # Not `read(out) == []`: the file is not there at all, because the only record so far is the
395
+ # one that could not be written.
396
+ assert not out.exists(), "the record that could not be serialised was written anyway"
397
+
398
+ processor.shutdown()
399
+
400
+ assert read(out) == [{"kind": "dropped", "count": 1}]
401
+
402
+
403
+ def test_every_loss_is_counted_not_just_the_first(tmp_path):
404
+ out = tmp_path / "spans.jsonl"
405
+ processor = AgenticReplayTracingProcessor(str(out))
406
+ for _ in range(3):
407
+ _wedge(processor)
408
+
409
+ processor.shutdown()
410
+
411
+ assert read(out) == [{"kind": "dropped", "count": 3}]
412
+
413
+
414
+ def test_shutdown_twice_reports_once(tmp_path):
415
+ """The SDK may call `shutdown` more than once; a second line reads as a second, separate loss."""
416
+ out = tmp_path / "spans.jsonl"
417
+ processor = AgenticReplayTracingProcessor(str(out))
418
+ _wedge(processor)
419
+
420
+ processor.shutdown()
421
+ processor.shutdown()
422
+
423
+ assert read(out) == [{"kind": "dropped", "count": 1}]
424
+
425
+
426
+ def test_reporting_a_loss_cannot_itself_end_the_run(tmp_path):
427
+ """The likeliest reason a record was dropped is that this file cannot be written to."""
428
+ out = tmp_path / "spans.jsonl"
429
+ processor = AgenticReplayTracingProcessor(str(out))
430
+ _wedge(processor)
431
+ # A directory where the file should be: every append fails, including shutdown's own.
432
+ (tmp_path / "wedged").mkdir()
433
+ processor._path = str(tmp_path / "wedged")
434
+
435
+ processor.shutdown() # must return, not raise
436
+
437
+
438
+ def test_an_inert_processor_writes_no_dropped_line(tmp_path, monkeypatch):
439
+ """Nothing is being recorded, so there is no file to report a loss into."""
440
+ monkeypatch.delenv(SPANS_ENV, raising=False)
441
+ processor = AgenticReplayTracingProcessor()
442
+ assert not processor.active
443
+
444
+ processor.shutdown() # must return, not raise
445
+
446
+ assert list(tmp_path.iterdir()) == []
447
+
448
+
449
+ def test_the_dropped_record_begins_with_kind_like_every_other(tmp_path):
450
+ """The CLI anchors its recovery of a torn line on these bytes. This record is not exempt."""
451
+ out = tmp_path / "spans.jsonl"
452
+ processor = AgenticReplayTracingProcessor(str(out))
453
+ _wedge(processor)
454
+ processor.shutdown()
455
+
456
+ with open(out, encoding="utf-8") as f:
457
+ assert f.read().startswith('{"kind": "dropped"')
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Plugin API neutrality check.
4
+ *
5
+ * The OrcaRouter plugin — and any other vendor plugin — must reach AgenticReplay only through the
6
+ * published @agenticreplay/plugin-api surface. Enforcing that mechanically is the difference between
7
+ * a neutrality commitment and a neutrality claim: nobody writes an adapter for a project that
8
+ * might grow a privileged path for its owner.
9
+ */
10
+ import { readdir, readFile, stat } from 'node:fs/promises';
11
+ import { join } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ const root = fileURLToPath(new URL('..', import.meta.url));
15
+ const providersSrc = join(root, 'packages', 'providers', 'src');
16
+
17
+ /** Packages a vendor provider plugin may import. Anything else is a privileged path. */
18
+ const ALLOWED = new Set(['@agenticreplay/plugin-api', '@agenticreplay/schema']);
19
+ const VENDOR_HINT = /orcarouter/i;
20
+
21
+ let failures = 0;
22
+
23
+ async function walk(dir) {
24
+ const out = [];
25
+ for (const name of await readdir(dir)) {
26
+ const p = join(dir, name);
27
+ if ((await stat(p)).isDirectory()) out.push(...(await walk(p)));
28
+ else if (p.endsWith('.ts')) out.push(p);
29
+ }
30
+ return out;
31
+ }
32
+
33
+ let files = [];
34
+ try {
35
+ files = await walk(providersSrc);
36
+ } catch {
37
+ console.log('no providers package yet — nothing to check');
38
+ process.exit(0);
39
+ }
40
+
41
+ const vendorFiles = files.filter((f) => VENDOR_HINT.test(f));
42
+ for (const file of files) {
43
+ const src = await readFile(file, 'utf8');
44
+ const isVendor = VENDOR_HINT.test(file) || VENDOR_HINT.test(src.slice(0, 400));
45
+ if (!isVendor) continue;
46
+ for (const m of src.matchAll(/from\s+'(@agenticreplay\/[^']+)'/g)) {
47
+ const pkg = m[1];
48
+ if (!ALLOWED.has(pkg)) {
49
+ failures += 1;
50
+ console.error(`FAIL ${file.replace(root, '')}: vendor plugin imports ${pkg}`);
51
+ console.error(` allowed: ${[...ALLOWED].join(', ')}`);
52
+ }
53
+ }
54
+ }
55
+
56
+ console.log(
57
+ vendorFiles.length === 0
58
+ ? 'no vendor plugin present yet; check is a no-op until one lands'
59
+ : `${vendorFiles.length} vendor plugin file(s) checked`,
60
+ );
61
+ console.log(`${failures} failure(s)`);
62
+ process.exit(failures === 0 ? 0 : 1);
@@ -0,0 +1,133 @@
1
+ // Native Codex acceptance: synthetic credentials, isolated config, independent endpoint.
2
+ import assert from 'node:assert/strict';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { createServer } from 'node:http';
5
+ import { mkdtemp, mkdir, writeFile, readFile } from 'node:fs/promises';
6
+ import { spawn } from 'node:child_process';
7
+ import { join } from 'node:path';
8
+ const root = await mkdtemp('/private/tmp/ar-codex-native-');
9
+ await mkdir(join(root, 'codex'));
10
+ const requests = [];
11
+ const body = {
12
+ id: 'resp_fixture',
13
+ object: 'response',
14
+ status: 'completed',
15
+ model: 'gpt-5.4',
16
+ output: [
17
+ {
18
+ id: 'msg_fixture',
19
+ type: 'message',
20
+ role: 'assistant',
21
+ status: 'completed',
22
+ content: [{ type: 'output_text', text: 'CODEX_TRAILING_SENTINEL', annotations: [] }],
23
+ },
24
+ ],
25
+ usage: { input_tokens: 10, output_tokens: 2, total_tokens: 12 },
26
+ };
27
+ const response = `event: response.created\ndata: ${JSON.stringify({ type: 'response.created', response: { ...body, status: 'in_progress', output: [] } })}\n\nevent: response.completed\ndata: ${JSON.stringify({ type: 'response.completed', response: body })}\n\n`;
28
+ const server = createServer(async (req, res) => {
29
+ let body = '';
30
+ for await (const chunk of req) body += chunk;
31
+ requests.push({ url: req.url, body, authorization: req.headers.authorization });
32
+ res.writeHead(200, { 'content-type': 'text/event-stream' });
33
+ res.end(response);
34
+ });
35
+ await new Promise((r) => server.listen(0, '127.0.0.1', r));
36
+ const base = `http://127.0.0.1:${server.address().port}/v1`;
37
+ await writeFile(join(root, 'codex/config.toml'), 'model="gpt-5.4"\n');
38
+ await writeFile(
39
+ join(root, 'codex/auth.json'),
40
+ JSON.stringify({ OPENAI_API_KEY: 'fixture-api-key' }),
41
+ );
42
+ const env = {
43
+ PATH: '/opt/homebrew/bin:/usr/bin:/bin',
44
+ HOME: root,
45
+ CODEX_HOME: join(root, 'codex'),
46
+ XDG_CONFIG_HOME: join(root, 'config'),
47
+ XDG_DATA_HOME: join(root, 'data'),
48
+ XDG_CACHE_HOME: join(root, 'cache'),
49
+ OPENAI_API_KEY: 'fixture-api-key',
50
+ AGENTICREPLAY_UPSTREAM_OPENAI: base,
51
+ };
52
+ const child = spawn(
53
+ process.execPath,
54
+ [
55
+ process.env.AGENTICREPLAY_TEST_CLI ?? join(process.cwd(), 'packages/cli/dist/cli.js'),
56
+ 'record',
57
+ 'codex',
58
+ '--no-fs',
59
+ '--no-shell',
60
+ '--json',
61
+ '--',
62
+ 'exec',
63
+ '--skip-git-repo-check',
64
+ 'CODEX_SYSTEM_REQUEST_SENTINEL. Reply briefly without tools.',
65
+ ],
66
+ { cwd: root, env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] },
67
+ );
68
+ let stdout = '',
69
+ stderr = '';
70
+ child.stdout.on('data', (c) => (stdout += c));
71
+ child.stderr.on('data', (c) => (stderr += c));
72
+ const timer = setTimeout(() => {
73
+ try {
74
+ process.kill(-child.pid, 'SIGKILL');
75
+ } catch {}
76
+ }, 60000);
77
+ const result = await new Promise((r) => child.on('close', (code, signal) => r({ code, signal })));
78
+ clearTimeout(timer);
79
+ server.closeAllConnections();
80
+ server.close();
81
+ assert.ok([0, 2].includes(result.code), stderr);
82
+ assert.ok(requests.length > 0, 'native Codex bypassed capture');
83
+ const run = JSON.parse(stdout.trim());
84
+ const { TraceReader } = await import(
85
+ pathToFileURL(
86
+ process.env.AGENTICREPLAY_TEST_TRACE_READER ??
87
+ join(process.cwd(), 'packages/core/dist/index.js'),
88
+ ).href
89
+ );
90
+ const reader = await TraceReader.open(run.runDir);
91
+ const events = await reader.events();
92
+ const captured = events.filter(
93
+ (e) => e.type === 'net.request' && e.attrs.phase === 'body' && e.attrs.method === 'POST',
94
+ );
95
+ const responses = events.filter(
96
+ (e) =>
97
+ e.type === 'net.response' &&
98
+ captured.some((request) => request.attrs.request_id === e.attrs.request_id),
99
+ );
100
+ const unsupported = events.filter((e) => e.type === 'net.response' && e.attrs.capture_incomplete);
101
+ assert.equal(result.code, unsupported.length ? 2 : 0);
102
+ assert.equal(captured.length, requests.length);
103
+ assert.equal(responses.length, requests.length);
104
+ for (let i = 0; i < requests.length; i++) {
105
+ assert.equal(requests[i].authorization, 'Bearer fixture-api-key');
106
+ // The random temporary directory name can trigger high-entropy redaction in Codex's
107
+ // system skill paths. Permit only that explicit fixture-path transformation.
108
+ const comparable = (text) =>
109
+ text
110
+ .replaceAll(root, '/private/tmp/<fixture-root>')
111
+ .replace(/\/private\/tmp\/<secret:high_entropy:[0-9a-f]{8}>/g, '/private/tmp/<fixture-root>');
112
+ const actual = comparable(await reader.resolvePayload(captured[i]));
113
+ const expected = comparable(requests[i].body);
114
+ assert.ok(actual === expected, 'captured request differs after expected fixture-path redaction');
115
+ assert.equal(await reader.resolvePayload(responses[i]), response);
116
+ const parsed = JSON.parse(requests[i].body);
117
+ assert.ok(parsed.instructions.length > 0);
118
+ assert.ok(parsed.tools.length > 0);
119
+ assert.ok(requests[i].body.includes('CODEX_SYSTEM_REQUEST_SENTINEL'));
120
+ }
121
+ assert.ok(!JSON.stringify(events).includes('fixture-api-key'));
122
+ console.log(
123
+ JSON.stringify({
124
+ root,
125
+ ...result,
126
+ requests: requests.length,
127
+ unsupportedAttempts: unsupported.length,
128
+ exactAfterExpectedRedaction: true,
129
+ system: true,
130
+ tools: true,
131
+ runDir: run.runDir,
132
+ }),
133
+ );