@caspian2026/agent-sdk 0.0.25 → 0.0.26
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.
- package/dist/gateway/index.js +98 -22
- package/dist/gateway/worker.js +86 -41
- package/dist/sdk/query.cjs +2 -362
- package/dist/sdk/query.js +2 -367
- package/package.json +4 -6
- package/dist/chunk-04n4fe72.js +0 -107
- package/dist/chunk-04ys66ej.js +0 -344
- package/dist/chunk-07069jq1.js +0 -30
- package/dist/chunk-0731m51q.js +0 -8
- package/dist/chunk-086x4ct4.js +0 -26
- package/dist/chunk-0btqb97n.js +0 -295
- package/dist/chunk-0paqc2yw.js +0 -15
- package/dist/chunk-0r1rjydx.js +0 -145
- package/dist/chunk-0r5bb9j4.js +0 -477
- package/dist/chunk-0t81d427.js +0 -41
- package/dist/chunk-0teq2mz0.js +0 -420
- package/dist/chunk-0vkfrmqm.js +0 -690
- package/dist/chunk-0vp3wfab.js +0 -12
- package/dist/chunk-0warp8dx.js +0 -253
- package/dist/chunk-0xjaqda8.js +0 -1124
- package/dist/chunk-10gzv316.js +0 -62
- package/dist/chunk-11pq9n08.js +0 -168
- package/dist/chunk-1ae3nt9j.js +0 -31
- package/dist/chunk-1fmb0njn.js +0 -396
- package/dist/chunk-1gx78081.js +0 -66
- package/dist/chunk-1h2famwb.js +0 -49
- package/dist/chunk-1ng8xwxz.js +0 -276
- package/dist/chunk-1v7jp29h.js +0 -206
- package/dist/chunk-1xxy5zhb.js +0 -673
- package/dist/chunk-20b73w7w.js +0 -117
- package/dist/chunk-20qxd83a.js +0 -1161
- package/dist/chunk-2239ny9q.js +0 -90
- package/dist/chunk-22d4rnef.js +0 -226
- package/dist/chunk-26wtxbdc.js +0 -13870
- package/dist/chunk-27225bjh.js +0 -618
- package/dist/chunk-2b0e32an.js +0 -5822
- package/dist/chunk-2bfa9w1y.js +0 -323
- package/dist/chunk-2epq04w1.js +0 -63
- package/dist/chunk-2fwze72g.js +0 -24
- package/dist/chunk-2gzv8nrw.js +0 -205
- package/dist/chunk-2mexte1r.js +0 -349
- package/dist/chunk-2mzaqh5g.js +0 -338
- package/dist/chunk-2tb6mzfc.js +0 -81
- package/dist/chunk-2xq0g43w.js +0 -558
- package/dist/chunk-334aeqg9.js +0 -90
- package/dist/chunk-34jx4rjd.js +0 -995
- package/dist/chunk-35w5nhex.js +0 -132
- package/dist/chunk-3c25bcsw.js +0 -17
- package/dist/chunk-3eaxj8dg.js +0 -151
- package/dist/chunk-3fdgrwd2.js +0 -111
- package/dist/chunk-3jw0r58d.js +0 -121
- package/dist/chunk-3mgywd32.js +0 -8
- package/dist/chunk-3nk79af8.js +0 -8
- package/dist/chunk-3vy1jt9p.js +0 -1010
- package/dist/chunk-3x78pd4j.js +0 -153
- package/dist/chunk-47x3dsmn.js +0 -95
- package/dist/chunk-49pqt48n.js +0 -108
- package/dist/chunk-4f7m9fjw.js +0 -317
- package/dist/chunk-4jm600zv.js +0 -13
- package/dist/chunk-4k9d7gxv.js +0 -118
- package/dist/chunk-4net8san.js +0 -155
- package/dist/chunk-4pbx3g7s.js +0 -26
- package/dist/chunk-4v125j4z.js +0 -58
- package/dist/chunk-4vxkv5vz.js +0 -1438
- package/dist/chunk-51fqpjy3.js +0 -121
- package/dist/chunk-52e64f2h.js +0 -439
- package/dist/chunk-52e9mdjv.js +0 -684
- package/dist/chunk-55raexh7.js +0 -14358
- package/dist/chunk-59pq5122.js +0 -269
- package/dist/chunk-5bsj67v1.js +0 -349
- package/dist/chunk-5ccdsxgy.js +0 -74
- package/dist/chunk-5ekyhb1w.js +0 -422
- package/dist/chunk-5gcqdn8x.js +0 -867
- package/dist/chunk-5h5kx2jd.js +0 -34
- package/dist/chunk-5hf3werb.js +0 -193
- package/dist/chunk-5n1jc02d.js +0 -87
- package/dist/chunk-5wfxvxm8.js +0 -127
- package/dist/chunk-5wjebwmn.js +0 -89
- package/dist/chunk-5z28bqne.js +0 -6748
- package/dist/chunk-5zwsxpjn.js +0 -671
- package/dist/chunk-60phw466.js +0 -29
- package/dist/chunk-64c1avct.js +0 -13
- package/dist/chunk-64r16v22.js +0 -162
- package/dist/chunk-65t1r7zs.js +0 -418
- package/dist/chunk-66zry909.js +0 -11
- package/dist/chunk-67hxjjgc.js +0 -731
- package/dist/chunk-68ffk5qa.js +0 -14
- package/dist/chunk-69dr6rrd.js +0 -177
- package/dist/chunk-69n11zng.js +0 -436
- package/dist/chunk-6dj5t602.js +0 -341
- package/dist/chunk-6dngjwkh.js +0 -63
- package/dist/chunk-6dp8sz55.js +0 -3561
- package/dist/chunk-6hqgg0sv.js +0 -103
- package/dist/chunk-6nsd9606.js +0 -790
- package/dist/chunk-6p0hbwz3.js +0 -65
- package/dist/chunk-6ywdv5vg.js +0 -97
- package/dist/chunk-6zc758qw.js +0 -640
- package/dist/chunk-7aw745vx.js +0 -40175
- package/dist/chunk-7fxaphbq.js +0 -116
- package/dist/chunk-7sgtxrsc.js +0 -1059
- package/dist/chunk-7wm5s02e.js +0 -216
- package/dist/chunk-7xdk4109.js +0 -442
- package/dist/chunk-7xyswgjh.js +0 -8
- package/dist/chunk-83hfzbx3.js +0 -10
- package/dist/chunk-87m69h0v.js +0 -219
- package/dist/chunk-8g5pe1gr.js +0 -37
- package/dist/chunk-8jbw0fnf.js +0 -167
- package/dist/chunk-8jf9se66.js +0 -321
- package/dist/chunk-8p65embj.js +0 -875
- package/dist/chunk-8qrmaff1.js +0 -2669
- package/dist/chunk-8r975mwc.js +0 -93
- package/dist/chunk-8yhf030a.js +0 -69
- package/dist/chunk-93emz367.js +0 -107
- package/dist/chunk-948mn975.js +0 -460
- package/dist/chunk-99chkt7r.js +0 -54
- package/dist/chunk-9f7c1hzz.js +0 -50
- package/dist/chunk-9fk9ps1g.js +0 -178
- package/dist/chunk-9rh0k0aq.js +0 -90
- package/dist/chunk-9x5zgy22.js +0 -12
- package/dist/chunk-a0k2vj5b.js +0 -460
- package/dist/chunk-a0m57ssq.js +0 -325
- package/dist/chunk-a0nsmmz1.js +0 -133
- package/dist/chunk-a25jh1v4.js +0 -105
- package/dist/chunk-a4j5ekv0.js +0 -83
- package/dist/chunk-a8k3zf58.js +0 -313
- package/dist/chunk-ah0zarbq.js +0 -260
- package/dist/chunk-ase86y73.js +0 -15
- package/dist/chunk-b0kf00ff.js +0 -637
- package/dist/chunk-b1kcd3ss.js +0 -27
- package/dist/chunk-b8kcqqds.js +0 -93
- package/dist/chunk-bg4x9ex0.js +0 -21
- package/dist/chunk-bh5zqvyc.js +0 -36
- package/dist/chunk-bqrkfekw.js +0 -267
- package/dist/chunk-brjd9zmk.js +0 -42
- package/dist/chunk-byfawrfx.js +0 -121
- package/dist/chunk-c6sjhj89.js +0 -1284
- package/dist/chunk-c7e5yv0q.js +0 -212
- package/dist/chunk-c7jwbe76.js +0 -29030
- package/dist/chunk-cb5v8w7k.js +0 -289
- package/dist/chunk-cdef9v7b.js +0 -27
- package/dist/chunk-cdz5yb0r.js +0 -57
- package/dist/chunk-cgfdkzhb.js +0 -12
- package/dist/chunk-cgqw4x5z.js +0 -155
- package/dist/chunk-cnsj3vq2.js +0 -35
- package/dist/chunk-cqxm7ggc.js +0 -123
- package/dist/chunk-cxrktb5g.js +0 -51
- package/dist/chunk-d089t7dk.js +0 -312
- package/dist/chunk-d1z934cp.js +0 -71
- package/dist/chunk-d4mdda98.js +0 -94
- package/dist/chunk-d7xw8v91.js +0 -332
- package/dist/chunk-dc06c3rw.js +0 -1154
- package/dist/chunk-ddsjkqs4.js +0 -39
- package/dist/chunk-dfzkwynj.js +0 -5368
- package/dist/chunk-dnmp7s85.js +0 -20
- package/dist/chunk-dqqwjkv3.js +0 -8583
- package/dist/chunk-dt2mr4vf.js +0 -2962
- package/dist/chunk-dztm97gg.js +0 -150
- package/dist/chunk-e0abab5b.js +0 -445
- package/dist/chunk-e0ragz46.js +0 -209386
- package/dist/chunk-e9w9zc0g.js +0 -392
- package/dist/chunk-ebwskmsr.js +0 -107
- package/dist/chunk-efztk52j.js +0 -114
- package/dist/chunk-ehd8wacx.js +0 -40
- package/dist/chunk-ehtwnxpg.js +0 -1591
- package/dist/chunk-eqp1rfft.js +0 -17
- package/dist/chunk-etdt1xz3.js +0 -19
- package/dist/chunk-eva785x8.js +0 -88
- package/dist/chunk-ewadzrm8.js +0 -103
- package/dist/chunk-f2ajmcav.js +0 -92
- package/dist/chunk-fajg8x36.js +0 -8158
- package/dist/chunk-fbv4apne.js +0 -51
- package/dist/chunk-fcynwjpm.js +0 -1072
- package/dist/chunk-fev86f95.js +0 -1052
- package/dist/chunk-feyzykye.js +0 -10
- package/dist/chunk-ff85rwvc.js +0 -180
- package/dist/chunk-fk6ktvg2.js +0 -275
- package/dist/chunk-fqak69ft.js +0 -458
- package/dist/chunk-fqwas4jk.js +0 -281
- package/dist/chunk-fs35fdpj.js +0 -439
- package/dist/chunk-fvr3f9s3.js +0 -55
- package/dist/chunk-fyc5fepv.js +0 -10
- package/dist/chunk-g2g9cwt9.js +0 -54
- package/dist/chunk-g4znz46v.js +0 -2335
- package/dist/chunk-g5ts4e6k.js +0 -697
- package/dist/chunk-g6een9wr.js +0 -654
- package/dist/chunk-g7cmtx8r.js +0 -77
- package/dist/chunk-g9f19ttm.js +0 -15
- package/dist/chunk-gc7ap41t.js +0 -516
- package/dist/chunk-gdwdqewd.js +0 -19
- package/dist/chunk-gg14h3n4.js +0 -131
- package/dist/chunk-gg55fns0.js +0 -6440
- package/dist/chunk-gq7zab4e.js +0 -418
- package/dist/chunk-gydw3qy3.js +0 -169
- package/dist/chunk-gz1e8y1w.js +0 -33
- package/dist/chunk-h19r628d.js +0 -91
- package/dist/chunk-h2k8mt3z.js +0 -329
- package/dist/chunk-h9n54swm.js +0 -27
- package/dist/chunk-hakdhagh.js +0 -16606
- package/dist/chunk-hc2chp3g.js +0 -308
- package/dist/chunk-hemcv9t7.js +0 -153
- package/dist/chunk-hm62ntv3.js +0 -20
- package/dist/chunk-hmq09ytj.js +0 -100
- package/dist/chunk-hmv4hhqt.js +0 -2718
- package/dist/chunk-hwfknpxv.js +0 -39
- package/dist/chunk-j5bth84e.js +0 -97
- package/dist/chunk-j64ga6ta.js +0 -8035
- package/dist/chunk-j6v3w4yf.js +0 -244
- package/dist/chunk-jc29d2nm.js +0 -130
- package/dist/chunk-jd32zbps.js +0 -15
- package/dist/chunk-jd4sx4wh.js +0 -594
- package/dist/chunk-jha8n8b9.js +0 -33118
- package/dist/chunk-jj71qx7m.js +0 -122
- package/dist/chunk-jka9vpak.js +0 -114
- package/dist/chunk-jkf6ayv0.js +0 -32
- package/dist/chunk-jpz6t2tt.js +0 -61
- package/dist/chunk-jqt3sw12.js +0 -9114
- package/dist/chunk-jswd1q63.js +0 -101
- package/dist/chunk-jtc4aa2y.js +0 -1543
- package/dist/chunk-jyx3h86z.js +0 -635
- package/dist/chunk-jzthz1bx.js +0 -15
- package/dist/chunk-k0p9w03v.js +0 -4957
- package/dist/chunk-k6x3s7x5.js +0 -211
- package/dist/chunk-k7kmvnnx.js +0 -942
- package/dist/chunk-k8vp0atq.js +0 -2331
- package/dist/chunk-k9vm6x6z.js +0 -257
- package/dist/chunk-kb1edvhs.js +0 -120
- package/dist/chunk-kbhbe33q.js +0 -113
- package/dist/chunk-kgcgpp7z.js +0 -140
- package/dist/chunk-kvywbvqs.js +0 -261
- package/dist/chunk-kwekc97v.js +0 -18
- package/dist/chunk-kwyk9zp1.js +0 -74
- package/dist/chunk-ky1z78ve.js +0 -119
- package/dist/chunk-mcws22k3.js +0 -42
- package/dist/chunk-mr2z79r3.js +0 -1385
- package/dist/chunk-mst9nmns.js +0 -642
- package/dist/chunk-mswx2nma.js +0 -103
- package/dist/chunk-n1e3fjpz.js +0 -266
- package/dist/chunk-n6vjp9yg.js +0 -138
- package/dist/chunk-n84tqtvv.js +0 -120
- package/dist/chunk-n8ssddbw.js +0 -105
- package/dist/chunk-na35whkd.js +0 -227
- package/dist/chunk-netzwgv1.js +0 -154
- package/dist/chunk-ng7j0yy1.js +0 -100
- package/dist/chunk-nmgj86tt.js +0 -24
- package/dist/chunk-ns7x6xam.js +0 -22820
- package/dist/chunk-p7vkh4wx.js +0 -15
- package/dist/chunk-p8na2wwp.js +0 -14
- package/dist/chunk-pe3rkfp2.js +0 -74
- package/dist/chunk-pf0152j3.js +0 -40
- package/dist/chunk-pgtnj1mt.js +0 -705
- package/dist/chunk-ppwjyveh.js +0 -8
- package/dist/chunk-pq5qp2y4.js +0 -388
- package/dist/chunk-pqqxdk5f.js +0 -543
- package/dist/chunk-ps49ymvj.js +0 -43
- package/dist/chunk-pws8gq7m.js +0 -7422
- package/dist/chunk-pwwa7s62.js +0 -11
- package/dist/chunk-pyq0fabn.js +0 -860
- package/dist/chunk-q0p1m40t.js +0 -79
- package/dist/chunk-q0vhv550.js +0 -393
- package/dist/chunk-q7r0kt08.js +0 -1809
- package/dist/chunk-qajrkk97.js +0 -298
- package/dist/chunk-qatfdxvd.js +0 -34
- package/dist/chunk-qb6k2afy.js +0 -153
- package/dist/chunk-qg2qgx8h.js +0 -266
- package/dist/chunk-qkczt8cr.js +0 -24
- package/dist/chunk-qnfx3qtx.js +0 -617
- package/dist/chunk-qp2qdcda.js +0 -100
- package/dist/chunk-qtwgzej9.js +0 -85
- package/dist/chunk-r1dh0ymt.js +0 -91
- package/dist/chunk-r36xvgvv.js +0 -407
- package/dist/chunk-r48he8g3.js +0 -251
- package/dist/chunk-r63tqmtk.js +0 -146
- package/dist/chunk-rbdd3q5k.js +0 -101
- package/dist/chunk-rmbbmd3s.js +0 -68
- package/dist/chunk-rn0v1hk8.js +0 -34
- package/dist/chunk-rnxctq9p.js +0 -1646
- package/dist/chunk-rrs2mchs.js +0 -183
- package/dist/chunk-rtrybvnp.js +0 -209
- package/dist/chunk-rw2wkn45.js +0 -494
- package/dist/chunk-s4kzkdhd.js +0 -847
- package/dist/chunk-s7a0zn7b.js +0 -55
- package/dist/chunk-s8gy4ky9.js +0 -122
- package/dist/chunk-s8kj6ajy.js +0 -32
- package/dist/chunk-sag785ad.js +0 -283
- package/dist/chunk-scqjyben.js +0 -174
- package/dist/chunk-sd36yzx8.js +0 -954
- package/dist/chunk-sdtqm0nm.js +0 -374
- package/dist/chunk-sg60xg0x.js +0 -52
- package/dist/chunk-sgpmpn90.js +0 -35
- package/dist/chunk-sh02d2qn.js +0 -38
- package/dist/chunk-sz9y6z13.js +0 -61
- package/dist/chunk-szj5wvdy.js +0 -28
- package/dist/chunk-t29a6zb5.js +0 -45
- package/dist/chunk-t2b49hcf.js +0 -87
- package/dist/chunk-t2wqdppz.js +0 -445
- package/dist/chunk-t4khqff1.js +0 -16
- package/dist/chunk-t70t2gne.js +0 -121
- package/dist/chunk-t9p85zff.js +0 -24
- package/dist/chunk-tkrstmwz.js +0 -94
- package/dist/chunk-tnyb4exc.js +0 -74
- package/dist/chunk-tpn8jsvw.js +0 -71
- package/dist/chunk-tt7x5j1q.js +0 -111
- package/dist/chunk-tw1p628z.js +0 -984
- package/dist/chunk-twvdafcz.js +0 -528
- package/dist/chunk-tzwjafgn.js +0 -24
- package/dist/chunk-v140t8ay.js +0 -152
- package/dist/chunk-v1kzp02e.js +0 -785
- package/dist/chunk-v4t6dyyh.js +0 -9076
- package/dist/chunk-v78fj8by.js +0 -145
- package/dist/chunk-v8kjswxt.js +0 -61
- package/dist/chunk-v9smspw2.js +0 -4301
- package/dist/chunk-vcfbjkk9.js +0 -201
- package/dist/chunk-ve167rcs.js +0 -148
- package/dist/chunk-vf612n57.js +0 -472
- package/dist/chunk-vhffyae8.js +0 -895
- package/dist/chunk-vkhrrvfq.js +0 -44
- package/dist/chunk-vybkmfhf.js +0 -91
- package/dist/chunk-vyjeh50y.js +0 -2149
- package/dist/chunk-w6m6trzq.js +0 -58
- package/dist/chunk-w9b6kngq.js +0 -234
- package/dist/chunk-wa8yn2p0.js +0 -2007
- package/dist/chunk-wanceff6.js +0 -2840
- package/dist/chunk-wcze2nea.js +0 -336
- package/dist/chunk-wgk9sxk7.js +0 -329
- package/dist/chunk-wnxcgfsd.js +0 -253
- package/dist/chunk-wyjerrr6.js +0 -565
- package/dist/chunk-wz9brkq5.js +0 -60
- package/dist/chunk-x47h283a.js +0 -56
- package/dist/chunk-x59j3x9c.js +0 -98
- package/dist/chunk-x6r4v44b.js +0 -8
- package/dist/chunk-x7fdwq3d.js +0 -33
- package/dist/chunk-x8d2ehd7.js +0 -19
- package/dist/chunk-xeb6075z.js +0 -3435
- package/dist/chunk-xfw2pxwd.js +0 -223
- package/dist/chunk-xh06jc72.js +0 -200
- package/dist/chunk-xhfmdq1y.js +0 -147
- package/dist/chunk-xkwyg1d2.js +0 -195
- package/dist/chunk-xv3era3s.js +0 -8
- package/dist/chunk-xyapc58m.js +0 -87
- package/dist/chunk-xzgnc76g.js +0 -107
- package/dist/chunk-y1784krc.js +0 -19
- package/dist/chunk-y4ca9kqz.js +0 -3830
- package/dist/chunk-y9bhjjdz.js +0 -145
- package/dist/chunk-yb3bxv3w.js +0 -30
- package/dist/chunk-yddek6xk.js +0 -146
- package/dist/chunk-ypaq3d12.js +0 -4265
- package/dist/chunk-yq8z040g.js +0 -111
- package/dist/chunk-yqs481qq.js +0 -1163
- package/dist/chunk-ys9a9c9h.js +0 -105
- package/dist/chunk-yyex5gsf.js +0 -269
- package/dist/chunk-yzn396hn.js +0 -89
- package/dist/chunk-z2dp53wn.js +0 -17
- package/dist/chunk-zay4xp4n.js +0 -251
- package/dist/chunk-zc8bwy57.js +0 -212
- package/dist/chunk-zhx88cfx.js +0 -97
- package/dist/chunk-zkh6f4ct.js +0 -385
- package/dist/chunk-zq56gcca.js +0 -206
- package/dist/chunk-zrkefd22.js +0 -490
- package/dist/chunk-zs5p0yq1.js +0 -1030
- package/dist/chunk-zxh62ved.js +0 -31
- package/dist/chunk-zzm33q8x.js +0 -8
- package/dist/cli.js +0 -220
package/dist/chunk-27225bjh.js
DELETED
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
init_channelNotification,
|
|
4
|
-
init_omit,
|
|
5
|
-
omit_default
|
|
6
|
-
} from "./chunk-rw2wkn45.js";
|
|
7
|
-
import {
|
|
8
|
-
clearClaudeAIMcpConfigsCache,
|
|
9
|
-
clearServerCache,
|
|
10
|
-
commandBelongsToServer,
|
|
11
|
-
dedupClaudeAiMcpServers,
|
|
12
|
-
doesEnterpriseMcpConfigExist,
|
|
13
|
-
excludeStalePluginClients,
|
|
14
|
-
fetchClaudeAIMcpConfigsIfEligible,
|
|
15
|
-
fetchCommandsForClient,
|
|
16
|
-
fetchResourcesForClient,
|
|
17
|
-
fetchToolsForClient,
|
|
18
|
-
filterMcpServersByPolicy,
|
|
19
|
-
getClaudeCodeMcpConfigs,
|
|
20
|
-
getMcpToolsCommandsAndResources,
|
|
21
|
-
init_AppState,
|
|
22
|
-
init_claudeai,
|
|
23
|
-
init_client,
|
|
24
|
-
init_config,
|
|
25
|
-
init_elicitationHandler,
|
|
26
|
-
init_messageQueueManager,
|
|
27
|
-
init_notifications,
|
|
28
|
-
init_reject,
|
|
29
|
-
init_utils,
|
|
30
|
-
isMcpServerDisabled,
|
|
31
|
-
reconnectMcpServerImpl,
|
|
32
|
-
registerElicitationHandler,
|
|
33
|
-
reject_default,
|
|
34
|
-
setMcpServerEnabled,
|
|
35
|
-
useAppState,
|
|
36
|
-
useAppStateStore,
|
|
37
|
-
useNotifications,
|
|
38
|
-
useSetAppState
|
|
39
|
-
} from "./chunk-e0ragz46.js";
|
|
40
|
-
import {
|
|
41
|
-
PromptListChangedNotificationSchema,
|
|
42
|
-
ResourceListChangedNotificationSchema,
|
|
43
|
-
ToolListChangedNotificationSchema,
|
|
44
|
-
init_types
|
|
45
|
-
} from "./chunk-v4t6dyyh.js";
|
|
46
|
-
import {
|
|
47
|
-
getMcpPrefix,
|
|
48
|
-
init_growthbook,
|
|
49
|
-
init_mcpStringUtils
|
|
50
|
-
} from "./chunk-2b0e32an.js";
|
|
51
|
-
import {
|
|
52
|
-
require_jsx_dev_runtime,
|
|
53
|
-
require_react
|
|
54
|
-
} from "./chunk-7sgtxrsc.js";
|
|
55
|
-
import {
|
|
56
|
-
init_analytics,
|
|
57
|
-
logEvent
|
|
58
|
-
} from "./chunk-x8d2ehd7.js";
|
|
59
|
-
import {
|
|
60
|
-
errorMessage,
|
|
61
|
-
init_debug,
|
|
62
|
-
init_errors,
|
|
63
|
-
init_log,
|
|
64
|
-
init_slowOperations,
|
|
65
|
-
logForDebugging,
|
|
66
|
-
logMCPDebug,
|
|
67
|
-
logMCPError
|
|
68
|
-
} from "./chunk-gg55fns0.js";
|
|
69
|
-
import {
|
|
70
|
-
getSessionId,
|
|
71
|
-
init_state
|
|
72
|
-
} from "./chunk-k8vp0atq.js";
|
|
73
|
-
import {
|
|
74
|
-
__esm,
|
|
75
|
-
__toESM
|
|
76
|
-
} from "./chunk-qp2qdcda.js";
|
|
77
|
-
|
|
78
|
-
// src/services/mcp/channelPermissions.ts
|
|
79
|
-
var init_channelPermissions = __esm(() => {
|
|
80
|
-
init_slowOperations();
|
|
81
|
-
init_growthbook();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// src/services/mcp/useManageMCPConnections.ts
|
|
85
|
-
import { basename } from "path";
|
|
86
|
-
function getErrorKey(error) {
|
|
87
|
-
const plugin = "plugin" in error ? error.plugin : "no-plugin";
|
|
88
|
-
return `${error.type}:${error.source}:${plugin}`;
|
|
89
|
-
}
|
|
90
|
-
function addErrorsToAppState(setAppState, newErrors) {
|
|
91
|
-
if (newErrors.length === 0)
|
|
92
|
-
return;
|
|
93
|
-
setAppState((prevState) => {
|
|
94
|
-
const existingKeys = new Set(prevState.plugins.errors.map((e) => getErrorKey(e)));
|
|
95
|
-
const uniqueNewErrors = newErrors.filter((error) => !existingKeys.has(getErrorKey(error)));
|
|
96
|
-
if (uniqueNewErrors.length === 0) {
|
|
97
|
-
return prevState;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
...prevState,
|
|
101
|
-
plugins: {
|
|
102
|
-
...prevState.plugins,
|
|
103
|
-
errors: [...prevState.plugins.errors, ...uniqueNewErrors]
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function useManageMCPConnections(dynamicMcpConfig, isStrictMcpConfig = false) {
|
|
109
|
-
const store = useAppStateStore();
|
|
110
|
-
const _authVersion = useAppState((s) => s.authVersion);
|
|
111
|
-
const _pluginReconnectKey = useAppState((s) => s.mcp.pluginReconnectKey);
|
|
112
|
-
const setAppState = useSetAppState();
|
|
113
|
-
const reconnectTimersRef = import_react.useRef(new Map);
|
|
114
|
-
const channelWarnedKindsRef = import_react.useRef(new Set);
|
|
115
|
-
const channelPermCallbacksRef = import_react.useRef(null);
|
|
116
|
-
if (false) {}
|
|
117
|
-
import_react.useEffect(() => {
|
|
118
|
-
if (false) {}
|
|
119
|
-
}, [setAppState]);
|
|
120
|
-
const { addNotification } = useNotifications();
|
|
121
|
-
const MCP_BATCH_FLUSH_MS = 16;
|
|
122
|
-
const pendingUpdatesRef = import_react.useRef([]);
|
|
123
|
-
const flushTimerRef = import_react.useRef(null);
|
|
124
|
-
const flushPendingUpdates = import_react.useCallback(() => {
|
|
125
|
-
flushTimerRef.current = null;
|
|
126
|
-
const updates = pendingUpdatesRef.current;
|
|
127
|
-
if (updates.length === 0)
|
|
128
|
-
return;
|
|
129
|
-
pendingUpdatesRef.current = [];
|
|
130
|
-
setAppState((prevState) => {
|
|
131
|
-
let mcp = prevState.mcp;
|
|
132
|
-
for (const update of updates) {
|
|
133
|
-
const {
|
|
134
|
-
tools: rawTools,
|
|
135
|
-
commands: rawCmds,
|
|
136
|
-
resources: rawRes,
|
|
137
|
-
...client
|
|
138
|
-
} = update;
|
|
139
|
-
const tools = client.type === "disabled" || client.type === "failed" ? rawTools ?? [] : rawTools;
|
|
140
|
-
const commands = client.type === "disabled" || client.type === "failed" ? rawCmds ?? [] : rawCmds;
|
|
141
|
-
const resources = client.type === "disabled" || client.type === "failed" ? rawRes ?? [] : rawRes;
|
|
142
|
-
const prefix = getMcpPrefix(client.name);
|
|
143
|
-
const existingClientIndex = mcp.clients.findIndex((c) => c.name === client.name);
|
|
144
|
-
const updatedClients = existingClientIndex === -1 ? [...mcp.clients, client] : mcp.clients.map((c) => c.name === client.name ? client : c);
|
|
145
|
-
const updatedTools = tools === undefined ? mcp.tools : [...reject_default(mcp.tools, (t) => t.name?.startsWith(prefix)), ...tools];
|
|
146
|
-
const updatedCommands = commands === undefined ? mcp.commands : [
|
|
147
|
-
...reject_default(mcp.commands, (c) => commandBelongsToServer(c, client.name)),
|
|
148
|
-
...commands
|
|
149
|
-
];
|
|
150
|
-
const updatedResources = resources === undefined ? mcp.resources : {
|
|
151
|
-
...mcp.resources,
|
|
152
|
-
...resources.length > 0 ? { [client.name]: resources } : omit_default(mcp.resources, client.name)
|
|
153
|
-
};
|
|
154
|
-
mcp = {
|
|
155
|
-
...mcp,
|
|
156
|
-
clients: updatedClients,
|
|
157
|
-
tools: updatedTools,
|
|
158
|
-
commands: updatedCommands,
|
|
159
|
-
resources: updatedResources
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return { ...prevState, mcp };
|
|
163
|
-
});
|
|
164
|
-
}, [setAppState]);
|
|
165
|
-
const updateServer = import_react.useCallback((update) => {
|
|
166
|
-
pendingUpdatesRef.current.push(update);
|
|
167
|
-
if (flushTimerRef.current === null) {
|
|
168
|
-
flushTimerRef.current = setTimeout(flushPendingUpdates, MCP_BATCH_FLUSH_MS);
|
|
169
|
-
}
|
|
170
|
-
}, [flushPendingUpdates]);
|
|
171
|
-
const onConnectionAttempt = import_react.useCallback(({
|
|
172
|
-
client,
|
|
173
|
-
tools,
|
|
174
|
-
commands,
|
|
175
|
-
resources
|
|
176
|
-
}) => {
|
|
177
|
-
updateServer({ ...client, tools, commands, resources });
|
|
178
|
-
switch (client.type) {
|
|
179
|
-
case "connected": {
|
|
180
|
-
registerElicitationHandler(client.client, client.name, setAppState);
|
|
181
|
-
client.client.onclose = () => {
|
|
182
|
-
const configType = client.config.type ?? "stdio";
|
|
183
|
-
clearServerCache(client.name, client.config).catch(() => {
|
|
184
|
-
logForDebugging(`Failed to invalidate the server cache: ${client.name}`);
|
|
185
|
-
});
|
|
186
|
-
if (isMcpServerDisabled(client.name)) {
|
|
187
|
-
logMCPDebug(client.name, `Server is disabled, skipping automatic reconnection`);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (configType !== "stdio" && configType !== "sdk") {
|
|
191
|
-
const transportType = getTransportDisplayName(configType);
|
|
192
|
-
logMCPDebug(client.name, `${transportType} transport closed/disconnected, attempting automatic reconnection`);
|
|
193
|
-
const existingTimer = reconnectTimersRef.current.get(client.name);
|
|
194
|
-
if (existingTimer) {
|
|
195
|
-
clearTimeout(existingTimer);
|
|
196
|
-
reconnectTimersRef.current.delete(client.name);
|
|
197
|
-
}
|
|
198
|
-
const reconnectWithBackoff = async () => {
|
|
199
|
-
for (let attempt = 1;attempt <= MAX_RECONNECT_ATTEMPTS; attempt++) {
|
|
200
|
-
if (isMcpServerDisabled(client.name)) {
|
|
201
|
-
logMCPDebug(client.name, `Server disabled during reconnection, stopping retry`);
|
|
202
|
-
reconnectTimersRef.current.delete(client.name);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
updateServer({
|
|
206
|
-
...client,
|
|
207
|
-
type: "pending",
|
|
208
|
-
reconnectAttempt: attempt,
|
|
209
|
-
maxReconnectAttempts: MAX_RECONNECT_ATTEMPTS
|
|
210
|
-
});
|
|
211
|
-
const reconnectStartTime = Date.now();
|
|
212
|
-
try {
|
|
213
|
-
const result = await reconnectMcpServerImpl(client.name, client.config);
|
|
214
|
-
const elapsed = Date.now() - reconnectStartTime;
|
|
215
|
-
if (result.client.type === "connected") {
|
|
216
|
-
logMCPDebug(client.name, `${transportType} reconnection successful after ${elapsed}ms (attempt ${attempt})`);
|
|
217
|
-
reconnectTimersRef.current.delete(client.name);
|
|
218
|
-
onConnectionAttempt(result);
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
logMCPDebug(client.name, `${transportType} reconnection attempt ${attempt} completed with status: ${result.client.type}`);
|
|
222
|
-
if (attempt === MAX_RECONNECT_ATTEMPTS) {
|
|
223
|
-
logMCPDebug(client.name, `Max reconnection attempts (${MAX_RECONNECT_ATTEMPTS}) reached, giving up`);
|
|
224
|
-
reconnectTimersRef.current.delete(client.name);
|
|
225
|
-
onConnectionAttempt(result);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
} catch (error) {
|
|
229
|
-
const elapsed = Date.now() - reconnectStartTime;
|
|
230
|
-
logMCPError(client.name, `${transportType} reconnection attempt ${attempt} failed after ${elapsed}ms: ${error}`);
|
|
231
|
-
if (attempt === MAX_RECONNECT_ATTEMPTS) {
|
|
232
|
-
logMCPDebug(client.name, `Max reconnection attempts (${MAX_RECONNECT_ATTEMPTS}) reached, giving up`);
|
|
233
|
-
reconnectTimersRef.current.delete(client.name);
|
|
234
|
-
updateServer({ ...client, type: "failed" });
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
const backoffMs = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt - 1), MAX_BACKOFF_MS);
|
|
239
|
-
logMCPDebug(client.name, `Scheduling reconnection attempt ${attempt + 1} in ${backoffMs}ms`);
|
|
240
|
-
await new Promise((resolve) => {
|
|
241
|
-
const timer = setTimeout(resolve, backoffMs);
|
|
242
|
-
reconnectTimersRef.current.set(client.name, timer);
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
reconnectWithBackoff();
|
|
247
|
-
} else {
|
|
248
|
-
updateServer({ ...client, type: "failed" });
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
if (false) {
|
|
252
|
-
switch (gate.action) {
|
|
253
|
-
case "register":
|
|
254
|
-
case "skip":
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (client.capabilities?.tools?.listChanged) {
|
|
258
|
-
client.client.setNotificationHandler(ToolListChangedNotificationSchema, async () => {
|
|
259
|
-
logMCPDebug(client.name, `Received tools/list_changed notification, refreshing tools`);
|
|
260
|
-
try {
|
|
261
|
-
const previousToolsPromise = fetchToolsForClient.cache.get(client.name);
|
|
262
|
-
fetchToolsForClient.cache.delete(client.name);
|
|
263
|
-
const newTools = await fetchToolsForClient(client);
|
|
264
|
-
const newCount = newTools.length;
|
|
265
|
-
if (previousToolsPromise) {
|
|
266
|
-
previousToolsPromise.then((previousTools) => {
|
|
267
|
-
logEvent("tengu_mcp_list_changed", {
|
|
268
|
-
type: "tools",
|
|
269
|
-
previousCount: previousTools.length,
|
|
270
|
-
newCount
|
|
271
|
-
});
|
|
272
|
-
}, () => {
|
|
273
|
-
logEvent("tengu_mcp_list_changed", {
|
|
274
|
-
type: "tools",
|
|
275
|
-
newCount
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
} else {
|
|
279
|
-
logEvent("tengu_mcp_list_changed", {
|
|
280
|
-
type: "tools",
|
|
281
|
-
newCount
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
updateServer({ ...client, tools: newTools });
|
|
285
|
-
} catch (error) {
|
|
286
|
-
logMCPError(client.name, `Failed to refresh tools after list_changed notification: ${errorMessage(error)}`);
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
if (client.capabilities?.prompts?.listChanged) {
|
|
291
|
-
client.client.setNotificationHandler(PromptListChangedNotificationSchema, async () => {
|
|
292
|
-
logMCPDebug(client.name, `Received prompts/list_changed notification, refreshing prompts`);
|
|
293
|
-
logEvent("tengu_mcp_list_changed", {
|
|
294
|
-
type: "prompts"
|
|
295
|
-
});
|
|
296
|
-
try {
|
|
297
|
-
fetchCommandsForClient.cache.delete(client.name);
|
|
298
|
-
const [mcpPrompts, mcpSkills] = await Promise.all([
|
|
299
|
-
fetchCommandsForClient(client),
|
|
300
|
-
Promise.resolve([])
|
|
301
|
-
]);
|
|
302
|
-
updateServer({
|
|
303
|
-
...client,
|
|
304
|
-
commands: [...mcpPrompts, ...mcpSkills]
|
|
305
|
-
});
|
|
306
|
-
clearSkillIndexCache?.();
|
|
307
|
-
} catch (error) {
|
|
308
|
-
logMCPError(client.name, `Failed to refresh prompts after list_changed notification: ${errorMessage(error)}`);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
if (client.capabilities?.resources?.listChanged) {
|
|
313
|
-
client.client.setNotificationHandler(ResourceListChangedNotificationSchema, async () => {
|
|
314
|
-
logMCPDebug(client.name, `Received resources/list_changed notification, refreshing resources`);
|
|
315
|
-
logEvent("tengu_mcp_list_changed", {
|
|
316
|
-
type: "resources"
|
|
317
|
-
});
|
|
318
|
-
try {
|
|
319
|
-
fetchResourcesForClient.cache.delete(client.name);
|
|
320
|
-
if (false) {} else {
|
|
321
|
-
const newResources = await fetchResourcesForClient(client);
|
|
322
|
-
updateServer({ ...client, resources: newResources });
|
|
323
|
-
}
|
|
324
|
-
} catch (error) {
|
|
325
|
-
logMCPError(client.name, `Failed to refresh resources after list_changed notification: ${errorMessage(error)}`);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
case "needs-auth":
|
|
332
|
-
case "failed":
|
|
333
|
-
case "pending":
|
|
334
|
-
case "disabled":
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
}, [updateServer]);
|
|
338
|
-
const sessionId = getSessionId();
|
|
339
|
-
import_react.useEffect(() => {
|
|
340
|
-
async function initializeServersAsPending() {
|
|
341
|
-
const { servers: existingConfigs, errors: mcpErrors } = isStrictMcpConfig ? { servers: {}, errors: [] } : await getClaudeCodeMcpConfigs(dynamicMcpConfig);
|
|
342
|
-
const configs = { ...existingConfigs, ...dynamicMcpConfig };
|
|
343
|
-
addErrorsToAppState(setAppState, mcpErrors);
|
|
344
|
-
setAppState((prevState) => {
|
|
345
|
-
const { stale, ...mcpWithoutStale } = excludeStalePluginClients(prevState.mcp, configs);
|
|
346
|
-
for (const s of stale) {
|
|
347
|
-
const timer = reconnectTimersRef.current.get(s.name);
|
|
348
|
-
if (timer) {
|
|
349
|
-
clearTimeout(timer);
|
|
350
|
-
reconnectTimersRef.current.delete(s.name);
|
|
351
|
-
}
|
|
352
|
-
if (s.type === "connected") {
|
|
353
|
-
s.client.onclose = undefined;
|
|
354
|
-
clearServerCache(s.name, s.config).catch(() => {});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const existingServerNames = new Set(mcpWithoutStale.clients.map((c) => c.name));
|
|
358
|
-
const newClients = Object.entries(configs).filter(([name]) => !existingServerNames.has(name)).map(([name, config]) => ({
|
|
359
|
-
name,
|
|
360
|
-
type: isMcpServerDisabled(name) ? "disabled" : "pending",
|
|
361
|
-
config
|
|
362
|
-
}));
|
|
363
|
-
if (newClients.length === 0 && stale.length === 0) {
|
|
364
|
-
return prevState;
|
|
365
|
-
}
|
|
366
|
-
return {
|
|
367
|
-
...prevState,
|
|
368
|
-
mcp: {
|
|
369
|
-
...prevState.mcp,
|
|
370
|
-
...mcpWithoutStale,
|
|
371
|
-
clients: [...mcpWithoutStale.clients, ...newClients]
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
initializeServersAsPending().catch((error) => {
|
|
377
|
-
logMCPError("useManageMCPConnections", `Failed to initialize servers as pending: ${errorMessage(error)}`);
|
|
378
|
-
});
|
|
379
|
-
}, [
|
|
380
|
-
isStrictMcpConfig,
|
|
381
|
-
dynamicMcpConfig,
|
|
382
|
-
setAppState,
|
|
383
|
-
sessionId,
|
|
384
|
-
_pluginReconnectKey
|
|
385
|
-
]);
|
|
386
|
-
import_react.useEffect(() => {
|
|
387
|
-
let cancelled = false;
|
|
388
|
-
async function loadAndConnectMcpConfigs() {
|
|
389
|
-
let claudeaiPromise;
|
|
390
|
-
if (isStrictMcpConfig || doesEnterpriseMcpConfigExist()) {
|
|
391
|
-
claudeaiPromise = Promise.resolve({});
|
|
392
|
-
} else {
|
|
393
|
-
clearClaudeAIMcpConfigsCache();
|
|
394
|
-
claudeaiPromise = fetchClaudeAIMcpConfigsIfEligible();
|
|
395
|
-
}
|
|
396
|
-
const { servers: claudeCodeConfigs, errors: mcpErrors } = isStrictMcpConfig ? { servers: {}, errors: [] } : await getClaudeCodeMcpConfigs(dynamicMcpConfig, claudeaiPromise);
|
|
397
|
-
if (cancelled)
|
|
398
|
-
return;
|
|
399
|
-
addErrorsToAppState(setAppState, mcpErrors);
|
|
400
|
-
const configs = { ...claudeCodeConfigs, ...dynamicMcpConfig };
|
|
401
|
-
const enabledConfigs = Object.fromEntries(Object.entries(configs).filter(([name]) => !isMcpServerDisabled(name)));
|
|
402
|
-
getMcpToolsCommandsAndResources(onConnectionAttempt, enabledConfigs).catch((error) => {
|
|
403
|
-
logMCPError("useManageMcpConnections", `Failed to get MCP resources: ${errorMessage(error)}`);
|
|
404
|
-
});
|
|
405
|
-
let claudeaiConfigs = {};
|
|
406
|
-
if (!isStrictMcpConfig) {
|
|
407
|
-
claudeaiConfigs = filterMcpServersByPolicy(await claudeaiPromise).allowed;
|
|
408
|
-
if (cancelled)
|
|
409
|
-
return;
|
|
410
|
-
if (Object.keys(claudeaiConfigs).length > 0) {
|
|
411
|
-
const { servers: dedupedClaudeAi } = dedupClaudeAiMcpServers(claudeaiConfigs, configs);
|
|
412
|
-
claudeaiConfigs = dedupedClaudeAi;
|
|
413
|
-
}
|
|
414
|
-
if (Object.keys(claudeaiConfigs).length > 0) {
|
|
415
|
-
setAppState((prevState) => {
|
|
416
|
-
const existingServerNames = new Set(prevState.mcp.clients.map((c) => c.name));
|
|
417
|
-
const newClients = Object.entries(claudeaiConfigs).filter(([name]) => !existingServerNames.has(name)).map(([name, config]) => ({
|
|
418
|
-
name,
|
|
419
|
-
type: isMcpServerDisabled(name) ? "disabled" : "pending",
|
|
420
|
-
config
|
|
421
|
-
}));
|
|
422
|
-
if (newClients.length === 0)
|
|
423
|
-
return prevState;
|
|
424
|
-
return {
|
|
425
|
-
...prevState,
|
|
426
|
-
mcp: {
|
|
427
|
-
...prevState.mcp,
|
|
428
|
-
clients: [...prevState.mcp.clients, ...newClients]
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
});
|
|
432
|
-
const enabledClaudeaiConfigs = Object.fromEntries(Object.entries(claudeaiConfigs).filter(([name]) => !isMcpServerDisabled(name)));
|
|
433
|
-
getMcpToolsCommandsAndResources(onConnectionAttempt, enabledClaudeaiConfigs).catch((error) => {
|
|
434
|
-
logMCPError("useManageMcpConnections", `Failed to get claude.ai MCP resources: ${errorMessage(error)}`);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
const allConfigs = { ...configs, ...claudeaiConfigs };
|
|
439
|
-
const counts = {
|
|
440
|
-
enterprise: 0,
|
|
441
|
-
global: 0,
|
|
442
|
-
project: 0,
|
|
443
|
-
user: 0,
|
|
444
|
-
plugin: 0,
|
|
445
|
-
claudeai: 0
|
|
446
|
-
};
|
|
447
|
-
const stdioCommands = [];
|
|
448
|
-
for (const [name, serverConfig] of Object.entries(allConfigs)) {
|
|
449
|
-
if (serverConfig.scope === "enterprise")
|
|
450
|
-
counts.enterprise++;
|
|
451
|
-
else if (serverConfig.scope === "user")
|
|
452
|
-
counts.global++;
|
|
453
|
-
else if (serverConfig.scope === "project")
|
|
454
|
-
counts.project++;
|
|
455
|
-
else if (serverConfig.scope === "local")
|
|
456
|
-
counts.user++;
|
|
457
|
-
else if (serverConfig.scope === "dynamic")
|
|
458
|
-
counts.plugin++;
|
|
459
|
-
else if (serverConfig.scope === "claudeai")
|
|
460
|
-
counts.claudeai++;
|
|
461
|
-
if (process.env.USER_TYPE === "ant" && !isMcpServerDisabled(name) && (serverConfig.type === undefined || serverConfig.type === "stdio") && "command" in serverConfig) {
|
|
462
|
-
stdioCommands.push(basename(serverConfig.command));
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
logEvent("tengu_mcp_servers", {
|
|
466
|
-
...counts,
|
|
467
|
-
...process.env.USER_TYPE === "ant" && stdioCommands.length > 0 ? {
|
|
468
|
-
stdio_commands: stdioCommands.sort().join(",")
|
|
469
|
-
} : {}
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
loadAndConnectMcpConfigs();
|
|
473
|
-
return () => {
|
|
474
|
-
cancelled = true;
|
|
475
|
-
};
|
|
476
|
-
}, [
|
|
477
|
-
isStrictMcpConfig,
|
|
478
|
-
dynamicMcpConfig,
|
|
479
|
-
onConnectionAttempt,
|
|
480
|
-
setAppState,
|
|
481
|
-
_authVersion,
|
|
482
|
-
sessionId,
|
|
483
|
-
_pluginReconnectKey
|
|
484
|
-
]);
|
|
485
|
-
import_react.useEffect(() => {
|
|
486
|
-
const timers = reconnectTimersRef.current;
|
|
487
|
-
return () => {
|
|
488
|
-
for (const timer of timers.values()) {
|
|
489
|
-
clearTimeout(timer);
|
|
490
|
-
}
|
|
491
|
-
timers.clear();
|
|
492
|
-
if (flushTimerRef.current !== null) {
|
|
493
|
-
clearTimeout(flushTimerRef.current);
|
|
494
|
-
flushTimerRef.current = null;
|
|
495
|
-
flushPendingUpdates();
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
}, [flushPendingUpdates]);
|
|
499
|
-
const reconnectMcpServer = import_react.useCallback(async (serverName) => {
|
|
500
|
-
const client = store.getState().mcp.clients.find((c) => c.name === serverName);
|
|
501
|
-
if (!client) {
|
|
502
|
-
throw new Error(`MCP server ${serverName} not found`);
|
|
503
|
-
}
|
|
504
|
-
const existingTimer = reconnectTimersRef.current.get(serverName);
|
|
505
|
-
if (existingTimer) {
|
|
506
|
-
clearTimeout(existingTimer);
|
|
507
|
-
reconnectTimersRef.current.delete(serverName);
|
|
508
|
-
}
|
|
509
|
-
const result = await reconnectMcpServerImpl(serverName, client.config);
|
|
510
|
-
onConnectionAttempt(result);
|
|
511
|
-
return result;
|
|
512
|
-
}, [store, onConnectionAttempt]);
|
|
513
|
-
const toggleMcpServer = import_react.useCallback(async (serverName) => {
|
|
514
|
-
const client = store.getState().mcp.clients.find((c) => c.name === serverName);
|
|
515
|
-
if (!client) {
|
|
516
|
-
throw new Error(`MCP server ${serverName} not found`);
|
|
517
|
-
}
|
|
518
|
-
const isCurrentlyDisabled = client.type === "disabled";
|
|
519
|
-
if (!isCurrentlyDisabled) {
|
|
520
|
-
const existingTimer = reconnectTimersRef.current.get(serverName);
|
|
521
|
-
if (existingTimer) {
|
|
522
|
-
clearTimeout(existingTimer);
|
|
523
|
-
reconnectTimersRef.current.delete(serverName);
|
|
524
|
-
}
|
|
525
|
-
setMcpServerEnabled(serverName, false);
|
|
526
|
-
if (client.type === "connected") {
|
|
527
|
-
await clearServerCache(serverName, client.config);
|
|
528
|
-
}
|
|
529
|
-
updateServer({
|
|
530
|
-
name: serverName,
|
|
531
|
-
type: "disabled",
|
|
532
|
-
config: client.config
|
|
533
|
-
});
|
|
534
|
-
} else {
|
|
535
|
-
setMcpServerEnabled(serverName, true);
|
|
536
|
-
updateServer({
|
|
537
|
-
name: serverName,
|
|
538
|
-
type: "pending",
|
|
539
|
-
config: client.config
|
|
540
|
-
});
|
|
541
|
-
const result = await reconnectMcpServerImpl(serverName, client.config);
|
|
542
|
-
onConnectionAttempt(result);
|
|
543
|
-
}
|
|
544
|
-
}, [store, updateServer, onConnectionAttempt]);
|
|
545
|
-
return { reconnectMcpServer, toggleMcpServer };
|
|
546
|
-
}
|
|
547
|
-
function getTransportDisplayName(type) {
|
|
548
|
-
switch (type) {
|
|
549
|
-
case "http":
|
|
550
|
-
return "HTTP";
|
|
551
|
-
case "ws":
|
|
552
|
-
case "ws-ide":
|
|
553
|
-
return "WebSocket";
|
|
554
|
-
default:
|
|
555
|
-
return "SSE";
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
var import_react, clearSkillIndexCache = null, MAX_RECONNECT_ATTEMPTS = 5, INITIAL_BACKOFF_MS = 1000, MAX_BACKOFF_MS = 30000;
|
|
559
|
-
var init_useManageMCPConnections = __esm(() => {
|
|
560
|
-
init_state();
|
|
561
|
-
init_client();
|
|
562
|
-
init_types();
|
|
563
|
-
init_omit();
|
|
564
|
-
init_reject();
|
|
565
|
-
init_analytics();
|
|
566
|
-
init_config();
|
|
567
|
-
init_debug();
|
|
568
|
-
init_state();
|
|
569
|
-
init_notifications();
|
|
570
|
-
init_AppState();
|
|
571
|
-
init_errors();
|
|
572
|
-
init_log();
|
|
573
|
-
init_messageQueueManager();
|
|
574
|
-
init_channelNotification();
|
|
575
|
-
init_channelPermissions();
|
|
576
|
-
init_claudeai();
|
|
577
|
-
init_elicitationHandler();
|
|
578
|
-
init_mcpStringUtils();
|
|
579
|
-
init_utils();
|
|
580
|
-
import_react = __toESM(require_react(), 1);
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
// src/services/mcp/MCPConnectionManager.tsx
|
|
584
|
-
function useMcpReconnect() {
|
|
585
|
-
const context = import_react2.useContext(MCPConnectionContext);
|
|
586
|
-
if (!context) {
|
|
587
|
-
throw new Error("useMcpReconnect must be used within MCPConnectionManager");
|
|
588
|
-
}
|
|
589
|
-
return context.reconnectMcpServer;
|
|
590
|
-
}
|
|
591
|
-
function useMcpToggleEnabled() {
|
|
592
|
-
const context = import_react2.useContext(MCPConnectionContext);
|
|
593
|
-
if (!context) {
|
|
594
|
-
throw new Error("useMcpToggleEnabled must be used within MCPConnectionManager");
|
|
595
|
-
}
|
|
596
|
-
return context.toggleMcpServer;
|
|
597
|
-
}
|
|
598
|
-
function MCPConnectionManager({
|
|
599
|
-
children,
|
|
600
|
-
dynamicMcpConfig,
|
|
601
|
-
isStrictMcpConfig
|
|
602
|
-
}) {
|
|
603
|
-
const { reconnectMcpServer, toggleMcpServer } = useManageMCPConnections(dynamicMcpConfig, isStrictMcpConfig);
|
|
604
|
-
const value = import_react2.useMemo(() => ({ reconnectMcpServer, toggleMcpServer }), [reconnectMcpServer, toggleMcpServer]);
|
|
605
|
-
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(MCPConnectionContext.Provider, {
|
|
606
|
-
value,
|
|
607
|
-
children
|
|
608
|
-
}, undefined, false, undefined, this);
|
|
609
|
-
}
|
|
610
|
-
var import_react2, jsx_dev_runtime, MCPConnectionContext;
|
|
611
|
-
var init_MCPConnectionManager = __esm(() => {
|
|
612
|
-
init_useManageMCPConnections();
|
|
613
|
-
import_react2 = __toESM(require_react(), 1);
|
|
614
|
-
jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
615
|
-
MCPConnectionContext = import_react2.createContext(null);
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
export { init_channelPermissions, useMcpReconnect, useMcpToggleEnabled, MCPConnectionManager, init_MCPConnectionManager };
|