@caspian2026/agent-sdk 0.0.9 → 0.0.11

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 (216) hide show
  1. package/dist/{chunk-jgvmjwnx.js → chunk-0ac6r0fw.js} +14 -14
  2. package/dist/{chunk-9957ffjc.js → chunk-0dm971mw.js} +2 -2
  3. package/dist/{chunk-0txtpamh.js → chunk-0f5anjkb.js} +6 -6
  4. package/dist/{chunk-c5zkrd7r.js → chunk-0k9sft0s.js} +15 -15
  5. package/dist/{chunk-04h360ha.js → chunk-0kgwksm1.js} +5 -5
  6. package/dist/{chunk-hg6fwhj1.js → chunk-1etzkkxs.js} +1 -1
  7. package/dist/{chunk-4myad919.js → chunk-1gz2wrhq.js} +14 -14
  8. package/dist/{chunk-ty1cyqr7.js → chunk-1pr4hr5x.js} +17 -17
  9. package/dist/{chunk-44t1xk05.js → chunk-1vhjn1j9.js} +14 -14
  10. package/dist/{chunk-1hqb50ne.js → chunk-1wr6ag3j.js} +2 -2
  11. package/dist/{chunk-vbtm9g57.js → chunk-24t2wjab.js} +1 -1
  12. package/dist/{chunk-vk3nb2xe.js → chunk-2589k4k0.js} +15 -15
  13. package/dist/{chunk-hqjdgc6c.js → chunk-28k13wc7.js} +2 -2
  14. package/dist/{chunk-hparkfvt.js → chunk-2cr43hzw.js} +22 -22
  15. package/dist/{chunk-2nrarbza.js → chunk-2sqhjnpn.js} +14 -14
  16. package/dist/{chunk-9z9teq7p.js → chunk-2tfe2zs1.js} +15 -15
  17. package/dist/{chunk-5tw3gj5z.js → chunk-2z9rak9s.js} +14 -14
  18. package/dist/{chunk-1gaw18rz.js → chunk-31bwdrm5.js} +15 -15
  19. package/dist/{chunk-x3jthbjq.js → chunk-38rkx4cj.js} +15 -15
  20. package/dist/{chunk-jjz3hs34.js → chunk-394djs3v.js} +23 -23
  21. package/dist/{chunk-thmtkfgj.js → chunk-3we6j8b4.js} +3 -3
  22. package/dist/{chunk-22mfb6bp.js → chunk-400r5gmq.js} +4 -4
  23. package/dist/{chunk-kxrrtr3p.js → chunk-4057dtxd.js} +1 -1
  24. package/dist/{chunk-dt3epnwj.js → chunk-41en0cc6.js} +4 -4
  25. package/dist/{chunk-rx4mcfg1.js → chunk-488spx13.js} +23 -23
  26. package/dist/{chunk-ttyfhx12.js → chunk-49bs7x5p.js} +68 -35
  27. package/dist/{chunk-b547q41s.js → chunk-4d0g9n3q.js} +15 -15
  28. package/dist/{chunk-thenr6b3.js → chunk-4fh25m1z.js} +6 -6
  29. package/dist/{chunk-y5wfy524.js → chunk-4hgxxzdw.js} +17 -17
  30. package/dist/{chunk-sh2v9ywv.js → chunk-4pj88fnc.js} +2 -2
  31. package/dist/{chunk-t1pygy19.js → chunk-4re879ja.js} +15 -15
  32. package/dist/{chunk-vw5jzpcm.js → chunk-50art2hr.js} +3 -3
  33. package/dist/{chunk-frwznxnf.js → chunk-5pqq0nym.js} +1 -1
  34. package/dist/{chunk-b6prbsae.js → chunk-6696fngv.js} +1 -1
  35. package/dist/{chunk-b89ese8r.js → chunk-66dk94r4.js} +14 -14
  36. package/dist/{chunk-hzbr9543.js → chunk-67808qek.js} +3 -3
  37. package/dist/{chunk-xcrzgyce.js → chunk-69841w77.js} +14 -14
  38. package/dist/{chunk-ay5fvc2r.js → chunk-6ebvysef.js} +15 -15
  39. package/dist/{chunk-tpk67mjc.js → chunk-6zsxtysq.js} +2 -2
  40. package/dist/{chunk-54wn2jdr.js → chunk-75qqeec8.js} +2 -2
  41. package/dist/{chunk-ecvy1ng2.js → chunk-765zdaq8.js} +16 -16
  42. package/dist/{chunk-jwwpfq76.js → chunk-7ce8wn1f.js} +16 -16
  43. package/dist/{chunk-zcgprbyy.js → chunk-7p2vw8qe.js} +11 -11
  44. package/dist/{chunk-t1s91wrk.js → chunk-7t5ymv2m.js} +1 -1
  45. package/dist/{chunk-3pzwd6qq.js → chunk-7tphrzjj.js} +1 -1
  46. package/dist/{chunk-hgmhngje.js → chunk-8c907cv9.js} +1 -1
  47. package/dist/{chunk-d8z7pyrb.js → chunk-8dzg4nr5.js} +15 -15
  48. package/dist/{chunk-qkp4ygnk.js → chunk-8hn2xqjz.js} +2 -2
  49. package/dist/{chunk-1kmwf4vn.js → chunk-8kmna3cc.js} +3 -3
  50. package/dist/{chunk-p9ny0p2a.js → chunk-8r5eevap.js} +8 -8
  51. package/dist/{chunk-1vp22nex.js → chunk-8vkv63c5.js} +1 -1
  52. package/dist/{chunk-1486qzk5.js → chunk-8w21adpe.js} +3 -3
  53. package/dist/{chunk-vajsk9ya.js → chunk-8w8d1k7b.js} +3 -3
  54. package/dist/{chunk-r6nnp8mj.js → chunk-90bqyqfd.js} +14 -14
  55. package/dist/{chunk-3e4r5pmc.js → chunk-942yq6xx.js} +1 -1
  56. package/dist/{chunk-35z2vxep.js → chunk-99ck62v1.js} +17 -17
  57. package/dist/{chunk-9w114071.js → chunk-9g29z3dv.js} +1 -1
  58. package/dist/{chunk-hg45r671.js → chunk-9nj016rn.js} +1 -1
  59. package/dist/{chunk-6cfcqjty.js → chunk-9nk34wee.js} +17 -17
  60. package/dist/{chunk-xhn4ptjn.js → chunk-9z45660r.js} +19 -19
  61. package/dist/{chunk-njw0haha.js → chunk-a3gq2vv4.js} +4 -4
  62. package/dist/{chunk-tf859h88.js → chunk-akqsq8bn.js} +2 -2
  63. package/dist/{chunk-rmpaj37q.js → chunk-aqq5qh2y.js} +15 -15
  64. package/dist/{chunk-ghwvqhx9.js → chunk-awdftfcf.js} +15 -15
  65. package/dist/{chunk-2y8x7xt7.js → chunk-b3nkagky.js} +2 -2
  66. package/dist/{chunk-vtmxgm1m.js → chunk-b8f5dz5b.js} +2 -2
  67. package/dist/{chunk-rygxwjtc.js → chunk-bayvqjm6.js} +15 -15
  68. package/dist/{chunk-1hqvvvrt.js → chunk-bgyb0z0p.js} +23 -23
  69. package/dist/{chunk-t3gmfcy7.js → chunk-bhabqhx1.js} +14 -14
  70. package/dist/{chunk-c6hsz5ey.js → chunk-bj85dnsy.js} +3 -3
  71. package/dist/{chunk-g597bz1j.js → chunk-bp4s0gry.js} +15 -15
  72. package/dist/{chunk-x2bnzvd6.js → chunk-brng9f4q.js} +14 -14
  73. package/dist/{chunk-3fn3ysvs.js → chunk-bvdzmdw4.js} +15 -15
  74. package/dist/{chunk-w3782jck.js → chunk-ca72efeb.js} +15 -15
  75. package/dist/{chunk-67wms97m.js → chunk-cdact4jj.js} +2 -2
  76. package/dist/{chunk-zqbnw3n2.js → chunk-cfyvkbe5.js} +20 -20
  77. package/dist/{chunk-zyjkg76f.js → chunk-cjca0q27.js} +3 -3
  78. package/dist/{chunk-wtpgjmjd.js → chunk-cs9aqzag.js} +15 -15
  79. package/dist/{chunk-7hrmxpha.js → chunk-cttezxcb.js} +18 -8
  80. package/dist/{chunk-w6mcmmt5.js → chunk-d2g976qe.js} +3 -3
  81. package/dist/{chunk-zxywawr7.js → chunk-d7ws01qk.js} +1 -1
  82. package/dist/{chunk-f4tdn7yr.js → chunk-dsqfe05n.js} +14 -14
  83. package/dist/{chunk-dz6zxh89.js → chunk-e82vbky2.js} +14 -14
  84. package/dist/{chunk-jtgyzqbq.js → chunk-eba0b85f.js} +1 -1
  85. package/dist/{chunk-5zcygjb2.js → chunk-eqnfk1g0.js} +14 -14
  86. package/dist/{chunk-trvc6jh7.js → chunk-erj5nc8b.js} +17 -17
  87. package/dist/{chunk-xtdm6ejq.js → chunk-eseq7djh.js} +1 -1
  88. package/dist/{chunk-7skyagc2.js → chunk-esrkw9v4.js} +2 -2
  89. package/dist/{chunk-hae34yd0.js → chunk-ewbvcf88.js} +3 -3
  90. package/dist/{chunk-q8hxwh48.js → chunk-ewhxddsa.js} +1 -1
  91. package/dist/{chunk-1nvcmzj1.js → chunk-ey1pg5v8.js} +25 -25
  92. package/dist/{chunk-v5g8nf5h.js → chunk-f1v8h236.js} +4 -4
  93. package/dist/{chunk-dexkgxt4.js → chunk-f70fwxds.js} +2 -2
  94. package/dist/{chunk-j0gke393.js → chunk-f73trmvk.js} +14 -14
  95. package/dist/{chunk-y32em34x.js → chunk-fcww10dt.js} +4 -4
  96. package/dist/{chunk-h4xfadhf.js → chunk-fhprmgf4.js} +1 -1
  97. package/dist/{chunk-xw99fqv1.js → chunk-fnf4av18.js} +3 -3
  98. package/dist/{chunk-frm7mphm.js → chunk-fy543pwf.js} +2 -2
  99. package/dist/{chunk-wa0xgm6m.js → chunk-fybanr7d.js} +2 -2
  100. package/dist/{chunk-2vbash3m.js → chunk-g5epkvz2.js} +1 -1
  101. package/dist/{chunk-ratnrv9v.js → chunk-g8183rkv.js} +2 -2
  102. package/dist/{chunk-ecbh4n6q.js → chunk-gbztsm42.js} +14 -14
  103. package/dist/{chunk-szzff973.js → chunk-ge57c9hg.js} +3 -3
  104. package/dist/{chunk-93vwm44t.js → chunk-ggq2y3tn.js} +91 -91
  105. package/dist/{chunk-42a0nyrq.js → chunk-gpzkzg7v.js} +15 -15
  106. package/dist/{chunk-dngfdsm9.js → chunk-gw1a82j8.js} +66 -66
  107. package/dist/{chunk-tj7v47cp.js → chunk-gw1g065z.js} +1 -1
  108. package/dist/{chunk-gzj94jgg.js → chunk-h4dnamt5.js} +14 -14
  109. package/dist/{chunk-xvk90wpt.js → chunk-h5mkzk0z.js} +1 -1
  110. package/dist/{chunk-5m3m7hr5.js → chunk-h7dm24cc.js} +4 -4
  111. package/dist/{chunk-wkt2q02c.js → chunk-hadww3nd.js} +1 -1
  112. package/dist/{chunk-fesvrjhd.js → chunk-hapvn84d.js} +3 -3
  113. package/dist/{chunk-wm1zm5xj.js → chunk-hekf5s9q.js} +2 -2
  114. package/dist/{chunk-0gpem3pk.js → chunk-hkgb5y9f.js} +14 -14
  115. package/dist/{chunk-azv68vk1.js → chunk-hzceftr4.js} +1 -1
  116. package/dist/{chunk-9wf3fc4t.js → chunk-j2x6fp25.js} +2 -2
  117. package/dist/{chunk-ssb4wba6.js → chunk-j30g8fd1.js} +3 -3
  118. package/dist/{chunk-jxp2j9t5.js → chunk-j3awswy3.js} +14 -14
  119. package/dist/{chunk-bjdknxqn.js → chunk-j513wqe9.js} +14 -14
  120. package/dist/{chunk-wg47eg7y.js → chunk-jkens34n.js} +14 -14
  121. package/dist/{chunk-ef2m4xyz.js → chunk-jperb6n2.js} +14 -14
  122. package/dist/{chunk-etbb3dss.js → chunk-jqmr6ag1.js} +17 -17
  123. package/dist/{chunk-xs7zsmzk.js → chunk-jx6k8msx.js} +14 -14
  124. package/dist/{chunk-t9eeyrkn.js → chunk-jyz65rfv.js} +15 -15
  125. package/dist/{chunk-sjpqw47t.js → chunk-k5mckm5f.js} +1 -1
  126. package/dist/{chunk-bf03a1w7.js → chunk-k9z36r5q.js} +16 -16
  127. package/dist/{chunk-ec6ga5ey.js → chunk-kamesdff.js} +19 -19
  128. package/dist/{chunk-wgd4n1q7.js → chunk-kj4m0j4n.js} +1 -1
  129. package/dist/{chunk-rpsqtvkx.js → chunk-m25yfqc3.js} +14 -14
  130. package/dist/{chunk-7cdy4aj6.js → chunk-mgpj5f7h.js} +65 -65
  131. package/dist/{chunk-ayx9aq2k.js → chunk-mmn62bh2.js} +15 -15
  132. package/dist/{chunk-rz94yg8c.js → chunk-mq94v5vn.js} +1 -1
  133. package/dist/{chunk-mewywsar.js → chunk-msvv7dpt.js} +14 -14
  134. package/dist/{chunk-r3ehjkj5.js → chunk-mtv83pq4.js} +25 -25
  135. package/dist/{chunk-h61d4awv.js → chunk-n36xjgtj.js} +16 -16
  136. package/dist/{chunk-q4f1g9y6.js → chunk-n9d0gg9z.js} +9 -9
  137. package/dist/{chunk-ckh4f9ry.js → chunk-na63s9wn.js} +3 -3
  138. package/dist/{chunk-v6hbqcmr.js → chunk-nebntwvd.js} +11 -11
  139. package/dist/{chunk-dj7d67ya.js → chunk-nj02kck4.js} +1 -1
  140. package/dist/{chunk-pddf0719.js → chunk-nv7vcqme.js} +17 -17
  141. package/dist/{chunk-vmp5rk8q.js → chunk-pbeee2kp.js} +2 -2
  142. package/dist/{chunk-q14wrksq.js → chunk-pcbm66ch.js} +16 -16
  143. package/dist/{chunk-72qa16xm.js → chunk-pe3n0w2t.js} +16 -16
  144. package/dist/{chunk-f4v7t54y.js → chunk-peh3mj19.js} +1 -1
  145. package/dist/{chunk-65q3hqkw.js → chunk-pepgckn4.js} +3 -3
  146. package/dist/{chunk-cay13mxk.js → chunk-pm67yj46.js} +3 -3
  147. package/dist/{chunk-35nft36d.js → chunk-pp8nrx40.js} +83 -83
  148. package/dist/{chunk-rfbbcx5s.js → chunk-pq5290db.js} +14 -14
  149. package/dist/{chunk-gkn3jgqn.js → chunk-pzp8fj0a.js} +25 -25
  150. package/dist/{chunk-2m32xn94.js → chunk-q1j8ebyf.js} +3 -3
  151. package/dist/{chunk-jj4zs4gr.js → chunk-q2fn2p7y.js} +14 -14
  152. package/dist/{chunk-4vtvwg7e.js → chunk-q347821k.js} +22 -22
  153. package/dist/{chunk-be77bcs8.js → chunk-qb88vpgy.js} +14 -14
  154. package/dist/{chunk-grqkx44z.js → chunk-qehbwde1.js} +15 -15
  155. package/dist/{chunk-qqs58ywv.js → chunk-qmmxwh8x.js} +2 -2
  156. package/dist/{chunk-jksf0ax9.js → chunk-qxmm3jbn.js} +14 -14
  157. package/dist/{chunk-ey0n4emm.js → chunk-qywk2c7m.js} +14 -14
  158. package/dist/{chunk-1efrnkxx.js → chunk-r0dpeqg0.js} +6 -6
  159. package/dist/{chunk-xffb3dsw.js → chunk-r0m970pk.js} +1 -1
  160. package/dist/{chunk-v4wba09w.js → chunk-r5bf0h0t.js} +14 -14
  161. package/dist/{chunk-1yfc1d48.js → chunk-r7xpsch7.js} +14 -14
  162. package/dist/{chunk-vyz3v0qx.js → chunk-rkvwts6v.js} +2 -2
  163. package/dist/{chunk-w3gnkyfc.js → chunk-rm4c8zd9.js} +16 -16
  164. package/dist/{chunk-qctsv1d7.js → chunk-rm9gb396.js} +1 -1
  165. package/dist/{chunk-s19b0bc7.js → chunk-s213xmp8.js} +14 -14
  166. package/dist/{chunk-rnxpvm3m.js → chunk-s3s0611n.js} +1 -1
  167. package/dist/{chunk-qxjhw1dt.js → chunk-scrk9jbt.js} +9 -9
  168. package/dist/{chunk-vmbht6ec.js → chunk-tgmettzd.js} +3 -3
  169. package/dist/{chunk-9byfzaeq.js → chunk-tj6hejny.js} +14 -14
  170. package/dist/{chunk-djfq8ws0.js → chunk-tn0xnp8a.js} +25 -25
  171. package/dist/{chunk-k8jpbz31.js → chunk-tpn6rh31.js} +4 -4
  172. package/dist/{chunk-rhvn1rqs.js → chunk-tq4vws6e.js} +2 -2
  173. package/dist/{chunk-ecv9kbtk.js → chunk-tzzzbb9d.js} +3 -3
  174. package/dist/{chunk-jwpp2bq2.js → chunk-v6fcbmqz.js} +51 -51
  175. package/dist/{chunk-mmhkcj7c.js → chunk-vc59jf3q.js} +22 -22
  176. package/dist/{chunk-jqfrz5g9.js → chunk-vdk9b74d.js} +5 -5
  177. package/dist/{chunk-g78fetxa.js → chunk-vf9c1649.js} +14 -14
  178. package/dist/{chunk-1nhnn2rg.js → chunk-vgk0nymz.js} +2 -2
  179. package/dist/{chunk-e7ag583m.js → chunk-vgzpbh28.js} +15 -15
  180. package/dist/{chunk-txgbs4hp.js → chunk-vhxrn87v.js} +16 -16
  181. package/dist/{chunk-7cje7scj.js → chunk-vnzgpyrz.js} +1 -1
  182. package/dist/{chunk-v0tgjdx0.js → chunk-vqh6cjfx.js} +2 -2
  183. package/dist/{chunk-r5nd93kc.js → chunk-vz3pa5n6.js} +1 -1
  184. package/dist/{chunk-3npsy4c4.js → chunk-w1h5z2sy.js} +14 -14
  185. package/dist/{chunk-msxggy37.js → chunk-w2vvxj1f.js} +4 -4
  186. package/dist/{chunk-2yxqz99n.js → chunk-w5zezk61.js} +1 -1
  187. package/dist/{chunk-5mrc0ps5.js → chunk-wahqac7c.js} +8 -8
  188. package/dist/{chunk-84cdy41j.js → chunk-wc0np2zw.js} +3 -3
  189. package/dist/{chunk-xgbd6ec5.js → chunk-wcpmtszh.js} +15 -15
  190. package/dist/{chunk-ev7h351p.js → chunk-wdzjtdye.js} +2 -2
  191. package/dist/{chunk-6hs0cptm.js → chunk-wmbpjx7v.js} +20 -20
  192. package/dist/{chunk-m70n19dz.js → chunk-wrsy4y58.js} +16 -16
  193. package/dist/{chunk-hb1gr101.js → chunk-wskkym13.js} +2 -2
  194. package/dist/{chunk-r7684mmh.js → chunk-wt6v1zbe.js} +1 -1
  195. package/dist/{chunk-hrhp26d7.js → chunk-wyj3wpjv.js} +22 -22
  196. package/dist/{chunk-pfarypfq.js → chunk-xdg2rpj3.js} +16 -16
  197. package/dist/{chunk-grqhgr2b.js → chunk-xemw9d52.js} +3 -3
  198. package/dist/{chunk-04pw5akr.js → chunk-xmdny0m1.js} +5 -5
  199. package/dist/{chunk-8jy18nx9.js → chunk-xv5a2xbe.js} +1 -1
  200. package/dist/{chunk-p791ydbm.js → chunk-xx709m24.js} +1 -1
  201. package/dist/{chunk-cr1dv2js.js → chunk-y024419t.js} +14 -14
  202. package/dist/{chunk-wxkrq9eb.js → chunk-y1ps26mz.js} +14 -14
  203. package/dist/{chunk-0v89r445.js → chunk-y2r5e6kv.js} +2 -2
  204. package/dist/{chunk-rn1s097c.js → chunk-y41svpxw.js} +14 -14
  205. package/dist/{chunk-1hx5g6qy.js → chunk-ygwcq4vd.js} +3 -3
  206. package/dist/{chunk-ya9dxex0.js → chunk-ykv414dd.js} +16 -16
  207. package/dist/{chunk-h3vyya5n.js → chunk-ynkzfhs1.js} +8 -8
  208. package/dist/{chunk-rjq5nf1c.js → chunk-yrqx3p9k.js} +2 -2
  209. package/dist/{chunk-8ckwc9k8.js → chunk-ys17e80d.js} +14 -14
  210. package/dist/{chunk-c4d52460.js → chunk-zbb7qd0v.js} +2 -2
  211. package/dist/{chunk-ftsdm7y7.js → chunk-zjxv5g2n.js} +22 -22
  212. package/dist/{chunk-j99ms5ep.js → chunk-zmwgp2sh.js} +1 -1
  213. package/dist/cli.js +5 -5
  214. package/dist/gateway/index.js +131 -27
  215. package/dist/gateway/worker.js +558 -112
  216. package/package.json +1 -1
@@ -32893,6 +32893,14 @@ var init_platform = __esm(() => {
32893
32893
  });
32894
32894
 
32895
32895
  // src/utils/windowsPaths.ts
32896
+ var exports_windowsPaths = {};
32897
+ __export(exports_windowsPaths, {
32898
+ windowsPathToPosixPath: () => windowsPathToPosixPath,
32899
+ setShellIfWindows: () => setShellIfWindows,
32900
+ posixPathToWindowsPath: () => posixPathToWindowsPath,
32901
+ findGitBashPathSafe: () => findGitBashPathSafe,
32902
+ findGitBashPath: () => findGitBashPath
32903
+ });
32896
32904
  import * as path8 from "path";
32897
32905
  import * as pathWin32 from "path/win32";
32898
32906
  function checkPathExists(path9) {
@@ -32937,7 +32945,18 @@ function findExecutable(executable) {
32937
32945
  return null;
32938
32946
  }
32939
32947
  }
32940
- var findGitBashPath, windowsPathToPosixPath, posixPathToWindowsPath;
32948
+ function setShellIfWindows() {
32949
+ if (getPlatform() === "windows") {
32950
+ const gitBashPath = findGitBashPathSafe();
32951
+ if (gitBashPath) {
32952
+ process.env.SHELL = gitBashPath;
32953
+ logForDebugging(`Using bash path: "${gitBashPath}"`);
32954
+ } else {
32955
+ logForDebugging("Git Bash not found on Windows; shell detection will fall back to system PATH. " + "Set CLAUDE_CODE_GIT_BASH_PATH or install Git for Windows.");
32956
+ }
32957
+ }
32958
+ }
32959
+ var findGitBashPathSafe, findGitBashPath, windowsPathToPosixPath, posixPathToWindowsPath;
32941
32960
  var init_windowsPaths = __esm(() => {
32942
32961
  init_memoize();
32943
32962
  init_cwd();
@@ -32945,13 +32964,13 @@ var init_windowsPaths = __esm(() => {
32945
32964
  init_execSyncWrapper();
32946
32965
  init_memoize2();
32947
32966
  init_platform();
32948
- findGitBashPath = memoize_default(() => {
32967
+ findGitBashPathSafe = memoize_default(() => {
32949
32968
  if (process.env.CLAUDE_CODE_GIT_BASH_PATH) {
32950
32969
  if (checkPathExists(process.env.CLAUDE_CODE_GIT_BASH_PATH)) {
32951
32970
  return process.env.CLAUDE_CODE_GIT_BASH_PATH;
32952
32971
  }
32953
- console.error(`Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "${process.env.CLAUDE_CODE_GIT_BASH_PATH}"`);
32954
- process.exit(1);
32972
+ logForDebugging(`CLAUDE_CODE_GIT_BASH_PATH "${process.env.CLAUDE_CODE_GIT_BASH_PATH}" does not exist`);
32973
+ return null;
32955
32974
  }
32956
32975
  const gitPath = findExecutable("git");
32957
32976
  if (gitPath) {
@@ -32960,7 +32979,13 @@ var init_windowsPaths = __esm(() => {
32960
32979
  return bashPath;
32961
32980
  }
32962
32981
  }
32963
- console.error("Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win). If installed but not in PATH, set environment variable pointing to your bash.exe, similar to: CLAUDE_CODE_GIT_BASH_PATH=C:\\Program Files\\Git\\bin\\bash.exe");
32982
+ return null;
32983
+ });
32984
+ findGitBashPath = memoize_default(() => {
32985
+ const result = findGitBashPathSafe();
32986
+ if (result)
32987
+ return result;
32988
+ console.error(process.env.CLAUDE_CODE_GIT_BASH_PATH ? `Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "${process.env.CLAUDE_CODE_GIT_BASH_PATH}"` : "Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win). If installed but not in PATH, set environment variable pointing to your bash.exe, similar to: CLAUDE_CODE_GIT_BASH_PATH=C:\\Program Files\\Git\\bin\\bash.exe");
32964
32989
  process.exit(1);
32965
32990
  });
32966
32991
  windowsPathToPosixPath = memoizeWithLRU((windowsPath) => {
@@ -116173,7 +116198,7 @@ var init_metadata = __esm(() => {
116173
116198
  isClaudeAiAuth: false,
116174
116199
  version: "2.1.888",
116175
116200
  versionBase: getVersionBase(),
116176
- buildTime: "2026-05-02T02:41:49.506Z",
116201
+ buildTime: "2026-05-05T17:34:10.461Z",
116177
116202
  deploymentEnvironment: env3.detectDeploymentEnvironment(),
116178
116203
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
116179
116204
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -374701,6 +374726,34 @@ var init_VerifyPlanExecutionTool = __esm(() => {
374701
374726
  });
374702
374727
 
374703
374728
  // src/tools.ts
374729
+ var exports_tools = {};
374730
+ __export(exports_tools, {
374731
+ parseToolPreset: () => parseToolPreset,
374732
+ getToolsForDefaultPreset: () => getToolsForDefaultPreset,
374733
+ getTools: () => getTools,
374734
+ getMergedTools: () => getMergedTools,
374735
+ getAllBaseTools: () => getAllBaseTools,
374736
+ filterToolsByDenyRules: () => filterToolsByDenyRules,
374737
+ assembleToolPool: () => assembleToolPool,
374738
+ TOOL_PRESETS: () => TOOL_PRESETS,
374739
+ REPL_ONLY_TOOLS: () => REPL_ONLY_TOOLS,
374740
+ CUSTOM_AGENT_DISALLOWED_TOOLS: () => CUSTOM_AGENT_DISALLOWED_TOOLS,
374741
+ COORDINATOR_MODE_ALLOWED_TOOLS: () => COORDINATOR_MODE_ALLOWED_TOOLS,
374742
+ ASYNC_AGENT_ALLOWED_TOOLS: () => ASYNC_AGENT_ALLOWED_TOOLS,
374743
+ ALL_AGENT_DISALLOWED_TOOLS: () => ALL_AGENT_DISALLOWED_TOOLS
374744
+ });
374745
+ function parseToolPreset(preset) {
374746
+ const presetString = preset.toLowerCase();
374747
+ if (!TOOL_PRESETS.includes(presetString)) {
374748
+ return null;
374749
+ }
374750
+ return presetString;
374751
+ }
374752
+ function getToolsForDefaultPreset() {
374753
+ const tools = getAllBaseTools();
374754
+ const isEnabled2 = tools.map((tool) => tool.isEnabled());
374755
+ return tools.filter((_2, i3) => isEnabled2[i3]).map((tool) => tool.name);
374756
+ }
374704
374757
  function getAllBaseTools() {
374705
374758
  return [
374706
374759
  AgentTool,
@@ -374760,11 +374813,15 @@ function assembleToolPool(permissionContext, mcpTools) {
374760
374813
  const byName = (a2, b3) => a2.name.localeCompare(b3.name);
374761
374814
  return uniqBy_default([...builtInTools].sort(byName).concat(allowedMcpTools.sort(byName)), "name");
374762
374815
  }
374816
+ function getMergedTools(permissionContext, mcpTools) {
374817
+ const builtInTools = getTools(permissionContext);
374818
+ return [...builtInTools, ...mcpTools];
374819
+ }
374763
374820
  var REPLTool2, SuggestBackgroundPRTool2, SleepTool = null, cronTools, RemoteTriggerTool = null, MonitorTool = null, SendUserFileTool = null, PushNotificationTool = null, SubscribePRTool = null, getTeamCreateTool = () => (init_TeamCreateTool(), __toCommonJS(exports_TeamCreateTool)).TeamCreateTool, getTeamDeleteTool = () => (init_TeamDeleteTool(), __toCommonJS(exports_TeamDeleteTool)).TeamDeleteTool, getSendMessageTool = () => (init_SendMessageTool(), __toCommonJS(exports_SendMessageTool)).SendMessageTool, VerifyPlanExecutionTool2, OverflowTestTool = null, CtxInspectTool = null, TerminalCaptureTool = null, WebBrowserTool = null, SnipTool = null, ListPeersTool = null, WorkflowTool = null, getPowerShellTool2 = () => {
374764
374821
  if (!isPowerShellToolEnabled())
374765
374822
  return null;
374766
374823
  return (init_PowerShellTool(), __toCommonJS(exports_PowerShellTool)).PowerShellTool;
374767
- }, getTools = (permissionContext) => {
374824
+ }, TOOL_PRESETS, getTools = (permissionContext) => {
374768
374825
  if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
374769
374826
  if (isReplModeEnabled() && REPLTool2) {
374770
374827
  const replSimple = [REPLTool2];
@@ -374843,6 +374900,7 @@ var init_tools2 = __esm(() => {
374843
374900
  (init_CronListTool(), __toCommonJS(exports_CronListTool)).CronListTool
374844
374901
  ];
374845
374902
  VerifyPlanExecutionTool2 = process.env.CLAUDE_CODE_VERIFY_PLAN === "true" ? (init_VerifyPlanExecutionTool(), __toCommonJS(exports_VerifyPlanExecutionTool)).VerifyPlanExecutionTool : null;
374903
+ TOOL_PRESETS = ["default"];
374846
374904
  });
374847
374905
 
374848
374906
  // src/hooks/useDoublePress.ts
@@ -384379,7 +384437,7 @@ function getAnthropicEnvMetadata() {
384379
384437
  function getBuildAgeMinutes() {
384380
384438
  if (false)
384381
384439
  ;
384382
- const buildTime = new Date("2026-05-02T02:41:49.506Z").getTime();
384440
+ const buildTime = new Date("2026-05-05T17:34:10.461Z").getTime();
384383
384441
  if (isNaN(buildTime))
384384
384442
  return;
384385
384443
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -452685,7 +452743,7 @@ var init_bridge_kick = __esm(() => {
452685
452743
  var call55 = async () => {
452686
452744
  return {
452687
452745
  type: "text",
452688
- value: `${"2.1.888"} (built ${"2026-05-02T02:41:49.506Z"})`
452746
+ value: `${"2.1.888"} (built ${"2026-05-05T17:34:10.461Z"})`
452689
452747
  };
452690
452748
  }, version2, version_default;
452691
452749
  var init_version = __esm(() => {
@@ -480760,6 +480818,70 @@ var init_MessageSelector = __esm(() => {
480760
480818
  jsx_dev_runtime356 = __toESM(require_jsx_dev_runtime(), 1);
480761
480819
  });
480762
480820
 
480821
+ // packages/sdk/src/adapters/permissions.ts
480822
+ var exports_permissions3 = {};
480823
+ __export(exports_permissions3, {
480824
+ createHeadlessCanUseTool: () => createHeadlessCanUseTool
480825
+ });
480826
+ function createHeadlessCanUseTool(handler) {
480827
+ return async (tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision) => {
480828
+ if (forceDecision !== undefined) {
480829
+ return forceDecision;
480830
+ }
480831
+ if (handler.deniedTools?.includes(tool.name)) {
480832
+ return {
480833
+ behavior: "deny",
480834
+ decisionReason: { type: "other", reason: "Tool is in the denied list" },
480835
+ message: `Permission to use ${tool.name} has been denied.`
480836
+ };
480837
+ }
480838
+ if (handler.allowedTools?.includes(tool.name)) {
480839
+ return {
480840
+ behavior: "allow",
480841
+ updatedInput: input,
480842
+ decisionReason: { type: "other", reason: "Tool is in the allowed list" }
480843
+ };
480844
+ }
480845
+ const result = await hasPermissionsToUseTool(tool, input, toolUseContext, assistantMessage, toolUseID);
480846
+ if (result.behavior === "allow" || result.behavior === "deny") {
480847
+ return result;
480848
+ }
480849
+ if (handler.onPermissionRequest) {
480850
+ const description = tool.getActivityDescription?.(input) ?? tool.name;
480851
+ const request = {
480852
+ toolName: tool.name,
480853
+ input,
480854
+ description,
480855
+ toolUseId: toolUseID
480856
+ };
480857
+ const response = await handler.onPermissionRequest(request);
480858
+ if (response.allowed) {
480859
+ return {
480860
+ behavior: "allow",
480861
+ updatedInput: response.updatedInput ?? input,
480862
+ decisionReason: { type: "other", reason: "Approved by permission handler" }
480863
+ };
480864
+ }
480865
+ return {
480866
+ behavior: "deny",
480867
+ message: response.message ?? `Permission denied for ${tool.name}`,
480868
+ decisionReason: { type: "other", reason: "Denied by permission handler" }
480869
+ };
480870
+ }
480871
+ return {
480872
+ behavior: "deny",
480873
+ decisionReason: {
480874
+ type: "other",
480875
+ reason: "No permission handler configured"
480876
+ },
480877
+ message: "Permission denied (no handler configured)"
480878
+ };
480879
+ };
480880
+ }
480881
+ var init_permissions6 = __esm(() => {
480882
+ init_permissions2();
480883
+ });
480884
+
480763
480885
  // src/entrypoints/gateway/worker.ts
480764
480886
  import { parentPort, workerData } from "node:worker_threads";
480765
480887
 
@@ -481199,6 +481321,7 @@ class QueryEngine {
481199
481321
  readFileState;
481200
481322
  discoveredSkillNames = new Set;
481201
481323
  loadedNestedMemoryPaths = new Set;
481324
+ destroyed = false;
481202
481325
  constructor(config5) {
481203
481326
  this.config = config5;
481204
481327
  this.mutableMessages = config5.initialMessages ?? [];
@@ -481520,6 +481643,8 @@ class QueryEngine {
481520
481643
  maxTurns,
481521
481644
  taskBudget
481522
481645
  })) {
481646
+ if (this.destroyed)
481647
+ return;
481523
481648
  if (message.type === "assistant" || message.type === "user" || message.type === "system" && message.subtype === "compact_boundary") {
481524
481649
  if (persistSession && message.type === "system" && message.subtype === "compact_boundary") {
481525
481650
  const compactMsg = message;
@@ -481860,9 +481985,39 @@ class QueryEngine {
481860
481985
  getSessionId() {
481861
481986
  return getSessionId();
481862
481987
  }
481863
- setModel(model) {
481988
+ updateModel(model) {
481864
481989
  this.config.userSpecifiedModel = model;
481865
481990
  }
481991
+ updatePermission(canUseTool) {
481992
+ this.config.canUseTool = canUseTool;
481993
+ }
481994
+ updateMcpClients(mcpClients, tools) {
481995
+ this.config.mcpClients = mcpClients;
481996
+ this.config.tools = tools;
481997
+ }
481998
+ updateSystemPrompt(prompt) {
481999
+ this.config.customSystemPrompt = prompt;
482000
+ }
482001
+ updateMaxTurns(maxTurns) {
482002
+ this.config.maxTurns = maxTurns;
482003
+ }
482004
+ updateEnv(env6) {
482005
+ Object.assign(process.env, env6);
482006
+ }
482007
+ updateThinking(config5) {
482008
+ this.config.thinkingConfig = config5;
482009
+ }
482010
+ updateAppendSystemPrompt(prompt) {
482011
+ this.config.appendSystemPrompt = prompt;
482012
+ }
482013
+ destroy() {
482014
+ this.destroyed = true;
482015
+ this.mutableMessages = [];
482016
+ this.abortController.abort();
482017
+ this.permissionDenials = [];
482018
+ this.discoveredSkillNames.clear();
482019
+ this.loadedNestedMemoryPaths.clear();
482020
+ }
481866
482021
  }
481867
482022
 
481868
482023
  // packages/sdk/src/adapters/app-state.ts
@@ -481889,63 +482044,8 @@ function createHeadlessStore(config5 = {}) {
481889
482044
  return createStore(initialState);
481890
482045
  }
481891
482046
 
481892
- // packages/sdk/src/adapters/permissions.ts
481893
- init_permissions2();
481894
- function createHeadlessCanUseTool(handler) {
481895
- return async (tool, input, toolUseContext, assistantMessage, toolUseID, forceDecision) => {
481896
- if (forceDecision !== undefined) {
481897
- return forceDecision;
481898
- }
481899
- if (handler.deniedTools?.includes(tool.name)) {
481900
- return {
481901
- behavior: "deny",
481902
- decisionReason: { type: "other", reason: "Tool is in the denied list" },
481903
- message: `Permission to use ${tool.name} has been denied.`
481904
- };
481905
- }
481906
- if (handler.allowedTools?.includes(tool.name)) {
481907
- return {
481908
- behavior: "allow",
481909
- updatedInput: input,
481910
- decisionReason: { type: "other", reason: "Tool is in the allowed list" }
481911
- };
481912
- }
481913
- const result = await hasPermissionsToUseTool(tool, input, toolUseContext, assistantMessage, toolUseID);
481914
- if (result.behavior === "allow" || result.behavior === "deny") {
481915
- return result;
481916
- }
481917
- if (handler.onPermissionRequest) {
481918
- const description = tool.getActivityDescription?.(input) ?? tool.name;
481919
- const request = {
481920
- toolName: tool.name,
481921
- input,
481922
- description,
481923
- toolUseId: toolUseID
481924
- };
481925
- const response = await handler.onPermissionRequest(request);
481926
- if (response.allowed) {
481927
- return {
481928
- behavior: "allow",
481929
- updatedInput: response.updatedInput ?? input,
481930
- decisionReason: { type: "other", reason: "Approved by permission handler" }
481931
- };
481932
- }
481933
- return {
481934
- behavior: "deny",
481935
- message: response.message ?? `Permission denied for ${tool.name}`,
481936
- decisionReason: { type: "other", reason: "Denied by permission handler" }
481937
- };
481938
- }
481939
- return {
481940
- behavior: "deny",
481941
- decisionReason: {
481942
- type: "other",
481943
- reason: "No permission handler configured"
481944
- },
481945
- message: "Permission denied (no handler configured)"
481946
- };
481947
- };
481948
- }
482047
+ // packages/sdk/src/adapters/bootstrap.ts
482048
+ init_permissions6();
481949
482049
 
481950
482050
  // packages/sdk/src/adapters/tool-context.ts
481951
482051
  init_abortController();
@@ -482015,13 +482115,71 @@ function bootstrap(config5 = {}, permissionHandler = {}, mcpClients) {
482015
482115
  };
482016
482116
  }
482017
482117
 
482118
+ // packages/sdk/src/state-machine.ts
482119
+ var SESSION_TRANSITIONS = [
482120
+ { from: "created", to: "idle" },
482121
+ { from: "idle", to: "prompting" },
482122
+ { from: "prompting", to: "idle" },
482123
+ { from: "prompting", to: "aborting" },
482124
+ { from: "aborting", to: "idle" },
482125
+ { from: "idle", to: "updating" },
482126
+ { from: "updating", to: "idle" },
482127
+ { from: ["created", "idle", "prompting", "aborting", "updating"], to: "destroying" },
482128
+ { from: "destroying", to: "destroyed" }
482129
+ ];
482130
+
482131
+ class SessionStateMachine {
482132
+ _state = "created";
482133
+ _history = [];
482134
+ get state() {
482135
+ return this._state;
482136
+ }
482137
+ get history() {
482138
+ return this._history;
482139
+ }
482140
+ canTransition(to) {
482141
+ return SESSION_TRANSITIONS.some((rule) => rule.to === to && (Array.isArray(rule.from) ? rule.from.includes(this._state) : rule.from === this._state));
482142
+ }
482143
+ transition(to, reason) {
482144
+ if (!this.canTransition(to)) {
482145
+ throw new Error(`Invalid state transition: ${this._state} → ${to}`);
482146
+ }
482147
+ const from = this._state;
482148
+ this._history.push({ from, to, timestamp: Date.now(), reason });
482149
+ if (this._history.length > 100) {
482150
+ this._history = this._history.slice(-100);
482151
+ }
482152
+ this._state = to;
482153
+ }
482154
+ reset() {
482155
+ this._history = [];
482156
+ this._state = "created";
482157
+ }
482158
+ }
482159
+
482160
+ class SessionDestroyedError extends Error {
482161
+ constructor() {
482162
+ super("Session has been destroyed");
482163
+ this.name = "SessionDestroyedError";
482164
+ }
482165
+ }
482166
+
482167
+ class SessionBusyError extends Error {
482168
+ constructor() {
482169
+ super("Session is busy processing a prompt");
482170
+ this.name = "SessionBusyError";
482171
+ }
482172
+ }
482173
+
482018
482174
  // packages/sdk/src/session.ts
482019
482175
  class Session {
482020
482176
  sessionId;
482021
482177
  engine;
482022
482178
  bootstrapResult;
482023
- destroyed = false;
482024
- mcpClients = [];
482179
+ mcpClients;
482180
+ sm = new SessionStateMachine;
482181
+ createdAt = Date.now();
482182
+ lastPromptAt;
482025
482183
  constructor(config5 = {}, permissionHandler = {}, extraOptions) {
482026
482184
  const mcpClients = extraOptions?.mcpClients ?? [];
482027
482185
  this.mcpClients = mcpClients;
@@ -482045,26 +482203,137 @@ class Session {
482045
482203
  maxTurns: config5.maxTurns,
482046
482204
  maxBudgetUsd: config5.maxBudgetUsd,
482047
482205
  abortController: result.abortController,
482048
- includePartialMessages: config5.includePartialMessages ?? true
482206
+ includePartialMessages: config5.includePartialMessages ?? true,
482207
+ initialMessages: extraOptions?.initialMessages
482049
482208
  });
482209
+ this.sm.transition("idle", "bootstrap complete");
482050
482210
  }
482051
482211
  async* prompt(input) {
482052
- this.assertAlive();
482053
- yield* this.engine.submitMessage(input);
482212
+ const state = this.sm.state;
482213
+ if (state === "destroyed" || state === "destroying") {
482214
+ throw new SessionDestroyedError;
482215
+ }
482216
+ if (state === "prompting" || state === "aborting") {
482217
+ throw new SessionBusyError;
482218
+ }
482219
+ this.sm.transition("prompting", `prompt(${input.slice(0, 50)})`);
482220
+ this.lastPromptAt = Date.now();
482221
+ try {
482222
+ yield* this.engine.submitMessage(input);
482223
+ } finally {
482224
+ const currentState = this.sm.state;
482225
+ if (currentState === "prompting" || currentState === "aborting") {
482226
+ this.sm.transition("idle", "prompt complete");
482227
+ }
482228
+ }
482229
+ }
482230
+ async update(config5) {
482231
+ if (this.sm.state === "destroyed" || this.sm.state === "destroying") {
482232
+ throw new SessionDestroyedError;
482233
+ }
482234
+ if (this.sm.state !== "idle") {
482235
+ throw new SessionBusyError;
482236
+ }
482237
+ this.sm.transition("updating", "update()");
482238
+ const changes = [];
482239
+ try {
482240
+ if (config5.model) {
482241
+ this.engine.updateModel(config5.model);
482242
+ changes.push(`model: ${config5.model}`);
482243
+ }
482244
+ if (config5.systemPrompt !== undefined) {
482245
+ this.engine.updateSystemPrompt(config5.systemPrompt);
482246
+ changes.push("systemPrompt updated");
482247
+ }
482248
+ if (config5.maxTurns !== undefined) {
482249
+ this.engine.updateMaxTurns(config5.maxTurns);
482250
+ changes.push(`maxTurns: ${config5.maxTurns}`);
482251
+ }
482252
+ if (config5.permissionHandler) {
482253
+ const { createHeadlessCanUseTool: createHeadlessCanUseTool2 } = await Promise.resolve().then(() => (init_permissions6(), exports_permissions3));
482254
+ const canUseTool = createHeadlessCanUseTool2(config5.permissionHandler);
482255
+ this.engine.updatePermission(canUseTool);
482256
+ changes.push("permission updated");
482257
+ }
482258
+ if (config5.mcpClients !== undefined) {
482259
+ for (const client2 of this.mcpClients) {
482260
+ if (client2.type === "connected" && client2.cleanup) {
482261
+ try {
482262
+ await client2.cleanup();
482263
+ } catch {}
482264
+ }
482265
+ }
482266
+ const { getTools: getTools2, assembleToolPool: assembleToolPool2 } = await Promise.resolve().then(() => (init_tools2(), exports_tools));
482267
+ const toolPermissionContext = this.bootstrapResult.toolUseContext.getAppState().toolPermissionContext;
482268
+ const builtInTools = getTools2(toolPermissionContext);
482269
+ const allTools = config5.mcpTools ? assembleToolPool2(toolPermissionContext, config5.mcpTools) : builtInTools;
482270
+ this.engine.updateMcpClients(config5.mcpClients, allTools);
482271
+ this.mcpClients = config5.mcpClients;
482272
+ changes.push(`mcpClients: ${config5.mcpClients.length} clients`);
482273
+ }
482274
+ if (config5.additionalDirectories) {
482275
+ changes.push(`additionalDirectories: ${config5.additionalDirectories.length} dirs`);
482276
+ }
482277
+ if (config5.env) {
482278
+ this.engine.updateEnv(config5.env);
482279
+ changes.push("env updated");
482280
+ }
482281
+ if (config5.thinking) {
482282
+ this.engine.updateThinking(config5.thinking);
482283
+ changes.push("thinking updated");
482284
+ }
482285
+ if (config5.appendSystemPrompt !== undefined) {
482286
+ this.engine.updateAppendSystemPrompt(config5.appendSystemPrompt);
482287
+ changes.push("appendSystemPrompt updated");
482288
+ }
482289
+ this.sm.transition("idle", `update(${changes.join(", ")})`);
482290
+ } catch (err2) {
482291
+ this.sm.transition("idle", "update failed");
482292
+ throw err2;
482293
+ }
482054
482294
  }
482055
482295
  abort() {
482056
- this.engine.interrupt();
482296
+ if (this.sm.state === "destroyed" || this.sm.state === "destroying")
482297
+ return;
482298
+ if (this.sm.state === "prompting") {
482299
+ this.engine.interrupt();
482300
+ this.sm.transition("aborting", "abort()");
482301
+ }
482057
482302
  }
482058
- destroy() {
482059
- if (this.destroyed)
482303
+ async destroy() {
482304
+ const state = this.sm.state;
482305
+ if (state === "destroyed")
482060
482306
  return;
482061
- this.destroyed = true;
482307
+ if (state === "prompting") {
482308
+ this.engine.interrupt();
482309
+ this.sm.transition("aborting", "destroy() during prompt");
482310
+ const drainDeadline = Date.now() + 5000;
482311
+ while (this.sm.state === "aborting" && Date.now() < drainDeadline) {
482312
+ await new Promise((r) => setTimeout(r, 10));
482313
+ }
482314
+ }
482315
+ this.sm.transition("destroying", "destroy()");
482316
+ this.engine.destroy();
482062
482317
  this.bootstrapResult.cleanup();
482063
482318
  for (const client2 of this.mcpClients) {
482064
482319
  if (client2.type === "connected" && client2.cleanup) {
482065
- client2.cleanup().catch(() => {});
482320
+ try {
482321
+ await client2.cleanup();
482322
+ } catch {}
482066
482323
  }
482067
482324
  }
482325
+ this.sm.transition("destroyed", "cleanup complete");
482326
+ }
482327
+ getState() {
482328
+ return {
482329
+ state: this.sm.state,
482330
+ sessionId: this.sessionId,
482331
+ createdAt: this.createdAt,
482332
+ lastPromptAt: this.lastPromptAt
482333
+ };
482334
+ }
482335
+ getStateHistory() {
482336
+ return this.sm.history;
482068
482337
  }
482069
482338
  static resume(sessionId, config5, permissionHandler) {
482070
482339
  const session2 = new Session(config5 ?? {}, permissionHandler ?? {});
@@ -482080,20 +482349,22 @@ class Session {
482080
482349
  const sessions = await listSessionsImpl2(options);
482081
482350
  return sessions.find((s) => s.sessionId === sessionId);
482082
482351
  }
482083
- assertAlive() {
482084
- if (this.destroyed) {
482085
- throw new Error("Session has been destroyed");
482086
- }
482087
- }
482088
482352
  }
482089
482353
 
482090
482354
  // src/entrypoints/gateway/worker.ts
482091
482355
  var config5 = workerData;
482092
482356
  var { sessionKey } = config5;
482093
482357
  var PERMISSION_TIMEOUT_MS = 60000;
482358
+ var messageQueue = [];
482359
+ var processingMessage = false;
482360
+ function logState(reason) {
482361
+ const state = session2.getState().state;
482362
+ process.stderr.write(`[Worker ${sessionKey}] State: ${state}${reason ? ` (${reason})` : ""}
482363
+ `);
482364
+ }
482094
482365
  var pendingPermissions = new Map;
482366
+ var savedPermissionCallback;
482095
482367
  var session2;
482096
- var running = false;
482097
482368
  function send(msg) {
482098
482369
  parentPort.postMessage(msg);
482099
482370
  }
@@ -482106,37 +482377,72 @@ function buildScopedMcpConfigs(mcpServers) {
482106
482377
  }
482107
482378
  return scoped;
482108
482379
  }
482109
- async function connectMcpServers() {
482110
- const mcpConfigs = buildScopedMcpConfigs(config5.session.mcpServers);
482380
+ async function connectMcpServers(mcpServers) {
482381
+ const mcpConfigs = buildScopedMcpConfigs(mcpServers);
482111
482382
  if (!mcpConfigs)
482112
- return [];
482113
- try {
482114
- const { prefetchAllMcpResources: prefetchAllMcpResources2 } = await Promise.resolve().then(() => (init_client5(), exports_client));
482115
- const { clients } = await prefetchAllMcpResources2(mcpConfigs);
482116
- return clients;
482117
- } catch (err2) {
482118
- process.stderr.write(`MCP connection failed: ${err2 instanceof Error ? err2.message : String(err2)}
482119
- `);
482120
- return [];
482121
- }
482383
+ return { clients: [], mcpTools: [] };
482384
+ const { prefetchAllMcpResources: prefetchAllMcpResources2 } = await Promise.resolve().then(() => (init_client5(), exports_client));
482385
+ const { clients, tools: mcpTools } = await prefetchAllMcpResources2(mcpConfigs);
482386
+ return { clients, mcpTools };
482122
482387
  }
482123
482388
  async function start() {
482389
+ process.stderr.write(`[Worker ${sessionKey}] Starting worker
482390
+ `);
482124
482391
  if (config5.env) {
482125
482392
  Object.assign(process.env, config5.env);
482126
482393
  }
482127
482394
  const { enableConfigs: enableConfigs2 } = await Promise.resolve().then(() => (init_config(), exports_config));
482128
482395
  enableConfigs2();
482396
+ let initialMessages;
482397
+ if (config5.resume) {
482398
+ const { switchSession: switchSession2 } = await Promise.resolve().then(() => (init_state(), exports_state));
482399
+ const { getLastSessionLog: getLastSessionLog2 } = await Promise.resolve().then(() => (init_sessionStorage(), exports_sessionStorage));
482400
+ switchSession2(config5.resume);
482401
+ process.stderr.write(`[Worker ${sessionKey}] Resuming session: ${config5.resume}
482402
+ `);
482403
+ try {
482404
+ const log2 = await getLastSessionLog2(config5.resume);
482405
+ initialMessages = log2?.messages ?? undefined;
482406
+ if (initialMessages) {
482407
+ process.stderr.write(`[Worker ${sessionKey}] Loaded ${initialMessages.length} history messages
482408
+ `);
482409
+ }
482410
+ } catch (err2) {
482411
+ process.stderr.write(`[Worker ${sessionKey}] Failed to load session history: ${err2 instanceof Error ? err2.message : String(err2)}
482412
+ `);
482413
+ }
482414
+ }
482415
+ if (process.platform === "win32") {
482416
+ const { setShellIfWindows: setShellIfWindows2 } = await Promise.resolve().then(() => (init_windowsPaths(), exports_windowsPaths));
482417
+ setShellIfWindows2();
482418
+ process.stderr.write(`[Worker ${sessionKey}] Shell: ${process.env.SHELL ?? "not found"}
482419
+ `);
482420
+ }
482129
482421
  if (config5.session.additionalDirectories?.length) {
482130
482422
  const { setAdditionalDirectoriesForClaudeMd: setAdditionalDirectoriesForClaudeMd2 } = await Promise.resolve().then(() => (init_state(), exports_state));
482131
482423
  setAdditionalDirectoriesForClaudeMd2(config5.session.additionalDirectories);
482132
482424
  }
482133
- const mcpClients = await connectMcpServers();
482425
+ let mcpClients = [];
482426
+ try {
482427
+ const result = await connectMcpServers(config5.session.mcpServers);
482428
+ mcpClients = result.clients;
482429
+ } catch (err2) {
482430
+ process.stderr.write(`[Worker ${sessionKey}] Initial MCP connection failed, continuing without MCP: ${err2 instanceof Error ? err2.message : String(err2)}
482431
+ `);
482432
+ }
482433
+ const sessionExtraOptions = {};
482434
+ if (mcpClients.length > 0)
482435
+ sessionExtraOptions.mcpClients = mcpClients;
482436
+ if (initialMessages)
482437
+ sessionExtraOptions.initialMessages = initialMessages;
482134
482438
  session2 = new Session(config5.session, {
482135
482439
  mode: config5.permission.mode,
482136
482440
  allowedTools: config5.permission.allowed_tools,
482137
482441
  deniedTools: config5.permission.denied_tools,
482138
- onPermissionRequest: async (request) => {
482442
+ onPermissionRequest: savedPermissionCallback = async (request) => {
482139
482443
  const requestId = crypto.randomUUID();
482444
+ process.stderr.write(`[Worker ${sessionKey}] Permission request: ${request.toolName}
482445
+ `);
482140
482446
  send({
482141
482447
  type: "permission_request",
482142
482448
  session_key: sessionKey,
@@ -482149,44 +482455,79 @@ async function start() {
482149
482455
  return await new Promise((resolve43, reject2) => {
482150
482456
  const timer = setTimeout(() => {
482151
482457
  pendingPermissions.delete(requestId);
482458
+ process.stderr.write(`[Worker ${sessionKey}] Permission request timed out: ${requestId}
482459
+ `);
482152
482460
  reject2(new Error("Permission request timed out"));
482153
482461
  }, PERMISSION_TIMEOUT_MS);
482154
482462
  pendingPermissions.set(requestId, { resolve: resolve43, reject: reject2, timer });
482155
482463
  });
482156
482464
  }
482157
- }, mcpClients.length > 0 ? { mcpClients } : undefined);
482465
+ }, sessionExtraOptions);
482466
+ logState("session ready");
482467
+ const { getSessionId: getSessionId3 } = await Promise.resolve().then(() => (init_state(), exports_state));
482468
+ process.stderr.write(`[Worker ${sessionKey}] Session ready, sessionId: ${session2.sessionId}, stateSessionId: ${getSessionId3()}
482469
+ `);
482158
482470
  send({
482159
482471
  type: "ready",
482160
482472
  session_key: sessionKey,
482161
- session_id: session2.sessionId
482473
+ session_id: session2.sessionId,
482474
+ state_session_id: getSessionId3()
482162
482475
  });
482163
482476
  parentPort.on("message", (msg) => {
482164
482477
  switch (msg.type) {
482165
- case "prompt":
482166
- handlePrompt(msg.text);
482167
- break;
482168
482478
  case "interrupt":
482479
+ process.stderr.write(`[Worker ${sessionKey}] Session interrupted
482480
+ `);
482169
482481
  session2.abort();
482170
482482
  break;
482171
- case "destroy":
482172
- session2.destroy();
482173
- break;
482174
482483
  case "permission_response":
482175
482484
  handlePermissionResponse(msg.request_id, msg.result);
482176
482485
  break;
482486
+ default:
482487
+ if (processingMessage) {
482488
+ messageQueue.push(msg);
482489
+ } else {
482490
+ dequeueAndProcess(msg);
482491
+ }
482492
+ break;
482177
482493
  }
482178
482494
  });
482179
482495
  }
482496
+ async function dequeueAndProcess(msg) {
482497
+ processingMessage = true;
482498
+ try {
482499
+ switch (msg.type) {
482500
+ case "prompt":
482501
+ await handlePrompt(msg.text);
482502
+ break;
482503
+ case "update":
482504
+ await handleUpdate(msg.config);
482505
+ break;
482506
+ case "destroy":
482507
+ await handleDestroy();
482508
+ break;
482509
+ }
482510
+ } finally {
482511
+ processingMessage = false;
482512
+ const next = messageQueue.shift();
482513
+ if (next) {
482514
+ dequeueAndProcess(next);
482515
+ }
482516
+ }
482517
+ }
482180
482518
  async function handlePrompt(text2) {
482181
- if (running) {
482519
+ const state = session2.getState().state;
482520
+ if (state !== "idle") {
482521
+ process.stderr.write(`[Worker ${sessionKey}] Prompt rejected: session state is ${state}
482522
+ `);
482182
482523
  send({
482183
482524
  type: "error",
482184
482525
  session_key: sessionKey,
482185
- error: "Session is already running a prompt"
482526
+ error: `Session is busy (state: ${state})`
482186
482527
  });
482187
482528
  return;
482188
482529
  }
482189
- running = true;
482530
+ logState(`prompt(${text2.slice(0, 50)})`);
482190
482531
  try {
482191
482532
  for await (const sdkMsg of session2.prompt(text2)) {
482192
482533
  send({
@@ -482200,16 +482541,113 @@ async function handlePrompt(text2) {
482200
482541
  session_key: sessionKey,
482201
482542
  session_id: session2.sessionId
482202
482543
  });
482544
+ process.stderr.write(`[Worker ${sessionKey}] Prompt completed successfully
482545
+ `);
482203
482546
  } catch (err2) {
482547
+ const errorMsg = err2 instanceof Error ? err2.message : String(err2);
482548
+ process.stderr.write(`[Worker ${sessionKey}] Prompt failed: ${errorMsg}
482549
+ `);
482204
482550
  send({
482205
482551
  type: "error",
482206
482552
  session_key: sessionKey,
482207
- error: err2 instanceof Error ? err2.message : String(err2)
482553
+ error: errorMsg
482208
482554
  });
482209
482555
  } finally {
482210
- running = false;
482556
+ logState("prompt done");
482211
482557
  }
482212
482558
  }
482559
+ async function handleUpdate(updateConfig2) {
482560
+ const state = session2.getState().state;
482561
+ if (state !== "idle") {
482562
+ send({
482563
+ type: "error",
482564
+ session_key: sessionKey,
482565
+ error: `Cannot update: session state is ${state}`
482566
+ });
482567
+ return;
482568
+ }
482569
+ logState("session.update starting");
482570
+ const changes = [];
482571
+ try {
482572
+ if (updateConfig2.env) {
482573
+ Object.assign(process.env, updateConfig2.env);
482574
+ changes.push("env");
482575
+ }
482576
+ const batchUpdate = {};
482577
+ if (updateConfig2.mcp_servers !== undefined) {
482578
+ const { clients, mcpTools } = await connectMcpServers(updateConfig2.mcp_servers);
482579
+ batchUpdate.mcpClients = clients;
482580
+ batchUpdate.mcpTools = mcpTools;
482581
+ changes.push(`mcpServers: ${clients.length} clients`);
482582
+ }
482583
+ if (updateConfig2.additional_directories) {
482584
+ const { setAdditionalDirectoriesForClaudeMd: setAdditionalDirectoriesForClaudeMd2 } = await Promise.resolve().then(() => (init_state(), exports_state));
482585
+ setAdditionalDirectoriesForClaudeMd2(updateConfig2.additional_directories);
482586
+ batchUpdate.additionalDirectories = updateConfig2.additional_directories;
482587
+ changes.push(`additionalDirectories: ${updateConfig2.additional_directories.length} dirs`);
482588
+ }
482589
+ if (updateConfig2.system_prompt !== undefined) {
482590
+ batchUpdate.systemPrompt = updateConfig2.system_prompt;
482591
+ changes.push("systemPrompt");
482592
+ }
482593
+ if (updateConfig2.append_system_prompt !== undefined) {
482594
+ batchUpdate.appendSystemPrompt = updateConfig2.append_system_prompt;
482595
+ changes.push("appendSystemPrompt");
482596
+ }
482597
+ if (updateConfig2.model) {
482598
+ batchUpdate.model = updateConfig2.model;
482599
+ changes.push(`model: ${updateConfig2.model}`);
482600
+ }
482601
+ if (updateConfig2.max_turns !== undefined) {
482602
+ batchUpdate.maxTurns = updateConfig2.max_turns;
482603
+ changes.push(`maxTurns: ${updateConfig2.max_turns}`);
482604
+ }
482605
+ if (updateConfig2.thinking) {
482606
+ batchUpdate.thinking = updateConfig2.thinking;
482607
+ changes.push("thinking");
482608
+ }
482609
+ if (updateConfig2.permission_mode !== undefined || updateConfig2.allowed_tools !== undefined) {
482610
+ batchUpdate.permissionHandler = {
482611
+ mode: updateConfig2.permission_mode,
482612
+ allowedTools: updateConfig2.allowed_tools,
482613
+ deniedTools: updateConfig2.denied_tools,
482614
+ onPermissionRequest: savedPermissionCallback
482615
+ };
482616
+ changes.push("permission");
482617
+ }
482618
+ if (Object.keys(batchUpdate).length > 0) {
482619
+ await session2.update(batchUpdate);
482620
+ }
482621
+ process.stderr.write(`[Worker ${sessionKey}] Session updated: ${changes.join(", ")}
482622
+ `);
482623
+ send({ type: "updated", session_key: sessionKey });
482624
+ } catch (err2) {
482625
+ const errorMsg = err2 instanceof Error ? err2.message : String(err2);
482626
+ process.stderr.write(`[Worker ${sessionKey}] Update failed: ${errorMsg}
482627
+ `);
482628
+ send({ type: "error", session_key: sessionKey, error: errorMsg });
482629
+ } finally {
482630
+ logState("update done");
482631
+ }
482632
+ }
482633
+ async function handleDestroy() {
482634
+ const state = session2.getState().state;
482635
+ if (state === "destroyed")
482636
+ return;
482637
+ logState("destroy");
482638
+ process.stderr.write(`[Worker ${sessionKey}] Destroying session
482639
+ `);
482640
+ try {
482641
+ await session2.destroy();
482642
+ logState("cleanup done");
482643
+ } catch (err2) {
482644
+ const errorMsg = err2 instanceof Error ? err2.message : String(err2);
482645
+ process.stderr.write(`[Worker ${sessionKey}] Destroy error (forcing exit): ${errorMsg}
482646
+ `);
482647
+ logState("destroy error");
482648
+ }
482649
+ process.exit(0);
482650
+ }
482213
482651
  function handlePermissionResponse(requestId, result) {
482214
482652
  const pending = pendingPermissions.get(requestId);
482215
482653
  if (pending) {
@@ -482226,16 +482664,24 @@ start().catch((err2) => {
482226
482664
  });
482227
482665
  });
482228
482666
  process.on("uncaughtException", (err2) => {
482667
+ const errorDetails = err2 instanceof Error ? err2.stack || err2.message : String(err2);
482668
+ process.stderr.write(`[Worker ${sessionKey}] Uncaught exception: ${errorDetails}
482669
+ `);
482229
482670
  send({
482230
482671
  type: "error",
482231
482672
  session_key: sessionKey,
482232
- error: `Uncaught exception: ${err2 instanceof Error ? err2.stack || err2.message : String(err2)}`
482673
+ error: `Uncaught exception: ${errorDetails}`
482233
482674
  });
482675
+ setTimeout(() => process.exit(1), 100);
482234
482676
  });
482235
482677
  process.on("unhandledRejection", (reason) => {
482678
+ const reasonDetails = reason instanceof Error ? reason.stack || reason.message : String(reason);
482679
+ process.stderr.write(`[Worker ${sessionKey}] Unhandled rejection: ${reasonDetails}
482680
+ `);
482236
482681
  send({
482237
482682
  type: "error",
482238
482683
  session_key: sessionKey,
482239
- error: `Unhandled rejection: ${reason instanceof Error ? reason.stack || reason.message : String(reason)}`
482684
+ error: `Unhandled rejection: ${reasonDetails}`
482240
482685
  });
482686
+ setTimeout(() => process.exit(1), 100);
482241
482687
  });