oh-my-copilot 5.18.0 → 5.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +3 -3
  4. package/bridge/__pycache__/gyoshu_bridge.cpython-314.pyc +0 -0
  5. package/bridge/claude-md-coordinator.cjs +2 -2
  6. package/bridge/cli.cjs +17691 -14571
  7. package/bridge/mcp-server.cjs +4624 -1922
  8. package/bridge/runtime-cli.cjs +2735 -757
  9. package/bridge/team-bridge.cjs +357 -139
  10. package/bridge/team-mcp.cjs +922 -645
  11. package/bridge/team.js +2851 -874
  12. package/dist/__tests__/delegation-enforcer.test.js +1 -1
  13. package/dist/__tests__/delegation-enforcer.test.js.map +1 -1
  14. package/dist/__tests__/hud/cli-diagnostic.test.js +1 -1
  15. package/dist/__tests__/hud/cli-diagnostic.test.js.map +1 -1
  16. package/dist/__tests__/pre-tool-enforcer.test.js +3 -0
  17. package/dist/__tests__/pre-tool-enforcer.test.js.map +1 -1
  18. package/dist/__tests__/session-start-script-context.test.js +1 -1
  19. package/dist/__tests__/session-start-script-context.test.js.map +1 -1
  20. package/dist/__tests__/skills.test.js +9 -0
  21. package/dist/__tests__/skills.test.js.map +1 -1
  22. package/dist/cli/commands/__tests__/smoke-cassette.test.d.ts +2 -0
  23. package/dist/cli/commands/__tests__/smoke-cassette.test.d.ts.map +1 -0
  24. package/dist/cli/commands/__tests__/smoke-cassette.test.js +135 -0
  25. package/dist/cli/commands/__tests__/smoke-cassette.test.js.map +1 -0
  26. package/dist/cli/commands/smoke.d.ts +41 -2
  27. package/dist/cli/commands/smoke.d.ts.map +1 -1
  28. package/dist/cli/commands/smoke.js +103 -6
  29. package/dist/cli/commands/smoke.js.map +1 -1
  30. package/dist/cli/index.d.ts.map +1 -1
  31. package/dist/cli/index.js +30 -2
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/copilot-run/__tests__/job.test.js +347 -2
  34. package/dist/copilot-run/__tests__/job.test.js.map +1 -1
  35. package/dist/copilot-run/__tests__/sandbox-session.test.d.ts +2 -0
  36. package/dist/copilot-run/__tests__/sandbox-session.test.d.ts.map +1 -0
  37. package/dist/copilot-run/__tests__/sandbox-session.test.js +181 -0
  38. package/dist/copilot-run/__tests__/sandbox-session.test.js.map +1 -0
  39. package/dist/copilot-run/__tests__/sandbox.test.js +128 -4
  40. package/dist/copilot-run/__tests__/sandbox.test.js.map +1 -1
  41. package/dist/copilot-run/job.d.ts +87 -13
  42. package/dist/copilot-run/job.d.ts.map +1 -1
  43. package/dist/copilot-run/job.js +517 -177
  44. package/dist/copilot-run/job.js.map +1 -1
  45. package/dist/copilot-run/sandbox-session.d.ts +71 -0
  46. package/dist/copilot-run/sandbox-session.d.ts.map +1 -0
  47. package/dist/copilot-run/sandbox-session.js +156 -0
  48. package/dist/copilot-run/sandbox-session.js.map +1 -0
  49. package/dist/copilot-run/sandbox.d.ts +17 -0
  50. package/dist/copilot-run/sandbox.d.ts.map +1 -1
  51. package/dist/copilot-run/sandbox.js +108 -4
  52. package/dist/copilot-run/sandbox.js.map +1 -1
  53. package/dist/copilot-run/timeout.d.ts +4 -0
  54. package/dist/copilot-run/timeout.d.ts.map +1 -0
  55. package/dist/copilot-run/timeout.js +10 -0
  56. package/dist/copilot-run/timeout.js.map +1 -0
  57. package/dist/factory/check/__tests__/cli-ado.test.d.ts +2 -0
  58. package/dist/factory/check/__tests__/cli-ado.test.d.ts.map +1 -0
  59. package/dist/factory/check/__tests__/cli-ado.test.js +95 -0
  60. package/dist/factory/check/__tests__/cli-ado.test.js.map +1 -0
  61. package/dist/factory/check/__tests__/cli.test.js +2 -1
  62. package/dist/factory/check/__tests__/cli.test.js.map +1 -1
  63. package/dist/factory/check/cli.d.ts +17 -1
  64. package/dist/factory/check/cli.d.ts.map +1 -1
  65. package/dist/factory/check/cli.js +20 -2
  66. package/dist/factory/check/cli.js.map +1 -1
  67. package/dist/factory/heal/__tests__/logs-ado.test.d.ts +2 -0
  68. package/dist/factory/heal/__tests__/logs-ado.test.d.ts.map +1 -0
  69. package/dist/factory/heal/__tests__/logs-ado.test.js +39 -0
  70. package/dist/factory/heal/__tests__/logs-ado.test.js.map +1 -0
  71. package/dist/factory/heal/classify.d.ts +3 -1
  72. package/dist/factory/heal/classify.d.ts.map +1 -1
  73. package/dist/factory/heal/classify.js +4 -2
  74. package/dist/factory/heal/classify.js.map +1 -1
  75. package/dist/factory/heal/cli.d.ts +8 -2
  76. package/dist/factory/heal/cli.d.ts.map +1 -1
  77. package/dist/factory/heal/cli.js +11 -9
  78. package/dist/factory/heal/cli.js.map +1 -1
  79. package/dist/factory/heal/debug-lane.js +1 -1
  80. package/dist/factory/heal/debug-lane.js.map +1 -1
  81. package/dist/factory/heal/heal-evidence.d.ts +4 -2
  82. package/dist/factory/heal/heal-evidence.d.ts.map +1 -1
  83. package/dist/factory/heal/heal-evidence.js +8 -6
  84. package/dist/factory/heal/heal-evidence.js.map +1 -1
  85. package/dist/factory/heal/logs.d.ts +1 -1
  86. package/dist/factory/heal/logs.d.ts.map +1 -1
  87. package/dist/factory/heal/logs.js +4 -3
  88. package/dist/factory/heal/logs.js.map +1 -1
  89. package/dist/factory/heal/run.d.ts +3 -0
  90. package/dist/factory/heal/run.d.ts.map +1 -1
  91. package/dist/factory/heal/run.js +1 -1
  92. package/dist/factory/heal/run.js.map +1 -1
  93. package/dist/factory/run/__tests__/engine.sandbox.test.js +30 -2
  94. package/dist/factory/run/__tests__/engine.sandbox.test.js.map +1 -1
  95. package/dist/factory/run/__tests__/engine.test.js +31 -1
  96. package/dist/factory/run/__tests__/engine.test.js.map +1 -1
  97. package/dist/factory/run/__tests__/fake-lanes.d.ts +2 -0
  98. package/dist/factory/run/__tests__/fake-lanes.d.ts.map +1 -1
  99. package/dist/factory/run/__tests__/fake-lanes.js +1 -1
  100. package/dist/factory/run/__tests__/fake-lanes.js.map +1 -1
  101. package/dist/factory/run/__tests__/merge-policy.test.d.ts +2 -0
  102. package/dist/factory/run/__tests__/merge-policy.test.d.ts.map +1 -0
  103. package/dist/factory/run/__tests__/merge-policy.test.js +40 -0
  104. package/dist/factory/run/__tests__/merge-policy.test.js.map +1 -0
  105. package/dist/factory/run/__tests__/prepare-gates.test.js +22 -0
  106. package/dist/factory/run/__tests__/prepare-gates.test.js.map +1 -1
  107. package/dist/factory/run/__tests__/units.test.js +12 -1
  108. package/dist/factory/run/__tests__/units.test.js.map +1 -1
  109. package/dist/factory/run/engine.d.ts.map +1 -1
  110. package/dist/factory/run/engine.js +32 -6
  111. package/dist/factory/run/engine.js.map +1 -1
  112. package/dist/factory/run/lane-commit.d.ts +10 -1
  113. package/dist/factory/run/lane-commit.d.ts.map +1 -1
  114. package/dist/factory/run/lane-commit.js +21 -4
  115. package/dist/factory/run/lane-commit.js.map +1 -1
  116. package/dist/factory/run/merge-policy.d.ts +3 -1
  117. package/dist/factory/run/merge-policy.d.ts.map +1 -1
  118. package/dist/factory/run/merge-policy.js +8 -2
  119. package/dist/factory/run/merge-policy.js.map +1 -1
  120. package/dist/factory/run/review-guard.d.ts +2 -0
  121. package/dist/factory/run/review-guard.d.ts.map +1 -1
  122. package/dist/factory/run/review-guard.js +1 -1
  123. package/dist/factory/run/review-guard.js.map +1 -1
  124. package/dist/factory/run/state.d.ts +13 -0
  125. package/dist/factory/run/state.d.ts.map +1 -1
  126. package/dist/factory/run/state.js +20 -5
  127. package/dist/factory/run/state.js.map +1 -1
  128. package/dist/features/builtin-skills/skills.js +1 -1
  129. package/dist/features/builtin-skills/skills.js.map +1 -1
  130. package/dist/features/delegation-enforcer.d.ts.map +1 -1
  131. package/dist/features/delegation-enforcer.js +2 -6
  132. package/dist/features/delegation-enforcer.js.map +1 -1
  133. package/dist/forge/__tests__/gh-argv-baseline.heal.test.js +52 -2
  134. package/dist/forge/__tests__/gh-argv-baseline.heal.test.js.map +1 -1
  135. package/dist/forge/ado/__tests__/acceptance-scripts.test.d.ts +8 -0
  136. package/dist/forge/ado/__tests__/acceptance-scripts.test.d.ts.map +1 -0
  137. package/dist/forge/ado/__tests__/acceptance-scripts.test.js +567 -0
  138. package/dist/forge/ado/__tests__/acceptance-scripts.test.js.map +1 -0
  139. package/dist/forge/ado/__tests__/az-binary.test.js +4 -0
  140. package/dist/forge/ado/__tests__/az-binary.test.js.map +1 -1
  141. package/dist/forge/ado/__tests__/failed-jobs.test.d.ts +2 -0
  142. package/dist/forge/ado/__tests__/failed-jobs.test.d.ts.map +1 -0
  143. package/dist/forge/ado/__tests__/failed-jobs.test.js +96 -0
  144. package/dist/forge/ado/__tests__/failed-jobs.test.js.map +1 -0
  145. package/dist/forge/ado/az-binary.d.ts +2 -1
  146. package/dist/forge/ado/az-binary.d.ts.map +1 -1
  147. package/dist/forge/ado/az-binary.js +3 -2
  148. package/dist/forge/ado/az-binary.js.map +1 -1
  149. package/dist/forge/ado/checks.d.ts.map +1 -1
  150. package/dist/forge/ado/checks.js +30 -0
  151. package/dist/forge/ado/checks.js.map +1 -1
  152. package/dist/forge/github/ci.d.ts +2 -0
  153. package/dist/forge/github/ci.d.ts.map +1 -1
  154. package/dist/forge/github/ci.js +3 -0
  155. package/dist/forge/github/ci.js.map +1 -1
  156. package/dist/forge/types.d.ts +2 -0
  157. package/dist/forge/types.d.ts.map +1 -1
  158. package/dist/hooks/autopilot/__tests__/pipeline.test.js +1 -1
  159. package/dist/hooks/autopilot/__tests__/pipeline.test.js.map +1 -1
  160. package/dist/hooks/autopilot/adapters/execution-adapter.js +3 -3
  161. package/dist/hooks/autopilot/adapters/execution-adapter.js.map +1 -1
  162. package/dist/hooks/keyword-detector/__tests__/index.test.js +4 -0
  163. package/dist/hooks/keyword-detector/__tests__/index.test.js.map +1 -1
  164. package/dist/hooks/keyword-detector/__tests__/jev-shadow.test.js +7 -0
  165. package/dist/hooks/keyword-detector/__tests__/jev-shadow.test.js.map +1 -1
  166. package/dist/hooks/keyword-detector/index.d.ts +1 -1
  167. package/dist/hooks/keyword-detector/index.js +4 -4
  168. package/dist/hooks/keyword-detector/index.js.map +1 -1
  169. package/dist/hooks/keyword-detector/jev-shadow.js +1 -1
  170. package/dist/hooks/keyword-detector/jev-shadow.js.map +1 -1
  171. package/dist/hud/index.js +1 -1
  172. package/dist/hud/index.js.map +1 -1
  173. package/dist/mcp/__tests__/host-smoke-tool.test.js +14 -0
  174. package/dist/mcp/__tests__/host-smoke-tool.test.js.map +1 -1
  175. package/dist/ship/gates.d.ts +9 -3
  176. package/dist/ship/gates.d.ts.map +1 -1
  177. package/dist/ship/gates.js +24 -7
  178. package/dist/ship/gates.js.map +1 -1
  179. package/dist/smoke/__tests__/copilot-sdk-driver.test.js +129 -4
  180. package/dist/smoke/__tests__/copilot-sdk-driver.test.js.map +1 -1
  181. package/dist/smoke/__tests__/copilot-session-env.test.d.ts +2 -0
  182. package/dist/smoke/__tests__/copilot-session-env.test.d.ts.map +1 -0
  183. package/dist/smoke/__tests__/copilot-session-env.test.js +29 -0
  184. package/dist/smoke/__tests__/copilot-session-env.test.js.map +1 -0
  185. package/dist/smoke/__tests__/copilot-team-scenario.test.js +3 -0
  186. package/dist/smoke/__tests__/copilot-team-scenario.test.js.map +1 -1
  187. package/dist/smoke/copilot-sdk-driver.d.ts +37 -1
  188. package/dist/smoke/copilot-sdk-driver.d.ts.map +1 -1
  189. package/dist/smoke/copilot-sdk-driver.js +114 -10
  190. package/dist/smoke/copilot-sdk-driver.js.map +1 -1
  191. package/dist/smoke/copilot-sdk-scenarios.d.ts +27 -0
  192. package/dist/smoke/copilot-sdk-scenarios.d.ts.map +1 -1
  193. package/dist/smoke/copilot-sdk-scenarios.js +31 -0
  194. package/dist/smoke/copilot-sdk-scenarios.js.map +1 -1
  195. package/dist/smoke/copilot-session-env.d.ts +38 -1
  196. package/dist/smoke/copilot-session-env.d.ts.map +1 -1
  197. package/dist/smoke/copilot-session-env.js +82 -1
  198. package/dist/smoke/copilot-session-env.js.map +1 -1
  199. package/dist/smoke/copilot-smoke.d.ts +21 -1
  200. package/dist/smoke/copilot-smoke.d.ts.map +1 -1
  201. package/dist/smoke/copilot-smoke.js +86 -6
  202. package/dist/smoke/copilot-smoke.js.map +1 -1
  203. package/dist/smoke/copilot-team-scenario.d.ts +4 -2
  204. package/dist/smoke/copilot-team-scenario.d.ts.map +1 -1
  205. package/dist/smoke/copilot-team-scenario.js +5 -4
  206. package/dist/smoke/copilot-team-scenario.js.map +1 -1
  207. package/dist/smoke/replay/__tests__/cassette.test.d.ts +2 -0
  208. package/dist/smoke/replay/__tests__/cassette.test.d.ts.map +1 -0
  209. package/dist/smoke/replay/__tests__/cassette.test.js +387 -0
  210. package/dist/smoke/replay/__tests__/cassette.test.js.map +1 -0
  211. package/dist/smoke/replay/__tests__/handler.test.d.ts +2 -0
  212. package/dist/smoke/replay/__tests__/handler.test.d.ts.map +1 -0
  213. package/dist/smoke/replay/__tests__/handler.test.js +367 -0
  214. package/dist/smoke/replay/__tests__/handler.test.js.map +1 -0
  215. package/dist/smoke/replay/__tests__/matcher.test.d.ts +2 -0
  216. package/dist/smoke/replay/__tests__/matcher.test.d.ts.map +1 -0
  217. package/dist/smoke/replay/__tests__/matcher.test.js +318 -0
  218. package/dist/smoke/replay/__tests__/matcher.test.js.map +1 -0
  219. package/dist/smoke/replay/__tests__/normalize.test.d.ts +2 -0
  220. package/dist/smoke/replay/__tests__/normalize.test.d.ts.map +1 -0
  221. package/dist/smoke/replay/__tests__/normalize.test.js +53 -0
  222. package/dist/smoke/replay/__tests__/normalize.test.js.map +1 -0
  223. package/dist/smoke/replay/__tests__/redact.test.d.ts +2 -0
  224. package/dist/smoke/replay/__tests__/redact.test.d.ts.map +1 -0
  225. package/dist/smoke/replay/__tests__/redact.test.js +453 -0
  226. package/dist/smoke/replay/__tests__/redact.test.js.map +1 -0
  227. package/dist/smoke/replay/__tests__/run.test.d.ts +2 -0
  228. package/dist/smoke/replay/__tests__/run.test.d.ts.map +1 -0
  229. package/dist/smoke/replay/__tests__/run.test.js +311 -0
  230. package/dist/smoke/replay/__tests__/run.test.js.map +1 -0
  231. package/dist/smoke/replay/cassette.d.ts +210 -0
  232. package/dist/smoke/replay/cassette.d.ts.map +1 -0
  233. package/dist/smoke/replay/cassette.js +580 -0
  234. package/dist/smoke/replay/cassette.js.map +1 -0
  235. package/dist/smoke/replay/handler.d.ts +221 -0
  236. package/dist/smoke/replay/handler.d.ts.map +1 -0
  237. package/dist/smoke/replay/handler.js +702 -0
  238. package/dist/smoke/replay/handler.js.map +1 -0
  239. package/dist/smoke/replay/matcher.d.ts +194 -0
  240. package/dist/smoke/replay/matcher.d.ts.map +1 -0
  241. package/dist/smoke/replay/matcher.js +344 -0
  242. package/dist/smoke/replay/matcher.js.map +1 -0
  243. package/dist/smoke/replay/normalize.d.ts +35 -0
  244. package/dist/smoke/replay/normalize.d.ts.map +1 -0
  245. package/dist/smoke/replay/normalize.js +64 -0
  246. package/dist/smoke/replay/normalize.js.map +1 -0
  247. package/dist/smoke/replay/redact.d.ts +151 -0
  248. package/dist/smoke/replay/redact.d.ts.map +1 -0
  249. package/dist/smoke/replay/redact.js +577 -0
  250. package/dist/smoke/replay/redact.js.map +1 -0
  251. package/dist/smoke/replay/run.d.ts +119 -0
  252. package/dist/smoke/replay/run.d.ts.map +1 -0
  253. package/dist/smoke/replay/run.js +302 -0
  254. package/dist/smoke/replay/run.js.map +1 -0
  255. package/dist/team/__tests__/sdk-transport.test.js +334 -6
  256. package/dist/team/__tests__/sdk-transport.test.js.map +1 -1
  257. package/dist/team/__tests__/tmux-session.pane-env.test.js +13 -13
  258. package/dist/team/__tests__/tmux-session.pane-env.test.js.map +1 -1
  259. package/dist/team/__tests__/tmux-session.spawn.test.js +12 -0
  260. package/dist/team/__tests__/tmux-session.spawn.test.js.map +1 -1
  261. package/dist/team/__tests__/tmux-session.split-pane-env.test.js +2 -2
  262. package/dist/team/__tests__/tmux-session.split-pane-env.test.js.map +1 -1
  263. package/dist/team/__tests__/worker-launch-ack.test.js +173 -9
  264. package/dist/team/__tests__/worker-launch-ack.test.js.map +1 -1
  265. package/dist/team/git-worktree.d.ts.map +1 -1
  266. package/dist/team/git-worktree.js +2 -1
  267. package/dist/team/git-worktree.js.map +1 -1
  268. package/dist/team/model-contract.d.ts.map +1 -1
  269. package/dist/team/model-contract.js +3 -2
  270. package/dist/team/model-contract.js.map +1 -1
  271. package/dist/team/sdk-host.d.ts +44 -0
  272. package/dist/team/sdk-host.d.ts.map +1 -1
  273. package/dist/team/sdk-host.js +147 -5
  274. package/dist/team/sdk-host.js.map +1 -1
  275. package/dist/team/sdk-policy.d.ts +17 -0
  276. package/dist/team/sdk-policy.d.ts.map +1 -1
  277. package/dist/team/sdk-policy.js +79 -1
  278. package/dist/team/sdk-policy.js.map +1 -1
  279. package/dist/team/sdk-transport.d.ts +15 -0
  280. package/dist/team/sdk-transport.d.ts.map +1 -1
  281. package/dist/team/sdk-transport.js +54 -9
  282. package/dist/team/sdk-transport.js.map +1 -1
  283. package/dist/team/tmux-session.d.ts.map +1 -1
  284. package/dist/team/tmux-session.js +5 -0
  285. package/dist/team/tmux-session.js.map +1 -1
  286. package/dist/team/worker-launch-ack.d.ts +3 -1
  287. package/dist/team/worker-launch-ack.d.ts.map +1 -1
  288. package/dist/team/worker-launch-ack.js +73 -8
  289. package/dist/team/worker-launch-ack.js.map +1 -1
  290. package/dist/tools/host-smoke-tool.d.ts +5 -1
  291. package/dist/tools/host-smoke-tool.d.ts.map +1 -1
  292. package/dist/tools/host-smoke-tool.js +26 -3
  293. package/dist/tools/host-smoke-tool.js.map +1 -1
  294. package/dist/workflow/__tests__/alias-resolver.test.js +2 -0
  295. package/dist/workflow/__tests__/alias-resolver.test.js.map +1 -1
  296. package/dist/workflow/alias-resolver.js +2 -2
  297. package/dist/workflow/alias-resolver.js.map +1 -1
  298. package/docs/CLAUDE.md +3 -2
  299. package/docs/REFERENCE.md +69 -4
  300. package/docs/copilot-instructions.md +6 -5
  301. package/package.json +2 -2
  302. package/plugin.json +1 -1
  303. package/scripts/ado-acceptance.mjs +611 -0
  304. package/scripts/ado-capture.mjs +320 -0
  305. package/scripts/ado-fixture-import.mjs +293 -0
  306. package/scripts/keyword-detector.mjs +2 -2
  307. package/scripts/lib/backlog-to-workitems.mjs +115 -0
  308. package/scripts/persistent-mode.cjs +1 -1
  309. package/scripts/persistent-mode.mjs +1 -1
  310. package/scripts/pre-tool-enforcer.mjs +1 -1
  311. package/scripts/session-start.mjs +3 -3
  312. package/scripts/setup-copilot-instructions.sh +1 -1
  313. package/scripts/spikes/request-handler-probe.mjs +186 -0
  314. package/skills/autopilot/SKILL.md +3 -3
  315. package/skills/cancel/SKILL.md +1 -1
  316. package/skills/ship/SKILL.md +2 -2
  317. package/skills/team/SKILL.md +3 -3
  318. package/templates/hooks/keyword-detector.mjs +1 -1
  319. package/templates/hooks/pre-tool-use.mjs +1 -1
  320. package/bridge/__pycache__/gyoshu_bridge.cpython-312.pyc +0 -0
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Cassette request handlers and the `withCassette` SDK wrapper (design:
3
+ * .omc/plans/2026-10-29-copilot-replay-design.md, sections 2, 4 and 8).
4
+ *
5
+ * The SDK's experimental `CopilotClientOptions.requestHandler` receives every
6
+ * model-layer request the runtime issues. {@link withCassette} (applied in
7
+ * `loadCopilotSdk`, so every client of the codebase is covered) injects one per
8
+ * client when `OMG_COPILOT_CASSETTE_MODE` is set:
9
+ *
10
+ * - record: a pass-through tap. Each request is forwarded by the SDK's own
11
+ * default, the response is teed, redacted (redact.ts) and kept in memory;
12
+ * `client.stop()` writes the recording through {@link writeCassette}, which
13
+ * gates it and writes nothing if a secret survived. One part per client and scenario,
14
+ * under `<state>/parts/` (`<pid>-<n>.failed` when it could not be written);
15
+ * the smoke merges them (replay/run.ts).
16
+ * - replay: never forwards. The handler class overrides both SDK hooks without
17
+ * calling `super` and holds no upstream: every request is answered from the
18
+ * cassette through {@link ReplayMatcher}, a miss with HTTP 418.
19
+ *
20
+ * WebSocket transport is refused in both modes (recordings set
21
+ * `COPILOT_CLI_DISABLE_WEBSOCKET_RESPONSES=1`).
22
+ */
23
+ import type { LoadedSdk } from '../copilot-sdk-driver.js';
24
+ import { type Cassette, type CassetteResponse } from './cassette.js';
25
+ import { type LiveRequest, type MatchMode } from './matcher.js';
26
+ import { type PlaceholderDirs, type RedactionIdentity } from './redact.js';
27
+ /** What the SDK hands each hook (`CopilotRequestContext`, SDK 1.0.16). */
28
+ export interface CopilotRequestContextLike {
29
+ requestId?: string;
30
+ sessionId?: string;
31
+ agentId?: string;
32
+ parentAgentId?: string;
33
+ interactionType?: string;
34
+ transport: 'http' | 'websocket';
35
+ url: string;
36
+ headers?: Record<string, string[] | string | undefined>;
37
+ signal?: AbortSignal;
38
+ }
39
+ /** The SDK's `CopilotRequestHandler` base: its defaults forward upstream (`fetch`, a WebSocket forwarder). */
40
+ export interface CopilotRequestHandlerLike {
41
+ sendRequest(request: Request, ctx: CopilotRequestContextLike): Promise<Response>;
42
+ openWebSocket(ctx: CopilotRequestContextLike): Promise<unknown>;
43
+ }
44
+ export type CopilotRequestHandlerCtor = new () => CopilotRequestHandlerLike;
45
+ export type CassetteMode = 'record' | 'replay';
46
+ export interface CassetteConfig {
47
+ mode: CassetteMode;
48
+ /** `OMG_COPILOT_CASSETTE`: the cassette (replay) or recording root (record). */
49
+ dir: string;
50
+ /** `OMG_COPILOT_CASSETTE_STATE`: shared by every process of one run (claims, ordinals, logs, record parts). */
51
+ stateDir: string;
52
+ scenario?: string;
53
+ /** `OMG_COPILOT_CASSETTE_MATCH` (replay only). */
54
+ matchMode?: MatchMode;
55
+ /** `OMG_COPILOT_CASSETTE_DIRS`: placeholder dirs on top of TMP and USERHOME. */
56
+ dirs?: PlaceholderDirs;
57
+ }
58
+ export declare const REQUEST_HANDLER_MISSING = "replay needs @github/copilot-sdk with requestHandler (>= 1.0.16)";
59
+ /** Per-client recordings, `<state>/parts/<pid>-<n>`, merged by the smoke. */
60
+ export declare const RECORD_PARTS_DIR = "parts";
61
+ /** `<state>/parts/<pid>-<n>.failed`: a recording that could not be written (gate refusal, write error); the merge refuses. */
62
+ export declare const RECORD_FAILED_SUFFIX = ".failed";
63
+ /** `<state>/parts/<pid>-<n>.started`: a client recorded and has not stopped yet; left behind by a killed process, so the merge refuses. */
64
+ export declare const RECORD_STARTED_SUFFIX = ".started";
65
+ /**
66
+ * The state dir name of a multi-scenario client (the smoke driver's) before
67
+ * its first `setCassetteScenario`: record and replay both answer its requests
68
+ * with a 418 miss, so a recording holds nothing a replay could not serve.
69
+ */
70
+ export declare const UNSCOPED_STATE_DIR = "_client";
71
+ export declare class CassetteConfigError extends Error {
72
+ name: string;
73
+ }
74
+ /**
75
+ * The cassette env, checked (section 8.5): null when neither the mode nor the
76
+ * dir is set; otherwise the mode must be exactly `record` or `replay` and the
77
+ * dir and state dir are required. Recording is refused under `CI` and into a
78
+ * fixtures dir.
79
+ */
80
+ export declare function readCassetteConfig(env: NodeJS.ProcessEnv): CassetteConfig | null;
81
+ interface RequestShape {
82
+ messages: unknown[];
83
+ tools: string[];
84
+ /** Responses API with `previous_response_id`: `input` already holds only the new items. */
85
+ incremental: boolean;
86
+ }
87
+ /** New messages per live stream since its previous request. */
88
+ export declare class DeltaTracker {
89
+ private readonly seen;
90
+ next(key: string, shape: RequestShape): unknown[];
91
+ }
92
+ export interface AnalyzedRequest {
93
+ live: LiveRequest;
94
+ /** The raw new messages, one JSON per line (memory only; disk gets {@link diskDelta}). */
95
+ deltaText: string;
96
+ }
97
+ /**
98
+ * The matcher's view of one request. A request with no user message (`GET
99
+ * /models`, no body) has no `promptDigest` and is served from the global
100
+ * stream; every other one advances its live stream's delta.
101
+ */
102
+ export declare function analyzeRequest(method: string, body: string, ctx: CopilotRequestContextLike, dirs: PlaceholderDirs, deltas: DeltaTracker): AnalyzedRequest;
103
+ /**
104
+ * Tool-call ids a response issues, in any wire format (buffered or SSE): chat
105
+ * `tool_calls[].id`, Responses `function_call` items' `call_id`, Anthropic
106
+ * `tool_use` blocks' `id`. The next request of the stream must answer each.
107
+ */
108
+ export declare function responseToolCallIds(res: CassetteResponse): string[];
109
+ /** Add secret literals to this process's redaction deny set (never written anywhere). */
110
+ export declare function addRecordingDenyLiterals(values: Iterable<string>): void;
111
+ interface Deferred<T> {
112
+ promise: Promise<T>;
113
+ resolve: (value: T) => void;
114
+ }
115
+ interface PendingInteraction {
116
+ order: number;
117
+ stream: string;
118
+ seq: number;
119
+ method: string;
120
+ ctx: CopilotRequestContextLike;
121
+ analyzed: AnalyzedRequest;
122
+ expects: Promise<string[]>;
123
+ toolCalls: Deferred<string[]>;
124
+ started: number;
125
+ }
126
+ export interface CassetteRecorderOptions {
127
+ stateDir: string;
128
+ scenario?: string;
129
+ sdkVersion?: string | null;
130
+ dirs: PlaceholderDirs;
131
+ /** Source of credential env values for the deny set (default `process.env`). */
132
+ env?: NodeJS.ProcessEnv;
133
+ identity?: RedactionIdentity;
134
+ }
135
+ /**
136
+ * One client's recording. Stream ids are `s<ordinal>-<agent path>`, with
137
+ * ordinals from the same cross-process allocation the matcher uses
138
+ * ({@link StreamPositions}), so parts from several processes never collide.
139
+ */
140
+ export declare class CassetteRecorder {
141
+ private readonly options;
142
+ private readonly positions;
143
+ private readonly deltas;
144
+ private readonly streams;
145
+ private readonly seqs;
146
+ private readonly lastToolCalls;
147
+ private readonly recorded;
148
+ private readonly pending;
149
+ private readonly authorizations;
150
+ private readonly retiredHits;
151
+ private readonly errors;
152
+ private redactor;
153
+ private redactorDenySize;
154
+ private order;
155
+ constructor(options: CassetteRecorderOptions);
156
+ /** The deny set as of now: env credentials, every Authorization seen, the process's extra literals. */
157
+ denyLiterals(): Set<string>;
158
+ /** A redactor over the current deny set; rebuilt (hits carried over) when the set grows. */
159
+ private currentRedactor;
160
+ /** Before forwarding: assign the request its stream and seq, in arrival order. */
161
+ begin(method: string, body: string, ctx: CopilotRequestContextLike): PendingInteraction;
162
+ /** The upstream failed: nothing is recorded for this request. */
163
+ abandon(p: PendingInteraction): void;
164
+ /**
165
+ * After forwarding: hand the runtime one branch of the teed body and record
166
+ * the other. Redaction runs before the interaction is kept.
167
+ */
168
+ tap(p: PendingInteraction, response: Response): Response;
169
+ /** Everything recorded so far, once every tapped response finished. */
170
+ cassette(): Promise<Cassette>;
171
+ /**
172
+ * Write the recording to `dir` through the gate (fail closed: a
173
+ * CassetteGateError and nothing written). Null when nothing was recorded.
174
+ */
175
+ finish(dir: string): Promise<string[] | null>;
176
+ }
177
+ /** A recording handler: forwards through the SDK's default (`super`), taps the response. */
178
+ export declare function createRecordingHandler(Base: CopilotRequestHandlerCtor, recorderOf: CassetteRecorder | ((ctx: CopilotRequestContextLike) => CassetteRecorder | null)): CopilotRequestHandlerLike;
179
+ /** Answers requests from one cassette; holds no upstream of any kind. */
180
+ export declare class CassetteReplayer {
181
+ private readonly dirs;
182
+ private readonly matcher;
183
+ private readonly deltas;
184
+ constructor(cassette: Cassette, stateDir: string, mode: MatchMode, dirs: PlaceholderDirs);
185
+ respond(method: string, body: string, ctx: CopilotRequestContextLike): Response;
186
+ }
187
+ /**
188
+ * A replay handler. It extends the SDK base only because the SDK dispatches
189
+ * through it; both hooks are overridden without `super`, and nothing in the
190
+ * class can reach an upstream (section 8.1).
191
+ */
192
+ export declare function createReplayHandler(Base: CopilotRequestHandlerCtor, replayerOf: CassetteReplayer | ((ctx: CopilotRequestContextLike) => CassetteReplayer | null)): CopilotRequestHandlerLike;
193
+ /** The cassette of a replay run: `<dir>` itself, or `<dir>/<scenario>`. Refuses one from another platform. */
194
+ export declare function loadReplayCassette(config: CassetteConfig): Cassette;
195
+ export interface WithCassetteOptions {
196
+ /** Dirs turned into placeholders (on top of TMP, USERHOME and the env's `OMG_COPILOT_CASSETTE_DIRS`). */
197
+ dirs?: PlaceholderDirs;
198
+ matchMode?: MatchMode;
199
+ }
200
+ /** What a cassette client adds to the SDK client. */
201
+ export interface CassetteClientControl {
202
+ /** The marker callers test instead of re-reading the env. */
203
+ readonly cassette: CassetteMode;
204
+ /**
205
+ * Record or replay this client's next requests as `scenario`, with that
206
+ * scenario's state dir: for the smoke driver, whose one client runs several
207
+ * scenarios. Every other client takes its scenario from the env. Throws when
208
+ * the scenario's cassette cannot be replayed.
209
+ */
210
+ setCassetteScenario(scenario: string, stateDir: string): void;
211
+ }
212
+ /**
213
+ * The SDK with a client that records or replays every model request, per the
214
+ * cassette env; `loaded` unchanged when that env is unset. Throws (never a
215
+ * plain client) when the env is invalid, the cassette cannot be read, or the
216
+ * SDK has no `CopilotRequestHandler`. The returned SDK and its clients carry
217
+ * the mode as `cassette`.
218
+ */
219
+ export declare function withCassette(loaded: LoadedSdk, env?: NodeJS.ProcessEnv, options?: WithCassetteOptions): LoadedSdk;
220
+ export {};
221
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/smoke/replay/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAqD,MAAM,0BAA0B,CAAC;AAC7G,OAAO,EAOL,KAAK,QAAQ,EAEb,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwD,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtH,OAAO,EAUL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAErB,0EAA0E;AAC1E,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,C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