@yolk-sdk/emulators 0.1.0-canary.96

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 (333) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2135 -0
  3. package/dist/anthropic.d.mts +269 -0
  4. package/dist/anthropic.d.mts.map +1 -0
  5. package/dist/anthropic.mjs +177 -0
  6. package/dist/anthropic.mjs.map +1 -0
  7. package/dist/chat-completions.d.mts +288 -0
  8. package/dist/chat-completions.d.mts.map +1 -0
  9. package/dist/chat-completions.mjs +451 -0
  10. package/dist/chat-completions.mjs.map +1 -0
  11. package/dist/codex.d.mts +265 -0
  12. package/dist/codex.d.mts.map +1 -0
  13. package/dist/codex.mjs +199 -0
  14. package/dist/codex.mjs.map +1 -0
  15. package/dist/dropbox/api.d.mts +63 -0
  16. package/dist/dropbox/api.d.mts.map +1 -0
  17. package/dist/dropbox/api.mjs +565 -0
  18. package/dist/dropbox/api.mjs.map +1 -0
  19. package/dist/dropbox/state.d.mts +136 -0
  20. package/dist/dropbox/state.d.mts.map +1 -0
  21. package/dist/dropbox/state.mjs +209 -0
  22. package/dist/dropbox/state.mjs.map +1 -0
  23. package/dist/dropbox.d.mts +79 -0
  24. package/dist/dropbox.d.mts.map +1 -0
  25. package/dist/dropbox.mjs +124 -0
  26. package/dist/dropbox.mjs.map +1 -0
  27. package/dist/email-fixtures.d.mts +36 -0
  28. package/dist/email-fixtures.d.mts.map +1 -0
  29. package/dist/email-fixtures.mjs +1080 -0
  30. package/dist/email-fixtures.mjs.map +1 -0
  31. package/dist/email.d.mts +160 -0
  32. package/dist/email.d.mts.map +1 -0
  33. package/dist/email.mjs +608 -0
  34. package/dist/email.mjs.map +1 -0
  35. package/dist/emulator-compose.d.mts +40 -0
  36. package/dist/emulator-compose.d.mts.map +1 -0
  37. package/dist/emulator-compose.mjs +91 -0
  38. package/dist/emulator-compose.mjs.map +1 -0
  39. package/dist/emulator-http.d.mts +53 -0
  40. package/dist/emulator-http.d.mts.map +1 -0
  41. package/dist/emulator-http.mjs +117 -0
  42. package/dist/emulator-http.mjs.map +1 -0
  43. package/dist/emulator-kernel.d.mts +176 -0
  44. package/dist/emulator-kernel.d.mts.map +1 -0
  45. package/dist/emulator-kernel.mjs +413 -0
  46. package/dist/emulator-kernel.mjs.map +1 -0
  47. package/dist/fixture-route.d.mts +129 -0
  48. package/dist/fixture-route.d.mts.map +1 -0
  49. package/dist/fixture-route.mjs +257 -0
  50. package/dist/fixture-route.mjs.map +1 -0
  51. package/dist/fortnox/api.d.mts +92 -0
  52. package/dist/fortnox/api.d.mts.map +1 -0
  53. package/dist/fortnox/api.mjs +750 -0
  54. package/dist/fortnox/api.mjs.map +1 -0
  55. package/dist/fortnox/state.d.mts +533 -0
  56. package/dist/fortnox/state.d.mts.map +1 -0
  57. package/dist/fortnox/state.mjs +612 -0
  58. package/dist/fortnox/state.mjs.map +1 -0
  59. package/dist/fortnox.d.mts +128 -0
  60. package/dist/fortnox.d.mts.map +1 -0
  61. package/dist/fortnox.mjs +403 -0
  62. package/dist/fortnox.mjs.map +1 -0
  63. package/dist/gateway-evaluate-recordings.d.mts +12 -0
  64. package/dist/gateway-evaluate-recordings.d.mts.map +1 -0
  65. package/dist/gateway-evaluate-recordings.mjs +128 -0
  66. package/dist/gateway-evaluate-recordings.mjs.map +1 -0
  67. package/dist/gateway.d.mts +272 -0
  68. package/dist/gateway.d.mts.map +1 -0
  69. package/dist/gateway.mjs +400 -0
  70. package/dist/gateway.mjs.map +1 -0
  71. package/dist/github/api.d.mts +63 -0
  72. package/dist/github/api.d.mts.map +1 -0
  73. package/dist/github/api.mjs +527 -0
  74. package/dist/github/api.mjs.map +1 -0
  75. package/dist/github/state.d.mts +272 -0
  76. package/dist/github/state.d.mts.map +1 -0
  77. package/dist/github/state.mjs +303 -0
  78. package/dist/github/state.mjs.map +1 -0
  79. package/dist/github.d.mts +77 -0
  80. package/dist/github.d.mts.map +1 -0
  81. package/dist/github.mjs +180 -0
  82. package/dist/github.mjs.map +1 -0
  83. package/dist/google/calendar.d.mts +10 -0
  84. package/dist/google/calendar.d.mts.map +1 -0
  85. package/dist/google/calendar.mjs +252 -0
  86. package/dist/google/calendar.mjs.map +1 -0
  87. package/dist/google/drive.d.mts +8 -0
  88. package/dist/google/drive.d.mts.map +1 -0
  89. package/dist/google/drive.mjs +252 -0
  90. package/dist/google/drive.mjs.map +1 -0
  91. package/dist/google/gmail.d.mts +10 -0
  92. package/dist/google/gmail.d.mts.map +1 -0
  93. package/dist/google/gmail.mjs +591 -0
  94. package/dist/google/gmail.mjs.map +1 -0
  95. package/dist/google/shared.d.mts +107 -0
  96. package/dist/google/shared.d.mts.map +1 -0
  97. package/dist/google/shared.mjs +146 -0
  98. package/dist/google/shared.mjs.map +1 -0
  99. package/dist/google/state.d.mts +385 -0
  100. package/dist/google/state.d.mts.map +1 -0
  101. package/dist/google/state.mjs +496 -0
  102. package/dist/google/state.mjs.map +1 -0
  103. package/dist/google.d.mts +75 -0
  104. package/dist/google.d.mts.map +1 -0
  105. package/dist/google.mjs +210 -0
  106. package/dist/google.mjs.map +1 -0
  107. package/dist/linkedin-search/api.d.mts +45 -0
  108. package/dist/linkedin-search/api.d.mts.map +1 -0
  109. package/dist/linkedin-search/api.mjs +181 -0
  110. package/dist/linkedin-search/api.mjs.map +1 -0
  111. package/dist/linkedin-search/state.d.mts +123 -0
  112. package/dist/linkedin-search/state.d.mts.map +1 -0
  113. package/dist/linkedin-search/state.mjs +261 -0
  114. package/dist/linkedin-search/state.mjs.map +1 -0
  115. package/dist/linkedin-search.d.mts +69 -0
  116. package/dist/linkedin-search.d.mts.map +1 -0
  117. package/dist/linkedin-search.mjs +158 -0
  118. package/dist/linkedin-search.mjs.map +1 -0
  119. package/dist/mcp/api.d.mts +44 -0
  120. package/dist/mcp/api.d.mts.map +1 -0
  121. package/dist/mcp/api.mjs +557 -0
  122. package/dist/mcp/api.mjs.map +1 -0
  123. package/dist/mcp/recordings.d.mts +40 -0
  124. package/dist/mcp/recordings.d.mts.map +1 -0
  125. package/dist/mcp/recordings.mjs +2390 -0
  126. package/dist/mcp/recordings.mjs.map +1 -0
  127. package/dist/mcp/state.d.mts +71 -0
  128. package/dist/mcp/state.d.mts.map +1 -0
  129. package/dist/mcp/state.mjs +83 -0
  130. package/dist/mcp/state.mjs.map +1 -0
  131. package/dist/mcp.d.mts +84 -0
  132. package/dist/mcp.d.mts.map +1 -0
  133. package/dist/mcp.mjs +241 -0
  134. package/dist/mcp.mjs.map +1 -0
  135. package/dist/messages.d.mts +183 -0
  136. package/dist/messages.d.mts.map +1 -0
  137. package/dist/messages.mjs +532 -0
  138. package/dist/messages.mjs.map +1 -0
  139. package/dist/microsoft/api.d.mts +47 -0
  140. package/dist/microsoft/api.d.mts.map +1 -0
  141. package/dist/microsoft/api.mjs +178 -0
  142. package/dist/microsoft/api.mjs.map +1 -0
  143. package/dist/microsoft/calendar.d.mts +30 -0
  144. package/dist/microsoft/calendar.d.mts.map +1 -0
  145. package/dist/microsoft/calendar.mjs +271 -0
  146. package/dist/microsoft/calendar.mjs.map +1 -0
  147. package/dist/microsoft/drive.d.mts +36 -0
  148. package/dist/microsoft/drive.d.mts.map +1 -0
  149. package/dist/microsoft/drive.mjs +298 -0
  150. package/dist/microsoft/drive.mjs.map +1 -0
  151. package/dist/microsoft/graph.d.mts +198 -0
  152. package/dist/microsoft/graph.d.mts.map +1 -0
  153. package/dist/microsoft/graph.mjs +264 -0
  154. package/dist/microsoft/graph.mjs.map +1 -0
  155. package/dist/microsoft/mail.d.mts +48 -0
  156. package/dist/microsoft/mail.d.mts.map +1 -0
  157. package/dist/microsoft/mail.mjs +488 -0
  158. package/dist/microsoft/mail.mjs.map +1 -0
  159. package/dist/microsoft/state.d.mts +480 -0
  160. package/dist/microsoft/state.d.mts.map +1 -0
  161. package/dist/microsoft/state.mjs +625 -0
  162. package/dist/microsoft/state.mjs.map +1 -0
  163. package/dist/microsoft.d.mts +168 -0
  164. package/dist/microsoft.d.mts.map +1 -0
  165. package/dist/microsoft.mjs +483 -0
  166. package/dist/microsoft.mjs.map +1 -0
  167. package/dist/node.d.mts +47 -0
  168. package/dist/node.d.mts.map +1 -0
  169. package/dist/node.mjs +178 -0
  170. package/dist/node.mjs.map +1 -0
  171. package/dist/notion/api.d.mts +51 -0
  172. package/dist/notion/api.d.mts.map +1 -0
  173. package/dist/notion/api.mjs +507 -0
  174. package/dist/notion/api.mjs.map +1 -0
  175. package/dist/notion/state.d.mts +329 -0
  176. package/dist/notion/state.d.mts.map +1 -0
  177. package/dist/notion/state.mjs +432 -0
  178. package/dist/notion/state.mjs.map +1 -0
  179. package/dist/notion.d.mts +72 -0
  180. package/dist/notion.d.mts.map +1 -0
  181. package/dist/notion.mjs +127 -0
  182. package/dist/notion.mjs.map +1 -0
  183. package/dist/openai.d.mts +165 -0
  184. package/dist/openai.d.mts.map +1 -0
  185. package/dist/openai.mjs +141 -0
  186. package/dist/openai.mjs.map +1 -0
  187. package/dist/opencode-recordings.d.mts +7 -0
  188. package/dist/opencode-recordings.d.mts.map +1 -0
  189. package/dist/opencode-recordings.mjs +222 -0
  190. package/dist/opencode-recordings.mjs.map +1 -0
  191. package/dist/opencode.d.mts +70 -0
  192. package/dist/opencode.d.mts.map +1 -0
  193. package/dist/opencode.mjs +217 -0
  194. package/dist/opencode.mjs.map +1 -0
  195. package/dist/r2-fixtures.d.mts +36 -0
  196. package/dist/r2-fixtures.d.mts.map +1 -0
  197. package/dist/r2-fixtures.mjs +245 -0
  198. package/dist/r2-fixtures.mjs.map +1 -0
  199. package/dist/r2-guard.d.mts +43 -0
  200. package/dist/r2-guard.d.mts.map +1 -0
  201. package/dist/r2-guard.mjs +215 -0
  202. package/dist/r2-guard.mjs.map +1 -0
  203. package/dist/r2.d.mts +166 -0
  204. package/dist/r2.d.mts.map +1 -0
  205. package/dist/r2.mjs +517 -0
  206. package/dist/r2.mjs.map +1 -0
  207. package/dist/responses.d.mts +231 -0
  208. package/dist/responses.d.mts.map +1 -0
  209. package/dist/responses.mjs +556 -0
  210. package/dist/responses.mjs.map +1 -0
  211. package/dist/route-evidence.d.mts +45 -0
  212. package/dist/route-evidence.d.mts.map +1 -0
  213. package/dist/route-evidence.mjs +56 -0
  214. package/dist/route-evidence.mjs.map +1 -0
  215. package/dist/router.d.mts +93 -0
  216. package/dist/router.d.mts.map +1 -0
  217. package/dist/router.mjs +259 -0
  218. package/dist/router.mjs.map +1 -0
  219. package/dist/stateful-core.d.mts +17 -0
  220. package/dist/stateful-core.d.mts.map +1 -0
  221. package/dist/stateful-core.mjs +41 -0
  222. package/dist/stateful-core.mjs.map +1 -0
  223. package/dist/stateful-emulator.d.mts +565 -0
  224. package/dist/stateful-emulator.d.mts.map +1 -0
  225. package/dist/stateful-emulator.mjs +1228 -0
  226. package/dist/stateful-emulator.mjs.map +1 -0
  227. package/dist/stateful-secrets.d.mts +84 -0
  228. package/dist/stateful-secrets.d.mts.map +1 -0
  229. package/dist/stateful-secrets.mjs +216 -0
  230. package/dist/stateful-secrets.mjs.map +1 -0
  231. package/dist/subscription-usage-recordings.d.mts +9 -0
  232. package/dist/subscription-usage-recordings.d.mts.map +1 -0
  233. package/dist/subscription-usage-recordings.mjs +53 -0
  234. package/dist/subscription-usage-recordings.mjs.map +1 -0
  235. package/dist/subscription-usage.d.mts +53 -0
  236. package/dist/subscription-usage.d.mts.map +1 -0
  237. package/dist/subscription-usage.mjs +21 -0
  238. package/dist/subscription-usage.mjs.map +1 -0
  239. package/dist/telegram/api.d.mts +34 -0
  240. package/dist/telegram/api.d.mts.map +1 -0
  241. package/dist/telegram/api.mjs +257 -0
  242. package/dist/telegram/api.mjs.map +1 -0
  243. package/dist/telegram/state.d.mts +128 -0
  244. package/dist/telegram/state.d.mts.map +1 -0
  245. package/dist/telegram/state.mjs +154 -0
  246. package/dist/telegram/state.mjs.map +1 -0
  247. package/dist/telegram.d.mts +62 -0
  248. package/dist/telegram.d.mts.map +1 -0
  249. package/dist/telegram.mjs +127 -0
  250. package/dist/telegram.mjs.map +1 -0
  251. package/dist/todoist/api.d.mts +55 -0
  252. package/dist/todoist/api.d.mts.map +1 -0
  253. package/dist/todoist/api.mjs +415 -0
  254. package/dist/todoist/api.mjs.map +1 -0
  255. package/dist/todoist/state.d.mts +275 -0
  256. package/dist/todoist/state.d.mts.map +1 -0
  257. package/dist/todoist/state.mjs +345 -0
  258. package/dist/todoist/state.mjs.map +1 -0
  259. package/dist/todoist.d.mts +68 -0
  260. package/dist/todoist.d.mts.map +1 -0
  261. package/dist/todoist.mjs +181 -0
  262. package/dist/todoist.mjs.map +1 -0
  263. package/dist/xai.d.mts +267 -0
  264. package/dist/xai.d.mts.map +1 -0
  265. package/dist/xai.mjs +252 -0
  266. package/dist/xai.mjs.map +1 -0
  267. package/package.json +157 -0
  268. package/src/anthropic.ts +289 -0
  269. package/src/chat-completions.ts +924 -0
  270. package/src/codex.ts +296 -0
  271. package/src/dropbox/api.ts +1084 -0
  272. package/src/dropbox/state.ts +364 -0
  273. package/src/dropbox.ts +203 -0
  274. package/src/email-fixtures.ts +1297 -0
  275. package/src/email.ts +1108 -0
  276. package/src/emulator-compose.ts +147 -0
  277. package/src/emulator-http.ts +184 -0
  278. package/src/emulator-kernel.ts +844 -0
  279. package/src/fixture-route.ts +561 -0
  280. package/src/fortnox/api.ts +1352 -0
  281. package/src/fortnox/state.ts +798 -0
  282. package/src/fortnox.ts +801 -0
  283. package/src/gateway-evaluate-recordings.ts +153 -0
  284. package/src/gateway.ts +530 -0
  285. package/src/github/api.ts +986 -0
  286. package/src/github/state.ts +439 -0
  287. package/src/github.ts +271 -0
  288. package/src/google/calendar.ts +486 -0
  289. package/src/google/drive.ts +471 -0
  290. package/src/google/gmail.ts +1011 -0
  291. package/src/google/shared.ts +321 -0
  292. package/src/google/state.ts +686 -0
  293. package/src/google.ts +298 -0
  294. package/src/linkedin-search/api.ts +363 -0
  295. package/src/linkedin-search/state.ts +373 -0
  296. package/src/linkedin-search.ts +241 -0
  297. package/src/mcp/api.ts +995 -0
  298. package/src/mcp/recordings.ts +2665 -0
  299. package/src/mcp/state.ts +125 -0
  300. package/src/mcp.ts +319 -0
  301. package/src/messages.ts +844 -0
  302. package/src/microsoft/api.ts +426 -0
  303. package/src/microsoft/calendar.ts +491 -0
  304. package/src/microsoft/drive.ts +541 -0
  305. package/src/microsoft/graph.ts +550 -0
  306. package/src/microsoft/mail.ts +833 -0
  307. package/src/microsoft/state.ts +822 -0
  308. package/src/microsoft.ts +982 -0
  309. package/src/node.ts +293 -0
  310. package/src/notion/api.ts +976 -0
  311. package/src/notion/state.ts +512 -0
  312. package/src/notion.ts +210 -0
  313. package/src/openai.ts +198 -0
  314. package/src/opencode-recordings.ts +257 -0
  315. package/src/opencode.ts +271 -0
  316. package/src/r2-fixtures.ts +295 -0
  317. package/src/r2-guard.ts +323 -0
  318. package/src/r2.ts +890 -0
  319. package/src/responses.ts +901 -0
  320. package/src/route-evidence.ts +90 -0
  321. package/src/router.ts +490 -0
  322. package/src/stateful-core.ts +70 -0
  323. package/src/stateful-emulator.ts +2571 -0
  324. package/src/stateful-secrets.ts +299 -0
  325. package/src/subscription-usage-recordings.ts +77 -0
  326. package/src/subscription-usage.ts +68 -0
  327. package/src/telegram/api.ts +437 -0
  328. package/src/telegram/state.ts +229 -0
  329. package/src/telegram.ts +227 -0
  330. package/src/todoist/api.ts +736 -0
  331. package/src/todoist/state.ts +456 -0
  332. package/src/todoist.ts +316 -0
  333. package/src/xai.ts +341 -0
@@ -0,0 +1,222 @@
1
+ //#region src/opencode-recordings.ts
2
+ const openCodeGoRecordings = [
3
+ {
4
+ fixtureId: "opencode.go.chat.stream.plain-text.synthetic",
5
+ caseId: "opencode.go.chat.stream.plain-text",
6
+ request: {
7
+ method: "POST",
8
+ path: "/zen/go/v1/chat/completions",
9
+ query: "",
10
+ headers: {
11
+ accept: "text/event-stream",
12
+ "content-type": "application/json"
13
+ },
14
+ body: {
15
+ model: "synthetic-go-chat",
16
+ messages: [{
17
+ role: "system",
18
+ content: "Reply in one short sentence."
19
+ }, {
20
+ role: "user",
21
+ content: "Say hello."
22
+ }],
23
+ max_tokens: 64,
24
+ stream: true,
25
+ stream_options: { include_usage: true }
26
+ }
27
+ },
28
+ response: {
29
+ status: 200,
30
+ headers: { "content-type": "text/event-stream" },
31
+ streamed: true,
32
+ chunks: [
33
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\n\n",
34
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\n\n",
35
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,",
36
+ "\"delta\":{\"content\":\" from the\"},\"finish_reason\":null}]}\n\n",
37
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" synthetic model.\"},\"finish_reason\":null}]}\n\n",
38
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\n",
39
+ "data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[],\"usage\":{\"prompt_tokens\":53,\"completion_tokens\":12,\"total_tokens\":65}}\n\n",
40
+ "data: [DONE]\n\n"
41
+ ]
42
+ }
43
+ },
44
+ {
45
+ fixtureId: "opencode.go.messages.stream.plain-text.synthetic",
46
+ caseId: "opencode.go.messages.stream.plain-text",
47
+ request: {
48
+ method: "POST",
49
+ path: "/zen/go/v1/messages",
50
+ query: "",
51
+ headers: {
52
+ accept: "text/event-stream",
53
+ "content-type": "application/json"
54
+ },
55
+ body: {
56
+ model: "synthetic-go-messages",
57
+ system: [{
58
+ type: "text",
59
+ text: "Reply in one short sentence."
60
+ }],
61
+ messages: [{
62
+ role: "user",
63
+ content: "Say hello."
64
+ }],
65
+ max_tokens: 64,
66
+ stream: true
67
+ }
68
+ },
69
+ response: {
70
+ status: 200,
71
+ headers: { "content-type": "text/event-stream" },
72
+ streamed: true,
73
+ chunks: [
74
+ "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_synthetic_1\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"synthetic-go-messages\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":1}}}\n\n",
75
+ "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n",
76
+ "event: ping\ndata: {\"type\":\"ping\"}\n\n",
77
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Hello\"}}\n\n",
78
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",",
79
+ "\"text\":\" from the\"}}\n\n",
80
+ "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" synthetic Anthropic emulator.\"}}\n\n",
81
+ "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n",
82
+ "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":11}}\n\n",
83
+ "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
84
+ ]
85
+ }
86
+ },
87
+ {
88
+ fixtureId: "opencode.go.responses.stream.plain-text.synthetic",
89
+ caseId: "opencode.go.responses.stream.plain-text",
90
+ request: {
91
+ method: "POST",
92
+ path: "/zen/go/v1/responses",
93
+ query: "",
94
+ headers: {
95
+ accept: "text/event-stream",
96
+ "content-type": "application/json"
97
+ },
98
+ body: {
99
+ model: "synthetic-go-responses",
100
+ instructions: "Reply in one short sentence.",
101
+ input: [{
102
+ role: "user",
103
+ content: "Say hello."
104
+ }],
105
+ store: false,
106
+ stream: true,
107
+ max_output_tokens: 64
108
+ }
109
+ },
110
+ response: {
111
+ status: 200,
112
+ headers: { "content-type": "text/event-stream" },
113
+ streamed: true,
114
+ chunks: [
115
+ "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\n\n",
116
+ "event: response.in_progress\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\n\n",
117
+ "event: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\n\n",
118
+ "event: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\n\n",
119
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"Hello\"}\n\n",
120
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,",
121
+ "\"delta\":\" from the\"}\n\n",
122
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\" synthetic model.\"}\n\n",
123
+ "event: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"Hello from the synthetic model.\"}\n\n",
124
+ "event: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":8,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}}\n\n",
125
+ "event: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":9,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}}\n\n",
126
+ "event: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":10,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":45,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":12,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":57}}}\n\n"
127
+ ]
128
+ }
129
+ },
130
+ {
131
+ fixtureId: "opencode.go.responses.stream.commentary-replay.synthetic",
132
+ caseId: "opencode.go.responses.stream.commentary-replay",
133
+ request: {
134
+ method: "POST",
135
+ path: "/zen/go/v1/responses",
136
+ query: "",
137
+ headers: {
138
+ accept: "text/event-stream",
139
+ "content-type": "application/json"
140
+ },
141
+ body: {
142
+ model: "synthetic-go-responses",
143
+ instructions: "Reply in one short sentence.",
144
+ input: [
145
+ {
146
+ role: "user",
147
+ content: "What is the weather in Springfield?"
148
+ },
149
+ {
150
+ role: "assistant",
151
+ content: "I will look up the weather first.",
152
+ phase: "commentary"
153
+ },
154
+ {
155
+ type: "function_call",
156
+ call_id: "call_synthetic_weather",
157
+ name: "lookup_weather",
158
+ arguments: "{\"city\":\"Springfield\"}"
159
+ },
160
+ {
161
+ type: "function_call_output",
162
+ call_id: "call_synthetic_weather",
163
+ output: "Sunny and mild."
164
+ }
165
+ ],
166
+ store: false,
167
+ stream: true,
168
+ max_output_tokens: 64,
169
+ tools: [{
170
+ type: "function",
171
+ name: "lookup_weather",
172
+ description: "Look up the current weather for a city.",
173
+ parameters: {
174
+ type: "object",
175
+ properties: { city: { type: "string" } },
176
+ required: ["city"],
177
+ additionalProperties: false
178
+ }
179
+ }],
180
+ parallel_tool_calls: true
181
+ }
182
+ },
183
+ response: {
184
+ status: 200,
185
+ headers: { "content-type": "text/event-stream" },
186
+ streamed: true,
187
+ chunks: [
188
+ "event: response.created\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\n\n",
189
+ "event: response.in_progress\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\n\n",
190
+ "event: response.output_item.added\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\n\n",
191
+ "event: response.content_part.added\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\n\n",
192
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"It is sunny\"}\n\n",
193
+ "event: response.output_text.delta\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,",
194
+ "\"delta\":\" and mild in Springfield.\"}\n\n",
195
+ "event: response.output_text.done\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"It is sunny and mild in Springfield.\"}\n\n",
196
+ "event: response.content_part.done\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}}\n\n",
197
+ "event: response.output_item.done\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":8,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}}\n\n",
198
+ "event: response.completed\ndata: {\"type\":\"response.completed\",\"sequence_number\":9,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":193,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":9,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":202}}}\n\n"
199
+ ]
200
+ }
201
+ },
202
+ {
203
+ fixtureId: "opencode.go.usage.snapshot.synthetic",
204
+ caseId: "opencode.go.usage.snapshot",
205
+ request: {
206
+ method: "GET",
207
+ path: "/zen/go/v1/usage",
208
+ query: "",
209
+ headers: { accept: "application/json" }
210
+ },
211
+ response: {
212
+ status: 200,
213
+ headers: { "content-type": "application/json" },
214
+ streamed: false,
215
+ chunks: ["{\"usage\":{\"rolling\":{\"percent\":12.5,\"resetsAt\":\"2026-10-01T03:00:00.000Z\"},\"weekly\":{\"percent\":40,\"resetsAt\":\"2026-10-05T00:00:00.000Z\"},\"monthly\":{\"percent\":55,\"resetsAt\":\"2026-10-31T00:00:00.000Z\"}}}"]
216
+ }
217
+ }
218
+ ];
219
+ //#endregion
220
+ export { openCodeGoRecordings };
221
+
222
+ //# sourceMappingURL=opencode-recordings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-recordings.mjs","names":[],"sources":["../src/opencode-recordings.ts"],"sourcesContent":["/**\n * OpenCode Go recordings the `/opencode` emulator answers from: one per Go conformance fixture.\n *\n * Copied as data from the committed (synthetic, unverified) conformance fixtures; never imported.\n * `test/fixture-recordings.test.ts` fails when a fixture changes and this copy does not. Internal;\n * not a package export.\n */\nimport type { FixtureRecording } from './fixture-route.ts'\n\nexport const openCodeGoRecordings: ReadonlyArray<FixtureRecording> = [\n {\n fixtureId: 'opencode.go.chat.stream.plain-text.synthetic',\n caseId: 'opencode.go.chat.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/chat/completions',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-chat',\n messages: [\n {\n role: 'system',\n content: 'Reply in one short sentence.'\n },\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n max_tokens: 64,\n stream: true,\n stream_options: {\n include_usage: true\n }\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,',\n '\"delta\":{\"content\":\" from the\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" synthetic model.\"},\"finish_reason\":null}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\\n\\n',\n 'data: {\"id\":\"chatcmpl-synthetic-go-1\",\"object\":\"chat.completion.chunk\",\"created\":1790000000,\"model\":\"synthetic-go-chat\",\"choices\":[],\"usage\":{\"prompt_tokens\":53,\"completion_tokens\":12,\"total_tokens\":65}}\\n\\n',\n 'data: [DONE]\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.messages.stream.plain-text.synthetic',\n caseId: 'opencode.go.messages.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/messages',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-messages',\n system: [\n {\n type: 'text',\n text: 'Reply in one short sentence.'\n }\n ],\n messages: [\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n max_tokens: 64,\n stream: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: message_start\\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"msg_synthetic_1\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"synthetic-go-messages\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":1}}}\\n\\n',\n 'event: content_block_start\\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\\n\\n',\n 'event: ping\\ndata: {\"type\":\"ping\"}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"Hello\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",',\n '\"text\":\" from the\"}}\\n\\n',\n 'event: content_block_delta\\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\" synthetic Anthropic emulator.\"}}\\n\\n',\n 'event: content_block_stop\\ndata: {\"type\":\"content_block_stop\",\"index\":0}\\n\\n',\n 'event: message_delta\\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":45,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":11}}\\n\\n',\n 'event: message_stop\\ndata: {\"type\":\"message_stop\"}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.plain-text.synthetic',\n caseId: 'opencode.go.responses.stream.plain-text',\n request: {\n method: 'POST',\n path: '/zen/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'Say hello.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"Hello\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" from the\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\" synthetic model.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"Hello from the synthetic model.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":8,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":9,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":10,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"Hello from the synthetic model.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":45,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":12,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":57}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.responses.stream.commentary-replay.synthetic',\n caseId: 'opencode.go.responses.stream.commentary-replay',\n request: {\n method: 'POST',\n path: '/zen/go/v1/responses',\n query: '',\n headers: {\n accept: 'text/event-stream',\n 'content-type': 'application/json'\n },\n body: {\n model: 'synthetic-go-responses',\n instructions: 'Reply in one short sentence.',\n input: [\n {\n role: 'user',\n content: 'What is the weather in Springfield?'\n },\n {\n role: 'assistant',\n content: 'I will look up the weather first.',\n phase: 'commentary'\n },\n {\n type: 'function_call',\n call_id: 'call_synthetic_weather',\n name: 'lookup_weather',\n arguments: '{\"city\":\"Springfield\"}'\n },\n {\n type: 'function_call_output',\n call_id: 'call_synthetic_weather',\n output: 'Sunny and mild.'\n }\n ],\n store: false,\n stream: true,\n max_output_tokens: 64,\n tools: [\n {\n type: 'function',\n name: 'lookup_weather',\n description: 'Look up the current weather for a city.',\n parameters: {\n type: 'object',\n properties: {\n city: {\n type: 'string'\n }\n },\n required: ['city'],\n additionalProperties: false\n }\n }\n ],\n parallel_tool_calls: true\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'text/event-stream'\n },\n streamed: true,\n chunks: [\n 'event: response.created\\ndata: {\"type\":\"response.created\",\"sequence_number\":0,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.in_progress\\ndata: {\"type\":\"response.in_progress\",\"sequence_number\":1,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"in_progress\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[],\"usage\":null}}\\n\\n',\n 'event: response.output_item.added\\ndata: {\"type\":\"response.output_item.added\",\"sequence_number\":2,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"in_progress\",\"role\":\"assistant\",\"content\":[]}}\\n\\n',\n 'event: response.content_part.added\\ndata: {\"type\":\"response.content_part.added\",\"sequence_number\":3,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":4,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"delta\":\"It is sunny\"}\\n\\n',\n 'event: response.output_text.delta\\ndata: {\"type\":\"response.output_text.delta\",\"sequence_number\":5,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,',\n '\"delta\":\" and mild in Springfield.\"}\\n\\n',\n 'event: response.output_text.done\\ndata: {\"type\":\"response.output_text.done\",\"sequence_number\":6,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"text\":\"It is sunny and mild in Springfield.\"}\\n\\n',\n 'event: response.content_part.done\\ndata: {\"type\":\"response.content_part.done\",\"sequence_number\":7,\"item_id\":\"msg_synthetic_1_0\",\"output_index\":0,\"content_index\":0,\"part\":{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}}\\n\\n',\n 'event: response.output_item.done\\ndata: {\"type\":\"response.output_item.done\",\"sequence_number\":8,\"output_index\":0,\"item\":{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}}\\n\\n',\n 'event: response.completed\\ndata: {\"type\":\"response.completed\",\"sequence_number\":9,\"response\":{\"id\":\"resp_synthetic_1\",\"object\":\"response\",\"created_at\":1790000000,\"status\":\"completed\",\"error\":null,\"incomplete_details\":null,\"model\":\"synthetic-go-responses\",\"output\":[{\"id\":\"msg_synthetic_1_0\",\"type\":\"message\",\"status\":\"completed\",\"role\":\"assistant\",\"content\":[{\"type\":\"output_text\",\"text\":\"It is sunny and mild in Springfield.\",\"annotations\":[]}]}],\"usage\":{\"input_tokens\":193,\"input_tokens_details\":{\"cached_tokens\":0},\"output_tokens\":9,\"output_tokens_details\":{\"reasoning_tokens\":0},\"total_tokens\":202}}}\\n\\n'\n ]\n }\n },\n {\n fixtureId: 'opencode.go.usage.snapshot.synthetic',\n caseId: 'opencode.go.usage.snapshot',\n request: {\n method: 'GET',\n path: '/zen/go/v1/usage',\n query: '',\n headers: {\n accept: 'application/json'\n }\n },\n response: {\n status: 200,\n headers: {\n 'content-type': 'application/json'\n },\n streamed: false,\n chunks: [\n '{\"usage\":{\"rolling\":{\"percent\":12.5,\"resetsAt\":\"2026-10-01T03:00:00.000Z\"},\"weekly\":{\"percent\":40,\"resetsAt\":\"2026-10-05T00:00:00.000Z\"},\"monthly\":{\"percent\":55,\"resetsAt\":\"2026-10-31T00:00:00.000Z\"}}}'\n ]\n }\n }\n]\n"],"mappings":";AASA,MAAa,uBAAwD;CACnE;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,UAAU,CACR;KACE,MAAM;KACN,SAAS;IACX,GACA;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,YAAY;IACZ,QAAQ;IACR,gBAAgB,EACd,eAAe,KACjB;GACF;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,QAAQ,CACN;KACE,MAAM;KACN,MAAM;IACR,CACF;IACA,UAAU,CACR;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,YAAY;IACZ,QAAQ;GACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO,CACL;KACE,MAAM;KACN,SAAS;IACX,CACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;GACrB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS;IACP,QAAQ;IACR,gBAAgB;GAClB;GACA,MAAM;IACJ,OAAO;IACP,cAAc;IACd,OAAO;KACL;MACE,MAAM;MACN,SAAS;KACX;KACA;MACE,MAAM;MACN,SAAS;MACT,OAAO;KACT;KACA;MACE,MAAM;MACN,SAAS;MACT,MAAM;MACN,WAAW;KACb;KACA;MACE,MAAM;MACN,SAAS;MACT,QAAQ;KACV;IACF;IACA,OAAO;IACP,QAAQ;IACR,mBAAmB;IACnB,OAAO,CACL;KACE,MAAM;KACN,MAAM;KACN,aAAa;KACb,YAAY;MACV,MAAM;MACN,YAAY,EACV,MAAM,EACJ,MAAM,SACR,EACF;MACA,UAAU,CAAC,MAAM;MACjB,sBAAsB;KACxB;IACF,CACF;IACA,qBAAqB;GACvB;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,oBAClB;GACA,UAAU;GACV,QAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF;CACF;CACA;EACE,WAAW;EACX,QAAQ;EACR,SAAS;GACP,QAAQ;GACR,MAAM;GACN,OAAO;GACP,SAAS,EACP,QAAQ,mBACV;EACF;EACA,UAAU;GACR,QAAQ;GACR,SAAS,EACP,gBAAgB,mBAClB;GACA,UAAU;GACV,QAAQ,CACN,qOACF;EACF;CACF;AACF"}
@@ -0,0 +1,70 @@
1
+ import { EmulatorEvidence, EmulatorRouteEvidence, emulatorEvidenceHeader } from "./route-evidence.mjs";
2
+ import { EmulatorCoverage } from "./emulator-kernel.mjs";
3
+ import { FixtureRouteEmulator, FixtureRouteFault, FixtureRouteLedgerEntry, FixtureRouteScriptedTurn } from "./fixture-route.mjs";
4
+ import * as Schema from "effect/Schema";
5
+
6
+ //#region src/opencode.d.ts
7
+ declare const openCodeGoChatCompletionsPath = "/zen/go/v1/chat/completions";
8
+ declare const openCodeGoMessagesPath = "/zen/go/v1/messages";
9
+ declare const openCodeGoResponsesPath = "/zen/go/v1/responses";
10
+ /** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */
11
+ declare const openCodeGoUsagePath = "/zen/go/v1/usage";
12
+ /**
13
+ * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol
14
+ * route answers only its recorded model; any other model is not emulated.
15
+ */
16
+ declare const openCodeGoEmulatorDefaultModels: ReadonlyArray<string>;
17
+ /**
18
+ * Route evidence manifest: every emulated OpenCode Go route and the conformance cases whose
19
+ * (synthetic, unverified) fixtures it answers from.
20
+ */
21
+ declare const openCodeGoEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence>;
22
+ /**
23
+ * The recorded Go usage body (the synthetic `opencode.go.usage.snapshot` fixture, copied as
24
+ * data): `usage.rolling`, `usage.weekly`, and `usage.monthly` as `{ percent, resetsAt }`.
25
+ */
26
+ declare const openCodeGoUsageDefault: Schema.Json;
27
+ declare const OpenCodeGoEmulatorInputInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
28
+ readonly _tag: "OpenCodeGoEmulatorInputInvalid";
29
+ } & Readonly<A>;
30
+ /** Thrown by the JS API (`faults.add`, `script.enqueue`) and at construction for invalid input. */
31
+ declare class OpenCodeGoEmulatorInputInvalid extends OpenCodeGoEmulatorInputInvalid_base<{
32
+ readonly protocol: 'chat-completions' | 'messages' | 'responses' | 'usage';
33
+ readonly input: 'fault' | 'turn';
34
+ readonly reason: string;
35
+ }> {
36
+ get message(): string;
37
+ }
38
+ type OpenCodeGoEmulatorOptions = {
39
+ /**
40
+ * Replacement usage-route body; must have the recorded JSON shape (same keys and value kinds).
41
+ * Defaults to the recorded body (`openCodeGoUsageDefault`).
42
+ */
43
+ readonly subscriptionUsage?: Schema.Json;
44
+ };
45
+ /** One Go route: a fixture-only emulator API (ledger, faults, scripted turns, coverage). */
46
+ type OpenCodeGoRouteEmulator = FixtureRouteEmulator;
47
+ type OpenCodeGoEmulator = {
48
+ /** The fetch handler for every route and the `/_emulate/*` control plane. Never rejects. */readonly fetch: (request: Request) => Promise<Response>; /** Reset every part (ledgers, faults, and scripted turns). */
49
+ readonly reset: () => void; /** Every route's coverage, in manifest order. */
50
+ readonly coverage: () => EmulatorCoverage; /** `POST /zen/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */
51
+ readonly chat: OpenCodeGoRouteEmulator; /** `POST /zen/go/v1/messages` (control plane `/_emulate/messages/*`). */
52
+ readonly messages: OpenCodeGoRouteEmulator; /** `POST /zen/go/v1/responses` (control plane `/_emulate/responses/*`). */
53
+ readonly responses: OpenCodeGoRouteEmulator; /** `GET /zen/go/v1/usage` (control plane `/_emulate/usage/*`). */
54
+ readonly usage: OpenCodeGoRouteEmulator;
55
+ };
56
+ /**
57
+ * Create an OpenCode Go emulator. Each call has independent state for every part. Throws
58
+ * `OpenCodeGoEmulatorInputInvalid` when `subscriptionUsage` does not have the recorded shape.
59
+ *
60
+ * Per route, a request carrying the credential and headers the Go provider or usage fetcher sends
61
+ * (Bearer for chat, Responses, and usage; `x-api-key` and `anthropic-version: 2023-06-01` for
62
+ * Messages), the recorded `accept` and `content-type`, and a body matching a recorded request
63
+ * shape gets the recorded response; anything else answers 400 not-emulated. Test controls per
64
+ * part: the shared kernel faults and scripted error turns (and, on usage, a scripted same-shaped
65
+ * `{ usage }` body).
66
+ */
67
+ declare const makeOpenCodeGoEmulator: (options?: OpenCodeGoEmulatorOptions) => OpenCodeGoEmulator;
68
+ //#endregion
69
+ export { type EmulatorEvidence, type EmulatorRouteEvidence, OpenCodeGoEmulator, OpenCodeGoEmulatorInputInvalid, OpenCodeGoEmulatorOptions, type FixtureRouteFault as OpenCodeGoFault, type FixtureRouteLedgerEntry as OpenCodeGoLedgerEntry, OpenCodeGoRouteEmulator, type FixtureRouteScriptedTurn as OpenCodeGoScriptedTurn, emulatorEvidenceHeader, makeOpenCodeGoEmulator, openCodeGoChatCompletionsPath, openCodeGoEmulatorDefaultModels, openCodeGoEmulatorRoutes, openCodeGoMessagesPath, openCodeGoResponsesPath, openCodeGoUsageDefault, openCodeGoUsagePath };
70
+ //# sourceMappingURL=opencode.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.d.mts","names":[],"sources":["../src/opencode.ts"],"mappings":";;;;;;cAmDa,6BAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,uBAAA;AAJ6B;AAAA,cAO7B,mBAAA;;;;AALsB;cAuBtB,+BAAA,EAAiC,aAAa;;;;AArBvB;cAmCvB,wBAAA,EAA0B,aAAa,CAAC,qBAAA;;;;AAhCrB;cA8EnB,sBAAA,EAAwB,MAAA,CAAO,IAAwC;AAAA,cAAA,mCAAA;;;AA5DzB;AAAA,cA+D9C,8BAAA,SAAuC,mCAAA;EAAA,SAGzC,QAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;EAAA,IAEI,OAAA,CAAA;AAAA;AAAA,KAKH,yBAAA;EAfyB;AAA+C;AAAA;;EAA/C,SAoB1B,iBAAA,GAAoB,MAAA,CAAO,IAAI;AAAA;;KAI9B,uBAAA,GAA0B,oBAAoB;AAAA,KAE9C,kBAAA;uGAED,KAAA,GAAQ,OAAA,EAAS,OAAA,KAAY,OAAA,CAAQ,QAAA;WAErC,KAAA;WAEA,QAAA,QAAgB,gBAAA;WAEhB,IAAA,EAAM,uBAAA;WAEN,QAAA,EAAU,uBAAA;WAEV,SAAA,EAAW,uBAAA;WAEX,KAAA,EAAO,uBAAA;AAAA;;;;;;;;AArClB;;;;cAsDa,sBAAA,GACX,OAAA,GAAS,yBAAA,KACR,kBA2EF"}
@@ -0,0 +1,217 @@
1
+ import { emulatorEvidenceHeader } from "./route-evidence.mjs";
2
+ import { jsonResponse, stringField } from "./emulator-kernel.mjs";
3
+ import { combinedCoverage, composeFetch } from "./emulator-compose.mjs";
4
+ import { makeFixtureRouteEmulator } from "./fixture-route.mjs";
5
+ import { makeSubscriptionUsageEmulator, recordedUsageBody } from "./subscription-usage.mjs";
6
+ import { openCodeGoRecordings } from "./opencode-recordings.mjs";
7
+ import { Data } from "effect";
8
+ //#region src/opencode.ts
9
+ /**
10
+ * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the
11
+ * routes the OpenCode Go provider and usage fetcher call under `/zen/go/v1`:
12
+ *
13
+ * - `POST /zen/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);
14
+ * - `POST /zen/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);
15
+ * - `POST /zen/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed
16
+ * tool turn with commentary-tagged text);
17
+ * - `GET /zen/go/v1/usage` (Bearer).
18
+ *
19
+ * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded
20
+ * request shape, within the documented request-shape latitude, gets that Go conformance fixture's
21
+ * recorded response, copied as data (`opencode-recordings.ts`); everything else (unknown routes,
22
+ * missing credentials or headers, other models, non-streamed modes, tools other than the recorded
23
+ * replay, reasoning, extra fields) answers one ledgered 400 not-emulated.
24
+ *
25
+ * Each route keeps its own ledger, faults, scripted turns, and control plane (`emulator.chat`,
26
+ * `emulator.messages`, `emulator.responses`, `emulator.usage`; over HTTP `/_emulate/<part>/*`);
27
+ * `emulator.coverage()` and `GET /_emulate/coverage` combine them, and `emulator.reset()` and
28
+ * `POST /_emulate/reset` reset all four. Requests on no route are ledgered by the chat part.
29
+ *
30
+ * It never imports SDK code. All routes are `unverified` (the fixtures are synthetic).
31
+ *
32
+ * Runtime-portable Web APIs only (`Request`, `Response`, `ReadableStream`, `TextEncoder`, `URL`);
33
+ * no Effect runtime is required to use it.
34
+ *
35
+ * @experimental
36
+ */
37
+ const openCodeGoChatCompletionsPath = "/zen/go/v1/chat/completions";
38
+ const openCodeGoMessagesPath = "/zen/go/v1/messages";
39
+ const openCodeGoResponsesPath = "/zen/go/v1/responses";
40
+ /** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */
41
+ const openCodeGoUsagePath = "/zen/go/v1/usage";
42
+ const recordingsFor = (path) => openCodeGoRecordings.filter((recording) => recording.request.path === path);
43
+ const usageRecording = (() => {
44
+ const [recording] = recordingsFor(openCodeGoUsagePath);
45
+ if (recording === void 0) throw new Error("the Go usage recording is missing");
46
+ return recording;
47
+ })();
48
+ /**
49
+ * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol
50
+ * route answers only its recorded model; any other model is not emulated.
51
+ */
52
+ const openCodeGoEmulatorDefaultModels = [...new Set(openCodeGoRecordings.flatMap((recording) => {
53
+ const model = stringField(recording.request.body, "model");
54
+ return model === void 0 ? [] : [model];
55
+ }))];
56
+ /**
57
+ * Route evidence manifest: every emulated OpenCode Go route and the conformance cases whose
58
+ * (synthetic, unverified) fixtures it answers from.
59
+ */
60
+ const openCodeGoEmulatorRoutes = [
61
+ {
62
+ method: "POST",
63
+ path: openCodeGoChatCompletionsPath,
64
+ kind: "provider",
65
+ write: false,
66
+ caseIds: ["opencode.go.chat.stream.plain-text"],
67
+ evidence: "unverified",
68
+ observedAt: void 0
69
+ },
70
+ {
71
+ method: "POST",
72
+ path: openCodeGoMessagesPath,
73
+ kind: "provider",
74
+ write: false,
75
+ caseIds: ["opencode.go.messages.stream.plain-text"],
76
+ evidence: "unverified",
77
+ observedAt: void 0
78
+ },
79
+ {
80
+ method: "POST",
81
+ path: openCodeGoResponsesPath,
82
+ kind: "provider",
83
+ write: false,
84
+ caseIds: ["opencode.go.responses.stream.plain-text", "opencode.go.responses.stream.commentary-replay"],
85
+ evidence: "unverified",
86
+ observedAt: void 0
87
+ },
88
+ {
89
+ method: "GET",
90
+ path: openCodeGoUsagePath,
91
+ kind: "provider",
92
+ write: false,
93
+ caseIds: ["opencode.go.usage.snapshot"],
94
+ evidence: "unverified",
95
+ observedAt: void 0
96
+ }
97
+ ];
98
+ /**
99
+ * The recorded Go usage body (the synthetic `opencode.go.usage.snapshot` fixture, copied as
100
+ * data): `usage.rolling`, `usage.weekly`, and `usage.monthly` as `{ percent, resetsAt }`.
101
+ */
102
+ const openCodeGoUsageDefault = recordedUsageBody(usageRecording);
103
+ /** Thrown by the JS API (`faults.add`, `script.enqueue`) and at construction for invalid input. */
104
+ var OpenCodeGoEmulatorInputInvalid = class extends Data.TaggedError("OpenCodeGoEmulatorInputInvalid") {
105
+ get message() {
106
+ return `Invalid OpenCode Go ${this.protocol} emulator ${this.input}: ${this.reason}`;
107
+ }
108
+ };
109
+ const routesFor = (path) => openCodeGoEmulatorRoutes.filter((route) => route.path === path);
110
+ /**
111
+ * Create an OpenCode Go emulator. Each call has independent state for every part. Throws
112
+ * `OpenCodeGoEmulatorInputInvalid` when `subscriptionUsage` does not have the recorded shape.
113
+ *
114
+ * Per route, a request carrying the credential and headers the Go provider or usage fetcher sends
115
+ * (Bearer for chat, Responses, and usage; `x-api-key` and `anthropic-version: 2023-06-01` for
116
+ * Messages), the recorded `accept` and `content-type`, and a body matching a recorded request
117
+ * shape gets the recorded response; anything else answers 400 not-emulated. Test controls per
118
+ * part: the shared kernel faults and scripted error turns (and, on usage, a scripted same-shaped
119
+ * `{ usage }` body).
120
+ */
121
+ const makeOpenCodeGoEmulator = (options = {}) => {
122
+ const inputInvalid = (protocol) => (input, reason) => new OpenCodeGoEmulatorInputInvalid({
123
+ protocol,
124
+ input,
125
+ reason
126
+ });
127
+ const chat = makeFixtureRouteEmulator({
128
+ method: "POST",
129
+ path: openCodeGoChatCompletionsPath,
130
+ routes: routesFor(openCodeGoChatCompletionsPath),
131
+ recordings: recordingsFor(openCodeGoChatCompletionsPath),
132
+ credential: "bearer",
133
+ headers: [],
134
+ inputInvalid: inputInvalid("chat-completions")
135
+ });
136
+ const messages = makeFixtureRouteEmulator({
137
+ method: "POST",
138
+ path: openCodeGoMessagesPath,
139
+ routes: routesFor(openCodeGoMessagesPath),
140
+ recordings: recordingsFor(openCodeGoMessagesPath),
141
+ credential: "x-api-key",
142
+ headers: [{
143
+ name: "anthropic-version",
144
+ record: true,
145
+ accepts: (value) => value === "2023-06-01"
146
+ }],
147
+ inputInvalid: inputInvalid("messages")
148
+ });
149
+ const responses = makeFixtureRouteEmulator({
150
+ method: "POST",
151
+ path: openCodeGoResponsesPath,
152
+ routes: routesFor(openCodeGoResponsesPath),
153
+ recordings: recordingsFor(openCodeGoResponsesPath),
154
+ credential: "bearer",
155
+ headers: [],
156
+ inputInvalid: inputInvalid("responses")
157
+ });
158
+ const usage = makeSubscriptionUsageEmulator({
159
+ path: openCodeGoUsagePath,
160
+ routes: routesFor(openCodeGoUsagePath),
161
+ recording: usageRecording,
162
+ headers: [],
163
+ subscriptionUsage: options.subscriptionUsage,
164
+ inputInvalid: inputInvalid("usage")
165
+ });
166
+ const parts = [
167
+ chat,
168
+ messages,
169
+ responses,
170
+ usage
171
+ ];
172
+ const coverage = () => combinedCoverage(parts);
173
+ const reset = () => {
174
+ for (const part of parts) part.reset();
175
+ };
176
+ return {
177
+ fetch: composeFetch({
178
+ routes: [
179
+ {
180
+ name: "chat",
181
+ paths: [openCodeGoChatCompletionsPath],
182
+ part: chat
183
+ },
184
+ {
185
+ name: "messages",
186
+ paths: [openCodeGoMessagesPath],
187
+ part: messages
188
+ },
189
+ {
190
+ name: "responses",
191
+ paths: [openCodeGoResponsesPath],
192
+ part: responses
193
+ },
194
+ {
195
+ name: "usage",
196
+ paths: [openCodeGoUsagePath],
197
+ part: usage
198
+ }
199
+ ],
200
+ fallback: chat,
201
+ control: async (request, path) => path === "/_emulate/coverage" && request.method === "GET" ? jsonResponse(200, coverage()) : jsonResponse(404, { error: {
202
+ message: "unknown control-plane route: use /_emulate/{chat,messages,responses,usage}/*, GET /_emulate/coverage, or POST /_emulate/reset",
203
+ type: "emulator_error"
204
+ } })
205
+ }),
206
+ reset,
207
+ coverage,
208
+ chat,
209
+ messages,
210
+ responses,
211
+ usage
212
+ };
213
+ };
214
+ //#endregion
215
+ export { OpenCodeGoEmulatorInputInvalid, emulatorEvidenceHeader, makeOpenCodeGoEmulator, openCodeGoChatCompletionsPath, openCodeGoEmulatorDefaultModels, openCodeGoEmulatorRoutes, openCodeGoMessagesPath, openCodeGoResponsesPath, openCodeGoUsageDefault, openCodeGoUsagePath };
216
+
217
+ //# sourceMappingURL=opencode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.mjs","names":[],"sources":["../src/opencode.ts"],"sourcesContent":["/**\n * OpenCode Go emulator: one plain fetch handler for the origin `https://opencode.ai`, serving the\n * routes the OpenCode Go provider and usage fetcher call under `/zen/go/v1`:\n *\n * - `POST /zen/go/v1/chat/completions` (Bearer, `max_tokens`, streamed with usage);\n * - `POST /zen/go/v1/messages` (`x-api-key`, `anthropic-version: 2023-06-01`, streamed);\n * - `POST /zen/go/v1/responses` (Bearer, `max_output_tokens`, streamed; plain text or a replayed\n * tool turn with commentary-tagged text);\n * - `GET /zen/go/v1/usage` (Bearer).\n *\n * Fixture-only (the owner rule for new routes; `fixture-route.ts`): a request matching a recorded\n * request shape, within the documented request-shape latitude, gets that Go conformance fixture's\n * recorded response, copied as data (`opencode-recordings.ts`); everything else (unknown routes,\n * missing credentials or headers, other models, non-streamed modes, tools other than the recorded\n * replay, reasoning, extra fields) answers one ledgered 400 not-emulated.\n *\n * Each route keeps its own ledger, faults, scripted turns, and control plane (`emulator.chat`,\n * `emulator.messages`, `emulator.responses`, `emulator.usage`; over HTTP `/_emulate/<part>/*`);\n * `emulator.coverage()` and `GET /_emulate/coverage` combine them, and `emulator.reset()` and\n * `POST /_emulate/reset` reset all four. Requests on no route are ledgered by the chat part.\n *\n * It never imports SDK code. All routes are `unverified` (the fixtures are synthetic).\n *\n * Runtime-portable Web APIs only (`Request`, `Response`, `ReadableStream`, `TextEncoder`, `URL`);\n * no Effect runtime is required to use it.\n *\n * @experimental\n */\nimport { Data } from 'effect'\nimport type * as Schema from 'effect/Schema'\nimport { combinedCoverage, composeFetch, type ComposedPart } from './emulator-compose.ts'\nimport { jsonResponse, stringField, type EmulatorCoverage } from './emulator-kernel.ts'\nimport {\n makeFixtureRouteEmulator,\n type FixtureRecording,\n type FixtureRouteEmulator\n} from './fixture-route.ts'\nimport { openCodeGoRecordings } from './opencode-recordings.ts'\nimport type { EmulatorRouteEvidence } from './route-evidence.ts'\nimport { makeSubscriptionUsageEmulator, recordedUsageBody } from './subscription-usage.ts'\n\nexport type { EmulatorEvidence, EmulatorRouteEvidence } from './route-evidence.ts'\n\nexport { emulatorEvidenceHeader } from './route-evidence.ts'\n\nexport type {\n FixtureRouteFault as OpenCodeGoFault,\n FixtureRouteLedgerEntry as OpenCodeGoLedgerEntry,\n FixtureRouteScriptedTurn as OpenCodeGoScriptedTurn\n} from './fixture-route.ts'\n\nexport const openCodeGoChatCompletionsPath = '/zen/go/v1/chat/completions'\n\nexport const openCodeGoMessagesPath = '/zen/go/v1/messages'\n\nexport const openCodeGoResponsesPath = '/zen/go/v1/responses'\n\n/** The Go subscription-usage path (`openCodeGoSubscriptionUsageUrl` in the SDK). */\nexport const openCodeGoUsagePath = '/zen/go/v1/usage'\n\nconst recordingsFor = (path: string): ReadonlyArray<FixtureRecording> =>\n openCodeGoRecordings.filter(recording => recording.request.path === path)\n\nconst usageRecording: FixtureRecording = (() => {\n const [recording] = recordingsFor(openCodeGoUsagePath)\n\n // Packaging-data invariant: the Go usage fixture is copied into this package.\n if (recording === undefined) throw new Error('the Go usage recording is missing')\n\n return recording\n})()\n\n/**\n * The model ids the Go fixtures record, one per protocol (synthetic placeholders). A protocol\n * route answers only its recorded model; any other model is not emulated.\n */\nexport const openCodeGoEmulatorDefaultModels: ReadonlyArray<string> = [\n ...new Set(\n openCodeGoRecordings.flatMap(recording => {\n const model = stringField(recording.request.body, 'model')\n\n return model === undefined ? [] : [model]\n })\n )\n]\n\n/**\n * Route evidence manifest: every emulated OpenCode Go route and the conformance cases whose\n * (synthetic, unverified) fixtures it answers from.\n */\nexport const openCodeGoEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> = [\n {\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.chat.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoMessagesPath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.messages.stream.plain-text'],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'POST',\n path: openCodeGoResponsesPath,\n kind: 'provider',\n write: false,\n caseIds: [\n 'opencode.go.responses.stream.plain-text',\n 'opencode.go.responses.stream.commentary-replay'\n ],\n evidence: 'unverified',\n observedAt: undefined\n },\n {\n method: 'GET',\n path: openCodeGoUsagePath,\n kind: 'provider',\n write: false,\n caseIds: ['opencode.go.usage.snapshot'],\n evidence: 'unverified',\n observedAt: undefined\n }\n]\n\n/**\n * The recorded Go usage body (the synthetic `opencode.go.usage.snapshot` fixture, copied as\n * data): `usage.rolling`, `usage.weekly`, and `usage.monthly` as `{ percent, resetsAt }`.\n */\nexport const openCodeGoUsageDefault: Schema.Json = recordedUsageBody(usageRecording)\n\n/** Thrown by the JS API (`faults.add`, `script.enqueue`) and at construction for invalid input. */\nexport class OpenCodeGoEmulatorInputInvalid extends Data.TaggedError(\n 'OpenCodeGoEmulatorInputInvalid'\n)<{\n readonly protocol: 'chat-completions' | 'messages' | 'responses' | 'usage'\n readonly input: 'fault' | 'turn'\n readonly reason: string\n}> {\n override get message(): string {\n return `Invalid OpenCode Go ${this.protocol} emulator ${this.input}: ${this.reason}`\n }\n}\n\nexport type OpenCodeGoEmulatorOptions = {\n /**\n * Replacement usage-route body; must have the recorded JSON shape (same keys and value kinds).\n * Defaults to the recorded body (`openCodeGoUsageDefault`).\n */\n readonly subscriptionUsage?: Schema.Json\n}\n\n/** One Go route: a fixture-only emulator API (ledger, faults, scripted turns, coverage). */\nexport type OpenCodeGoRouteEmulator = FixtureRouteEmulator\n\nexport type OpenCodeGoEmulator = {\n /** The fetch handler for every route and the `/_emulate/*` control plane. Never rejects. */\n readonly fetch: (request: Request) => Promise<Response>\n /** Reset every part (ledgers, faults, and scripted turns). */\n readonly reset: () => void\n /** Every route's coverage, in manifest order. */\n readonly coverage: () => EmulatorCoverage\n /** `POST /zen/go/v1/chat/completions` (control plane `/_emulate/chat/*`). */\n readonly chat: OpenCodeGoRouteEmulator\n /** `POST /zen/go/v1/messages` (control plane `/_emulate/messages/*`). */\n readonly messages: OpenCodeGoRouteEmulator\n /** `POST /zen/go/v1/responses` (control plane `/_emulate/responses/*`). */\n readonly responses: OpenCodeGoRouteEmulator\n /** `GET /zen/go/v1/usage` (control plane `/_emulate/usage/*`). */\n readonly usage: OpenCodeGoRouteEmulator\n}\n\nconst routesFor = (path: string): ReadonlyArray<EmulatorRouteEvidence> =>\n openCodeGoEmulatorRoutes.filter(route => route.path === path)\n\n/**\n * Create an OpenCode Go emulator. Each call has independent state for every part. Throws\n * `OpenCodeGoEmulatorInputInvalid` when `subscriptionUsage` does not have the recorded shape.\n *\n * Per route, a request carrying the credential and headers the Go provider or usage fetcher sends\n * (Bearer for chat, Responses, and usage; `x-api-key` and `anthropic-version: 2023-06-01` for\n * Messages), the recorded `accept` and `content-type`, and a body matching a recorded request\n * shape gets the recorded response; anything else answers 400 not-emulated. Test controls per\n * part: the shared kernel faults and scripted error turns (and, on usage, a scripted same-shaped\n * `{ usage }` body).\n */\nexport const makeOpenCodeGoEmulator = (\n options: OpenCodeGoEmulatorOptions = {}\n): OpenCodeGoEmulator => {\n const inputInvalid =\n (protocol: OpenCodeGoEmulatorInputInvalid['protocol']) =>\n (input: 'fault' | 'turn', reason: string) =>\n new OpenCodeGoEmulatorInputInvalid({ protocol, input, reason })\n\n const chat = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoChatCompletionsPath,\n routes: routesFor(openCodeGoChatCompletionsPath),\n recordings: recordingsFor(openCodeGoChatCompletionsPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('chat-completions')\n })\n\n const messages = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoMessagesPath,\n routes: routesFor(openCodeGoMessagesPath),\n recordings: recordingsFor(openCodeGoMessagesPath),\n credential: 'x-api-key',\n headers: [\n { name: 'anthropic-version', record: true, accepts: value => value === '2023-06-01' }\n ],\n inputInvalid: inputInvalid('messages')\n })\n\n const responses = makeFixtureRouteEmulator({\n method: 'POST',\n path: openCodeGoResponsesPath,\n routes: routesFor(openCodeGoResponsesPath),\n recordings: recordingsFor(openCodeGoResponsesPath),\n credential: 'bearer',\n headers: [],\n inputInvalid: inputInvalid('responses')\n })\n\n const usage = makeSubscriptionUsageEmulator({\n path: openCodeGoUsagePath,\n routes: routesFor(openCodeGoUsagePath),\n recording: usageRecording,\n headers: [],\n subscriptionUsage: options.subscriptionUsage,\n inputInvalid: inputInvalid('usage')\n })\n\n const parts: ReadonlyArray<ComposedPart> = [chat, messages, responses, usage]\n const coverage = () => combinedCoverage(parts)\n\n const reset = () => {\n for (const part of parts) part.reset()\n }\n\n const fetch = composeFetch({\n routes: [\n { name: 'chat', paths: [openCodeGoChatCompletionsPath], part: chat },\n { name: 'messages', paths: [openCodeGoMessagesPath], part: messages },\n { name: 'responses', paths: [openCodeGoResponsesPath], part: responses },\n { name: 'usage', paths: [openCodeGoUsagePath], part: usage }\n ],\n fallback: chat,\n control: async (request, path) =>\n path === '/_emulate/coverage' && request.method === 'GET'\n ? jsonResponse(200, coverage())\n : jsonResponse(404, {\n error: {\n message:\n 'unknown control-plane route: use /_emulate/{chat,messages,responses,usage}/*, GET /_emulate/coverage, or POST /_emulate/reset',\n type: 'emulator_error'\n }\n })\n })\n\n return { fetch, reset, coverage, chat, messages, responses, usage }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gCAAgC;AAE7C,MAAa,yBAAyB;AAEtC,MAAa,0BAA0B;;AAGvC,MAAa,sBAAsB;AAEnC,MAAM,iBAAiB,SACrB,qBAAqB,QAAO,cAAa,UAAU,QAAQ,SAAS,IAAI;AAE1E,MAAM,wBAA0C;CAC9C,MAAM,CAAC,aAAa,cAAc,mBAAmB;CAGrD,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,mCAAmC;CAEhF,OAAO;AACT,GAAG;;;;;AAMH,MAAa,kCAAyD,CACpE,GAAG,IAAI,IACL,qBAAqB,SAAQ,cAAa;CACxC,MAAM,QAAQ,YAAY,UAAU,QAAQ,MAAM,OAAO;CAEzD,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;AAC1C,CAAC,CACH,CACF;;;;;AAMA,MAAa,2BAAiE;CAC5E;EACE,QAAQ;EACR,MAAM;EACN,MAAM;EACN,OAAO;EACP,SAAS,CAAC,oCAAoC;EAC9C,UAAU;EACV,YAAY,KAAA;CACd;CACA;EACE,QAAQ;EACR,MAAM;EACN,MAAM;EACN,OAAO;EACP,SAAS,CAAC,wCAAwC;EAClD,UAAU;EACV,YAAY,KAAA;CACd;CACA;EACE,QAAQ;EACR,MAAM;EACN,MAAM;EACN,OAAO;EACP,SAAS,CACP,2CACA,gDACF;EACA,UAAU;EACV,YAAY,KAAA;CACd;CACA;EACE,QAAQ;EACR,MAAM;EACN,MAAM;EACN,OAAO;EACP,SAAS,CAAC,4BAA4B;EACtC,UAAU;EACV,YAAY,KAAA;CACd;AACF;;;;;AAMA,MAAa,yBAAsC,kBAAkB,cAAc;;AAGnF,IAAa,iCAAb,cAAoD,KAAK,YACvD,gCACF,EAIG;CACD,IAAa,UAAkB;EAC7B,OAAO,uBAAuB,KAAK,SAAS,YAAY,KAAK,MAAM,IAAI,KAAK;CAC9E;AACF;AA8BA,MAAM,aAAa,SACjB,yBAAyB,QAAO,UAAS,MAAM,SAAS,IAAI;;;;;;;;;;;;AAa9D,MAAa,0BACX,UAAqC,CAAC,MACf;CACvB,MAAM,gBACH,cACA,OAAyB,WACxB,IAAI,+BAA+B;EAAE;EAAU;EAAO;CAAO,CAAC;CAElE,MAAM,OAAO,yBAAyB;EACpC,QAAQ;EACR,MAAM;EACN,QAAQ,UAAU,6BAA6B;EAC/C,YAAY,cAAc,6BAA6B;EACvD,YAAY;EACZ,SAAS,CAAC;EACV,cAAc,aAAa,kBAAkB;CAC/C,CAAC;CAED,MAAM,WAAW,yBAAyB;EACxC,QAAQ;EACR,MAAM;EACN,QAAQ,UAAU,sBAAsB;EACxC,YAAY,cAAc,sBAAsB;EAChD,YAAY;EACZ,SAAS,CACP;GAAE,MAAM;GAAqB,QAAQ;GAAM,UAAS,UAAS,UAAU;EAAa,CACtF;EACA,cAAc,aAAa,UAAU;CACvC,CAAC;CAED,MAAM,YAAY,yBAAyB;EACzC,QAAQ;EACR,MAAM;EACN,QAAQ,UAAU,uBAAuB;EACzC,YAAY,cAAc,uBAAuB;EACjD,YAAY;EACZ,SAAS,CAAC;EACV,cAAc,aAAa,WAAW;CACxC,CAAC;CAED,MAAM,QAAQ,8BAA8B;EAC1C,MAAM;EACN,QAAQ,UAAU,mBAAmB;EACrC,WAAW;EACX,SAAS,CAAC;EACV,mBAAmB,QAAQ;EAC3B,cAAc,aAAa,OAAO;CACpC,CAAC;CAED,MAAM,QAAqC;EAAC;EAAM;EAAU;EAAW;CAAK;CAC5E,MAAM,iBAAiB,iBAAiB,KAAK;CAE7C,MAAM,cAAc;EAClB,KAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;CACvC;CAsBA,OAAO;EAAE,OApBK,aAAa;GACzB,QAAQ;IACN;KAAE,MAAM;KAAQ,OAAO,CAAC,6BAA6B;KAAG,MAAM;IAAK;IACnE;KAAE,MAAM;KAAY,OAAO,CAAC,sBAAsB;KAAG,MAAM;IAAS;IACpE;KAAE,MAAM;KAAa,OAAO,CAAC,uBAAuB;KAAG,MAAM;IAAU;IACvE;KAAE,MAAM;KAAS,OAAO,CAAC,mBAAmB;KAAG,MAAM;IAAM;GAC7D;GACA,UAAU;GACV,SAAS,OAAO,SAAS,SACvB,SAAS,wBAAwB,QAAQ,WAAW,QAChD,aAAa,KAAK,SAAS,CAAC,IAC5B,aAAa,KAAK,EAChB,OAAO;IACL,SACE;IACF,MAAM;GACR,EACF,CAAC;EACT,CAEa;EAAG;EAAO;EAAU;EAAM;EAAU;EAAW;CAAM;AACpE"}