@agent-spaces/server 0.3.4 → 0.3.6

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 (288) hide show
  1. package/dist/adapters/claude-code-runtime/index.js +19 -1
  2. package/dist/adapters/codex-runtime.js +13 -3
  3. package/dist/agents/agent-message-parts.js +9 -1
  4. package/dist/agents/commit-agent.js +7 -15
  5. package/dist/app.js +26 -0
  6. package/dist/package.json +3 -1
  7. package/dist/routes/code-favorites.js +60 -0
  8. package/dist/routes/file.js +13 -0
  9. package/dist/routes/prompt-template.js +48 -0
  10. package/dist/services/agent.js +45 -3
  11. package/dist/services/code-favorites.js +23 -0
  12. package/dist/services/file.js +4 -0
  13. package/dist/services/persistent-agent-context.js +3 -2
  14. package/dist/services/prompt-template.js +93 -0
  15. package/dist/services/pty.js +18 -1
  16. package/dist/storage/code-favorites-store.js +15 -0
  17. package/dist/web/404.html +1 -1
  18. package/dist/web/__next.__PAGE__.txt +4 -4
  19. package/dist/web/__next._full.txt +21 -21
  20. package/dist/web/__next._head.txt +4 -4
  21. package/dist/web/__next._index.txt +13 -13
  22. package/dist/web/__next._tree.txt +2 -2
  23. package/dist/web/_next/static/chunks/0-1pn22sg~67u.js +2 -0
  24. package/dist/web/_next/static/chunks/0-lseun2l1m_t.js +2 -0
  25. package/dist/web/_next/static/chunks/0-wkj-hzh444r.css +4 -0
  26. package/dist/web/_next/static/chunks/{0f6vrjsdauiwl.js → 0-~4vw4_9z_0_.js} +2 -2
  27. package/dist/web/_next/static/chunks/0..g0jl-8qup7.js +1 -0
  28. package/dist/web/_next/static/chunks/0.006.ycpe92w.js +496 -0
  29. package/dist/web/_next/static/chunks/0.6x8f.mb-1qf.js +1 -0
  30. package/dist/web/_next/static/chunks/{0qe5wvs8fe9ip.js → 004wt62de8617.js} +1 -1
  31. package/dist/web/_next/static/chunks/016xz2o-hv3am.js +1 -0
  32. package/dist/web/_next/static/chunks/01gi~q0c6ez6..js +1 -0
  33. package/dist/web/_next/static/chunks/023lpc7n70tav.css +1 -0
  34. package/dist/web/_next/static/chunks/03me5_ir..2ix.js +1 -0
  35. package/dist/web/_next/static/chunks/04fk~8rnrvs44.js +1 -0
  36. package/dist/web/_next/static/chunks/05eu2fdixf7c9.js +1 -0
  37. package/dist/web/_next/static/chunks/05gt_g_vbzh-5.css +1 -0
  38. package/dist/web/_next/static/chunks/06vadtvw631k5.css +1 -0
  39. package/dist/web/_next/static/chunks/07ge_85i__6pb.js +1 -0
  40. package/dist/web/_next/static/chunks/07ne4g8zopykv.js +1 -0
  41. package/dist/web/_next/static/chunks/07xvadmf~8bow.js +1 -0
  42. package/dist/web/_next/static/chunks/08.u~dmq20cak.css +23 -0
  43. package/dist/web/_next/static/chunks/{03sd~wmqw.9gc.js → 08kpa0nox.bb1.js} +2 -2
  44. package/dist/web/_next/static/chunks/08o-zmr-40r5g.js +1 -0
  45. package/dist/web/_next/static/chunks/0_-c.y2qq4ax4.js +270 -0
  46. package/dist/web/_next/static/chunks/0a1rewz7xr-xi.js +1 -0
  47. package/dist/web/_next/static/chunks/0amcocbojo4v2.js +1 -0
  48. package/dist/web/_next/static/chunks/0brrgp3ki5w4_.css +17 -0
  49. package/dist/web/_next/static/chunks/0bzmgi.ynrn.0.css +3 -0
  50. package/dist/web/_next/static/chunks/0c_vfzf1z7-rt.js +2 -0
  51. package/dist/web/_next/static/chunks/0cjmfclopcxho.css +1 -0
  52. package/dist/web/_next/static/chunks/0cs830n97dgjy.js +1 -0
  53. package/dist/web/_next/static/chunks/0d_dp_4ofz0l3.css +3 -0
  54. package/dist/web/_next/static/chunks/0dws-faof-ryx.css +13 -0
  55. package/dist/web/_next/static/chunks/0ejc_zlyocy_r.css +1 -0
  56. package/dist/web/_next/static/chunks/0esty_4gmxfq3.js +1 -0
  57. package/dist/web/_next/static/chunks/0evjw7bao5_e~.js +1 -0
  58. package/dist/web/_next/static/chunks/{0ag4p6m9rze~n.js → 0g-0n6glz_z6w.js} +1 -1
  59. package/dist/web/_next/static/chunks/{145qu5b0tgm9w.js → 0gig.k.rq8d0x.js} +1 -1
  60. package/dist/web/_next/static/chunks/0hl_7y464qll6.css +2 -0
  61. package/dist/web/_next/static/chunks/0hrbuvzuxrjfl.js +1 -0
  62. package/dist/web/_next/static/chunks/0i_3.3rdsu2mw.js +2 -0
  63. package/dist/web/_next/static/chunks/0i_gi.kq2dau8.css +1 -0
  64. package/dist/web/_next/static/chunks/0j00r2f_n-.lx.js +1 -0
  65. package/dist/web/_next/static/chunks/0jh9xnkimjkyh.js +1 -0
  66. package/dist/web/_next/static/chunks/0jokpgh485~28.js +167 -0
  67. package/dist/web/_next/static/chunks/0kvsjgpj7zcb9.css +9 -0
  68. package/dist/web/_next/static/chunks/0l5ab99s37x5f.js +1 -0
  69. package/dist/web/_next/static/chunks/0lcc9r.o.p.sc.js +1 -0
  70. package/dist/web/_next/static/chunks/0lh~x2tf~i1hd.css +2 -0
  71. package/dist/web/_next/static/chunks/0me8ho8j4tq7_.css +2 -0
  72. package/dist/web/_next/static/chunks/0mny8i81aenx3.js +1 -0
  73. package/dist/web/_next/static/chunks/0mt-7av8yrg0o.css +3 -0
  74. package/dist/web/_next/static/chunks/0njy89g5coeyi.js +60 -0
  75. package/dist/web/_next/static/chunks/0nsu~f3voe~0i.js +5 -0
  76. package/dist/web/_next/static/chunks/0ow~co9wcleka.js +173 -0
  77. package/dist/web/_next/static/chunks/0pldvk5_h__t7.css +3 -0
  78. package/dist/web/_next/static/chunks/0qad.lgvtlt0b.css +16 -0
  79. package/dist/web/_next/static/chunks/0qpq0~_58fe9a.js +18 -0
  80. package/dist/web/_next/static/chunks/{0.335m_d-cd_g.js → 0qtc_rbo1oghu.js} +1 -1
  81. package/dist/web/_next/static/chunks/0qz5~3wquy~3q.css +2 -0
  82. package/dist/web/_next/static/chunks/0rv0nj__24y60.js +10 -0
  83. package/dist/web/_next/static/chunks/{145gbwitjxamg.js → 0sz8_nijfiz0p.js} +1 -1
  84. package/dist/web/_next/static/chunks/0tvd~rxgf0oh_.js +1 -0
  85. package/dist/web/_next/static/chunks/0wv0h27jafag4.js +1 -0
  86. package/dist/web/_next/static/chunks/0wwvc4zc2q6bn.js +1 -0
  87. package/dist/web/_next/static/chunks/0x4b-a2ixww6m.js +1 -0
  88. package/dist/web/_next/static/chunks/0z8ipjj2z-3al.css +8 -0
  89. package/dist/web/_next/static/chunks/0zd1o3u04~qvo.js +127 -0
  90. package/dist/web/_next/static/chunks/0~2l1-8o4delc.js +1 -0
  91. package/dist/web/_next/static/chunks/0~w6ugk9s5p-h.css +1 -0
  92. package/dist/web/_next/static/chunks/10jfi.9fw5g48.js +1 -0
  93. package/dist/web/_next/static/chunks/11_tltlhc8.sj.js +1 -0
  94. package/dist/web/_next/static/chunks/125nunjfj2fj0.js +1 -0
  95. package/dist/web/_next/static/chunks/1285yqy_oirb-.js +1 -0
  96. package/dist/web/_next/static/chunks/12md9ajfx2o85.css +1 -0
  97. package/dist/web/_next/static/chunks/12odetnu-lyrr.js +167 -0
  98. package/dist/web/_next/static/chunks/12u4g4uzrlten.js +2 -0
  99. package/dist/web/_next/static/chunks/134ozsnbd~0qw.js +1 -0
  100. package/dist/web/_next/static/chunks/13ess~4pdmxma.js +1 -0
  101. package/dist/web/_next/static/chunks/13xfagjq0q~tf.js +1 -0
  102. package/dist/web/_next/static/chunks/143.pbs8a1ivm.js +1 -0
  103. package/dist/web/_next/static/chunks/14_y_s_5rhsd1.css +5 -0
  104. package/dist/web/_next/static/chunks/15hca2.5le07..js +3 -0
  105. package/dist/web/_next/static/chunks/15rf3~h7sugz4.css +19 -0
  106. package/dist/web/_next/static/chunks/16i87txo0qh0h.css +6 -0
  107. package/dist/web/_next/static/chunks/16~udgv7eel6a.css +2 -0
  108. package/dist/web/_next/static/chunks/{turbopack-0-j2hpomozegf.js → turbopack-000x5q9w-wx10.js} +1 -1
  109. package/dist/web/_next/static/chunks/{turbopack-0rrhp9pbrv0p3.js → turbopack-0hrx111grzq49.js} +1 -1
  110. package/dist/web/_next/static/chunks/{turbopack-0_zn00zg5kmqz.js → turbopack-0w-kua.9ymd0x.js} +1 -1
  111. package/dist/web/_next/static/chunks/{turbopack-0l~pq1hytx49z.js → turbopack-15zqm_4ixj.18.js} +1 -1
  112. package/dist/web/_next/static/media/code-icon.0g3wskzlr7oxf.svg +1 -0
  113. package/dist/web/_next/static/media/codicon.0pqe-t5rtghj8.ttf +0 -0
  114. package/dist/web/_next/static/media/continue-tb.0qei4mru4tzd2.png +0 -0
  115. package/dist/web/_next/static/media/dark_modern.09.uq6bp373zs.json +1 -0
  116. package/dist/web/_next/static/media/dark_plus.187umr0~d1_r7.json +1 -0
  117. package/dist/web/_next/static/media/dark_vs.12ju8ocr7rg--.json +1 -0
  118. package/dist/web/_next/static/media/document-dark.0vvlbsi_fdy~4.svg +3 -0
  119. package/dist/web/_next/static/media/document-light.0bfi_yt9e~vk7.svg +3 -0
  120. package/dist/web/_next/static/media/editor.worker.0ffjdaaj15t6e.js +1 -0
  121. package/dist/web/_next/static/media/extensionHost.worker.14sz5xf8-1efr.js +2 -0
  122. package/dist/web/_next/static/media/fake.16yx0-xxqj4pc.html +10 -0
  123. package/dist/web/_next/static/media/folder-dark.02kdicw3013tb.svg +3 -0
  124. package/dist/web/_next/static/media/folder-light.0s165k4fp3.53.svg +3 -0
  125. package/dist/web/_next/static/media/folder-open-dark.0sk6.yh45uqs3.svg +4 -0
  126. package/dist/web/_next/static/media/folder-open-light.10k1v_ugaq8ic.svg +4 -0
  127. package/dist/web/_next/static/media/hc_black.0-ul9e2oc5twb.json +1 -0
  128. package/dist/web/_next/static/media/hc_light.0vi.a7fr.z4gy.json +1 -0
  129. package/dist/web/_next/static/media/index.0jmafs_mwcjgg.html +1341 -0
  130. package/dist/web/_next/static/media/keyboard-dark.0t86n~1rrhj2-.svg +10 -0
  131. package/dist/web/_next/static/media/keyboard-light.0abw0ukjcd9ox.svg +10 -0
  132. package/dist/web/_next/static/media/letterpress-dark.181s2xkw~lfyo.svg +3 -0
  133. package/dist/web/_next/static/media/letterpress-hcDark.0ftfw8fess-5y.svg +3 -0
  134. package/dist/web/_next/static/media/letterpress-hcLight.06x23d0.aixf_.svg +3 -0
  135. package/dist/web/_next/static/media/letterpress-light.0xb1bapis~iw7.svg +3 -0
  136. package/dist/web/_next/static/media/light_modern.00ps-apoc9ph7.json +1 -0
  137. package/dist/web/_next/static/media/light_plus.0ow37ouyuazdz.json +1 -0
  138. package/dist/web/_next/static/media/light_vs.0fdbve5sxkgq1.json +1 -0
  139. package/dist/web/_next/static/media/onig.0dk~55st~1x8..wasm +0 -0
  140. package/dist/web/_next/static/media/opacity-background.0-9.t0ta0ko23.png +0 -0
  141. package/dist/web/_next/static/media/package.0_p8a~hpmb_uj.json +1 -0
  142. package/dist/web/_next/static/media/package.nls.0e5hn-g497b64.json +1 -0
  143. package/dist/web/_next/static/media/pause-tb.0ttrm1r1uuz_c.png +0 -0
  144. package/dist/web/_next/static/media/restart-tb.086872s_sc2qv.png +0 -0
  145. package/dist/web/_next/static/media/root-folder-dark.14iwnfb7p2na~.svg +5 -0
  146. package/dist/web/_next/static/media/root-folder-light.0ljk9fi7sw3.2.svg +5 -0
  147. package/dist/web/_next/static/media/root-folder-open-dark.08vw3g9zvki33.svg +5 -0
  148. package/dist/web/_next/static/media/root-folder-open-light.0f46.ahns5c~..svg +5 -0
  149. package/dist/web/_next/static/media/run-with-debugging-tb.0j1h52k~h~72z.png +0 -0
  150. package/dist/web/_next/static/media/service-worker.0_udu6mraxn4k.js +543 -0
  151. package/dist/web/_next/static/media/stepinto-tb.0cl87yt4ub_j8.png +0 -0
  152. package/dist/web/_next/static/media/stepout-tb.0vjib_bn-_xax.png +0 -0
  153. package/dist/web/_next/static/media/stepover-tb.04beeu~7cxr4l.png +0 -0
  154. package/dist/web/_next/static/media/stop-tb.1498tmu97_y9j.png +0 -0
  155. package/dist/web/_next/static/media/vs_minimal-icon-theme.0-qs73lvw4voi.json +1 -0
  156. package/dist/web/_next/static/media/webWorkerExtensionHostIframe.0x2r1o97s.m0m.html +156 -0
  157. package/dist/web/_next/static/media/worker.081j0x4avp1l1.js +2 -0
  158. package/dist/web/_not-found/__next._full.txt +19 -19
  159. package/dist/web/_not-found/__next._head.txt +4 -4
  160. package/dist/web/_not-found/__next._index.txt +13 -13
  161. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  162. package/dist/web/_not-found/__next._not-found.txt +3 -3
  163. package/dist/web/_not-found/__next._tree.txt +2 -2
  164. package/dist/web/_not-found.html +1 -1
  165. package/dist/web/_not-found.txt +19 -19
  166. package/dist/web/index.html +1 -1
  167. package/dist/web/index.txt +21 -21
  168. package/dist/web/login/__next._full.txt +21 -21
  169. package/dist/web/login/__next._head.txt +4 -4
  170. package/dist/web/login/__next._index.txt +13 -13
  171. package/dist/web/login/__next._tree.txt +2 -2
  172. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  173. package/dist/web/login/__next.login.txt +3 -3
  174. package/dist/web/login.html +1 -1
  175. package/dist/web/login.txt +21 -21
  176. package/dist/web/settings/__next._full.txt +23 -23
  177. package/dist/web/settings/__next._head.txt +4 -4
  178. package/dist/web/settings/__next._index.txt +13 -13
  179. package/dist/web/settings/__next._tree.txt +2 -2
  180. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  181. package/dist/web/settings/__next.settings.txt +5 -5
  182. package/dist/web/settings/agents/__next._full.txt +23 -23
  183. package/dist/web/settings/agents/__next._head.txt +4 -4
  184. package/dist/web/settings/agents/__next._index.txt +13 -13
  185. package/dist/web/settings/agents/__next._tree.txt +2 -2
  186. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  187. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  188. package/dist/web/settings/agents/__next.settings.txt +5 -5
  189. package/dist/web/settings/agents.html +1 -1
  190. package/dist/web/settings/agents.txt +23 -23
  191. package/dist/web/settings/mcps/__next._full.txt +23 -23
  192. package/dist/web/settings/mcps/__next._head.txt +4 -4
  193. package/dist/web/settings/mcps/__next._index.txt +13 -13
  194. package/dist/web/settings/mcps/__next._tree.txt +2 -2
  195. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  196. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  197. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  198. package/dist/web/settings/mcps.html +1 -1
  199. package/dist/web/settings/mcps.txt +23 -23
  200. package/dist/web/settings/models/__next._full.txt +23 -23
  201. package/dist/web/settings/models/__next._head.txt +4 -4
  202. package/dist/web/settings/models/__next._index.txt +13 -13
  203. package/dist/web/settings/models/__next._tree.txt +2 -2
  204. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  205. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  206. package/dist/web/settings/models/__next.settings.txt +5 -5
  207. package/dist/web/settings/models.html +1 -1
  208. package/dist/web/settings/models.txt +23 -23
  209. package/dist/web/settings/prompts/__next._full.txt +42 -0
  210. package/dist/web/settings/prompts/__next._head.txt +6 -0
  211. package/dist/web/settings/prompts/__next._index.txt +15 -0
  212. package/dist/web/settings/prompts/__next._tree.txt +8 -0
  213. package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +9 -0
  214. package/dist/web/settings/prompts/__next.settings.prompts.txt +5 -0
  215. package/dist/web/settings/prompts/__next.settings.txt +7 -0
  216. package/dist/web/settings/prompts.html +1 -0
  217. package/dist/web/settings/prompts.txt +42 -0
  218. package/dist/web/settings/providers/__next._full.txt +23 -23
  219. package/dist/web/settings/providers/__next._head.txt +4 -4
  220. package/dist/web/settings/providers/__next._index.txt +13 -13
  221. package/dist/web/settings/providers/__next._tree.txt +2 -2
  222. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  223. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  224. package/dist/web/settings/providers/__next.settings.txt +5 -5
  225. package/dist/web/settings/providers.html +1 -1
  226. package/dist/web/settings/providers.txt +23 -23
  227. package/dist/web/settings/skills/__next._full.txt +23 -23
  228. package/dist/web/settings/skills/__next._head.txt +4 -4
  229. package/dist/web/settings/skills/__next._index.txt +13 -13
  230. package/dist/web/settings/skills/__next._tree.txt +2 -2
  231. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  232. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  233. package/dist/web/settings/skills/__next.settings.txt +5 -5
  234. package/dist/web/settings/skills.html +1 -1
  235. package/dist/web/settings/skills.txt +23 -23
  236. package/dist/web/settings.html +1 -1
  237. package/dist/web/settings.txt +23 -23
  238. package/dist/web/workflows/__next._full.txt +21 -21
  239. package/dist/web/workflows/__next._head.txt +4 -4
  240. package/dist/web/workflows/__next._index.txt +13 -13
  241. package/dist/web/workflows/__next._tree.txt +2 -2
  242. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  243. package/dist/web/workflows/__next.workflows.txt +3 -3
  244. package/dist/web/workflows.html +1 -1
  245. package/dist/web/workflows.txt +21 -21
  246. package/dist/web/workspace/_/__next._full.txt +68 -35
  247. package/dist/web/workspace/_/__next._head.txt +4 -4
  248. package/dist/web/workspace/_/__next._index.txt +13 -13
  249. package/dist/web/workspace/_/__next._tree.txt +15 -3
  250. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +16 -4
  251. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  252. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  253. package/dist/web/workspace/_.html +1 -1
  254. package/dist/web/workspace/_.txt +68 -35
  255. package/dist/web/workspaces/__next._full.txt +21 -21
  256. package/dist/web/workspaces/__next._head.txt +4 -4
  257. package/dist/web/workspaces/__next._index.txt +13 -13
  258. package/dist/web/workspaces/__next._tree.txt +2 -2
  259. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  260. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  261. package/dist/web/workspaces.html +1 -1
  262. package/dist/web/workspaces.txt +21 -21
  263. package/dist/ws/agent-runner.js +158 -20
  264. package/dist/ws/handler.js +6 -1
  265. package/dist/ws/message-parts.js +20 -1
  266. package/dist/ws/terminal-handler.js +12 -7
  267. package/dist/ws/typescript-lsp.js +78 -0
  268. package/package.json +13 -10
  269. package/dist/web/_next/static/chunks/0-a17~4piefz_.js +0 -1
  270. package/dist/web/_next/static/chunks/01tyftu_-l7tm.css +0 -1
  271. package/dist/web/_next/static/chunks/028b9_5cyq-_m.js +0 -1
  272. package/dist/web/_next/static/chunks/0anuxr11yn5iv.js +0 -2
  273. package/dist/web/_next/static/chunks/0e.z4v3cd78dx.js +0 -1
  274. package/dist/web/_next/static/chunks/0egot8y~i-ge3.js +0 -1
  275. package/dist/web/_next/static/chunks/0eq7wt-l.fetc.js +0 -1
  276. package/dist/web/_next/static/chunks/0gtbd3yt7y1gx.js +0 -1
  277. package/dist/web/_next/static/chunks/0j2w71psq6w9u.js +0 -1
  278. package/dist/web/_next/static/chunks/0kyv5yika-41a.js +0 -1
  279. package/dist/web/_next/static/chunks/0ms3tsu4men_j.js +0 -204
  280. package/dist/web/_next/static/chunks/0plreh4_gkxf9.js +0 -1
  281. package/dist/web/_next/static/chunks/0qxk21zejhdbm.js +0 -1
  282. package/dist/web/_next/static/chunks/12gvpt~z9mn8w.js +0 -1
  283. package/dist/web/_next/static/chunks/14iaqoj9-09g..js +0 -2
  284. package/dist/web/_next/static/chunks/15dyaigebtnwg.js +0 -5
  285. package/dist/web/_next/static/chunks/17oc2l.ekcs8b.css +0 -1
  286. /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_buildManifest.js +0 -0
  287. /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_clientMiddlewareManifest.js +0 -0
  288. /package/dist/web/_next/static/{O5-QCW1u2YNyAUyaoYh6s → HUlYEknPhyW7dRmJ5mFdG}/_ssgManifest.js +0 -0
@@ -0,0 +1,543 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ //@ts-check
6
+ /// <reference lib="webworker" />
7
+
8
+ /** @type {ServiceWorkerGlobalScope} */
9
+ const sw = /** @type {any} */ (self);
10
+
11
+ const VERSION = 4;
12
+
13
+ const resourceCacheName = `vscode-resource-cache-${VERSION}`;
14
+
15
+ const rootPath = sw.location.pathname.replace(/\/service-worker.js$/, '');
16
+
17
+ const searchParams = new URL(location.toString()).searchParams;
18
+
19
+ const remoteAuthority = searchParams.get('remoteAuthority');
20
+
21
+ /** @type {MessagePort|undefined} */
22
+ let outerIframeMessagePort;
23
+
24
+ /**
25
+ * Origin used for resources
26
+ */
27
+ const resourceBaseAuthority = searchParams.get('vscode-resource-base-authority');
28
+
29
+ /**
30
+ * @param {string} name
31
+ * @param {Record<string, string>} [options]
32
+ */
33
+ const perfMark = (name, options = {}) => {
34
+ performance.mark(`webview/service-worker/${name}`, {
35
+ detail: {
36
+ ...options
37
+ }
38
+ });
39
+ };
40
+
41
+ perfMark('scriptStart');
42
+
43
+ /** @type {number} */
44
+ const resolveTimeout = 30_000;
45
+
46
+
47
+ /**
48
+ * @template T
49
+ * @typedef {{ status: 'ok', value: T } | { status: 'timeout' }} RequestStoreResult
50
+ */
51
+
52
+
53
+ /**
54
+ * @template T
55
+ * @typedef {{ resolve: (x: RequestStoreResult<T>) => void, promise: Promise<RequestStoreResult<T>> }} RequestStoreEntry
56
+ */
57
+
58
+
59
+ /**
60
+ * @template T
61
+ */
62
+ class RequestStore {
63
+ constructor() {
64
+ /** @type {Map<number, RequestStoreEntry<T>>} */
65
+ this.map = new Map();
66
+ /** @type {number} */
67
+ this.requestPool = 0;
68
+ }
69
+
70
+ /**
71
+ * @returns {{ requestId: number, promise: Promise<RequestStoreResult<T>> }}
72
+ */
73
+ create() {
74
+ const requestId = ++this.requestPool;
75
+
76
+ /** @type {(x: RequestStoreResult<T>) => void} */
77
+ let resolve;
78
+ const promise = new Promise(r => resolve = r);
79
+
80
+ /** @type {RequestStoreEntry<T>} */
81
+ const entry = { resolve, promise };
82
+ this.map.set(requestId, entry);
83
+
84
+ const dispose = () => {
85
+ clearTimeout(timeout);
86
+ const existingEntry = this.map.get(requestId);
87
+ if (existingEntry === entry) {
88
+ existingEntry.resolve({ status: 'timeout' });
89
+ this.map.delete(requestId);
90
+ }
91
+ };
92
+ const timeout = setTimeout(dispose, resolveTimeout);
93
+ return { requestId, promise };
94
+ }
95
+
96
+ /**
97
+ * @param {number} requestId
98
+ * @param {T} result
99
+ * @returns {boolean}
100
+ */
101
+ resolve(requestId, result) {
102
+ const entry = this.map.get(requestId);
103
+ if (!entry) {
104
+ return false;
105
+ }
106
+ entry.resolve({ status: 'ok', value: result });
107
+ this.map.delete(requestId);
108
+ return true;
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Map of requested paths to responses.
114
+ */
115
+ /** @type {RequestStore<ResourceResponse>} */
116
+ const resourceRequestStore = new RequestStore();
117
+
118
+ /**
119
+ * Map of requested localhost origins to optional redirects.
120
+ */
121
+ /** @type {RequestStore<string|undefined>} */
122
+ const localhostRequestStore = new RequestStore();
123
+
124
+ const unauthorized = () =>
125
+ new Response('Unauthorized', { status: 401, });
126
+
127
+ const notFound = () =>
128
+ new Response('Not Found', { status: 404, });
129
+
130
+ const methodNotAllowed = () =>
131
+ new Response('Method Not Allowed', { status: 405, });
132
+
133
+ const requestTimeout = () =>
134
+ new Response('Request Timeout', { status: 408, });
135
+
136
+ sw.addEventListener('message', async (event) => {
137
+ if (!event.source) {
138
+ return;
139
+ }
140
+
141
+ /** @type {Client} */
142
+ const source = event.source;
143
+ switch (event.data.channel) {
144
+ case 'version': {
145
+ perfMark('version/request');
146
+ outerIframeMessagePort = event.ports[0];
147
+ sw.clients.get(source.id).then(client => {
148
+ perfMark('version/reply');
149
+ if (client) {
150
+ client.postMessage({
151
+ channel: 'version',
152
+ version: VERSION
153
+ });
154
+ }
155
+ });
156
+ return;
157
+ }
158
+ case 'did-load-resource': {
159
+ /** @type {ResourceResponse} */
160
+ const response = event.data.data;
161
+ if (!resourceRequestStore.resolve(response.id, response)) {
162
+ console.log('Could not resolve unknown resource', response.path);
163
+ }
164
+ return;
165
+ }
166
+ case 'did-load-localhost': {
167
+ const data = event.data.data;
168
+ if (!localhostRequestStore.resolve(data.id, data.location)) {
169
+ console.log('Could not resolve unknown localhost', data.origin);
170
+ }
171
+ return;
172
+ }
173
+ default: {
174
+ console.log('Unknown message');
175
+ return;
176
+ }
177
+ }
178
+ });
179
+
180
+ sw.addEventListener('fetch', (event) => {
181
+ const requestUrl = new URL(event.request.url);
182
+ if (typeof resourceBaseAuthority === 'string' && requestUrl.protocol === 'https:' && requestUrl.hostname.endsWith('.' + resourceBaseAuthority)) {
183
+ switch (event.request.method) {
184
+ case 'GET':
185
+ case 'HEAD': {
186
+ const firstHostSegment = requestUrl.hostname.slice(0, requestUrl.hostname.length - (resourceBaseAuthority.length + 1));
187
+ const scheme = firstHostSegment.split('+', 1)[0];
188
+ const authority = firstHostSegment.slice(scheme.length + 1); // may be empty
189
+ return event.respondWith(processResourceRequest(event, {
190
+ scheme,
191
+ authority,
192
+ path: requestUrl.pathname,
193
+ query: requestUrl.search.replace(/^\?/, ''),
194
+ }));
195
+ }
196
+ default: {
197
+ return event.respondWith(methodNotAllowed());
198
+ }
199
+ }
200
+ }
201
+
202
+ // If we're making a request against the remote authority, we want to go
203
+ // through VS Code itself so that we are authenticated properly. If the
204
+ // service worker is hosted on the same origin we will have cookies and
205
+ // authentication will not be an issue.
206
+ if (requestUrl.origin !== sw.origin && requestUrl.host === remoteAuthority) {
207
+ switch (event.request.method) {
208
+ case 'GET':
209
+ case 'HEAD': {
210
+ return event.respondWith(processResourceRequest(event, {
211
+ path: requestUrl.pathname,
212
+ scheme: requestUrl.protocol.slice(0, requestUrl.protocol.length - 1),
213
+ authority: requestUrl.host,
214
+ query: requestUrl.search.replace(/^\?/, ''),
215
+ }));
216
+ }
217
+ default: {
218
+ return event.respondWith(methodNotAllowed());
219
+ }
220
+ }
221
+ }
222
+
223
+ // See if it's a localhost request
224
+ if (requestUrl.origin !== sw.origin && requestUrl.host.match(/^(localhost|127.0.0.1|0.0.0.0):(\d+)$/)) {
225
+ return event.respondWith(processLocalhostRequest(event, requestUrl));
226
+ }
227
+ });
228
+
229
+ sw.addEventListener('install', (event) => {
230
+ event.waitUntil(sw.skipWaiting()); // Activate worker immediately
231
+ });
232
+
233
+ sw.addEventListener('activate', (event) => {
234
+ event.waitUntil(sw.clients.claim()); // Become available to all pages
235
+ });
236
+
237
+
238
+ /**
239
+ * @typedef {Object} ResourceRequestUrlComponents
240
+ * @property {string} scheme
241
+ * @property {string} authority
242
+ * @property {string} path
243
+ * @property {string} query
244
+ */
245
+
246
+ /**
247
+ * @param {FetchEvent} event
248
+ * @param {ResourceRequestUrlComponents} requestUrlComponents
249
+ * @returns {Promise<Response>}
250
+ */
251
+ async function processResourceRequest(
252
+ event,
253
+ requestUrlComponents
254
+ ) {
255
+ let client = await sw.clients.get(event.clientId);
256
+ if (!client) {
257
+ client = await getWorkerClientForId(event.clientId);
258
+ if (!client) {
259
+ console.error('Could not find inner client for request');
260
+ return notFound();
261
+ }
262
+ }
263
+
264
+ const webviewId = getWebviewIdForClient(client);
265
+
266
+ // Refs https://github.com/microsoft/vscode/issues/244143
267
+ // With PlzDedicatedWorker, worker subresources and blob wokers
268
+ // will use clients different from the window client.
269
+ // Since we cannot different a worker main resource from a worker subresource
270
+ // we will use message channel to the outer iframe provided at the time
271
+ // of service worker controller version initialization.
272
+ if (!webviewId && client.type !== 'worker' && client.type !== 'sharedworker') {
273
+ console.error('Could not resolve webview id');
274
+ return notFound();
275
+ }
276
+
277
+ const shouldTryCaching = (event.request.method === 'GET');
278
+
279
+ /**
280
+ * @param {RequestStoreResult<ResourceResponse>} result
281
+ * @param {Response|undefined} cachedResponse
282
+ * @returns {Response}
283
+ */
284
+ const resolveResourceEntry = (result, cachedResponse) => {
285
+ if (result.status === 'timeout') {
286
+ return requestTimeout();
287
+ }
288
+
289
+ /** @type {Record<string, string>} */
290
+ const accessControlHeaders = {
291
+ 'Access-Control-Allow-Origin': '*',
292
+ 'Cross-Origin-Resource-Policy': 'cross-origin',
293
+ };
294
+
295
+ const entry = result.value;
296
+ if (entry.status === 304) { // Not modified
297
+ if (cachedResponse) {
298
+ const r = cachedResponse.clone();
299
+ for (const [key, value] of Object.entries(accessControlHeaders)) {
300
+ r.headers.set(key, value);
301
+ }
302
+ return r;
303
+ } else {
304
+ throw new Error('No cache found');
305
+ }
306
+ }
307
+
308
+ if (entry.status === 401) {
309
+ return unauthorized();
310
+ }
311
+
312
+ if (entry.status !== 200) {
313
+ return notFound();
314
+ }
315
+
316
+ const byteLength = entry.data.byteLength;
317
+
318
+ const range = event.request.headers.get('range');
319
+ if (range) {
320
+ // To support seeking for videos, we need to handle range requests
321
+ const bytes = range.match(/^bytes\=(\d+)\-(\d+)?$/g);
322
+ if (bytes) {
323
+ // TODO: Right now we are always reading the full file content. This is a bad idea
324
+ // for large video files :)
325
+
326
+ const start = Number(bytes[1]);
327
+ const end = Number(bytes[2]) || byteLength - 1;
328
+ return new Response(entry.data.slice(start, end + 1), {
329
+ status: 206,
330
+ headers: {
331
+ ...accessControlHeaders,
332
+ 'Content-range': `bytes 0-${end}/${byteLength}`,
333
+ }
334
+ });
335
+ } else {
336
+ // We don't understand the requested bytes
337
+ return new Response(null, {
338
+ status: 416,
339
+ headers: {
340
+ ...accessControlHeaders,
341
+ 'Content-range': `*/${byteLength}`
342
+ }
343
+ });
344
+ }
345
+ }
346
+
347
+ /** @type {Record<string, string>} */
348
+ const headers = {
349
+ ...accessControlHeaders,
350
+ 'Content-Type': entry.mime,
351
+ 'Content-Length': byteLength.toString(),
352
+ };
353
+
354
+ if (entry.etag) {
355
+ headers['ETag'] = entry.etag;
356
+ headers['Cache-Control'] = 'no-cache';
357
+ }
358
+ if (entry.mtime) {
359
+ headers['Last-Modified'] = new Date(entry.mtime).toUTCString();
360
+ }
361
+
362
+ // support COI requests, see network.ts#COI.getHeadersFromQuery(...)
363
+ const coiRequest = new URL(event.request.url).searchParams.get('vscode-coi');
364
+ if (coiRequest === '3') {
365
+ headers['Cross-Origin-Opener-Policy'] = 'same-origin';
366
+ headers['Cross-Origin-Embedder-Policy'] = 'require-corp';
367
+ } else if (coiRequest === '2') {
368
+ headers['Cross-Origin-Embedder-Policy'] = 'require-corp';
369
+ } else if (coiRequest === '1') {
370
+ headers['Cross-Origin-Opener-Policy'] = 'same-origin';
371
+ }
372
+
373
+ const response = new Response(entry.data, {
374
+ status: 200,
375
+ headers
376
+ });
377
+
378
+ if (shouldTryCaching && entry.etag) {
379
+ caches.open(resourceCacheName).then(cache => {
380
+ return cache.put(event.request, response);
381
+ });
382
+ }
383
+ return response.clone();
384
+ };
385
+
386
+ /** @type {Response|undefined} */
387
+ let cached;
388
+ if (shouldTryCaching) {
389
+ const cache = await caches.open(resourceCacheName);
390
+ cached = await cache.match(event.request);
391
+ }
392
+
393
+ const { requestId, promise } = resourceRequestStore.create();
394
+
395
+ if (webviewId) {
396
+ const parentClients = await getOuterIframeClient(webviewId);
397
+ if (!parentClients.length) {
398
+ console.log('Could not find parent client for request');
399
+ return notFound();
400
+ }
401
+
402
+ for (const parentClient of parentClients) {
403
+ parentClient.postMessage({
404
+ channel: 'load-resource',
405
+ id: requestId,
406
+ scheme: requestUrlComponents.scheme,
407
+ authority: requestUrlComponents.authority,
408
+ path: requestUrlComponents.path,
409
+ query: requestUrlComponents.query,
410
+ ifNoneMatch: cached?.headers.get('ETag'),
411
+ });
412
+ }
413
+ } else if (client.type === 'worker' || client.type === 'sharedworker') {
414
+ outerIframeMessagePort?.postMessage({
415
+ channel: 'load-resource',
416
+ id: requestId,
417
+ scheme: requestUrlComponents.scheme,
418
+ authority: requestUrlComponents.authority,
419
+ path: requestUrlComponents.path,
420
+ query: requestUrlComponents.query,
421
+ ifNoneMatch: cached?.headers.get('ETag'),
422
+ });
423
+ }
424
+
425
+ return promise.then(entry => resolveResourceEntry(entry, cached));
426
+ }
427
+
428
+ /**
429
+ * @param {FetchEvent} event
430
+ * @param {URL} requestUrl
431
+ * @returns {Promise<Response>}
432
+ */
433
+ async function processLocalhostRequest(
434
+ event,
435
+ requestUrl
436
+ ) {
437
+ const client = await sw.clients.get(event.clientId);
438
+ if (!client) {
439
+ // This is expected when requesting resources on other localhost ports
440
+ // that are not spawned by vs code
441
+ return fetch(event.request);
442
+ }
443
+ const webviewId = getWebviewIdForClient(client);
444
+ // Refs https://github.com/microsoft/vscode/issues/244143
445
+ // With PlzDedicatedWorker, worker subresources and blob wokers
446
+ // will use clients different from the window client.
447
+ // Since we cannot different a worker main resource from a worker subresource
448
+ // we will use message channel to the outer iframe provided at the time
449
+ // of service worker controller version initialization.
450
+ if (!webviewId && client.type !== 'worker' && client.type !== 'sharedworker') {
451
+ console.error('Could not resolve webview id');
452
+ return fetch(event.request);
453
+ }
454
+
455
+ const origin = requestUrl.origin;
456
+
457
+ /**
458
+ * @param {RequestStoreResult<string|undefined>} result
459
+ * @returns {Promise<Response>}
460
+ */
461
+ const resolveRedirect = async function (result) {
462
+ if (result.status !== 'ok' || !result.value) {
463
+ return fetch(event.request);
464
+ }
465
+
466
+ const redirectOrigin = result.value;
467
+ const location = event.request.url.replace(new RegExp(`^${requestUrl.origin}(/|$)`), `${redirectOrigin}$1`);
468
+ return new Response(null, {
469
+ status: 302,
470
+ headers: {
471
+ Location: location
472
+ }
473
+ });
474
+ };
475
+
476
+ const { requestId, promise } = localhostRequestStore.create();
477
+ if (webviewId) {
478
+ const parentClients = await getOuterIframeClient(webviewId);
479
+ if (!parentClients.length) {
480
+ console.log('Could not find parent client for request');
481
+ return notFound();
482
+ }
483
+ for (const parentClient of parentClients) {
484
+ parentClient.postMessage({
485
+ channel: 'load-localhost',
486
+ origin: origin,
487
+ id: requestId,
488
+ });
489
+ }
490
+ } else if (client.type === 'worker' || client.type === 'sharedworker') {
491
+ outerIframeMessagePort?.postMessage({
492
+ channel: 'load-localhost',
493
+ origin: origin,
494
+ id: requestId,
495
+ });
496
+ }
497
+
498
+ return promise.then(resolveRedirect);
499
+ }
500
+
501
+ /**
502
+ * @param {Client} client
503
+ * @returns {string|null}
504
+ */
505
+ function getWebviewIdForClient(client) {
506
+ const requesterClientUrl = new URL(client.url);
507
+ return requesterClientUrl.searchParams.get('id');
508
+ }
509
+
510
+ /**
511
+ * @param {string} webviewId
512
+ * @returns {Promise<Client[]>}
513
+ */
514
+ async function getOuterIframeClient(webviewId) {
515
+ const allClients = await sw.clients.matchAll({ includeUncontrolled: true });
516
+ return allClients.filter(client => {
517
+ const clientUrl = new URL(client.url);
518
+ return clientUrl.searchParams.get('id') === webviewId;
519
+ });
520
+ }
521
+
522
+ /**
523
+ * @param {string} clientId
524
+ * @returns {Promise<Client|undefined>}
525
+ */
526
+ async function getWorkerClientForId(clientId) {
527
+ const allDedicatedWorkerClients = await sw.clients.matchAll({ type: 'worker' });
528
+ const allSharedWorkerClients = await sw.clients.matchAll({ type: 'sharedworker' });
529
+ const allWorkerClients = [...allDedicatedWorkerClients, ...allSharedWorkerClients];
530
+ return allWorkerClients.find(client => {
531
+ return client.id === clientId;
532
+ });
533
+ }
534
+
535
+
536
+ /**
537
+ * @typedef {(
538
+ * | { readonly status: 200, id: number, path: string, mime: string, data: Uint8Array, etag: string|undefined, mtime: number|undefined }
539
+ * | { readonly status: 304, id: number, path: string, mime: string, mtime: number|undefined }
540
+ * | { readonly status: 401, id: number, path: string }
541
+ * | { readonly status: 404, id: number, path: string }
542
+ * )} ResourceResponse
543
+ */
@@ -0,0 +1 @@
1
+ {"iconDefinitions":{"_root_folder_dark":{"iconPath":"./images/root-folder-dark.svg"},"_root_folder_open_dark":{"iconPath":"./images/root-folder-open-dark.svg"},"_folder_dark":{"iconPath":"./images/folder-dark.svg"},"_folder_open_dark":{"iconPath":"./images/folder-open-dark.svg"},"_file_dark":{"iconPath":"./images/document-dark.svg"},"_root_folder":{"iconPath":"./images/root-folder-light.svg"},"_root_folder_open":{"iconPath":"./images/root-folder-open-light.svg"},"_folder_light":{"iconPath":"./images/folder-light.svg"},"_folder_open_light":{"iconPath":"./images/folder-open-light.svg"},"_file_light":{"iconPath":"./images/document-light.svg"}},"folderExpanded":"_folder_open_dark","folder":"_folder_dark","file":"_file_dark","rootFolderExpanded":"_root_folder_open_dark","rootFolder":"_root_folder_dark","fileExtensions":{},"fileNames":{},"languageIds":{},"light":{"folderExpanded":"_folder_open_light","folder":"_folder_light","rootFolderExpanded":"_root_folder_open","rootFolder":"_root_folder","file":"_file_light","fileExtensions":{},"fileNames":{},"languageIds":{}},"highContrast":{}}