@caspian2026/agent-sdk 0.0.2 → 0.0.3

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 (219) hide show
  1. package/dist/{chunk-6gh20s05.js → chunk-0ey4cg5k.js} +16 -16
  2. package/dist/{chunk-s4cb0bcb.js → chunk-0fqnpjb8.js} +1 -1
  3. package/dist/{chunk-qfk94vcn.js → chunk-0g5cy3wj.js} +4 -4
  4. package/dist/{chunk-p11xp4xp.js → chunk-0q8745s9.js} +1 -1
  5. package/dist/{chunk-e97mp86b.js → chunk-0x81g48x.js} +21 -21
  6. package/dist/{chunk-vrf54kmt.js → chunk-0ze8q2yz.js} +1 -1
  7. package/dist/{chunk-prcah3ys.js → chunk-11mzpgem.js} +15 -15
  8. package/dist/{chunk-etgh9xvt.js → chunk-18c4q7fg.js} +17 -17
  9. package/dist/{chunk-9grztvcg.js → chunk-19fq1kwa.js} +18 -18
  10. package/dist/{chunk-vmbfv1y5.js → chunk-1dtg5p61.js} +2 -2
  11. package/dist/{chunk-kqggbte3.js → chunk-1ef43gpq.js} +15 -15
  12. package/dist/{chunk-3qbdzsvm.js → chunk-1xfvkmkt.js} +2 -2
  13. package/dist/{chunk-gkyzz8er.js → chunk-2bhq6mq2.js} +2 -2
  14. package/dist/{chunk-pkkngdv0.js → chunk-2dgcm775.js} +64 -64
  15. package/dist/{chunk-46n7byh8.js → chunk-2dzpw3wn.js} +18 -18
  16. package/dist/{chunk-wby6yd4m.js → chunk-2ht8gq9b.js} +16 -16
  17. package/dist/{chunk-rsq0h0rz.js → chunk-2me4kc29.js} +21 -21
  18. package/dist/{chunk-7gvwg1v9.js → chunk-2t3805kp.js} +18 -18
  19. package/dist/{chunk-0kxcq8h9.js → chunk-361d4z05.js} +16 -16
  20. package/dist/{chunk-mpk1sjyk.js → chunk-3bfn2a4v.js} +23 -23
  21. package/dist/{chunk-waqwgprq.js → chunk-3jty4gzq.js} +25 -25
  22. package/dist/{chunk-cxq7gc42.js → chunk-408jazm9.js} +15 -15
  23. package/dist/{chunk-mpbfkp8j.js → chunk-44pwvyq7.js} +15 -15
  24. package/dist/{chunk-spybh2dy.js → chunk-4be5h0yc.js} +15 -15
  25. package/dist/{chunk-yg4vgpxs.js → chunk-4nf2fyk9.js} +2 -2
  26. package/dist/{chunk-80a8vabn.js → chunk-56sxesq4.js} +18 -18
  27. package/dist/{chunk-8qhxyqj9.js → chunk-5ansv95b.js} +15 -15
  28. package/dist/{chunk-572vjq78.js → chunk-5d6qszza.js} +3 -3
  29. package/dist/{chunk-msecaxyj.js → chunk-5fczbwbd.js} +1 -1
  30. package/dist/{chunk-ne5r3k03.js → chunk-5seqsaw2.js} +16 -16
  31. package/dist/{chunk-nebezy1d.js → chunk-6a1a7h81.js} +1 -1
  32. package/dist/{chunk-hzgnejb1.js → chunk-6ap6tj51.js} +2 -2
  33. package/dist/{chunk-jss0azv7.js → chunk-6cv9d7sq.js} +15 -15
  34. package/dist/{chunk-nxgsnh2y.js → chunk-6d4v1hv4.js} +1 -1
  35. package/dist/{chunk-46hd1gyd.js → chunk-6dkz81cc.js} +1 -1
  36. package/dist/{chunk-ahr1r7c6.js → chunk-6g08p77s.js} +14 -14
  37. package/dist/{chunk-wtjt9qyk.js → chunk-6hw0f4ym.js} +10 -10
  38. package/dist/{chunk-1yrcnrs7.js → chunk-6zkha0yn.js} +16 -16
  39. package/dist/{chunk-ysanv95x.js → chunk-71kpm320.js} +1 -1
  40. package/dist/{chunk-ratvcbmn.js → chunk-72eqezp9.js} +16 -16
  41. package/dist/{chunk-zpmwvd09.js → chunk-72wwwagz.js} +2 -2
  42. package/dist/{chunk-wjcq2vkf.js → chunk-73hk10ba.js} +15 -15
  43. package/dist/{chunk-7h2ybnf3.js → chunk-75sn3f0z.js} +15 -15
  44. package/dist/{chunk-ercvcek8.js → chunk-7800bmte.js} +15 -15
  45. package/dist/{chunk-zf47r1b7.js → chunk-781e202z.js} +15 -15
  46. package/dist/{chunk-2n7bbxm6.js → chunk-79vgx5xx.js} +16 -16
  47. package/dist/{chunk-7kcm5hn2.js → chunk-7ft9zhef.js} +3 -3
  48. package/dist/{chunk-xzhaa7gd.js → chunk-7h07x96r.js} +15 -15
  49. package/dist/{chunk-3389cj3w.js → chunk-7kbkx0yy.js} +15 -15
  50. package/dist/{chunk-n0kmh4ra.js → chunk-7thhwqxr.js} +1 -1
  51. package/dist/{chunk-jyw3np47.js → chunk-7ty8tj56.js} +3 -3
  52. package/dist/{chunk-8mkwsdk1.js → chunk-7xshmwm1.js} +1 -1
  53. package/dist/{chunk-5dmhsqap.js → chunk-7yr67s8x.js} +2 -2
  54. package/dist/{chunk-68w91pzt.js → chunk-89cp87ps.js} +2 -2
  55. package/dist/{chunk-jgwd85hp.js → chunk-8b84wjgw.js} +18 -18
  56. package/dist/{chunk-fn1vvj8k.js → chunk-8c2eawmj.js} +15 -15
  57. package/dist/{chunk-jk69qtzx.js → chunk-8jjqfmfc.js} +15 -15
  58. package/dist/{chunk-q6cfkntd.js → chunk-8mp4fwz4.js} +20 -20
  59. package/dist/{chunk-chakj069.js → chunk-8pq8e1bn.js} +2 -2
  60. package/dist/{chunk-my40g5hp.js → chunk-9159pxty.js} +17 -17
  61. package/dist/{chunk-sfcpjh4r.js → chunk-96aeszqf.js} +15 -15
  62. package/dist/{chunk-p1hwrf72.js → chunk-9e0gg5n6.js} +6 -6
  63. package/dist/{chunk-pqvr8jq7.js → chunk-9gmagxgg.js} +16 -16
  64. package/dist/{chunk-v8g3kad0.js → chunk-9jpgcgjx.js} +16 -16
  65. package/dist/{chunk-162ewhvy.js → chunk-9w6vmnwm.js} +15 -15
  66. package/dist/{chunk-w004kfw0.js → chunk-a2g1kkb0.js} +23 -23
  67. package/dist/{chunk-qj2mk79w.js → chunk-abfc6bsz.js} +2 -2
  68. package/dist/{chunk-a8792r1c.js → chunk-ac5wa5c1.js} +3 -3
  69. package/dist/{chunk-nhapyawz.js → chunk-b63w1za4.js} +55 -55
  70. package/dist/{chunk-7acgdm7x.js → chunk-b7j8wgza.js} +3 -3
  71. package/dist/{chunk-q7zpf4r2.js → chunk-bch5pzsb.js} +1 -1
  72. package/dist/{chunk-5rt4b8q9.js → chunk-bdepkffm.js} +23 -23
  73. package/dist/{chunk-gdg6411p.js → chunk-bjhshbab.js} +15 -15
  74. package/dist/{chunk-50bay5qy.js → chunk-bjqfz533.js} +27 -27
  75. package/dist/{chunk-p39a677r.js → chunk-bpye0b8s.js} +23 -23
  76. package/dist/{chunk-vjn8mbcw.js → chunk-bvm1dctd.js} +3 -3
  77. package/dist/{chunk-n18q5yqs.js → chunk-c18kgbb7.js} +25 -25
  78. package/dist/{chunk-v0qraze5.js → chunk-cfx7wfk6.js} +15 -15
  79. package/dist/{chunk-5nchekqe.js → chunk-cpmn4fjt.js} +3 -3
  80. package/dist/{chunk-kvfg8eeg.js → chunk-cpyrcg4y.js} +1 -1
  81. package/dist/{chunk-zx5kw7z4.js → chunk-crsch4vf.js} +2 -2
  82. package/dist/{chunk-fbvw6wq9.js → chunk-cscdr443.js} +23 -23
  83. package/dist/{chunk-mxr2s6d1.js → chunk-ct6rynsc.js} +16 -16
  84. package/dist/{chunk-tqmtkm0k.js → chunk-dhk1bbnx.js} +15 -15
  85. package/dist/{chunk-pcb7fbyg.js → chunk-dn3wnpzd.js} +3 -3
  86. package/dist/{chunk-26hg7303.js → chunk-dqb56c5c.js} +2 -2
  87. package/dist/{chunk-q6xs51jj.js → chunk-dyb2pz6v.js} +2 -2
  88. package/dist/{chunk-35sgv3er.js → chunk-e2msjgt3.js} +3 -3
  89. package/dist/{chunk-7yxvpj5j.js → chunk-e927d4zv.js} +16 -16
  90. package/dist/{chunk-5pp28k2r.js → chunk-eaecret8.js} +1 -1
  91. package/dist/{chunk-cdhmrbj4.js → chunk-ecn92eyg.js} +46 -46
  92. package/dist/{chunk-8hj8ms5q.js → chunk-ek8yfknw.js} +4 -4
  93. package/dist/{chunk-jfja8q7w.js → chunk-ekabtxs5.js} +16 -16
  94. package/dist/{chunk-e4p1jbs4.js → chunk-enw0tvvd.js} +3 -3
  95. package/dist/{chunk-0kj8bq80.js → chunk-epbatqnz.js} +15 -15
  96. package/dist/{chunk-2352ts05.js → chunk-ethz3kk6.js} +5 -5
  97. package/dist/{chunk-10qhq6f8.js → chunk-exzfhqcw.js} +7 -7
  98. package/dist/{chunk-d7f1pzkq.js → chunk-ez5g4s3x.js} +3 -3
  99. package/dist/{chunk-69fgaak0.js → chunk-ezewb24j.js} +20 -20
  100. package/dist/{chunk-21bcvwr7.js → chunk-f8k2m8t5.js} +2 -2
  101. package/dist/{chunk-e8p3fy6v.js → chunk-f9pmx93x.js} +15 -15
  102. package/dist/{chunk-qygmcg7w.js → chunk-fahjtsky.js} +3 -3
  103. package/dist/{chunk-jxpmkae9.js → chunk-fddncz1a.js} +17 -17
  104. package/dist/{chunk-3e20cj49.js → chunk-fn27e5q1.js} +4 -4
  105. package/dist/{chunk-15sfg4bs.js → chunk-ftqr2rnb.js} +1 -1
  106. package/dist/{chunk-npnvheft.js → chunk-fy3wj80e.js} +18 -18
  107. package/dist/{chunk-gcpfxk0c.js → chunk-fzhwt8cv.js} +3 -3
  108. package/dist/{chunk-kjh11txh.js → chunk-g1mv9mvv.js} +15 -15
  109. package/dist/{chunk-5apfzkpy.js → chunk-g7e5d5p6.js} +2 -2
  110. package/dist/{chunk-505mxxa9.js → chunk-ga86yjm1.js} +4 -4
  111. package/dist/{chunk-h6fsks9j.js → chunk-gh22pv06.js} +16 -16
  112. package/dist/{chunk-70cw4cg9.js → chunk-gksbas59.js} +8 -8
  113. package/dist/{chunk-e2mv8ts8.js → chunk-gnhmax8q.js} +16 -16
  114. package/dist/{chunk-d4kwjqjy.js → chunk-gy8bxg6y.js} +1 -1
  115. package/dist/{chunk-vzgkedm9.js → chunk-h0xhdme4.js} +139 -139
  116. package/dist/{chunk-8y30k9pz.js → chunk-h7g702xg.js} +2 -2
  117. package/dist/{chunk-tc1aazk4.js → chunk-hmvgaxcy.js} +16 -16
  118. package/dist/{chunk-bktfq0ns.js → chunk-hp36phn4.js} +21 -21
  119. package/dist/{chunk-htpehq9t.js → chunk-hy6v0p5h.js} +2 -2
  120. package/dist/{chunk-c5mz5vw2.js → chunk-hzr8wcet.js} +2 -2
  121. package/dist/{chunk-0htx82k2.js → chunk-j814rssk.js} +3 -3
  122. package/dist/{chunk-q6m26rc8.js → chunk-j8tgj0nj.js} +15 -15
  123. package/dist/{chunk-q3jr5t07.js → chunk-ja0e0n2h.js} +2 -2
  124. package/dist/{chunk-f0rzvqmq.js → chunk-jck1zn7p.js} +1 -1
  125. package/dist/{chunk-fshfxw2q.js → chunk-jdkxtvsq.js} +1 -1
  126. package/dist/{chunk-b2fd462a.js → chunk-jfndcmsy.js} +1 -1
  127. package/dist/{chunk-537qfvn5.js → chunk-jsmf95r7.js} +17 -17
  128. package/dist/{chunk-3yprydpw.js → chunk-jx1pp4q8.js} +16 -16
  129. package/dist/{chunk-k3939ggz.js → chunk-ke2cy3b6.js} +15 -15
  130. package/dist/{chunk-qwqjesx7.js → chunk-kh6vcrwx.js} +5 -5
  131. package/dist/{chunk-zghtdbat.js → chunk-khdcvjdb.js} +3 -3
  132. package/dist/{chunk-3mr5ryx4.js → chunk-kt7bv7ky.js} +3 -3
  133. package/dist/{chunk-w0yhbmxn.js → chunk-kxjevttw.js} +18 -18
  134. package/dist/{chunk-k2rybwww.js → chunk-kzmh7ra2.js} +16 -16
  135. package/dist/{chunk-hchy0hq6.js → chunk-m0v0xgsr.js} +3 -3
  136. package/dist/{chunk-efgjfast.js → chunk-m1f7cfnj.js} +1 -1
  137. package/dist/{chunk-bvf2z3g6.js → chunk-m7emb9zr.js} +18 -18
  138. package/dist/{chunk-960ze3jj.js → chunk-mcfc152r.js} +15 -15
  139. package/dist/{chunk-ebqwkhyf.js → chunk-mf0c3jdd.js} +63 -63
  140. package/dist/{chunk-yk62vxj2.js → chunk-mk23f69h.js} +7 -7
  141. package/dist/{chunk-0jmt5sx1.js → chunk-mw580pc6.js} +15 -15
  142. package/dist/{chunk-hyb749hd.js → chunk-mw970f89.js} +15 -15
  143. package/dist/{chunk-2vqrdwx9.js → chunk-mx77s51x.js} +5 -5
  144. package/dist/{chunk-5fs6nkjr.js → chunk-nmk3h03d.js} +1 -1
  145. package/dist/{chunk-tvgvt220.js → chunk-nqn45znr.js} +9 -9
  146. package/dist/{chunk-m1cehfta.js → chunk-nstcd31j.js} +15 -15
  147. package/dist/{chunk-018smjq7.js → chunk-nvkqnxse.js} +1 -1
  148. package/dist/{chunk-zshzdw1n.js → chunk-nvqyjpk0.js} +16 -16
  149. package/dist/{chunk-beg7bdyz.js → chunk-p897jpw3.js} +15 -15
  150. package/dist/{chunk-f1m9pect.js → chunk-pkxf7b8m.js} +15 -15
  151. package/dist/{chunk-yff68ex1.js → chunk-prmmnxrv.js} +2 -2
  152. package/dist/{chunk-k5ez1h65.js → chunk-qaafznja.js} +15 -15
  153. package/dist/{chunk-zb8f6h5g.js → chunk-qcm6cec5.js} +98 -98
  154. package/dist/{chunk-2h05vtpv.js → chunk-qgrxp31t.js} +2 -2
  155. package/dist/{chunk-ctdg0qxh.js → chunk-qkn0t7qw.js} +22 -22
  156. package/dist/{chunk-c37j5zxe.js → chunk-qrxnqq1e.js} +4 -4
  157. package/dist/{chunk-tjcfpk38.js → chunk-qrzch8z1.js} +2 -2
  158. package/dist/{chunk-kajf3jgq.js → chunk-qybvf59x.js} +21 -21
  159. package/dist/{chunk-hx3j6n92.js → chunk-r25gxvfw.js} +16 -16
  160. package/dist/{chunk-430yrtmk.js → chunk-r9wd5vyt.js} +16 -16
  161. package/dist/{chunk-8n42zyfx.js → chunk-rahj2cma.js} +2 -2
  162. package/dist/{chunk-055q0a2m.js → chunk-rv3mfwbg.js} +2 -2
  163. package/dist/{chunk-j3zhb8vv.js → chunk-s6x5f0r9.js} +1 -1
  164. package/dist/{chunk-qzj4e8fn.js → chunk-sa05epz2.js} +4 -4
  165. package/dist/{chunk-nb6abcch.js → chunk-sbtw37tw.js} +2 -2
  166. package/dist/{chunk-exah13mz.js → chunk-sbxet7s6.js} +15 -15
  167. package/dist/{chunk-6t4a9cgj.js → chunk-sdv9rd2d.js} +7 -7
  168. package/dist/{chunk-e4bhfc6d.js → chunk-sk71mpcs.js} +15 -15
  169. package/dist/{chunk-4dn3n459.js → chunk-spkndfy1.js} +15 -15
  170. package/dist/{chunk-ev3qkf76.js → chunk-t1ad6f2g.js} +16 -16
  171. package/dist/{chunk-kbm69rtz.js → chunk-t1jxa0p1.js} +2 -2
  172. package/dist/{chunk-sw9ax3ym.js → chunk-t2s1skd1.js} +19 -19
  173. package/dist/{chunk-682qgta2.js → chunk-t4z5dzj5.js} +15 -15
  174. package/dist/{chunk-2nv3d0he.js → chunk-tba8ad4h.js} +15 -15
  175. package/dist/{chunk-ped973jn.js → chunk-tbkmn3tw.js} +2 -2
  176. package/dist/{chunk-7m2hp89m.js → chunk-tcwb3a2s.js} +3 -3
  177. package/dist/{chunk-p1zj9mg9.js → chunk-tg8c7b7e.js} +15 -15
  178. package/dist/{chunk-q8c88vjm.js → chunk-tj0q283m.js} +1 -1
  179. package/dist/{chunk-zesnmkg3.js → chunk-tm5jd44f.js} +3 -3
  180. package/dist/{chunk-k591cwbg.js → chunk-tr74vr8t.js} +16 -16
  181. package/dist/{chunk-jy9rxxqe.js → chunk-ttzbsh14.js} +3 -3
  182. package/dist/{chunk-mg7pbk0r.js → chunk-v270w96b.js} +1 -1
  183. package/dist/{chunk-6maej1hh.js → chunk-v6qkcn3c.js} +2 -2
  184. package/dist/{chunk-zr6mz36s.js → chunk-v89zna4t.js} +2 -2
  185. package/dist/{chunk-jr1xm1dd.js → chunk-vh316r81.js} +20 -20
  186. package/dist/{chunk-zqncgyf6.js → chunk-vh5hef50.js} +16 -16
  187. package/dist/{chunk-1c4j7qn2.js → chunk-vnd60kzr.js} +17 -17
  188. package/dist/{chunk-46hdszda.js → chunk-w1qjz3ym.js} +1 -1
  189. package/dist/{chunk-rvnb2gn6.js → chunk-wdbd36jw.js} +15 -15
  190. package/dist/{chunk-d1pyf9as.js → chunk-wgx1c22r.js} +10 -10
  191. package/dist/{chunk-1xvcvdef.js → chunk-wpr48ga6.js} +17 -17
  192. package/dist/{chunk-pckwmrzd.js → chunk-wtjrbc18.js} +3 -3
  193. package/dist/{chunk-b0qptb1k.js → chunk-wxbfyvkv.js} +1 -1
  194. package/dist/{chunk-bdrjvs5k.js → chunk-x0zq9nvp.js} +2 -2
  195. package/dist/{chunk-cc2tg4q8.js → chunk-x5y2at68.js} +1 -1
  196. package/dist/{chunk-vb3x3cxe.js → chunk-xa4rted0.js} +24 -24
  197. package/dist/{chunk-19e603rv.js → chunk-xds4gydx.js} +15 -15
  198. package/dist/{chunk-qq0phwn8.js → chunk-xk154b34.js} +16 -16
  199. package/dist/{chunk-rx278zpa.js → chunk-xn9m0kzv.js} +1 -1
  200. package/dist/{chunk-177s15bv.js → chunk-xpb339s9.js} +1 -1
  201. package/dist/{chunk-6vthy0fj.js → chunk-xr0306g4.js} +15 -15
  202. package/dist/{chunk-2h0y6m16.js → chunk-xwtahnmz.js} +4 -4
  203. package/dist/{chunk-6t8yqfks.js → chunk-y06wew00.js} +17 -17
  204. package/dist/{chunk-nw9t5pq9.js → chunk-y3hd0azg.js} +1 -1
  205. package/dist/{chunk-qj2e1apf.js → chunk-yfwxjr5b.js} +17 -17
  206. package/dist/{chunk-kr6qfwq0.js → chunk-yhrmtb28.js} +1 -1
  207. package/dist/{chunk-en8wkxh7.js → chunk-yr9sczgc.js} +4 -4
  208. package/dist/{chunk-gxahdggv.js → chunk-z4t6b6c4.js} +1 -1
  209. package/dist/{chunk-qk7dfae6.js → chunk-za4s66jw.js} +1 -1
  210. package/dist/{chunk-1xct96nd.js → chunk-znbw4gde.js} +15 -15
  211. package/dist/{chunk-pxdzy0jh.js → chunk-zngg9gmy.js} +17 -17
  212. package/dist/{chunk-hqqkj5pg.js → chunk-zph33jdm.js} +2 -2
  213. package/dist/{chunk-evp5pb9x.js → chunk-zsvtrqrz.js} +21 -21
  214. package/dist/{chunk-xd6kmmb1.js → chunk-zzyebz89.js} +22 -22
  215. package/dist/cli.js +5 -5
  216. package/dist/sdk/query.cjs +407 -0
  217. package/dist/sdk/query.js +372 -0
  218. package/package.json +9 -2
  219. package/dist/{chunk-tp2jxmcx.js → chunk-tr9rx7f4.js} +4 -4
@@ -0,0 +1,372 @@
1
+ // @bun
2
+ import {
3
+ __require
4
+ } from "../chunk-qp2qdcda.js";
5
+
6
+ // src/entrypoints/sdk/query.ts
7
+ import { spawn } from "child_process";
8
+ import { createInterface } from "readline";
9
+ var require_ = __require;
10
+ function resolveCliPath(options) {
11
+ if (options.pathToClaudeCodeExecutable) {
12
+ return options.pathToClaudeCodeExecutable;
13
+ }
14
+ try {
15
+ return require_.resolve("@caspian2026/agent-sdk/dist/cli.js");
16
+ } catch {
17
+ throw new Error("Cannot resolve CLI path. Set options.pathToClaudeCodeExecutable or install @caspian2026/agent-sdk.");
18
+ }
19
+ }
20
+ function buildCliArgs(options) {
21
+ const args = ["-p", "--output-format", "stream-json", "--input-format", "stream-json", "--verbose"];
22
+ if (options.model) {
23
+ args.push("--model", options.model);
24
+ }
25
+ if (options.resume) {
26
+ args.push("--resume", options.resume);
27
+ }
28
+ if (options.continue) {
29
+ args.push("--continue");
30
+ }
31
+ if (options.permissionMode) {
32
+ args.push("--permission-mode", options.permissionMode);
33
+ }
34
+ if (options.maxTurns !== undefined) {
35
+ args.push("--max-turns", String(options.maxTurns));
36
+ }
37
+ if (options.maxBudgetUsd !== undefined) {
38
+ args.push("--max-budget-usd", String(options.maxBudgetUsd));
39
+ }
40
+ if (options.thinking) {
41
+ args.push("--thinking", options.thinking);
42
+ }
43
+ if (options.allowedTools?.length) {
44
+ args.push("--allowed-tools", ...options.allowedTools);
45
+ }
46
+ if (options.includePartialMessages) {
47
+ args.push("--include-partial-messages");
48
+ }
49
+ if (options.allowDangerouslySkipPermissions) {
50
+ args.push("--dangerously-skip-permissions");
51
+ }
52
+ if (options.permissionPromptToolName) {
53
+ args.push("--permission-prompt-tool", options.permissionPromptToolName);
54
+ }
55
+ if (options.plugins?.length) {
56
+ for (const plugin of options.plugins) {
57
+ args.push("--plugin-dir", plugin.path);
58
+ }
59
+ }
60
+ if (options.additionalDirectories?.length) {
61
+ args.push("--add-dir", ...options.additionalDirectories);
62
+ }
63
+ if (options.settingSources?.length) {
64
+ args.push("--setting-sources", ...options.settingSources);
65
+ }
66
+ if (typeof options.systemPrompt === "string") {
67
+ args.push("--system-prompt", options.systemPrompt);
68
+ } else if (options.systemPrompt && typeof options.systemPrompt === "object") {
69
+ if (options.systemPrompt.type === "preset" && options.systemPrompt.append) {
70
+ args.push("--append-system-prompt", options.systemPrompt.append);
71
+ }
72
+ }
73
+ if (options.fallbackModel) {
74
+ args.push("--fallback-model", options.fallbackModel);
75
+ }
76
+ if (options.mcpServers && Object.keys(options.mcpServers).length > 0) {
77
+ args.push("--mcp-config", JSON.stringify(options.mcpServers));
78
+ }
79
+ if (options.extraArgs) {
80
+ for (const [key, value] of Object.entries(options.extraArgs)) {
81
+ if (value === null) {
82
+ args.push(key);
83
+ } else {
84
+ args.push(key, value);
85
+ }
86
+ }
87
+ }
88
+ return args;
89
+ }
90
+ function ndjsonParse(line) {
91
+ if (!line.trim())
92
+ return;
93
+ return JSON.parse(line);
94
+ }
95
+ function ndjsonStringify(obj) {
96
+ return JSON.stringify(obj) + `
97
+ `;
98
+ }
99
+ function buildHookCallbackMap(hooks) {
100
+ const map = new Map;
101
+ if (!hooks)
102
+ return map;
103
+ for (const [_event, matchers] of Object.entries(hooks)) {
104
+ if (!matchers)
105
+ continue;
106
+ for (const matcher of matchers) {
107
+ for (const hook of matcher.hooks) {
108
+ const id = `hook_${_event}_${matcher.matcher || "all"}_${map.size}`;
109
+ map.set(id, { callback: hook, timeout: matcher.timeout });
110
+ }
111
+ }
112
+ }
113
+ return map;
114
+ }
115
+ function buildHooksConfig(hooks) {
116
+ if (!hooks)
117
+ return;
118
+ const config = {};
119
+ for (const [event, matchers] of Object.entries(hooks)) {
120
+ if (!matchers)
121
+ continue;
122
+ const eventHooks = [];
123
+ for (const matcher of matchers) {
124
+ const callbackIds = [];
125
+ for (let i = 0;i < matcher.hooks.length; i++) {
126
+ callbackIds.push(`hook_${event}_${matcher.matcher || "all"}_${eventHooks.length * matcher.hooks.length + i}`);
127
+ }
128
+ eventHooks.push({
129
+ matcher: matcher.matcher,
130
+ hookCallbackIds: callbackIds,
131
+ timeout: matcher.timeout
132
+ });
133
+ }
134
+ if (eventHooks.length > 0) {
135
+ config[event] = eventHooks;
136
+ }
137
+ }
138
+ return Object.keys(config).length > 0 ? config : undefined;
139
+ }
140
+ async function* query(params) {
141
+ const { prompt, options } = params;
142
+ const abortController = options.abortController ?? new AbortController;
143
+ const signal = abortController.signal;
144
+ const cliPath = resolveCliPath(options);
145
+ const cliArgs = buildCliArgs(options);
146
+ const cliDir = options.cwd ?? process.cwd();
147
+ const env = {
148
+ ...process.env,
149
+ ...options.env,
150
+ ELECTRON_RUN_AS_NODE: "1"
151
+ };
152
+ const child = spawn(process.execPath, [cliPath, ...cliArgs], {
153
+ cwd: cliDir,
154
+ env,
155
+ stdio: ["pipe", "pipe", "pipe"],
156
+ signal
157
+ });
158
+ const stdin = child.stdin;
159
+ const stdout = child.stdout;
160
+ const stderr = child.stderr;
161
+ if (options.stderr) {
162
+ stderr.on("data", (chunk) => {
163
+ options.stderr(chunk.toString());
164
+ });
165
+ } else {
166
+ stderr.resume();
167
+ }
168
+ const hookCallbacks = buildHookCallbackMap(options.hooks);
169
+ const pendingControlRequests = new Map;
170
+ const hooksConfig = buildHooksConfig(options.hooks);
171
+ if (hooksConfig) {
172
+ const initRequestId = "sdk-init-hooks";
173
+ const initRequest = {
174
+ type: "control_request",
175
+ request_id: initRequestId,
176
+ request: {
177
+ subtype: "initialize",
178
+ hooks: hooksConfig
179
+ }
180
+ };
181
+ stdin.write(ndjsonStringify(initRequest));
182
+ }
183
+ const promptQueue = [];
184
+ async function writePrompt() {
185
+ if (typeof prompt === "string") {
186
+ const msg = {
187
+ type: "user",
188
+ content: prompt,
189
+ uuid: "",
190
+ session_id: "",
191
+ message: { role: "user", content: prompt },
192
+ parent_tool_use_id: null
193
+ };
194
+ stdin.write(ndjsonStringify(msg));
195
+ } else {
196
+ for await (const userMsg of prompt) {
197
+ if (signal.aborted)
198
+ break;
199
+ stdin.write(ndjsonStringify(userMsg));
200
+ }
201
+ }
202
+ }
203
+ const promptPromise = writePrompt().catch((err) => {
204
+ if (!signal.aborted) {
205
+ throw err;
206
+ }
207
+ });
208
+ const rl = createInterface({ input: stdout });
209
+ async function handleControlRequest(msg) {
210
+ const { request_id, request } = msg;
211
+ try {
212
+ switch (request.subtype) {
213
+ case "can_use_tool": {
214
+ if (!options.canUseTool) {
215
+ const response2 = {
216
+ type: "control_response",
217
+ response: { subtype: "success", request_id, response: { behavior: "deny", message: "No permission handler configured" } }
218
+ };
219
+ stdin.write(ndjsonStringify(response2));
220
+ break;
221
+ }
222
+ const toolName = request.tool_name;
223
+ const toolInput = request.input ?? {};
224
+ const toolUseID = request.tool_use_id;
225
+ const suggestions = request.permission_suggestions;
226
+ const blockedPath = request.blocked_path;
227
+ const decisionReason = request.decision_reason;
228
+ const agentID = request.agent_id;
229
+ const result = await options.canUseTool(toolName, toolInput, {
230
+ signal,
231
+ suggestions,
232
+ blockedPath,
233
+ decisionReason,
234
+ toolUseID,
235
+ agentID
236
+ });
237
+ const response = {
238
+ type: "control_response",
239
+ response: {
240
+ subtype: "success",
241
+ request_id,
242
+ response: result
243
+ }
244
+ };
245
+ stdin.write(ndjsonStringify(response));
246
+ break;
247
+ }
248
+ case "hook_callback": {
249
+ const callbackId = request.callback_id;
250
+ const hookInput = request.input;
251
+ const toolUseId = request.tool_use_id;
252
+ const hookEntry = hookCallbacks.get(callbackId);
253
+ if (hookEntry) {
254
+ const result = await hookEntry.callback(hookInput, toolUseId, { signal });
255
+ const response = {
256
+ type: "control_response",
257
+ response: {
258
+ subtype: "success",
259
+ request_id,
260
+ response: result
261
+ }
262
+ };
263
+ stdin.write(ndjsonStringify(response));
264
+ } else {
265
+ const response = {
266
+ type: "control_response",
267
+ response: {
268
+ subtype: "success",
269
+ request_id,
270
+ response: {}
271
+ }
272
+ };
273
+ stdin.write(ndjsonStringify(response));
274
+ }
275
+ break;
276
+ }
277
+ case "initialize": {
278
+ const response = {
279
+ type: "control_response",
280
+ response: { subtype: "success", request_id, response: {} }
281
+ };
282
+ stdin.write(ndjsonStringify(response));
283
+ break;
284
+ }
285
+ default: {
286
+ const response = {
287
+ type: "control_response",
288
+ response: { subtype: "success", request_id, response: {} }
289
+ };
290
+ stdin.write(ndjsonStringify(response));
291
+ }
292
+ }
293
+ } catch (err) {
294
+ const errorMsg = err instanceof Error ? err.message : String(err);
295
+ const response = {
296
+ type: "control_response",
297
+ response: { subtype: "error", request_id, error: errorMsg }
298
+ };
299
+ try {
300
+ stdin.write(ndjsonStringify(response));
301
+ } catch {}
302
+ }
303
+ }
304
+ try {
305
+ for await (const line of rl) {
306
+ if (signal.aborted)
307
+ break;
308
+ let msg;
309
+ try {
310
+ msg = ndjsonParse(line);
311
+ } catch {
312
+ continue;
313
+ }
314
+ if (!msg || typeof msg !== "object")
315
+ continue;
316
+ const typed = msg;
317
+ switch (typed.type) {
318
+ case "control_request": {
319
+ handleControlRequest(typed).catch(() => {});
320
+ break;
321
+ }
322
+ case "control_response": {
323
+ const resp = typed;
324
+ const pending = pendingControlRequests.get(resp.response.request_id);
325
+ if (pending) {
326
+ pendingControlRequests.delete(resp.response.request_id);
327
+ if (resp.response.subtype === "error") {
328
+ pending.reject(new Error(resp.response.error));
329
+ } else {
330
+ pending.resolve(resp.response);
331
+ }
332
+ }
333
+ break;
334
+ }
335
+ case "control_cancel_request": {
336
+ const cancel = typed;
337
+ const pending = pendingControlRequests.get(cancel.request_id);
338
+ if (pending) {
339
+ pendingControlRequests.delete(cancel.request_id);
340
+ pending.reject(new Error("Request cancelled"));
341
+ }
342
+ break;
343
+ }
344
+ case "keep_alive": {
345
+ stdin.write(ndjsonStringify({ type: "keep_alive" }));
346
+ break;
347
+ }
348
+ default: {
349
+ if (typed.type === "assistant" || typed.type === "user" || typed.type === "system" || typed.type === "result" || typed.type === "stream_event" || typed.type === "tool_progress") {
350
+ yield typed;
351
+ }
352
+ }
353
+ }
354
+ }
355
+ } finally {
356
+ rl.close();
357
+ try {
358
+ stdin.end();
359
+ } catch {}
360
+ if (!child.killed) {
361
+ child.kill();
362
+ }
363
+ for (const pending of pendingControlRequests.values()) {
364
+ pending.reject(new Error("Query ended"));
365
+ }
366
+ pendingControlRequests.clear();
367
+ await promptPromise.catch(() => {});
368
+ }
369
+ }
370
+ export {
371
+ query
372
+ };
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@caspian2026/agent-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "AI-powered agent SDK for the terminal",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "bun": ">=1.2.0"
8
8
  },
9
+ "main": "dist/sdk/query.cjs",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/sdk/query.js",
13
+ "require": "./dist/sdk/query.cjs",
14
+ "default": "./dist/sdk/query.cjs"
15
+ }
16
+ },
9
17
  "bin": {
10
18
  "ccb": "dist/cli.js",
11
19
  "agent-sdk": "dist/cli.js"
@@ -40,7 +48,6 @@
40
48
  "@ant/computer-use-input": "workspace:*",
41
49
  "@ant/computer-use-mcp": "workspace:*",
42
50
  "@ant/computer-use-swift": "workspace:*",
43
- "@anthropic-ai/claude-agent-sdk": "^0.2.87",
44
51
  "@anthropic-ai/mcpb": "^2.1.2",
45
52
  "@anthropic-ai/sandbox-runtime": "^0.0.44",
46
53
  "@anthropic-ai/sdk": "^0.80.0",
@@ -13,10 +13,6 @@ import {
13
13
  normalizePathForConfigKey,
14
14
  sanitizePath
15
15
  } from "./chunk-1ax1znzj.js";
16
- import {
17
- getProxyFetchOptions,
18
- init_proxy
19
- } from "./chunk-wha6v7za.js";
20
16
  import {
21
17
  count,
22
18
  init_array,
@@ -32,6 +28,10 @@ import {
32
28
  init_lazySchema,
33
29
  lazySchema
34
30
  } from "./chunk-64c1avct.js";
31
+ import {
32
+ getProxyFetchOptions,
33
+ init_proxy
34
+ } from "./chunk-wha6v7za.js";
35
35
  import {
36
36
  init_v4,
37
37
  v4_default