@neuralnomads/codenomad-dev 0.20.0-dev-20260917-aa51cbb9 → 0.20.0-dev-20260918-a311de98

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 (223) hide show
  1. package/dist/api-types.js.map +1 -1
  2. package/dist/events/bus.js +2 -0
  3. package/dist/events/bus.js.map +1 -1
  4. package/dist/filesystem/__tests__/browser.test.js +10 -10
  5. package/dist/filesystem/__tests__/browser.test.js.map +1 -1
  6. package/dist/filesystem/__tests__/responsiveness.test.js +79 -0
  7. package/dist/filesystem/__tests__/responsiveness.test.js.map +1 -0
  8. package/dist/filesystem/__tests__/search-cache.test.js +48 -9
  9. package/dist/filesystem/__tests__/search-cache.test.js.map +1 -1
  10. package/dist/filesystem/__tests__/search.test.js +8 -8
  11. package/dist/filesystem/__tests__/search.test.js.map +1 -1
  12. package/dist/filesystem/__tests__/write-order.test.js +64 -0
  13. package/dist/filesystem/__tests__/write-order.test.js.map +1 -0
  14. package/dist/filesystem/browser.js +44 -46
  15. package/dist/filesystem/browser.js.map +1 -1
  16. package/dist/filesystem/file-access.js +19 -0
  17. package/dist/filesystem/file-access.js.map +1 -0
  18. package/dist/filesystem/search-cache.js +35 -9
  19. package/dist/filesystem/search-cache.js.map +1 -1
  20. package/dist/filesystem/search.js +9 -8
  21. package/dist/filesystem/search.js.map +1 -1
  22. package/dist/index.js +28 -18
  23. package/dist/index.js.map +1 -1
  24. package/dist/opencode/automation/desktop-plugin.js +69 -0
  25. package/dist/opencode/automation/desktop-plugin.js.map +1 -0
  26. package/dist/opencode/automation/desktop-plugin.test.js +155 -0
  27. package/dist/opencode/automation/desktop-plugin.test.js.map +1 -0
  28. package/dist/opencode/automation-plugin.js +90 -24
  29. package/dist/opencode/automation-plugin.js.map +1 -1
  30. package/dist/opencode/automation-plugin.test.js +14 -1
  31. package/dist/opencode/automation-plugin.test.js.map +1 -1
  32. package/dist/opencode/compatibility/contract-fixture.js +13 -1
  33. package/dist/opencode/compatibility/contract-fixture.js.map +1 -1
  34. package/dist/opencode/compatibility/location.js +13 -0
  35. package/dist/opencode/compatibility/location.js.map +1 -1
  36. package/dist/opencode/compatibility/location.test.js +44 -0
  37. package/dist/opencode/compatibility/location.test.js.map +1 -1
  38. package/dist/opencode/compatibility/runtime.js.map +1 -1
  39. package/dist/opencode/compatibility/transport.js +3 -0
  40. package/dist/opencode/compatibility/transport.js.map +1 -1
  41. package/dist/opencode/compatibility/transport.test.js +40 -0
  42. package/dist/opencode/compatibility/transport.test.js.map +1 -1
  43. package/dist/opencode/desktop-plugin-installation.js +103 -0
  44. package/dist/opencode/desktop-plugin-installation.js.map +1 -0
  45. package/dist/opencode/desktop-plugin-lifecycle.js +117 -0
  46. package/dist/opencode/desktop-plugin-lifecycle.js.map +1 -0
  47. package/dist/opencode/desktop-plugin-lifecycle.test.js +180 -0
  48. package/dist/opencode/desktop-plugin-lifecycle.test.js.map +1 -0
  49. package/dist/opencode/desktop-plugin-paths.js +30 -0
  50. package/dist/opencode/desktop-plugin-paths.js.map +1 -0
  51. package/dist/opencode/desktop-plugin-paths.test.js +46 -0
  52. package/dist/opencode/desktop-plugin-paths.test.js.map +1 -0
  53. package/dist/opencode/desktop-plugin-presence.js +42 -0
  54. package/dist/opencode/desktop-plugin-presence.js.map +1 -0
  55. package/dist/opencode/pruning-installation.js +3 -63
  56. package/dist/opencode/pruning-installation.js.map +1 -1
  57. package/dist/opencode/pruning-lifecycle.js +3 -64
  58. package/dist/opencode/pruning-lifecycle.js.map +1 -1
  59. package/dist/opencode/session-pruning/presence.js +1 -41
  60. package/dist/opencode/session-pruning/presence.js.map +1 -1
  61. package/dist/permissions/opencode-yolo-metadata.js +3 -1
  62. package/dist/permissions/opencode-yolo-metadata.js.map +1 -1
  63. package/dist/permissions/opencode-yolo-metadata.test.js +2 -2
  64. package/dist/permissions/opencode-yolo-metadata.test.js.map +1 -1
  65. package/dist/plugins/automation/plugin.mjs +504 -0
  66. package/dist/plugins/session-pruning/plugin.mjs +1 -1
  67. package/dist/server/routes/automation-plugin.js +31 -4
  68. package/dist/server/routes/automation-plugin.js.map +1 -1
  69. package/dist/server/routes/automation-plugin.test.js +46 -0
  70. package/dist/server/routes/automation-plugin.test.js.map +1 -1
  71. package/dist/server/routes/filesystem.js +3 -3
  72. package/dist/server/routes/filesystem.js.map +1 -1
  73. package/dist/server/routes/workspaces.js +13 -7
  74. package/dist/server/routes/workspaces.js.map +1 -1
  75. package/dist/server/routes/workspaces.test.js +31 -0
  76. package/dist/server/routes/workspaces.test.js.map +1 -1
  77. package/dist/server/routes/worktrees.js +232 -41
  78. package/dist/server/routes/worktrees.js.map +1 -1
  79. package/dist/server/routes/worktrees.test.js +113 -40
  80. package/dist/server/routes/worktrees.test.js.map +1 -1
  81. package/dist/workspaces/__tests__/git-worktrees.test.js +2 -2
  82. package/dist/workspaces/__tests__/git-worktrees.test.js.map +1 -1
  83. package/dist/workspaces/__tests__/native-worktree-fixture.js +22 -0
  84. package/dist/workspaces/__tests__/native-worktree-fixture.js.map +1 -0
  85. package/dist/workspaces/git-status.test.js +24 -1
  86. package/dist/workspaces/git-status.test.js.map +1 -1
  87. package/dist/workspaces/git-worktrees.js +37 -204
  88. package/dist/workspaces/git-worktrees.js.map +1 -1
  89. package/dist/workspaces/host-opencode-service.test.js +58 -1
  90. package/dist/workspaces/host-opencode-service.test.js.map +1 -1
  91. package/dist/workspaces/instance-events.js +5 -0
  92. package/dist/workspaces/instance-events.js.map +1 -1
  93. package/dist/workspaces/instance-events.test.js +36 -1
  94. package/dist/workspaces/instance-events.test.js.map +1 -1
  95. package/dist/workspaces/manager.js +124 -14
  96. package/dist/workspaces/manager.js.map +1 -1
  97. package/dist/workspaces/manager.test.js +25 -0
  98. package/dist/workspaces/manager.test.js.map +1 -1
  99. package/dist/workspaces/native-service-start.js +13 -0
  100. package/dist/workspaces/native-service-start.js.map +1 -0
  101. package/dist/workspaces/native-service-start.test.js +65 -0
  102. package/dist/workspaces/native-service-start.test.js.map +1 -0
  103. package/dist/workspaces/native-worktrees.js +140 -0
  104. package/dist/workspaces/native-worktrees.js.map +1 -0
  105. package/dist/workspaces/opencode-cli-service.js +10 -2
  106. package/dist/workspaces/opencode-cli-service.js.map +1 -1
  107. package/dist/workspaces/opencode-service.js +24 -2
  108. package/dist/workspaces/opencode-service.js.map +1 -1
  109. package/dist/workspaces/opencode-service.test.js +62 -0
  110. package/dist/workspaces/opencode-service.test.js.map +1 -1
  111. package/dist/workspaces/project-session-families.js +376 -0
  112. package/dist/workspaces/project-session-families.js.map +1 -0
  113. package/dist/workspaces/project-session-families.test.js +341 -0
  114. package/dist/workspaces/project-session-families.test.js.map +1 -0
  115. package/dist/workspaces/worktree-directory.js +36 -18
  116. package/dist/workspaces/worktree-directory.js.map +1 -1
  117. package/dist/workspaces/worktree-directory.test.js +123 -5
  118. package/dist/workspaces/worktree-directory.test.js.map +1 -1
  119. package/dist/workspaces/worktree-inventory.js +79 -0
  120. package/dist/workspaces/worktree-inventory.js.map +1 -0
  121. package/dist/workspaces/worktree-inventory.test.js +156 -0
  122. package/dist/workspaces/worktree-inventory.test.js.map +1 -0
  123. package/dist/workspaces/worktree-map.js +2 -5
  124. package/dist/workspaces/worktree-map.js.map +1 -1
  125. package/dist/workspaces/wsl-opencode-service.test.js +16 -2
  126. package/dist/workspaces/wsl-opencode-service.test.js.map +1 -1
  127. package/package.json +4 -3
  128. package/public/assets/App-I9uNKt0K.js +54 -0
  129. package/public/assets/App-I9uNKt0K.js.map +1 -0
  130. package/public/assets/{FilesTab-DY3Vr-3r.js → FilesTab-_xb_Aq0c.js} +3 -3
  131. package/public/assets/{FilesTab-DY3Vr-3r.js.map → FilesTab-_xb_Aq0c.js.map} +1 -1
  132. package/public/assets/{GitChangesTab-BD6CJngE.js → GitChangesTab-Cz0RckYn.js} +3 -3
  133. package/public/assets/{GitChangesTab-BD6CJngE.js.map → GitChangesTab-Cz0RckYn.js.map} +1 -1
  134. package/public/assets/{SplitFilePanel-BdY6d_6m.js → SplitFilePanel-DVkVS5C0.js} +2 -2
  135. package/public/assets/{SplitFilePanel-BdY6d_6m.js.map → SplitFilePanel-DVkVS5C0.js.map} +1 -1
  136. package/public/assets/{StatusTab-C-_2yaPa.js → StatusTab-DU1H4ngp.js} +2 -2
  137. package/public/assets/{StatusTab-C-_2yaPa.js.map → StatusTab-DU1H4ngp.js.map} +1 -1
  138. package/public/assets/{align-justify-DI8VTZ4G.js → align-justify-Czy9hp3K.js} +2 -2
  139. package/public/assets/{align-justify-DI8VTZ4G.js.map → align-justify-Czy9hp3K.js.map} +1 -1
  140. package/public/assets/{bundle-full-D_M65Eb_.js → bundle-full-CMakdq_6.js} +2 -2
  141. package/public/assets/{bundle-full-D_M65Eb_.js.map → bundle-full-CMakdq_6.js.map} +1 -1
  142. package/public/assets/{client-state-CWCzCOz6.js → client-state-DGbupmmR.js} +2 -2
  143. package/public/assets/{client-state-CWCzCOz6.js.map → client-state-DGbupmmR.js.map} +1 -1
  144. package/public/assets/{diff-viewer-CGPsYEr3.js → diff-viewer-CSOlh3i1.js} +2 -2
  145. package/public/assets/{diff-viewer-CGPsYEr3.js.map → diff-viewer-CSOlh3i1.js.map} +1 -1
  146. package/public/assets/index-B0BLbbT3.js +2 -0
  147. package/public/assets/{index-BxRFHpJd.js.map → index-B0BLbbT3.js.map} +1 -1
  148. package/public/assets/index-B52s_Dh2.js +2 -0
  149. package/public/assets/index-B52s_Dh2.js.map +1 -0
  150. package/public/assets/index-B8W9is7z.js +2 -0
  151. package/public/assets/index-B8W9is7z.js.map +1 -0
  152. package/public/assets/index-Bn8a8ymh.js +2 -0
  153. package/public/assets/index-Bn8a8ymh.js.map +1 -0
  154. package/public/assets/index-CWaDoBhJ.js +2 -0
  155. package/public/assets/index-CWaDoBhJ.js.map +1 -0
  156. package/public/assets/{index-MeFffHqb.css → index-CXEtEGDL.css} +1 -1
  157. package/public/assets/index-CbuT2QEY.js +2 -0
  158. package/public/assets/index-CbuT2QEY.js.map +1 -0
  159. package/public/assets/{index-Ddjkirek.js → index-Cq5Hfa6i.js} +2 -2
  160. package/public/assets/{index-Ddjkirek.js.map → index-Cq5Hfa6i.js.map} +1 -1
  161. package/public/assets/index-D03eJbIp.js +2 -0
  162. package/public/assets/index-D03eJbIp.js.map +1 -0
  163. package/public/assets/index-DDK0Fk7j.js +2 -0
  164. package/public/assets/index-DDK0Fk7j.js.map +1 -0
  165. package/public/assets/index-DftCJdT3.js +2 -0
  166. package/public/assets/index-DftCJdT3.js.map +1 -0
  167. package/public/assets/index-_N9V2vB3.js +3 -0
  168. package/public/assets/index-_N9V2vB3.js.map +1 -0
  169. package/public/assets/index-zo6cKyNQ.js +2 -0
  170. package/public/assets/index-zo6cKyNQ.js.map +1 -0
  171. package/public/assets/{loading-Gqh6NPUr.js → loading-B2-6L7aO.js} +2 -2
  172. package/public/assets/{loading-Gqh6NPUr.js.map → loading-B2-6L7aO.js.map} +1 -1
  173. package/public/assets/main-pZWMgVoG.js +42 -0
  174. package/public/assets/main-pZWMgVoG.js.map +1 -0
  175. package/public/assets/{markdown-BWnjyvnX.js → markdown-CH9bocix.js} +4 -4
  176. package/public/assets/{markdown-BWnjyvnX.js.map → markdown-CH9bocix.js.map} +1 -1
  177. package/public/assets/monaco-viewer-Bv1s0h2m.js +27 -0
  178. package/public/assets/monaco-viewer-Bv1s0h2m.js.map +1 -0
  179. package/public/assets/{startup-state-settings-card-C4E2Itop.js → startup-state-settings-card-mmovljyz.js} +2 -2
  180. package/public/assets/{startup-state-settings-card-C4E2Itop.js.map → startup-state-settings-card-mmovljyz.js.map} +1 -1
  181. package/public/assets/{terminal-square-C3wutdV0.js → terminal-square-U8R46SS0.js} +2 -2
  182. package/public/assets/{terminal-square-C3wutdV0.js.map → terminal-square-U8R46SS0.js.map} +1 -1
  183. package/public/assets/tool-call-AnfwOPww.js +60 -0
  184. package/public/assets/tool-call-AnfwOPww.js.map +1 -0
  185. package/public/assets/unified-picker-DtvQUEiv.js +2 -0
  186. package/public/assets/unified-picker-DtvQUEiv.js.map +1 -0
  187. package/public/assets/{wrap-text-CkBxzt04.js → wrap-text-Bh1AU9Re.js} +2 -2
  188. package/public/assets/{wrap-text-CkBxzt04.js.map → wrap-text-Bh1AU9Re.js.map} +1 -1
  189. package/public/index.html +4 -4
  190. package/public/loading.html +4 -4
  191. package/public/sw.js +1 -1
  192. package/public/sw.js.map +1 -1
  193. package/public/assets/App-BROhwPo9.js +0 -54
  194. package/public/assets/App-BROhwPo9.js.map +0 -1
  195. package/public/assets/index-B8-lAqjr.js +0 -2
  196. package/public/assets/index-B8-lAqjr.js.map +0 -1
  197. package/public/assets/index-BeUewQym.js +0 -2
  198. package/public/assets/index-BeUewQym.js.map +0 -1
  199. package/public/assets/index-BxRFHpJd.js +0 -2
  200. package/public/assets/index-Bzv1kU-S.js +0 -2
  201. package/public/assets/index-Bzv1kU-S.js.map +0 -1
  202. package/public/assets/index-C9tI4CRG.js +0 -2
  203. package/public/assets/index-C9tI4CRG.js.map +0 -1
  204. package/public/assets/index-CGYHFZ6F.js +0 -2
  205. package/public/assets/index-CGYHFZ6F.js.map +0 -1
  206. package/public/assets/index-CMEAjBFp.js +0 -2
  207. package/public/assets/index-CMEAjBFp.js.map +0 -1
  208. package/public/assets/index-Cazypvyc.js +0 -2
  209. package/public/assets/index-Cazypvyc.js.map +0 -1
  210. package/public/assets/index-CwqzofWP.js +0 -2
  211. package/public/assets/index-CwqzofWP.js.map +0 -1
  212. package/public/assets/index-Da9yOa6q.js +0 -2
  213. package/public/assets/index-Da9yOa6q.js.map +0 -1
  214. package/public/assets/index-HHgvEOAH.js +0 -3
  215. package/public/assets/index-HHgvEOAH.js.map +0 -1
  216. package/public/assets/main-Cbx7KdTr.js +0 -38
  217. package/public/assets/main-Cbx7KdTr.js.map +0 -1
  218. package/public/assets/monaco-viewer-BEJIiZWL.js +0 -27
  219. package/public/assets/monaco-viewer-BEJIiZWL.js.map +0 -1
  220. package/public/assets/tool-call-DNsAQ_m4.js +0 -60
  221. package/public/assets/tool-call-DNsAQ_m4.js.map +0 -1
  222. package/public/assets/unified-picker-tB7y17Qz.js +0 -2
  223. package/public/assets/unified-picker-tB7y17Qz.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"automation-plugin.test.js","sourceRoot":"","sources":["../../src/opencode/automation-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnF,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,kCAAkC,EAClC,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,qBAAqB,CAAA;AAO5B,SAAS,MAAM,CAAC,OAA4E;IAC1F,OAAO,IAAI,OAAO,CAAuC,CAAC,OAAO,EAAE,EAAE;QACnE,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACrD,MAAM,MAAM,GAAa,EAAE,CAAA;YAC3B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACrB,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,C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AAC,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC1F,OAAO,EAAE,CAAC;gBACV,GAAG,EAAE,IAAI,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI;gBACrD,KAAK;gBACL,GAAG,EAAE,UAAU;gBACf,SAAS;aACV,CAAC,CAAC,CAAA;QACL,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAE,CAAA;QAC3F,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;QAChG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;YAAS,CAAC;QACT,MAAM,YAAY,EAAE,EAAE,CAAA;QACtB,MAAM,WAAW,CAAC,MAAM,CAAC,CAAA;QACzB,qBAAqB,EAAE,CAAA;QACvB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import assert from \"node:assert/strict\"\nimport { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from \"node:fs/promises\"\nimport http from \"node:http\"\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport test from \"node:test\"\nimport {\n AUTOMATION_BRIDGE_PATH,\n automationBridgeDirectory,\n automationBridgeDirectories,\n createAutomationBridgeRegistration,\n parseDeveloperAction,\n publishAutomationBridge,\n removeLegacyAutomationPlugin,\n setupAutomationPlugin,\n} from \"./automation-plugin\"\n\ntype ToolDefinition = {\n name: string\n execute(input: unknown, context: { sessionID: string }): Promise<{ content: unknown }>\n}\n\nfunction listen(handler: (body: Record<string, unknown>) => Promise<Record<string, unknown>>) {\n return new Promise<{ server: http.Server; url: string }>((resolve) => {\n const server = http.createServer((request, response) => {\n const chunks: Buffer[] = []\n request.on(\"data\", (chunk) => chunks.push(Buffer.from(chunk)))\n request.on(\"end\", () => {\n void handler(JSON.parse(Buffer.concat(chunks).toString(\"utf8\"))).then((body) => {\n response.setHeader(\"content-type\", \"application/json\")\n response.end(JSON.stringify(body))\n })\n })\n })\n server.listen(0, \"127.0.0.1\", () => {\n const address = server.address() as { port: number }\n resolve({ server, url: `http://127.0.0.1:${address.port}` })\n })\n })\n}\n\nasync function collectTools(): Promise<ToolDefinition[]> {\n const definitions: ToolDefinition[] = []\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => definitions.push(value as ToolDefinition) }) },\n })\n return definitions\n}\n\nfunction closeServer(server: http.Server | undefined): Promise<void> {\n return new Promise((resolve) => server?.close(() => resolve()) ?? resolve())\n}\n\nfunction isolateAutomationBridgeRegistry(root: string): () => void {\n const previousLocalAppData = process.env.LOCALAPPDATA\n const previousXdgRuntimeDir = process.env.XDG_RUNTIME_DIR\n const previousWslDistroName = process.env.WSL_DISTRO_NAME\n process.env.LOCALAPPDATA = root\n process.env.XDG_RUNTIME_DIR = root\n delete process.env.WSL_DISTRO_NAME\n return () => {\n if (previousLocalAppData === undefined) delete process.env.LOCALAPPDATA\n else process.env.LOCALAPPDATA = previousLocalAppData\n if (previousXdgRuntimeDir === undefined) delete process.env.XDG_RUNTIME_DIR\n else process.env.XDG_RUNTIME_DIR = previousXdgRuntimeDir\n if (previousWslDistroName === undefined) delete process.env.WSL_DISTRO_NAME\n else process.env.WSL_DISTRO_NAME = previousWslDistroName\n }\n}\n\ntest(\"validates Developer Mode actions\", () => {\n assert.deepEqual(parseDeveloperAction({ action: \"type\", ref: \"e4\", text: \"CodeNomad\" }), {\n action: \"type\",\n ref: \"e4\",\n text: \"CodeNomad\",\n })\n assert.deepEqual(parseDeveloperAction({ action: \"restart\" }), { action: \"restart\" })\n assert.throws(() => parseDeveloperAction({ action: \"click\" }), /click requires ref/)\n})\n\ntest(\"registers developer tools while execution remains session-gated\", async () => {\n const tools: string[] = []\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => tools.push(value.name) }) },\n })\n\n assert.deepEqual(tools, [\"inspect\", \"act\", \"screenshot\"])\n})\n\ntest(\"discovers the Windows bridge registry from a WSL plugin\", () => {\n assert.deepEqual(automationBridgeDirectories({\n platform: \"linux\",\n env: { WSL_DISTRO_NAME: \"Ubuntu\", XDG_RUNTIME_DIR: \"/run/user/1000\" },\n home: \"/home/dev\",\n windowsLocalAppData: \"/mnt/c/Users/dev/AppData/Local\",\n }), [\n \"/run/user/1000/codenomad/automation-bridges\",\n \"/mnt/c/Users/dev/AppData/Local/CodeNomad/automation-bridges\",\n ])\n})\n\ntest(\"removes only the generated legacy global plugin shim\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-legacy-plugin-\"))\n const plugin = path.join(root, \"opencode\", \"plugins\", \"codenomad-automation.ts\")\n await mkdir(path.dirname(plugin), { recursive: true })\n try {\n await writeFile(plugin, 'export { default } from \"file:///C:/CodeNomad/resources/server/dist/opencode/automation-plugin.js\"\\n')\n assert.equal(await removeLegacyAutomationPlugin(root), true)\n await assert.rejects(readFile(plugin, \"utf8\"), { code: \"ENOENT\" })\n\n await writeFile(plugin, \"export default { id: 'user-plugin' }\\n\")\n assert.equal(await removeLegacyAutomationPlugin(root), false)\n assert.match(await readFile(plugin, \"utf8\"), /user-plugin/)\n } finally {\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"restart waits for a new native generation and returns a fresh inspection\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-restart-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n const definitions: ToolDefinition[] = []\n let removeOld: (() => Promise<void>) | undefined\n let removeNew: (() => Promise<void>) | undefined\n let removePreexisting: (() => Promise<void>) | undefined\n const removeDistractors: Array<() => Promise<void>> = []\n let oldServer: http.Server | undefined\n let newServer: http.Server | undefined\n let preexistingServer: http.Server | undefined\n const distractorServers: http.Server[] = []\n let restarting = false\n\n try {\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => definitions.push(value as typeof definitions[number]) }) },\n })\n const replacement = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-new\" } }\n : { result: { target: { id: \"page-new\", title: \"Restarted\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n newServer = replacement.server\n const preexisting = await listen(async (body) => body.mode === \"developer-probe\" && restarting\n ? { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-preexisting\" } }\n : body.mode === \"developer-probe\"\n ? { result: { available: false } }\n : { result: { target: { id: \"page-wrong\", title: \"Pre-existing\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n preexistingServer = preexisting.server\n removePreexisting = await publishAutomationBridge(createAutomationBridgeRegistration(preexisting.url))\n const distractors = await Promise.all(Array.from({ length: 5 }, (_, index) => listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: `electron:distractor-${index}`, runId: `run-distractor-${index}` } }\n : { result: { target: { id: `page-${index}`, title: \"Distractor\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })))\n distractorServers.push(...distractors.map((value) => value.server))\n const old = await listen(async (body) => {\n if (body.mode === \"developer-probe\") return { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-old\" } }\n if (body.command && (body.command as { action?: unknown }).action === \"inspect\") {\n return { result: { target: { id: \"page-old\", title: \"Original\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } }\n }\n restarting = true\n removeNew = await publishAutomationBridge(createAutomationBridgeRegistration(replacement.url))\n for (const distractor of distractors) {\n await new Promise((resolve) => setTimeout(resolve, 2))\n removeDistractors.push(await publishAutomationBridge(createAutomationBridgeRegistration(distractor.url)))\n }\n return { result: { state: \"starting\" } }\n })\n oldServer = old.server\n removeOld = await publishAutomationBridge(createAutomationBridgeRegistration(old.url))\n\n const inspect = definitions.find((definition) => definition.name === \"inspect\")!\n await inspect.execute({}, { sessionID: \"session-1\" })\n const act = definitions.find((definition) => definition.name === \"act\")!\n const result = await act.execute({ action: \"restart\" }, { sessionID: \"session-1\" })\n assert.match(String(result.content), /Restarted/)\n } finally {\n await removeOld?.()\n await removeNew?.()\n await removePreexisting?.()\n await Promise.all(removeDistractors.map((remove) => remove()))\n await closeServer(oldServer)\n await closeServer(newServer)\n await closeServer(preexistingServer)\n await Promise.all(distractorServers.map(closeServer))\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"keeps inspected targets isolated per plugin setup\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-isolation-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n let removeBridge: (() => Promise<void>) | undefined\n let server: http.Server | undefined\n try {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:isolation\", runId: \"run-isolation\" } }\n : { result: { target: { id: \"isolated\", title: \"Isolated\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n server = bridge.server\n removeBridge = await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url))\n const first = await collectTools()\n const second = await collectTools()\n await first.find((definition) => definition.name === \"inspect\")!.execute({}, { sessionID: \"session-isolation\" })\n await assert.rejects(\n second.find((definition) => definition.name === \"screenshot\")!.execute({}, { sessionID: \"session-isolation\" }),\n /Run codenomad\\.inspect/,\n )\n } finally {\n await removeBridge?.()\n await closeServer(server)\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"pins parallel sessions to their independently inspected bridges\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-sessions-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n const removals: Array<() => Promise<void>> = []\n const servers: http.Server[] = []\n try {\n for (const sessionID of [\"session-a\", \"session-b\"]) {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: body.sessionID === sessionID, nativeIdentity: `electron:${sessionID}`, runId: `run-${sessionID}` } }\n : { result: { target: { id: sessionID, title: sessionID, url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n servers.push(bridge.server)\n removals.push(await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url)))\n }\n const tools = await collectTools()\n const inspect = tools.find((definition) => definition.name === \"inspect\")!\n const screenshot = tools.find((definition) => definition.name === \"screenshot\")!\n await inspect.execute({}, { sessionID: \"session-a\" })\n await inspect.execute({}, { sessionID: \"session-b\" })\n assert.match(String((await screenshot.execute({}, { sessionID: \"session-a\" })).content), /session-a/)\n assert.match(String((await screenshot.execute({}, { sessionID: \"session-b\" })).content), /session-b/)\n } finally {\n await Promise.all(removals.map((remove) => remove()))\n await Promise.all(servers.map(closeServer))\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"prunes stale registry pressure before limiting discovery\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-stale-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n let removeBridge: (() => Promise<void>) | undefined\n let server: http.Server | undefined\n try {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:live\", runId: \"run-live\" } }\n : { result: { target: { id: \"live\", title: \"Live\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n server = bridge.server\n removeBridge = await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url))\n const directory = automationBridgeDirectory()\n assert.equal(path.dirname(path.dirname(directory)), root)\n const base = Date.now() + 10_000\n for (let index = 0; index < 70; index += 1) {\n const startedAt = base + index\n const token = `dead${String(index).padStart(8, \"0\")}`\n await writeFile(path.join(directory, `${startedAt}-99999999-${token}.json`), JSON.stringify({\n version: 1,\n url: new URL(AUTOMATION_BRIDGE_PATH, bridge.url).href,\n token,\n pid: 99_999_999,\n startedAt,\n }))\n }\n const inspect = (await collectTools()).find((definition) => definition.name === \"inspect\")!\n assert.match(String((await inspect.execute({}, { sessionID: \"session-live\" })).content), /Live/)\n assert.equal((await readdir(directory)).length, 1)\n } finally {\n await removeBridge?.()\n await closeServer(server)\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n"]}
1
+ {"version":3,"file":"automation-plugin.test.js","sourceRoot":"","sources":["../../src/opencode/automation-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnF,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,kCAAkC,EAClC,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,qBAAqB,CAAA;AAO5B,SAAS,MAAM,CAAC,OAA4E;IAC1F,OAAO,IAAI,OAAO,CAAuC,CAAC,OAAO,EAAE,EAAE;QACnE,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACrD,MAAM,MAAM,GAAa,EAAE,CAAA;YAC3B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC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,CAAC,IAAI,KAAK,SAAS,CAAE,CAAA;QAC3F,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;QAChG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;YAAS,CAAC;QACT,MAAM,YAAY,EAAE,EAAE,CAAA;QACtB,MAAM,WAAW,CAAC,MAAM,CAAC,CAAA;QACzB,qBAAqB,EAAE,CAAA;QACvB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import assert from \"node:assert/strict\"\nimport { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from \"node:fs/promises\"\nimport http from \"node:http\"\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport test from \"node:test\"\nimport {\n AUTOMATION_BRIDGE_PATH,\n automationBridgeDirectory,\n automationBridgeDirectories,\n createAutomationBridgeRegistration,\n parseBrowserAction,\n parseDeveloperAction,\n publishAutomationBridge,\n removeLegacyAutomationPlugin,\n setupAutomationPlugin,\n} from \"./automation-plugin\"\n\ntype ToolDefinition = {\n name: string\n execute(input: unknown, context: { sessionID: string }): Promise<{ content: unknown }>\n}\n\nfunction listen(handler: (body: Record<string, unknown>) => Promise<Record<string, unknown>>) {\n return new Promise<{ server: http.Server; url: string }>((resolve) => {\n const server = http.createServer((request, response) => {\n const chunks: Buffer[] = []\n request.on(\"data\", (chunk) => chunks.push(Buffer.from(chunk)))\n request.on(\"end\", () => {\n void handler(JSON.parse(Buffer.concat(chunks).toString(\"utf8\"))).then((body) => {\n response.setHeader(\"content-type\", \"application/json\")\n response.end(JSON.stringify(body))\n })\n })\n })\n server.listen(0, \"127.0.0.1\", () => {\n const address = server.address() as { port: number }\n resolve({ server, url: `http://127.0.0.1:${address.port}` })\n })\n })\n}\n\nasync function collectTools(): Promise<ToolDefinition[]> {\n const definitions: ToolDefinition[] = []\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => definitions.push(value as ToolDefinition) }) },\n })\n return definitions\n}\n\nfunction closeServer(server: http.Server | undefined): Promise<void> {\n return new Promise((resolve) => server?.close(() => resolve()) ?? resolve())\n}\n\nfunction isolateAutomationBridgeRegistry(root: string): () => void {\n const previousLocalAppData = process.env.LOCALAPPDATA\n const previousXdgRuntimeDir = process.env.XDG_RUNTIME_DIR\n const previousWslDistroName = process.env.WSL_DISTRO_NAME\n process.env.LOCALAPPDATA = root\n process.env.XDG_RUNTIME_DIR = root\n delete process.env.WSL_DISTRO_NAME\n return () => {\n if (previousLocalAppData === undefined) delete process.env.LOCALAPPDATA\n else process.env.LOCALAPPDATA = previousLocalAppData\n if (previousXdgRuntimeDir === undefined) delete process.env.XDG_RUNTIME_DIR\n else process.env.XDG_RUNTIME_DIR = previousXdgRuntimeDir\n if (previousWslDistroName === undefined) delete process.env.WSL_DISTRO_NAME\n else process.env.WSL_DISTRO_NAME = previousWslDistroName\n }\n}\n\ntest(\"validates Developer Mode actions\", () => {\n assert.deepEqual(parseDeveloperAction({ action: \"type\", ref: \"e4\", text: \"CodeNomad\" }), {\n action: \"type\",\n ref: \"e4\",\n text: \"CodeNomad\",\n })\n assert.deepEqual(parseDeveloperAction({ action: \"restart\" }), { action: \"restart\" })\n assert.throws(() => parseDeveloperAction({ action: \"click\" }), /click requires ref/)\n})\n\ntest(\"validates browser actions\", () => {\n assert.deepEqual(parseBrowserAction({ action: \"open\", url: \"https://example.com\" }), {\n action: \"open\",\n url: \"https://example.com\",\n })\n assert.deepEqual(parseBrowserAction({ action: \"type\", ref: \"e2\", text: \"hello\", clear: false }), {\n action: \"type\",\n ref: \"e2\",\n text: \"hello\",\n clear: false,\n })\n assert.throws(() => parseBrowserAction({ action: \"open\" }), /open requires url/)\n})\n\ntest(\"registers developer tools while execution remains session-gated\", async () => {\n const tools: string[] = []\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => tools.push(value.name) }) },\n })\n\n assert.deepEqual(tools, [\"inspect\", \"act\", \"screenshot\"])\n})\n\ntest(\"discovers the Windows bridge registry from a WSL plugin\", () => {\n assert.deepEqual(automationBridgeDirectories({\n platform: \"linux\",\n env: { WSL_DISTRO_NAME: \"Ubuntu\", XDG_RUNTIME_DIR: \"/run/user/1000\" },\n home: \"/home/dev\",\n windowsLocalAppData: \"/mnt/c/Users/dev/AppData/Local\",\n }), [\n \"/run/user/1000/codenomad/automation-bridges\",\n \"/mnt/c/Users/dev/AppData/Local/CodeNomad/automation-bridges\",\n ])\n})\n\ntest(\"removes only the generated legacy global plugin shim\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-legacy-plugin-\"))\n const plugin = path.join(root, \"opencode\", \"plugins\", \"codenomad-automation.ts\")\n await mkdir(path.dirname(plugin), { recursive: true })\n try {\n await writeFile(plugin, 'export { default } from \"file:///C:/CodeNomad/resources/server/dist/opencode/automation-plugin.js\"\\n')\n assert.equal(await removeLegacyAutomationPlugin(root), true)\n await assert.rejects(readFile(plugin, \"utf8\"), { code: \"ENOENT\" })\n\n await writeFile(plugin, \"export default { id: 'user-plugin' }\\n\")\n assert.equal(await removeLegacyAutomationPlugin(root), false)\n assert.match(await readFile(plugin, \"utf8\"), /user-plugin/)\n } finally {\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"restart waits for a new native generation and returns a fresh inspection\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-restart-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n const definitions: ToolDefinition[] = []\n let removeOld: (() => Promise<void>) | undefined\n let removeNew: (() => Promise<void>) | undefined\n let removePreexisting: (() => Promise<void>) | undefined\n const removeDistractors: Array<() => Promise<void>> = []\n let oldServer: http.Server | undefined\n let newServer: http.Server | undefined\n let preexistingServer: http.Server | undefined\n const distractorServers: http.Server[] = []\n let restarting = false\n\n try {\n await setupAutomationPlugin({\n tool: { transform: async (callback) => callback({ add: (value) => definitions.push(value as typeof definitions[number]) }) },\n })\n const replacement = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-new\" } }\n : { result: { target: { id: \"page-new\", title: \"Restarted\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n newServer = replacement.server\n const preexisting = await listen(async (body) => body.mode === \"developer-probe\" && restarting\n ? { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-preexisting\" } }\n : body.mode === \"developer-probe\"\n ? { result: { available: false } }\n : { result: { target: { id: \"page-wrong\", title: \"Pre-existing\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n preexistingServer = preexisting.server\n removePreexisting = await publishAutomationBridge(createAutomationBridgeRegistration(preexisting.url))\n const distractors = await Promise.all(Array.from({ length: 5 }, (_, index) => listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: `electron:distractor-${index}`, runId: `run-distractor-${index}` } }\n : { result: { target: { id: `page-${index}`, title: \"Distractor\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })))\n distractorServers.push(...distractors.map((value) => value.server))\n const old = await listen(async (body) => {\n if (body.mode === \"developer-probe\") return { result: { available: true, nativeIdentity: \"electron:test\", runId: \"run-old\" } }\n if (body.command && (body.command as { action?: unknown }).action === \"inspect\") {\n return { result: { target: { id: \"page-old\", title: \"Original\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } }\n }\n restarting = true\n removeNew = await publishAutomationBridge(createAutomationBridgeRegistration(replacement.url))\n for (const distractor of distractors) {\n await new Promise((resolve) => setTimeout(resolve, 2))\n removeDistractors.push(await publishAutomationBridge(createAutomationBridgeRegistration(distractor.url)))\n }\n return { result: { state: \"starting\" } }\n })\n oldServer = old.server\n removeOld = await publishAutomationBridge(createAutomationBridgeRegistration(old.url))\n\n const inspect = definitions.find((definition) => definition.name === \"inspect\")!\n await inspect.execute({}, { sessionID: \"session-1\" })\n const act = definitions.find((definition) => definition.name === \"act\")!\n const result = await act.execute({ action: \"restart\" }, { sessionID: \"session-1\" })\n assert.match(String(result.content), /Restarted/)\n } finally {\n await removeOld?.()\n await removeNew?.()\n await removePreexisting?.()\n await Promise.all(removeDistractors.map((remove) => remove()))\n await closeServer(oldServer)\n await closeServer(newServer)\n await closeServer(preexistingServer)\n await Promise.all(distractorServers.map(closeServer))\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"keeps inspected targets isolated per plugin setup\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-isolation-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n let removeBridge: (() => Promise<void>) | undefined\n let server: http.Server | undefined\n try {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:isolation\", runId: \"run-isolation\" } }\n : { result: { target: { id: \"isolated\", title: \"Isolated\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n server = bridge.server\n removeBridge = await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url))\n const first = await collectTools()\n const second = await collectTools()\n await first.find((definition) => definition.name === \"inspect\")!.execute({}, { sessionID: \"session-isolation\" })\n await assert.rejects(\n second.find((definition) => definition.name === \"screenshot\")!.execute({}, { sessionID: \"session-isolation\" }),\n /Run codenomad\\.inspect/,\n )\n } finally {\n await removeBridge?.()\n await closeServer(server)\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"pins parallel sessions to their independently inspected bridges\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-sessions-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n const removals: Array<() => Promise<void>> = []\n const servers: http.Server[] = []\n try {\n for (const sessionID of [\"session-a\", \"session-b\"]) {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: body.sessionID === sessionID, nativeIdentity: `electron:${sessionID}`, runId: `run-${sessionID}` } }\n : { result: { target: { id: sessionID, title: sessionID, url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n servers.push(bridge.server)\n removals.push(await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url)))\n }\n const tools = await collectTools()\n const inspect = tools.find((definition) => definition.name === \"inspect\")!\n const screenshot = tools.find((definition) => definition.name === \"screenshot\")!\n await inspect.execute({}, { sessionID: \"session-a\" })\n await inspect.execute({}, { sessionID: \"session-b\" })\n assert.match(String((await screenshot.execute({}, { sessionID: \"session-a\" })).content), /session-a/)\n assert.match(String((await screenshot.execute({}, { sessionID: \"session-b\" })).content), /session-b/)\n } finally {\n await Promise.all(removals.map((remove) => remove()))\n await Promise.all(servers.map(closeServer))\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n\ntest(\"prunes stale registry pressure before limiting discovery\", async () => {\n const root = await mkdtemp(path.join(os.tmpdir(), \"codenomad-automation-stale-\"))\n const restoreBridgeRegistry = isolateAutomationBridgeRegistry(root)\n let removeBridge: (() => Promise<void>) | undefined\n let server: http.Server | undefined\n try {\n const bridge = await listen(async (body) => body.mode === \"developer-probe\"\n ? { result: { available: true, nativeIdentity: \"electron:live\", runId: \"run-live\" } }\n : { result: { target: { id: \"live\", title: \"Live\", url: \"http://app.test\" }, nodes: [], diagnostics: [] } })\n server = bridge.server\n removeBridge = await publishAutomationBridge(createAutomationBridgeRegistration(bridge.url))\n const directory = automationBridgeDirectory()\n assert.equal(path.dirname(path.dirname(directory)), root)\n const base = Date.now() + 10_000\n for (let index = 0; index < 70; index += 1) {\n const startedAt = base + index\n const token = `dead${String(index).padStart(8, \"0\")}`\n await writeFile(path.join(directory, `${startedAt}-99999999-${token}.json`), JSON.stringify({\n version: 1,\n url: new URL(AUTOMATION_BRIDGE_PATH, bridge.url).href,\n token,\n pid: 99_999_999,\n startedAt,\n }))\n }\n const inspect = (await collectTools()).find((definition) => definition.name === \"inspect\")!\n assert.match(String((await inspect.execute({}, { sessionID: \"session-live\" })).content), /Live/)\n assert.equal((await readdir(directory)).length, 1)\n } finally {\n await removeBridge?.()\n await closeServer(server)\n restoreBridgeRegistry()\n await rm(root, { recursive: true, force: true })\n }\n})\n"]}
@@ -1,4 +1,4 @@
1
- // Minimal structural excerpts from the published earlier V2 OpenAPI document.
1
+ // Minimal structural excerpts from the published V2 OpenAPI contracts.
2
2
  // For test fixtures only; real-runtime tests also negotiate full native schemas.
3
3
  export const legacyContractFixture = {
4
4
  paths: {
@@ -12,4 +12,16 @@ export const legacyContractFixture = {
12
12
  },
13
13
  components: { schemas: { "Session.Inbox.User": { properties: { timeCreated: { type: "number" } } } } },
14
14
  };
15
+ export const modernContractFixture = {
16
+ paths: {
17
+ "/api/session/{sessionID}": { patch: {} },
18
+ "/api/form": { get: {} },
19
+ "/api/session/{sessionID}/form/{formID}": { delete: {} },
20
+ "/api/experimental/session/{sessionID}/wait": { post: {} },
21
+ "/api/session/{sessionID}/fork": { post: { requestBody: { content: { "application/json": { schema: { properties: { before: {} } } } } } } },
22
+ "/api/session/{sessionID}/command": { post: { requestBody: { content: { "application/json": { schema: { properties: { name: {} } } } } } } },
23
+ "/api/session/{sessionID}/permission/{requestID}/reply": { post: { requestBody: { content: { "application/json": { schema: { properties: { decision: {} } } } } } } },
24
+ },
25
+ components: { schemas: { "Session.Inbox.User": { properties: { time: { type: "object" } } } } },
26
+ };
15
27
  //# sourceMappingURL=contract-fixture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-fixture.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/contract-fixture.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE;QACL,iCAAiC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/C,mBAAmB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAChC,+CAA+C,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7D,+BAA+B,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7C,+BAA+B,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QAC7I,kCAAkC,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QAC/I,uDAAuD,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;KACnK;IACD,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE;CACvG,CAAA","sourcesContent":["// Minimal structural excerpts from the published earlier V2 OpenAPI document.\n// For test fixtures only; real-runtime tests also negotiate full native schemas.\nexport const legacyContractFixture = {\n paths: {\n \"/api/session/{sessionID}/rename\": { post: {} },\n \"/api/form/request\": { get: {} },\n \"/api/session/{sessionID}/form/{formID}/cancel\": { post: {} },\n \"/api/session/{sessionID}/wait\": { post: {} },\n \"/api/session/{sessionID}/fork\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { boundary: {} } } } } } } },\n \"/api/session/{sessionID}/command\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { command: {} } } } } } } },\n \"/api/session/{sessionID}/permission/{requestID}/reply\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { reply: {} } } } } } } },\n },\n components: { schemas: { \"Session.Inbox.User\": { properties: { timeCreated: { type: \"number\" } } } } },\n}\n"]}
1
+ {"version":3,"file":"contract-fixture.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/contract-fixture.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE;QACL,iCAAiC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/C,mBAAmB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAChC,+CAA+C,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7D,+BAA+B,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7C,+BAA+B,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QAC7I,kCAAkC,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QAC/I,uDAAuD,EAAE,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,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2 OpenAPI contracts.\n// For test fixtures only; real-runtime tests also negotiate full native schemas.\nexport const legacyContractFixture = {\n paths: {\n \"/api/session/{sessionID}/rename\": { post: {} },\n \"/api/form/request\": { get: {} },\n \"/api/session/{sessionID}/form/{formID}/cancel\": { post: {} },\n \"/api/session/{sessionID}/wait\": { post: {} },\n \"/api/session/{sessionID}/fork\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { boundary: {} } } } } } } },\n \"/api/session/{sessionID}/command\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { command: {} } } } } } } },\n \"/api/session/{sessionID}/permission/{requestID}/reply\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { reply: {} } } } } } } },\n },\n components: { schemas: { \"Session.Inbox.User\": { properties: { timeCreated: { type: \"number\" } } } } },\n}\n\nexport const modernContractFixture = {\n paths: {\n \"/api/session/{sessionID}\": { patch: {} },\n \"/api/form\": { get: {} },\n \"/api/session/{sessionID}/form/{formID}\": { delete: {} },\n \"/api/experimental/session/{sessionID}/wait\": { post: {} },\n \"/api/session/{sessionID}/fork\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { before: {} } } } } } } },\n \"/api/session/{sessionID}/command\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { name: {} } } } } } } },\n \"/api/session/{sessionID}/permission/{requestID}/reply\": { post: { requestBody: { content: { \"application/json\": { schema: { properties: { decision: {} } } } } } } },\n },\n components: { schemas: { \"Session.Inbox.User\": { properties: { time: { type: \"object\" } } } } },\n}\n"]}
@@ -35,6 +35,19 @@ export function applyLocationContext(url, method, body, headers, profile) {
35
35
  if (!location)
36
36
  return body;
37
37
  const input = body && typeof body === "object" && !Array.isArray(body) ? body : undefined;
38
+ if ((url.pathname === "/api/worktree" && ["GET", "POST", "DELETE"].includes(method))
39
+ || (method === "POST" && url.pathname === "/api/worktree/refresh")) {
40
+ if (profile === "modern")
41
+ return body;
42
+ url.searchParams.delete("projectID");
43
+ url.searchParams.set("location[directory]", location.directory);
44
+ if (location.workspaceID !== undefined)
45
+ url.searchParams.set("location[workspace]", location.workspaceID);
46
+ if (!input || url.pathname.endsWith("/refresh"))
47
+ return undefined;
48
+ const { projectID: _projectID, ...payload } = input;
49
+ return payload;
50
+ }
38
51
  const assertDirectory = (directory) => {
39
52
  if (directory !== location.directory)
40
53
  throw new Error("Location context does not match request");
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/location.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE3E,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAA;AAE7D,MAAM,UAAU,sBAAsB,CAAC,QAAqB,EAAE,OAAwC;IACpG,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC1C,OAAO,QAAQ,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QACpF,OAAO,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE;KACrF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAoC,EAAE,OAAwB;IAChG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IACnG,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,IAAI,CAAC,KAAK,IAAI,OA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,qBAAqB,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IAClG,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;QAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;IACzG,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { LocationRef, OpenCodeClient } from \"@opencode/client\"\nimport type { ContractProfile } from \"./runtime\"\nimport { readLocationRef } from \"../session-pruning/location\"\nexport { readLocationRef, sameLocation } from \"../session-pruning/location\"\n\n// An explicit CodeNomad context channel survives the generated modern client's\n// field selection. Never forward this header to OpenCode unchanged. The guarded\n// proxy must authorize its complete location before transport serialization.\nexport const LOCATION_CONTEXT_HEADER = \"x-codenomad-location\"\n\nexport function locationRequestOptions(location: LocationRef, options?: { includeDirectory?: boolean }): { headers: Record<string, string> } | undefined {\n const resolved = readLocationRef(location)\n return resolved.workspaceID === undefined && !options?.includeDirectory ? undefined : {\n headers: { [LOCATION_CONTEXT_HEADER]: encodeURIComponent(JSON.stringify(resolved)) },\n }\n}\n\nexport function readLocationContext(value: string | string[] | undefined, profile: ContractProfile): LocationRef | undefined {\n if (value === undefined) return undefined\n if (typeof value !== \"string\" || value.length > 16_384) throw new Error(\"Invalid location context\")\n const input: unknown = JSON.parse(decodeURIComponent(value))\n if (!input || typeof input !== \"object\" || Object.keys(input).some(key => key !== \"directory\" && key !== \"workspaceID\")) {\n throw new Error(\"Invalid location context\")\n }\n const location = readLocationRef(input)\n if (location.workspaceID !== undefined && profile !== \"legacy\") throw new Error(\"Unsupported workspace selector\")\n return location\n}\n\nexport async function moveSessionToLocation(client: OpenCodeClient, sessionID: string, location: LocationRef): Promise<void> {\n await client.session.move({ sessionID, directory: location.directory }, locationRequestOptions(location))\n}\n\n// The selected transport calls this AFTER authorization. Only the explicitly\n// supported wire slots are adapted; this is not a general header-to-body merge.\nexport function applyLocationContext(url: URL, method: string, body: unknown, headers: Headers, profile: ContractProfile): unknown {\n const location = readLocationContext(headers.get(LOCATION_CONTEXT_HEADER) ?? undefined, profile)\n headers.delete(LOCATION_CONTEXT_HEADER)\n if (!location) return body\n const input = body && typeof body === \"object\" && !Array.isArray(body) ? body as Record<string, unknown> : undefined\n const assertDirectory = (directory: unknown) => {\n if (directory !== location.directory) throw new Error(\"Location context does not match request\")\n }\n if (method === \"POST\" && /^\\/api\\/session\\/[^/]+\\/move\\/?$/.test(url.pathname)) {\n assertDirectory(input?.directory)\n if (input?.workspaceID !== undefined && input.workspaceID !== location.workspaceID) throw new Error(\"Conflicting workspace selector\")\n return { ...input, workspaceID: location.workspaceID }\n }\n if (method === \"POST\" && /^\\/api\\/(?:experimental\\/)?session(?:\\/import)?\\/?$/.test(url.pathname)) {\n const destination = readLocationRef(input?.location)\n assertDirectory(destination.directory)\n if (destination.workspaceID !== undefined && destination.workspaceID !== location.workspaceID) throw new Error(\"Conflicting workspace selector\")\n return { ...input, location: { ...destination, workspaceID: location.workspaceID } }\n }\n if (/^\\/api\\/session\\/global\\/form(?:\\/[^/]+(?:\\/(?:reply|cancel|state))?)?\\/?$/.test(url.pathname)) {\n assertDirectory(decodeURIComponent(headers.get(\"x-opencode-directory\") ?? \"\"))\n if (location.workspaceID !== undefined) headers.set(\"x-opencode-workspace\", location.workspaceID)\n return body\n }\n if (method === \"GET\" && /^\\/api\\/session\\/?$/.test(url.pathname)) {\n // The cursor is the complete native query, not a location selector to amend.\n if (url.searchParams.has(\"cursor\")) throw new Error(\"Cursor already carries session list scope\")\n assertDirectory(url.searchParams.get(\"directory\"))\n if (url.searchParams.has(\"workspace\")) throw new Error(\"Conflicting workspace selector\")\n if (location.workspaceID !== undefined) url.searchParams.set(\"workspace\", location.workspaceID)\n return body\n }\n if (/^\\/api\\/credential\\/[^/]+(?:\\/activate)?\\/?$/.test(url.pathname)) {\n // Modern credential mutations are global; legacy invalidation is scoped.\n // The generated modern client has no location query to preserve for us.\n if (profile !== \"legacy\") return body\n if (url.searchParams.has(\"location[directory]\")) assertDirectory(url.searchParams.get(\"location[directory]\"))\n url.searchParams.set(\"location[directory]\", location.directory)\n }\n const directory = url.searchParams.get(\"location[directory]\")\n assertDirectory(directory)\n if (url.searchParams.has(\"location[workspace]\")) throw new Error(\"Conflicting workspace selector\")\n if (location.workspaceID !== undefined) url.searchParams.set(\"location[workspace]\", location.workspaceID)\n return body\n}\n"]}
1
+ {"version":3,"file":"location.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/location.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE3E,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAA;AAE7D,MAAM,UAAU,sBAAsB,CAAC,QAAqB,EAAE,OAAwC;IACpG,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC1C,OAAO,QAAQ,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QACpF,OAAO,EAAE,EAAE,CAAC,uBAAuB,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE;KACrF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAoC,EAAE,OAAwB;IAChG,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IACnG,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAA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,CAAC,GAAG,CAAC,WAAW,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACxF,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;QAC/F,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,8CAA8C,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtE,yEAAyE;QACzE,wEAAwE;QACxE,IAAI,OAAO,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAA;QACrC,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAAE,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAA;QAC7G,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;IACjE,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;IAC7D,eAAe,CAAC,SAAS,CAAC,CAAA;IAC1B,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IAClG,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS;QAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;IACzG,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import type { LocationRef, OpenCodeClient } from \"@opencode/client\"\nimport type { ContractProfile } from \"./runtime\"\nimport { readLocationRef } from \"../session-pruning/location\"\nexport { readLocationRef, sameLocation } from \"../session-pruning/location\"\n\n// An explicit CodeNomad context channel survives the generated modern client's\n// field selection. Never forward this header to OpenCode unchanged. The guarded\n// proxy must authorize its complete location before transport serialization.\nexport const LOCATION_CONTEXT_HEADER = \"x-codenomad-location\"\n\nexport function locationRequestOptions(location: LocationRef, options?: { includeDirectory?: boolean }): { headers: Record<string, string> } | undefined {\n const resolved = readLocationRef(location)\n return resolved.workspaceID === undefined && !options?.includeDirectory ? undefined : {\n headers: { [LOCATION_CONTEXT_HEADER]: encodeURIComponent(JSON.stringify(resolved)) },\n }\n}\n\nexport function readLocationContext(value: string | string[] | undefined, profile: ContractProfile): LocationRef | undefined {\n if (value === undefined) return undefined\n if (typeof value !== \"string\" || value.length > 16_384) throw new Error(\"Invalid location context\")\n const input: unknown = JSON.parse(decodeURIComponent(value))\n if (!input || typeof input !== \"object\" || Object.keys(input).some(key => key !== \"directory\" && key !== \"workspaceID\")) {\n throw new Error(\"Invalid location context\")\n }\n const location = readLocationRef(input)\n if (location.workspaceID !== undefined && profile !== \"legacy\") throw new Error(\"Unsupported workspace selector\")\n return location\n}\n\nexport async function moveSessionToLocation(client: OpenCodeClient, sessionID: string, location: LocationRef): Promise<void> {\n await client.session.move({ sessionID, directory: location.directory }, locationRequestOptions(location))\n}\n\n// The selected transport calls this AFTER authorization. Only the explicitly\n// supported wire slots are adapted; this is not a general header-to-body merge.\nexport function applyLocationContext(url: URL, method: string, body: unknown, headers: Headers, profile: ContractProfile): unknown {\n const location = readLocationContext(headers.get(LOCATION_CONTEXT_HEADER) ?? undefined, profile)\n headers.delete(LOCATION_CONTEXT_HEADER)\n if (!location) return body\n const input = body && typeof body === \"object\" && !Array.isArray(body) ? body as Record<string, unknown> : undefined\n if ((url.pathname === \"/api/worktree\" && [\"GET\", \"POST\", \"DELETE\"].includes(method))\n || (method === \"POST\" && url.pathname === \"/api/worktree/refresh\")) {\n if (profile === \"modern\") return body\n url.searchParams.delete(\"projectID\")\n url.searchParams.set(\"location[directory]\", location.directory)\n if (location.workspaceID !== undefined) url.searchParams.set(\"location[workspace]\", location.workspaceID)\n if (!input || url.pathname.endsWith(\"/refresh\")) return undefined\n const { projectID: _projectID, ...payload } = input\n return payload\n }\n const assertDirectory = (directory: unknown) => {\n if (directory !== location.directory) throw new Error(\"Location context does not match request\")\n }\n if (method === \"POST\" && /^\\/api\\/session\\/[^/]+\\/move\\/?$/.test(url.pathname)) {\n assertDirectory(input?.directory)\n if (input?.workspaceID !== undefined && input.workspaceID !== location.workspaceID) throw new Error(\"Conflicting workspace selector\")\n return { ...input, workspaceID: location.workspaceID }\n }\n if (method === \"POST\" && /^\\/api\\/(?:experimental\\/)?session(?:\\/import)?\\/?$/.test(url.pathname)) {\n const destination = readLocationRef(input?.location)\n assertDirectory(destination.directory)\n if (destination.workspaceID !== undefined && destination.workspaceID !== location.workspaceID) throw new Error(\"Conflicting workspace selector\")\n return { ...input, location: { ...destination, workspaceID: location.workspaceID } }\n }\n if (/^\\/api\\/session\\/global\\/form(?:\\/[^/]+(?:\\/(?:reply|cancel|state))?)?\\/?$/.test(url.pathname)) {\n assertDirectory(decodeURIComponent(headers.get(\"x-opencode-directory\") ?? \"\"))\n if (location.workspaceID !== undefined) headers.set(\"x-opencode-workspace\", location.workspaceID)\n return body\n }\n if (method === \"GET\" && /^\\/api\\/session\\/?$/.test(url.pathname)) {\n // The cursor is the complete native query, not a location selector to amend.\n if (url.searchParams.has(\"cursor\")) throw new Error(\"Cursor already carries session list scope\")\n assertDirectory(url.searchParams.get(\"directory\"))\n if (url.searchParams.has(\"workspace\")) throw new Error(\"Conflicting workspace selector\")\n if (location.workspaceID !== undefined) url.searchParams.set(\"workspace\", location.workspaceID)\n return body\n }\n if (/^\\/api\\/credential\\/[^/]+(?:\\/activate)?\\/?$/.test(url.pathname)) {\n // Modern credential mutations are global; legacy invalidation is scoped.\n // The generated modern client has no location query to preserve for us.\n if (profile !== \"legacy\") return body\n if (url.searchParams.has(\"location[directory]\")) assertDirectory(url.searchParams.get(\"location[directory]\"))\n url.searchParams.set(\"location[directory]\", location.directory)\n }\n const directory = url.searchParams.get(\"location[directory]\")\n assertDirectory(directory)\n if (url.searchParams.has(\"location[workspace]\")) throw new Error(\"Conflicting workspace selector\")\n if (location.workspaceID !== undefined) url.searchParams.set(\"location[workspace]\", location.workspaceID)\n return body\n}\n"]}
@@ -89,4 +89,48 @@ test("directory-only credential context is native-scoped on legacy and global on
89
89
  await client.credential.remove({ credentialID: "credential" }, locationRequestOptions({ directory: "/repo" }, { includeDirectory: true }));
90
90
  }
91
91
  });
92
+ test("worktree refresh retains canonical project requests and adapts legacy directory context", () => {
93
+ const location = { directory: "/repo", workspaceID: "native" };
94
+ const legacyUrl = new URL("http://localhost/api/worktree/refresh");
95
+ const headers = new Headers(locationRequestOptions(location)?.headers);
96
+ assert.equal(applyLocationContext(legacyUrl, "POST", { projectID: "project" }, headers, "legacy"), undefined);
97
+ assert.equal(legacyUrl.searchParams.get("location[directory]"), "/repo");
98
+ assert.equal(legacyUrl.searchParams.get("location[workspace]"), "native");
99
+ const modernUrl = new URL("http://localhost/api/worktree/refresh");
100
+ const modernHeaders = new Headers(locationRequestOptions({ directory: "/repo" }, { includeDirectory: true })?.headers);
101
+ assert.deepEqual(applyLocationContext(modernUrl, "POST", { projectID: "project" }, modernHeaders, "modern"), { projectID: "project" });
102
+ assert.equal(modernUrl.search, "");
103
+ });
104
+ test("generated worktree methods retain their payload while adapting the legacy location scope", async () => {
105
+ for (const version of ["2.0.3", "2.0.4"]) {
106
+ const endpoint = { url: "http://localhost:4321", auth: { type: "basic", username: "fixture", password: "fixture" } };
107
+ rememberRuntime(endpoint, { version, pid: 1, discovery: version === "2.0.3" ? "health" : "status" });
108
+ const requests = [];
109
+ const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {
110
+ const request = new Request(input, init);
111
+ requests.push({ method: request.method, url: new URL(request.url), body: request.body ? await request.json() : undefined });
112
+ if (request.method === "GET")
113
+ return Response.json([{ directory: "/repo", strategy: "git" }]);
114
+ if (request.method === "POST")
115
+ return Response.json({ directory: "/repo/.codenomad/worktrees/new" });
116
+ return new Response(null, { status: 204 });
117
+ }) });
118
+ const options = locationRequestOptions({ directory: "/repo" }, { includeDirectory: true });
119
+ await client.worktree.list({ projectID: "project" }, options);
120
+ await client.worktree.create({ projectID: "project", from: "/source", branch: "revision", directory: "/repo/.codenomad/worktrees", name: "new" }, options);
121
+ await client.worktree.remove({ projectID: "project", directory: "/repo/.codenomad/worktrees/new", force: false }, options);
122
+ const legacy = version === "2.0.3";
123
+ for (const request of requests) {
124
+ assert.equal(request.url.searchParams.get("location[directory]"), legacy ? "/repo" : null);
125
+ if (request.method === "GET")
126
+ assert.equal(request.url.searchParams.get("projectID"), legacy ? null : "project");
127
+ else
128
+ assert.equal(request.body.projectID, legacy ? undefined : "project");
129
+ }
130
+ assert.equal(requests[1].body.branch, "revision");
131
+ assert.equal(requests[1].body.from, "/source");
132
+ assert.equal(requests[2].body.directory, "/repo/.codenomad/worktrees/new");
133
+ assert.equal(requests[2].body.force, false);
134
+ }
135
+ });
92
136
  //# sourceMappingURL=location.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"location.test.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/location.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EACL,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EACrE,qBAAqB,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,GAC1E,MAAM,YAAY,CAAA;AAEnB,IAAI,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;IACpF,MAAM,QAAQ,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,aA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AAkC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBACxG,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YAC5C,CAAC,CAAC,EAAE,CAAC,CAAA;QACL,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,sBAAsB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC5I,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import assert from \"node:assert/strict\"\nimport { test } from \"node:test\"\nimport { OpenCode } from \"@opencode/client\"\nimport { createRuntimeFetch } from \"./transport\"\nimport { rememberRuntime } from \"./runtime\"\nimport {\n LOCATION_CONTEXT_HEADER, applyLocationContext, locationRequestOptions,\n moveSessionToLocation, readLocationContext, readLocationRef, sameLocation,\n} from \"./location\"\n\ntest(\"identity context survives real modern generated move serialization\", async () => {\n const original = { directory: \"/work/100% 工作\", workspaceID: \"workspace-1\" }\n let calls = 0\n const client = OpenCode.make({ baseUrl: \"http://localhost:1234\", fetch: async (input, init) => {\n calls++\n const request = new Request(input, init)\n const before = await request.json()\n assert.deepEqual(before, { directory: original.directory })\n const headers = new Headers(request.headers)\n const after = applyLocationContext(new URL(request.url), request.method, before, headers, \"legacy\")\n assert.deepEqual(after, original)\n assert.equal(headers.has(LOCATION_CONTEXT_HEADER), false)\n return new Response(null, { status: 204 })\n } })\n await moveSessionToLocation(client, \"s\", original)\n assert.equal(calls, 1)\n})\n\ntest(\"context parser refuses malformed, duplicate, unknown and modern identity selectors\", () => {\n const encoded = locationRequestOptions({ directory: \"/repo\", workspaceID: \"w\" })!.headers[LOCATION_CONTEXT_HEADER]\n assert.deepEqual(readLocationContext(encoded, \"legacy\"), { directory: \"/repo\", workspaceID: \"w\" })\n for (const profile of [\"modern\", \"unknown\"] as const) assert.throws(() => readLocationContext(encoded, profile), /Unsupported/)\n assert.throws(() => readLocationContext([encoded, encoded], \"legacy\"))\n assert.throws(() => readLocationContext(\"%\", \"legacy\"))\n assert.throws(() => readLocationContext(encodeURIComponent('{\"directory\":\"/repo\",\"workspace\":\"w\"}'), \"legacy\"))\n assert.throws(() => readLocationRef({ directory: \"/repo\", workspaceID: null }))\n assert.equal(sameLocation({ directory: \"/repo\", workspaceID: \"one\" }, { directory: \"/repo\", workspaceID: \"two\" }), false)\n})\n\ntest(\"global Forms and catalog requests preserve explicit identity without forwarding private headers\", () => {\n const ref = { directory: \"/工作/100% ready\", workspaceID: \"worktree\" }\n const options = locationRequestOptions(ref)!\n const headers = new Headers({ ...options.headers, \"x-opencode-directory\": encodeURIComponent(ref.directory) })\n applyLocationContext(new URL(\"http://localhost/api/session/global/form/f/reply\"), \"POST\", { answer: {} }, headers, \"legacy\")\n assert.equal(headers.get(\"x-opencode-workspace\"), \"worktree\")\n assert.equal(headers.has(LOCATION_CONTEXT_HEADER), false)\n const url = new URL(\"http://localhost/api/form\")\n url.searchParams.set(\"location[directory]\", ref.directory)\n applyLocationContext(url, \"GET\", undefined, new Headers(options.headers), \"legacy\")\n assert.equal(url.searchParams.get(\"location[workspace]\"), \"worktree\")\n const foreign = new URL(\"http://localhost/api/form?location[directory]=/other\")\n assert.throws(() => applyLocationContext(foreign, \"GET\", undefined, new Headers(options.headers), \"legacy\"), /does not match/)\n assert.throws(() => applyLocationContext(url, \"GET\", undefined, new Headers(options.headers), \"modern\"), /Unsupported/)\n})\n\ntest(\"real generated list, RPC, eviction and credential calls use their distinct legacy wire locations\", async () => {\n const endpoint = { url: \"http://localhost:1234\" }\n rememberRuntime(endpoint, { version: \"2.0.3\", pid: 1, discovery: \"health\" })\n const location = { directory: \"/repo\", workspaceID: \"wrk_one\" }\n const calls: URL[] = []\n const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {\n const request = new Request(input, init)\n assert.equal(request.headers.has(LOCATION_CONTEXT_HEADER), false)\n const url = new URL(request.url)\n calls.push(url)\n if (url.pathname === \"/api/session\") {\n assert.equal(url.searchParams.get(\"directory\"), \"/repo\")\n assert.equal(url.searchParams.get(\"workspace\"), \"wrk_one\")\n assert.equal(url.searchParams.has(\"location[directory]\"), false)\n return Response.json({ data: [], cursor: {} })\n }\n assert.equal(url.searchParams.get(\"location[directory]\"), \"/repo\")\n assert.equal(url.searchParams.get(\"location[workspace]\"), \"wrk_one\")\n return url.pathname.startsWith(\"/api/rpc/\") ? Response.json({ output: true }) : new Response(null, { status: 204 })\n }) })\n const options = locationRequestOptions(location)\n await client.session.list({ directory: location.directory }, options)\n await client.rpc.call({ rpcID: \"fixture\", method: \"check\", input: {}, location: { directory: location.directory } }, options)\n await client.debug.location.evict({ location: { directory: location.directory } }, options)\n await client.credential.remove({ credentialID: \"credential\" }, options)\n assert.equal(calls.length, 4)\n await assert.rejects(client.session.list({ cursor: \"native-cursor\" }, options))\n assert.equal(calls.length, 4, \"conflicting cursor context never dispatches\")\n})\n\ntest(\"directory-only credential context is native-scoped on legacy and global on modern\", async () => {\n for (const version of [\"2.0.3\", \"2.0.4\"]) {\n const endpoint = { url: \"http://localhost:1234\" }\n rememberRuntime(endpoint, { version, pid: 1, discovery: version === \"2.0.3\" ? \"health\" : \"status\" })\n const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {\n const request = new Request(input, init)\n assert.equal(request.headers.has(LOCATION_CONTEXT_HEADER), false)\n assert.equal(new URL(request.url).search, version === \"2.0.3\" ? \"?location%5Bdirectory%5D=%2Frepo\" : \"\")\n return new Response(null, { status: 204 })\n }) })\n await client.credential.remove({ credentialID: \"credential\" }, locationRequestOptions({ directory: \"/repo\" }, { includeDirectory: true }))\n }\n})\n"]}
1
+ {"version":3,"file":"location.test.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/location.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,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AAA;QAC1E,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import assert from \"node:assert/strict\"\nimport { test } from \"node:test\"\nimport { OpenCode } from \"@opencode/client\"\nimport { createRuntimeFetch } from \"./transport\"\nimport { rememberRuntime } from \"./runtime\"\nimport {\n LOCATION_CONTEXT_HEADER, applyLocationContext, locationRequestOptions,\n moveSessionToLocation, readLocationContext, readLocationRef, sameLocation,\n} from \"./location\"\n\ntest(\"identity context survives real modern generated move serialization\", async () => {\n const original = { directory: \"/work/100% 工作\", workspaceID: \"workspace-1\" }\n let calls = 0\n const client = OpenCode.make({ baseUrl: \"http://localhost:1234\", fetch: async (input, init) => {\n calls++\n const request = new Request(input, init)\n const before = await request.json()\n assert.deepEqual(before, { directory: original.directory })\n const headers = new Headers(request.headers)\n const after = applyLocationContext(new URL(request.url), request.method, before, headers, \"legacy\")\n assert.deepEqual(after, original)\n assert.equal(headers.has(LOCATION_CONTEXT_HEADER), false)\n return new Response(null, { status: 204 })\n } })\n await moveSessionToLocation(client, \"s\", original)\n assert.equal(calls, 1)\n})\n\ntest(\"context parser refuses malformed, duplicate, unknown and modern identity selectors\", () => {\n const encoded = locationRequestOptions({ directory: \"/repo\", workspaceID: \"w\" })!.headers[LOCATION_CONTEXT_HEADER]\n assert.deepEqual(readLocationContext(encoded, \"legacy\"), { directory: \"/repo\", workspaceID: \"w\" })\n for (const profile of [\"modern\", \"unknown\"] as const) assert.throws(() => readLocationContext(encoded, profile), /Unsupported/)\n assert.throws(() => readLocationContext([encoded, encoded], \"legacy\"))\n assert.throws(() => readLocationContext(\"%\", \"legacy\"))\n assert.throws(() => readLocationContext(encodeURIComponent('{\"directory\":\"/repo\",\"workspace\":\"w\"}'), \"legacy\"))\n assert.throws(() => readLocationRef({ directory: \"/repo\", workspaceID: null }))\n assert.equal(sameLocation({ directory: \"/repo\", workspaceID: \"one\" }, { directory: \"/repo\", workspaceID: \"two\" }), false)\n})\n\ntest(\"global Forms and catalog requests preserve explicit identity without forwarding private headers\", () => {\n const ref = { directory: \"/工作/100% ready\", workspaceID: \"worktree\" }\n const options = locationRequestOptions(ref)!\n const headers = new Headers({ ...options.headers, \"x-opencode-directory\": encodeURIComponent(ref.directory) })\n applyLocationContext(new URL(\"http://localhost/api/session/global/form/f/reply\"), \"POST\", { answer: {} }, headers, \"legacy\")\n assert.equal(headers.get(\"x-opencode-workspace\"), \"worktree\")\n assert.equal(headers.has(LOCATION_CONTEXT_HEADER), false)\n const url = new URL(\"http://localhost/api/form\")\n url.searchParams.set(\"location[directory]\", ref.directory)\n applyLocationContext(url, \"GET\", undefined, new Headers(options.headers), \"legacy\")\n assert.equal(url.searchParams.get(\"location[workspace]\"), \"worktree\")\n const foreign = new URL(\"http://localhost/api/form?location[directory]=/other\")\n assert.throws(() => applyLocationContext(foreign, \"GET\", undefined, new Headers(options.headers), \"legacy\"), /does not match/)\n assert.throws(() => applyLocationContext(url, \"GET\", undefined, new Headers(options.headers), \"modern\"), /Unsupported/)\n})\n\ntest(\"real generated list, RPC, eviction and credential calls use their distinct legacy wire locations\", async () => {\n const endpoint = { url: \"http://localhost:1234\" }\n rememberRuntime(endpoint, { version: \"2.0.3\", pid: 1, discovery: \"health\" })\n const location = { directory: \"/repo\", workspaceID: \"wrk_one\" }\n const calls: URL[] = []\n const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {\n const request = new Request(input, init)\n assert.equal(request.headers.has(LOCATION_CONTEXT_HEADER), false)\n const url = new URL(request.url)\n calls.push(url)\n if (url.pathname === \"/api/session\") {\n assert.equal(url.searchParams.get(\"directory\"), \"/repo\")\n assert.equal(url.searchParams.get(\"workspace\"), \"wrk_one\")\n assert.equal(url.searchParams.has(\"location[directory]\"), false)\n return Response.json({ data: [], cursor: {} })\n }\n assert.equal(url.searchParams.get(\"location[directory]\"), \"/repo\")\n assert.equal(url.searchParams.get(\"location[workspace]\"), \"wrk_one\")\n return url.pathname.startsWith(\"/api/rpc/\") ? Response.json({ output: true }) : new Response(null, { status: 204 })\n }) })\n const options = locationRequestOptions(location)\n await client.session.list({ directory: location.directory }, options)\n await client.rpc.call({ rpcID: \"fixture\", method: \"check\", input: {}, location: { directory: location.directory } }, options)\n await client.debug.location.evict({ location: { directory: location.directory } }, options)\n await client.credential.remove({ credentialID: \"credential\" }, options)\n assert.equal(calls.length, 4)\n await assert.rejects(client.session.list({ cursor: \"native-cursor\" }, options))\n assert.equal(calls.length, 4, \"conflicting cursor context never dispatches\")\n})\n\ntest(\"directory-only credential context is native-scoped on legacy and global on modern\", async () => {\n for (const version of [\"2.0.3\", \"2.0.4\"]) {\n const endpoint = { url: \"http://localhost:1234\" }\n rememberRuntime(endpoint, { version, pid: 1, discovery: version === \"2.0.3\" ? \"health\" : \"status\" })\n const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {\n const request = new Request(input, init)\n assert.equal(request.headers.has(LOCATION_CONTEXT_HEADER), false)\n assert.equal(new URL(request.url).search, version === \"2.0.3\" ? \"?location%5Bdirectory%5D=%2Frepo\" : \"\")\n return new Response(null, { status: 204 })\n }) })\n await client.credential.remove({ credentialID: \"credential\" }, locationRequestOptions({ directory: \"/repo\" }, { includeDirectory: true }))\n }\n})\ntest(\"worktree refresh retains canonical project requests and adapts legacy directory context\", () => {\n const location = { directory: \"/repo\", workspaceID: \"native\" }\n const legacyUrl = new URL(\"http://localhost/api/worktree/refresh\")\n const headers = new Headers(locationRequestOptions(location)?.headers)\n assert.equal(applyLocationContext(legacyUrl, \"POST\", { projectID: \"project\" }, headers, \"legacy\"), undefined)\n assert.equal(legacyUrl.searchParams.get(\"location[directory]\"), \"/repo\")\n assert.equal(legacyUrl.searchParams.get(\"location[workspace]\"), \"native\")\n const modernUrl = new URL(\"http://localhost/api/worktree/refresh\")\n const modernHeaders = new Headers(locationRequestOptions({ directory: \"/repo\" }, { includeDirectory: true })?.headers)\n assert.deepEqual(applyLocationContext(modernUrl, \"POST\", { projectID: \"project\" }, modernHeaders, \"modern\"), { projectID: \"project\" })\n assert.equal(modernUrl.search, \"\")\n})\n\ntest(\"generated worktree methods retain their payload while adapting the legacy location scope\", async () => {\n for (const version of [\"2.0.3\", \"2.0.4\"]) {\n const endpoint = { url: \"http://localhost:4321\", auth: { type: \"basic\" as const, username: \"fixture\", password: \"fixture\" } }\n rememberRuntime(endpoint, { version, pid: 1, discovery: version === \"2.0.3\" ? \"health\" : \"status\" })\n const requests: Array<{ method: string; url: URL; body: any }> = []\n const client = OpenCode.make({ baseUrl: endpoint.url, fetch: createRuntimeFetch(endpoint, async (input, init) => {\n const request = new Request(input, init)\n requests.push({ method: request.method, url: new URL(request.url), body: request.body ? await request.json() : undefined })\n if (request.method === \"GET\") return Response.json([{ directory: \"/repo\", strategy: \"git\" }])\n if (request.method === \"POST\") return Response.json({ directory: \"/repo/.codenomad/worktrees/new\" })\n return new Response(null, { status: 204 })\n }) })\n const options = locationRequestOptions({ directory: \"/repo\" }, { includeDirectory: true })\n await client.worktree.list({ projectID: \"project\" }, options)\n await client.worktree.create({ projectID: \"project\", from: \"/source\", branch: \"revision\", directory: \"/repo/.codenomad/worktrees\", name: \"new\" }, options)\n await client.worktree.remove({ projectID: \"project\", directory: \"/repo/.codenomad/worktrees/new\", force: false }, options)\n const legacy = version === \"2.0.3\"\n for (const request of requests) {\n assert.equal(request.url.searchParams.get(\"location[directory]\"), legacy ? \"/repo\" : null)\n if (request.method === \"GET\") assert.equal(request.url.searchParams.get(\"projectID\"), legacy ? null : \"project\")\n else assert.equal(request.body.projectID, legacy ? undefined : \"project\")\n }\n assert.equal(requests[1].body.branch, \"revision\")\n assert.equal(requests[1].body.from, \"/source\")\n assert.equal(requests[2].body.directory, \"/repo/.codenomad/worktrees/new\")\n assert.equal(requests[2].body.force, false)\n }\n})\n"]}
@@ -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,KAAK,EAAE,KAAK;QACpE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACpE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACxE,OAAO,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;AACjE,CAAC","sourcesContent":["import type { Endpoint } from \"@opencode/client/service\"\n\nexport interface RuntimeIdentity {\n version: string\n pid: number\n discovery: \"status\" | \"health\"\n /** Filled only by a successful, authenticated schema negotiation. */\n contract?: { profile?: Exclude<ContractProfile, \"unknown\"> }\n}\n\n// Keep authenticated daemon metadata out of public endpoints and credentials.\nconst RUNTIME_IDENTITY = Symbol.for(\"codenomad.opencode.runtime\")\nexport function rememberRuntime(endpoint: Endpoint, identity: RuntimeIdentity): void {\n Object.defineProperty(endpoint, RUNTIME_IDENTITY, { value: Object.freeze({ ...identity, contract: {} }) })\n}\nexport function runtimeIdentity(endpoint: Endpoint): RuntimeIdentity | undefined {\n return (endpoint as Endpoint & { [RUNTIME_IDENTITY]?: RuntimeIdentity })[RUNTIME_IDENTITY]\n}\n\nexport type ContractProfile = \"modern\" | \"legacy\" | \"unknown\"\nexport function contractProfile(identity: RuntimeIdentity | undefined): ContractProfile {\n // Custom embedded/test lifecycles that don't negotiate use the pinned contract.\n if (!identity) return \"modern\"\n if (identity.contract?.profile) return identity.contract.profile\n if (/^2\\.0\\.[0-3]$/.test(identity.version)) return \"legacy\"\n if (/^2\\.0\\.[45]$/.test(identity.version)) return \"modern\"\n const beta = /^0\\.0\\.0-beta-(\\d+)$/.exec(identity.version)?.[1]\n const audited = new Set([18866, 18955, 18965, 18985, 18992, 18999, 19059, 19086,\n 19124, 19129, 19133, 19135, 19151, 19157, 19187, 19192, 19215, 19213,\n 19228, 19234, 19242, 19266, 19271, 19275, 19278, 19283, 19288, 19289,\n 19296, 19365, 19378, 19381, 19398, 19419, 19422, 19425, 19500, 19507])\n return beta && audited.has(Number(beta)) ? \"legacy\" : \"unknown\"\n}\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/runtime.ts"],"names":[],"mappings":"AAUA,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AACjE,MAAM,UAAU,eAAe,CAAC,QAAkB,EAAE,QAAyB;IAC3E,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;AAC5G,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,QAAkB;IAChD,OAAQ,QAAgE,CAAC,gBAAgB,CAAC,CAAA;AAC5F,CAAC;AAGD,MAAM,UAAU,eAAe,CAAC,QAAqC;IACnE,gFAAgF;IAChF,IAAI,CAAC,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC9B,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO;QAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAA;IAChE,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC3D,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC/D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QAC7E,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACpE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACpE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACxE,OAAO,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;AACjE,CAAC","sourcesContent":["import type { Endpoint } from \"@opencode/client/service\"\n\nexport interface RuntimeIdentity {\n version: string\n pid: number\n discovery: \"status\" | \"health\" | \"info\"\n /** Filled only by a successful, authenticated schema negotiation. */\n contract?: { profile?: Exclude<ContractProfile, \"unknown\"> }\n}\n\n// Keep authenticated daemon metadata out of public endpoints and credentials.\nconst RUNTIME_IDENTITY = Symbol.for(\"codenomad.opencode.runtime\")\nexport function rememberRuntime(endpoint: Endpoint, identity: RuntimeIdentity): void {\n Object.defineProperty(endpoint, RUNTIME_IDENTITY, { value: Object.freeze({ ...identity, contract: {} }) })\n}\nexport function runtimeIdentity(endpoint: Endpoint): RuntimeIdentity | undefined {\n return (endpoint as Endpoint & { [RUNTIME_IDENTITY]?: RuntimeIdentity })[RUNTIME_IDENTITY]\n}\n\nexport type ContractProfile = \"modern\" | \"legacy\" | \"unknown\"\nexport function contractProfile(identity: RuntimeIdentity | undefined): ContractProfile {\n // Custom embedded/test lifecycles that don't negotiate use the pinned contract.\n if (!identity) return \"modern\"\n if (identity.contract?.profile) return identity.contract.profile\n if (/^2\\.0\\.[0-3]$/.test(identity.version)) return \"legacy\"\n if (/^2\\.0\\.[45]$/.test(identity.version)) return \"modern\"\n const beta = /^0\\.0\\.0-beta-(\\d+)$/.exec(identity.version)?.[1]\n const audited = new Set([18866, 18955, 18965, 18985, 18992, 18999, 19059, 19086,\n 19124, 19129, 19133, 19135, 19151, 19157, 19187, 19192, 19215, 19213,\n 19228, 19234, 19242, 19266, 19271, 19275, 19278, 19283, 19288, 19289,\n 19296, 19365, 19378, 19381, 19398, 19419, 19422, 19425, 19500, 19507])\n return beta && audited.has(Number(beta)) ? \"legacy\" : \"unknown\"\n}\n"]}
@@ -49,6 +49,9 @@ export function createRuntimeTransport(endpoint, fetcher = globalThis.fetch, lif
49
49
  // Credentialed native requests must never follow a redirect to another host.
50
50
  const options = { method: request.method, headers, signal: AbortSignal.any([request.signal, lifetime]), redirect: "error" };
51
51
  const originalPath = url.pathname;
52
+ if (originalPath === "/api/status" && request.method === "GET" && identity?.discovery === "info") {
53
+ url.pathname = "/api/info";
54
+ }
52
55
  if (profile === "legacy" || headers.has(LOCATION_CONTEXT_HEADER)) {
53
56
  const text = request.body ? await request.text() : undefined;
54
57
  let body = text ? JSON.parse(text) : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAE1E,SAAS,MAAM,CAAC,K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AE,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;QACzF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAAC,OAAM;QAAC,CAAC;QACrD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE;YAC5F,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Service, type Endpoint } from \"@opencode/client/service\"\nimport { contractProfile, runtimeIdentity } from \"./runtime\"\nimport { legacyRequest } from \"./requests\"\nimport { negotiateRuntime } from \"./negotiate\"\nimport { applyLocationContext, LOCATION_CONTEXT_HEADER } from \"./location\"\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value)\n}\n\nfunction normalizeInbox(value: unknown): unknown {\n if (!object(value)) throw new Error(\"Invalid native inbox item\")\n if (object(value.time) && typeof value.time.created === \"number\") return value\n if (typeof value.timeCreated !== \"number\" || !Number.isFinite(value.timeCreated)) {\n throw new Error(\"Invalid native inbox creation time\")\n }\n const { timeCreated, ...rest } = value\n return { ...rest, time: { created: timeCreated } }\n}\n\n// Both the server's generated client and the authorized browser proxy use this\n// transport. No error classification here retries a mutation.\nexport function createRuntimeFetch(endpoint: Endpoint, fetcher: typeof fetch = globalThis.fetch): typeof fetch {\n return createRuntimeTransport(endpoint, fetcher).fetch\n}\n\nexport function createRuntimeTransport(endpoint: Endpoint, fetcher: typeof fetch = globalThis.fetch, lifetime = new AbortController().signal) {\n const identity = runtimeIdentity(endpoint)\n let profile = contractProfile(identity)\n let negotiation: Promise<\"modern\" | \"legacy\"> | undefined\n const resolveProfile = async (signal?: AbortSignal) => {\n signal?.throwIfAborted()\n lifetime.throwIfAborted()\n if (profile !== \"unknown\") return profile\n negotiation ??= negotiateRuntime(endpoint, fetcher, lifetime).then(value => {\n profile = value\n return value\n }).catch(error => { negotiation = undefined; throw error })\n return awaitLocal(negotiation, signal)\n }\n const adaptedFetch: typeof fetch = async (input, init) => {\n const request = new Request(input, init)\n const url = new URL(request.url)\n if (url.origin !== new URL(endpoint.url).origin) throw new Error(\"OpenCode transport origin mismatch\")\n const profile = await resolveProfile(request.signal)\n const headers = new Headers(request.headers)\n for (const [name, value] of Object.entries(Service.headers(endpoint) ?? {})) headers.set(name, value)\n // Credentialed native requests must never follow a redirect to another host.\n const options: RequestInit = { method: request.method, headers, signal: AbortSignal.any([request.signal, lifetime]), redirect: \"error\" }\n const originalPath = url.pathname\n if (profile === \"legacy\" || headers.has(LOCATION_CONTEXT_HEADER)) {\n const text = request.body ? await request.text() : undefined\n let body: unknown = text ? JSON.parse(text) : undefined\n body = applyLocationContext(url, request.method, body, headers, profile)\n if (body !== undefined && !object(body)) throw new Error(\"Invalid OpenCode request body\")\n const translated = profile === \"legacy\" ? legacyRequest(url, request.method, body) : { method: request.method, body }\n options.method = translated.method\n options.body = translated.body === undefined ? undefined : JSON.stringify(translated.body)\n headers.delete(\"content-length\")\n if (options.body === undefined) headers.delete(\"content-type\")\n } else if (request.body) {\n options.body = await request.arrayBuffer()\n }\n const response = await fetcher(url, options)\n if (!response.ok && !response.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await response.body?.cancel()\n return Response.json({\n _tag: \"OpenCodeContractError\", message: `OpenCode ${identity?.version ?? profile}: ${request.method} ${originalPath} returned HTTP ${response.status}`,\n status: response.status, profile, method: request.method, path: originalPath,\n }, { status: response.status })\n }\n if (profile === \"legacy\" && response.ok && originalPath === \"/api/status\") {\n const health = await response.json() as { version: string; pid: number }\n return Response.json({ version: health.version, pid: health.pid, urls: [endpoint.url] })\n }\n if (profile !== \"legacy\" || !response.ok || !/^\\/api\\/session\\/[^/]+\\/(?:inbox|prompt|synthetic|compact)$/.test(originalPath)\n || response.status === 204) return response\n const value: unknown = await response.json()\n if (!object(value)) throw new Error(\"Invalid native inbox response\")\n const normalized = { ...value, data: Array.isArray(value.data) ? value.data.map(normalizeInbox) : normalizeInbox(value.data) }\n const responseHeaders = new Headers(response.headers)\n responseHeaders.delete(\"content-length\")\n responseHeaders.delete(\"content-encoding\")\n return new Response(JSON.stringify(normalized), { status: response.status, headers: responseHeaders })\n }\n return { fetch: adaptedFetch, profile: resolveProfile }\n}\n\n// A cancelled subscriber must not cancel the connection's negotiation or wait\n// for another subscriber's request to finish before observing its own abort.\nfunction awaitLocal<T>(pending: Promise<T>, signal?: AbortSignal): Promise<T> {\n if (!signal) return pending\n return new Promise<T>((resolve, reject) => {\n const abort = () => { signal.removeEventListener(\"abort\", abort); reject(signal.reason) }\n if (signal.aborted) { reject(signal.reason); return }\n signal.addEventListener(\"abort\", abort, { once: true })\n pending.then(value => { signal.removeEventListener(\"abort\", abort); resolve(value) }, error => {\n signal.removeEventListener(\"abort\", abort); reject(error)\n })\n })\n}\n"]}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/opencode/compatibility/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa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AAE,OAAO,EAAE,cAAc,EAAE,CAAA;AACzD,CAAC;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,SAAS,UAAU,CAAI,OAAmB,EAAE,MAAoB;IAC9D,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAA;IAC3B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,KAAK,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA,CAAC,CAAC,CAAA;QACzF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAAC,OAAM;QAAC,CAAC;QACrD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE;YAC5F,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3D,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Service, type Endpoint } from \"@opencode/client/service\"\nimport { contractProfile, runtimeIdentity } from \"./runtime\"\nimport { legacyRequest } from \"./requests\"\nimport { negotiateRuntime } from \"./negotiate\"\nimport { applyLocationContext, LOCATION_CONTEXT_HEADER } from \"./location\"\n\nfunction object(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value)\n}\n\nfunction normalizeInbox(value: unknown): unknown {\n if (!object(value)) throw new Error(\"Invalid native inbox item\")\n if (object(value.time) && typeof value.time.created === \"number\") return value\n if (typeof value.timeCreated !== \"number\" || !Number.isFinite(value.timeCreated)) {\n throw new Error(\"Invalid native inbox creation time\")\n }\n const { timeCreated, ...rest } = value\n return { ...rest, time: { created: timeCreated } }\n}\n\n// Both the server's generated client and the authorized browser proxy use this\n// transport. No error classification here retries a mutation.\nexport function createRuntimeFetch(endpoint: Endpoint, fetcher: typeof fetch = globalThis.fetch): typeof fetch {\n return createRuntimeTransport(endpoint, fetcher).fetch\n}\n\nexport function createRuntimeTransport(endpoint: Endpoint, fetcher: typeof fetch = globalThis.fetch, lifetime = new AbortController().signal) {\n const identity = runtimeIdentity(endpoint)\n let profile = contractProfile(identity)\n let negotiation: Promise<\"modern\" | \"legacy\"> | undefined\n const resolveProfile = async (signal?: AbortSignal) => {\n signal?.throwIfAborted()\n lifetime.throwIfAborted()\n if (profile !== \"unknown\") return profile\n negotiation ??= negotiateRuntime(endpoint, fetcher, lifetime).then(value => {\n profile = value\n return value\n }).catch(error => { negotiation = undefined; throw error })\n return awaitLocal(negotiation, signal)\n }\n const adaptedFetch: typeof fetch = async (input, init) => {\n const request = new Request(input, init)\n const url = new URL(request.url)\n if (url.origin !== new URL(endpoint.url).origin) throw new Error(\"OpenCode transport origin mismatch\")\n const profile = await resolveProfile(request.signal)\n const headers = new Headers(request.headers)\n for (const [name, value] of Object.entries(Service.headers(endpoint) ?? {})) headers.set(name, value)\n // Credentialed native requests must never follow a redirect to another host.\n const options: RequestInit = { method: request.method, headers, signal: AbortSignal.any([request.signal, lifetime]), redirect: \"error\" }\n const originalPath = url.pathname\n if (originalPath === \"/api/status\" && request.method === \"GET\" && identity?.discovery === \"info\") {\n url.pathname = \"/api/info\"\n }\n if (profile === \"legacy\" || headers.has(LOCATION_CONTEXT_HEADER)) {\n const text = request.body ? await request.text() : undefined\n let body: unknown = text ? JSON.parse(text) : undefined\n body = applyLocationContext(url, request.method, body, headers, profile)\n if (body !== undefined && !object(body)) throw new Error(\"Invalid OpenCode request body\")\n const translated = profile === \"legacy\" ? legacyRequest(url, request.method, body) : { method: request.method, body }\n options.method = translated.method\n options.body = translated.body === undefined ? undefined : JSON.stringify(translated.body)\n headers.delete(\"content-length\")\n if (options.body === undefined) headers.delete(\"content-type\")\n } else if (request.body) {\n options.body = await request.arrayBuffer()\n }\n const response = await fetcher(url, options)\n if (!response.ok && !response.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await response.body?.cancel()\n return Response.json({\n _tag: \"OpenCodeContractError\", message: `OpenCode ${identity?.version ?? profile}: ${request.method} ${originalPath} returned HTTP ${response.status}`,\n status: response.status, profile, method: request.method, path: originalPath,\n }, { status: response.status })\n }\n if (profile === \"legacy\" && response.ok && originalPath === \"/api/status\") {\n const health = await response.json() as { version: string; pid: number }\n return Response.json({ version: health.version, pid: health.pid, urls: [endpoint.url] })\n }\n if (profile !== \"legacy\" || !response.ok || !/^\\/api\\/session\\/[^/]+\\/(?:inbox|prompt|synthetic|compact)$/.test(originalPath)\n || response.status === 204) return response\n const value: unknown = await response.json()\n if (!object(value)) throw new Error(\"Invalid native inbox response\")\n const normalized = { ...value, data: Array.isArray(value.data) ? value.data.map(normalizeInbox) : normalizeInbox(value.data) }\n const responseHeaders = new Headers(response.headers)\n responseHeaders.delete(\"content-length\")\n responseHeaders.delete(\"content-encoding\")\n return new Response(JSON.stringify(normalized), { status: response.status, headers: responseHeaders })\n }\n return { fetch: adaptedFetch, profile: resolveProfile }\n}\n\n// A cancelled subscriber must not cancel the connection's negotiation or wait\n// for another subscriber's request to finish before observing its own abort.\nfunction awaitLocal<T>(pending: Promise<T>, signal?: AbortSignal): Promise<T> {\n if (!signal) return pending\n return new Promise<T>((resolve, reject) => {\n const abort = () => { signal.removeEventListener(\"abort\", abort); reject(signal.reason) }\n if (signal.aborted) { reject(signal.reason); return }\n signal.addEventListener(\"abort\", abort, { once: true })\n pending.then(value => { signal.removeEventListener(\"abort\", abort); resolve(value) }, error => {\n signal.removeEventListener(\"abort\", abort); reject(error)\n })\n })\n}\n"]}
@@ -5,6 +5,46 @@ import { test } from "node:test";
5
5
  import { OpenCode } from "@opencode/client";
6
6
  import { rememberRuntime } from "./runtime";
7
7
  import { createRuntimeFetch } from "./transport";
8
+ import { modernContractFixture } from "./contract-fixture";
9
+ test("the pinned status client follows the discovered route across legacy, modern and info runtimes", async () => {
10
+ for (const [version, discovery, route] of [
11
+ ["2.0.0", "health", "/api/health"],
12
+ ["2.0.4", "status", "/api/status"],
13
+ ["2.0.7", "info", "/api/info"],
14
+ ["future-release", "info", "/api/info"],
15
+ ]) {
16
+ const endpoint = { url: "http://127.0.0.1:4321", auth: { type: "basic", username: "opencode", password: "fixture" } };
17
+ rememberRuntime(endpoint, { version, pid: 123, discovery });
18
+ const seen = [];
19
+ const fetch = createRuntimeFetch(endpoint, async (input, init) => {
20
+ const path = new URL(String(input)).pathname;
21
+ seen.push(path);
22
+ assert.equal(init?.redirect, "error");
23
+ assert.equal(new Headers(init?.headers).get("authorization"), `Basic ${Buffer.from("opencode:fixture").toString("base64")}`);
24
+ if (path === "/openapi.json")
25
+ return Response.json(modernContractFixture);
26
+ assert.equal(path, route);
27
+ return Response.json(discovery === "health" ? { healthy: true, version, pid: 123 } : { version, pid: 123, urls: [endpoint.url] });
28
+ });
29
+ const client = OpenCode.make({ baseUrl: endpoint.url, fetch });
30
+ assert.deepEqual(await client.server.status(), { version, pid: 123, urls: [endpoint.url] });
31
+ assert.deepEqual(seen, discovery === "info" ? ["/openapi.json", route] : [route]);
32
+ }
33
+ });
34
+ test("info translation is GET-only and does not probe alternate routes on failure", async () => {
35
+ const endpoint = { url: "http://127.0.0.1:4321" };
36
+ rememberRuntime(endpoint, { version: "2.0.7", pid: 123, discovery: "info" });
37
+ const seen = [];
38
+ const fetch = createRuntimeFetch(endpoint, async (input, init) => {
39
+ const path = new URL(String(input)).pathname;
40
+ seen.push(`${init?.method ?? "GET"} ${path}`);
41
+ return path === "/openapi.json" ? Response.json(modernContractFixture) : new Response(null, { status: 404 });
42
+ });
43
+ const client = OpenCode.make({ baseUrl: endpoint.url, fetch });
44
+ await assert.rejects(client.server.status());
45
+ await fetch(`${endpoint.url}/api/status`, { method: "POST" });
46
+ assert.deepEqual(seen, ["GET /openapi.json", "GET /api/info", "POST /api/status"]);
47
+ });
8
48
  test("the pinned client uses the earlier wire contract and retains admission/list timestamps", async () => {
9
49
  const seen = [];
10
50
  const item = { id: "inbox-fixture", sessionID: "s", type: "user", payload: { text: "fixture" }, delivery: "queue", timeCreated: 123 };