@unieai/code 0.0.10 → 0.0.12
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/README.en.md +6 -59
- package/README.md +5 -59
- package/dist/chunks/App-s5ex5j86.js +2 -0
- package/dist/chunks/ApproveApiKey-b4z6h2gn.js +2 -0
- package/dist/chunks/{assistant-yvtpv5sv.js → AssistantSessionChooser-g1vsya6h.js} +1 -1
- package/dist/chunks/BypassPermissionsModeDialog-jbg97eja.js +2 -0
- package/dist/chunks/ClaudeInChromeOnboarding-qa0pvwfw.js +2 -0
- package/dist/chunks/ClaudeMdExternalIncludesDialog-gqmed78y.js +2 -0
- package/dist/chunks/ConsoleOAuthFlow-yh72vs8j.js +2 -0
- package/dist/chunks/{DiffDialog-v8smgzpd.js → DiffDialog-t6vvtbb2.js} +1 -1
- package/dist/chunks/Doctor-k08ggw2j.js +2 -0
- package/dist/chunks/Grove-tkkskg8n.js +2 -0
- package/dist/chunks/ITermBackend-73waaahf.js +2 -0
- package/dist/chunks/{InProcessTransport-57c2w5v4.js → InProcessTransport-qwjgb17j.js} +1 -1
- package/dist/chunks/InvalidConfigDialog-zmqw3fj1.js +2 -0
- package/dist/chunks/InvalidSettingsDialog-tnd5hymg.js +2 -0
- package/dist/chunks/Onboarding-p0tq6pgz.js +2 -0
- package/dist/chunks/REPL-hjjz80kq.js +2 -0
- package/dist/chunks/ResumeConversation-krn9hqb1.js +2 -0
- package/dist/chunks/{SnapshotUpdateDialog-5yvfnp0q.js → SnapshotUpdateDialog-raq029pd.js} +1 -1
- package/dist/chunks/TeleportProgress-vyy2k3bv.js +2 -0
- package/dist/chunks/TeleportRepoMismatchDialog-ff0h2cnq.js +2 -0
- package/dist/chunks/TeleportResumeWrapper-esjykret.js +2 -0
- package/dist/chunks/{TmuxBackend-j665sv6f.js → TmuxBackend-14kmnkcb.js} +1 -1
- package/dist/chunks/ToolSearchTool-w4t61c7d.js +2 -0
- package/dist/chunks/TrustDialog-7fvaze2x.js +2 -0
- package/dist/chunks/TungstenTool-rv96z549.js +2 -0
- package/dist/chunks/add-dir-kqw72mky.js +2 -0
- package/dist/chunks/agents-3exybgtb.js +4 -0
- package/dist/chunks/{agents-e7x38q37.js → agents-z66twpqr.js} +1 -1
- package/dist/chunks/ant-claude-for-chrome-mcp-712xg07f.js +2 -0
- package/dist/chunks/api-z8svc3xt.js +2 -0
- package/dist/chunks/asciicast-vzd7qjbb.js +2 -0
- package/dist/chunks/{AssistantSessionChooser-0r5zamt1.js → assistant-ftzr3mjp.js} +1 -1
- package/dist/chunks/auth-gbyfq0g2.js +2 -0
- package/dist/chunks/auth-wk077awh.js +2 -0
- package/dist/chunks/backgroundHousekeeping-m8gthtkh.js +2 -0
- package/dist/chunks/branch-1d0b8590.js +5 -0
- package/dist/chunks/{bridgePointer-9q6wh2ct.js → bridgePointer-vhd47np6.js} +1 -1
- package/dist/chunks/btw-s3r5jhyd.js +2 -0
- package/dist/chunks/buddy-xzm5npk8.js +2 -0
- package/dist/chunks/{cachedMicrocompact-thnhx1zt.js → cachedMicrocompact-6j3zxr4g.js} +1 -1
- package/dist/chunks/caches-fbggdeq7.js +2 -0
- package/dist/chunks/chrome-mdyx0s5j.js +2 -0
- package/dist/chunks/{chromeNativeHost-nnjkj164.js → chromeNativeHost-8wc6wcr6.js} +1 -1
- package/dist/chunks/{claudeDesktop-nsangyk5.js → claudeDesktop-p5bfxmvz.js} +1 -1
- package/dist/chunks/{cleanup-mv462dsh.js → cleanup-q46nbce1.js} +1 -1
- package/dist/chunks/clear-fwad6zxy.js +2 -0
- package/dist/chunks/{cli-sbp2221d.js → cli-0dc8sd37.js} +2 -2
- package/dist/chunks/{cli-3xhqacdd.js → cli-0qt9btbe.js} +2 -2
- package/dist/chunks/{cli-4j5yyvek.js → cli-0w4wc1z0.js} +2 -2
- package/dist/chunks/{cli-r6hm1q63.js → cli-15sqp3mq.js} +2 -2
- package/dist/chunks/{cli-45ftgn85.js → cli-15w3eaed.js} +1 -1
- package/dist/chunks/{cli-b7wx1479.js → cli-19ncan36.js} +1 -1
- package/dist/chunks/{cli-hx28w3cq.js → cli-1jp3rm7n.js} +1 -1
- package/dist/chunks/{cli-90b87f45.js → cli-1n8he7s8.js} +2 -2
- package/dist/chunks/{cli-bthzmdgv.js → cli-1ny2386w.js} +2 -2
- package/dist/chunks/{cli-vq899n8p.js → cli-27mzrnr8.js} +1 -1
- package/dist/chunks/{cli-gnjff7md.js → cli-2rw44zfx.js} +2 -2
- package/dist/chunks/{cli-7gpep1x5.js → cli-2rwjx3w0.js} +1 -1
- package/dist/chunks/{cli-jqppy97b.js → cli-2wd8eaac.js} +2 -2
- package/dist/chunks/{cli-3hwpymrd.js → cli-350pymj4.js} +2 -2
- package/dist/chunks/{cli-w754xmyv.js → cli-3ac555qw.js} +2 -2
- package/dist/chunks/{cli-8kyjh67j.js → cli-3gwqrmcd.js} +1 -1
- package/dist/chunks/{cli-msr9n6da.js → cli-3m8n808e.js} +2 -2
- package/dist/chunks/{cli-ptv3h2tx.js → cli-42kma5r3.js} +1 -1
- package/dist/chunks/{cli-r9p0g894.js → cli-49m97nbg.js} +2 -2
- package/dist/chunks/{cli-bkxwwj81.js → cli-4a4bb1kf.js} +1 -1
- package/dist/chunks/{cli-3bxtq5dc.js → cli-4ewb3q42.js} +2 -2
- package/dist/chunks/{cli-v3mf1g0z.js → cli-4mvvtchx.js} +2 -2
- package/dist/chunks/{cli-r2p5bkx5.js → cli-4nejhkd0.js} +2 -2
- package/dist/chunks/{cli-dx46fn1w.js → cli-51720d82.js} +2 -2
- package/dist/chunks/cli-55jdp9ky.js +3 -0
- package/dist/chunks/{cli-6vwdnz9p.js → cli-55ntywtj.js} +1 -1
- package/dist/chunks/{cli-pz8vxqw0.js → cli-57yrpnaq.js} +2 -2
- package/dist/chunks/{cli-59ysj9y4.js → cli-5dt9yjha.js} +2 -2
- package/dist/chunks/{cli-e37w9dxm.js → cli-5f0w3fy6.js} +1 -1
- package/dist/chunks/{cli-z9jm4xjn.js → cli-5vsnhp97.js} +2 -2
- package/dist/chunks/{cli-x758qvv7.js → cli-61x73ksv.js} +1 -1
- package/dist/chunks/{cli-ye3qk73s.js → cli-66jj9zj3.js} +1 -1
- package/dist/chunks/{cli-zac1afnb.js → cli-6bxfdgv1.js} +1 -1
- package/dist/chunks/{cli-md1h6sbv.js → cli-6pdpyz1a.js} +1 -1
- package/dist/chunks/{cli-mejr8b5m.js → cli-6yprtw88.js} +2 -2
- package/dist/chunks/{cli-qs0v3mf6.js → cli-73jf8hyz.js} +2 -2
- package/dist/chunks/{cli-948we41z.js → cli-749tdaqc.js} +2 -2
- package/dist/chunks/{cli-vxxkrd5y.js → cli-764c4bsm.js} +2 -2
- package/dist/chunks/cli-78apjp3t.js +3 -0
- package/dist/chunks/{cli-k0jpcxwa.js → cli-7c99j0pt.js} +2 -2
- package/dist/chunks/{cli-by5b2216.js → cli-89x414pj.js} +2 -2
- package/dist/chunks/{cli-fqb71hy3.js → cli-8dmy2s42.js} +1 -1
- package/dist/chunks/cli-8hxz2qs6.js +3 -0
- package/dist/chunks/cli-8mk2zg4a.js +4 -0
- package/dist/chunks/{cli-29gcax34.js → cli-8qd16mt4.js} +2 -2
- package/dist/chunks/cli-95wg48h9.js +3 -0
- package/dist/chunks/{cli-wz9r5s81.js → cli-99mqr54v.js} +2 -2
- package/dist/chunks/{cli-8qk46mt3.js → cli-9aq7vxaq.js} +1 -1
- package/dist/chunks/{cli-zcpjf07m.js → cli-9z9r2set.js} +2 -2
- package/dist/chunks/{cli-2wvsym16.js → cli-a52ra30v.js} +1 -1
- package/dist/chunks/{cli-s6qk3rbv.js → cli-akcxtvv9.js} +2 -2
- package/dist/chunks/{cli-h3kcprht.js → cli-bmk0rb5v.js} +2 -2
- package/dist/chunks/{cli-pmzht94n.js → cli-br6zjh6x.js} +2 -2
- package/dist/chunks/{cli-z8hqtyjg.js → cli-c22wpdk4.js} +1 -1
- package/dist/chunks/{cli-zbt28krs.js → cli-c60c9qvm.js} +1 -1
- package/dist/chunks/{cli-3357rxva.js → cli-cqkne34j.js} +2 -2
- package/dist/chunks/{cli-0s65jzgr.js → cli-cwbxhdt1.js} +1 -1
- package/dist/chunks/{cli-xsap3gxj.js → cli-d0hzw78c.js} +1 -1
- package/dist/chunks/{cli-0b4dmvvw.js → cli-d53fhs6v.js} +2 -2
- package/dist/chunks/{cli-extf4h54.js → cli-dbdqrqmt.js} +1 -1
- package/dist/chunks/{cli-yf3sh3aw.js → cli-de1hwp88.js} +1 -1
- package/dist/chunks/cli-edkqs0ge.js +3 -0
- package/dist/chunks/{cli-dsnjsvqs.js → cli-er7z496e.js} +2 -2
- package/dist/chunks/{cli-atpfeg28.js → cli-eyw3czmn.js} +2 -2
- package/dist/chunks/{cli-tyxvdf66.js → cli-ezs5sney.js} +2 -2
- package/dist/chunks/{cli-tn47e131.js → cli-f63fdj4w.js} +2 -2
- package/dist/chunks/cli-fakdskp6.js +3 -0
- package/dist/chunks/{cli-nj726gac.js → cli-fdya77ch.js} +3 -3
- package/dist/chunks/{cli-b1dptek2.js → cli-fghyxar5.js} +2 -2
- package/dist/chunks/{cli-g1spmn9n.js → cli-fm14mg07.js} +1 -1
- package/dist/chunks/{cli-cr1hvkmz.js → cli-fs7yttfp.js} +2 -2
- package/dist/chunks/{cli-rcvta3zk.js → cli-fwrj8ybs.js} +2 -2
- package/dist/chunks/{cli-v77avvvk.js → cli-g4n9das2.js} +1 -1
- package/dist/chunks/{cli-cbdrqqf2.js → cli-g5wq5ptg.js} +2 -2
- package/dist/chunks/{cli-yrk194b9.js → cli-gq5fve62.js} +1 -1
- package/dist/chunks/{cli-nykt265k.js → cli-grxvgq2n.js} +1 -1
- package/dist/chunks/{cli-ffjjv4j8.js → cli-gtm212j6.js} +2 -2
- package/dist/chunks/{cli-skq9ktf8.js → cli-gxgdnjfn.js} +1 -1
- package/dist/chunks/{cli-x5z5m6y7.js → cli-h120wpk2.js} +1 -1
- package/dist/chunks/{cli-58t6a5n6.js → cli-h4a90xbh.js} +1 -1
- package/dist/chunks/cli-h4dspaac.js +3 -0
- package/dist/chunks/{cli-a98b285v.js → cli-hke6r0q8.js} +2 -2
- package/dist/chunks/{cli-jxwm52wg.js → cli-hzr2zraz.js} +1 -1
- package/dist/chunks/{cli-x4a9geyz.js → cli-j08dmxw5.js} +1 -1
- package/dist/chunks/{cli-jvs98a70.js → cli-ja540nr7.js} +1 -1
- package/dist/chunks/{cli-dr1ph0pp.js → cli-jegyadmb.js} +2 -2
- package/dist/chunks/{cli-xjx11p6m.js → cli-jgn9jprh.js} +2 -2
- package/dist/chunks/{cli-n3m134cf.js → cli-jj93qmmc.js} +2 -2
- package/dist/chunks/{cli-kje3t5yg.js → cli-jkj867t1.js} +3 -3
- package/dist/chunks/{cli-6he3kpeb.js → cli-k2nh5cby.js} +2 -2
- package/dist/chunks/{cli-3je4vtx7.js → cli-k4v08k8t.js} +2 -2
- package/dist/chunks/{cli-c2pn6csk.js → cli-khs3sj9k.js} +1 -1
- package/dist/chunks/{cli-shz2e0q5.js → cli-kq16afrr.js} +2 -2
- package/dist/chunks/{cli-2zh6c5xz.js → cli-kqv5b8zh.js} +1 -1
- package/dist/chunks/{cli-k8fd74g6.js → cli-m0z3rmf0.js} +2 -2
- package/dist/chunks/{cli-a72n4ej7.js → cli-m12smc5e.js} +1 -1
- package/dist/chunks/{cli-15zbq52w.js → cli-m8fq163z.js} +1 -1
- package/dist/chunks/{cli-1215h20m.js → cli-mb1qrqw1.js} +2 -2
- package/dist/chunks/{cli-50wh7ttg.js → cli-mbp8f3f3.js} +2 -2
- package/dist/chunks/{cli-5pb6kdxn.js → cli-me4e2p3e.js} +595 -595
- package/dist/chunks/{cli-vz1j9n38.js → cli-mj03488e.js} +2 -2
- package/dist/chunks/{cli-6dcra6rs.js → cli-ms5j6fff.js} +2 -2
- package/dist/chunks/{cli-0v6qg4zv.js → cli-msgx4pnp.js} +2 -2
- package/dist/chunks/cli-msmzt4c3.js +130 -0
- package/dist/chunks/{cli-h5yfk29j.js → cli-msw0vv86.js} +2 -2
- package/dist/chunks/{cli-ewts4g0p.js → cli-mzcsnm06.js} +2 -2
- package/dist/chunks/{cli-wr4k6ngg.js → cli-n5s5fnyj.js} +2 -2
- package/dist/chunks/{cli-ygq3fy9g.js → cli-ns0aaggm.js} +1 -1
- package/dist/chunks/{cli-1a2nss2m.js → cli-nvnj7r73.js} +1 -1
- package/dist/chunks/{cli-hpzy0mat.js → cli-p0vh69b9.js} +2 -2
- package/dist/chunks/{cli-zf7yzkn6.js → cli-p2cqnrnp.js} +2 -2
- package/dist/chunks/{cli-px7jhzgq.js → cli-pbc8sk2d.js} +2 -2
- package/dist/chunks/{cli-29078yxj.js → cli-pgg33dhw.js} +2 -2
- package/dist/chunks/cli-przq3zk6.js +3 -0
- package/dist/chunks/{cli-q9fn82b1.js → cli-q0156x0d.js} +2 -2
- package/dist/chunks/{cli-zdy5bccv.js → cli-q46epwyh.js} +1 -1
- package/dist/chunks/{cli-v8w48y51.js → cli-qaxvg7gv.js} +1 -1
- package/dist/chunks/{cli-ytj910yt.js → cli-qm684n63.js} +1 -1
- package/dist/chunks/{cli-2qec7gn4.js → cli-r3etpht1.js} +1 -1
- package/dist/chunks/{cli-amy2yafd.js → cli-r83ttew2.js} +2 -2
- package/dist/chunks/{cli-22zbzzap.js → cli-r9db9mqv.js} +1 -1
- package/dist/chunks/{cli-3q7meftn.js → cli-rjerv816.js} +2 -2
- package/dist/chunks/{cli-mx6xk0dw.js → cli-rvad3yhg.js} +2 -2
- package/dist/chunks/{cli-wfqsfwa2.js → cli-rxb5q8zw.js} +2 -2
- package/dist/chunks/{cli-7cn4gwqc.js → cli-s160fqyz.js} +2 -2
- package/dist/chunks/{cli-v2hg35qk.js → cli-s6vr7213.js} +2 -2
- package/dist/chunks/{cli-49dqgzsg.js → cli-s9fhtgmz.js} +2 -2
- package/dist/chunks/{cli-tezq577c.js → cli-scaqq0v9.js} +2 -2
- package/dist/chunks/{cli-15tr7ade.js → cli-sh9w2tbd.js} +1 -1
- package/dist/chunks/{cli-zd2e6bq1.js → cli-sycqd3xe.js} +4 -4
- package/dist/chunks/{cli-d06qr5p3.js → cli-t4j047cx.js} +2 -2
- package/dist/chunks/{cli-s5epnnj5.js → cli-t9jht3kb.js} +2 -2
- package/dist/chunks/{cli-bd1ryrzd.js → cli-tckzkegq.js} +1 -1
- package/dist/chunks/{cli-p2gt60aj.js → cli-tfv2qcgf.js} +1 -1
- package/dist/chunks/{cli-1qszxdan.js → cli-tq5z9qv3.js} +2 -2
- package/dist/chunks/{cli-wthnf2t5.js → cli-tt9a4124.js} +1 -1
- package/dist/chunks/{cli-8v5ajztt.js → cli-tyqh91zq.js} +1 -1
- package/dist/chunks/cli-v943fd6a.js +3 -0
- package/dist/chunks/{cli-wn4ywgbv.js → cli-v9f860t5.js} +2 -2
- package/dist/chunks/{cli-qc7zfabw.js → cli-vkvmhjha.js} +2 -2
- package/dist/chunks/{cli-6b6e5zj9.js → cli-vkzp66cm.js} +2 -2
- package/dist/chunks/{cli-6qhwqfwp.js → cli-vwg0v35a.js} +2 -2
- package/dist/chunks/{cli-x514vyva.js → cli-w1d8n9g3.js} +1 -1
- package/dist/chunks/cli-w52yvzkn.js +3 -0
- package/dist/chunks/{cli-et2cj5dc.js → cli-wbe1p8n2.js} +2 -2
- package/dist/chunks/{cli-5mdbbvnv.js → cli-wm8qb6j3.js} +1 -1
- package/dist/chunks/{cli-1tq57kq0.js → cli-wn2srq2e.js} +1 -1
- package/dist/chunks/{cli-088ac95n.js → cli-wt2bfbn0.js} +2 -2
- package/dist/chunks/{cli-jmypsed1.js → cli-x70v8rsj.js} +2 -2
- package/dist/chunks/{cli-5wh173wa.js → cli-x8xgga1a.js} +3 -3
- package/dist/chunks/{cli-2vc9kv40.js → cli-xfsqvp8r.js} +2 -2
- package/dist/chunks/{cli-6xmbrh42.js → cli-xmgm2573.js} +2 -2
- package/dist/chunks/{cli-d58ptbve.js → cli-xpa1neza.js} +2 -2
- package/dist/chunks/{cli-6bxmycm6.js → cli-yqbvprz7.js} +1 -1
- package/dist/chunks/{cli-bz32070f.js → cli-yrwenjxs.js} +1 -1
- package/dist/chunks/{cli-3p0mfsqg.js → cli-z5e72gsd.js} +1 -1
- package/dist/chunks/{cli-z2jpyr57.js → cli-zev50xap.js} +1 -1
- package/dist/chunks/{cli-mjz85907.js → cli-zjbzak9n.js} +1 -1
- package/dist/chunks/{cli-h2dynmt7.js → cli-zjfya500.js} +1 -1
- package/dist/chunks/{cli-60mdvk6q.js → cli-zp8s7q5w.js} +1 -1
- package/dist/chunks/{cli-znz72ctn.js → cli-zpcncwrv.js} +1 -1
- package/dist/chunks/{cli-ew59cmn3.js → cli-zxdnz6vp.js} +1 -1
- package/dist/chunks/client-dkpgx025.js +2 -0
- package/dist/chunks/color-zrm6r755.js +2 -0
- package/dist/chunks/commitAttribution-3y6pessz.js +2 -0
- package/dist/chunks/common-0bee37at.js +2 -0
- package/dist/chunks/compact-zmvj1pk0.js +4 -0
- package/dist/chunks/config-gj0gbg5g.js +2 -0
- package/dist/chunks/config-hbq35b68.js +2 -0
- package/dist/chunks/context-h1qc69rg.js +2 -0
- package/dist/chunks/context-noninteractive-7wbe6qvd.js +2 -0
- package/dist/chunks/conversation-fwnfp0p5.js +2 -0
- package/dist/chunks/{copy-bpypgpy8.js → copy-76r9v46d.js} +1 -1
- package/dist/chunks/cost-56r5xxqy.js +5 -0
- package/dist/chunks/createSession-m5y8fjy4.js +2 -0
- package/dist/chunks/desktop-z3jqgnw7.js +2 -0
- package/dist/chunks/detectRepository-w6wawmmg.js +2 -0
- package/dist/chunks/detection-1yb2c7hh.js +2 -0
- package/dist/chunks/{devtools-mt3vnaw3.js → devtools-10ba48t9.js} +1 -1
- package/dist/chunks/{diff-bcdc10jv.js → diff-05xxjeqc.js} +1 -1
- package/dist/chunks/doctor-hgwjdraj.js +2 -0
- package/dist/chunks/earlyInput-navj6cdn.js +2 -0
- package/dist/chunks/effort-a190c878.js +9 -0
- package/dist/chunks/executor-s42mdmqs.js +2 -0
- package/dist/chunks/exit-kyrjy6hb.js +2 -0
- package/dist/chunks/export-ct4sty4d.js +3 -0
- package/dist/chunks/extra-usage-noninteractive-byts9mme.js +2 -0
- package/dist/chunks/extra-usage-xh1mkrca.js +2 -0
- package/dist/chunks/fast-g4aa49jf.js +2 -0
- package/dist/chunks/feedback-m5r66qd5.js +2 -0
- package/dist/chunks/{files-fx3xz1bj.js → files-qrrrkjke.js} +1 -1
- package/dist/chunks/firstPartyEventLogger-mthxtmgc.js +2 -0
- package/dist/chunks/gates-yhakv4vb.js +2 -0
- package/dist/chunks/git-c39vd9dm.js +2 -0
- package/dist/chunks/goal-24dr7fwz.js +2 -0
- package/dist/chunks/growthbook-f7ag30hy.js +2 -0
- package/dist/chunks/heapdump-16gnh3zm.js +7 -0
- package/dist/chunks/help-rgcakcxe.js +2 -0
- package/dist/chunks/hooks-8dh43zmv.js +2 -0
- package/dist/chunks/{hooks-7kspbr6v.js → hooks-c7fqwas5.js} +1 -1
- package/dist/chunks/{ide-5bsqkr23.js → ide-q83qr9cn.js} +1 -1
- package/dist/chunks/index-v875zpde.js +2 -0
- package/dist/chunks/initReplBridge-zfwxgpsm.js +2 -0
- package/dist/chunks/ink-vkxsn90v.js +2 -0
- package/dist/chunks/{insights-z9edzgf1.js → insights-4fwap4e5.js} +1 -1
- package/dist/chunks/install-7nxzmgp5.js +2 -0
- package/dist/chunks/{install-github-app-918fh4r2.js → install-github-app-djzea7r4.js} +1 -1
- package/dist/chunks/install-slack-app-3rde0k08.js +2 -0
- package/dist/chunks/{instrumentation-b8ysw74t.js → instrumentation-223qqr23.js} +1 -1
- package/dist/chunks/keybindings-6t5f69wx.js +3 -0
- package/dist/chunks/loadAgentsDir-f8shfnw3.js +2 -0
- package/dist/chunks/loadPluginHooks-mdwjrjtp.js +2 -0
- package/dist/chunks/login-34j3xdr9.js +2 -0
- package/dist/chunks/logout-yew8mymc.js +2 -0
- package/dist/chunks/{main-sqrzjvg9.js → main-0b8hyp8h.js} +79 -79
- package/dist/chunks/mcp-9enw5a8j.js +2 -0
- package/dist/chunks/mcp-fn4yrf5y.js +3 -0
- package/dist/chunks/{mcp-dqh1vtvf.js → mcp-yymqpmv6.js} +3 -3
- package/dist/chunks/mcpServer-60jg9v58.js +2 -0
- package/dist/chunks/mcpServer-85gt8ypc.js +2 -0
- package/dist/chunks/memory-kam5z1cw.js +4 -0
- package/dist/chunks/{mobile-9m41g9bp.js → mobile-7zsgawnb.js} +1 -1
- package/dist/chunks/model-03987182.js +2 -0
- package/dist/chunks/model-wbxx5kcd.js +3 -0
- package/dist/chunks/{oauth-98khjrd8.js → oauth-y0p2y1w5.js} +1 -1
- package/dist/chunks/{output-style-1h6b2zf8.js → output-style-x148mzhn.js} +1 -1
- package/dist/chunks/parser-4y4b0e6b.js +2 -0
- package/dist/chunks/passes-jrmjk5zk.js +2 -0
- package/dist/chunks/permissions-karmgb0m.js +4 -0
- package/dist/chunks/plan-w0beh9bh.js +2 -0
- package/dist/chunks/plugin-6nwptn3s.js +2 -0
- package/dist/chunks/pluginStartupCheck-0nzv1ae9.js +2 -0
- package/dist/chunks/{plugins-pe89pa7p.js → plugins-vvf897b4.js} +2 -2
- package/dist/chunks/{preauthorizedConfig-g0aq6f03.js → preauthorizedConfig-p02f23jb.js} +1 -1
- package/dist/chunks/{print-cjjnhg9d.js → print-krwpbp2j.js} +4 -4
- package/dist/chunks/privacy-settings-m0mfykh0.js +2 -0
- package/dist/chunks/process-26nny2p0.js +2 -0
- package/dist/chunks/processBashCommand-8fqgv2ec.js +2 -0
- package/dist/chunks/{processSlashCommand-6d8rnm8v.js → processSlashCommand-q32wy80b.js} +1 -1
- package/dist/chunks/prompt-gw1e1gef.js +2 -0
- package/dist/chunks/prompt-xgw2hxrc.js +2 -0
- package/dist/chunks/provider-prompt-s26vatcw.js +2 -0
- package/dist/chunks/rate-limit-options-rd4rjfv5.js +2 -0
- package/dist/chunks/registry-fp7x9ekd.js +2 -0
- package/dist/chunks/release-notes-76y1r2s1.js +6 -0
- package/dist/chunks/reload-plugins-z0fepkva.js +3 -0
- package/dist/chunks/remote-env-nn9ngr99.js +2 -0
- package/dist/chunks/remoteBridgeCore-cg7qd8m4.js +2 -0
- package/dist/chunks/rename-fdjzyjar.js +2 -0
- package/dist/chunks/resume-4rvj8jbz.js +3 -0
- package/dist/chunks/{rewind-cpv2pwfx.js → rewind-r4g5njsg.js} +1 -1
- package/dist/chunks/sandbox-adapter-craea9vm.js +2 -0
- package/dist/chunks/sandbox-toggle-620bkz9q.js +2 -0
- package/dist/chunks/session-5vm1vwv1.js +3 -0
- package/dist/chunks/sessionFileAccessHooks-5jbvwabj.js +2 -0
- package/dist/chunks/sessionStorage-ffkhmn5q.js +2 -0
- package/dist/chunks/settings-s2bcajs6.js +2 -0
- package/dist/chunks/setup-fwcttwbm.js +2 -0
- package/dist/chunks/setup-pf09nfsj.js +7 -0
- package/dist/chunks/{setup-mecsw2ye.js → setup-vegs56f5.js} +1 -1
- package/dist/chunks/sinks-wd4ccgbf.js +2 -0
- package/dist/chunks/skills-evga8f7n.js +2 -0
- package/dist/chunks/startupProfiler-x5zbs2j7.js +2 -0
- package/dist/chunks/state-qpmfrvsv.js +2 -0
- package/dist/chunks/{stats-3v0r4e1v.js → stats-mgqf6r7c.js} +1 -1
- package/dist/chunks/status-78yks3jw.js +2 -0
- package/dist/chunks/stickers-bdp8w2gr.js +2 -0
- package/dist/chunks/subprocessEnv-s797f06r.js +2 -0
- package/dist/chunks/{systemPromptSections-htbs443y.js → systemPromptSections-07y2z2wn.js} +1 -1
- package/dist/chunks/tag-gd73kstd.js +12 -0
- package/dist/chunks/tasks-63qaca0z.js +2 -0
- package/dist/chunks/{teamHelpers-dddedf19.js → teamHelpers-8ykc4bxa.js} +1 -1
- package/dist/chunks/teammateModeSnapshot-ae9r29dy.js +2 -0
- package/dist/chunks/teleport-es58k4xz.js +2 -0
- package/dist/chunks/terminalSetup-gyh5z5e2.js +2 -0
- package/dist/chunks/theme-qrhbaht6.js +2 -0
- package/dist/chunks/thinkback-5bs7ezv5.js +2 -0
- package/dist/chunks/thinkback-play-1dy160y5.js +2 -0
- package/dist/chunks/toolSearch-6cv284b7.js +2 -0
- package/dist/chunks/trustedDevice-77ketbgg.js +2 -0
- package/dist/chunks/{ultrareviewCommand-jtmh2xb1.js → ultrareviewCommand-j23bjbf8.js} +1 -1
- package/dist/chunks/{update-mkzzbt54.js → update-w8wdxh3m.js} +1 -1
- package/dist/chunks/upgrade-nft7c1yk.js +2 -0
- package/dist/chunks/{upstreamproxy-hbbvxzb5.js → upstreamproxy-x405ef9p.js} +1 -1
- package/dist/chunks/usage-s5qgc615.js +2 -0
- package/dist/chunks/util-1geb93kp.js +2 -0
- package/dist/chunks/utils-6sb44pg8.js +2 -0
- package/dist/chunks/vim-kq91w44a.js +2 -0
- package/dist/chunks/worktree-0af6b1mt.js +2 -0
- package/dist/chunks/worktreeModeEnabled-ea6wb7aj.js +2 -0
- package/dist/cli.js +1 -1
- package/package.json +4 -1
- package/preload.ts +24 -2
- package/dist/chunks/App-skattzvx.js +0 -2
- package/dist/chunks/ApproveApiKey-1zk1g80v.js +0 -2
- package/dist/chunks/BypassPermissionsModeDialog-4bd5a65d.js +0 -2
- package/dist/chunks/ClaudeInChromeOnboarding-jrj410t2.js +0 -2
- package/dist/chunks/ClaudeMdExternalIncludesDialog-2bn5pwwr.js +0 -2
- package/dist/chunks/ConsoleOAuthFlow-8hn6958t.js +0 -2
- package/dist/chunks/Doctor-w0eqwfzb.js +0 -2
- package/dist/chunks/Grove-ygg0z9mr.js +0 -2
- package/dist/chunks/ITermBackend-ht0ds6se.js +0 -2
- package/dist/chunks/InvalidConfigDialog-h2jkde64.js +0 -2
- package/dist/chunks/InvalidSettingsDialog-3p7ehs0t.js +0 -2
- package/dist/chunks/Onboarding-np5yfyy1.js +0 -2
- package/dist/chunks/REPL-8811fta4.js +0 -2
- package/dist/chunks/ResumeConversation-d03pbgnw.js +0 -2
- package/dist/chunks/TeleportProgress-ghjbbh9h.js +0 -2
- package/dist/chunks/TeleportRepoMismatchDialog-hhcyekar.js +0 -2
- package/dist/chunks/TeleportResumeWrapper-66e7dnk5.js +0 -2
- package/dist/chunks/ToolSearchTool-dgwhh0gd.js +0 -2
- package/dist/chunks/TrustDialog-w9tj4t8r.js +0 -2
- package/dist/chunks/TungstenTool-7k2gt6pa.js +0 -2
- package/dist/chunks/add-dir-pg1rb88e.js +0 -2
- package/dist/chunks/agents-mcbqv3h3.js +0 -4
- package/dist/chunks/ant-claude-for-chrome-mcp-c765s2bt.js +0 -2
- package/dist/chunks/api-qvdz0vdp.js +0 -2
- package/dist/chunks/asciicast-ygqjzj6w.js +0 -2
- package/dist/chunks/auth-gkfrn4ga.js +0 -2
- package/dist/chunks/auth-y1hqesm6.js +0 -2
- package/dist/chunks/backgroundHousekeeping-wk8ne1wg.js +0 -2
- package/dist/chunks/branch-yre4hh7s.js +0 -5
- package/dist/chunks/btw-091q02sh.js +0 -2
- package/dist/chunks/buddy-5xd2vjhm.js +0 -2
- package/dist/chunks/caches-g4cc992y.js +0 -2
- package/dist/chunks/chrome-rd8crze6.js +0 -2
- package/dist/chunks/clear-25jzke5j.js +0 -2
- package/dist/chunks/cli-6hvqmebc.js +0 -3
- package/dist/chunks/cli-9hskw92e.js +0 -130
- package/dist/chunks/cli-avcnnw0n.js +0 -3
- package/dist/chunks/cli-e9pafjv1.js +0 -4
- package/dist/chunks/cli-gyp5wyzg.js +0 -3
- package/dist/chunks/cli-jbbxj53h.js +0 -3
- package/dist/chunks/cli-pbp5hza0.js +0 -3
- package/dist/chunks/cli-tzaj50bd.js +0 -3
- package/dist/chunks/cli-xzsc9n84.js +0 -3
- package/dist/chunks/cli-yv1znypb.js +0 -3
- package/dist/chunks/client-037bm52v.js +0 -2
- package/dist/chunks/color-ceqfke15.js +0 -2
- package/dist/chunks/commitAttribution-3ewwca68.js +0 -2
- package/dist/chunks/common-jn8w5r1w.js +0 -2
- package/dist/chunks/compact-631qpkbp.js +0 -4
- package/dist/chunks/config-6em7qq45.js +0 -2
- package/dist/chunks/config-h2e5ra49.js +0 -2
- package/dist/chunks/context-31c3znwn.js +0 -2
- package/dist/chunks/context-noninteractive-q418vz0p.js +0 -2
- package/dist/chunks/conversation-yz22h1cb.js +0 -2
- package/dist/chunks/cost-8rr9expn.js +0 -5
- package/dist/chunks/createSession-jratqxvc.js +0 -2
- package/dist/chunks/desktop-zq22ksq3.js +0 -2
- package/dist/chunks/detectRepository-djxyq37h.js +0 -2
- package/dist/chunks/detection-b18r43da.js +0 -2
- package/dist/chunks/doctor-cs43t62h.js +0 -2
- package/dist/chunks/earlyInput-361tx72y.js +0 -2
- package/dist/chunks/effort-qw83nert.js +0 -9
- package/dist/chunks/executor-rvxyyheh.js +0 -2
- package/dist/chunks/exit-kynz824m.js +0 -2
- package/dist/chunks/export-95j3srp6.js +0 -3
- package/dist/chunks/extra-usage-hxyp53v5.js +0 -2
- package/dist/chunks/extra-usage-noninteractive-53w28t1j.js +0 -2
- package/dist/chunks/fast-ec1hxnv7.js +0 -2
- package/dist/chunks/feedback-qtsk3t9f.js +0 -2
- package/dist/chunks/firstPartyEventLogger-4yfx731e.js +0 -2
- package/dist/chunks/gates-85t459a0.js +0 -2
- package/dist/chunks/git-e0mvprv8.js +0 -2
- package/dist/chunks/goal-ywc7exvv.js +0 -2
- package/dist/chunks/growthbook-ykj8089v.js +0 -2
- package/dist/chunks/heapdump-w6a13cfe.js +0 -7
- package/dist/chunks/help-enq1htxe.js +0 -2
- package/dist/chunks/hooks-wxm384wn.js +0 -2
- package/dist/chunks/initReplBridge-acrf7hyb.js +0 -2
- package/dist/chunks/ink-9vrw9yhe.js +0 -2
- package/dist/chunks/install-c8gv4wfg.js +0 -2
- package/dist/chunks/install-slack-app-1aqgxsb6.js +0 -2
- package/dist/chunks/keybindings-v92d2xht.js +0 -3
- package/dist/chunks/loadAgentsDir-k53rdwbr.js +0 -2
- package/dist/chunks/loadPluginHooks-rmzgs29p.js +0 -2
- package/dist/chunks/login-j9bz1g34.js +0 -2
- package/dist/chunks/logout-58wm6hsc.js +0 -2
- package/dist/chunks/mcp-z3j236hk.js +0 -3
- package/dist/chunks/mcp-zryxxcaz.js +0 -2
- package/dist/chunks/mcpServer-b2m7ewct.js +0 -2
- package/dist/chunks/mcpServer-xpq096r4.js +0 -2
- package/dist/chunks/memory-5tvqvktk.js +0 -4
- package/dist/chunks/model-cta1svwb.js +0 -3
- package/dist/chunks/model-d96jkka7.js +0 -2
- package/dist/chunks/parser-jpf6bfmz.js +0 -2
- package/dist/chunks/passes-reh6ja9j.js +0 -2
- package/dist/chunks/permissions-xgydmrq2.js +0 -4
- package/dist/chunks/plan-z4k8zj56.js +0 -2
- package/dist/chunks/plugin-0tztmcsg.js +0 -2
- package/dist/chunks/pluginStartupCheck-vxmkvt40.js +0 -2
- package/dist/chunks/privacy-settings-zbrc40a1.js +0 -2
- package/dist/chunks/process-msr26xa0.js +0 -2
- package/dist/chunks/processBashCommand-hnhy8brr.js +0 -2
- package/dist/chunks/prompt-cfaneybz.js +0 -2
- package/dist/chunks/prompt-wg6hfj0k.js +0 -2
- package/dist/chunks/provider-prompt-c8wew66t.js +0 -2
- package/dist/chunks/rate-limit-options-fyjqpxp3.js +0 -2
- package/dist/chunks/registry-ht9aazng.js +0 -2
- package/dist/chunks/release-notes-5v16zb9c.js +0 -6
- package/dist/chunks/reload-plugins-apyma8vs.js +0 -3
- package/dist/chunks/remote-env-p6ym55w6.js +0 -2
- package/dist/chunks/remoteBridgeCore-0v9x8112.js +0 -2
- package/dist/chunks/rename-j9rc9dwj.js +0 -2
- package/dist/chunks/resume-tbr3mkch.js +0 -3
- package/dist/chunks/sandbox-adapter-qh943bs4.js +0 -2
- package/dist/chunks/sandbox-toggle-1f70ejwk.js +0 -2
- package/dist/chunks/session-42zhjgd2.js +0 -3
- package/dist/chunks/sessionFileAccessHooks-1nh915er.js +0 -2
- package/dist/chunks/sessionStorage-j5m0nf55.js +0 -2
- package/dist/chunks/settings-c709knqg.js +0 -2
- package/dist/chunks/setup-0n2p20yw.js +0 -7
- package/dist/chunks/setup-2hqyyxff.js +0 -2
- package/dist/chunks/sinks-q6etaenz.js +0 -2
- package/dist/chunks/skills-xads3027.js +0 -2
- package/dist/chunks/startupProfiler-4wmjq0yd.js +0 -2
- package/dist/chunks/state-edaz98bj.js +0 -2
- package/dist/chunks/status-9rtty0ee.js +0 -2
- package/dist/chunks/stickers-m73qwecp.js +0 -2
- package/dist/chunks/subprocessEnv-rass28aq.js +0 -2
- package/dist/chunks/tag-vj93fgp6.js +0 -12
- package/dist/chunks/tasks-avbqta2s.js +0 -2
- package/dist/chunks/teammateModeSnapshot-32yfa4hf.js +0 -2
- package/dist/chunks/teleport-jw6w0rn4.js +0 -2
- package/dist/chunks/terminalSetup-ppt6v9xf.js +0 -2
- package/dist/chunks/theme-2csrfbca.js +0 -2
- package/dist/chunks/thinkback-2ahfejyt.js +0 -2
- package/dist/chunks/thinkback-play-kffa7rdp.js +0 -2
- package/dist/chunks/toolSearch-ptrcr8ec.js +0 -2
- package/dist/chunks/trustedDevice-xvtp79f1.js +0 -2
- package/dist/chunks/upgrade-c4argpvv.js +0 -2
- package/dist/chunks/usage-w30yajzy.js +0 -2
- package/dist/chunks/util-zkawe0w0.js +0 -2
- package/dist/chunks/utils-v86tf27x.js +0 -2
- package/dist/chunks/vim-3stm1kbg.js +0 -2
- package/dist/chunks/worktree-pbeayfjp.js +0 -2
- package/dist/chunks/worktreeModeEnabled-ysks760x.js +0 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$3 as H6,R3 as I2,S3 as d6,T3 as V0,W3 as u3,Y3 as k2,b4 as cK}from"./cli-msw0vv86.js";import{D4 as vG,d4 as I6,e4 as uY,f4 as wY,g4 as yZ,h4 as Z9,k4 as q9,q4 as A3,s4 as C3,u4 as k3,v4 as v3}from"./cli-s6vr7213.js";import{J4 as Uq,N4 as W1,O4 as L8}from"./cli-fghyxar5.js";import{W4 as n6}from"./cli-1ny2386w.js";import{$4 as D,a5 as b1}from"./cli-fakdskp6.js";import{c5 as j0,d5 as G4,e5 as M3,f5 as P3,g5 as T2}from"./cli-mb1qrqw1.js";import{v5 as JZ,x5 as T8,z5 as L9}from"./cli-f63fdj4w.js";import{B5 as OX,C5 as $5}from"./cli-k4v08k8t.js";import{D5 as Z4,E5 as SZ}from"./cli-pgg33dhw.js";import{F5 as rX,H5 as oX,S5 as k5,U5 as PJ,Y5 as v5}from"./cli-w52yvzkn.js";import{u6 as n0,z6 as q6}from"./cli-51720d82.js";import{A7 as A4,O6 as Y1,Q6 as N8,c7 as E4,h7 as _q,n7 as E3}from"./cli-fdya77ch.js";import{B7 as pJ,D7 as UV}from"./cli-mzcsnm06.js";import{E7 as K1,F7 as m7,G7 as l4,H7 as p1,I7 as b2}from"./cli-p0vh69b9.js";import{L7 as S0,M7 as S4}from"./cli-rvad3yhg.js";import{A8 as y4,E8 as O,J8 as W0,x8 as J$,y8 as oJ,z8 as X9}from"./cli-4ewb3q42.js";import{W8 as m3,Y8 as F,Z8 as V1}from"./cli-t9jht3kb.js";import{f9 as jG,g9 as yG}from"./cli-350pymj4.js";import{h9 as o$,i9 as DB}from"./cli-rxb5q8zw.js";import{k9 as NQ,l9 as LW,o9 as i,p9 as B3,q9 as s,r9 as E$,s9 as v2}from"./cli-jj93qmmc.js";import{B9 as f,C9 as T0,u9 as i8,v9 as jZ,w9 as P0,y9 as l9,z9 as n9}from"./cli-kq16afrr.js";import{$9 as h$,K9 as _8,M9 as K7,R9 as k4,W9 as u1,X9 as o,Y9 as Y0,Z9 as U1,b_ as N0,d_ as A,e_ as a,f_ as f6,g_ as j9,h_ as X0,i_ as e0,l_ as x,p_ as $1,s_ as t2,v_ as L,x_ as X4,y_ as p}from"./cli-hke6r0q8.js";import{F_ as b,I_ as R,J_ as P4,K_ as C0,M_ as y2,P_ as vZ,R_ as $Z,S_ as j}from"./cli-tq5z9qv3.js";import{Eba as Oq,Gba as $$,Mba as mY,T_ as yY,Taa as u,U_ as SY,Uaa as I3,V_ as fY,Vba as C2,W_ as bY,Waa as T3,X_ as hY,Y_ as pY,Z_ as x2,__ as gY,_aa as _Q,b$ as u6,baa as EQ,bda as n,c$ as m0,d$ as a8,e$ as A0,g$ as x3,k$ as q1,l$ as T4,lba as b6,nba as h6,paa as gQ,rba as o9,sba as s9,taa as DZ,tba as a9,uba as t9,yaa as S2,zaa as p4}from"./cli-3ac555qw.js";import{cda as kG,eda as LV,fda as U,gda as r}from"./cli-w1d8n9g3.js";function W8($){let{buffer:J,bytesRead:Q}=x().readSync($,{length:4096});if(Q===0)return"utf8";if(Q>=2){if(J[0]===255&&J[1]===254)return"utf16le"}if(Q>=3&&J[0]===239&&J[1]===187&&J[2]===191)return"utf8";return"utf8"}function V8($){let J=0,Q=0;for(let X=0;X<$.length;X++)if($[X]===`
|
|
3
|
+
`)if(X>0&&$[X-1]==="\r")J++;else Q++;return J>Q?"CRLF":"LF"}function rY($){let J=x(),{resolvedPath:Q,isSymlink:X}=e0(J,$);if(X)L(`Reading through symlink: ${$} -> ${Q}`);let Z=W8(Q),q=J.readFileSync(Q,{encoding:Z}),Y=V8(q.slice(0,4096));return{content:q.replaceAll(`\r
|
|
4
|
+
`,`
|
|
5
|
+
`),encoding:Z,lineEndings:Y}}function v0($){return rY($).content}var F2=U(()=>{p();$1()});import{join as oY}from"path";function ZL($){z2=$}function qL(){z2=null,G8=void 0}function YL($){return G8=$,$}function aY(){return oY(b(),sY)}function tY(){try{let $=v0(aY()),J=a(I2($));if(!J||typeof J!=="object"||Array.isArray(J))return null;return J}catch{return null}}function I4(){if(G8!==!0)return null;if(z2)return z2;let $=tY();if($)return z2=$,x2(),$;return null}var sY="remote-settings.json",z2=null,G8;var c6=U(()=>{j();F2();d6();u6();X0()});function K8(){return process.env.USER_TYPE==="ant"?R(process.env.ENABLE_GROWTHBOOK_DEV)?"":"":""}var l6=U(()=>{j()});import eY from"lodash-es/memoize.js";import{homedir as $7}from"os";import{isAbsolute as J7,join as M4,normalize as B8,sep as i6}from"path";function DL(){let $=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(R($))return!1;if(P4($))return!0;if(R(process.env.CLAUDE_CODE_SIMPLE))return!1;if(R(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let J=_0();if(J.autoMemoryEnabled!==void 0)return J.autoMemoryEnabled;return!0}function Q7(){if(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR;return b()}function r6($,J){if(!$)return;let Q=$;if(J&&(Q.startsWith("~/")||Q.startsWith("~\\"))){let Z=Q.slice(2),q=B8(Z||".");if(q==="."||q==="..")return;Q=M4($7(),Z)}let X=B8(Q).replace(/[/\\]+$/,"");if(!J7(X)||X.length<3||/^[A-Za-z]:$/.test(X)||X.startsWith("\\\\")||X.startsWith("//")||X.includes("\x00"))return;return(X+i6).normalize("NFC")}function o6(){return r6(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function q7(){let $=S("policySettings")?.autoMemoryDirectory??S("flagSettings")?.autoMemoryDirectory??S("localSettings")?.autoMemoryDirectory??S("userSettings")?.autoMemoryDirectory;return r6($,!0)}function OL(){return o6()!==void 0}function Y7(){return E4(T4())??T4()}function a6(){return M4(s6(),Z7)}function FL($){return B8($).startsWith(s6())}var X7="memory",Z7="MEMORY.md",s6;var t6=U(()=>{n();Q1();j();A4();L8();J1();s6=eY(()=>{let $=o6()??q7();if($)return $;let J=M4(Q7(),"projects");return(M4(J,n6(Y7()),X7)+i6).normalize("NFC")},()=>T4())});import e6 from"lodash-es/memoize.js";import{join as W7}from"path";var X1,M2;var C4=U(()=>{T2();X1=e6(function(){if(process.env.USER_TYPE==="ant"&&process.env.CLAUDE_CODE_MANAGED_SETTINGS_PATH)return process.env.CLAUDE_CODE_MANAGED_SETTINGS_PATH;switch(j0()){case"macos":return"/Library/Application Support/ClaudeCode";case"windows":return"C:\\Program Files\\ClaudeCode";default:return"/etc/claude-code"}}),M2=e6(function(){return W7(X1(),"managed-settings.d")})});var V7,G7,PL;var $9=U(()=>{V7=["auto","iterm2","iterm2_with_bell","terminal_bell","kitty","ghostty","notifications_disabled"],G7=["normal","vim"],PL=["auto","tmux","in-process"]});import{randomBytes as U7}from"crypto";import{unwatchFile as H7,watchFile as w7}from"fs";import R7 from"lodash-es/memoize.js";import Y9 from"lodash-es/pickBy.js";import{basename as D8,dirname as O8,join as q0,resolve as E2}from"path";function y0(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:"dark",preferredNotifChannel:"auto",verbose:!1,editorMode:"normal",autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:"auto",customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:60000,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},cachedGrowthBookFeatures:{},respectGitignore:!0,copyFullResponse:!1}}function $U($){return _7.includes($)}function JU(){W9=!1}function t(){return W9||=D7()}function D7(){if(C2())return!0;let $=I(),J=I8();if($.projects?.[J]?.hasTrustDialogAccepted)return!0;let X=W1(S0());while(!0){if($.projects?.[X]?.hasTrustDialogAccepted)return!0;let q=W1(E2(X,".."));if(q===X)break;X=q}return!1}function QU($){let J=I(),Q=W1(E2($));while(!0){if(J.projects?.[Q]?.hasTrustDialogAccepted)return!0;let X=W1(E2(Q,".."));if(X===Q)return!1;Q=X}}function qU($){return N7.includes($)}function b4($){let J=I0.config;if(!J)return!1;let Q=J.oauthAccount!==void 0&&$.oauthAccount===void 0,X=J.hasCompletedOnboarding===!0&&$.hasCompletedOnboarding!==!0;return Q||X}function l($){let J=null;try{if(G9(i(),y0,(X)=>{let Z=$(X);if(Z===X)return X;return J={...Z,projects:J9(X.projects)},J})&&J)j4(J)}catch(Q){L(`Failed to save config with lock: ${Q}`,{level:"error"});let X=T1(i(),y0);if(b4(X)){L("saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.",{level:"error"}),F("tengu_config_auth_loss_prevented",{});return}let Z=$(X);if(Z===X)return;J={...Z,projects:J9(X.projects)},V9(i(),J,F8),j4(J)}}function YU(){return z8}function O7(){let $=P2+v4;if($>0)F("tengu_config_cache_stats",{cache_hits:P2,cache_misses:v4,hit_rate:P2/$});P2=0,v4=0}function w8($){if($.installMethod!==void 0)return $;let J=$,Q="unknown",X=$.autoUpdates??!0;switch(J.autoUpdaterStatus){case"migrated":Q="local";break;case"installed":Q="native";break;case"disabled":X=!1;break;case"enabled":case"no_permissions":case"not_configured":Q="global";break;case void 0:break}return{...$,installMethod:Q,autoUpdates:X}}function J9($){if(!$)return $;let J={},Q=!1;for(let[X,Z]of Object.entries($)){let q=Z;if(q.history!==void 0){Q=!0;let{history:Y,...W}=q;J[X]=W}else J[X]=Z}return Q?J:$}function z7(){if(H8)return;H8=!0;let $=i();w7($,{interval:F7,persistent:!1},(J)=>{if(J.mtimeMs<=I0.mtime)return;x().readFile($,{encoding:"utf-8"}).then((Q)=>{if(J.mtimeMs<=I0.mtime)return;let X=V0(I2(Q));if(X===null||typeof X!=="object")return;I0={config:w8({...y0(),...X}),mtime:J.mtimeMs},Z1={mtime:J.mtimeMs,size:J.size}}).catch(()=>{})}),_8(async()=>{H7($),H8=!1})}function j4($){I0={config:$,mtime:Date.now()},Z1=null}function I(){if(I0.config)return P2++,I0.config;v4++;try{let $=null;try{$=x().statSync(i())}catch{}let J=w8(T1(i(),y0));return I0={config:J,mtime:$?.mtimeMs??Date.now()},Z1=$?{mtime:$.mtimeMs,size:$.size}:null,z7(),J}catch{return w8(T1(i(),y0))}}function VU(){let $=I().remoteControlAtStartup;if($!==void 0)return $;return!1}function GU($){let J=I();if(J.customApiKeyResponses?.approved?.includes($))return"approved";if(J.customApiKeyResponses?.rejected?.includes($))return"rejected";return"new"}function V9($,J,Q){let X=O8($);x().mkdirSync(X);let q=Y9(J,(Y,W)=>A(Y)!==A(Q[W]));if(i1($,A(q,null,2),{encoding:"utf-8",mode:384}),$===i())z8++}function G9($,J,Q){let X=J(),Z=O8($),q=x();q.mkdirSync(Z);let Y;try{let W=`${$}.lock`,K=Date.now();Y=Z9($,{lockfilePath:W,onCompromised:(_)=>{L(`Config lock compromised: ${_}`,{level:"error"})}});let B=Date.now()-K;if(B>100)L("Lock acquisition took longer than expected - another Claude instance may be running"),F("tengu_config_lock_contention",{lock_time_ms:B});if(Z1&&$===i())try{let _=q.statSync($);if(_.mtimeMs!==Z1.mtime||_.size!==Z1.size)F("tengu_config_stale_write",{read_mtime:Z1.mtime,write_mtime:_.mtimeMs,read_size:Z1.size,write_size:_.size})}catch(_){if(Y0(_)!=="ENOENT")throw _}let w=T1($,J);if($===i()&&b4(w))return L("saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.claude.json. See GH #3117.",{level:"error"}),F("tengu_config_auth_loss_prevented",{}),!1;let H=Q(w);if(H===w)return!1;let z=Y9(H,(_,M)=>A(_)!==A(X[M]));try{let _=D8($),M=x8();try{q.mkdirSync(M)}catch(h){if(Y0(h)!=="EEXIST")throw h}let k=60000,F1=q.readdirStringSync(M).filter((h)=>h.startsWith(`${_}.backup.`)).sort().reverse(),z1=F1[0],O2=z1?Number(z1.split(".backup.").pop()):0,x1=Number.isNaN(O2)||Date.now()-O2>=k;if(x1){let h=q0(M,`${_}.backup.${Date.now()}`);q.copyFileSync($,h)}let q8=5,I1=x1?q.readdirStringSync(M).filter((h)=>h.startsWith(`${_}.backup.`)).sort().reverse():F1;for(let h of I1.slice(q8))try{q.unlinkSync(q0(M,h))}catch{}}catch(_){if(Y0(_)!=="ENOENT")L(`Failed to backup config: ${_}`,{level:"error"})}if(i1($,A(z,null,2),{encoding:"utf-8",mode:384}),$===i())z8++;return!0}finally{if(Y)Y()}}function KU(){if(R8)return;let $=Date.now();Y1("info","enable_configs_started"),R8=!0,T1(i(),y0,!0),Y1("info","enable_configs_completed",{duration_ms:Date.now()-$})}function x8(){return q0(b(),"backups")}function Q9($){let J=x(),Q=D8($),X=x8();try{let Y=J.readdirStringSync(X).filter((W)=>W.startsWith(`${Q}.backup.`)).sort().at(-1);if(Y)return q0(X,Y)}catch{}let Z=O8($);try{let Y=J.readdirStringSync(Z).filter((K)=>K.startsWith(`${Q}.backup.`)).sort().at(-1);if(Y)return q0(Z,Y);let W=`${$}.backup`;try{return J.statSync(W),W}catch{}}catch{}return null}function T1($,J,Q){if(!R8)throw Error("Config accessed before allowed.");let X=x();try{let Z=X.readFileSync($,{encoding:"utf-8"});try{let q=a(I2(Z));return{...J(),...q}}catch(q){let Y=q instanceof Error?q.message:String(q);throw new k4(Y,$,J())}}catch(Z){if(Y0(Z)==="ENOENT"){let Y=Q9($);if(Y)process.stderr.write(`
|
|
6
|
+
Claude configuration file not found at: ${$}
|
|
7
|
+
A backup file exists at: ${Y}
|
|
8
|
+
You can manually restore it by running: cp "${Y}" "${$}"
|
|
9
|
+
|
|
10
|
+
`);return J()}if(Z instanceof k4&&Q)throw Z;if(Z instanceof k4){if(L(`Config file corrupted, resetting to defaults: ${Z.message}`,{level:"error"}),!U8){U8=!0;try{O(Z);let _=!1;try{X.statSync(`${$}.backup`),_=!0}catch{}F("tengu_config_parse_error",{has_backup:_})}finally{U8=!1}}process.stderr.write(`
|
|
11
|
+
Claude configuration file at ${$} is corrupted: ${Z.message}
|
|
12
|
+
`);let Y=D8($),W=x8();try{X.mkdirSync(W)}catch(_){if(Y0(_)!=="EEXIST")throw _}let K=X.readdirStringSync(W).filter((_)=>_.startsWith(`${Y}.corrupted.`)),B,w=!1,H=X.readFileSync($,{encoding:"utf-8"});for(let _ of K)try{let M=X.readFileSync(q0(W,_),{encoding:"utf-8"});if(H===M){w=!0;break}}catch{}if(!w){B=q0(W,`${Y}.corrupted.${Date.now()}`);try{X.copyFileSync($,B),L(`Corrupted config backed up to: ${B}`,{level:"error"})}catch{}}let z=Q9($);if(B)process.stderr.write(`The corrupted file has been backed up to: ${B}
|
|
13
|
+
`);else if(w)process.stderr.write(`The corrupted file has already been backed up.
|
|
14
|
+
`);if(z)process.stderr.write(`A backup file exists at: ${z}
|
|
15
|
+
You can manually restore it by running: cp "${z}" "${$}"
|
|
16
|
+
|
|
17
|
+
`);else process.stderr.write(`
|
|
18
|
+
`)}return J()}}function x7($){let J=E4($);if(J)return W1(J);return W1(E2($))}function BU($){let J=I8($),Q=I();if(!Q.projects)return A2;let X=Q.projects[J]??A2;if(typeof X.allowedTools==="string")X.allowedTools=V0(X.allowedTools)??[];return X}function LU($,J){let Q=I8(J),X=null;try{if(G9(i(),y0,(q)=>{let Y=q.projects?.[Q]??A2,W=$(Y);if(W===Y)return q;return X={...q,projects:{...q.projects,[Q]:W}},X})&&X)j4(X)}catch(Z){L(`Failed to save config with lock: ${Z}`,{level:"error"});let q=T1(i(),y0);if(b4(q)){L("saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.",{level:"error"}),F("tengu_config_auth_loss_prevented",{});return}let Y=q.projects?.[Q]??A2,W=$(Y);if(W===Y)return;X={...q,projects:{...q.projects,[Q]:W}},V9(i(),X,F8),j4(X)}}function I7(){return T7()!==null}function UU(){return I7()&&!R(process.env.FORCE_AUTOUPDATE_PLUGINS)}function HU($){switch($.type){case"development":return"development build";case"env":return`${$.envVar} set`;case"config":return"config"}}function T7(){return{type:"development"}}function j2(){let $=I();if($.userID)return $.userID;let J=U7(32).toString("hex");return l((Q)=>({...Q,userID:J})),J}function wU(){if(!I().firstStartTime){let J=new Date().toISOString();l((Q)=>({...Q,firstStartTime:Q.firstStartTime??J}))}}function RU($){let J=q1();switch($){case"User":return q0(b(),"CLAUDE.md");case"Local":return q0(J,"CLAUDE.local.md");case"Project":return q0(J,"CLAUDE.md");case"Managed":return q0(X1(),"CLAUDE.md");case"AutoMem":return a6()}return""}function _U(){return q0(X1(),".claude","rules")}function NU(){return q0(b(),"rules")}function FU($){I0.config=$,I0.mtime=$?Date.now():0}var U8=!1,A2,F8,_7,N7,W9=!1,XU,ZU,I0,Z1=null,P2=0,v4=0,z8=0,WU=20,F7=1000,H8=!1,R8=!1,I8,DU,OU;var D0=U(()=>{n();t6();V1();S4();K7();p();N8();v2();j();N0();f4();$1();A4();k2();d6();q9();W0();L8();y4();C4();X0();$9();A2={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasClaudeMdExternalIncludesApproved:!1,hasClaudeMdExternalIncludesWarningShown:!1};F8=y0(),_7=["apiKeyHelper","installMethod","autoUpdates","autoUpdatesProtectedForNative","theme","verbose","preferredNotifChannel","shiftEnterKeyBindingInstalled","editorMode","hasUsedBackslashReturn","autoCompactEnabled","showTurnDuration","diffTool","env","tipsHistory","todoFeatureEnabled","showExpandedTodos","messageIdleNotifThresholdMs","autoConnectIde","autoInstallIdeExtension","fileCheckpointingEnabled","terminalProgressBarEnabled","showStatusInTerminalTab","taskCompleteNotifEnabled","inputNeededNotifEnabled","agentPushNotifEnabled","respectGitignore","claudeInChromeDefaultEnabled","hasCompletedClaudeInChromeOnboarding","lspRecommendationDisabled","lspRecommendationNeverPlugins","lspRecommendationIgnoredCount","copyFullResponse","copyOnSelect","permissionExplainerEnabled","prStatusFooterEnabled","remoteControlAtStartup","remoteDialogSeen"];N7=["allowedTools","hasTrustDialogAccepted","hasCompletedProjectOnboarding"];XU={...F8,autoUpdates:!1},ZU={...A2};I0={config:null,mtime:0};_8(async()=>{O7()});I8=R7(($)=>x7($??q1()),($)=>W1(E2($??q1())));DU=T1,OU=b4});function K9($){let J=[],Q=!1;async function X(){if(Q)return;if(J.length===0)return;Q=!0;while(J.length>0){let{args:Z,resolve:q,reject:Y,context:W}=J.shift();try{let K=await $.apply(W,Z);q(K)}catch(K){Y(K)}}if(Q=!1,J.length>0)X()}return function(...Z){return new Promise((q,Y)=>{J.push({args:Z,resolve:q,reject:Y,context:this}),X()})}}var B9=()=>{};import U9 from"lodash-es/memoize.js";function w9($,J){return $.find((Q)=>Q.includes(J))??null}async function R9(){let{BedrockClient:$}=await import("@aws-sdk/client-bedrock"),J=y2(),Q=R(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),X={region:J,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await T8(),...Q&&{requestHandler:new(await import("@smithy/node-http-handler")).NodeHttpHandler,httpAuthSchemes:[{schemeId:"smithy.api#noAuth",identityProvider:()=>async()=>({}),signer:new(await import("@smithy/core")).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:"smithy.api#noAuth"}]}};if(!Q&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let Z=await G1();if(Z)X.credentials={accessKeyId:Z.accessKeyId,secretAccessKey:Z.secretAccessKey,sessionToken:Z.sessionToken}}return new $(X)}async function CU(){let{BedrockRuntimeClient:$}=await import("@aws-sdk/client-bedrock-runtime"),J=y2(),Q=R(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),X={region:J,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await T8(),...Q&&{requestHandler:new(await import("@smithy/node-http-handler")).NodeHttpHandler,httpAuthSchemes:[{schemeId:"smithy.api#noAuth",identityProvider:()=>async()=>({}),signer:new(await import("@smithy/core")).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:"smithy.api#noAuth"}]}};if(!Q&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let Z=await G1();if(Z)X.credentials={accessKeyId:Z.accessKeyId,secretAccessKey:Z.secretAccessKey,sessionToken:Z.sessionToken}}return new $(X)}function M7($){return $.startsWith("anthropic.")}function E7($){if(!$.startsWith("arn:"))return $;let J=$.lastIndexOf("/");if(J===-1)return $;return $.substring(J+1)}function A7($){let J=E7($);for(let Q of P7)if(J.startsWith(`${Q}.anthropic.`))return Q;return}function vU($,J){let Q=A7($);if(Q)return $.replace(`${Q}.`,`${J}.`);if(M7($))return`${J}.${$}`;return $}var H9,kU,P7;var _9=U(()=>{e();j();W0();L9();H9=U9(async function(){let[$,{ListInferenceProfilesCommand:J}]=await Promise.all([R9(),import("@aws-sdk/client-bedrock")]),Q=[],X;try{do{let Z=new J({...X&&{nextToken:X},typeEquals:"SYSTEM_DEFINED"}),q=await $.send(Z);if(q.inferenceProfileSummaries)Q.push(...q.inferenceProfileSummaries);X=q.nextToken}while(X);return Q.filter((Z)=>Z.inferenceProfileId?.includes("anthropic")).map((Z)=>Z.inferenceProfileId).filter(Boolean)}catch(Z){throw O(Z),Z}});kU=U9(async function($){try{let[J,{GetInferenceProfileCommand:Q}]=await Promise.all([R9(),import("@aws-sdk/client-bedrock")]),X=new Q({inferenceProfileIdentifier:$}),Z=await J.send(X);if(!Z.models||Z.models.length===0)return null;let q=Z.models[0];if(!q?.modelArn)return null;let Y=q.modelArn.lastIndexOf("/");return Y>=0?q.modelArn.substring(Y+1):q.modelArn}catch(J){return O(J),null}});P7=["us","eu","apac","global"]});var M8,P8,E8,A8,C8,k8,v8,j8,y8,h4,S8,C7,k7,v7,r1,yU,N9;var f8=U(()=>{M8={firstParty:"claude-3-7-sonnet-20250219",bedrock:"us.anthropic.claude-3-7-sonnet-20250219-v1:0",vertex:"claude-3-7-sonnet@20250219",foundry:"claude-3-7-sonnet",azureOpenAI:"claude-3-7-sonnet-20250219"},P8={firstParty:"claude-3-5-sonnet-20241022",bedrock:"anthropic.claude-3-5-sonnet-20241022-v2:0",vertex:"claude-3-5-sonnet-v2@20241022",foundry:"claude-3-5-sonnet",azureOpenAI:"claude-3-5-sonnet-20241022"},E8={firstParty:"claude-3-5-haiku-20241022",bedrock:"us.anthropic.claude-3-5-haiku-20241022-v1:0",vertex:"claude-3-5-haiku@20241022",foundry:"claude-3-5-haiku",azureOpenAI:"claude-3-5-haiku-20241022"},A8={firstParty:"claude-haiku-4-5-20251001",bedrock:"us.anthropic.claude-haiku-4-5-20251001-v1:0",vertex:"claude-haiku-4-5@20251001",foundry:"claude-haiku-4-5",azureOpenAI:"claude-haiku-4-5-20251001"},C8={firstParty:"claude-sonnet-4-20250514",bedrock:"us.anthropic.claude-sonnet-4-20250514-v1:0",vertex:"claude-sonnet-4@20250514",foundry:"claude-sonnet-4",azureOpenAI:"claude-sonnet-4-20250514"},k8={firstParty:"claude-sonnet-4-5-20250929",bedrock:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",vertex:"claude-sonnet-4-5@20250929",foundry:"claude-sonnet-4-5",azureOpenAI:"claude-sonnet-4-5-20250929"},v8={firstParty:"claude-opus-4-20250514",bedrock:"us.anthropic.claude-opus-4-20250514-v1:0",vertex:"claude-opus-4@20250514",foundry:"claude-opus-4",azureOpenAI:"claude-opus-4-20250514"},j8={firstParty:"claude-opus-4-1-20250805",bedrock:"us.anthropic.claude-opus-4-1-20250805-v1:0",vertex:"claude-opus-4-1@20250805",foundry:"claude-opus-4-1",azureOpenAI:"claude-opus-4-1-20250805"},y8={firstParty:"claude-opus-4-5-20251101",bedrock:"us.anthropic.claude-opus-4-5-20251101-v1:0",vertex:"claude-opus-4-5@20251101",foundry:"claude-opus-4-5",azureOpenAI:"claude-opus-4-5-20251101"},h4={firstParty:"claude-opus-4-7",bedrock:"us.anthropic.claude-opus-4-7-v1",vertex:"claude-opus-4-7",foundry:"claude-opus-4-7",azureOpenAI:"claude-opus-4-7"},S8={firstParty:"claude-sonnet-4-6",bedrock:"us.anthropic.claude-sonnet-4-6",vertex:"claude-sonnet-4-6",foundry:"claude-sonnet-4-6",azureOpenAI:"claude-sonnet-4-6"},C7={firstParty:"gpt-5.2-codex",bedrock:"gpt-5.2-codex",vertex:"gpt-5.2-codex",foundry:"gpt-5.2-codex",azureOpenAI:"gpt-5.2-codex"},k7={firstParty:"gpt-5.3-codex",bedrock:"gpt-5.3-codex",vertex:"gpt-5.3-codex",foundry:"gpt-5.3-codex",azureOpenAI:"gpt-5.3-codex"},v7={firstParty:"gpt-5.4-codex",bedrock:"gpt-5.4-codex",vertex:"gpt-5.4-codex",foundry:"gpt-5.4-codex",azureOpenAI:"gpt-5.4-codex"},r1={haiku35:E8,haiku45:A8,sonnet35:P8,sonnet37:M8,sonnet40:C8,sonnet45:k8,sonnet46:S8,opus40:v8,opus41:j8,opus45:y8,opus46:h4,gpt52codex:C7,gpt53codex:k7,gpt54codex:v7},yU=Object.values(r1).map(($)=>$.firstParty),N9=Object.fromEntries(Object.entries(r1).map(([$,J])=>[J.firstParty,$]))});function P(){return R(process.env.CLAUDE_CODE_USE_BEDROCK)?"bedrock":R(process.env.CLAUDE_CODE_USE_VERTEX)?"vertex":R(process.env.CLAUDE_CODE_USE_FOUNDRY)?"foundry":R(process.env.CLAUDE_CODE_USE_AZURE_OPENAI)?"azureOpenAI":"firstParty"}function bU(){return P()}function f0(){let $=process.env.ANTHROPIC_BASE_URL;if(!$)return!0;try{let J=new URL($).host,Q=["api.anthropic.com"];if(process.env.USER_TYPE==="ant")Q.push("api-staging.anthropic.com");return Q.includes(J)}catch{return!1}}var b0=U(()=>{j()});function g4($){let J={};for(let Q of O9)J[Q]=r1[Q][$];return J}async function j7(){let $=g4("bedrock"),J;try{J=await H9()}catch(X){return O(X),$}if(!J?.length)return $;let Q={};for(let X of O9){let Z=r1[X].firstParty;Q[X]=w9(J,Z)||$[X]}return Q}function D9($){let J=_0().modelOverrides;if(!J)return $;let Q={...$};for(let[X,Z]of Object.entries(J)){let q=N9[X];if(q&&Z)Q[q]=Z}return Q}function m4($){let J;try{J=_0().modelOverrides}catch{return $}if(!J)return $;for(let[Q,X]of Object.entries(J))if(X===$)return Q;return $}function y7(){if(S2()!==null)return;if(P()!=="bedrock"){p4(g4(P()));return}F9()}function v(){let $=S2();if($===null)return y7(),D9(g4(P()));return D9($)}async function nU(){if(S2()!==null)return;if(P()!=="bedrock"){p4(g4(P()));return}await F9()}var O9,F9;var u4=U(()=>{n();W0();B9();J1();_9();f8();b0();O9=Object.keys(r1);F9=K9(async()=>{if(S2()!==null)return;try{let $=await j7();p4($)}catch($){O($)}})});function aU(){if(R(process.env.DISABLE_COST_WARNINGS))return!1;if(y())return!1;let J=M1(),Q=U0()!==null;if(!J.hasToken&&!Q)return!1;let X=I(),Z=X.oauthAccount?.organizationRole,q=X.oauthAccount?.workspaceRole;if(!Z||!q)return!1;return["admin","billing"].includes(Z)||["workspace_admin","workspace_billing"].includes(q)}function z9($){b8=$}function tU(){if(b8!==null)return b8;if(!y())return!1;let $=d();if($==="max"||$==="pro")return!0;let Q=I().oauthAccount?.organizationRole;return!!Q&&["admin","billing","owner","primary_owner"].includes(Q)}var b8=null;var x9=U(()=>{e();D0();j()});function JH(){if(process.env.USER_TYPE!=="ant")return null;if(process.env.CLAUDE_MOCK_HEADERLESS_429)return process.env.CLAUDE_MOCK_HEADERLESS_429;if(!s1)return null;return I9}function b7(){if(!s1||process.env.USER_TYPE!=="ant"||Object.keys(d4).length===0)return null;return d4}function h7(){d4={},f7=[],h8=null,c4=null,o1=null,I9=null,z9(null),s1=!1}function QH($){let J=b7();if(!J)return $;let Q=new globalThis.Headers($);return Object.entries(J).forEach(([X,Z])=>{if(Z!==void 0)Q.set(X,Z)}),Q}function XH(){if(process.env.USER_TYPE!=="ant")return!1;return s1||Boolean(process.env.CLAUDE_MOCK_HEADERLESS_429)}function T9(){if(!s1||process.env.USER_TYPE!=="ant")return null;return h8||S7}function M9(){return s1&&h8!==null&&process.env.USER_TYPE==="ant"}function ZH(){return c4!==null}function qH($){if(c4===null)return null;if(!$)return null;if(o1!==null&&Date.now()>=o1)return h7(),null;if(o1===null)o1=Date.now()+c4;let J=o1-Date.now(),Q={...d4};return Q["retry-after"]=String(Math.max(1,Math.ceil(J/1000))),Q}var d4,s1=!1,I9=null,h8=null,c4=null,o1=null,S7="max",f7;var P9=U(()=>{x9();d4={},f7=[]});function E9($,J){return{name:`${$.name}-with-${J.name}-fallback`,read(){let Q=$.read();if(Q!==null&&Q!==void 0)return Q;return J.read()||{}},async readAsync(){let Q=await $.readAsync();if(Q!==null&&Q!==void 0)return Q;return await J.readAsync()||{}},update(Q){let X=$.read(),Z=$.update(Q);if(Z.success){if(X===null)J.delete();return Z}let q=J.update(Q);if(q.success){if(X!==null)$.delete();return{success:!0,warning:q.warning}}return{success:!1}},delete(){let Q=$.delete(),X=J.delete();return Q||X}}}var A9=()=>{};import{createHash as p7}from"crypto";import{userInfo as g7}from"os";function G0($=""){let J=b(),X=!process.env.CLAUDE_CONFIG_DIR?"":`-${p7("sha256").update(J).digest("hex").substring(0,8)}`;return`Claude Code${f().OAUTH_FILE_SUFFIX}${$}${X}`}function h0(){try{return process.env.USER||g7().username}catch{return"claude-code-user"}}function p0(){g.cache={data:null,cachedAt:0},g.generation++,g.readInFlight=null}function C9($){if(g.cache.cachedAt!==0)return;let J=null;if($)try{J=JSON.parse($)}catch{return}g.cache={data:J,cachedAt:Date.now()}}var P1="-credentials",p8=30000,g;var f2=U(()=>{T0();j();g={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}});import{execaSync as g8}from"execa";async function d7(){try{let $=G0(P1),J=h0(),{stdout:Q,code:X}=await l4("security",["find-generic-password","-a",J,"-w","-s",$],{useCwd:!1,preserveOutputOnError:!1});if(X===0&&Q)return a(Q.trim())}catch($){}return null}function DH(){if(a1!==void 0)return a1;if(process.platform!=="darwin")return a1=!1,!1;try{a1=g8("security",["show-keychain-info"],{reject:!1,stdio:["ignore","pipe","pipe"]}).exitCode===36}catch{a1=!1}return a1}var u7=4032,k9,a1;var v9=U(()=>{p();b2();m7();X0();f2();k9={name:"keychain",read(){let $=g.cache;if(Date.now()-$.cachedAt<p8)return $.data;try{let J=G0(P1),Q=h0(),X=K1(`security find-generic-password -a "${Q}" -w -s "${J}"`);if(X){let Z=a(X);return g.cache={data:Z,cachedAt:Date.now()},Z}}catch(J){}if($.data!==null)return L("[keychain] read failed; serving stale cache",{level:"warn"}),g.cache={data:$.data,cachedAt:Date.now()},$.data;return g.cache={data:null,cachedAt:Date.now()},null},async readAsync(){let $=g.cache;if(Date.now()-$.cachedAt<p8)return $.data;if(g.readInFlight)return g.readInFlight;let J=g.generation,Q=d7().then((X)=>{if(J===g.generation){if(X===null&&$.data!==null)L("[keychain] readAsync failed; serving stale cache",{level:"warn"});let Z=X??$.data;return g.cache={data:Z,cachedAt:Date.now()},g.readInFlight=null,Z}return X});return g.readInFlight=Q,Q},update($){p0();try{let J=G0(P1),Q=h0(),X=A($),Z=Buffer.from(X,"utf-8").toString("hex"),q=`add-generic-password -U -a "${Q}" -s "${J}" -X "${Z}"
|
|
19
|
+
`,Y;if(q.length<=u7)Y=g8("security",["-i"],{input:q,stdio:["pipe","pipe","pipe"],reject:!1});else L(`Keychain payload (${X.length}B JSON) exceeds security -i stdin limit; using argv`,{level:"warn"}),Y=g8("security",["add-generic-password","-U","-a",Q,"-s",J,"-X",Z],{stdio:["ignore","pipe","pipe"],reject:!1});if(Y.exitCode!==0)return{success:!1};return g.cache={data:$,cachedAt:Date.now()},{success:!0}}catch(J){return{success:!1}}},delete(){p0();try{let $=G0(P1),J=h0();return K1(`security delete-generic-password -a "${J}" -s "${$}"`),!0}catch($){return!1}}}});import{chmodSync as c7}from"fs";import{join as l7}from"path";function n4(){let $=b(),J=".credentials.json";return{storageDir:$,storagePath:l7($,".credentials.json")}}var m8;var y9=U(()=>{j();N0();$1();X0();m8={name:"plaintext",read(){let{storagePath:$}=n4();try{let J=x().readFileSync($,{encoding:"utf8"});return a(J)}catch{return null}},async readAsync(){let{storagePath:$}=n4();try{let J=await x().readFile($,{encoding:"utf8"});return a(J)}catch{return null}},update($){try{let{storageDir:J,storagePath:Q}=n4();try{x().mkdirSync(J)}catch(X){if(Y0(X)!=="EEXIST")throw X}return j9(Q,A($),{encoding:"utf8",flush:!1}),c7(Q,384),{success:!0,warning:"Warning: Storing credentials in plaintext."}}catch{return{success:!1}}},delete(){let{storagePath:$}=n4();try{return x().unlinkSync($),!0}catch(J){if(Y0(J)==="ENOENT")return!0;return!1}}}});function M0(){if(process.platform==="darwin")return E9(k9,m8);return m8}var u8=U(()=>{A9();v9();y9()});import*as c from"fs";import*as S9 from"os";import*as t1 from"path";import n7 from"lodash-es/memoize.js";function e1(){let $=process.env[i7]?.trim();return $?$:null}function b9(){let $=process.env.CLAUDE_CONFIG_DIR||t1.join(S9.homedir(),".claude");return t1.join($,"cc-haha")}function c8(){return t1.join(b9(),o7)}function h9(){try{c.mkdirSync(b9(),{recursive:!0}),c.writeFileSync(c8(),`1
|
|
20
|
+
`,{mode:384})}catch($){O($)}}function s7(){try{c.rmSync(c8(),{force:!0})}catch($){if($.code!=="ENOENT")O($)}}function p9(){return c.existsSync(c8())}function g9($){if(!$||typeof $!=="object"||Array.isArray($))return null;let J=$;if(typeof J.accessToken!=="string"||typeof J.refreshToken!=="string"||typeof J.expiresAt!=="number")return null;return{accessToken:J.accessToken,refreshToken:J.refreshToken,expiresAt:J.expiresAt,...typeof J.idToken==="string"&&{idToken:J.idToken},...typeof J.accountId==="string"&&{accountId:J.accountId},...typeof J.email==="string"&&{email:J.email},...typeof J.clientId==="string"&&{clientId:J.clientId}}}function a7($=e1()){if(!$)return null;try{return g9(JSON.parse(c.readFileSync($,"utf-8")))}catch(J){if(J.code!=="ENOENT")O(J);return null}}async function t7($=e1()){if(!$)return null;try{let J=await c.promises.readFile($,"utf-8");return g9(JSON.parse(J))}catch(J){if(J.code!=="ENOENT")O(J);return null}}function e7($){let J=e1();if(!J)return!1;c.mkdirSync(t1.dirname(J),{recursive:!0});let Q=`${J}.tmp.${process.pid}.${Date.now()}`,X=!1;try{return c.writeFileSync(Q,JSON.stringify($,null,2)+`
|
|
21
|
+
`,{mode:384}),c.renameSync(Q,J),X=!0,!0}finally{if(!X)try{c.rmSync(Q,{force:!0})}catch(Z){if(Z.code!=="ENOENT")O(Z)}}}function i4($){try{if(e7($))return h9(),B1(),{success:!0};let J=M0(),Q=J.read()??{};Q[f9]=$;let X=J.update(Q);if(X.success)s7();return B1(),X}catch(J){return O(J),{success:!1,warning:`Failed to save OpenAI OAuth tokens: ${o(J)}`}}}function h2(){let $=e1();return m9($?`${d8}${$}`:r7)}async function l8(){let $=e1();if($)return t7($);if(p9())return null;try{return(await M0().readAsync())?.openaiCodexOauth??null}catch(J){return O(J),null}}function B1(){m9.cache?.clear?.()}function u9(){try{let $=e1();if($)return c.rmSync($,{force:!0}),h9(),B1(),!0;let J=M0(),Q=J.read()??{};delete Q[f9];let X=J.update(Q);return B1(),X.success}catch($){return O($),!1}}var f9="openaiCodexOauth",i7="OPENAI_CODEX_OAUTH_FILE",r7="secure-storage",d8="file:",o7="openai-oauth-file-backed",m9;var r4=U(()=>{u8();N0();W0();m9=n7(($)=>{if($.startsWith(d8))return a7($.slice(d8.length));if(p9())return null;try{return M0().read()?.openaiCodexOauth??null}catch(J){return O(J),null}})});import d9 from"axios";async function uH(){let J=I().oauthAccount?.accountUuid,Q=U0();if(!J||!Q)return;let X=`${f().BASE_API_URL}/api/claude_cli_profile`;try{return(await d9.get(X,{headers:{"x-api-key":Q,"anthropic-beta":P0},params:{account_uuid:J},timeout:1e4})).data}catch(Z){O(Z)}}async function $2($){let J=`${f().BASE_API_URL}/api/oauth/profile`;try{return(await d9.get(J,{headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"},timeout:1e4})).data}catch(Q){O(Q)}}var n8=U(()=>{T0();e();D0();W0()});import p2 from"axios";function L1($){return Boolean($?.includes(i8))}function $W($){return $?.split(" ").filter(Boolean)??[]}function aH({codeChallenge:$,state:J,port:Q,isManual:X,loginWithClaudeAi:Z,inferenceOnly:q,orgUUID:Y,loginHint:W,loginMethod:K}){let B=Z?f().CLAUDE_AI_AUTHORIZE_URL:f().CONSOLE_AUTHORIZE_URL,w=new URL(B);w.searchParams.append("code","true"),w.searchParams.append("client_id",f().CLIENT_ID),w.searchParams.append("response_type","code"),w.searchParams.append("redirect_uri",X?f().MANUAL_REDIRECT_URL:`http://localhost:${Q}/callback`);let H=q?[i8]:n9;if(w.searchParams.append("scope",H.join(" ")),w.searchParams.append("code_challenge",$),w.searchParams.append("code_challenge_method","S256"),w.searchParams.append("state",J),Y)w.searchParams.append("orgUUID",Y);if(W)w.searchParams.append("login_hint",W);if(K)w.searchParams.append("login_method",K);return w.toString()}async function tH($,J,Q,X,Z=!1,q){let Y={grant_type:"authorization_code",code:$,redirect_uri:Z?f().MANUAL_REDIRECT_URL:`http://localhost:${X}/callback`,client_id:f().CLIENT_ID,code_verifier:Q,state:J};if(q!==void 0)Y.expires_in=q;let W=await p2.post(f().TOKEN_URL,Y,{headers:{"Content-Type":"application/json"},timeout:15000});if(W.status!==200)throw Error(W.status===401?"Authentication failed: Invalid authorization code":`Token exchange failed (${W.status}): ${W.statusText}`);return F("tengu_oauth_token_exchange_success",{}),W.data}async function i9($,{scopes:J}={}){let Q={grant_type:"refresh_token",refresh_token:$,client_id:f().CLIENT_ID,scope:((J?.length)?J:l9).join(" ")};try{let X=await p2.post(f().TOKEN_URL,Q,{headers:{"Content-Type":"application/json"},timeout:15000});if(X.status!==200)throw Error(`Token refresh failed: ${X.statusText}`);let Z=X.data,{access_token:q,refresh_token:Y=$,expires_in:W}=Z,K=Date.now()+W*1000,B=$W(Z.scope);F("tengu_oauth_token_refresh_success",{});let w=I(),H=C(),_=w.oauthAccount?.billingType!==void 0&&w.oauthAccount?.accountCreatedAt!==void 0&&w.oauthAccount?.subscriptionCreatedAt!==void 0&&H?.subscriptionType!=null&&H?.rateLimitTier!=null?null:await JW(q);if(_&&w.oauthAccount){let M={};if(_.displayName!==void 0)M.displayName=_.displayName;if(typeof _.hasExtraUsageEnabled==="boolean")M.hasExtraUsageEnabled=_.hasExtraUsageEnabled;if(_.billingType!==null)M.billingType=_.billingType;if(_.accountCreatedAt!==void 0)M.accountCreatedAt=_.accountCreatedAt;if(_.subscriptionCreatedAt!==void 0)M.subscriptionCreatedAt=_.subscriptionCreatedAt;if(Object.keys(M).length>0)l((k)=>({...k,oauthAccount:k.oauthAccount?{...k.oauthAccount,...M}:k.oauthAccount}))}return{accessToken:q,refreshToken:Y,expiresAt:K,scopes:B,subscriptionType:_?.subscriptionType??H?.subscriptionType??null,rateLimitTier:_?.rateLimitTier??H?.rateLimitTier??null,profile:_?.rawProfile,tokenAccount:Z.account?{uuid:Z.account.uuid,emailAddress:Z.account.email_address,organizationUuid:Z.organization?.uuid}:void 0}}catch(X){let Z=p2.isAxiosError(X)&&X.response?.data?JSON.stringify(X.response.data):void 0;throw F("tengu_oauth_token_refresh_failure",{error:X.message,...Z&&{responseBody:Z}}),X}}async function eH($){let J=await p2.get(f().ROLES_URL,{headers:{Authorization:`Bearer ${$}`}});if(J.status!==200)throw Error(`Failed to fetch user roles: ${J.statusText}`);let Q=J.data;if(!I().oauthAccount)throw Error("OAuth account information not found in config");l((Z)=>({...Z,oauthAccount:Z.oauthAccount?{...Z.oauthAccount,organizationRole:Q.organization_role,workspaceRole:Q.workspace_role,organizationName:Q.organization_name}:Z.oauthAccount})),F("tengu_oauth_roles_stored",{org_role:Q.organization_role})}async function $w($){try{let J=await p2.post(f().API_KEY_URL,null,{headers:{Authorization:`Bearer ${$}`}}),Q=J.data?.raw_key;if(Q)return await r8(Q),F("tengu_oauth_api_key",{status:"success",statusCode:J.status}),Q;return null}catch(J){throw F("tengu_oauth_api_key",{status:"failure",error:J instanceof Error?J.message:String(J)}),J}}function E1($){if($===null)return!1;let J=300000;return Date.now()+J>=$}async function JW($){let J=await $2($),Q=J?.organization?.organization_type,X=null;switch(Q){case"claude_max":X="max";break;case"claude_pro":X="pro";break;case"claude_enterprise":X="enterprise";break;case"claude_team":X="team";break;default:X=null;break}let Z={subscriptionType:X,rateLimitTier:J?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:J?.organization?.has_extra_usage_enabled??null,billingType:J?.organization?.billing_type??null};if(J?.account?.display_name)Z.displayName=J.account.display_name;if(J?.account?.created_at)Z.accountCreatedAt=J.account.created_at;if(J?.organization?.subscription_created_at)Z.subscriptionCreatedAt=J.organization.subscription_created_at;return F("tengu_oauth_profile_fetch_success",{}),{...Z,rawProfile:J}}async function Jw(){let J=I().oauthAccount?.organizationUuid;if(J)return J;let Q=C()?.accessToken;if(Q===void 0||!g0())return null;let Z=(await $2(Q))?.organization?.uuid;if(!Z)return null;return Z}async function Qw(){let $=process.env.CLAUDE_CODE_ACCOUNT_UUID,J=process.env.CLAUDE_CODE_USER_EMAIL,Q=process.env.CLAUDE_CODE_ORGANIZATION_UUID,X=Boolean($&&J&&Q);if($&&J&&Q){if(!I().oauthAccount)c9({accountUuid:$,emailAddress:J,organizationUuid:Q})}await A1();let Z=I();if(Z.oauthAccount&&Z.oauthAccount.billingType!==void 0&&Z.oauthAccount.accountCreatedAt!==void 0&&Z.oauthAccount.subscriptionCreatedAt!==void 0||!y()||!g0())return!1;let q=C();if(q?.accessToken){let Y=await $2(q.accessToken);if(Y){if(X)L("OAuth profile fetch succeeded, overriding env var account info",{level:"info"});return c9({accountUuid:Y.account.uuid,emailAddress:Y.account.email,organizationUuid:Y.organization.uuid,displayName:Y.account.display_name||void 0,hasExtraUsageEnabled:Y.organization.has_extra_usage_enabled??!1,billingType:Y.organization.billing_type??void 0,accountCreatedAt:Y.account.created_at,subscriptionCreatedAt:Y.organization.subscription_created_at??void 0}),!0}}return!1}function c9({accountUuid:$,emailAddress:J,organizationUuid:Q,displayName:X,hasExtraUsageEnabled:Z,billingType:q,accountCreatedAt:Y,subscriptionCreatedAt:W}){let K={accountUuid:$,emailAddress:J,organizationUuid:Q,hasExtraUsageEnabled:Z,billingType:q,accountCreatedAt:Y,subscriptionCreatedAt:W};if(X)K.displayName=X;l((B)=>{if(B.oauthAccount?.accountUuid===K.accountUuid&&B.oauthAccount?.emailAddress===K.emailAddress&&B.oauthAccount?.organizationUuid===K.organizationUuid&&B.oauthAccount?.displayName===K.displayName&&B.oauthAccount?.hasExtraUsageEnabled===K.hasExtraUsageEnabled&&B.oauthAccount?.billingType===K.billingType&&B.oauthAccount?.accountCreatedAt===K.accountCreatedAt&&B.oauthAccount?.subscriptionCreatedAt===K.subscriptionCreatedAt)return B;return{...B,oauthAccount:K}})}var o4=U(()=>{V1();T0();e();D0();p();n8()});import{mkdirSync as QW,writeFileSync as XW}from"fs";function YW($,J,Q){if(!R(process.env.CLAUDE_CODE_REMOTE))return;try{QW(s4,{recursive:!0,mode:448}),XW($,J,{encoding:"utf8",mode:384}),L(`Persisted ${Q} to ${$} for subprocess access`)}catch(X){L(`Failed to persist ${Q} to disk (non-fatal): ${o(X)}`,{level:"error"})}}function r9($,J){try{let X=x().readFileSync($,{encoding:"utf8"}).trim();if(!X)return null;return L(`Read ${J} from well-known file ${$}`),X}catch(Q){if(!U1(Q))L(`Failed to read ${J} from ${$}: ${o(Q)}`,{level:"debug"});return null}}function e9({envVar:$,wellKnownPath:J,label:Q,getCached:X,setCached:Z}){let q=X();if(q!==void 0)return q;let Y=process.env[$];if(!Y){let K=r9(J,Q);return Z(K),K}let W=parseInt(Y,10);if(Number.isNaN(W))return L(`${$} must be a valid file descriptor number, got: ${Y}`,{level:"error"}),Z(null),null;try{let K=x(),B=process.platform==="darwin"||process.platform==="freebsd"?`/dev/fd/${W}`:`/proc/self/fd/${W}`,w=K.readFileSync(B,{encoding:"utf8"}).trim();if(!w)return L(`File descriptor contained empty ${Q}`,{level:"error"}),Z(null),null;return L(`Successfully read ${Q} from file descriptor ${W}`),Z(w),YW(J,w,Q),w}catch(K){L(`Failed to read ${Q} from file descriptor ${W}: ${o(K)}`,{level:"error"});let B=r9(J,Q);return Z(B),B}}function a4(){return e9({envVar:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",wellKnownPath:ZW,label:"OAuth token",getCached:o9,setCached:s9})}function o8(){return e9({envVar:"CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR",wellKnownPath:qW,label:"API key",getCached:a9,setCached:t9})}var s4="/home/claude/.claude/remote",ZW,qW,Kw;var $Q=U(()=>{n();p();j();N0();$1();ZW=`${s4}/.oauth_token`,qW=`${s4}/.api_key`,Kw=`${s4}/.session_ingress_token`});import{execa as WW}from"execa";async function JQ(){if(process.platform==="darwin"){let $=G0();if((await WW(`security delete-generic-password -a $USER -s "${$}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error("Failed to delete keychain entry")}}function t4($){return $.slice(-20)}var QQ=U(()=>{f2()});function Rw($){return $?.name==="CredentialsProviderError"}function XQ($){if(!$||typeof $!=="object")return!1;let J=$;if(!J.Credentials||typeof J.Credentials!=="object")return!1;let Q=J.Credentials;return typeof Q.AccessKeyId==="string"&&typeof Q.SecretAccessKey==="string"&&typeof Q.SessionToken==="string"&&Q.AccessKeyId.length>0&&Q.SecretAccessKey.length>0&&Q.SessionToken.length>0}async function s8(){let{STSClient:$,GetCallerIdentityCommand:J}=await import("@aws-sdk/client-sts");await new $().send(new J({}))}async function ZQ(){try{L("Clearing AWS credential provider cache");let{fromIni:$}=await import("@aws-sdk/credential-providers");await $({ignoreCache:!0})(),L("AWS credential provider cache refreshed")}catch($){L("Failed to clear AWS credential cache (this is expected if no credentials are configured)")}}var qQ=U(()=>{p()});class O0{static instance=null;status={isAuthenticating:!1,output:[]};changed=m0();static getInstance(){if(!O0.instance)O0.instance=new O0;return O0.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput($){this.status.output.push($),this.changed.emit(this.getStatus())}setError($){this.status.error=$,this.changed.emit(this.getStatus())}endAuthentication($){if($)this.status={isAuthenticating:!1,output:[]};else this.status.isAuthenticating=!1;this.changed.emit(this.getStatus())}subscribe=this.changed.subscribe;static reset(){if(O0.instance)O0.instance.changed.clear(),O0.instance=null}}var YQ=U(()=>{a8()});var e4="claude-code-20250219",WQ="interleaved-thinking-2025-05-14",g2="context-1m-2025-08-07",VQ="context-management-2025-06-27",GQ="structured-outputs-2025-12-15",t8="web-search-2025-03-05",KQ="advanced-tool-use-2025-11-20",BQ="tool-search-tool-2025-10-19",Ow="effort-2025-11-24",Fw="task-budgets-2026-03-13",LQ="prompt-caching-scope-2026-01-05",zw="fast-mode-2026-02-01",UQ="redact-thinking-2026-02-12",HQ="token-efficient-tools-2026-03-28",e8="",xw="",J2,Iw="advisor-tool-2026-03-01",$J,Tw;var JJ=U(()=>{J2=process.env.USER_TYPE==="ant"?"cli-internal-2026-02-09":"",$J=new Set(["interleaved-thinking-2025-05-14","context-1m-2025-08-07","tool-search-tool-2025-10-19"]),Tw=new Set(["claude-code-20250219","interleaved-thinking-2025-05-14","context-management-2025-06-27"])});function QJ($){let J=$.trim().toLowerCase();return J.startsWith("gpt-")||/^o\d/.test(J)}function C1($){if(process.env.OPENAI_CODEX_MODEL?.trim())return process.env.OPENAI_CODEX_MODEL.trim();let J=$.trim().toLowerCase();if(QJ(J))return $;if(J.includes("haiku"))return process.env.OPENAI_CODEX_HAIKU_MODEL?.trim()||"gpt-5.4-mini";if(J.includes("sonnet"))return process.env.OPENAI_CODEX_SONNET_MODEL?.trim()||"gpt-5.4";if(J.includes("opus"))return process.env.OPENAI_CODEX_OPUS_MODEL?.trim()||"gpt-5.3-codex";return"gpt-5.3-codex"}function XJ($){switch($.trim().toLowerCase()){case"gpt-5.3-codex":return"GPT-5.3 Codex";case"gpt-5.3-codex-spark":return"GPT-5.3 Codex Spark";case"gpt-5.5":return"GPT-5.5";case"gpt-5.4":return"GPT-5.4";case"gpt-5.4-mini":return"GPT-5.4 Mini";case"gpt-5.2":return"GPT-5.2";case"gpt-5.2-codex":return"GPT-5.2 Codex";case"gpt-5.1-codex":return"GPT-5.1 Codex";case"gpt-5.1-codex-max":return"GPT-5.1 Codex Max";case"gpt-5.1-codex-mini":return"GPT-5.1 Codex Mini";default:return null}}function wQ($){let J=$.trim().toLowerCase();if(J==="gpt-5.4"||J==="gpt-5.4-pro")return KW;if(J==="gpt-5.3-codex-spark")return BW;if(J==="gpt-5.5"||J==="gpt-5.5-pro"||J==="gpt-5.4-mini"||J==="gpt-5.4-nano"||J==="gpt-5.3-codex"||J==="gpt-5.2"||J==="gpt-5.2-codex"||J==="gpt-5.1"||J==="gpt-5.1-codex"||J==="gpt-5.1-codex-max"||J==="gpt-5.1-codex-mini"||J==="gpt-5-codex"||J==="gpt-5"||J==="gpt-5-mini"||J==="gpt-5-nano")return GW;return null}var Pw="gpt-5.3-codex",Ew="gpt-5.4",Aw="gpt-5.4-mini",GW,KW,BW,Cw;var m2=U(()=>{GW=Math.floor(258400),KW=Math.floor(950000),BW=Math.floor(121600),Cw=[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex",description:"Best for coding and agentic work",descriptionForModel:"GPT-5.3 Codex - best for coding and agentic work"},{value:"gpt-5.4",label:"GPT-5.4",description:"Strong general-purpose model",descriptionForModel:"GPT-5.4 - strong general-purpose model"},{value:"gpt-5.5",label:"GPT-5.5",description:"Latest general-purpose model",descriptionForModel:"GPT-5.5 - latest general-purpose model"},{value:"gpt-5.4-mini",label:"GPT-5.4 Mini",description:"Fastest for quick tasks",descriptionForModel:"GPT-5.4 Mini - fastest for quick tasks"}]});import ZJ from"axios";function F0(){return!R(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function DQ(){if(!F0())return!1;return HW()===null}function UW($,J){switch($){case"free":return J==="oauth"?"Fast mode requires a paid subscription":"Fast mode unavailable during evaluation. Please purchase credits.";case"preference":return"Fast mode has been disabled by your organization";case"extra_usage_disabled":return"Fast mode requires extra usage billing \xB7 /extra-usage to enable";case"network_error":return"Fast mode unavailable due to network connectivity issues";case"unknown":return"Fast mode is currently unavailable"}}function HW(){if(!F0())return"Fast mode is not available";let $=Z0("tengu_penguins_off",null);if($!==null)return L(`Fast mode unavailable: ${$}`),$;if(!NQ()&&Z0("tengu_marble_sandcastle",!1))return"Fast mode requires the native binary \xB7 Install from: https://claude.com/product/claude-code";if(u()&&$$()&&!_Q()){if(!S("flagSettings")?.fastMode)return L("Fast mode unavailable: Fast mode is not available in the Agent SDK"),"Fast mode is not available in the Agent SDK"}if(P()!=="firstParty")return L("Fast mode unavailable: Fast mode is not available on Bedrock, Vertex, or Foundry"),"Fast mode is not available on Bedrock, Vertex, or Foundry";if($0.status==="disabled"){if($0.reason==="network_error"||$0.reason==="unknown"){if(R(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS))return null}let J=C()!==null?"oauth":"api-key",Q=UW($0.reason,J);return L(`Fast mode unavailable: ${Q}`),Q}return null}function rw(){return"opus"+(d2()?"[1m]":"")}function ow($){if(!F0())return!1;if(!DQ())return!1;if(!OQ($))return!1;let J=_0();if(J.fastModePerSessionOptIn)return!1;return J.fastMode===!0}function OQ($){if(!F0())return!1;let J=$??k1();return K0(J).toLowerCase().includes("opus-4-6")}function wW(){if(Q2.status==="cooldown"&&Date.now()>=Q2.resetAt){if(F0()&&!qJ)L("Fast mode cooldown expired, re-enabling fast mode"),qJ=!0,zQ.emit();Q2={status:"active"}}return Q2}function tw($,J){if(!F0())return;Q2={status:"cooldown",resetAt:$,reason:J},qJ=!1;let Q=$-Date.now();L(`Fast mode cooldown triggered (${J}), duration ${Math.round(Q/1000)}s`),F("tengu_fast_mode_fallback_triggered",{cooldown_duration_ms:Q,cooldown_reason:J}),FQ.emit($,J)}function ew(){Q2={status:"active"}}function $R(){if($0.status==="disabled")return;$0={status:"disabled",reason:"preference"},Q$("userSettings",{fastMode:void 0}),l(($)=>({...$,penguinModeOrgEnabled:!1})),YJ.emit(!1)}function RW($){switch($){case"out_of_credits":return"Fast mode disabled \xB7 extra usage credits exhausted";case"org_level_disabled":case"org_service_level_disabled":return"Fast mode disabled \xB7 extra usage disabled by your organization";case"org_level_disabled_until":return"Fast mode disabled \xB7 extra usage spending cap reached";case"member_level_disabled":return"Fast mode disabled \xB7 extra usage disabled for your account";case"seat_tier_level_disabled":case"seat_tier_zero_credit_limit":case"member_zero_credit_limit":return"Fast mode disabled \xB7 extra usage not available for your plan";case"overage_not_provisioned":case"no_limits_configured":return"Fast mode requires extra usage billing \xB7 /extra-usage to enable";default:return"Fast mode disabled \xB7 extra usage not available"}}function _W($){return $==="org_level_disabled_until"||$==="out_of_credits"}function QR($){let J=RW($);if(L(`Fast mode overage rejection: ${$??"unknown"} \u2014 ${J}`),F("tengu_fast_mode_overage_rejected",{overage_disabled_reason:$??"unknown"}),!_W($))Q$("userSettings",{fastMode:void 0}),l((Q)=>({...Q,penguinModeOrgEnabled:!1}));xQ.emit(J)}function NW(){return wW().status==="cooldown"}function XR($,J){let Q=F0()&&DQ()&&!!J&&OQ($);if(Q&&NW())return"cooldown";if(Q)return"on";return"off"}async function DW($){let J=`${f().BASE_API_URL}/api/claude_code_penguin_mode`,Q="accessToken"in $?{Authorization:`Bearer ${$.accessToken}`,"anthropic-beta":P0}:{"x-api-key":$.apiKey};return(await ZJ.get(J,{headers:Q})).data}function qR(){if(!F0())return;if($0.status!=="pending")return;let $=process.env.USER_TYPE==="ant",J=I().penguinModeOrgEnabled===!0;$0=$||J?{status:"enabled"}:{status:"disabled",reason:"unknown"}}async function YR(){if(J$())return;if(!F0())return;if(u2)return L("Fast mode prefetch in progress, returning in-flight promise"),u2;let $=U0();if(!(C()?.accessToken&&g0())&&!$){let q=process.env.USER_TYPE==="ant",Y=I().penguinModeOrgEnabled===!0;$0=q||Y?{status:"enabled"}:{status:"disabled",reason:"preference"};return}let Q=Date.now();if(Q-RQ<OW){L("Skipping fast mode prefetch, fetched recently");return}RQ=Q;let X=async()=>{let q=C(),Y=q?.accessToken&&g0()?{accessToken:q.accessToken}:$?{apiKey:$}:null;if(!Y)throw Error("No auth available");return DW(Y)};async function Z(){try{let q;try{q=await X()}catch(W){if(ZJ.isAxiosError(W)&&(W.response?.status===401||W.response?.status===403&&typeof W.response?.data==="string"&&W.response.data.includes("OAuth token has been revoked"))){let B=C()?.accessToken;if(B)await c2(B),q=await X();else throw W}else throw W}let Y=$0.status!=="pending"?$0.status==="enabled":I().penguinModeOrgEnabled;if($0=q.enabled?{status:"enabled"}:{status:"disabled",reason:q.disabled_reason??"preference"},Y!==q.enabled){if(!q.enabled)Q$("userSettings",{fastMode:void 0});l((W)=>({...W,penguinModeOrgEnabled:q.enabled})),YJ.emit(q.enabled)}L(`Org fast mode: ${q.enabled?"enabled":`disabled (${q.disabled_reason??"preference"})`}`)}catch(q){let Y=process.env.USER_TYPE==="ant",W=I().penguinModeOrgEnabled===!0;$0=Y||W?{status:"enabled"}:{status:"disabled",reason:"network_error"},L(`Failed to fetch org fast mode status, defaulting to ${$0.status==="enabled"?"enabled (cached)":"disabled (network_error)"}: ${q}`,{level:"error"}),F("tengu_org_penguin_mode_fetch_failed",{})}finally{u2=null}}return u2=Z(),u2}var iw="Opus 4.7",Q2,qJ=!1,FQ,zQ,sw,aw,xQ,JR,$0,YJ,ZR,OW=30000,RQ=0,u2=null;var IQ=U(()=>{T0();Q1();n();V1();e();LW();D0();p();j();u0();b0();y4();J1();a8();Q2={status:"active"},FQ=m0(),zQ=m0(),sw=FQ.subscribe,aw=zQ.subscribe;xQ=m0(),JR=xQ.subscribe;$0={status:"pending"},YJ=m0(),ZR=YJ.subscribe});function WJ($){if(F0()&&$)return FW;return X$}function TW($,J){return J.input_tokens/1e6*$.inputTokens+J.output_tokens/1e6*$.outputTokens+(J.cache_read_input_tokens??0)/1e6*$.promptCacheReadTokens+(J.cache_creation_input_tokens??0)/1e6*$.promptCacheWriteTokens+(J.server_tool_use?.web_search_requests??0)*$.webSearchRequests}function MW($,J){let Q=Q0($);if(Q===J0(h4.firstParty)){let Z=J.speed==="fast";return WJ(Z)}let X=MQ[Q];if(!X)return PW($,Q),MQ[Q0(k1())]??IW;return X}function PW($,J){F("tengu_unknown_model_cost",{model:$,shortName:J}),EQ()}function UR($,J){let Q=MW($,J);return TW(Q,J)}function PQ($){if(Number.isInteger($))return`$${$}`;return`$${$.toFixed(2)}`}function AQ($){return`${PQ($.inputTokens)}/${PQ($.outputTokens)} per Mtok`}var l2,TQ,X$,FW,zW,xW,IW,MQ;var CQ=U(()=>{V1();n();IQ();f8();u0();l2={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:0.3,webSearchRequests:0.01},TQ={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:0.01},X$={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:0.5,webSearchRequests:0.01},FW={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:0.01},zW={inputTokens:0.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:0.08,webSearchRequests:0.01},xW={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:0.1,webSearchRequests:0.01},IW=X$;MQ={[J0(E8.firstParty)]:zW,[J0(A8.firstParty)]:xW,[J0(P8.firstParty)]:l2,[J0(M8.firstParty)]:l2,[J0(C8.firstParty)]:l2,[J0(k8.firstParty)]:l2,[J0(S8.firstParty)]:l2,[J0(v8.firstParty)]:TQ,[J0(j8.firstParty)]:TQ,[J0(y8.firstParty)]:X$,[J0(h4.firstParty)]:X$}});var RR,_R="\u273B",NR="\u2191",DR="\u2193",kQ="\u21AF",OR="\u25CB",FR="\u25D0",zR="\u25CF",xR="\u25C9",vQ="\u23F8",IR="\u21BB",TR="\u25C7",MR="\u25C6",PR="\u203B",ER="\u258E",AR="\xB7\u2714\uFE0E\xB7",CR="\xD7";var VJ=U(()=>{v2();RR=s.platform==="darwin"?"\u23FA":"\u25CF"});function d0($){return EW.includes($)}function X2($){return AW.includes($)}var EW,AW;var GJ=U(()=>{EW=["sonnet","opus","haiku","best","sonnet[1m]","opus[1m]","opusplan"];AW=["sonnet","opus","haiku"]});function CW($,J){if($.includes(J))return!0;if(d0($))return K0($).toLowerCase().includes(J);return!1}function jQ($,J){if(!$.startsWith(J))return!1;return $.length===J.length||$[J.length]==="-"}function kW($,J){let Q=d0($)?K0($).toLowerCase():$;if(jQ(Q,J))return!0;if(!J.startsWith("claude-")&&jQ(Q,`claude-${J}`))return!0;return!1}function yQ($,J){for(let Q of J){if(X2(Q))continue;let X=Q.indexOf($);if(X===-1)continue;let Z=X+$.length;if(Z===Q.length||Q[Z]==="-")return!0}return!1}function SQ($){let J=z0()||{},{availableModels:Q}=J;if(!Q)return!0;if(Q.length===0)return!1;let Z=m4($).trim().toLowerCase(),q=Q.map((Y)=>Y.trim().toLowerCase());if(q.includes(Z)){if(!X2(Z)||!yQ(Z,q))return!0}for(let Y of q)if(X2(Y)&&!yQ(Y,q)&&CW(Z,Y))return!0;if(d0(Z)){let Y=K0(Z).toLowerCase();if(q.includes(Y))return!0}for(let Y of q)if(!X2(Y)&&d0(Y)){if(K0(Y).toLowerCase()===Z)return!0}for(let Y of q)if(!X2(Y)&&!d0(Y)){if(kW(Z,Y))return!0}return!1}var fQ=U(()=>{J1();GJ();u0();u4()});function hR($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z$($){return $.charAt(0).toUpperCase()+$.slice(1)}function bQ($,J,Q=J+"s"){return $===1?J:Q}function pR($){let J=$.indexOf(`
|
|
22
|
+
`);return J===-1?$:$.slice(0,J)}function gR($,J,Q=0){let X=0,Z=$.indexOf(J,Q);while(Z!==-1)X++,Z=$.indexOf(J,Z+1);return X}function mR($){return $.replace(/[\uFF10-\uFF19]/g,(J)=>String.fromCharCode(J.charCodeAt(0)-65248))}function uR($){return $.replace(/\u3000/g," ")}function dR($,J=",",Q=hQ){let Z="";for(let q of $){let Y=Z?J:"",W=Y+q;if(Z.length+W.length<=Q)Z+=W;else{let K=Q-Z.length-Y.length-14;if(K>0)Z+=Y+q.slice(0,K)+"...[truncated]";else Z+="...[truncated]";return Z}}return Z}class vW{maxSize;content="";isTruncated=!1;totalBytesReceived=0;constructor($=hQ){this.maxSize=$}append($){let J=typeof $==="string"?$:$.toString();if(this.totalBytesReceived+=J.length,this.isTruncated&&this.content.length>=this.maxSize)return;if(this.content.length+J.length>this.maxSize){let Q=this.maxSize-this.content.length;if(Q>0)this.content+=J.slice(0,Q);this.isTruncated=!0}else this.content+=J}toString(){if(!this.isTruncated)return this.content;let $=this.totalBytesReceived-this.maxSize,J=Math.round($/1024);return this.content+`
|
|
23
|
+
... [output truncated - ${J}KB removed]`}clear(){this.content="",this.isTruncated=!1,this.totalBytesReceived=0}get length(){return this.content.length}get truncated(){return this.isTruncated}get totalBytes(){return this.totalBytesReceived}}function cR($,J){let Q=$.split(`
|
|
24
|
+
`);if(Q.length<=J)return $;return Q.slice(0,J).join(`
|
|
25
|
+
`)+"\u2026"}var hQ=33554432;var q$=()=>{};function mQ(){return process.env.ANTHROPIC_SMALL_FAST_MODEL||dQ()}function q_($){return $===v().opus40||$===v().opus41||$===v().opus45||$===v().opus46}function n2(){let $,J=gQ();if(J!==void 0)$=J;else{let Q=z0()||{};$=process.env.ANTHROPIC_MODEL||Q.model||void 0}if($&&!SQ($))return;return $}function uQ(){let $=n2();if($!==void 0&&$!==null)return K0($);return cQ()}function jW(){return v1()}function v1(){if(y1())return C1("opus");if(process.env.ANTHROPIC_DEFAULT_OPUS_MODEL)return process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;if(P()!=="firstParty")return v().opus46;return v().opus46}function Y$(){if(y1())return C1("sonnet");if(process.env.ANTHROPIC_DEFAULT_SONNET_MODEL)return process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;if(P()!=="firstParty")return v().sonnet45;return v().sonnet46}function dQ(){if(y1())return C1("haiku");if(process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL)return process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;return v().haiku45}function Y_($){let{permissionMode:J,mainLoopModel:Q,exceeds200kTokens:X=!1}=$;if(n2()==="opusplan"&&J==="plan"&&!X)return v1();if(n2()==="haiku"&&J==="plan")return Y$();return Q}function k1(){if(P()==="azureOpenAI")return"gpt-5.2-codex";if(process.env.USER_TYPE==="ant")return getAntModelOverrideConfig()?.defaultModel??v1()+"[1m]";if(y1())return C1("opus");if(W$())return v1()+(d2()?"[1m]":"");if(V$())return v1()+(d2()?"[1m]":"");return Y$()}function cQ(){return K0(k1())}function J0($){if($=$.toLowerCase(),$.includes("claude-opus-4-7"))return"claude-opus-4-7";if($.includes("claude-opus-4-5"))return"claude-opus-4-5";if($.includes("claude-opus-4-1"))return"claude-opus-4-1";if($.includes("claude-opus-4"))return"claude-opus-4";if($.includes("claude-sonnet-4-6"))return"claude-sonnet-4-6";if($.includes("claude-sonnet-4-5"))return"claude-sonnet-4-5";if($.includes("claude-sonnet-4"))return"claude-sonnet-4";if($.includes("claude-haiku-4-5"))return"claude-haiku-4-5";if($.includes("claude-3-7-sonnet"))return"claude-3-7-sonnet";if($.includes("claude-3-5-sonnet"))return"claude-3-5-sonnet";if($.includes("claude-3-5-haiku"))return"claude-3-5-haiku";if($.includes("claude-3-opus"))return"claude-3-opus";if($.includes("claude-3-sonnet"))return"claude-3-sonnet";if($.includes("claude-3-haiku"))return"claude-3-haiku";let J=$.match(/(claude-(\d+-\d+-)?\w+)/);if(J&&J[1])return J[1];return $}function Q0($){return J0(m4($))}function yW($=!1){if(y1())return`${lQ(k1())} \xB7 OpenAI/Codex default`;if(W$()||V$()){if(d2())return`Opus 4.7 with 1M context \xB7 Most capable for complex work${$?pQ(!0):""}`;return`Opus 4.7 \xB7 Most capable for complex work${$?pQ(!0):""}`}return"Sonnet 4.6 \xB7 Best for everyday tasks"}function lQ($){if($==="opusplan")return"Opus 4.7 in plan mode, else Sonnet 4.6";return iQ(K0($))}function pQ($){if(P()!=="firstParty")return"";let J=AQ(WJ($));return` \xB7${$?` (${kQ})`:""} ${J}`}function d2(){if(j1()||LJ()||P()!=="firstParty")return!1;if(y()&&d()===null)return!1;return!0}function W_($){if($==="opusplan")return"Opus Plan";if(d0($))return Z$($);return iQ($)}function nQ($){let J=XJ($);if(J)return J;switch($){case v().opus46:return"Opus 4.7";case v().opus46+"[1m]":return"Opus 4.7 (1M context)";case v().opus45:return"Opus 4.5";case v().opus41:return"Opus 4.1";case v().opus40:return"Opus 4";case v().sonnet46+"[1m]":return"Sonnet 4.6 (1M context)";case v().sonnet46:return"Sonnet 4.6";case v().sonnet45+"[1m]":return"Sonnet 4.5 (1M context)";case v().sonnet45:return"Sonnet 4.5";case v().sonnet40:return"Sonnet 4";case v().sonnet40+"[1m]":return"Sonnet 4 (1M context)";case v().sonnet37:return"Sonnet 3.7";case v().sonnet35:return"Sonnet 3.5";case v().haiku45:return"Haiku 4.5";case v().haiku35:return"Haiku 3.5";default:return null}}function SW($){let[J="",...Q]=$.split("-");return[J.slice(0,3)+"*".repeat(Math.max(0,J.length-3)),...Q].join("-")}function iQ($){let J=nQ($);if(J)return J;if(process.env.USER_TYPE==="ant"){let Q=K0($),X=resolveAntModel($);if(X){let Z=X.model.replace(/\[1m\]$/i,""),q=SW(Z),Y=E0(Q)?"[1m]":"";return q+Y}if(Q!==$)return`${$} (${Q})`;return Q}return $}function V_($){let J=nQ($);if(J)return`Claude ${J}`;return`Claude (${$})`}function K0($){let J=$.trim(),Q=J.toLowerCase(),X=E0(Q),Z=X?Q.replace(/\[1m]$/i,"").trim():Q;if(d0(Z))switch(Z){case"opusplan":return Y$()+(X?"[1m]":"");case"sonnet":return Y$()+(X?"[1m]":"");case"haiku":return dQ()+(X?"[1m]":"");case"opus":return v1()+(X?"[1m]":"");case"best":return jW();default:}if(P()==="firstParty"&&bW(Z)&&hW())return v1()+(X?"[1m]":"");if(process.env.USER_TYPE==="ant"){let q=E0(Q),Y=Q.replace(/\[1m]$/i,"").trim(),W=resolveAntModel(Y);if(W){let K=q?"[1m]":"";return W.model+K}}if(X)return J.replace(/\[1m\]$/i,"").trim()+"[1m]";return J}function G_($,J){if(E0($)||!E0(J))return $;if(KJ(K0($)))return $+"[1m]";return $}function bW($){return fW.includes($)}function hW(){return!R(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function K_($){if($===null){if(process.env.USER_TYPE==="ant")return`Default for Ants (${lQ(k1())})`;else if(y())return`Default (${yW()})`;return`Default (${cQ()})`}let J=K0($);return $===J?J:`${$} (${J})`}function B_($){let J=XJ($);if(J)return J;if(P()==="foundry")return;let Q=$.toLowerCase().includes("[1m]"),X=Q0($);if(X.includes("claude-opus-4-7"))return Q?"Opus 4.7 (with 1M context)":"Opus 4.7";if(X.includes("claude-opus-4-5"))return"Opus 4.5";if(X.includes("claude-opus-4-1"))return"Opus 4.1";if(X.includes("claude-opus-4"))return"Opus 4";if(X.includes("claude-sonnet-4-6"))return Q?"Sonnet 4.6 (with 1M context)":"Sonnet 4.6";if(X.includes("claude-sonnet-4-5"))return Q?"Sonnet 4.5 (with 1M context)":"Sonnet 4.5";if(X.includes("claude-sonnet-4"))return Q?"Sonnet 4 (with 1M context)":"Sonnet 4";if(X.includes("claude-3-7-sonnet"))return"Claude 3.7 Sonnet";if(X.includes("claude-3-5-sonnet"))return"Claude 3.5 Sonnet";if(X.includes("claude-haiku-4-5"))return"Haiku 4.5";if(X.includes("claude-3-5-haiku"))return"Claude 3.5 Haiku";return}function L_($){return $.replace(/\[(1|2)m\]/gi,"")}var fW;var u0=U(()=>{n();e();BJ();j();u4();CQ();J1();b0();VJ();fQ();GJ();m2();q$();fW=["claude-opus-4-20250514","claude-opus-4-1-20250805","claude-opus-4-0","claude-opus-4-1"]});function H_($){let J=$.entrypoint??"unknown",Q=$.workload?` cc_workload=${$.workload};`:"";return`x-anthropic-billing-header: cc_version=2.1.92.${$.fingerprint}; cc_entrypoint=${J}; cch=00000;${Q}`}var rQ="2.1.92",UJ="x-anthropic-billing-header:";var HJ=()=>{};function aQ($){return uW($,dW)}function uW($,J){if(!$.includes(UJ)||!$.includes(pW))return $;let Q;try{Q=JSON.parse($)}catch{return $}if(wJ($)!==1)return $;let X=J(Q);if(X.reduce((B,w)=>B+wJ(w),0)!==1)return $;let q=X.find((B)=>wJ(B)===1);if(!q)return $;let Y=JSON.stringify(q);if(lW($,Y)!==1)return $;let W=nW($),K=q.replace(eQ,`cch=${W};`);return $.replace(Y,JSON.stringify(K))}function QX($){if(typeof $==="string")return aQ($);if($ instanceof Uint8Array){let J=mW.decode($),Q=aQ(J);return Q===J?$:JX.encode(Q)}return $}function dW($){if(!XX($))return[];let{system:J}=$;if(typeof J==="string")return tQ(J)?[J]:[];if(!Array.isArray(J))return[];return J.flatMap((Q)=>cW(Q)&&tQ(Q.text)?[Q.text]:[])}function tQ($){return $.startsWith(UJ)}function cW($){return XX($)&&$.type==="text"&&typeof $.text==="string"}function XX($){return!!$&&typeof $==="object"&&!Array.isArray($)}function wJ($){return $.match(eQ)?.length??0}function lW($,J){let Q=0,X=$.indexOf(J);while(X!==-1)Q+=1,X=$.indexOf(J,X+J.length);return Q}function nW($){return(iW(JX.encode($),gW)&0xfffffn).toString(16).padStart(5,"0")}function iW($,J){let Q=0,X,Z=new DataView($.buffer,$.byteOffset,$.byteLength);if($.length>=32){let q=$.length-32,Y=J+S1+r2&m,W=J+r2&m,K=J&m,B=J-S1&m;while(Q<=q)Y=Z2(Y,i2(Z,Q)),Q+=8,W=Z2(W,i2(Z,Q)),Q+=8,K=Z2(K,i2(Z,Q)),Q+=8,B=Z2(B,i2(Z,Q)),Q+=8;X=H1(Y,1n)+H1(W,7n)+H1(K,12n)+H1(B,18n)&m,X=G$(X,Y),X=G$(X,W),X=G$(X,K),X=G$(X,B)}else X=J+sQ&m;X=X+BigInt($.length)&m;while(Q+8<=$.length){let q=Z2(0n,i2(Z,Q));X^=q,X=H1(X,27n)*S1+$X&m,Q+=8}if(Q+4<=$.length)X^=BigInt(rW(Z,Q))*S1&m,X=H1(X,23n)*r2+oQ&m,Q+=4;while(Q<$.length)X^=BigInt($[Q])*sQ&m,X=H1(X,11n)*S1&m,Q+=1;return X^=X>>33n,X=X*r2&m,X^=X>>29n,X=X*oQ&m,X^=X>>32n,X&m}function Z2($,J){return H1($+J*r2&m,31n)*S1&m}function G$($,J){return $^=Z2(0n,J),$*S1+$X&m}function H1($,J){return($<<J|$>>64n-J)&m}function i2($,J){return $.getBigUint64(J,!0)}function rW($,J){return $.getUint32(J,!0)}var pW="cch=00000;",eQ,gW=0x6E52736AC806831En,m=0xffffffffffffffffn,S1=11400714785074694791n,r2=14029467366897019727n,oQ=1609587929392839161n,$X=9650029242287828579n,sQ=2870177450012600261n,JX,mW;var ZX=U(()=>{HJ();eQ=/\bcch=00000;/g,JX=new TextEncoder,mW=new TextDecoder});import{createHash as oW,randomBytes as qX}from"crypto";function RJ($){return $.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function D_(){return RJ(qX(32))}function YX($){let J=oW("sha256");return J.update($),RJ(J.digest())}function O_(){return RJ(qX(32))}var WX=()=>{};import{randomBytes as VX}from"crypto";function LX(){return VX(32).toString("hex")}function UX(){return VX(64).toString("hex")}function HX($){let J=new URLSearchParams({response_type:"code",client_id:o2,redirect_uri:$.redirectUri,scope:"openid profile email offline_access",code_challenge:YX($.codeVerifier),code_challenge_method:"S256",id_token_add_organizations:"true",codex_cli_simplified_flow:"true",state:$.state});return`${_J}/oauth/authorize?${J.toString()}`}async function wX($){let J=await fetch(`${_J}/oauth/token`,{method:"POST",headers:BX,body:new URLSearchParams({grant_type:"authorization_code",code:$.code,redirect_uri:$.redirectUri,client_id:o2,code_verifier:$.codeVerifier}).toString()});if(!J.ok)throw await RX("exchange",J);return await J.json()}async function DJ($){let J=await fetch(`${_J}/oauth/token`,{method:"POST",headers:BX,body:new URLSearchParams({grant_type:"refresh_token",refresh_token:$,client_id:o2,scope:"openid profile email"}).toString()});if(!J.ok)throw await RX("refresh",J);return await J.json()}async function RX($,J){let Q=await J.text().catch(()=>""),X=tW(Q),Z=X?`: ${X}`:"";return Error(`OpenAI token ${$} failed: ${J.status}${Z}`)}function tW($){return $.replace(/"((?:access_token|refresh_token|id_token|code|code_verifier))"\s*:\s*"[^"]*"/gi,'"$1":"[redacted]"').replace(/\b(access_token|refresh_token|id_token|code|code_verifier)=([^&\s]+)/gi,"$1=[redacted]").slice(0,aW)}function K$($){if(!$)return;let J=$.split(".");if(J.length!==3)return;try{return JSON.parse(Buffer.from(J[1],"base64url").toString())}catch{return}}function _X($){if(!$)return;return $.chatgpt_account_id||$["https://api.openai.com/auth"]?.chatgpt_account_id||$.organizations?.[0]?.id}function NX($){let J=K$($.id_token)??K$($.access_token);if(!$.refresh_token)throw Error("OpenAI OAuth response did not include a refresh token");return{accessToken:$.access_token,refreshToken:$.refresh_token,expiresAt:Date.now()+($.expires_in??3600)*1000,idToken:$.id_token,accountId:_X(J),email:J?.email,clientId:o2}}function OJ($){return $-Date.now()<=300000}function FJ($,J){let Q=K$(J.id_token)??K$(J.access_token);return{accessToken:J.access_token,refreshToken:J.refresh_token??$.refreshToken,expiresAt:Date.now()+(J.expires_in??3600)*1000,idToken:J.id_token??$.idToken,accountId:_X(Q)??$.accountId,email:Q?.email??$.email,clientId:$.clientId??o2}}var _J="https://auth.openai.com",o2="app_EMoamEEZ73f0CkXaXp7hrann",GX="https://chatgpt.com/backend-api/codex/responses",KX=1455,NJ="/auth/callback",sW="codex-cli/0.91.0",aW=500,BX;var zJ=U(()=>{WX();BX={Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":sW}});import{createServer as eW}from"http";class xJ{localServer;port=0;promiseResolver=null;promiseRejecter=null;expectedState=null;pendingResponse=null;callbackPath;constructor($="/callback"){this.localServer=eW(),this.callbackPath=$}async start($){return new Promise((J,Q)=>{this.localServer.once("error",(X)=>{Q(Error(`Failed to start OAuth callback server: ${X.message}`))}),this.localServer.listen($??0,"localhost",()=>{let X=this.localServer.address();this.port=X.port,J(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization($,J){return new Promise((Q,X)=>{this.promiseResolver=Q,this.promiseRejecter=X,this.expectedState=$,this.startLocalListener(J)})}handleSuccessRedirect($,J){if(!this.pendingResponse)return;if(J){J(this.pendingResponse,$),this.pendingResponse=null,F("tengu_oauth_automatic_redirect",{custom_handler:!0});return}let Q=L1($)?f().CLAUDEAI_SUCCESS_URL:f().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:Q}),this.pendingResponse.end(),this.pendingResponse=null,F("tengu_oauth_automatic_redirect",{})}handleErrorRedirect(){if(!this.pendingResponse)return;let $=f().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:$}),this.pendingResponse.end(),this.pendingResponse=null,F("tengu_oauth_automatic_redirect_error",{})}startLocalListener($){this.localServer.on("request",this.handleRedirect.bind(this)),this.localServer.on("error",this.handleError.bind(this)),$()}handleRedirect($,J){let Q=new URL($.url||"",`http://${$.headers.host||"localhost"}`);if(Q.pathname!==this.callbackPath){J.writeHead(404),J.end();return}let X=Q.searchParams.get("code")??void 0,Z=Q.searchParams.get("state")??void 0;this.validateAndRespond(X,Z,J)}validateAndRespond($,J,Q){if(!$){Q.writeHead(400),Q.end("Authorization code not found"),this.reject(Error("No authorization code received"));return}if(J!==this.expectedState){Q.writeHead(400),Q.end("Invalid state parameter"),this.reject(Error("Invalid state parameter"));return}this.pendingResponse=Q,this.resolve($)}handleError($){O($),this.close(),this.reject($)}resolve($){if(this.promiseResolver)this.promiseResolver($),this.promiseResolver=null,this.promiseRejecter=null}reject($){if(this.promiseRejecter)this.promiseRejecter($),this.promiseResolver=null,this.promiseRejecter=null}close(){if(this.pendingResponse)this.handleErrorRedirect();if(this.localServer)this.localServer.removeAllListeners(),this.localServer.close()}}var DX=U(()=>{V1();T0();W0();o4()});class X5{codeVerifier;authCodeListener=null;port=null;manualAuthCodeResolver=null;constructor(){this.codeVerifier=UX()}async startOAuthFlow($,J){this.authCodeListener=new xJ(NJ),this.port=await this.authCodeListener.start(KX);let Q=LX(),X=`http://localhost:${this.port}${NJ}`,Z=HX({redirectUri:X,codeVerifier:this.codeVerifier,state:Q}),q=await this.waitForAuthorizationCode(Q,async()=>{if(J?.skipBrowserOpen)await $(Z,Z);else await $(Z),await OX(Z)});try{let Y=await wX({code:q,redirectUri:X,codeVerifier:this.codeVerifier}),W=NX(Y),K=i4(W);if(!K.success)throw Error(K.warning??"Failed to persist OpenAI OAuth tokens");return this.authCodeListener?.handleSuccessRedirect([],(B)=>{B.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),B.end(J5)}),W}catch(Y){throw this.authCodeListener?.handleSuccessRedirect([],(W)=>{W.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),W.end(Q5)}),Y}finally{this.cleanup()}}async waitForAuthorizationCode($,J){return new Promise((Q,X)=>{this.manualAuthCodeResolver=Q,this.authCodeListener?.waitForAuthorization($,J).then((Z)=>{this.manualAuthCodeResolver=null,Q(Z)}).catch((Z)=>{this.manualAuthCodeResolver=null,X(Z)})})}handleManualAuthCodeInput($){if(this.manualAuthCodeResolver)this.manualAuthCodeResolver($.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close()}async ensureFreshTokens(){B1();let $=await l8();if(!$)return null;if(!OJ($.expiresAt))return $;let J=await DJ($.refreshToken),Q=FJ($,J),X=i4(Q);if(!X.success)throw Error(X.warning??"Failed to persist refreshed OpenAI tokens");return Q}async ensureFreshAccessToken(){return(await this.ensureFreshTokens())?.accessToken??null}logout(){return B1(),u9()}cleanup(){this.authCodeListener?.close(),this.authCodeListener=null,this.port=null,this.manualAuthCodeResolver=null}}async function FX(){B1();let $=await l8();if(!$)return null;if(!OJ($.expiresAt))return $;try{let J=await DJ($.refreshToken),Q=FJ($,J),X=i4(Q);if(!X.success)throw Error(X.warning??"Failed to persist refreshed OpenAI tokens");return Q}catch{return null}}var J5=`<!doctype html>
|
|
26
|
+
<html>
|
|
27
|
+
<head>
|
|
28
|
+
<meta charset="utf-8">
|
|
29
|
+
<title>cc-haha OpenAI Authorization Successful</title>
|
|
30
|
+
<style>
|
|
31
|
+
body { font-family: system-ui, -apple-system, sans-serif; display:flex; justify-content:center; align-items:center; height:100vh; margin:0; background:#131010; color:#f1ecec; }
|
|
32
|
+
.container { text-align:center; padding:2rem; }
|
|
33
|
+
p { color:#b7b1b1; }
|
|
34
|
+
</style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<div class="container">
|
|
38
|
+
<h1>Authorization Successful</h1>
|
|
39
|
+
<p>You can close this window and return to Claude Code Haha.</p>
|
|
40
|
+
</div>
|
|
41
|
+
<script>setTimeout(() => window.close(), 2000)</script>
|
|
42
|
+
</body>
|
|
43
|
+
</html>`,Q5=`<!doctype html>
|
|
44
|
+
<html>
|
|
45
|
+
<head>
|
|
46
|
+
<meta charset="utf-8">
|
|
47
|
+
<title>cc-haha OpenAI Authorization Failed</title>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<h1>Authorization Failed</h1>
|
|
51
|
+
<p>You can close this window and return to Claude Code Haha.</p>
|
|
52
|
+
</body>
|
|
53
|
+
</html>`;var zX=U(()=>{$5();DX();zJ();r4()});function xX($){let J=[];for(let X of $.messages)Z5(X,J);let Q={model:$.model,input:J,stream:$.stream,store:!1};if($.system){if(typeof $.system==="string")Q.instructions=$.system;else if(Array.isArray($.system))Q.instructions=$.system.map((X)=>X.text).join(`
|
|
54
|
+
`)}if($.temperature!==void 0)Q.temperature=$.temperature;if($.top_p!==void 0)Q.top_p=$.top_p;if($.tools&&$.tools.length>0)Q.tools=$.tools.filter((X)=>X.name!=="BatchTool").map((X)=>({type:"function",name:X.name,description:X.description,parameters:X.input_schema}));if($.tool_choice!==void 0)Q.tool_choice=q5($.tool_choice);if($.thinking){let X=$.thinking.budget_tokens;if(X!==void 0)if(X<=1024)Q.reasoning={effort:"low"};else if(X<=8192)Q.reasoning={effort:"medium"};else Q.reasoning={effort:"high"};else if($.thinking.type==="enabled")Q.reasoning={effort:"high"}}return Q}function Z5($,J){let Q=$.content;if(typeof Q==="string"){J.push({type:"message",role:$.role,content:Q});return}if(!Array.isArray(Q)||Q.length===0){J.push({type:"message",role:$.role,content:""});return}let X=[];for(let Z of Q)if(Z.type==="text")X.push(Z.text);else if(Z.type==="image")X.push({type:"image_url",image_url:{url:`data:${Z.source.media_type};base64,${Z.source.data}`}});else if(Z.type==="tool_use"){if(X.length>0){let q=X.length===1&&typeof X[0]==="string"?X[0]:X.map((Y)=>typeof Y==="string"?Y:"").join("");if(q)J.push({type:"message",role:$.role,content:q});X.length=0}J.push({type:"function_call",call_id:Z.id,name:Z.name,arguments:typeof Z.input==="string"?Z.input:JSON.stringify(Z.input)})}else if(Z.type==="tool_result"){let q=typeof Z.content==="string"?Z.content:Array.isArray(Z.content)?Z.content.filter((Y)=>Y.type==="text").map((Y)=>Y.text).join(`
|
|
55
|
+
`):"";J.push({type:"function_call_output",call_id:Z.tool_use_id,output:q})}if(X.length>0){let Z=X.length===1&&typeof X[0]==="string"?X[0]:X.map((q)=>typeof q==="string"?q:"").join("");if(Z)J.push({type:"message",role:$.role,content:Z})}}function q5($){if(typeof $==="string")return $;if(typeof $==="object"&&$!==null){let J=$;if(J.type==="auto")return"auto";if(J.type==="any")return"required";if(J.type==="none")return"none";if(J.type==="tool"&&typeof J.name==="string")return{type:"function",function:{name:J.name}}}return"auto"}var IX=()=>{};function TX($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function B$($){if($==null||$==="")return{};if(typeof $==="string")try{let J=JSON.parse($);return TX(J)?J:{raw:J}}catch{return{raw:$}}if(TX($))return $;return{raw:$}}function L$($){if($==null||$==="")return"";return typeof $==="string"?$:JSON.stringify($)}var s2=()=>{};function U$($,J){let Q=[],X=!1;for(let Z of $.output||[])if(Y5(Z,Q),Z.type==="function_call")X=!0;if(Q.length===0)Q.push({type:"text",text:""});return{id:$.id||`msg_${Date.now()}`,type:"message",role:"assistant",content:Q,model:$.model||J,stop_reason:W5($.status,X),stop_sequence:null,usage:{input_tokens:$.usage?.input_tokens??$.usage?.prompt_tokens??0,output_tokens:$.usage?.output_tokens??$.usage?.completion_tokens??0}}}function Y5($,J){switch($.type){case"message":{for(let Q of $.content||[])if(Q.type==="output_text"||Q.type==="text")J.push({type:"text",text:Q.text||""});else if(Q.type==="refusal")J.push({type:"text",text:Q.refusal||"[Refusal]"});break}case"function_call":{J.push({type:"tool_use",id:$.call_id,name:$.name,input:B$($.arguments)});break}case"reasoning":{if($.summary){for(let Q of $.summary)if(Q.text)J.push({type:"thinking",thinking:Q.text})}break}}}function W5($,J){switch($){case"completed":return J?"tool_use":"end_turn";case"failed":return"end_turn";case"cancelled":return"end_turn";case"incomplete":return"max_tokens";default:return"end_turn"}}var IJ=U(()=>{s2()});function x0($,J){return`event: ${$}
|
|
56
|
+
data: ${JSON.stringify(J)}
|
|
57
|
+
|
|
58
|
+
`}function MX($,J){let Q=new TextEncoder,X=new TextDecoder,Z="",q={nextContentIndex:0,indexByKey:new Map,toolIndexByItemId:new Map,model:J,messageStarted:!1,messageStopped:!1};return new ReadableStream({async start(Y){let W=$.getReader(),K="";try{while(!0){let{done:B,value:w}=await W.read();if(B)break;Z+=X.decode(w,{stream:!0});let H=Z.split(`
|
|
59
|
+
`);Z=H.pop()||"";for(let z of H){let _=z.trim();if(_.startsWith("event: ")){K=_.slice(7).trim();continue}if(_.startsWith("data: ")){let M=_.slice(6);if(M==="[DONE]"){if(!q.messageStopped){if(q.messageStopped=!0,!q.messageStarted)H$(q,Y,Q,J);Y.enqueue(Q.encode(x0("message_stop",{type:"message_stop"})))}continue}let k;try{k=JSON.parse(M)}catch{continue}V5(K,k,q,Y,Q),K="";continue}if(_==="")K=""}}}catch(B){Y.error(B);return}Y.close()}})}function H$($,J,Q,X){$.messageStarted=!0,J.enqueue(Q.encode(x0("message_start",{type:"message_start",message:{id:`msg_${Date.now()}`,type:"message",role:"assistant",content:[],model:X,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})))}function V5($,J,Q,X,Z){switch($){case"response.created":{let q=J;Q.model=q.model||Q.model,H$(Q,X,Z,Q.model);break}case"response.output_item.added":{if(!Q.messageStarted)H$(Q,X,Z,Q.model);let q=J.item;if(!q)break;if(q.type==="function_call"){let Y=Q.nextContentIndex++,W=q.call_id||q.id||"",K=q.name||"";Q.toolIndexByItemId.set(q.id||W,Y),X.enqueue(Z.encode(x0("content_block_start",{type:"content_block_start",index:Y,content_block:{type:"tool_use",id:W,name:K,input:{}}})))}break}case"response.content_part.added":{if(!Q.messageStarted)H$(Q,X,Z,Q.model);if(!J.part)break;let Y=J.content_index??0,K=`${J.output_index??0}:${Y}`,B=Q.nextContentIndex++;Q.indexByKey.set(K,B),X.enqueue(Z.encode(x0("content_block_start",{type:"content_block_start",index:B,content_block:{type:"text",text:""}})));break}case"response.output_text.delta":{let q=J.content_index??0,W=`${J.output_index??0}:${q}`,K=Q.indexByKey.get(W);if(K===void 0)break;let B=J.delta||"";X.enqueue(Z.encode(x0("content_block_delta",{type:"content_block_delta",index:K,delta:{type:"text_delta",text:B}})));break}case"response.refusal.delta":{let q=J.content_index??0,W=`${J.output_index??0}:${q}`,K=Q.indexByKey.get(W);if(K===void 0)break;let B=J.delta||"";X.enqueue(Z.encode(x0("content_block_delta",{type:"content_block_delta",index:K,delta:{type:"text_delta",text:B}})));break}case"response.function_call_arguments.delta":{let q=J.item_id||"",Y=Q.toolIndexByItemId.get(q);if(Y===void 0)break;let W=L$(J.delta);X.enqueue(Z.encode(x0("content_block_delta",{type:"content_block_delta",index:Y,delta:{type:"input_json_delta",partial_json:W}})));break}case"response.output_text.done":case"response.refusal.done":{let q=J.content_index??0,W=`${J.output_index??0}:${q}`,K=Q.indexByKey.get(W);if(K===void 0)break;X.enqueue(Z.encode(x0("content_block_stop",{type:"content_block_stop",index:K})));break}case"response.function_call_arguments.done":{let q=J.item_id||"",Y=Q.toolIndexByItemId.get(q);if(Y===void 0)break;X.enqueue(Z.encode(x0("content_block_stop",{type:"content_block_stop",index:Y})));break}case"response.completed":{let q=J.response,Y=q?.status||"completed",W=q?.usage,K=Q.toolIndexByItemId.size>0,B=Y==="completed"?K?"tool_use":"end_turn":Y==="incomplete"?"max_tokens":"end_turn";if(X.enqueue(Z.encode(x0("message_delta",{type:"message_delta",delta:{stop_reason:B,stop_sequence:null},usage:{input_tokens:W?.input_tokens??0,output_tokens:W?.output_tokens??0}}))),!Q.messageStopped)Q.messageStopped=!0,X.enqueue(Z.encode(x0("message_stop",{type:"message_stop"})));break}}}var PX=U(()=>{s2()});async function EX($,J){let Q=new TextDecoder,X=$.getReader(),Z="",q="",Y=null,W={id:`resp_${Date.now()}`,createdAt:Math.floor(Date.now()/1000),model:J,status:"completed",textByKey:new Map,usage:void 0};while(!0){let{done:K,value:B}=await X.read();if(K)break;Z+=Q.decode(B,{stream:!0});let w=Z.split(`
|
|
60
|
+
`);Z=w.pop()||"";for(let H of w){let z=H.trim();if(z.startsWith("event: ")){q=z.slice(7).trim();continue}if(!z.startsWith("data: ")){if(z==="")q="";continue}let _=z.slice(6);if(_==="[DONE]"){q="";continue}let M;try{M=JSON.parse(_)}catch{q="";continue}if(q==="response.completed"){let k=M.response;if(B5(k))Y=k}else G5(q,M,W);q=""}}return U$(Y??K5(W),J)}function G5($,J,Q){if($==="response.created"){if(typeof J.id==="string")Q.id=J.id;if(typeof J.created_at==="number")Q.createdAt=J.created_at;if(typeof J.model==="string")Q.model=J.model;if(typeof J.status==="string")Q.status=J.status;return}if($==="response.output_text.delta"){let X=TJ(J),Z=typeof J.delta==="string"?J.delta:"";Q.textByKey.set(X,(Q.textByKey.get(X)??"")+Z);return}if($==="response.output_text.done"){let X=typeof J.text==="string"?J.text:null;if(X!==null)Q.textByKey.set(TJ(J),X);return}if($==="response.refusal.delta"){let X=TJ(J),Z=typeof J.delta==="string"?J.delta:"";Q.textByKey.set(X,(Q.textByKey.get(X)??"")+Z)}}function K5($){let J=[...$.textByKey.entries()].sort(([Q],[X])=>Q.localeCompare(X)).map(([,Q])=>Q).join("");return{id:$.id,object:"response",created_at:$.createdAt,model:$.model,status:$.status,output:[{type:"message",role:"assistant",content:[{type:"output_text",text:J}]}],usage:$.usage}}function TJ($){let J=typeof $.output_index==="number"?$.output_index:0,Q=typeof $.content_index==="number"?$.content_index:0;return`${J}:${Q}`}function B5($){return!!$&&typeof $==="object"&&!Array.isArray($)&&Array.isArray($.output)}var AX=U(()=>{IJ()});import{randomUUID as L5}from"crypto";function kX(){return!!h2()?.refreshToken}function vX($,J){let Q=$??globalThis.fetch;return async(X,Z)=>{let q=X instanceof Request?new URL(X.url):new URL(String(X));if(!q.pathname.endsWith("/v1/messages"))return Q(X,Z);let Y=await H5(X,Z),W=C1(Y.model),K=xX({...Y,model:W}),B={...K,stream:!0},w=await FX();if(!w)throw Error("OpenAI OAuth token is missing or expired. Run claude auth login --openai again.");let H=new Headers;if(H.set("Content-Type","application/json"),H.set("Authorization",`Bearer ${w.accessToken}`),w.accountId)H.set("ChatGPT-Account-Id",w.accountId);L(`[API REQUEST] ${q.pathname} remapped_to=OpenAI/Codex model=${W} source=${J??"unknown"} request_id=${L5()}`);let z=await Q(GX,{method:"POST",headers:H,body:JSON.stringify(B),signal:Z?.signal});if(!z.ok){let M=await z.text().catch(()=>"");return Response.json({type:"error",error:{type:"api_error",message:`OpenAI upstream returned HTTP ${z.status}: ${M.slice(0,500)}`}},{status:z.status})}if(K.stream){if(!z.body)return Response.json({type:"error",error:{type:"api_error",message:"OpenAI upstream returned no body for stream"}},{status:502});return new Response(MX(z.body,W),{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}if(z.body&&U5(z)){let M=await EX(z.body,W);return Response.json(M)}let _=await z.json();return Response.json(U$(_,W))}}function U5($){return($.headers.get("Content-Type")??"").toLowerCase().includes("text/event-stream")}async function H5($,J){let Q=J?.body;if(typeof Q==="string")return JSON.parse(Q);if(Q instanceof Uint8Array||Q instanceof ArrayBuffer)return JSON.parse(Buffer.from(Q).toString("utf8"));if($ instanceof Request)return await $.clone().json();throw Error("Unable to read Anthropic request body for OpenAI/Codex transformation")}var CX="openai-oauth-dummy-key";var jX=U(()=>{zJ();zX();m2();r4();IX();IJ();PX();AX();p()});function yX($,J={}){let Q=[];if($.system){if(typeof $.system==="string")Q.push({role:"system",content:$.system});else if(Array.isArray($.system)){let Z=$.system.map((q)=>q.text).join(`
|
|
61
|
+
`);Q.push({role:"system",content:Z})}}for(let Z of $.messages)w5(Z,Q,J);let X={model:$.model,messages:Q,stream:$.stream};if($.temperature!==void 0)X.temperature=$.temperature;if($.top_p!==void 0)X.top_p=$.top_p;if($.stop_sequences&&$.stop_sequences.length>0)X.stop=$.stop_sequences;if($.tools&&$.tools.length>0)X.tools=$.tools.filter((Z)=>Z.name!=="BatchTool").map((Z)=>({type:"function",function:{name:Z.name,description:Z.description,parameters:Z.input_schema}}));if($.tool_choice!==void 0)X.tool_choice=N5($.tool_choice);if($.thinking){let Z=$.thinking.budget_tokens;if(Z!==void 0)if(Z<=1024)X.reasoning_effort="low";else if(Z<=8192)X.reasoning_effort="medium";else X.reasoning_effort="high";else if($.thinking.type==="enabled")X.reasoning_effort="high";if(J.passThinkingToggle)X.thinking={type:$.thinking.type}}return X}function w5($,J,Q){let X=$.content;if(typeof X==="string"){J.push({role:$.role,content:X});return}if(!Array.isArray(X)||X.length===0){J.push({role:$.role,content:""});return}if($.role==="user")R5(X,J);else _5(X,J,Q)}function R5($,J){let Q=[];for(let X of $)if(X.type==="text")Q.push({type:"text",text:X.text});else if(X.type==="image"){let Z=`data:${X.source.media_type};base64,${X.source.data}`;Q.push({type:"image_url",image_url:{url:Z}})}else if(X.type==="tool_result"){let Z=typeof X.content==="string"?X.content:Array.isArray(X.content)?X.content.filter((q)=>q.type==="text").map((q)=>q.text).join(`
|
|
62
|
+
`):"";J.push({role:"tool",tool_call_id:X.tool_use_id,content:Z})}if(Q.length>0)J.push({role:"user",content:Q.length===1&&Q[0].type==="text"?Q[0].text:Q})}function _5($,J,Q){let X="",Z="",q=[];for(let W of $)if(W.type==="text")X+=W.text;else if(W.type==="thinking"&&Q.roundTripReasoningContent)Z+=W.thinking;else if(W.type==="tool_use")q.push({id:W.id,type:"function",function:{name:W.name,arguments:typeof W.input==="string"?W.input:JSON.stringify(W.input)}});let Y={role:"assistant",content:X||null};if(q.length>0)Y.tool_calls=q;if(Z)Y.reasoning_content=Z;J.push(Y)}function N5($){if(typeof $==="string")return $;if(typeof $==="object"&&$!==null){let J=$;if(J.type==="auto")return"auto";if(J.type==="any")return"required";if(J.type==="none")return"none";if(J.type==="tool"&&typeof J.name==="string")return{type:"function",function:{name:J.name}}}return"auto"}var SX=()=>{};function fX($,J){let Q=$.choices?.[0];if(!Q)return O5($,J);let X=[],Z=Q.message;if(typeof Z.reasoning_content==="string"&&Z.reasoning_content)X.push({type:"thinking",thinking:Z.reasoning_content});else if(typeof Z.reasoning==="string"&&Z.reasoning)X.push({type:"thinking",thinking:Z.reasoning});else if(Array.isArray(Z.thinking_blocks)){for(let q of Z.thinking_blocks)if(q.type==="thinking"&&typeof q.thinking==="string")X.push({type:"thinking",thinking:q.thinking,signature:q.signature})}if(Q.message.content)X.push({type:"text",text:Q.message.content});if(Q.message.tool_calls)for(let q of Q.message.tool_calls)X.push({type:"tool_use",id:q.id,name:q.function.name,input:B$(q.function.arguments)});if(X.length===0)X.push({type:"text",text:""});return{id:$.id||`msg_${Date.now()}`,type:"message",role:"assistant",content:X,model:$.model||J,stop_reason:D5(Q.finish_reason),stop_sequence:null,usage:bX($.usage)}}function D5($){switch($){case"stop":return"end_turn";case"tool_calls":return"tool_use";case"length":return"max_tokens";case"content_filter":return"end_turn";default:return"end_turn"}}function bX($){if(!$)return{input_tokens:0,output_tokens:0};return{input_tokens:$.prompt_tokens||0,output_tokens:$.completion_tokens||0,cache_read_input_tokens:$.prompt_tokens_details?.cached_tokens||0}}function O5($,J){return{id:$.id||`msg_${Date.now()}`,type:"message",role:"assistant",content:[{type:"text",text:""}],model:$.model||J,stop_reason:"end_turn",stop_sequence:null,usage:bX($.usage)}}var hX=U(()=>{s2()});function F5($,J){return`event: ${$}
|
|
63
|
+
data: ${JSON.stringify(J)}
|
|
64
|
+
|
|
65
|
+
`}function z5($){return{queue:[],currentBlockType:"text",currentBlockIndex:-1,nextContentIndex:0,blockStartSent:!1,blockStopSent:!1,toolBlocks:new Map,model:$,messageStartSent:!1,messageDeltaSent:!1,messageStopSent:!1,heldMessageDelta:null}}function gX($,J){let Q=new TextEncoder,X=new TextDecoder,Z="",q=z5(J);return new ReadableStream({async start(Y){let W=$.getReader(),K=!1;try{while(!0){let{done:B,value:w}=await W.read();if(B)break;Z+=X.decode(w,{stream:!0});let H=Z.split(`
|
|
66
|
+
`);Z=H.pop()||"";for(let z of H){let _=z.trim();if(!_||_.startsWith(":"))continue;if(_==="data: [DONE]"){pX(q),MJ(q,Y,Q);continue}if(!_.startsWith("data: "))continue;let M=_.slice(6),k;try{k=JSON.parse(M)}catch{continue}I5(k,q),MJ(q,Y,Q)}}}catch(B){K=!0,Y.error(B)}finally{if(!K)pX(q),MJ(q,Y,Q),Y.close()}}})}function w1($,J,Q){$.queue.push({event:J,data:Q})}function MJ($,J,Q){for(let X of $.queue)J.enqueue(Q.encode(F5(X.event,X.data)));$.queue.length=0}function mX($,J){if($.messageStartSent)return;$.messageStartSent=!0,w1($,"message_start",{type:"message_start",message:{id:J||`msg_${Date.now()}`,type:"message",role:"assistant",content:[],model:$.model,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})}function uX($,J,Q){let X=$.nextContentIndex++;return $.currentBlockType=J,$.currentBlockIndex=X,$.blockStartSent=!0,$.blockStopSent=!1,w1($,"content_block_start",{type:"content_block_start",index:X,content_block:Q}),X}function a2($,J,Q){w1($,"content_block_delta",{type:"content_block_delta",index:J,delta:Q})}function dX($){if(!$.blockStartSent||$.blockStopSent)return;$.blockStopSent=!0,w1($,"content_block_stop",{type:"content_block_stop",index:$.currentBlockIndex})}function cX($){for(let[,J]of $.toolBlocks)if(J.started)w1($,"content_block_stop",{type:"content_block_stop",index:J.anthropicIndex});if($.toolBlocks.clear(),$.currentBlockType==="tool_use")$.blockStopSent=!0}function lX($){if($.currentBlockType!=="tool_use")dX($);cX($)}function nX($){if(typeof $.reasoning_content==="string"&&$.reasoning_content)return{thinking:$.reasoning_content,signature:""};if(typeof $.reasoning==="string"&&$.reasoning)return{thinking:$.reasoning,signature:""};let J=$.thinking_blocks;if(Array.isArray(J)&&J.length>0){let Q=J[0];if(Q.type==="thinking"){let X=Q.thinking||"",Z=Q.signature||"";if(X||Z)return{thinking:X,signature:Z}}}return null}function x5($,J){if($.tool_calls&&$.tool_calls.length>0){let X=$.tool_calls[0];return{type:"tool_use",isNew:J.currentBlockType!=="tool_use"||!!X.function?.name}}if($.content!=null&&$.content!=="")return{type:"text",isNew:J.currentBlockType!=="text"||!J.blockStartSent};if(nX($))return{type:"thinking",isNew:J.currentBlockType!=="thinking"||!J.blockStartSent};return null}function I5($,J){let Q=$.choices?.[0];if(!Q){if($.usage&&J.heldMessageDelta)A5(J,$.usage);return}J.model=$.model||J.model,mX(J,$.id);let X=Q.delta,Z=x5(X,J);if(Z){if(Z.isNew&&J.blockStartSent&&!J.blockStopSent){if(J.currentBlockType==="tool_use"&&Z.type!=="tool_use")cX(J);else if(J.currentBlockType!=="tool_use")dX(J)}switch(Z.type){case"thinking":T5(X,J);break;case"text":M5(X,J);break;case"tool_use":P5(X,J);break}}if(Q.finish_reason)E5(Q.finish_reason,$,J)}function T5($,J){let Q=nX($);if(!Q)return;if(J.currentBlockType!=="thinking"||!J.blockStartSent)uX(J,"thinking",{type:"thinking",thinking:""});if(Q.thinking)a2(J,J.currentBlockIndex,{type:"thinking_delta",thinking:Q.thinking});if(Q.signature)a2(J,J.currentBlockIndex,{type:"signature_delta",signature:Q.signature})}function M5($,J){if($.content==null||$.content==="")return;if(J.currentBlockType!=="text"||!J.blockStartSent)uX(J,"text",{type:"text",text:""});a2(J,J.currentBlockIndex,{type:"text_delta",text:$.content})}function P5($,J){if(!$.tool_calls)return;for(let Q of $.tool_calls){let X=Q.index;if(!J.toolBlocks.has(X))J.toolBlocks.set(X,{id:"",name:"",argsBuffer:"",started:!1,anthropicIndex:-1});let Z=J.toolBlocks.get(X);if(Q.id)Z.id=Q.id;if(Q.function?.name)Z.name+=Q.function.name;let q=L$(Q.function?.arguments);if(q)Z.argsBuffer+=q;if(!Z.started&&Z.id&&Z.name){if(Z.started=!0,Z.anthropicIndex=J.nextContentIndex++,J.currentBlockType="tool_use",J.currentBlockIndex=Z.anthropicIndex,J.blockStartSent=!0,J.blockStopSent=!1,w1(J,"content_block_start",{type:"content_block_start",index:Z.anthropicIndex,content_block:{type:"tool_use",id:Z.id,name:Z.name,input:{}}}),Z.argsBuffer)a2(J,Z.anthropicIndex,{type:"input_json_delta",partial_json:Z.argsBuffer})}else if(Z.started&&q)a2(J,Z.anthropicIndex,{type:"input_json_delta",partial_json:q})}}function E5($,J,Q){if(Q.messageDeltaSent)return;lX(Q);let X=C5($),Z=J.usage?{output_tokens:J.usage.completion_tokens||0}:{output_tokens:0},q={event:"message_delta",data:{type:"message_delta",delta:{stop_reason:X,stop_sequence:null},usage:Z}};if(J.usage)Q.messageDeltaSent=!0,Q.queue.push(q);else Q.heldMessageDelta=q}function A5($,J){if(!$.heldMessageDelta)return;let Q=$.heldMessageDelta.data;Q.usage={output_tokens:J.completion_tokens||0},$.messageDeltaSent=!0,$.queue.push($.heldMessageDelta),$.heldMessageDelta=null}function pX($){if($.messageStopSent)return;if($.messageStopSent=!0,mX($),lX($),$.heldMessageDelta&&!$.messageDeltaSent)$.messageDeltaSent=!0,$.queue.push($.heldMessageDelta),$.heldMessageDelta=null;if(!$.messageDeltaSent)$.messageDeltaSent=!0,w1($,"message_delta",{type:"message_delta",delta:{stop_reason:"end_turn",stop_sequence:null},usage:{output_tokens:0}});w1($,"message_stop",{type:"message_stop"})}function C5($){switch($){case"stop":return"end_turn";case"tool_calls":return"tool_use";case"length":return"max_tokens";case"content_filter":return"end_turn";default:return"end_turn"}}var iX=U(()=>{s2()});import{randomUUID as j5}from"crypto";function aX(){return!!PJ()?.gatewayApiKey}function tX($,J){let Q=$??globalThis.fetch;return async(X,Z)=>{let q=X instanceof Request?new URL(X.url):new URL(String(X));if(!q.pathname.endsWith("/v1/messages"))return Q(X,Z);let Y=PJ();if(!Y?.gatewayApiKey)throw Error("UnieAI Studio gateway credentials are missing. Run `unieai login` again.");let W=await y5(X,Z),K=Y.availableModelIds??[];if(!K.includes(W.model)){let k=n2();if(typeof k==="string"&&K.includes(k))W.model=k;else if(K.length>0)W.model=K[0]}let B=process.env.UNIEAI_GATEWAY_URL?.trim(),w=(B?oX(B):Y.gatewayBaseURL??rX).replace(/\/$/,""),H=yX(W),z=new Headers;z.set("Content-Type","application/json"),z.set("Accept",H.stream?"text/event-stream":"application/json"),z.set("Authorization",`Bearer ${Y.gatewayApiKey}`),L(`[API REQUEST] ${q.pathname} routed_to=UnieAI/Studio model=${W.model} source=${J??"unknown"} request_id=${j5()}`);let _=await Q(`${w}/chat/completions`,{method:"POST",headers:z,body:JSON.stringify(H),signal:Z?.signal});if(!_.ok){let k=await _.text().catch(()=>"");return Response.json({type:"error",error:{type:"api_error",message:`UnieAI Studio gateway returned HTTP ${_.status}: ${k.slice(0,500)}`}},{status:_.status})}if(H.stream){if(!_.body)return Response.json({type:"error",error:{type:"api_error",message:"UnieAI Studio gateway returned no body for stream"}},{status:502});return new Response(gX(_.body,W.model),{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}let M=await _.json();return Response.json(fX(M,W.model))}}async function y5($,J){let Q=J?.body;if(typeof Q==="string")return JSON.parse(Q);if(Q instanceof Uint8Array||Q instanceof ArrayBuffer)return JSON.parse(Buffer.from(Q).toString("utf8"));if($ instanceof Request)return await $.clone().json();throw Error("Unable to read Anthropic request body for UnieAI Studio routing")}var sX="unieai-studio-dummy-key";var eX=U(()=>{SX();hX();iX();p();u0();k5();v5()});import S5 from"@anthropic-ai/sdk";import{randomUUID as f5}from"crypto";function w$(){return{error:($,...J)=>console.error("[Anthropic SDK ERROR]",$,...J),warn:($,...J)=>console.error("[Anthropic SDK WARN]",$,...J),info:($,...J)=>console.error("[Anthropic SDK INFO]",$,...J),debug:($,...J)=>console.error("[Anthropic SDK DEBUG]",$,...J)}}function b5({explicitApiKey:$,envAuthToken:J=process.env.ANTHROPIC_AUTH_TOKEN,envApiKey:Q=process.env.ANTHROPIC_API_KEY,getFallbackApiKey:X=U0}){if(J&&!$&&!Q)return null;return $||X()}function h5({hasOpenAIAuth:$,isClaudeSubscriber:J,forceOpenAICodex:Q,isOpenAIModel:X,hasAnthropicAuthToken:Z,hasExplicitApiKey:q,hasFallbackApiKey:Y}){return $&&(!J||Q)&&(X||!Z&&!q&&!Y)}async function QZ({apiKey:$,maxRetries:J,model:Q,fetchOverride:X,source:Z}){let q=process.env.CLAUDE_CODE_CONTAINER_ID,Y=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,W=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,K=g5(),B={"x-app":"cli","User-Agent":ZZ(),"X-Claude-Code-Session-Id":A0(),...K,...q?{"x-claude-remote-container-id":q}:{},...Y?{"x-claude-remote-session-id":Y}:{},...W?{"x-client-app":W}:{}};if(L(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!K.Authorization}`),R(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION))B["x-anthropic-additional-protection"]="true";L("[API:auth] OAuth token check starting"),await A1(),L("[API:auth] OAuth token check complete");let H=Q?QJ(Q):!1,z=aX(),_=y(),M=R(process.env.CC_HAHA_OPENAI_OAUTH_PROVIDER),k=kX(),F1=k&&!process.env.ANTHROPIC_AUTH_TOKEN&&!$&&!!U0(),z1=!z&&h5({hasOpenAIAuth:k,isClaudeSubscriber:_,forceOpenAICodex:M,isOpenAIModel:H,hasAnthropicAuthToken:!!process.env.ANTHROPIC_AUTH_TOKEN,hasExplicitApiKey:!!$,hasFallbackApiKey:F1});if(!_&&!z1&&!z)await p5(B,u());let O2=z?tX(X,Z):z1?vX(X,Z):m5(X,Z),x1={defaultHeaders:B,maxRetries:J,timeout:parseInt(process.env.API_TIMEOUT_MS||String(600000),10),dangerouslyAllowBrowser:!0,fetchOptions:JZ({forAnthropicAPI:!0}),...O2&&{fetch:O2}};if(R(process.env.CLAUDE_CODE_USE_BEDROCK)){let{AnthropicBedrock:I1}=await import("@anthropic-ai/bedrock-sdk"),h=Q===mQ()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:y2(),L0={...x1,awsRegion:h,...R(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...t2()&&{logger:w$()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)L0.skipAuth=!0,L0.defaultHeaders={...L0.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!R(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let t0=await G1();if(t0)L0.awsAccessKey=t0.accessKeyId,L0.awsSecretKey=t0.secretAccessKey,L0.awsSessionToken=t0.sessionToken}return new I1(L0)}if(R(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:I1}=await import("@anthropic-ai/foundry-sdk"),h;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(R(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))h=()=>Promise.resolve("");else{let{DefaultAzureCredential:t0,getBearerTokenProvider:Y8}=await import("@azure/identity");h=Y8(new t0,"https://cognitiveservices.azure.com/.default")}let L0={...x1,...h&&{azureADTokenProvider:h},...t2()&&{logger:w$()}};return new I1(L0)}if(R(process.env.CLAUDE_CODE_USE_VERTEX)){if(!R(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH))await e2();let[{AnthropicVertex:I1},{GoogleAuth:h}]=await Promise.all([import("@anthropic-ai/vertex-sdk"),import("google-auth-library")]),L0=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,t0=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,Y8=R(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new h({scopes:["https://www.googleapis.com/auth/cloud-platform"],...L0||t0?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}}),iY={...x1,region:$Z(Q),googleAuth:Y8,...t2()&&{logger:w$()}};return new I1(iY)}let q8={apiKey:z?sX:z1?CX:_?null:b5({explicitApiKey:$}),authToken:!z&&_&&!z1?C()?.accessToken:void 0,...process.env.USER_TYPE==="ant"&&R(process.env.USE_STAGING_OAUTH)?{baseURL:f().BASE_API_URL}:{},...x1,...t2()&&{logger:w$()}};return new S5(q8)}async function p5($,J){let Q=process.env.ANTHROPIC_AUTH_TOKEN||await _$(J);if(Q)$.Authorization=`Bearer ${Q}`}function g5(){let $={},J=process.env.ANTHROPIC_CUSTOM_HEADERS;if(!J)return $;let Q=J.split(/\n|\r\n/);for(let X of Q){if(!X.trim())continue;let Z=X.indexOf(":");if(Z===-1)continue;let q=X.slice(0,Z).trim(),Y=X.slice(Z+1).trim();if(q)$[q]=Y}return $}function m5($,J){let Q=$??globalThis.fetch,X=P()==="firstParty"&&f0();return(Z,q)=>{let Y=new Headers(q?.headers);if(X&&!Y.has(R$))Y.set(R$,f5());try{let W=Z instanceof Request?Z.url:String(Z),K=Y.get(R$);L(`[API REQUEST] ${new URL(W).pathname}${K?` ${R$}=${K}`:""} source=${J??"unknown"}`)}catch{}return Q(Z,{...q,headers:Y,body:QX(q?.body)})}}var R$="x-client-request-id";var XZ=U(()=>{e();ZX();N$();u0();b0();L9();n();T0();jX();m2();eX();p();j()});import{readFileSync as u5}from"fs";import{mkdir as d5,writeFile as c5}from"fs/promises";import l5 from"lodash-es/isEqual.js";import n5 from"lodash-es/memoize.js";import{join as qZ}from"path";import{z as f1}from"zod/v4";function WZ(){return qZ(b(),"cache")}function VZ(){return qZ(WZ(),"model-capabilities.json")}function GZ(){if(process.env.USER_TYPE!=="ant")return!1;if(P()!=="firstParty")return!1;if(!f0())return!1;return!0}function r5($){return[...$].sort((J,Q)=>Q.id.length-J.id.length||J.id.localeCompare(Q.id))}function AJ($){if(!GZ())return;let J=EJ(VZ());if(!J||J.length===0)return;let Q=$.toLowerCase(),X=J.find((Z)=>Z.id.toLowerCase()===Q);if(X)return X;return J.find((Z)=>Q.includes(Z.id.toLowerCase()))}async function iN(){if(!GZ())return;if(J$())return;try{let $=await QZ({maxRetries:1}),J=y()?[P0]:void 0,Q=[];for await(let q of $.models.list({betas:J})){let Y=YZ().safeParse(q);if(Y.success)Q.push(Y.data)}if(Q.length===0)return;let X=VZ(),Z=r5(Q);if(l5(EJ(X),Z)){L("[modelCapabilities] cache unchanged, skipping write");return}await d5(WZ(),{recursive:!0}),await c5(X,A({models:Z,timestamp:Date.now()}),{encoding:"utf-8",mode:384}),EJ.cache.delete(X),L(`[modelCapabilities] cached ${Z.length} models`)}catch($){L(`[modelCapabilities] fetch failed: ${$ instanceof Error?$.message:"unknown"}`)}}var YZ,i5,EJ;var KZ=U(()=>{T0();XZ();e();p();j();k2();b1();y4();X0();b0();YZ=D(()=>f1.object({id:f1.string(),max_input_tokens:f1.number().optional(),max_tokens:f1.number().optional()}).strip()),i5=D(()=>f1.object({models:f1.array(YZ()),timestamp:f1.number()}));EJ=n5(($)=>{try{let J=u5($,"utf-8"),Q=i5().safeParse(V0(J,!1));return Q.success?Q.data.models:null}catch{return null}},($)=>$)});function CJ($){return $.trim().replace(/\[1m\]$/i,"").replace(/:1m$/i,"").toLowerCase()}function a5($){if(typeof $!=="number"||!Number.isInteger($))return;if($<16000||$>1e7)return;return $}function t5(){let $=process.env.CLAUDE_CODE_MODEL_CONTEXT_WINDOWS;if(!$?.trim())return{};try{let J=JSON.parse($);if(!J||typeof J!=="object"||Array.isArray(J))return{};let Q={};for(let[X,Z]of Object.entries(J)){let q=a5(Z);if(q!==void 0)Q[CJ(X)]=q}return Q}catch{return{}}}function e5($){let J=t5(),Q=CJ($),X=J[Q];if(X!==void 0)return X;for(let[Z,q]of Object.entries(J))if(Q.endsWith(`/${Z}`)||Q.endsWith(`:${Z}`))return q;return}function $V($){let J=CJ($),Q=o5[J];if(Q!==void 0)return Q;for(let[X,Z]of s5)if(X.test(J))return Z;return}function BZ($){return e5($)??$V($)}var oN="CLAUDE_CODE_MODEL_CONTEXT_WINDOWS",o5,s5;var LZ=U(()=>{o5={"claude-opus-4-7":1e6,"claude-sonnet-4-6":200000,"claude-haiku-4-5":200000,"deepseek-v4-pro":1e6,"deepseek-v4-flash":1e6,"deepseek-chat":1e6,"deepseek-reasoner":1e6,"kimi-k2.6":262144,"kimi-k2.5":262144,"kimi-k2-0905-preview":262144,"kimi-k2-turbo-preview":262144,"kimi-k2-thinking":262144,"kimi-k2-thinking-turbo":262144,"minimax-m2.7":204800,"minimax-m2.7-highspeed":204800,"minimax-m2.5":204800,"minimax-m2.5-highspeed":204800,"minimax-m2.1":204800,"minimax-m2.1-highspeed":204800,"minimax-m2":204800,"glm-5.1":200000,"glm-5":200000,"glm-5-turbo":200000,"glm-4.7":200000,"glm-4.6":200000,"glm-4.5":128000,"glm-4.5-air":128000},s5=[[/^anthropic\/claude-opus-4\.7\b/i,1e6],[/^anthropic\/claude-sonnet-4\.6\b/i,200000],[/^anthropic\/claude-haiku-4\.5\b/i,200000],[/^openai\/gpt-4\.1\b/i,1047576],[/^openai\/gpt-5(?:[.-]\d+)?\b/i,400000],[/^google\/gemini-(?:2\.0|2\.5|3)/i,1048576],[/^gemini-(?:2\.0|2\.5|3)/i,1048576],[/^qwen\/qwen3\.5-(?:plus|flash)\b/i,1e6],[/^qwen3\.5-(?:plus|flash)\b/i,1e6],[/^qwen\/qwen3-max\b/i,262144],[/^qwen3-max\b/i,262144],[/qwen-long/i,1e7]]});function j1(){return R(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function E0($){if(j1())return!1;return/\[1m\]/i.test($)||/:1m$/i.test($)}function KJ($){if(j1())return!1;let J=Q0($);return J.includes("claude-sonnet-4")||J.includes("opus-4-6")}function WD($,J){if(process.env.USER_TYPE==="ant"&&process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS){let q=parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS,10);if(!isNaN(q)&&q>0)return q}if(E0($))return 1e6;let Q=BZ($);if(Q!==void 0){if(Q>$4&&j1())return $4;return Q}let X=wQ($);if(X)return X;let Z=AJ($);if(Z?.max_input_tokens&&Z.max_input_tokens>=1e5){if(Z.max_input_tokens>$4&&j1())return $4;return Z.max_input_tokens}if(J?.includes(g2)&&KJ($))return 1e6;if(JV($))return 1e6;if(process.env.USER_TYPE==="ant"){let q=resolveAntModel($);if(q?.contextWindow)return q.contextWindow}return $4}function JV($){if(j1())return!1;if(E0($))return!1;if(!Q0($).includes("sonnet-4-6"))return!1;return I().clientDataCache?.coral_reef_sonnet==="true"}function VD($,J){if(!$)return{used:null,remaining:null};let Q=$.input_tokens+$.cache_creation_input_tokens+$.cache_read_input_tokens,X=Math.round(Q/J*100),Z=Math.min(100,Math.max(0,X));return{used:Z,remaining:100-Z}}function GD($,J,Q){if(!J)return $;let X=J.input_tokens+J.cache_creation_input_tokens+J.cache_read_input_tokens+(J.output_tokens??0),Z=Math.max($,X);return Q!==void 0?Math.min(Z,Q):Z}function QV($){let J,Q;if(process.env.USER_TYPE==="ant"){let q=resolveAntModel($.toLowerCase());if(q)return J=q.defaultMaxTokens??UZ,Q=q.upperMaxTokensLimit??HZ,{default:J,upperLimit:Q}}let X=Q0($);if(X.includes("opus-4-6"))J=64000,Q=128000;else if(X.includes("sonnet-4-6"))J=32000,Q=128000;else if(X.includes("opus-4-5")||X.includes("sonnet-4")||X.includes("haiku-4"))J=32000,Q=64000;else if(X.includes("opus-4-1")||X.includes("opus-4"))J=32000,Q=32000;else if(X.includes("claude-3-opus"))J=4096,Q=4096;else if(X.includes("claude-3-sonnet"))J=8192,Q=8192;else if(X.includes("claude-3-haiku"))J=4096,Q=4096;else if(X.includes("3-5-sonnet")||X.includes("3-5-haiku"))J=8192,Q=8192;else if(X.includes("3-7-sonnet"))J=32000,Q=64000;else J=UZ,Q=HZ;let Z=AJ($);if(Z?.max_tokens&&Z.max_tokens>=4096)Q=Z.max_tokens,J=Math.min(J,Q);return{default:J,upperLimit:Q}}function KD($){return QV($).upperLimit-1}var $4=200000,ZD=20000,UZ=32000,HZ=64000,qD=8000,YD=64000;var BJ=U(()=>{JJ();m2();D0();j();u0();KZ();LZ()});import XV from"lodash-es/memoize.js";var ZV,wZ;var RZ=U(()=>{b0();ZV=[{modelEnvVar:"ANTHROPIC_DEFAULT_OPUS_MODEL",capabilitiesEnvVar:"ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES"},{modelEnvVar:"ANTHROPIC_DEFAULT_SONNET_MODEL",capabilitiesEnvVar:"ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES"},{modelEnvVar:"ANTHROPIC_DEFAULT_HAIKU_MODEL",capabilitiesEnvVar:"ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES"}],wZ=XV(($,J)=>{if(P()==="firstParty"&&f0())return;let Q=$.toLowerCase();for(let X of ZV){let Z=process.env[X.modelEnvVar],q=process.env[X.capabilitiesEnvVar];if(!Z||q===void 0)continue;if(Q!==Z.toLowerCase())continue;return q.toLowerCase().split(",").map((Y)=>Y.trim()).includes(J)}return},($,J)=>`${$.toLowerCase()}:${J}`)});import kJ from"lodash-es/memoize.js";function qV($){let J=[],Q=[];for(let X of $)if(OZ.includes(X))J.push(X);else Q.push(X);return{allowed:J,disallowed:Q}}function ED($){if(!$||$.length===0)return;if(y()){console.warn("Warning: Custom betas are only available for API key users. Ignoring provided betas.");return}let{allowed:J,disallowed:Q}=qV($);for(let X of Q)console.warn(`Warning: Beta header '${X}' is not allowed. Only the following betas are supported: ${OZ.join(", ")}`);return J.length>0?J:void 0}function _Z($){let J=wZ($,"interleaved_thinking");if(J!==void 0)return J;let Q=Q0($),X=P();if(X==="foundry")return!0;if(X==="firstParty")return!Q.includes("claude-3-");return Q.includes("claude-opus-4")||Q.includes("claude-sonnet-4")}function YV($){let J=Q0($);return J.includes("claude-opus-4")||J.includes("claude-sonnet-4")||J.includes("claude-haiku-4")}function WV($){let J=Q0($),Q=P();if(Q==="foundry")return!0;if(Q==="firstParty")return!J.includes("claude-3-");return J.includes("claude-opus-4")||J.includes("claude-sonnet-4")||J.includes("claude-haiku-4")}function VV($){let J=Q0($),Q=P();if(Q!=="firstParty"&&Q!=="foundry")return!1;return J.includes("claude-sonnet-4-6")||J.includes("claude-sonnet-4-5")||J.includes("claude-opus-4-1")||J.includes("claude-opus-4-5")||J.includes("claude-opus-4-7")||J.includes("claude-haiku-4-5")}function AD($){return!1}function CD(){let $=P();if($==="vertex"||$==="bedrock")return BQ;return KQ}function NZ(){return(P()==="firstParty"||P()==="foundry")&&(P()!=="firstParty"||f0())&&!R(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function kD(){return P()==="firstParty"&&!R(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function vD($,J){if(P()==="firstParty"&&!f0())return[];let Q=[...D$($)];if(J?.isAgenticQuery){if(!Q.includes(e4))Q.push(e4);if(process.env.USER_TYPE==="ant"&&process.env.CLAUDE_CODE_ENTRYPOINT==="cli"&&J2&&!Q.includes(J2))Q.push(J2)}let X=DZ();if(!X||X.length===0)return Q;return[...Q,...X.filter((Z)=>!Q.includes(Z))]}function FZ(){vJ.cache?.clear?.(),D$.cache?.clear?.(),GV.cache?.clear?.()}var OZ,vJ,D$,GV;var jJ=U(()=>{Q1();n();JJ();T0();e();BJ();j();u0();RZ();b0();J1();OZ=[g2];vJ=kJ(($)=>{let J=[],Q=Q0($).includes("haiku"),X=P(),Z=NZ();if(!Q){if(J.push(e4),process.env.USER_TYPE==="ant"&&process.env.CLAUDE_CODE_ENTRYPOINT==="cli"){if(J2)J.push(J2)}}if(y())J.push(P0);if(E0($))J.push(g2);if(!R(process.env.DISABLE_INTERLEAVED_THINKING)&&_Z($))J.push(WQ);if(Z&&_Z($)&&!u()&&_0().showThinkingSummaries!==!0)J.push(UQ);if(e8&&process.env.USER_TYPE==="ant"&&Z&&!P4(process.env.USE_CONNECTOR_TEXT_SUMMARIZATION)&&(R(process.env.USE_CONNECTOR_TEXT_SUMMARIZATION)||Z0("tengu_slate_prism",!1)))J.push(e8);let q=R(process.env.USE_API_CONTEXT_MANAGEMENT)&&process.env.USER_TYPE==="ant",Y=WV($);if(NZ()&&(q||Y))J.push(VQ);let W=zZ("tengu_tool_pear"),K=!W&&Z0("tengu_amber_json_tools",!1);if(Z&&VV($)&&W)J.push(GQ);if(process.env.USER_TYPE==="ant"&&Z&&K)J.push(HQ);if(X==="vertex"&&YV($))J.push(t8);if(X==="foundry")J.push(t8);if(Z)J.push(LQ);if(process.env.ANTHROPIC_BETAS)J.push(...process.env.ANTHROPIC_BETAS.split(",").map((B)=>B.trim()).filter(Boolean));return J}),D$=kJ(($)=>{let J=vJ($);if(P()==="bedrock")return J.filter((Q)=>!$J.has(Q));return J}),GV=kJ(($)=>{return vJ($).filter((Q)=>$J.has(Q))})});import{execFile as KV}from"child_process";function xZ($){return new Promise((J)=>{KV("security",["find-generic-password","-a",h0(),"-w","-s",$],{encoding:"utf-8",timeout:BV},(Q,X)=>{J({stdout:Q?null:X?.trim()||null,timedOut:Boolean(Q&&"killed"in Q&&Q.killed)})})})}function bD(){if(process.platform!=="darwin"||O$||C0())return;let $=xZ(G0(P1)),J=xZ(G0());O$=Promise.all([$,J]).then(([Q,X])=>{if(!Q.timedOut)C9(Q.stdout);if(!X.timedOut)yJ={stdout:X.stdout}})}async function hD(){if(O$)await O$}function IZ(){return yJ}function SJ(){yJ=null}var BV=1e4,yJ=null,O$=null;var TZ=U(()=>{j();f2()});function gD(){return MZ}function PZ(){MZ.clear()}var MZ;var EZ=U(()=>{MZ=new Map});var $G={};LV($G,{validateForceLoginOrg:()=>eV,saveOAuthTokensIfNeeded:()=>cZ,saveApiKey:()=>r8,removeApiKey:()=>bV,refreshGcpCredentialsIfNeeded:()=>e2,refreshGcpAuth:()=>uZ,refreshAwsAuth:()=>gZ,refreshAndGetAwsCredentials:()=>G1,prefetchGcpCredentialsIfSafe:()=>jV,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>yV,prefetchApiKeyFromApiKeyHelperIfSafe:()=>zV,isUsing3PServices:()=>M$,isTeamSubscriber:()=>cV,isTeamPremiumSubscriber:()=>V$,isProSubscriber:()=>LJ,isOverageProvisioningAllowed:()=>uV,isOtelHeadersHelperFromProjectOrLocalSettings:()=>iZ,isOpenAIAuthActive:()=>y1,isMaxSubscriber:()=>W$,isGcpAuthRefreshFromProjectSettings:()=>nJ,isEnterpriseSubscriber:()=>lV,isCustomApiKeyApproved:()=>fV,isConsumerSubscriber:()=>oV,isClaudeAISubscriber:()=>y,isAwsCredentialExportFromProjectSettings:()=>cJ,isAwsAuthRefreshFromProjectSettings:()=>uJ,isAnthropicAuthEnabled:()=>Y2,is1PApiCustomer:()=>mV,hasProfileScope:()=>g0,hasOpusAccess:()=>dV,hasOpenAIAuthLogin:()=>aV,hasAnthropicApiKeyAuth:()=>NV,handleOAuth401Error:()=>c2,getSubscriptionType:()=>d,getSubscriptionName:()=>lZ,getRateLimitTier:()=>T$,getOtelHeadersFromHelper:()=>iV,getOpenAISubscriptionName:()=>rZ,getOpenAIAuthOverrideWarning:()=>sV,getOauthAccountInfo:()=>_1,getConfiguredApiKeyHelper:()=>R1,getClaudeAIOAuthTokensAsync:()=>Q4,getClaudeAIOAuthTokens:()=>C,getAuthTokenSource:()=>M1,getApiKeyHelperElapsedMs:()=>DV,getApiKeyFromConfigOrMacOSKeychain:()=>x$,getApiKeyFromApiKeyHelperCached:()=>bJ,getApiKeyFromApiKeyHelper:()=>_$,getAnthropicApiKeyWithSource:()=>h1,getAnthropicApiKey:()=>U0,getAccountInformation:()=>tV,clearStoredClaudeAIOAuthTokens:()=>hV,clearOAuthTokenCache:()=>I$,clearGcpCredentialsCache:()=>vV,clearAwsCredentialsCache:()=>PV,clearApiKeyHelperCache:()=>FV,checkGcpCredentialsValid:()=>mZ,checkAndRefreshOAuthTokenIfNeeded:()=>A1,calculateApiKeyHelperTTL:()=>pZ});import k0 from"chalk";import{exec as fZ}from"child_process";import{execa as gJ}from"execa";import{mkdir as HV,stat as wV}from"fs/promises";import bZ from"lodash-es/memoize.js";import{join as RV}from"path";function z$(){return R(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT==="claude-desktop"}function Y2(){if(C0())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let $=R(process.env.CLAUDE_CODE_USE_BEDROCK)||R(process.env.CLAUDE_CODE_USE_VERTEX)||R(process.env.CLAUDE_CODE_USE_FOUNDRY)||R(process.env.CLAUDE_CODE_USE_AZURE_OPENAI),Q=(z0()||{}).apiKeyHelper,X=process.env.ANTHROPIC_AUTH_TOKEN||Q||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:Z}=h1({skipRetrievingKeyFromApiKeyHelper:!0}),q=Z==="ANTHROPIC_API_KEY"||Z==="apiKeyHelper";return!($||X&&!z$()||q&&!z$())}function M1(){if(C0()){if(R1())return{source:"apiKeyHelper",hasToken:!0};return{source:"none",hasToken:!1}}if(process.env.ANTHROPIC_AUTH_TOKEN&&!z$())return{source:"ANTHROPIC_AUTH_TOKEN",hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:"CLAUDE_CODE_OAUTH_TOKEN",hasToken:!0};if(a4()){if(process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)return{source:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",hasToken:!0};return{source:"CCR_OAUTH_TOKEN_FILE",hasToken:!0}}if(R1()&&!z$())return{source:"apiKeyHelper",hasToken:!0};let Q=C();if(L1(Q?.scopes)&&Q?.accessToken)return{source:"claude.ai",hasToken:!0};return{source:"none",hasToken:!1}}function U0(){let{key:$}=h1();return $}function NV(){let{key:$,source:J}=h1({skipRetrievingKeyFromApiKeyHelper:!0});return $!==null&&J!=="none"}function h1($={}){if(C0()){if(process.env.ANTHROPIC_API_KEY)return{key:process.env.ANTHROPIC_API_KEY,source:"ANTHROPIC_API_KEY"};if(R1())return{key:$.skipRetrievingKeyFromApiKeyHelper?null:bJ(),source:"apiKeyHelper"};return{key:null,source:"none"}}let J=vZ()?void 0:process.env.ANTHROPIC_API_KEY;if($$()&&J)return{key:J,source:"ANTHROPIC_API_KEY"};if(R(process.env.CI)){let q=o8();if(q)return{key:q,source:"ANTHROPIC_API_KEY"};if(!J&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error("ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required");if(J)return{key:J,source:"ANTHROPIC_API_KEY"};return{key:null,source:"none"}}if(J&&I().customApiKeyResponses?.approved?.includes(t4(J)))return{key:J,source:"ANTHROPIC_API_KEY"};let Q=o8();if(Q)return{key:Q,source:"ANTHROPIC_API_KEY"};if(R1()){if($.skipRetrievingKeyFromApiKeyHelper)return{key:null,source:"apiKeyHelper"};return{key:bJ(),source:"apiKeyHelper"}}let Z=x$();if(Z)return Z;return{key:null,source:"none"}}function R1(){if(C0())return S("flagSettings")?.apiKeyHelper;return(z0()||{}).apiKeyHelper}function hZ(){let $=R1();if(!$)return!1;let J=S("projectSettings"),Q=S("localSettings");return J?.apiKeyHelper===$||Q?.apiKeyHelper===$}function mJ(){return(z0()||{}).awsAuthRefresh}function uJ(){let $=mJ();if(!$)return!1;let J=S("projectSettings"),Q=S("localSettings");return J?.awsAuthRefresh===$||Q?.awsAuthRefresh===$}function dJ(){return(z0()||{}).awsCredentialExport}function cJ(){let $=dJ();if(!$)return!1;let J=S("projectSettings"),Q=S("localSettings");return J?.awsCredentialExport===$||Q?.awsCredentialExport===$}function pZ(){let $=process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;if($){let J=parseInt($,10);if(!Number.isNaN(J)&&J>=0)return J;L(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${$}`,{level:"error"})}return _V}function DV(){let $=c0?.startedAt;return $?Date.now()-$:0}async function _$($){if(!R1())return null;let J=pZ();if(B0){if(Date.now()-B0.timestamp<J)return B0.value;if(!c0)c0={promise:AZ($,!1,q2),startedAt:null};return B0.value}if(c0)return c0.promise;return c0={promise:AZ($,!0,q2),startedAt:Date.now()},c0.promise}async function AZ($,J,Q){try{let X=await OV($);if(Q!==q2)return X;if(X!==null)B0={value:X,timestamp:Date.now()};return X}catch(X){if(Q!==q2)return" ";let Z=X instanceof Error?X.message:String(X);if(console.error(k0.red(`apiKeyHelper failed: ${Z}`)),L(`Error getting API key from apiKeyHelper: ${Z}`,{level:"error"}),!J&&B0&&B0.value!==" ")return B0={...B0,timestamp:Date.now()},B0.value;return B0={value:" ",timestamp:Date.now()}," "}finally{if(Q===q2)c0=null}}async function OV($){let J=R1();if(!J)return null;if(hZ()){if(!t()&&!$){let q=Error(`Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`);return X4("apiKeyHelper invoked before trust check",q),F("tengu_apiKeyHelper_missing_trust11",{}),null}}let Q=await gJ(J,{shell:!0,timeout:600000,reject:!1});if(Q.failed){let Z=Q.timedOut?"timed out":`exited ${Q.exitCode}`,q=Q.stderr?.trim();throw Error(q?`${Z}: ${q}`:Z)}let X=Q.stdout?.trim();if(!X)throw Error("did not return a value");return X}function bJ(){return B0?.value??null}function FV(){q2++,B0=null,c0=null}function zV($){if(hZ()&&!t())return;_$($)}async function IV(){let $=mJ();if(!$)return!1;if(uJ()){if(!t()&&!u()){let Q=Error(`Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`);return X4("awsAuthRefresh invoked before trust check",Q),F("tengu_awsAuthRefresh_missing_trust",{}),!1}}try{return L("Fetching AWS caller identity for AWS auth refresh command"),await s8(),L("Fetched AWS caller identity, skipping AWS auth refresh command"),!1}catch{return gZ($)}}function gZ($){L("Running AWS auth refresh command");let J=O0.getInstance();return J.startAuthentication(),new Promise((Q)=>{let X=fZ($,{timeout:TV});X.stdout.on("data",(Z)=>{let q=Z.toString().trim();if(q)J.addOutput(q),L(q,{level:"debug"})}),X.stderr.on("data",(Z)=>{let q=Z.toString().trim();if(q)J.setError(q),L(q,{level:"error"})}),X.on("close",(Z,q)=>{if(Z===0)L("AWS auth refresh completed successfully"),J.endAuthentication(!0),Q(!0);else{let W=q==="SIGTERM"?k0.red("AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal."):k0.red("Error running awsAuthRefresh (in settings or ~/.claude.json):");console.error(W),J.endAuthentication(!1),Q(!1)}})})}async function MV(){let $=dJ();if(!$)return null;if(cJ()){if(!t()&&!u()){let Q=Error(`Security: awsCredentialExport executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`);return X4("awsCredentialExport invoked before trust check",Q),F("tengu_awsCredentialExport_missing_trust",{}),null}}try{return L("Fetching AWS caller identity for credential export command"),await s8(),L("Fetched AWS caller identity, skipping AWS credential export command"),null}catch{try{L("Running AWS credential export command");let J=await gJ($,{shell:!0,reject:!1});if(J.exitCode!==0||!J.stdout)throw Error("awsCredentialExport did not return a valid value");let Q=a(J.stdout.trim());if(!XQ(Q))throw Error("awsCredentialExport did not return valid AWS STS output structure");return L("AWS credentials retrieved from awsCredentialExport"),{accessKeyId:Q.Credentials.AccessKeyId,secretAccessKey:Q.Credentials.SecretAccessKey,sessionToken:Q.Credentials.SessionToken}}catch(J){let Q=k0.red("Error getting AWS credentials from awsCredentialExport (in settings or ~/.claude.json):");if(J instanceof Error)console.error(Q,J.message);else console.error(Q,J);return null}}}function PV(){G1.cache.clear()}function lJ(){return(z0()||{}).gcpAuthRefresh}function nJ(){let $=lJ();if(!$)return!1;let J=S("projectSettings"),Q=S("localSettings");return J?.gcpAuthRefresh===$||Q?.gcpAuthRefresh===$}async function mZ(){try{let{GoogleAuth:$}=await import("google-auth-library"),J=new $({scopes:["https://www.googleapis.com/auth/cloud-platform"]}),Q=(async()=>{await(await J.getClient()).getAccessToken()})(),X=Z4(EV).then(()=>{throw new sZ("GCP credentials check timed out")});return await Promise.race([Q,X]),!0}catch{return!1}}async function CV(){let $=lJ();if(!$)return!1;if(nJ()){if(!t()&&!u()){let Q=Error(`Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`);return X4("gcpAuthRefresh invoked before trust check",Q),F("tengu_gcpAuthRefresh_missing_trust",{}),!1}}try{if(L("Checking GCP credentials validity for auth refresh"),await mZ())return L("GCP credentials are valid, skipping auth refresh command"),!1}catch{}return uZ($)}function uZ($){L("Running GCP auth refresh command");let J=O0.getInstance();return J.startAuthentication(),new Promise((Q)=>{let X=fZ($,{timeout:kV});X.stdout.on("data",(Z)=>{let q=Z.toString().trim();if(q)J.addOutput(q),L(q,{level:"debug"})}),X.stderr.on("data",(Z)=>{let q=Z.toString().trim();if(q)J.setError(q),L(q,{level:"error"})}),X.on("close",(Z,q)=>{if(Z===0)L("GCP auth refresh completed successfully"),J.endAuthentication(!0),Q(!0);else{let W=q==="SIGTERM"?k0.red("GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal."):k0.red("Error running gcpAuthRefresh (in settings or ~/.claude.json):");console.error(W),J.endAuthentication(!1),Q(!1)}})})}function vV(){e2.cache.clear()}function jV(){if(!lJ())return;if(nJ()){if(!t()&&!u())return}e2()}function yV(){let $=mJ(),J=dJ();if(!$&&!J)return;if(uJ()||cJ()){if(!t()&&!u())return}G1(),v()}function SV($){return/^[a-zA-Z0-9-_]+$/.test($)}async function r8($){if(!SV($))throw Error("Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.");await dZ();let J=!1;if(process.platform==="darwin")try{let X=G0(),Z=h0(),q=Buffer.from($,"utf-8").toString("hex"),Y=`add-generic-password -U -a "${Z}" -s "${X}" -X "${q}"
|
|
67
|
+
`;await gJ("security",["-i"],{input:Y,reject:!1}),F("tengu_api_key_saved_to_keychain",{}),J=!0}catch(X){O(X),F("tengu_api_key_keychain_error",{error:o(X)}),F("tengu_api_key_saved_to_config",{})}else F("tengu_api_key_saved_to_config",{});let Q=t4($);l((X)=>{let Z=X.customApiKeyResponses?.approved??[];return{...X,primaryApiKey:J?X.primaryApiKey:$,customApiKeyResponses:{...X.customApiKeyResponses,approved:Z.includes(Q)?Z:[...Z,Q],rejected:X.customApiKeyResponses?.rejected??[]}}}),x$.cache.clear?.(),SJ()}function fV($){let J=I(),Q=t4($);return J.customApiKeyResponses?.approved?.includes(Q)??!1}async function bV(){await dZ(),l(($)=>({...$,primaryApiKey:void 0})),x$.cache.clear?.(),SJ()}function hV(){try{let $=M0(),J=$.read()||{};if("claudeAiOauth"in J)delete J.claudeAiOauth;let Q=$.update(J);return I$(),Q}catch($){return O($),{success:!1,warning:"Failed to clear stored Claude OAuth tokens"}}}async function dZ(){try{await JQ()}catch($){O($)}}function cZ($){if(!L1($.scopes))return F("tengu_oauth_tokens_not_claude_ai",{}),{success:!0};if(!$.refreshToken||!$.expiresAt)return F("tengu_oauth_tokens_inference_only",{}),{success:!0};let J=M0(),Q=J.name;try{let X=J.read()||{},Z=X.claudeAiOauth;X.claudeAiOauth={accessToken:$.accessToken,refreshToken:$.refreshToken,expiresAt:$.expiresAt,scopes:$.scopes,subscriptionType:$.subscriptionType??Z?.subscriptionType??null,rateLimitTier:$.rateLimitTier??Z?.rateLimitTier??null};let q=J.update(X);if(q.success)F("tengu_oauth_tokens_saved",{storageBackend:Q});else F("tengu_oauth_tokens_save_failed",{storageBackend:Q});return C.cache?.clear?.(),FZ(),PZ(),q}catch(X){return O(X),F("tengu_oauth_tokens_save_exception",{storageBackend:Q,error:o(X)}),{success:!1,warning:"Failed to save OAuth tokens"}}}function I$(){C.cache?.clear?.(),p0()}async function pV(){try{let{mtimeMs:$}=await wV(RV(b(),".credentials.json"));if($!==CZ)CZ=$,I$()}catch{C.cache?.clear?.()}}function c2($){let J=fJ.get($);if(J)return J;let Q=gV($).finally(()=>{fJ.delete($)});return fJ.set($,Q),Q}async function gV($){I$();let J=await Q4();if(!J?.refreshToken)return!1;if(J.accessToken!==$)return F("tengu_oauth_401_recovered_from_keychain",{}),!0;return A1(0,!0)}async function Q4(){if(C0())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||a4())return C();try{let Q=(await M0().readAsync())?.claudeAiOauth;if(!Q?.accessToken)return null;return Q}catch($){return O($),null}}function A1($=0,J=!1){if($===0&&!J){if(J4)return J4;return J4=hJ($,J).finally(()=>{J4=null}),J4}return hJ($,J)}async function hJ($,J){await pV();let X=C();if(!J){if(!X?.refreshToken||!E1(X.expiresAt))return!1}if(!X?.refreshToken)return!1;if(!L1(X.scopes))return!1;C.cache?.clear?.(),p0();let Z=await Q4();if(!Z?.refreshToken||!E1(Z.expiresAt))return!1;let q=b();await HV(q,{recursive:!0});let Y;try{F("tengu_oauth_token_refresh_lock_acquiring",{}),Y=await yZ(q),F("tengu_oauth_token_refresh_lock_acquired",{})}catch(W){if(W.code==="ELOCKED"){if($<5)return F("tengu_oauth_token_refresh_lock_retry",{retryCount:$+1}),await Z4(1000+Math.random()*1000),hJ($+1,J);return F("tengu_oauth_token_refresh_lock_retry_limit_reached",{maxRetries:5}),!1}return O(W),F("tengu_oauth_token_refresh_lock_error",{error:o(W)}),!1}try{C.cache?.clear?.(),p0();let W=await Q4();if(!W?.refreshToken||!E1(W.expiresAt))return F("tengu_oauth_token_refresh_race_resolved",{}),!1;F("tengu_oauth_token_refresh_starting",{});let K=await i9(W.refreshToken,{scopes:L1(W.scopes)?void 0:W.scopes});return cZ(K),C.cache?.clear?.(),p0(),!0}catch(W){O(W),C.cache?.clear?.(),p0();let K=await Q4();if(K&&!E1(K.expiresAt))return F("tengu_oauth_token_refresh_race_recovered",{}),!0;return!1}finally{F("tengu_oauth_token_refresh_lock_releasing",{}),await Y(),F("tengu_oauth_token_refresh_lock_released",{})}}function y(){if(!Y2())return!1;return L1(C()?.scopes)}function g0(){return C()?.scopes?.includes(jZ)??!1}function mV(){if(R(process.env.CLAUDE_CODE_USE_BEDROCK)||R(process.env.CLAUDE_CODE_USE_VERTEX)||R(process.env.CLAUDE_CODE_USE_FOUNDRY)||R(process.env.CLAUDE_CODE_USE_AZURE_OPENAI))return!1;if(y())return!1;return!0}function _1(){return Y2()?I().oauthAccount:void 0}function uV(){let J=_1()?.billingType;if(!y()||!J)return!1;if(J!=="stripe_subscription"&&J!=="stripe_subscription_contracted"&&J!=="apple_subscription"&&J!=="google_play_subscription")return!1;return!0}function dV(){let $=d();return $==="max"||$==="enterprise"||$==="team"||$==="pro"||$===null}function d(){if(M9())return T9();if(!Y2())return null;let $=C();if(!$)return null;return $.subscriptionType??null}function W$(){return d()==="max"}function cV(){return d()==="team"}function V$(){return d()==="team"&&T$()==="default_claude_max_5x"}function lV(){return d()==="enterprise"}function LJ(){return d()==="pro"}function T$(){if(!Y2())return null;let $=C();if(!$)return null;return $.rateLimitTier??null}function lZ(){switch(d()){case"enterprise":return"Claude Enterprise";case"team":return"Claude Team";case"max":return"Claude Max";case"pro":return"Claude Pro";default:return"Claude API"}}function M$(){return!!(R(process.env.CLAUDE_CODE_USE_BEDROCK)||R(process.env.CLAUDE_CODE_USE_VERTEX)||R(process.env.CLAUDE_CODE_USE_FOUNDRY)||R(process.env.CLAUDE_CODE_USE_AZURE_OPENAI))}function nZ(){return(z0()||{}).otelHeadersHelper}function iZ(){let $=nZ();if(!$)return!1;let J=S("projectSettings"),Q=S("localSettings");return J?.otelHeadersHelper===$||Q?.otelHeadersHelper===$}function iV(){let $=nZ();if(!$)return{};let J=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||nV.toString());if(F$&&Date.now()-kZ<J)return F$;if(iZ()){if(!t())return{}}try{let Q=K1($,{timeout:30000})?.toString().trim();if(!Q)throw Error("otelHeadersHelper did not return a valid value");let X=a(Q);if(typeof X!=="object"||X===null||Array.isArray(X))throw Error("otelHeadersHelper must return a JSON object with string key-value pairs");for(let[Z,q]of Object.entries(X))if(typeof q!=="string")throw Error(`otelHeadersHelper returned non-string value for key "${Z}": ${typeof q}`);return F$=X,kZ=Date.now(),F$}catch(Q){throw O(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${o(Q)}`)),Q}}function rV($){return $==="max"||$==="pro"}function oV(){let $=d();return y()&&$!==null&&rV($)}function rZ(){return"ChatGPT Pro/Plus"}function sV(){if(M$())return"OpenAI login is saved, but this shell is configured for a third-party provider.";let{source:$}=M1();if($!=="none")return`OpenAI login is saved, but this shell is still using ${$} for Anthropic-compatible auth.`;let{source:J}=h1({skipRetrievingKeyFromApiKeyHelper:!0});if(J!=="none")return`OpenAI login is saved, but this shell is still using ${J} for Anthropic-compatible auth.`;return null}function aV(){return!!h2()?.refreshToken&&!M$()}function y1(){return oZ()!==void 0}function oZ($){let J=h2();if(!J?.refreshToken||M$())return;let Q=$?.authTokenSource??M1().source,X=$?.apiKeySource??h1().source;if(Q!=="none"||X!=="none")return;return{provider:"openai",subscription:rZ(),tokenSource:"OpenAI OAuth",email:J.email,accountId:J.accountId}}function tV(){if(P()!=="firstParty")return;let{source:J}=M1(),{key:Q,source:X}=h1(),Z=oZ({authTokenSource:J,apiKeySource:X});if(Z)return Z;let q={};if(q.provider="anthropic",J==="CLAUDE_CODE_OAUTH_TOKEN"||J==="CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR")q.tokenSource=J;else if(y())q.subscription=lZ();else q.tokenSource=J;if(Q)q.apiKeySource=X;if(J==="claude.ai"||X==="/login managed key"){let W=_1()?.organizationName;if(W)q.organization=W}let Y=_1()?.emailAddress;if((J==="claude.ai"||X==="/login managed key")&&Y)q.email=Y;return q}async function eV(){if(process.env.ANTHROPIC_UNIX_SOCKET)return{valid:!0};if(!Y2())return{valid:!0};let $=S("policySettings")?.forceLoginOrgUUID;if(!$)return{valid:!0};await A1();let J=C();if(!J)return{valid:!0};let{source:Q}=M1(),X=Q==="CLAUDE_CODE_OAUTH_TOKEN"||Q==="CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",Z=await $2(J.accessToken);if(!Z)return{valid:!1,message:`Unable to verify organization for the current authentication token.
|
|
68
|
+
This machine requires organization ${$} but the profile could not be fetched.
|
|
69
|
+
This may be a network error, or the token may lack the user:profile scope required for
|
|
70
|
+
verification (tokens from 'claude setup-token' do not include this scope).
|
|
71
|
+
Try again, or obtain a full-scope token via 'claude auth login'.`};let q=Z.organization.uuid;if(q===$)return{valid:!0};if(X)return{valid:!1,message:`The ${Q==="CLAUDE_CODE_OAUTH_TOKEN"?"CLAUDE_CODE_OAUTH_TOKEN":"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR"} environment variable provides a token for a
|
|
72
|
+
different organization than required by this machine's managed settings.
|
|
73
|
+
|
|
74
|
+
Required organization: ${$}
|
|
75
|
+
Token organization: ${q}
|
|
76
|
+
|
|
77
|
+
Remove the environment variable or obtain a token for the correct organization.`};return{valid:!1,message:`Your authentication token belongs to organization ${q},
|
|
78
|
+
but this machine requires organization ${$}.
|
|
79
|
+
|
|
80
|
+
Please log in with the correct organization: claude auth login`}}var _V=300000,B0=null,c0=null,q2=0,xV=3600000,TV=180000,G1,EV=5000,AV=3600000,kV=180000,e2,x$,C,CZ=0,fJ,J4=null,F$=null,kZ=0,nV=1740000,sZ;var e=U(()=>{T0();V1();u4();b0();n();P9();r4();o4();n8();$Q();QQ();qQ();YQ();jJ();D0();p();j();N0();b2();q9();W0();UV();u8();TZ();f2();J1();SZ();X0();EZ();G1=pJ(async()=>{let $=await IV(),J=await MV();if($||J)await ZQ();return J},xV);e2=pJ(async()=>{return await CV()},AV);x$=bZ(()=>{if(C0())return null;if(process.platform==="darwin"){let J=IZ();if(J){if(J.stdout)return{key:J.stdout,source:"/login managed key"}}else{let Q=G0();try{let X=K1(`security find-generic-password -a $USER -w -s "${Q}"`);if(X)return{key:X,source:"/login managed key"}}catch(X){O(X)}}}let $=I();if(!$.primaryApiKey)return null;return{key:$.primaryApiKey,source:"/login managed key"}});C=bZ(()=>{if(C0())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:["user:inference"],subscriptionType:null,rateLimitTier:null};let $=a4();if($)return{accessToken:$,refreshToken:null,expiresAt:null,scopes:["user:inference"],subscriptionType:null,rateLimitTier:null};try{let X=M0().read()?.claudeAiOauth;if(!X?.accessToken)return null;return X}catch(J){return O(J),null}});fJ=new Map;sZ=class sZ extends Error{}});function P$(){return`claude-code/${MACRO.VERSION}`}var iJ=()=>{};import{AsyncLocalStorage as JG}from"async_hooks";function tZ(){return aZ.getStore()?.workload}function IO($,J){return aZ.run({workload:$},J)}var aZ;var eZ=U(()=>{aZ=new JG});import QG from"axios";function ZZ(){let $=process.env.CLAUDE_AGENT_SDK_VERSION?`, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`:"",J=process.env.CLAUDE_AGENT_SDK_CLIENT_APP?`, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`:"",Q=tZ(),X=Q?`, workload/${Q}`:"";return`claude-cli/${rQ} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT??"cli"}${$}${J}${X})`}function vO(){let $=[];if(process.env.CLAUDE_CODE_ENTRYPOINT)$.push(process.env.CLAUDE_CODE_ENTRYPOINT);if(process.env.CLAUDE_AGENT_SDK_VERSION)$.push(`agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`);if(process.env.CLAUDE_AGENT_SDK_CLIENT_APP)$.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);let J=$.length>0?` (${$.join(", ")})`:"";return`claude-code/${MACRO.VERSION}${J}`}function jO(){return`Claude-User (${P$()}; +https://support.anthropic.com/)`}function q4(){if(y()){let J=C();if(!J?.accessToken)return{headers:{},error:"No OAuth token available"};return{headers:{Authorization:`Bearer ${J.accessToken}`,"anthropic-beta":P0}}}let $=U0();if(!$)return{headers:{},error:"No API key available"};return{headers:{"x-api-key":$}}}async function yO($,J){try{return await $()}catch(Q){if(!QG.isAxiosError(Q))throw Q;let X=Q.response?.status;if(!(X===401||J?.also403Revoked&&X===403&&typeof Q.response?.data==="string"&&Q.response.data.includes("OAuth token has been revoked")))throw Q;let q=C()?.accessToken;if(!q)throw Q;return await c2(q),await $()}}var N$=U(()=>{T0();e();HJ();iJ();eZ()});import{execa as XG}from"execa";import $3 from"lodash-es/memoize.js";async function cO(){if(W4===null&&!Y4)Y4=qG(),W4=await Y4,Y4=null,W2.cache.clear?.()}function lO(){W4=null,Y4=null,W2.cache.clear?.(),Q3.cache.clear?.()}function J3(){return W2(!0)}function ZG(){if(W4!==null)return W4;let $=_1();if($?.emailAddress)return $.emailAddress;if(process.env.USER_TYPE!=="ant")return;if(process.env.COO_CREATOR)return`${process.env.COO_CREATOR}@anthropic.com`;return}async function qG(){let $=_1();if($?.emailAddress)return $.emailAddress;if(process.env.USER_TYPE!=="ant")return;if(process.env.COO_CREATOR)return`${process.env.COO_CREATOR}@anthropic.com`;return Q3()}var W4=null,Y4=null,W2,Q3;var rJ=U(()=>{n();e();D0();S4();v2();j();W2=$3(($)=>{let J=j2(),Q=I(),X,Z,q;if($){if(X=d()??void 0,Z=T$()??void 0,X&&Q.claudeCodeFirstTokenDate){let B=new Date(Q.claudeCodeFirstTokenDate).getTime();if(!isNaN(B))q=B}}let Y=_1(),W=Y?.organizationUuid,K=Y?.accountUuid;return{deviceId:J,sessionId:A0(),email:ZG(),appVersion:MACRO.VERSION,platform:E$(),organizationUuid:W,accountUuid:K,userType:process.env.USER_TYPE,subscriptionType:X,rateLimitTier:Z,firstTokenTime:q,...R(process.env.GITHUB_ACTIONS)&&{githubActionsMetadata:{actor:process.env.GITHUB_ACTOR,actorId:process.env.GITHUB_ACTOR_ID,repository:process.env.GITHUB_REPOSITORY,repositoryId:process.env.GITHUB_REPOSITORY_ID,repositoryOwner:process.env.GITHUB_REPOSITORY_OWNER,repositoryOwnerId:process.env.GITHUB_REPOSITORY_OWNER_ID}}}});Q3=$3(async()=>{let $=await XG("git config --get user.email",{shell:!0,reject:!1,cwd:S0()});return $.exitCode===0&&$.stdout?$.stdout.trim():void 0})});function X3(){return R(process.env.CLAUDE_CODE_USE_BEDROCK)||R(process.env.CLAUDE_CODE_USE_VERTEX)||R(process.env.CLAUDE_CODE_USE_FOUNDRY)||R(process.env.CLAUDE_CODE_USE_AZURE_OPENAI)||oJ()}function oO(){return oJ()}var Z3=U(()=>{j();y4()});function YG(){return{seconds:0,nanos:0}}function q3($){return $!==null&&$!==void 0}var V4;var sJ=U(()=>{V4={fromJSON($){return{seconds:q3($.seconds)?globalThis.Number($.seconds):0,nanos:q3($.nanos)?globalThis.Number($.nanos):0}},toJSON($){let J={};if($.seconds!==void 0)J.seconds=Math.round($.seconds);if($.nanos!==void 0)J.nanos=Math.round($.nanos);return J},create($){return V4.fromPartial($??{})},fromPartial($){let J=YG();return J.seconds=$.seconds??0,J.nanos=$.nanos??0,J}}});function WG(){return{account_id:0,organization_uuid:"",account_uuid:""}}function aJ($){return $!==null&&$!==void 0}var l0;var tJ=U(()=>{l0={fromJSON($){return{account_id:aJ($.account_id)?globalThis.Number($.account_id):0,organization_uuid:aJ($.organization_uuid)?globalThis.String($.organization_uuid):"",account_uuid:aJ($.account_uuid)?globalThis.String($.account_uuid):""}},toJSON($){let J={};if($.account_id!==void 0)J.account_id=Math.round($.account_id);if($.organization_uuid!==void 0)J.organization_uuid=$.organization_uuid;if($.account_uuid!==void 0)J.account_uuid=$.account_uuid;return J},create($){return l0.fromPartial($??{})},fromPartial($){let J=WG();return J.account_id=$.account_id??0,J.organization_uuid=$.organization_uuid??"",J.account_uuid=$.account_uuid??"",J}}});function VG(){return{actor_id:"",repository_id:"",repository_owner_id:""}}function GG(){return{platform:"",node_version:"",terminal:"",package_managers:"",runtimes:"",is_running_with_bun:!1,is_ci:!1,is_claubbit:!1,is_github_action:!1,is_claude_code_action:!1,is_claude_ai_auth:!1,version:"",github_event_name:"",github_actions_runner_environment:"",github_actions_runner_os:"",github_action_ref:"",wsl_version:"",github_actions_metadata:void 0,arch:"",is_claude_code_remote:!1,remote_environment_type:"",claude_code_container_id:"",claude_code_remote_session_id:"",tags:[],deployment_environment:"",is_conductor:!1,version_base:"",coworker_type:"",build_time:"",is_local_agent_mode:!1,linux_distro_id:"",linux_distro_version:"",linux_kernel:"",vcs:"",platform_raw:""}}function KG(){return{slack_team_id:"",is_enterprise_install:!1,trigger:"",creation_method:""}}function BG(){return{event_name:"",client_timestamp:void 0,model:"",session_id:"",user_type:"",betas:"",env:void 0,entrypoint:"",agent_sdk_version:"",is_interactive:!1,client_type:"",process:"",additional_metadata:"",auth:void 0,server_timestamp:void 0,event_id:"",device_id:"",swe_bench_run_id:"",swe_bench_instance_id:"",swe_bench_task_id:"",email:"",agent_id:"",parent_session_id:"",agent_type:"",slack:void 0,team_name:"",skill_name:"",plugin_name:"",marketplace_name:""}}function LG($){let J=($.seconds||0)*1000;return J+=($.nanos||0)/1e6,new globalThis.Date(J)}function Y3($){if($ instanceof globalThis.Date)return $;else if(typeof $==="string")return new globalThis.Date($);else return LG(V4.fromJSON($))}function N($){return $!==null&&$!==void 0}var A$,C$,k$,v$;var W3=U(()=>{sJ();tJ();A$={fromJSON($){return{actor_id:N($.actor_id)?globalThis.String($.actor_id):"",repository_id:N($.repository_id)?globalThis.String($.repository_id):"",repository_owner_id:N($.repository_owner_id)?globalThis.String($.repository_owner_id):""}},toJSON($){let J={};if($.actor_id!==void 0)J.actor_id=$.actor_id;if($.repository_id!==void 0)J.repository_id=$.repository_id;if($.repository_owner_id!==void 0)J.repository_owner_id=$.repository_owner_id;return J},create($){return A$.fromPartial($??{})},fromPartial($){let J=VG();return J.actor_id=$.actor_id??"",J.repository_id=$.repository_id??"",J.repository_owner_id=$.repository_owner_id??"",J}};C$={fromJSON($){return{platform:N($.platform)?globalThis.String($.platform):"",node_version:N($.node_version)?globalThis.String($.node_version):"",terminal:N($.terminal)?globalThis.String($.terminal):"",package_managers:N($.package_managers)?globalThis.String($.package_managers):"",runtimes:N($.runtimes)?globalThis.String($.runtimes):"",is_running_with_bun:N($.is_running_with_bun)?globalThis.Boolean($.is_running_with_bun):!1,is_ci:N($.is_ci)?globalThis.Boolean($.is_ci):!1,is_claubbit:N($.is_claubbit)?globalThis.Boolean($.is_claubbit):!1,is_github_action:N($.is_github_action)?globalThis.Boolean($.is_github_action):!1,is_claude_code_action:N($.is_claude_code_action)?globalThis.Boolean($.is_claude_code_action):!1,is_claude_ai_auth:N($.is_claude_ai_auth)?globalThis.Boolean($.is_claude_ai_auth):!1,version:N($.version)?globalThis.String($.version):"",github_event_name:N($.github_event_name)?globalThis.String($.github_event_name):"",github_actions_runner_environment:N($.github_actions_runner_environment)?globalThis.String($.github_actions_runner_environment):"",github_actions_runner_os:N($.github_actions_runner_os)?globalThis.String($.github_actions_runner_os):"",github_action_ref:N($.github_action_ref)?globalThis.String($.github_action_ref):"",wsl_version:N($.wsl_version)?globalThis.String($.wsl_version):"",github_actions_metadata:N($.github_actions_metadata)?A$.fromJSON($.github_actions_metadata):void 0,arch:N($.arch)?globalThis.String($.arch):"",is_claude_code_remote:N($.is_claude_code_remote)?globalThis.Boolean($.is_claude_code_remote):!1,remote_environment_type:N($.remote_environment_type)?globalThis.String($.remote_environment_type):"",claude_code_container_id:N($.claude_code_container_id)?globalThis.String($.claude_code_container_id):"",claude_code_remote_session_id:N($.claude_code_remote_session_id)?globalThis.String($.claude_code_remote_session_id):"",tags:globalThis.Array.isArray($?.tags)?$.tags.map((J)=>globalThis.String(J)):[],deployment_environment:N($.deployment_environment)?globalThis.String($.deployment_environment):"",is_conductor:N($.is_conductor)?globalThis.Boolean($.is_conductor):!1,version_base:N($.version_base)?globalThis.String($.version_base):"",coworker_type:N($.coworker_type)?globalThis.String($.coworker_type):"",build_time:N($.build_time)?globalThis.String($.build_time):"",is_local_agent_mode:N($.is_local_agent_mode)?globalThis.Boolean($.is_local_agent_mode):!1,linux_distro_id:N($.linux_distro_id)?globalThis.String($.linux_distro_id):"",linux_distro_version:N($.linux_distro_version)?globalThis.String($.linux_distro_version):"",linux_kernel:N($.linux_kernel)?globalThis.String($.linux_kernel):"",vcs:N($.vcs)?globalThis.String($.vcs):"",platform_raw:N($.platform_raw)?globalThis.String($.platform_raw):""}},toJSON($){let J={};if($.platform!==void 0)J.platform=$.platform;if($.node_version!==void 0)J.node_version=$.node_version;if($.terminal!==void 0)J.terminal=$.terminal;if($.package_managers!==void 0)J.package_managers=$.package_managers;if($.runtimes!==void 0)J.runtimes=$.runtimes;if($.is_running_with_bun!==void 0)J.is_running_with_bun=$.is_running_with_bun;if($.is_ci!==void 0)J.is_ci=$.is_ci;if($.is_claubbit!==void 0)J.is_claubbit=$.is_claubbit;if($.is_github_action!==void 0)J.is_github_action=$.is_github_action;if($.is_claude_code_action!==void 0)J.is_claude_code_action=$.is_claude_code_action;if($.is_claude_ai_auth!==void 0)J.is_claude_ai_auth=$.is_claude_ai_auth;if($.version!==void 0)J.version=$.version;if($.github_event_name!==void 0)J.github_event_name=$.github_event_name;if($.github_actions_runner_environment!==void 0)J.github_actions_runner_environment=$.github_actions_runner_environment;if($.github_actions_runner_os!==void 0)J.github_actions_runner_os=$.github_actions_runner_os;if($.github_action_ref!==void 0)J.github_action_ref=$.github_action_ref;if($.wsl_version!==void 0)J.wsl_version=$.wsl_version;if($.github_actions_metadata!==void 0)J.github_actions_metadata=A$.toJSON($.github_actions_metadata);if($.arch!==void 0)J.arch=$.arch;if($.is_claude_code_remote!==void 0)J.is_claude_code_remote=$.is_claude_code_remote;if($.remote_environment_type!==void 0)J.remote_environment_type=$.remote_environment_type;if($.claude_code_container_id!==void 0)J.claude_code_container_id=$.claude_code_container_id;if($.claude_code_remote_session_id!==void 0)J.claude_code_remote_session_id=$.claude_code_remote_session_id;if($.tags?.length)J.tags=$.tags;if($.deployment_environment!==void 0)J.deployment_environment=$.deployment_environment;if($.is_conductor!==void 0)J.is_conductor=$.is_conductor;if($.version_base!==void 0)J.version_base=$.version_base;if($.coworker_type!==void 0)J.coworker_type=$.coworker_type;if($.build_time!==void 0)J.build_time=$.build_time;if($.is_local_agent_mode!==void 0)J.is_local_agent_mode=$.is_local_agent_mode;if($.linux_distro_id!==void 0)J.linux_distro_id=$.linux_distro_id;if($.linux_distro_version!==void 0)J.linux_distro_version=$.linux_distro_version;if($.linux_kernel!==void 0)J.linux_kernel=$.linux_kernel;if($.vcs!==void 0)J.vcs=$.vcs;if($.platform_raw!==void 0)J.platform_raw=$.platform_raw;return J},create($){return C$.fromPartial($??{})},fromPartial($){let J=GG();return J.platform=$.platform??"",J.node_version=$.node_version??"",J.terminal=$.terminal??"",J.package_managers=$.package_managers??"",J.runtimes=$.runtimes??"",J.is_running_with_bun=$.is_running_with_bun??!1,J.is_ci=$.is_ci??!1,J.is_claubbit=$.is_claubbit??!1,J.is_github_action=$.is_github_action??!1,J.is_claude_code_action=$.is_claude_code_action??!1,J.is_claude_ai_auth=$.is_claude_ai_auth??!1,J.version=$.version??"",J.github_event_name=$.github_event_name??"",J.github_actions_runner_environment=$.github_actions_runner_environment??"",J.github_actions_runner_os=$.github_actions_runner_os??"",J.github_action_ref=$.github_action_ref??"",J.wsl_version=$.wsl_version??"",J.github_actions_metadata=$.github_actions_metadata!==void 0&&$.github_actions_metadata!==null?A$.fromPartial($.github_actions_metadata):void 0,J.arch=$.arch??"",J.is_claude_code_remote=$.is_claude_code_remote??!1,J.remote_environment_type=$.remote_environment_type??"",J.claude_code_container_id=$.claude_code_container_id??"",J.claude_code_remote_session_id=$.claude_code_remote_session_id??"",J.tags=$.tags?.map((Q)=>Q)||[],J.deployment_environment=$.deployment_environment??"",J.is_conductor=$.is_conductor??!1,J.version_base=$.version_base??"",J.coworker_type=$.coworker_type??"",J.build_time=$.build_time??"",J.is_local_agent_mode=$.is_local_agent_mode??!1,J.linux_distro_id=$.linux_distro_id??"",J.linux_distro_version=$.linux_distro_version??"",J.linux_kernel=$.linux_kernel??"",J.vcs=$.vcs??"",J.platform_raw=$.platform_raw??"",J}};k$={fromJSON($){return{slack_team_id:N($.slack_team_id)?globalThis.String($.slack_team_id):"",is_enterprise_install:N($.is_enterprise_install)?globalThis.Boolean($.is_enterprise_install):!1,trigger:N($.trigger)?globalThis.String($.trigger):"",creation_method:N($.creation_method)?globalThis.String($.creation_method):""}},toJSON($){let J={};if($.slack_team_id!==void 0)J.slack_team_id=$.slack_team_id;if($.is_enterprise_install!==void 0)J.is_enterprise_install=$.is_enterprise_install;if($.trigger!==void 0)J.trigger=$.trigger;if($.creation_method!==void 0)J.creation_method=$.creation_method;return J},create($){return k$.fromPartial($??{})},fromPartial($){let J=KG();return J.slack_team_id=$.slack_team_id??"",J.is_enterprise_install=$.is_enterprise_install??!1,J.trigger=$.trigger??"",J.creation_method=$.creation_method??"",J}};v$={fromJSON($){return{event_name:N($.event_name)?globalThis.String($.event_name):"",client_timestamp:N($.client_timestamp)?Y3($.client_timestamp):void 0,model:N($.model)?globalThis.String($.model):"",session_id:N($.session_id)?globalThis.String($.session_id):"",user_type:N($.user_type)?globalThis.String($.user_type):"",betas:N($.betas)?globalThis.String($.betas):"",env:N($.env)?C$.fromJSON($.env):void 0,entrypoint:N($.entrypoint)?globalThis.String($.entrypoint):"",agent_sdk_version:N($.agent_sdk_version)?globalThis.String($.agent_sdk_version):"",is_interactive:N($.is_interactive)?globalThis.Boolean($.is_interactive):!1,client_type:N($.client_type)?globalThis.String($.client_type):"",process:N($.process)?globalThis.String($.process):"",additional_metadata:N($.additional_metadata)?globalThis.String($.additional_metadata):"",auth:N($.auth)?l0.fromJSON($.auth):void 0,server_timestamp:N($.server_timestamp)?Y3($.server_timestamp):void 0,event_id:N($.event_id)?globalThis.String($.event_id):"",device_id:N($.device_id)?globalThis.String($.device_id):"",swe_bench_run_id:N($.swe_bench_run_id)?globalThis.String($.swe_bench_run_id):"",swe_bench_instance_id:N($.swe_bench_instance_id)?globalThis.String($.swe_bench_instance_id):"",swe_bench_task_id:N($.swe_bench_task_id)?globalThis.String($.swe_bench_task_id):"",email:N($.email)?globalThis.String($.email):"",agent_id:N($.agent_id)?globalThis.String($.agent_id):"",parent_session_id:N($.parent_session_id)?globalThis.String($.parent_session_id):"",agent_type:N($.agent_type)?globalThis.String($.agent_type):"",slack:N($.slack)?k$.fromJSON($.slack):void 0,team_name:N($.team_name)?globalThis.String($.team_name):"",skill_name:N($.skill_name)?globalThis.String($.skill_name):"",plugin_name:N($.plugin_name)?globalThis.String($.plugin_name):"",marketplace_name:N($.marketplace_name)?globalThis.String($.marketplace_name):""}},toJSON($){let J={};if($.event_name!==void 0)J.event_name=$.event_name;if($.client_timestamp!==void 0)J.client_timestamp=$.client_timestamp.toISOString();if($.model!==void 0)J.model=$.model;if($.session_id!==void 0)J.session_id=$.session_id;if($.user_type!==void 0)J.user_type=$.user_type;if($.betas!==void 0)J.betas=$.betas;if($.env!==void 0)J.env=C$.toJSON($.env);if($.entrypoint!==void 0)J.entrypoint=$.entrypoint;if($.agent_sdk_version!==void 0)J.agent_sdk_version=$.agent_sdk_version;if($.is_interactive!==void 0)J.is_interactive=$.is_interactive;if($.client_type!==void 0)J.client_type=$.client_type;if($.process!==void 0)J.process=$.process;if($.additional_metadata!==void 0)J.additional_metadata=$.additional_metadata;if($.auth!==void 0)J.auth=l0.toJSON($.auth);if($.server_timestamp!==void 0)J.server_timestamp=$.server_timestamp.toISOString();if($.event_id!==void 0)J.event_id=$.event_id;if($.device_id!==void 0)J.device_id=$.device_id;if($.swe_bench_run_id!==void 0)J.swe_bench_run_id=$.swe_bench_run_id;if($.swe_bench_instance_id!==void 0)J.swe_bench_instance_id=$.swe_bench_instance_id;if($.swe_bench_task_id!==void 0)J.swe_bench_task_id=$.swe_bench_task_id;if($.email!==void 0)J.email=$.email;if($.agent_id!==void 0)J.agent_id=$.agent_id;if($.parent_session_id!==void 0)J.parent_session_id=$.parent_session_id;if($.agent_type!==void 0)J.agent_type=$.agent_type;if($.slack!==void 0)J.slack=k$.toJSON($.slack);if($.team_name!==void 0)J.team_name=$.team_name;if($.skill_name!==void 0)J.skill_name=$.skill_name;if($.plugin_name!==void 0)J.plugin_name=$.plugin_name;if($.marketplace_name!==void 0)J.marketplace_name=$.marketplace_name;return J},create($){return v$.fromPartial($??{})},fromPartial($){let J=BG();return J.event_name=$.event_name??"",J.client_timestamp=$.client_timestamp??void 0,J.model=$.model??"",J.session_id=$.session_id??"",J.user_type=$.user_type??"",J.betas=$.betas??"",J.env=$.env!==void 0&&$.env!==null?C$.fromPartial($.env):void 0,J.entrypoint=$.entrypoint??"",J.agent_sdk_version=$.agent_sdk_version??"",J.is_interactive=$.is_interactive??!1,J.client_type=$.client_type??"",J.process=$.process??"",J.additional_metadata=$.additional_metadata??"",J.auth=$.auth!==void 0&&$.auth!==null?l0.fromPartial($.auth):void 0,J.server_timestamp=$.server_timestamp??void 0,J.event_id=$.event_id??"",J.device_id=$.device_id??"",J.swe_bench_run_id=$.swe_bench_run_id??"",J.swe_bench_instance_id=$.swe_bench_instance_id??"",J.swe_bench_task_id=$.swe_bench_task_id??"",J.email=$.email??"",J.agent_id=$.agent_id??"",J.parent_session_id=$.parent_session_id??"",J.agent_type=$.agent_type??"",J.slack=$.slack!==void 0&&$.slack!==null?k$.fromPartial($.slack):void 0,J.team_name=$.team_name??"",J.skill_name=$.skill_name??"",J.plugin_name=$.plugin_name??"",J.marketplace_name=$.marketplace_name??"",J}}});function UG(){return{event_id:"",timestamp:void 0,experiment_id:"",variation_id:0,environment:"",user_attributes:"",experiment_metadata:"",device_id:"",auth:void 0,session_id:"",anonymous_id:"",event_metadata_vars:""}}function HG($){let J=($.seconds||0)*1000;return J+=($.nanos||0)/1e6,new globalThis.Date(J)}function wG($){if($ instanceof globalThis.Date)return $;else if(typeof $==="string")return new globalThis.Date($);else return HG(V4.fromJSON($))}function H0($){return $!==null&&$!==void 0}var eJ;var V3=U(()=>{sJ();tJ();eJ={fromJSON($){return{event_id:H0($.event_id)?globalThis.String($.event_id):"",timestamp:H0($.timestamp)?wG($.timestamp):void 0,experiment_id:H0($.experiment_id)?globalThis.String($.experiment_id):"",variation_id:H0($.variation_id)?globalThis.Number($.variation_id):0,environment:H0($.environment)?globalThis.String($.environment):"",user_attributes:H0($.user_attributes)?globalThis.String($.user_attributes):"",experiment_metadata:H0($.experiment_metadata)?globalThis.String($.experiment_metadata):"",device_id:H0($.device_id)?globalThis.String($.device_id):"",auth:H0($.auth)?l0.fromJSON($.auth):void 0,session_id:H0($.session_id)?globalThis.String($.session_id):"",anonymous_id:H0($.anonymous_id)?globalThis.String($.anonymous_id):"",event_metadata_vars:H0($.event_metadata_vars)?globalThis.String($.event_metadata_vars):""}},toJSON($){let J={};if($.event_id!==void 0)J.event_id=$.event_id;if($.timestamp!==void 0)J.timestamp=$.timestamp.toISOString();if($.experiment_id!==void 0)J.experiment_id=$.experiment_id;if($.variation_id!==void 0)J.variation_id=Math.round($.variation_id);if($.environment!==void 0)J.environment=$.environment;if($.user_attributes!==void 0)J.user_attributes=$.user_attributes;if($.experiment_metadata!==void 0)J.experiment_metadata=$.experiment_metadata;if($.device_id!==void 0)J.device_id=$.device_id;if($.auth!==void 0)J.auth=l0.toJSON($.auth);if($.session_id!==void 0)J.session_id=$.session_id;if($.anonymous_id!==void 0)J.anonymous_id=$.anonymous_id;if($.event_metadata_vars!==void 0)J.event_metadata_vars=$.event_metadata_vars;return J},create($){return eJ.fromPartial($??{})},fromPartial($){let J=UG();return J.event_id=$.event_id??"",J.timestamp=$.timestamp??void 0,J.experiment_id=$.experiment_id??"",J.variation_id=$.variation_id??0,J.environment=$.environment??"",J.user_attributes=$.user_attributes??"",J.experiment_metadata=$.experiment_metadata??"",J.device_id=$.device_id??"",J.auth=$.auth!==void 0&&$.auth!==null?l0.fromPartial($.auth):void 0,J.session_id=$.session_id??"",J.anonymous_id=$.anonymous_id??"",J.event_metadata_vars=$.event_metadata_vars??"",J}}});function YF($){if($<=1)return!1;try{return process.kill($,0),!0}catch{return!1}}async function WF($,J=10){if(process.platform==="win32"){let Z=`
|
|
81
|
+
$pid = ${String($)}
|
|
82
|
+
$ancestors = @()
|
|
83
|
+
for ($i = 0; $i -lt ${J}; $i++) {
|
|
84
|
+
$proc = Get-CimInstance Win32_Process -Filter "ProcessId=$pid" -ErrorAction SilentlyContinue
|
|
85
|
+
if (-not $proc -or -not $proc.ParentProcessId -or $proc.ParentProcessId -eq 0) { break }
|
|
86
|
+
$pid = $proc.ParentProcessId
|
|
87
|
+
$ancestors += $pid
|
|
88
|
+
}
|
|
89
|
+
$ancestors -join ','
|
|
90
|
+
`.trim(),q=await p1("powershell.exe",["-NoProfile","-Command",Z],{timeout:3000});if(q.code!==0||!q.stdout?.trim())return[];return q.stdout.trim().split(",").filter(Boolean).map((Y)=>parseInt(Y,10)).filter((Y)=>!isNaN(Y))}let Q=`pid=${String($)}; for i in $(seq 1 ${J}); do ppid=$(ps -o ppid= -p $pid 2>/dev/null | tr -d ' '); if [ -z "$ppid" ] || [ "$ppid" = "0" ] || [ "$ppid" = "1" ]; then break; fi; echo $ppid; pid=$ppid; done`,X=await p1("sh",["-c",Q],{timeout:3000});if(X.code!==0||!X.stdout?.trim())return[];return X.stdout.trim().split(`
|
|
91
|
+
`).filter(Boolean).map((Z)=>parseInt(Z,10)).filter((Z)=>!isNaN(Z))}function VF($){try{let J=String($),Q=process.platform==="win32"?`powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter \\"ProcessId=${J}\\").CommandLine"`:`ps -o command= -p ${J}`,X=K1(Q,{timeout:1000});return X?X.trim():null}catch{return null}}async function G3($,J=10){if(process.platform==="win32"){let Z=`
|
|
92
|
+
$currentPid = ${String($)}
|
|
93
|
+
$commands = @()
|
|
94
|
+
for ($i = 0; $i -lt ${J}; $i++) {
|
|
95
|
+
$proc = Get-CimInstance Win32_Process -Filter "ProcessId=$currentPid" -ErrorAction SilentlyContinue
|
|
96
|
+
if (-not $proc) { break }
|
|
97
|
+
if ($proc.CommandLine) { $commands += $proc.CommandLine }
|
|
98
|
+
if (-not $proc.ParentProcessId -or $proc.ParentProcessId -eq 0) { break }
|
|
99
|
+
$currentPid = $proc.ParentProcessId
|
|
100
|
+
}
|
|
101
|
+
$commands -join [char]0
|
|
102
|
+
`.trim(),q=await p1("powershell.exe",["-NoProfile","-Command",Z],{timeout:3000});if(q.code!==0||!q.stdout?.trim())return[];return q.stdout.split("\x00").filter(Boolean)}let Q=`currentpid=${String($)}; for i in $(seq 1 ${J}); do cmd=$(ps -o command= -p $currentpid 2>/dev/null); if [ -n "$cmd" ]; then printf '%s\\0' "$cmd"; fi; ppid=$(ps -o ppid= -p $currentpid 2>/dev/null | tr -d ' '); if [ -z "$ppid" ] || [ "$ppid" = "0" ] || [ "$ppid" = "1" ]; then break; fi; currentpid=$ppid; done`,X=await p1("sh",["-c",Q],{timeout:3000});if(X.code!==0||!X.stdout?.trim())return[];return X.stdout.split("\x00").filter(Boolean)}var K3=U(()=>{b2()});import{stat as _G}from"fs/promises";import NG from"lodash-es/memoize.js";function OG(){return process.platform==="linux"&&R(process.env.CLAUDE_CODE_BUBBLEWRAP)}function FG(){if(process.platform!=="linux")return!1;return $6??!1}async function L3(){if(g1!==void 0)return g1;if(process.platform==="darwin")return g1=null,null;try{let $=await G3(process.pid,10);for(let J of $){let Q=J.toLowerCase();for(let X of B3)if(Q.includes(X))return g1=X,X}}catch{}return g1=null,null}async function zG(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"){if(s.platform!=="darwin")return await L3()||"pycharm"}return s.terminal}function xG(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"){if(s.platform!=="darwin"){if(g1!==void 0)return g1||"pycharm";return"pycharm"}}return s.terminal}async function IG(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm")await L3()}var DG,$6=null,g1,U3;var H3=U(()=>{v2();j();b2();K3();DG=NG(async()=>{if(process.platform!=="linux")return!1;let{code:$}=await l4("test",["-f","/.dockerenv"]);return $===0});if(process.platform==="linux"){let $=process.arch==="x64"?"x86_64":"aarch64";_G(`/lib/libc.musl-${$}.so.1`).then(()=>{$6=!0},()=>{$6=!1})}U3={...s,terminal:xG(),getIsDocker:DG,getIsBubblewrapSandbox:OG,isMuslEnvironment:FG,getTerminalWithJetBrainsDetectionAsync:zG,initJetBrainsDetection:IG}});import TG from"axios";function MG($){try{let J=new URL($);return J.search="",J.toString().replace(/\/$/,"")}catch{return}}async function OF(){if(process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)return;try{let $=await TG.get("https://api.anthropic.com/mcp-registry/v0/servers?version=latest&visibility=commercial",{timeout:5000}),J=new Set;for(let Q of $.data.servers)for(let X of Q.server.remotes??[]){let Z=MG(X.url);if(Z)J.add(Z)}w3=J,L(`[mcp-registry] Loaded ${J.size} official MCP URLs`)}catch($){L(`Failed to fetch MCP registry: ${o($)}`,{level:"error"})}}function R3($){return w3?.has($)??!1}var w3=void 0;var _3=U(()=>{p();N0()});function PG(){return process.argv.includes("--agent-teams")}function EG(){if(process.env.USER_TYPE==="ant")return!0;if(!R(process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS)&&!PG())return!1;if(!Z0("tengu_amber_flint",!0))return!1;return!0}var N3=U(()=>{Q1();j()});import{AsyncLocalStorage as AG}from"async_hooks";function j$(){return D3.getStore()}function PF($,J){return D3.run($,J)}function CG($){return $?.agentType==="subagent"}function EF(){let $=j$();if(!CG($)||!$.subagentName)return;return $.isBuiltIn?$.subagentName:"user-defined"}function AF(){let $=j$();if(!$?.invokingRequestId||$.invocationEmitted)return;return $.invocationEmitted=!0,{invokingRequestId:$.invokingRequestId,invocationKind:$.invocationKind}}var D3;var O3=U(()=>{N3();D3=new AG});import{extname as SG}from"path";import j3 from"lodash-es/memoize.js";function iF($){if($.startsWith("mcp__"))return"mcp_tool";return $}function fG(){return R(process.env.OTEL_LOG_TOOL_DETAILS)}function bG($,J){if(process.env.CLAUDE_CODE_ENTRYPOINT==="local-agent")return!0;if($==="claudeai-proxy")return!0;if(J&&R3(J))return!0;return!1}function rF($,J,Q){let X=pG($);if(!X)return{};if(!hG.has(X.serverName)&&!bG(J,Q))return{};return{mcpServerName:X.serverName,mcpToolName:X.mcpToolName}}function pG($){if(!$.startsWith("mcp__"))return;let J=$.split("__");if(J.length<3)return;let Q=J[1],X=J.slice(2).join("__");if(!Q||!X)return;return{serverName:Q,mcpToolName:X}}function oF($,J){if($!=="Skill")return;if(typeof J==="object"&&J!==null&&"skill"in J&&typeof J.skill==="string")return J.skill;return}function Q6($,J=0){if(typeof $==="string"){if($.length>gG)return`${$.slice(0,mG)}\u2026[${$.length} chars]`;return $}if(typeof $==="number"||typeof $==="boolean"||$===null||$===void 0)return $;if(J>=uG)return"<nested>";if(Array.isArray($)){let Q=$.slice(0,y$).map((X)=>Q6(X,J+1));if($.length>y$)Q.push(`\u2026[${$.length} items]`);return Q}if(typeof $==="object"){let Q=Object.entries($).filter(([Z])=>!Z.startsWith("_")),X=Q.slice(0,y$).map(([Z,q])=>[Z,Q6(q,J+1)]);if(Q.length>y$)X.push(["\u2026",`${Q.length} keys`]);return Object.fromEntries(X)}return String($)}function sF($){if(!fG())return;let J=Q6($),Q=A(J);if(Q.length>F3)Q=Q.slice(0,F3)+"\u2026[truncated]";return Q}function z3($){let J=SG($).toLowerCase();if(!J||J===".")return;let Q=J.slice(1);if(Q.length>dG)return"other";return Q}function aF($,J){if(!$.includes(".")&&!J)return;let Q,X=new Set;if(J){let Z=z3(J);if(Z)X.add(Z),Q=Z}for(let Z of $.split(lG)){if(!Z)continue;let q=Z.split(nG);if(q.length<2)continue;let Y=q[0],W=Y.lastIndexOf("/"),K=W>=0?Y.slice(W+1):Y;if(!cG.has(K))continue;for(let B=1;B<q.length;B++){let w=q[B];if(w.charCodeAt(0)===45)continue;let H=z3(w);if(H&&!X.has(H))X.add(H),Q=Q?Q+","+H:H}}if(!Q)return;return Q}function iG(){let $=j$();if($){let W={agentId:$.agentId,parentSessionId:$.parentSessionId,agentType:$.agentType};if($.agentType==="teammate")W.teamName=$.teamName;return W}let J=C3(),Q=A3(),X=k3(),q=v3()?"teammate":J?"standalone":void 0;if(J||q||Q||X)return{...J?{agentId:J}:{},...q?{agentType:q}:{},...Q?{parentSessionId:Q}:{},...X?{teamName:X}:{}};let Y=x3();if(Y)return{parentSessionId:Y};return{}}function sG(){try{let $=process.memoryUsage(),J=process.cpuUsage(),Q=Date.now(),X;if(S$&&J6){let Z=Q-J6;if(Z>0){let q=J.user-S$.user,Y=J.system-S$.system;X=(q+Y)/(Z*1000)*100}}return S$=J,J6=Q,{uptime:process.uptime(),rss:$.rss,heapTotal:$.heapTotal,heapUsed:$.heapUsed,external:$.external,arrayBuffers:$.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:J,cpuPercent:X}}catch{return}}async function S3($={}){let J=$.model?String($.model):uQ(),Q=typeof $.betas==="string"?$.betas:D$(J).join(","),[X,Z]=await Promise.all([oG(),E3()]),q=sG();return{model:J,sessionId:A0(),userType:process.env.USER_TYPE||"",...Q.length>0?{betas:Q}:{},envContext:X,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(I3()),clientType:T3(),...q&&{processMetrics:q},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||"",sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||"",sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||"",...iG(),...d()&&{subscriptionType:d()},...{},...Z&&{rh:Z}}}function f3($,J,Q={}){let{envContext:X,processMetrics:Z,rh:q,kairosActive:Y,skillMode:W,observerMode:K,...B}=$,w={platform:X.platform,platform_raw:X.platformRaw,arch:X.arch,node_version:X.nodeVersion,terminal:X.terminal||"unknown",package_managers:X.packageManagers,runtimes:X.runtimes,is_running_with_bun:X.isRunningWithBun,is_ci:X.isCi,is_claubbit:X.isClaubbit,is_claude_code_remote:X.isClaudeCodeRemote,is_local_agent_mode:X.isLocalAgentMode,is_conductor:X.isConductor,is_github_action:X.isGithubAction,is_claude_code_action:X.isClaudeCodeAction,is_claude_ai_auth:X.isClaudeAiAuth,version:X.version,build_time:X.buildTime,deployment_environment:X.deploymentEnvironment};if(X.remoteEnvironmentType)w.remote_environment_type=X.remoteEnvironmentType;if(X.claudeCodeContainerId)w.claude_code_container_id=X.claudeCodeContainerId;if(X.claudeCodeRemoteSessionId)w.claude_code_remote_session_id=X.claudeCodeRemoteSessionId;if(X.tags)w.tags=X.tags.split(",").map((_)=>_.trim()).filter(Boolean);if(X.githubEventName)w.github_event_name=X.githubEventName;if(X.githubActionsRunnerEnvironment)w.github_actions_runner_environment=X.githubActionsRunnerEnvironment;if(X.githubActionsRunnerOs)w.github_actions_runner_os=X.githubActionsRunnerOs;if(X.githubActionRef)w.github_action_ref=X.githubActionRef;if(X.wslVersion)w.wsl_version=X.wslVersion;if(X.linuxDistroId)w.linux_distro_id=X.linuxDistroId;if(X.linuxDistroVersion)w.linux_distro_version=X.linuxDistroVersion;if(X.linuxKernel)w.linux_kernel=X.linuxKernel;if(X.vcs)w.vcs=X.vcs;if(X.versionBase)w.version_base=X.versionBase;let H={session_id:B.sessionId,model:B.model,user_type:B.userType,is_interactive:B.isInteractive==="true",client_type:B.clientType};if(B.betas)H.betas=B.betas;if(B.entrypoint)H.entrypoint=B.entrypoint;if(B.agentSdkVersion)H.agent_sdk_version=B.agentSdkVersion;if(B.sweBenchRunId)H.swe_bench_run_id=B.sweBenchRunId;if(B.sweBenchInstanceId)H.swe_bench_instance_id=B.sweBenchInstanceId;if(B.sweBenchTaskId)H.swe_bench_task_id=B.sweBenchTaskId;if(B.agentId)H.agent_id=B.agentId;if(B.parentSessionId)H.parent_session_id=B.parentSessionId;if(B.agentType)H.agent_type=B.agentType;if(B.teamName)H.team_name=B.teamName;if(J.githubActionsMetadata){let _=J.githubActionsMetadata;w.github_actions_metadata={actor_id:_.actorId,repository_id:_.repositoryId,repository_owner_id:_.repositoryOwnerId}}let z;if(J.accountUuid||J.organizationUuid)z={account_uuid:J.accountUuid,organization_uuid:J.organizationUuid};return{env:w,...Z&&{process:Buffer.from(A(Z)).toString("base64")},...z&&{auth:z},core:H,additional:{...q&&{rh:q},...Y&&{is_assistant_mode:!0},...W&&{skill_mode:W},...K&&{observer_mode:K},...Q}}}var hG,gG=512,mG=128,F3=4096,y$=20,uG=2,dG=10,cG,lG,nG,rG,oG,S$=null,J6=null;var X6=U(()=>{v2();H3();jJ();u0();n();j();_3();e();A4();T2();O3();X0();vG();hG=new Set([(yG(),kG(jG)).COMPUTER_USE_MCP_SERVER_NAME]);cG=new Set(["rm","mv","cp","touch","mkdir","chmod","chown","cat","head","tail","sort","stat","diff","wc","grep","rg","sed"]),lG=/\s*(?:&&|\|\||[;|])\s*/,nG=/\s+/;rG=j3(()=>{let $=MACRO.VERSION.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return $?$[0]:void 0}),oG=j3(async()=>{let[$,J,Q,X]=await Promise.all([s.getPackageManagers(),s.getRuntimes(),M3(),P3()]);return{platform:E$(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:s.arch,nodeVersion:s.nodeVersion,terminal:U3.terminal,packageManagers:$.join(","),runtimes:J.join(","),isRunningWithBun:s.isRunningWithBun(),isCi:R(process.env.CI),isClaubbit:R(process.env.CLAUBBIT),isClaudeCodeRemote:R(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT==="local-agent",isConductor:s.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...{},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:R(process.env.GITHUB_ACTIONS),isClaudeCodeAction:R(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:y(),version:MACRO.VERSION,versionBase:rG(),buildTime:MACRO.BUILD_TIME,deploymentEnvironment:s.detectDeploymentEnvironment(),...R(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes("claude-code-action/")?process.env.GITHUB_ACTION_PATH.split("claude-code-action/")[1]:void 0},...G4()&&{wslVersion:G4()},...Q??{},...X.length>0?{vcs:X.join(",")}:{}}})});import{ExportResultCode as m1}from"@opentelemetry/core";import f$ from"axios";import{randomUUID as aG}from"crypto";import{appendFile as tG,mkdir as b3,readdir as eG,unlink as h3,writeFile as $K}from"fs/promises";import*as b$ from"path";function K4(){return b$.join(b(),"telemetry")}class Z6{endpoint;timeout;maxBatchSize;skipAuth;batchDelayMs;baseBackoffDelayMs;maxBackoffDelayMs;maxAttempts;isKilled;pendingExports=[];isShutdown=!1;schedule;cancelBackoff=null;attempts=0;isRetrying=!1;lastExportErrorContext;constructor($={}){let J=$.baseUrl||(process.env.ANTHROPIC_BASE_URL==="https://api-staging.anthropic.com"?"https://api-staging.anthropic.com":"https://api.anthropic.com");this.endpoint=`${J}${$.path||"/api/event_logging/batch"}`,this.timeout=$.timeout||1e4,this.maxBatchSize=$.maxBatchSize||200,this.skipAuth=$.skipAuth??!1,this.batchDelayMs=$.batchDelayMs||100,this.baseBackoffDelayMs=$.baseBackoffDelayMs||500,this.maxBackoffDelayMs=$.maxBackoffDelayMs||30000,this.maxAttempts=$.maxAttempts??8,this.isKilled=$.isKilled??(()=>!1),this.schedule=$.schedule??((Q,X)=>{let Z=setTimeout(Q,X);return()=>clearTimeout(Z)}),this.retryPreviousBatches()}async getQueuedEventCount(){return(await this.loadEventsFromCurrentBatch()).length}getCurrentBatchFilePath(){return b$.join(K4(),`${g3}${A0()}.${p3}.json`)}async loadEventsFromFile($){try{return await u3($)}catch{return[]}}async loadEventsFromCurrentBatch(){return this.loadEventsFromFile(this.getCurrentBatchFilePath())}async saveEventsToFile($,J){try{if(J.length===0)try{await h3($)}catch{}else{await b3(K4(),{recursive:!0});let Q=J.map((X)=>A(X)).join(`
|
|
103
|
+
`)+`
|
|
104
|
+
`;await $K($,Q,"utf8")}}catch(Q){O(Q)}}async appendEventsToFile($,J){if(J.length===0)return;try{await b3(K4(),{recursive:!0});let Q=J.map((X)=>A(X)).join(`
|
|
105
|
+
`)+`
|
|
106
|
+
`;await tG($,Q,"utf8")}catch(Q){O(Q)}}async deleteFile($){try{await h3($)}catch{}}async retryPreviousBatches(){try{let $=`${g3}${A0()}.`,J;try{J=(await eG(K4())).filter((Q)=>Q.startsWith($)&&Q.endsWith(".json")).filter((Q)=>!Q.includes(p3))}catch(Q){if(h$(Q))return;throw Q}for(let Q of J){let X=b$.join(K4(),Q);this.retryFileInBackground(X)}}catch($){O($)}}async retryFileInBackground($){if(this.attempts>=this.maxAttempts){await this.deleteFile($);return}let J=await this.loadEventsFromFile($);if(J.length===0){await this.deleteFile($);return}if(process.env.USER_TYPE==="ant")L(`1P event logging: retrying ${J.length} events from previous batch`);let Q=await this.sendEventsInBatches(J);if(Q.length===0){if(await this.deleteFile($),process.env.USER_TYPE==="ant")L("1P event logging: previous batch retry succeeded")}else if(await this.saveEventsToFile($,Q),process.env.USER_TYPE==="ant")L(`1P event logging: previous batch retry failed, ${Q.length} events remain`)}async export($,J){if(this.isShutdown){if(process.env.USER_TYPE==="ant")L("1P event logging export failed: Exporter has been shutdown");J({code:m1.FAILED,error:Error("Exporter has been shutdown")});return}let Q=this.doExport($,J);this.pendingExports.push(Q),Q.finally(()=>{let X=this.pendingExports.indexOf(Q);if(X>-1)this.pendingExports.splice(X,1)})}async doExport($,J){try{let Q=$.filter((q)=>q.instrumentationScope?.name==="com.anthropic.claude_code.events");if(Q.length===0){J({code:m1.SUCCESS});return}let X=this.transformLogsToEvents(Q).events;if(X.length===0){J({code:m1.SUCCESS});return}if(this.attempts>=this.maxAttempts){J({code:m1.FAILED,error:Error(`Dropped ${X.length} events: max attempts (${this.maxAttempts}) reached`)});return}let Z=await this.sendEventsInBatches(X);if(this.attempts++,Z.length>0){await this.queueFailedEvents(Z),this.scheduleBackoffRetry();let q=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:"";J({code:m1.FAILED,error:Error(`Failed to export ${Z.length} events${q}`)});return}if(this.resetBackoff(),await this.getQueuedEventCount()>0&&!this.isRetrying)this.retryFailedEvents();J({code:m1.SUCCESS})}catch(Q){if(process.env.USER_TYPE==="ant")L(`1P event logging export failed: ${o(Q)}`);O(Q),J({code:m1.FAILED,error:u1(Q)})}}async sendEventsInBatches($){let J=[];for(let Z=0;Z<$.length;Z+=this.maxBatchSize)J.push($.slice(Z,Z+this.maxBatchSize));if(process.env.USER_TYPE==="ant")L(`1P event logging: exporting ${$.length} events in ${J.length} batch(es)`);let Q=[],X;for(let Z=0;Z<J.length;Z++){let q=J[Z];try{await this.sendBatchWithRetry({events:q})}catch(Y){X=JK(Y);for(let W=Z;W<J.length;W++)Q.push(...J[W]);if(process.env.USER_TYPE==="ant"){let W=J.length-1-Z;L(`1P event logging: batch ${Z+1}/${J.length} failed (${X}); short-circuiting ${W} remaining batch(es)`)}break}if(Z<J.length-1&&this.batchDelayMs>0)await Z4(this.batchDelayMs)}if(Q.length>0&&X)this.lastExportErrorContext=X;return Q}async queueFailedEvents($){let J=this.getCurrentBatchFilePath();await this.appendEventsToFile(J,$);let Q=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:"",X=`1P event logging: ${$.length} events failed to export${Q}`;O(Error(X))}scheduleBackoffRetry(){if(this.cancelBackoff||this.isRetrying||this.isShutdown)return;let $=Math.min(this.baseBackoffDelayMs*this.attempts*this.attempts,this.maxBackoffDelayMs);if(process.env.USER_TYPE==="ant")L(`1P event logging: scheduling backoff retry in ${$}ms (attempt ${this.attempts})`);this.cancelBackoff=this.schedule(async()=>{this.cancelBackoff=null,await this.retryFailedEvents()},$)}async retryFailedEvents(){let $=this.getCurrentBatchFilePath();while(!this.isShutdown){let J=await this.loadEventsFromFile($);if(J.length===0)break;if(this.attempts>=this.maxAttempts){if(process.env.USER_TYPE==="ant")L(`1P event logging: max attempts (${this.maxAttempts}) reached, dropping ${J.length} events`);await this.deleteFile($),this.resetBackoff();return}if(this.isRetrying=!0,await this.deleteFile($),process.env.USER_TYPE==="ant")L(`1P event logging: retrying ${J.length} failed events (attempt ${this.attempts+1})`);let Q=await this.sendEventsInBatches(J);if(this.attempts++,this.isRetrying=!1,Q.length>0){await this.saveEventsToFile($,Q),this.scheduleBackoffRetry();return}if(this.resetBackoff(),process.env.USER_TYPE==="ant")L("1P event logging: backoff retry succeeded")}}resetBackoff(){if(this.attempts=0,this.cancelBackoff)this.cancelBackoff(),this.cancelBackoff=null}async sendBatchWithRetry($){if(this.isKilled())throw Error("firstParty sink killswitch active");let J={"Content-Type":"application/json","User-Agent":P$(),"x-service-name":"claude-code"},Q=t()||u();if(process.env.USER_TYPE==="ant"&&!Q)L("1P event logging: Trust not accepted");let X=this.skipAuth||!Q;if(!X&&y()){let W=C();if(!g0())X=!0;else if(W&&E1(W.expiresAt)){if(X=!0,process.env.USER_TYPE==="ant")L("1P event logging: OAuth token expired, skipping auth to avoid 401")}}let Z=X?{headers:{},error:"trust not established or Oauth token expired"}:q4(),q=!Z.error;if(!q&&process.env.USER_TYPE==="ant")L("1P event logging: auth not available, sending without auth");let Y=q?{...J,...Z.headers}:J;try{let W=await f$.post(this.endpoint,$,{timeout:this.timeout,headers:Y});this.logSuccess($.events.length,q,W.data);return}catch(W){if(q&&f$.isAxiosError(W)&&W.response?.status===401){if(process.env.USER_TYPE==="ant")L("1P event logging: 401 auth error, retrying without auth");let K=await f$.post(this.endpoint,$,{timeout:this.timeout,headers:J});this.logSuccess($.events.length,!1,K.data);return}throw W}}logSuccess($,J,Q){if(process.env.USER_TYPE==="ant")L(`1P event logging: ${$} events exported successfully${J?" (with auth)":" (without auth)"}`),L(`API Response: ${A(Q,null,2)}`)}hrTimeToDate($){let[J,Q]=$;return new Date(J*1000+Q/1e6)}transformLogsToEvents($){let J=[];for(let Q of $){let X=Q.attributes||{};if(X.event_type==="GrowthbookExperimentEvent"){let M=this.hrTimeToDate(Q.hrTime),k=X.account_uuid,F1=X.organization_uuid;J.push({event_type:"GrowthbookExperimentEvent",event_data:eJ.toJSON({event_id:X.event_id,timestamp:M,experiment_id:X.experiment_id,variation_id:X.variation_id,environment:X.environment,user_attributes:X.user_attributes,experiment_metadata:X.experiment_metadata,device_id:X.device_id,session_id:X.session_id,auth:k||F1?{account_uuid:k,organization_uuid:F1}:void 0})});continue}let Z=X.event_name||Q.body||"unknown",q=X.core_metadata,Y=X.user_metadata,W=X.event_metadata||{};if(!q){if(process.env.USER_TYPE==="ant")L(`1P event logging: core_metadata missing for event ${Z}`);J.push({event_type:"ClaudeCodeInternalEvent",event_data:v$.toJSON({event_id:X.event_id,event_name:Z,client_timestamp:this.hrTimeToDate(Q.hrTime),session_id:A0(),additional_metadata:Buffer.from(A({transform_error:"core_metadata attribute is missing"})).toString("base64")})});continue}let K=f3(q,Y,W),{_PROTO_skill_name:B,_PROTO_plugin_name:w,_PROTO_marketplace_name:H,...z}=K.additional,_=m3(z);J.push({event_type:"ClaudeCodeInternalEvent",event_data:v$.toJSON({event_id:X.event_id,event_name:Z,client_timestamp:this.hrTimeToDate(Q.hrTime),device_id:X.user_id,email:Y?.email,auth:K.auth,...K.core,env:K.env,process:K.process,skill_name:typeof B==="string"?B:void 0,plugin_name:typeof w==="string"?w:void 0,marketplace_name:typeof H==="string"?H:void 0,additional_metadata:Object.keys(_).length>0?Buffer.from(A(_)).toString("base64"):void 0})})}return{events:J}}async shutdown(){if(this.isShutdown=!0,this.resetBackoff(),await this.forceFlush(),process.env.USER_TYPE==="ant")L("1P event logging exporter shutdown complete")}async forceFlush(){if(await Promise.all(this.pendingExports),process.env.USER_TYPE==="ant")L("1P event logging exporter flush complete")}}function JK($){if(!f$.isAxiosError($))return o($);let J=[],Q=$.response?.headers?.["request-id"];if(Q)J.push(`request-id=${Q}`);if($.response?.status)J.push(`status=${$.response.status}`);if($.code)J.push(`code=${$.code}`);if($.message)J.push($.message);return J.join(", ")}var p3,g3="1p_failed_events.";var d3=U(()=>{n();W3();V3();e();D0();p();j();N0();N$();k2();W0();SZ();X0();iJ();o4();V1();X6();p3=aG()});function p$($){return B4(QK,{})?.[$]===!0}var QK="tengu_frond_boric";var c3=U(()=>{Q1()});import{resourceFromAttributes as XK}from"@opentelemetry/resources";import{BatchLogRecordProcessor as ZK,LoggerProvider as qK}from"@opentelemetry/sdk-logs";import{ATTR_SERVICE_NAME as YK,ATTR_SERVICE_VERSION as WK}from"@opentelemetry/semantic-conventions";import{randomUUID as l3}from"crypto";import{isEqual as VK}from"lodash-es";function KK(){return B4(GK,{})}function gz($){let Q=KK()[$];if(!Q)return null;let X=Q.sample_rate;if(typeof X!=="number"||X<0||X>1)return null;if(X>=1)return null;if(X<=0)return 0;return Math.random()<X?X:0}function i3(){return B4(n3,{})}async function mz(){if(!N1)return;try{if(await N1.shutdown(),process.env.USER_TYPE==="ant")L("1P event logging: final shutdown complete")}catch{}}function V2(){return!X3()}async function BK($,J,Q={}){try{let X=await S3({model:Q.model,betas:Q.betas}),Z={event_name:J,event_id:l3(),core_metadata:X,user_metadata:W2(!0),event_metadata:Q},q=j2();if(q)Z.user_id=q;if(process.env.USER_TYPE==="ant")L(`[ANT-ONLY] 1P event: ${J} ${A(Q,null,0)}`);$.emit({body:J,attributes:Z})}catch(X){throw X}}function uz($,J={}){if(!V2())return;if(!D1||p$("firstParty"))return;BK(D1,$,J)}function LK(){return"production"}function o3($){if(!V2())return;if(!D1||p$("firstParty"))return;let J=j2(),{accountUuid:Q,organizationUuid:X}=W2(!0),Z={event_type:"GrowthbookExperimentEvent",event_id:l3(),experiment_id:$.experimentId,variation_id:$.variationId,...J&&{device_id:J},...Q&&{account_uuid:Q},...X&&{organization_uuid:X},...$.userAttributes&&{session_id:$.userAttributes.sessionId,user_attributes:A($.userAttributes)},...$.experimentMetadata&&{experiment_metadata:A($.experimentMetadata)},environment:LK()};if(process.env.USER_TYPE==="ant")L(`[ANT-ONLY] 1P GrowthBook experiment: ${$.experimentId} variation=${$.variationId}`);D1.emit({body:"growthbook_experiment",attributes:Z})}function RK(){if(n0("1p_event_logging_start"),!V2()){if(process.env.USER_TYPE==="ant")L("1P event logging not enabled");return}let J=i3();r3=J,n0("1p_event_after_growthbook_config");let Q=J.scheduledDelayMillis||parseInt(process.env.OTEL_LOGS_EXPORT_INTERVAL||UK.toString()),X=J.maxExportBatchSize||HK,Z=J.maxQueueSize||wK,q=j0(),Y={[YK]:"claude-code",[WK]:MACRO.VERSION};if(q==="wsl"){let B=G4();if(B)Y["wsl.version"]=B}let W=XK(Y),K=new Z6({maxBatchSize:X,skipAuth:J.skipAuth,maxAttempts:J.maxAttempts,path:J.path,baseUrl:J.baseUrl,isKilled:()=>p$("firstParty")});N1=new qK({resource:W,processors:[new ZK(K,{scheduledDelayMillis:Q,maxExportBatchSize:X,maxQueueSize:Z})]}),D1=N1.getLogger("com.anthropic.claude_code.events",MACRO.VERSION)}async function dz(){if(!V2()||!N1)return;let $=i3();if(VK($,r3))return;if(process.env.USER_TYPE==="ant")L(`1P event logging: ${n3} changed, reinitializing`);let J=N1,Q=D1;D1=null;try{await J.forceFlush()}catch{}N1=null;try{RK()}catch(X){N1=J,D1=Q,O(X);return}J.shutdown().catch(()=>{})}var GK="tengu_event_sampling_config",n3="tengu_1p_event_batch_config",D1=null,N1=null,r3=null,UK=1e4,HK=200,wK=8192;var s3=U(()=>{D0();p();W0();T2();X0();q6();rJ();Z3();d3();Q1();X6();c3()});import{GrowthBook as _K}from"@growthbook/growthbook";import{isEqual as t3,memoize as e3}from"lodash-es";function a3($){try{Promise.resolve($()).catch((J)=>{O(J)})}catch(J){O(J)}}function Zx($){let J=!0,Q=B2.subscribe(()=>a3($));if(w0.size>0)queueMicrotask(()=>{if(J&&w0.size>0)a3($)});return()=>{J=!1,Q()}}function L2(){if(!W6){if(W6=!0,process.env.USER_TYPE==="ant"){let $=process.env.CLAUDE_INTERNAL_FC_OVERRIDES;if($)try{L4=JSON.parse($),L(`GrowthBook: Using env var overrides for ${Object.keys(L4).length} features: ${Object.keys(L4).join(", ")}`)}catch{O(Error(`GrowthBook: Failed to parse CLAUDE_INTERNAL_FC_OVERRIDES: ${$}`))}}}return L4}function qx($){let J=L2();return J!==null&&$ in J}function U2(){if(process.env.USER_TYPE!=="ant")return;try{return I().growthBookOverrides}catch{return}}function Yx(){if(w0.size>0)return Object.fromEntries(w0);return I().cachedGrowthBookFeatures??{}}function Wx(){return U2()??{}}function Vx($,J){if(process.env.USER_TYPE!=="ant")return;try{l((Q)=>{let X=Q.growthBookOverrides??{};if(J===void 0){if(!($ in X))return Q;let{[$]:Z,...q}=X;if(Object.keys(q).length===0){let{growthBookOverrides:Y,...W}=Q;return W}return{...Q,growthBookOverrides:q}}if(t3(X[$],J))return Q;return{...Q,growthBookOverrides:{...X,[$]:J}}}),B2.emit()}catch(Q){O(Q)}}function Gx(){if(process.env.USER_TYPE!=="ant")return;try{l(($)=>{if(!$.growthBookOverrides||Object.keys($.growthBookOverrides).length===0)return $;let{growthBookOverrides:J,...Q}=$;return Q}),B2.emit()}catch($){O($)}}function R4($){if(Y6.has($))return;let J=c1.get($);if(J)Y6.add($),o3({experimentId:J.experimentId,variationId:J.variationId,userAttributes:Qq(),experimentMetadata:{feature_id:$}})}async function $q($){let J=$.getPayload();if(!J?.features||Object.keys(J.features).length===0)return!1;c1.clear();let Q={};for(let[X,Z]of Object.entries(J.features)){let q=Z;if("value"in q&&!("defaultValue"in q))Q[X]={...q,defaultValue:q.value};else Q[X]=q;if(q.source==="experiment"&&q.experimentResult){let{experimentResult:Y,experiment:W}=q;if(W?.key&&Y.variationId!==void 0)c1.set(X,{experimentId:W.key,variationId:Y.variationId})}}await $.setPayload({...J,features:Q}),w0.clear();for(let[X,Z]of Object.entries(Q)){let q="value"in Z?Z.value:Z.defaultValue;if(q!==void 0)w0.set(X,q)}return!0}function Jq(){let $=Object.fromEntries(w0),J=I();if(t3(J.cachedGrowthBookFeatures,$))return;l((Q)=>({...Q,cachedGrowthBookFeatures:$}))}function r0(){if(!K8())return!1;return V2()}function NK(){let $=process.env.ANTHROPIC_BASE_URL;if(!$)return;try{let J=new URL($).host;if(J==="api.anthropic.com")return;return J}catch{return}}function Qq(){let $=J3(),J=$.email;if(!J&&process.env.USER_TYPE==="ant")J=I().oauthAccount?.emailAddress;let Q=NK();return{id:$.deviceId,sessionId:$.sessionId,deviceID:$.deviceId,platform:$.platform,...Q&&{apiBaseUrlHost:Q},...$.organizationUuid&&{organizationUUID:$.organizationUuid},...$.accountUuid&&{accountUUID:$.accountUuid},...$.userType&&{userType:$.userType},...$.subscriptionType&&{subscriptionType:$.subscriptionType},...$.rateLimitTier&&{rateLimitTier:$.rateLimitTier},...$.firstTokenTime&&{firstTokenTime:$.firstTokenTime},...J&&{email:J},...$.appVersion&&{appVersion:$.appVersion},...$.githubActionsMetadata&&{githubActionsMetadata:$.githubActionsMetadata}}}async function Xq($,J,Q){let X=L2();if(X&&$ in X)return X[$];let Z=U2();if(Z&&$ in Z)return Z[$];if(!r0())return J;let q=await g$();if(!q)return J;let Y;if(w0.has($))Y=w0.get($);else Y=q.getFeatureValue($,J);if(Q)R4($);if(process.env.USER_TYPE==="ant")L(`GrowthBook: getFeatureValue("${$}") = ${A(Y)}`);return Y}async function DK($,J){return Xq($,J,!0)}function Z0($,J){let Q=L2();if(Q&&$ in Q)return Q[$];let X=U2();if(X&&$ in X)return X[$];if(!r0())return J;if(c1.has($))R4($);else K2.add($);if(w0.has($))return w0.get($);try{let Z=I().cachedGrowthBookFeatures?.[$];return Z!==void 0?Z:J}catch{return J}}function Kx($,J,Q){return Z0($,J)}function zZ($){let J=L2();if(J&&$ in J)return Boolean(J[$]);let Q=U2();if(Q&&$ in Q)return Boolean(Q[$]);if(!r0())return!1;if(c1.has($))R4($);else K2.add($);let X=I(),Z=X.cachedGrowthBookFeatures?.[$];if(Z!==void 0)return Boolean(Z);return X.cachedStatsigGates?.[$]??!1}async function Bx($){let J=L2();if(J&&$ in J)return Boolean(J[$]);let Q=U2();if(Q&&$ in Q)return Boolean(Q[$]);if(!r0())return!1;if(w4)await w4;let X=I(),Z=X.cachedStatsigGates?.[$];if(Z!==void 0)return Boolean(Z);let q=X.cachedGrowthBookFeatures?.[$];if(q!==void 0)return Boolean(q);return!1}async function Lx($){let J=L2();if(J&&$ in J)return Boolean(J[$]);let Q=U2();if(Q&&$ in Q)return Boolean(Q[$]);if(!r0())return!1;if(I().cachedGrowthBookFeatures?.[$]===!0){if(c1.has($))R4($);else K2.add($);return!0}return Xq($,!1,!0)}function Ux(){if(!r0())return;try{Zq(),B2.emit(),w4=g$().catch(($)=>{return O(u1($)),null}).finally(()=>{w4=null})}catch($){throw $}}function Zq(){if(qq(),U4)process.off("beforeExit",U4),U4=null;if(H4)process.off("exit",H4),H4=null;i0?.destroy(),i0=null,G6=!1,w4=null,c1.clear(),K2.clear(),Y6.clear(),w0.clear(),V6.cache?.clear?.(),g$.cache?.clear?.(),L4=null,W6=!1}async function FK(){if(!r0())return;try{let $=await g$();if(!$)return;if(await $.refreshFeatures(),$!==i0){if(process.env.USER_TYPE==="ant")L("GrowthBook: Skipping refresh processing for replaced client");return}let J=await $q($);if($!==i0)return;if(process.env.USER_TYPE==="ant")L("GrowthBook: Light refresh completed");if(J)Jq(),B2.emit()}catch($){throw $}}function zK(){if(!r0())return;if(d1)clearInterval(d1);if(d1=setInterval(()=>{FK()},OK),d1.unref?.(),!G2)G2=()=>{qq()},process.once("beforeExit",G2)}function qq(){if(d1)clearInterval(d1),d1=null;if(G2)process.removeListener("beforeExit",G2),G2=null}async function Hx($,J){return DK($,J)}function B4($,J){return Z0($,J)}var i0=null,U4=null,H4=null,G6=!1,c1,w0,K2,Y6,w4=null,B2,L4=null,W6=!1,V6,g$,OK,d1=null,G2=null;var Q1=U(()=>{n();l6();D0();p();N0();N$();W0();a8();X0();rJ();s3();c1=new Map,w0=new Map,K2=new Set,Y6=new Set,B2=m0();V6=e3(()=>{if(!r0())return null;let $=Qq(),J=K8();if(process.env.USER_TYPE==="ant")L(`GrowthBook: Creating client with clientKey=${J}, attributes: ${A($)}`);let Q=process.env.USER_TYPE==="ant"?process.env.CLAUDE_CODE_GB_BASE_URL||"https://api.anthropic.com/":"https://api.anthropic.com/",Z=t()||C2()||u()?q4():{headers:{},error:"trust not established"},q=!Z.error;G6=q;let Y=new _K({apiHost:Q,clientKey:J,attributes:$,remoteEval:!0,cacheKeyAttributes:["id","organizationUUID"],...Z.error?{}:{apiHostRequestHeaders:Z.headers},...process.env.USER_TYPE==="ant"?{log:(K,B)=>{L(`GrowthBook: ${K} ${A(B)}`)}}:{}});if(i0=Y,!q)return{client:Y,initialized:Promise.resolve()};let W=Y.init({timeout:5000}).then(async(K)=>{if(i0!==Y){if(process.env.USER_TYPE==="ant")L("GrowthBook: Skipping init callback for replaced client");return}if(process.env.USER_TYPE==="ant")L(`GrowthBook initialized successfully, source: ${K.source}, success: ${K.success}`);let B=await $q(Y);if(i0!==Y)return;if(B){for(let w of K2)R4(w);K2.clear(),Jq(),B2.emit()}if(process.env.USER_TYPE==="ant"){let w=Y.getFeatures();if(w){let H=Object.keys(w);L(`GrowthBook loaded ${H.length} features: ${H.slice(0,10).join(", ")}${H.length>10?"...":""}`)}}}).catch((K)=>{if(process.env.USER_TYPE==="ant")O(u1(K))});return U4=()=>i0?.destroy(),H4=()=>i0?.destroy(),process.on("beforeExit",U4),process.on("exit",H4),{client:Y,initialized:W}}),g$=e3(async()=>{let $=V6();if(!$)return null;if(!G6){if(t()||C2()||u()){if(!q4().error){if(process.env.USER_TYPE==="ant")L("GrowthBook: Auth became available after client creation, reinitializing");if(Zq(),$=V6(),!$)return null}}}return await $.initialized,zK(),$.client});OK=process.env.USER_TYPE!=="ant"?21600000:1200000});class Yq{cache=new Map;maxCacheSize=1000;readFile($){let J=x(),Q;try{Q=J.statSync($)}catch(W){throw this.cache.delete($),W}let X=$,Z=this.cache.get(X);if(Z&&Z.mtime===Q.mtimeMs)return{content:Z.content,encoding:Z.encoding};let q=Gq($),Y=J.readFileSync($,{encoding:q}).replaceAll(`\r
|
|
107
|
+
`,`
|
|
108
|
+
`);if(this.cache.set(X,{content:Y,encoding:q,mtime:Q.mtimeMs}),this.cache.size>this.maxCacheSize){let W=this.cache.keys().next().value;if(W)this.cache.delete(W)}return{content:Y,encoding:q}}clear(){this.cache.clear()}invalidate($){this.cache.delete($)}getStats(){return{size:this.cache.size,entries:Array.from(this.cache.keys())}}}var Wq;var Vq=U(()=>{f4();$1();Wq=new Yq});import{chmodSync as xK,writeFileSync as Kq}from"fs";import{realpath as IK,stat as Hq}from"fs/promises";import{homedir as wq}from"os";import{basename as K6,dirname as m$,extname as Bq,isAbsolute as TK,join as H2,normalize as MK,relative as Rq,resolve as PK,sep as _4}from"path";async function yx($){try{return await Hq($),!0}catch{return!1}}function Sx($){try{return x().readFileSync($,{encoding:"utf8"})}catch(J){return O(J),null}}function fx($){let J=x();return Math.floor(J.statSync($).mtimeMs)}async function bx($){let J=await x().stat($);return Math.floor(J.mtimeMs)}function hx($,J,Q,X){let Z=J;if(X==="CRLF")Z=J.replaceAll(`\r
|
|
109
|
+
`,`
|
|
110
|
+
`).split(`
|
|
111
|
+
`).join(`\r
|
|
112
|
+
`);i1($,Z,{encoding:Q})}function Gq($){try{let J=x(),{resolvedPath:Q}=e0(J,$);return W8(Q)}catch(J){if(h$(J))L(`detectFileEncoding failed for expected reason: ${J.code}`,{level:"debug"});else O(J);return"utf8"}}function px($,J="utf8"){try{let Q=x(),{resolvedPath:X}=e0(Q,$),{buffer:Z,bytesRead:q}=Q.readSync(X,{length:4096}),Y=Z.toString(J,0,q);return V8(Y)}catch(Q){return O(Q),"LF"}}function gx($){if(!$.includes("\t"))return $;return $.replace(/^\t+/gm,(J)=>" ".repeat(J.length))}function AK($){let J=$?Uq($):void 0,Q=J?Rq(S0(),J):void 0;return{absolutePath:J,relativePath:Q}}function mx($){let{relativePath:J}=AK($);if(J&&!J.startsWith(".."))return J;let Q=wq();if($.startsWith(Q+_4))return"~"+$.slice(Q.length);return $}function ux($){let J=x();try{let Q=m$($),X=K6($,Bq($)),Y=J.readdirSync(Q).filter((W)=>K6(W.name,Bq(W.name))===X&&H2(Q,W.name)!==$)[0];if(Y)return Y.name;return}catch(Q){if(!U1(Q))O(Q);return}}async function cx($){let J=S0(),Q=m$(J),X=$;try{let W=await IK(m$($));X=H2(W,K6($))}catch{}let Z=Q===_4?_4:Q+_4;if(!X.startsWith(Z)||X.startsWith(J+_4)||X===J)return;let q=Rq(Q,X),Y=H2(J,q);try{return await Hq(Y),Y}catch{return}}function CK(){return!Z0("tengu_compact_line_prefix_killswitch",!1)}function lx({content:$,startLine:J}){if(!$)return"";let Q=$.split(/\r?\n/);if(CK())return Q.map((X,Z)=>`${Z+J} ${X}`).join(`
|
|
113
|
+
`);return Q.map((X,Z)=>{let q=String(Z+J);if(q.length>=6)return`${q}\u2192${X}`;return`${q.padStart(6," ")}\u2192${X}`}).join(`
|
|
114
|
+
`)}function nx($){return $.match(/^\s*\d+[\u2192\t](.*)$/)?.[1]??$}function ix($){try{return x().isDirEmptySync($)}catch(J){return U1(J)}}function rx($){let{content:J}=Wq.readFile($);return J}function i1($,J,Q={encoding:"utf-8"}){let X=x(),Z=$;try{let K=X.readlinkSync($);Z=TK(K)?K:PK(m$($),K),L(`Writing through symlink: ${$} -> ${Z}`)}catch{}let q=`${Z}.tmp.${process.pid}.${Date.now()}`,Y,W=!1;try{Y=X.statSync(Z).mode,W=!0,L(`Preserving file permissions: ${Y.toString(8)}`)}catch(K){if(!U1(K))throw K;if(Q.mode!==void 0)Y=Q.mode,L(`Setting permissions for new file: ${Y.toString(8)}`)}try{L(`Writing to temp file: ${q}`);let K={encoding:Q.encoding,flush:!0};if(!W&&Q.mode!==void 0)K.mode=Q.mode;if(Kq(q,J,K),L(`Temp file written successfully, size: ${J.length} bytes`),W&&Y!==void 0)xK(q,Y),L("Applied original permissions to temp file");L(`Renaming ${q} to ${Z}`),X.renameSync(q,Z),L(`File ${Z} written atomically`)}catch(K){L(`Failed to write file atomically: ${K}`,{level:"error"}),F("tengu_atomic_write_error",{});try{L(`Cleaning up temp file: ${q}`),X.unlinkSync(q)}catch(B){L(`Failed to clean up temp file: ${B}`)}L(`Falling back to non-atomic write for ${Z}`);try{let B={encoding:Q.encoding,flush:!0};if(!W&&Q.mode!==void 0)B.mode=Q.mode;Kq(Z,J,B),L(`File ${Z} written successfully with non-atomic fallback`)}catch(B){throw L(`Non-atomic write also failed: ${B}`),B}}}function ox(){let $=j0(),J=wq();if($==="macos")return H2(J,"Desktop");if($==="windows"){let X=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,"/"):null;if(X){let q=`/mnt/c${X.replace(/^[A-Z]:/,"")}/Desktop`;if(x().existsSync(q))return q}try{let q=x().readdirSync("/mnt/c/Users");for(let Y of q){if(Y.name==="Public"||Y.name==="Default"||Y.name==="Default User"||Y.name==="All Users")continue;let W=H2("/mnt/c/Users",Y.name,"Desktop");if(x().existsSync(W))return W}}catch(Z){O(Z)}}let Q=H2(J,"Desktop");if(x().existsSync(Q))return Q;return J}function sx($,J=EK){try{return x().statSync($).size<=J}catch{return!1}}function Lq($){let J=MK($);if(j0()==="windows")J=J.replace(/\//g,"\\").toLowerCase();return J}function ax($,J){return Lq($)===Lq(J)}var EK=262144,dx="Note: your current working directory is";var f4=U(()=>{V1();Q1();S4();p();N0();F2();Vq();$1();W0();L8();T2()});import{appendFile as kK,mkdir as vK,readFile as jK,writeFile as yK}from"fs/promises";import{homedir as SK}from"os";import{dirname as fK,join as bK}from"path";async function hK($,J){let{code:Q}=await p1("git",["check-ignore",$],{preserveOutputOnError:!1,cwd:J});return Q===0}function pK(){return bK(SK(),".config","git","ignore")}async function Nq($,J=S0()){try{if(!await _q(J))return;let Q=`**/${$}`,X=$.endsWith("/")?`${$}sample-file.txt`:$;if(await hK(X,J))return;let Z=pK(),q=fK(Z);await vK(q,{recursive:!0});try{if((await jK(Z,{encoding:"utf-8"})).includes(Q))return;await kK(Z,`
|
|
115
|
+
${Q}
|
|
116
|
+
`)}catch(Y){if(Y0(Y)==="ENOENT")await yK(Z,`${Q}
|
|
117
|
+
`,"utf-8");else throw Y}}catch(Q){O(Q)}}var Dq=U(()=>{S4();N0();b2();A4();W0()});function KI($){switch($){case"userSettings":return"user";case"projectSettings":return"project";case"localSettings":return"project, gitignored";case"flagSettings":return"cli flag";case"policySettings":return"managed"}}function BI($){switch($){case"userSettings":return"User";case"projectSettings":return"Project";case"localSettings":return"Local";case"flagSettings":return"Flag";case"policySettings":return"Managed";case"plugin":return"Plugin";case"built-in":return"Built-in"}}function LI($){switch($){case"userSettings":return"user settings";case"projectSettings":return"shared project settings";case"localSettings":return"project local settings";case"flagSettings":return"command line arguments";case"policySettings":return"enterprise managed settings";case"cliArg":return"CLI argument";case"command":return"command configuration";case"session":return"current session"}}function UI($){switch($){case"userSettings":return"User settings";case"projectSettings":return"Shared project settings";case"localSettings":return"Project local settings";case"flagSettings":return"Command line arguments";case"policySettings":return"Enterprise managed settings";case"cliArg":return"CLI argument";case"command":return"Command configuration";case"session":return"Current session"}}function HI($){if($==="")return[];let J=$.split(",").map((X)=>X.trim()),Q=[];for(let X of J)switch(X){case"user":Q.push("userSettings");break;case"project":Q.push("projectSettings");break;case"local":Q.push("localSettings");break;default:throw Error(`Invalid setting source: ${X}. Valid options are: user, project, local`)}return Q}function N4(){let $=Oq(),J=new Set($);return J.add("policySettings"),J.add("flagSettings"),Array.from(J)}function wI($){return N4().includes($)}var GI,RI,Fq="https://json.schemastore.org/claude-code-settings.json";var B6=U(()=>{n();GI=["userSettings","projectSettings","localSettings","flagSettings","policySettings"];RI=["localSettings","projectSettings","userSettings"]});function zq($){u$.set($,Date.now())}function NI($,J){let Q=u$.get($);if(Q!==void 0&&Date.now()-Q<J)return u$.delete($),!0;return!1}function DI(){u$.clear()}var u$;var xq=U(()=>{u$=new Map});import{z as E}from"zod/v4";var gK,mK,Iq;var Tq=U(()=>{b1();gK=D(()=>E.object({allowedDomains:E.array(E.string()).optional(),allowManagedDomainsOnly:E.boolean().optional().describe("When true (and set in managed settings), only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. User, project, local, and flag settings domains are ignored. Denied domains are still respected from all sources."),allowUnixSockets:E.array(E.string()).optional().describe("macOS only: Unix socket paths to allow. Ignored on Linux (seccomp cannot filter by path)."),allowAllUnixSockets:E.boolean().optional().describe("If true, allow all Unix sockets (disables blocking on both platforms)."),allowLocalBinding:E.boolean().optional(),httpProxyPort:E.number().optional(),socksProxyPort:E.number().optional()}).optional()),mK=D(()=>E.object({allowWrite:E.array(E.string()).optional().describe("Additional paths to allow writing within the sandbox. Merged with paths from Edit(...) allow permission rules."),denyWrite:E.array(E.string()).optional().describe("Additional paths to deny writing within the sandbox. Merged with paths from Edit(...) deny permission rules."),denyRead:E.array(E.string()).optional().describe("Additional paths to deny reading within the sandbox. Merged with paths from Read(...) deny permission rules."),allowRead:E.array(E.string()).optional().describe("Paths to re-allow reading within denyRead regions. Takes precedence over denyRead for matching paths."),allowManagedReadPathsOnly:E.boolean().optional().describe("When true (set in managed settings), only allowRead paths from policySettings are used.")}).optional()),Iq=D(()=>E.object({enabled:E.boolean().optional(),failIfUnavailable:E.boolean().optional().describe("Exit with an error at startup if sandbox.enabled is true but the sandbox cannot start (missing dependencies, unsupported platform, or platform not in enabledPlatforms). When false (default), a warning is shown and commands run unsandboxed. Intended for managed-settings deployments that require sandboxing as a hard gate."),autoAllowBashIfSandboxed:E.boolean().optional(),allowUnsandboxedCommands:E.boolean().optional().describe("Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true."),network:gK(),filesystem:mK(),ignoreViolations:E.record(E.string(),E.array(E.string())).optional(),enableWeakerNestedSandbox:E.boolean().optional(),enableWeakerNetworkIsolation:E.boolean().optional().describe("macOS only: Allow access to com.apple.trustd.agent in the sandbox. Needed for Go-based CLI tools (gh, gcloud, terraform, etc.) to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. "+"**Reduces security** \u2014 opens a potential data exfiltration vector through the trustd service. Default: false"),excludedCommands:E.array(E.string()).optional(),ripgrep:E.object({command:E.string(),args:E.array(E.string()).optional()}).optional().describe("Custom ripgrep configuration for bundled ripgrep support")}).passthrough())});var D4,uK,L6;var Mq=U(()=>{D4=["acceptEdits","bypassPermissions","default","dontAsk","plan"],uK=[...D4,...[]],L6=uK});import Eq from"zod/v4";function jI($){if(process.env.USER_TYPE!=="ant")return!0;return $!=="auto"&&$!=="bubble"}function d$($){return Pq[$]??Pq.default}function yI($){return d$($).external}function SI($){return L6.includes($)?$:"default"}function fI($){return d$($).title}function bI($){return $==="default"||$===void 0}function hI($){return d$($).symbol}function pI($){return d$($).color}var kI,vI,Pq;var Aq=U(()=>{VJ();Mq();b1();kI=D(()=>Eq.enum(L6)),vI=D(()=>Eq.enum(D4)),Pq={default:{title:"Default",shortTitle:"Default",symbol:"",color:"text",external:"default"},plan:{title:"Plan Mode",shortTitle:"Plan",symbol:vQ,color:"planMode",external:"plan"},acceptEdits:{title:"Accept edits",shortTitle:"Accept",symbol:"\u23F5\u23F5",color:"autoAccept",external:"acceptEdits"},bypassPermissions:{title:"Bypass Permissions",shortTitle:"Bypass",symbol:"\u23F5\u23F5",color:"error",external:"bypassPermissions"},dontAsk:{title:"Don't Ask",shortTitle:"DontAsk",symbol:"\u23F5\u23F5",color:"error",external:"dontAsk"},...{}}});var Cq=()=>{};var kq;var vq=U(()=>{Cq();kq=["PreToolUse","PostToolUse","PostToolUseFailure","Notification","UserPromptSubmit","SessionStart","SessionEnd","Stop","StopFailure","SubagentStart","SubagentStop","PreCompact","PostCompact","PermissionRequest","PermissionDenied","Setup","TeammateIdle","TaskCreated","TaskCompleted","Elicitation","ElicitationResult","ConfigChange","WorktreeCreate","WorktreeRemove","InstructionsLoaded","CwdChanged","FileChanged"]});var jq=()=>{};var yq=()=>{};var Sq=U(()=>{vq();jq();yq()});var fq,iI="bash";var bq=U(()=>{fq=["bash","powershell"]});import{z as T}from"zod/v4";function dK(){let $=T.object({type:T.literal("command").describe("Shell command hook type"),command:T.string().describe("Shell command to execute"),if:c$(),shell:T.enum(fq).optional().describe("Shell interpreter. 'bash' uses your $SHELL (bash/zsh/sh); 'powershell' uses pwsh. Defaults to bash."),timeout:T.number().positive().optional().describe("Timeout in seconds for this specific command"),statusMessage:T.string().optional().describe("Custom status message to display in spinner while hook runs"),once:T.boolean().optional().describe("If true, hook runs once and is removed after execution"),async:T.boolean().optional().describe("If true, hook runs in background without blocking"),asyncRewake:T.boolean().optional().describe("If true, hook runs in background and wakes the model on exit code 2 (blocking error). Implies async.")}),J=T.object({type:T.literal("prompt").describe("LLM prompt hook type"),prompt:T.string().describe("Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON."),if:c$(),timeout:T.number().positive().optional().describe("Timeout in seconds for this specific prompt evaluation"),model:T.string().optional().describe('Model to use for this prompt hook (e.g., "claude-sonnet-4-6"). If not specified, uses the default small fast model.'),statusMessage:T.string().optional().describe("Custom status message to display in spinner while hook runs"),once:T.boolean().optional().describe("If true, hook runs once and is removed after execution")}),Q=T.object({type:T.literal("http").describe("HTTP hook type"),url:T.string().url().describe("URL to POST the hook input JSON to"),if:c$(),timeout:T.number().positive().optional().describe("Timeout in seconds for this specific request"),headers:T.record(T.string(),T.string()).optional().describe('Additional headers to include in the request. Values may reference environment variables using $VAR_NAME or ${VAR_NAME} syntax (e.g., "Authorization": "Bearer $MY_TOKEN"). Only variables listed in allowedEnvVars will be interpolated.'),allowedEnvVars:T.array(T.string()).optional().describe("Explicit list of environment variable names that may be interpolated in header values. Only variables listed here will be resolved; all other $VAR references are left as empty strings. Required for env var interpolation to work."),statusMessage:T.string().optional().describe("Custom status message to display in spinner while hook runs"),once:T.boolean().optional().describe("If true, hook runs once and is removed after execution")}),X=T.object({type:T.literal("agent").describe("Agentic verifier hook type"),prompt:T.string().describe('Prompt describing what to verify (e.g. "Verify that unit tests ran and passed."). Use $ARGUMENTS placeholder for hook input JSON.'),if:c$(),timeout:T.number().positive().optional().describe("Timeout in seconds for agent execution (default 60)"),model:T.string().optional().describe('Model to use for this agent hook (e.g., "claude-sonnet-4-6"). If not specified, uses Haiku.'),statusMessage:T.string().optional().describe("Custom status message to display in spinner while hook runs"),once:T.boolean().optional().describe("If true, hook runs once and is removed after execution")});return{BashCommandHookSchema:$,PromptHookSchema:J,HttpHookSchema:Q,AgentHookSchema:X}}var c$,hq,pq,l1;var l$=U(()=>{Sq();b1();bq();c$=D(()=>T.string().optional().describe('Permission rule syntax to filter when this hook runs (e.g., "Bash(git *)"). Only runs if the tool call matches the pattern. Avoids spawning hooks for non-matching commands.'));hq=D(()=>{let{BashCommandHookSchema:$,PromptHookSchema:J,AgentHookSchema:Q,HttpHookSchema:X}=dK();return T.discriminatedUnion("type",[$,J,Q,X])}),pq=D(()=>T.object({matcher:T.string().optional().describe('String pattern to match (e.g. tool names like "Write")'),hooks:T.array(hq()).describe("List of hooks to execute when the matcher matches")})),l1=D(()=>T.partialRecord(T.enum(kq),T.array(pq())))});import{z as V}from"zod/v4";function ZT($,J){let Q=$.toLowerCase();return J.autoUpdate??(r$.has(Q)&&!lK.has(Q))}function rK($){if(r$.has($.toLowerCase()))return!1;if(iK.test($))return!0;return nK.test($)}function qT($,J){let Q=$.toLowerCase();if(!r$.has(Q))return null;if(J.source==="github"){if(!(J.repo||"").toLowerCase().startsWith(`${n$}/`))return`The name '${$}' is reserved for official Anthropic marketplaces. Only repositories from 'github.com/${n$}/' can use this name.`;return null}if(J.source==="git"&&J.url){let X=J.url.toLowerCase(),Z=X.includes("github.com/anthropics/"),q=X.includes("git@github.com:anthropics/");if(Z||q)return null;return`The name '${$}' is reserved for official Anthropic marketplaces. Only repositories from 'github.com/${n$}/' can use this name.`}return`The name '${$}' is reserved for official Anthropic marketplaces and can only be used with GitHub sources from the '${n$}' organization.`}function WT($){return typeof $==="string"&&$.startsWith("./")}function VT($){return $.source==="file"||$.source==="directory"}var r$,lK,nK,iK,n$="anthropics",o0,w2,gq,w6,R6,dq,_6,oK,YT,sK,aK,tK,eK,$B,JB,mq,QB,XB,cq,ZB,qB,uq,YB,lq,WB,VB,O4,U6,nq,GB,KB,GT,i$,BB,LB,KT,UB,HB,wB,RB,_B,BT,NB,LT;var iq=U(()=>{l$();cK();b1();r$=new Set(["claude-code-marketplace","claude-code-plugins","claude-plugins-official","anthropic-marketplace","anthropic-plugins","agent-skills","life-sciences","knowledge-work-plugins"]),lK=new Set(["knowledge-work-plugins"]);nK=/(?:official[^a-z0-9]*(anthropic|claude)|(?:anthropic|claude)[^a-z0-9]*official|^(?:anthropic|claude)[^a-z0-9]*(marketplace|plugins|official))/i,iK=/[^\u0020-\u007E]/;o0=D(()=>V.string().startsWith("./")),w2=D(()=>o0().endsWith(".json")),gq=D(()=>V.union([o0().refine(($)=>$.endsWith(".mcpb")||$.endsWith(".dxt"),{message:"MCPB file path must end with .mcpb or .dxt"}).describe("Path to MCPB file relative to plugin root"),V.string().url().refine(($)=>$.endsWith(".mcpb")||$.endsWith(".dxt"),{message:"MCPB URL must end with .mcpb or .dxt"}).describe("URL to MCPB file")])),w6=D(()=>o0().endsWith(".md")),R6=D(()=>V.union([w6(),o0()])),dq=D(()=>V.string().min(1,"Marketplace must have a name").refine(($)=>!$.includes(" "),{message:'Marketplace name cannot contain spaces. Use kebab-case (e.g., "my-marketplace")'}).refine(($)=>!$.includes("/")&&!$.includes("\\")&&!$.includes("..")&&$!==".",{message:'Marketplace name cannot contain path separators (/ or \\), ".." sequences, or be "."'}).refine(($)=>!rK($),{message:"Marketplace name impersonates an official Anthropic/Claude marketplace"}).refine(($)=>$.toLowerCase()!=="inline",{message:'Marketplace name "inline" is reserved for --plugin-dir session plugins'}).refine(($)=>$.toLowerCase()!=="builtin",{message:'Marketplace name "builtin" is reserved for built-in plugins'})),_6=D(()=>V.object({name:V.string().min(1,"Author name cannot be empty").describe("Display name of the plugin author or organization"),email:V.string().optional().describe("Contact email for support or feedback"),url:V.string().optional().describe("Website, GitHub profile, or organization URL")})),oK=D(()=>V.object({name:V.string().min(1,"Plugin name cannot be empty").refine(($)=>!$.includes(" "),{message:'Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")'}).describe("Unique identifier for the plugin, used for namespacing (prefer kebab-case)"),version:V.string().optional().describe("Semantic version (e.g., 1.2.3) following semver.org specification"),description:V.string().optional().describe("Brief, user-facing explanation of what the plugin provides"),author:_6().optional().describe("Information about the plugin creator or maintainer"),homepage:V.string().url().optional().describe("Plugin homepage or documentation URL"),repository:V.string().optional().describe("Source code repository URL"),license:V.string().optional().describe("SPDX license identifier (e.g., MIT, Apache-2.0)"),keywords:V.array(V.string()).optional().describe("Tags for plugin discovery and categorization"),dependencies:V.array(LB()).optional().describe(`Plugins that must be enabled for this plugin to function. Bare names (no "@marketplace") are resolved against the declaring plugin's own marketplace.`)})),YT=D(()=>V.object({description:V.string().optional().describe("Brief, user-facing explanation of what these hooks provide"),hooks:V.lazy(()=>l1()).describe("The hooks provided by the plugin, in the same format as the one used for settings")})),sK=D(()=>V.object({hooks:V.union([w2().describe("Path to file with additional hooks (in addition to those in hooks/hooks.json, if it exists), relative to the plugin root"),V.lazy(()=>l1()).describe("Additional hooks (in addition to those in hooks/hooks.json, if it exists)"),V.array(V.union([w2().describe("Path to file with additional hooks (in addition to those in hooks/hooks.json, if it exists), relative to the plugin root"),V.lazy(()=>l1()).describe("Additional hooks (in addition to those in hooks/hooks.json, if it exists)")]))])})),aK=D(()=>V.object({source:R6().optional().describe("Path to command markdown file, relative to plugin root"),content:V.string().optional().describe("Inline markdown content for the command"),description:V.string().optional().describe("Command description override"),argumentHint:V.string().optional().describe('Hint for command arguments (e.g., "[file]")'),model:V.string().optional().describe("Default model for this command"),allowedTools:V.array(V.string()).optional().describe("Tools allowed when command runs")}).refine(($)=>$.source&&!$.content||!$.source&&$.content,{message:'Command must have either "source" (file path) or "content" (inline markdown), but not both'})),tK=D(()=>V.object({commands:V.union([R6().describe("Path to additional command file or skill directory (in addition to those in the commands/ directory, if it exists), relative to the plugin root"),V.array(R6().describe("Path to additional command file or skill directory (in addition to those in the commands/ directory, if it exists), relative to the plugin root")).describe("List of paths to additional command files or skill directories"),V.record(V.string(),aK()).describe('Object mapping of command names to their metadata and source files. Command name becomes the slash command name (e.g., "about" \u2192 "/plugin:about")')])})),eK=D(()=>V.object({agents:V.union([w6().describe("Path to additional agent file (in addition to those in the agents/ directory, if it exists), relative to the plugin root"),V.array(w6().describe("Path to additional agent file (in addition to those in the agents/ directory, if it exists), relative to the plugin root")).describe("List of paths to additional agent files")])})),$B=D(()=>V.object({skills:V.union([o0().describe("Path to additional skill directory (in addition to those in the skills/ directory, if it exists), relative to the plugin root"),V.array(o0().describe("Path to additional skill directory (in addition to those in the skills/ directory, if it exists), relative to the plugin root")).describe("List of paths to additional skill directories")])})),JB=D(()=>V.object({outputStyles:V.union([o0().describe("Path to additional output styles directory or file (in addition to those in the output-styles/ directory, if it exists), relative to the plugin root"),V.array(o0().describe("Path to additional output styles directory or file (in addition to those in the output-styles/ directory, if it exists), relative to the plugin root")).describe("List of paths to additional output styles directories or files")])})),mq=D(()=>V.string().min(1)),QB=D(()=>V.string().min(2).refine(($)=>$.startsWith("."),{message:'File extensions must start with dot (e.g., ".ts", not "ts")'})),XB=D(()=>V.object({mcpServers:V.union([w2().describe("MCP servers to include in the plugin (in addition to those in the .mcp.json file, if it exists)"),gq().describe("Path or URL to MCPB file containing MCP server configuration"),V.record(V.string(),H6()).describe("MCP server configurations keyed by server name"),V.array(V.union([w2().describe("Path to MCP servers configuration file"),gq().describe("Path or URL to MCPB file"),V.record(V.string(),H6()).describe("Inline MCP server configurations")])).describe("Array of MCP server configurations (paths, MCPB files, or inline definitions)")])})),cq=D(()=>V.object({type:V.enum(["string","number","boolean","directory","file"]).describe("Type of the configuration value"),title:V.string().describe("Human-readable label shown in the config dialog"),description:V.string().describe("Help text shown beneath the field in the config dialog"),required:V.boolean().optional().describe("If true, validation fails when this field is empty"),default:V.union([V.string(),V.number(),V.boolean(),V.array(V.string())]).optional().describe("Default value used when the user provides nothing"),multiple:V.boolean().optional().describe("For string type: allow an array of strings"),sensitive:V.boolean().optional().describe("If true, masks dialog input and stores value in secure storage (keychain/credentials file) instead of settings.json"),min:V.number().optional().describe("Minimum value (number type only)"),max:V.number().optional().describe("Maximum value (number type only)")}).strict()),ZB=D(()=>V.object({userConfig:V.record(V.string().regex(/^[A-Za-z_]\w*$/,"Option keys must be valid identifiers (letters, digits, underscore; no leading digit) \u2014 they become CLAUDE_PLUGIN_OPTION_<KEY> env vars in hooks"),cq()).optional().describe("User-configurable values this plugin needs. Prompted at enable time. Non-sensitive values saved to settings.json; sensitive values to secure storage (macOS keychain or .credentials.json). Available as ${user_config.KEY} in MCP/LSP server config, hook commands, and (non-sensitive only) skill/agent content. "+"Note: sensitive values share a single keychain entry with OAuth tokens \u2014 keep "+"secret counts small to stay under the ~2KB stdin-safe limit (see INC-3028).")})),qB=D(()=>V.object({channels:V.array(V.object({server:V.string().min(1).describe("Name of the MCP server this channel binds to. Must match a key in this plugin's mcpServers."),displayName:V.string().optional().describe('Human-readable name shown in the config dialog title (e.g., "Telegram"). Defaults to the server name.'),userConfig:V.record(V.string(),cq()).optional().describe("Fields to prompt the user for when enabling this plugin in assistant mode. Saved values are substituted into ${user_config.KEY} references in the mcpServers env.")}).strict()).describe("Channels this plugin provides. Each entry declares an MCP server as a message channel and optionally specifies user configuration to prompt for at enable time.")})),uq=D(()=>V.strictObject({command:V.string().min(1).refine(($)=>{if($.includes(" ")&&!$.startsWith("/"))return!1;return!0},{message:"Command should not contain spaces. Use args array for arguments."}).describe('Command to execute the LSP server (e.g., "typescript-language-server")'),args:V.array(mq()).optional().describe("Command-line arguments to pass to the server"),extensionToLanguage:V.record(QB(),mq()).refine(($)=>Object.keys($).length>0,{message:"extensionToLanguage must have at least one mapping"}).describe("Mapping from file extension to LSP language ID. File extensions and languages are derived from this mapping."),transport:V.enum(["stdio","socket"]).default("stdio").describe("Communication transport mechanism"),env:V.record(V.string(),V.string()).optional().describe("Environment variables to set when starting the server"),initializationOptions:V.unknown().optional().describe("Initialization options passed to the server during initialization"),settings:V.unknown().optional().describe("Settings passed to the server via workspace/didChangeConfiguration"),workspaceFolder:V.string().optional().describe("Workspace folder path to use for the server"),startupTimeout:V.number().int().positive().optional().describe("Maximum time to wait for server startup (milliseconds)"),shutdownTimeout:V.number().int().positive().optional().describe("Maximum time to wait for graceful shutdown (milliseconds)"),restartOnCrash:V.boolean().optional().describe("Whether to restart the server if it crashes"),maxRestarts:V.number().int().nonnegative().optional().describe("Maximum number of restart attempts before giving up")})),YB=D(()=>V.object({lspServers:V.union([w2().describe("Path to .lsp.json configuration file relative to plugin root"),V.record(V.string(),uq()).describe("LSP server configurations keyed by server name"),V.array(V.union([w2().describe("Path to LSP configuration file"),V.record(V.string(),uq()).describe("Inline LSP server configurations")])).describe("Array of LSP server configurations (paths or inline definitions)")])})),lq=D(()=>V.string().refine(($)=>!$.includes("..")&&!$.includes("//"),"Package name cannot contain path traversal patterns").refine(($)=>{let J=/^@[a-z0-9][a-z0-9-._]*\/[a-z0-9][a-z0-9-._]*$/,Q=/^[a-z0-9][a-z0-9-._]*$/;return J.test($)||Q.test($)},"Invalid npm package name format")),WB=D(()=>V.object({settings:V.record(V.string(),V.unknown()).optional().describe("Settings to merge when plugin is enabled. Only allowlisted keys are kept (currently: agent)")})),VB=D(()=>V.object({...oK().shape,...sK().partial().shape,...tK().partial().shape,...eK().partial().shape,...$B().partial().shape,...JB().partial().shape,...qB().partial().shape,...XB().partial().shape,...YB().partial().shape,...WB().partial().shape,...ZB().partial().shape})),O4=D(()=>V.discriminatedUnion("source",[V.object({source:V.literal("url"),url:V.string().url().describe("Direct URL to marketplace.json file"),headers:V.record(V.string(),V.string()).optional().describe("Custom HTTP headers (e.g., for authentication)")}),V.object({source:V.literal("github"),repo:V.string().describe("GitHub repository in owner/repo format"),ref:V.string().optional().describe('Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.'),path:V.string().optional().describe("Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"),sparsePaths:V.array(V.string()).optional().describe('Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.')}),V.object({source:V.literal("git"),url:V.string().describe("Full git repository URL"),ref:V.string().optional().describe('Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.'),path:V.string().optional().describe("Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"),sparsePaths:V.array(V.string()).optional().describe('Directories to include via git sparse-checkout (cone mode). Use for monorepos where the marketplace lives in a subdirectory. Example: [".claude-plugin", "plugins"]. If omitted, the full repository is cloned.')}),V.object({source:V.literal("npm"),package:lq().describe("NPM package containing marketplace.json")}),V.object({source:V.literal("file"),path:V.string().describe("Local file path to marketplace.json")}),V.object({source:V.literal("directory"),path:V.string().describe("Local directory containing .claude-plugin/marketplace.json")}),V.object({source:V.literal("hostPattern"),hostPattern:V.string().describe('Regex pattern to match the host/domain extracted from any marketplace source type. For github sources, matches against "github.com". For git sources (SSH or HTTPS), extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all marketplaces from a specific host (e.g., "^github\\.mycompany\\.com$").')}),V.object({source:V.literal("pathPattern"),pathPattern:V.string().describe('Regex pattern matched against the .path field of file and directory sources. Use in strictKnownMarketplaces to allow filesystem-based marketplaces alongside hostPattern restrictions for network sources. Use ".*" to allow all filesystem paths, or a narrower pattern (e.g., "^/opt/approved/") to restrict to specific directories.')}),V.object({source:V.literal("settings"),name:dq().refine(($)=>!r$.has($.toLowerCase()),{message:"Reserved official marketplace names cannot be used with settings sources. validateOfficialNameSource only accepts github/git sources from anthropics/* for these names; a settings source would be rejected after loadAndCacheMarketplace has already written to disk with cleanupNeeded=false."}).describe("Marketplace name. Must match the extraKnownMarketplaces key (enforced); the synthetic manifest is written under this name. Same validation "+"as PluginMarketplaceSchema plus reserved-name rejection \u2014 "+"validateOfficialNameSource runs after the disk write, too late to clean up."),plugins:V.array(GB()).describe("Plugin entries declared inline in settings.json"),owner:_6().optional()}).describe("Inline marketplace manifest defined directly in settings.json. The reconciler writes a synthetic marketplace.json to the cache; diffMarketplaces detects edits via isEqual on the stored source (the plugins array is inside this object, so edits surface as sourceChanged).")])),U6=D(()=>V.string().length(40).regex(/^[a-f0-9]{40}$/,"Must be a full 40-character lowercase git commit SHA")),nq=D(()=>V.union([o0().describe("Path to the plugin root, relative to the marketplace root (the directory containing .claude-plugin/, not .claude-plugin/ itself)"),V.object({source:V.literal("npm"),package:lq().or(V.string()).describe("Package name (or url, or local path, or anything else that can be passed to `npm` as a package)"),version:V.string().optional().describe("Specific version or version range (e.g., ^1.0.0, ~2.1.0)"),registry:V.string().url().optional().describe("Custom NPM registry URL (defaults to using system default, likely npmjs.org)")}).describe("NPM package as plugin source"),V.object({source:V.literal("pip"),package:V.string().describe("Python package name as it appears on PyPI"),version:V.string().optional().describe("Version specifier (e.g., ==1.0.0, >=2.0.0, <3.0.0)"),registry:V.string().url().optional().describe("Custom PyPI registry URL (defaults to using system default, likely pypi.org)")}).describe("Python package as plugin source"),V.object({source:V.literal("url"),url:V.string().describe("Full git repository URL (https:// or git@)"),ref:V.string().optional().describe('Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.'),sha:U6().optional().describe("Specific commit SHA to use")}),V.object({source:V.literal("github"),repo:V.string().describe("GitHub repository in owner/repo format"),ref:V.string().optional().describe('Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.'),sha:U6().optional().describe("Specific commit SHA to use")}),V.object({source:V.literal("git-subdir"),url:V.string().describe("Git repository: GitHub owner/repo shorthand, https://, or git@ URL"),path:V.string().min(1).describe('Subdirectory within the repo containing the plugin (e.g., "tools/claude-plugin"). Cloned sparsely using partial clone (--filter=tree:0) to minimize bandwidth for monorepos.'),ref:V.string().optional().describe('Git branch or tag to use (e.g., "main", "v1.0.0"). Defaults to repository default branch.'),sha:U6().optional().describe("Specific commit SHA to use")}).describe("Plugin located in a subdirectory of a larger repository (monorepo). Only the specified subdirectory is materialized; the rest of the repo is not downloaded.")])),GB=D(()=>V.object({name:V.string().min(1,"Plugin name cannot be empty").refine(($)=>!$.includes(" "),{message:'Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")'}).describe("Plugin name as it appears in the target repository"),source:nq().describe("Where to fetch the plugin from. Must be a remote source \u2014 relative "+"paths have no marketplace repository to resolve against."),description:V.string().optional(),version:V.string().optional(),strict:V.boolean().optional()}).refine(($)=>typeof $.source!=="string",{message:'Plugins in a settings-sourced marketplace must use remote sources (github, git-subdir, npm, url, pip). Relative-path sources like "./foo" have no marketplace repository to resolve against.'}));KB=D(()=>VB().partial().extend({name:V.string().min(1,"Plugin name cannot be empty").refine(($)=>!$.includes(" "),{message:'Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")'}).describe("Unique identifier matching the plugin name"),source:nq().describe("Where to fetch the plugin from"),category:V.string().optional().describe('Category for organizing plugins (e.g., "productivity", "development")'),tags:V.array(V.string()).optional().describe("Tags for searchability and discovery"),strict:V.boolean().optional().default(!0).describe("Require the plugin manifest to be present in the plugin folder. If false, the marketplace entry provides the manifest.")})),GT=D(()=>V.object({name:dq(),owner:_6().describe("Marketplace maintainer or curator information"),plugins:V.array(KB()).describe("Collection of available plugins in this marketplace"),forceRemoveDeletedPlugins:V.boolean().optional().describe("When true, plugins removed from this marketplace will be automatically uninstalled and flagged for users"),metadata:V.object({pluginRoot:V.string().optional().describe("Base path for relative plugin sources"),version:V.string().optional().describe("Marketplace version"),description:V.string().optional().describe("Marketplace description")}).optional().describe("Optional marketplace metadata"),allowCrossMarketplaceDependenciesOn:V.array(V.string()).optional().describe("Marketplace names whose plugins may be auto-installed as dependencies. Only the root marketplace's allowlist applies \u2014 no transitive trust.")})),i$=D(()=>V.string().regex(/^[a-z0-9][-a-z0-9._]*@[a-z0-9][-a-z0-9._]*$/i,"Plugin ID must be in format: plugin@marketplace")),BB=/^[a-z0-9][-a-z0-9._]*(@[a-z0-9][-a-z0-9._]*)?(@\^[^@]*)?$/i,LB=D(()=>V.union([V.string().regex(BB,"Dependency must be a plugin name, optionally qualified with @marketplace").transform(($)=>$.replace(/@\^[^@]*$/,"")),V.object({name:V.string().min(1).regex(/^[a-z0-9][-a-z0-9._]*$/i),marketplace:V.string().min(1).regex(/^[a-z0-9][-a-z0-9._]*$/i).optional()}).loose().transform(($)=>$.marketplace?`${$.name}@${$.marketplace}`:$.name)])),KT=D(()=>V.union([i$(),V.object({id:i$().describe('Plugin identifier (e.g., "formatter@tools")'),version:V.string().optional().describe('Version constraint (e.g., "^2.0.0")'),required:V.boolean().optional().describe("If true, cannot be disabled"),config:V.record(V.string(),V.unknown()).optional().describe("Plugin-specific configuration")})])),UB=D(()=>V.object({version:V.string().describe("Currently installed version"),installedAt:V.string().describe("ISO 8601 timestamp of installation"),lastUpdated:V.string().optional().describe("ISO 8601 timestamp of last update"),installPath:V.string().describe("Absolute path to the installed plugin directory"),gitCommitSha:V.string().optional().describe("Git commit SHA for git-based plugins (for version tracking)")})),HB=D(()=>V.object({version:V.literal(1).describe("Schema version 1"),plugins:V.record(i$(),UB()).describe("Map of plugin IDs to their installation metadata")})),wB=D(()=>V.enum(["managed","user","project","local"])),RB=D(()=>V.object({scope:wB().describe("Installation scope"),projectPath:V.string().optional().describe("Project path (required for project/local scopes)"),installPath:V.string().describe("Absolute path to the versioned plugin directory"),version:V.string().optional().describe("Currently installed version"),installedAt:V.string().optional().describe("ISO 8601 timestamp of installation"),lastUpdated:V.string().optional().describe("ISO 8601 timestamp of last update"),gitCommitSha:V.string().optional().describe("Git commit SHA for git-based plugins")})),_B=D(()=>V.object({version:V.literal(2).describe("Schema version 2"),plugins:V.record(i$(),V.array(RB())).describe("Map of plugin IDs to arrays of installation entries")})),BT=D(()=>V.union([HB(),_B()])),NB=D(()=>V.object({source:O4().describe("Where to fetch the marketplace from"),installLocation:V.string().describe("Local cache path where marketplace manifest is stored"),lastUpdated:V.string().describe("ISO 8601 timestamp of last marketplace refresh"),autoUpdate:V.boolean().optional().describe("Whether to automatically update this marketplace and its installed plugins on startup")})),LT=D(()=>V.record(V.string(),NB()))});var N6,HT;var rq=U(()=>{N6=["auto","claude","beast","gpt","codex","copilot-gpt-5","gemini","kimi","trinity","anthropic","default"],HT=[{value:"auto",label:"Auto",description:"Detect by model ID (Claude \u2192 native, GPT \u2192 beast/gpt, etc.)"},{value:"claude",label:"Claude (native)",description:"Use cc-haha's native system prompt (no provider override)"},{value:"beast",label:"Beast",description:"Autonomous, thorough \u2014 keep going until problem is solved"},{value:"gpt",label:"GPT",description:"Pragmatic, direct senior engineer style"},{value:"codex",label:"Codex",description:"OpenAI Codex / gpt-*-codex style"},{value:"copilot-gpt-5",label:"Copilot GPT-5",description:"Copilot gpt-5 variant"},{value:"gemini",label:"Gemini",description:"Rigorous, minimal changes, convention-following"},{value:"kimi",label:"Kimi",description:"General purpose, parallel tool calls encouraged"},{value:"trinity",label:"Trinity",description:"Trinity model base prompt"},{value:"anthropic",label:"Anthropic (opencode)",description:"opencode's Claude-family prompt (even on non-Claude models)"},{value:"default",label:"Default (minimal)",description:"Minimal, concise \u2014 for simple or restricted models"}]});function RT($){switch($){case"untrusted":case"on-request":return"default";case"on-failure":return"acceptEdits";case"never":return"bypassPermissions";default:return}}function _T($){switch($){case"read-only":case"workspace-write":return!0;case"danger-full-access":return!1;default:return}}var oq,sq;var aq=U(()=>{oq=["untrusted","on-request","on-failure","never"],sq=["read-only","workspace-write","danger-full-access"]});function tq($){let J=$.split("__"),[Q,X,...Z]=J;if(Q!=="mcp"||!X)return null;let q=Z.length>0?Z.join("__"):void 0;return{serverName:X,toolName:q}}function OB($){return`mcp__${o$($)}__`}function FB($,J){return`${OB($)}${o$(J)}`}function OT($){return $.mcpInfo?FB($.mcpInfo.serverName,$.mcpInfo.toolName):$.name}function FT($,J){let Q=`mcp__${o$(J)}__`;return $.replace(Q,"")}function zT($){let J=$.replace(/\s*\(MCP\)\s*$/,"");J=J.trim();let Q=J.indexOf(" - ");if(Q!==-1)return J.substring(Q+3).trim();return J}var eq=U(()=>{DB()});var $Y="Agent",IT="Task",TT="verification",MT;var JY=U(()=>{MT=new Set(["Explore","Plan"])});var D6="TaskOutput";var QY=()=>{};var XY="TaskStop",AT=`
|
|
118
|
+
- Stops a running background task by its ID
|
|
119
|
+
- Takes a task_id parameter identifying the task to stop
|
|
120
|
+
- Returns a success or failure status
|
|
121
|
+
- Use this tool only when the user explicitly asks to cancel/stop a task, or when
|
|
122
|
+
the task is clearly runaway, harmful, duplicative, or no longer useful.
|
|
123
|
+
- Do not stop a background agent merely because you have already read enough of
|
|
124
|
+
its output. Prefer waiting for the automatic completion notification or
|
|
125
|
+
leaving it running while you summarize available progress.
|
|
126
|
+
`;var ZY=()=>{};function R2($){return qY[$]??$}function yT($){let J=[];for(let[Q,X]of Object.entries(qY))if(X===$)J.push(Q);return J}function xB($){return $.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")}function IB($){return $.replace(/\\\(/g,"(").replace(/\\\)/g,")").replace(/\\\\/g,"\\")}function YY($){let J=TB($,"(");if(J===-1)return{toolName:R2($)};let Q=MB($,")");if(Q===-1||Q<=J)return{toolName:R2($)};if(Q!==$.length-1)return{toolName:R2($)};let X=$.substring(0,J),Z=$.substring(J+1,Q);if(!X)return{toolName:R2($)};if(Z===""||Z==="*")return{toolName:R2(X)};let q=IB(Z);return{toolName:R2(X),ruleContent:q}}function ST($){if(!$.ruleContent)return $.toolName;let J=xB($.ruleContent);return`${$.toolName}(${J})`}function TB($,J){for(let Q=0;Q<$.length;Q++)if($[Q]===J){let X=0,Z=Q-1;while(Z>=0&&$[Z]==="\\")X++,Z--;if(X%2===0)return Q}return-1}function MB($,J){for(let Q=$.length-1;Q>=0;Q--)if($[Q]===J){let X=0,Z=Q-1;while(Z>=0&&$[Z]==="\\")X++,Z--;if(X%2===0)return Q}return-1}var qY;var WY=U(()=>{JY();QY();ZY();qY={Task:$Y,KillShell:XY,AgentOutputTool:D6,BashOutputTool:D6,...{}}});function VY($){return O6.filePatternTools.includes($)}function GY($){return O6.bashPrefixTools.includes($)}function KY($){return O6.customValidation[$]}var O6;var BY=U(()=>{O6={filePatternTools:["Read","Write","Edit","Glob","NotebookRead","NotebookEdit"],bashPrefixTools:["Bash"],customValidation:{WebSearch:($)=>{if($.includes("*")||$.includes("?"))return{valid:!1,error:"WebSearch does not support wildcards",suggestion:"Use exact search terms without * or ?",examples:["WebSearch(claude ai)","WebSearch(typescript tutorial)"]};return{valid:!0}},WebFetch:($)=>{if($.includes("://")||$.startsWith("http"))return{valid:!1,error:"WebFetch permissions use domain format, not URLs",suggestion:'Use "domain:hostname" format',examples:["WebFetch(domain:example.com)","WebFetch(domain:github.com)"]};if(!$.startsWith("domain:"))return{valid:!1,error:'WebFetch permissions must use "domain:" prefix',suggestion:'Use "domain:hostname" format',examples:["WebFetch(domain:example.com)","WebFetch(domain:*.google.com)"]};return{valid:!0}}}}});import{z as LY}from"zod/v4";function UY($,J){let Q=0,X=J-1;while(X>=0&&$[X]==="\\")Q++,X--;return Q%2!==0}function F6($,J){let Q=0;for(let X=0;X<$.length;X++)if($[X]===J&&!UY($,X))Q++;return Q}function PB($){for(let J=0;J<$.length-1;J++)if($[J]==="("&&$[J+1]===")"){if(!UY($,J))return!0}return!1}function z6($){if(!$||$.trim()==="")return{valid:!1,error:"Permission rule cannot be empty"};let J=F6($,"("),Q=F6($,")");if(J!==Q)return{valid:!1,error:"Mismatched parentheses",suggestion:"Ensure all opening parentheses have matching closing parentheses"};if(PB($)){let Y=$.substring(0,$.indexOf("("));if(!Y)return{valid:!1,error:"Empty parentheses with no tool name",suggestion:"Specify a tool name before the parentheses"};return{valid:!1,error:"Empty parentheses",suggestion:`Either specify a pattern or use just "${Y}" without parentheses`,examples:[`${Y}`,`${Y}(some-pattern)`]}}let X=YY($),Z=tq(X.toolName);if(Z){if(X.ruleContent!==void 0||F6($,"(")>0)return{valid:!1,error:"MCP rules do not support patterns in parentheses",suggestion:`Use "${X.toolName}" without parentheses, or use "mcp__${Z.serverName}__*" for all tools`,examples:[`mcp__${Z.serverName}`,`mcp__${Z.serverName}__*`,Z.toolName&&Z.toolName!=="*"?`mcp__${Z.serverName}__${Z.toolName}`:void 0].filter(Boolean)};return{valid:!0}}if(!X.toolName||X.toolName.length===0)return{valid:!1,error:"Tool name cannot be empty"};if(X.toolName[0]!==X.toolName[0]?.toUpperCase())return{valid:!1,error:"Tool names must start with uppercase",suggestion:`Use "${Z$(String(X.toolName))}"`};let q=KY(X.toolName);if(q&&X.ruleContent!==void 0){let Y=q(X.ruleContent);if(!Y.valid)return Y}if(GY(X.toolName)&&X.ruleContent!==void 0){let Y=X.ruleContent;if(Y.includes(":*")&&!Y.endsWith(":*"))return{valid:!1,error:"The :* pattern must be at the end",suggestion:"Move :* to the end for prefix matching, or use * for wildcard matching",examples:["Bash(npm run:*) - prefix matching (legacy)","Bash(npm run *) - wildcard matching"]};if(Y===":*")return{valid:!1,error:"Prefix cannot be empty before :*",suggestion:"Specify a command prefix before :*",examples:["Bash(npm:*)","Bash(git:*)"]}}if(VY(X.toolName)&&X.ruleContent!==void 0){let Y=X.ruleContent;if(Y.includes(":*"))return{valid:!1,error:'The ":*" syntax is only for Bash prefix rules',suggestion:'Use glob patterns like "*" or "**" for file matching',examples:[`${X.toolName}(*.ts) - matches .ts files`,`${X.toolName}(src/**) - matches all files in src`,`${X.toolName}(**/*.test.ts) - matches test files`]};if(Y.includes("*")&&!Y.match(/^\*|\*$|\*\*|\/\*|\*\.|\*\)/)&&!Y.includes("**"))return{valid:!1,error:"Wildcard placement might be incorrect",suggestion:"Wildcards are typically used at path boundaries",examples:[`${X.toolName}(*.js) - all .js files`,`${X.toolName}(src/*) - all files directly in src`,`${X.toolName}(src/**) - all files recursively in src`]}}return{valid:!0}}var s$;var x6=U(()=>{eq();b1();WY();q$();BY();s$=D(()=>LY.string().superRefine(($,J)=>{let Q=z6($);if(!Q.valid){let X=Q.error;if(Q.suggestion)X+=`. ${Q.suggestion}`;if(Q.examples&&Q.examples.length>0)X+=`. Examples: ${Q.examples.join(", ")}`;J.addIssue({code:LY.ZodIssueCode.custom,message:X,params:{received:$}})}}))});import{z as G}from"zod/v4";function ZM($){return"serverName"in $&&$.serverName!==void 0}function qM($){return"serverCommand"in $&&$.serverCommand!==void 0}function YM($){return"serverUrl"in $&&$.serverUrl!==void 0}var EB,AB,CB,kB,vB,HY,R0;var F4=U(()=>{Tq();j();b1();Aq();iq();rq();aq();B6();x6();l$();l$();wY();EB=D(()=>G.record(G.string(),G.coerce.string())),AB=D(()=>G.object({allow:G.array(s$()).optional().describe("List of permission rules for allowed operations"),deny:G.array(s$()).optional().describe("List of permission rules for denied operations"),ask:G.array(s$()).optional().describe("List of permission rules that should always prompt for confirmation"),defaultMode:G.enum(D4).optional().describe("Default permission mode when Claude Code needs access"),disableBypassPermissionsMode:G.enum(["disable"]).optional().describe("Disable the ability to bypass permission prompts"),...{},additionalDirectories:G.array(G.string()).optional().describe("Additional directories to include in the permission scope")}).passthrough()),CB=D(()=>G.object({source:O4().describe("Where to fetch the marketplace from"),installLocation:G.string().optional().describe("Local cache path where marketplace manifest is stored (auto-generated if not provided)"),autoUpdate:G.boolean().optional().describe("Whether to automatically update this marketplace and its installed plugins on startup")})),kB=D(()=>G.object({serverName:G.string().regex(/^[a-zA-Z0-9_-]+$/,"Server name can only contain letters, numbers, hyphens, and underscores").optional().describe("Name of the MCP server that users are allowed to configure"),serverCommand:G.array(G.string()).min(1,"Server command must have at least one element (the command)").optional().describe("Command array [command, ...args] to match exactly for allowed stdio servers"),serverUrl:G.string().optional().describe('URL pattern with wildcard support (e.g., "https://*.example.com/*") for allowed remote MCP servers')}).refine(($)=>{return I6([$.serverName!==void 0,$.serverCommand!==void 0,$.serverUrl!==void 0],Boolean)===1},{message:'Entry must have exactly one of "serverName", "serverCommand", or "serverUrl"'})),vB=D(()=>G.object({serverName:G.string().regex(/^[a-zA-Z0-9_-]+$/,"Server name can only contain letters, numbers, hyphens, and underscores").optional().describe("Name of the MCP server that is explicitly blocked"),serverCommand:G.array(G.string()).min(1,"Server command must have at least one element (the command)").optional().describe("Command array [command, ...args] to match exactly for blocked stdio servers"),serverUrl:G.string().optional().describe('URL pattern with wildcard support (e.g., "https://*.example.com/*") for blocked remote MCP servers')}).refine(($)=>{return I6([$.serverName!==void 0,$.serverCommand!==void 0,$.serverUrl!==void 0],Boolean)===1},{message:'Entry must have exactly one of "serverName", "serverCommand", or "serverUrl"'})),HY=["skills","agents","hooks","mcp"],R0=D(()=>G.object({$schema:G.literal(Fq).optional().describe("JSON Schema reference for Claude Code settings"),apiKeyHelper:G.string().optional().describe("Path to a script that outputs authentication values"),awsCredentialExport:G.string().optional().describe("Path to a script that exports AWS credentials"),awsAuthRefresh:G.string().optional().describe("Path to a script that refreshes AWS authentication"),gcpAuthRefresh:G.string().optional().describe("Command to refresh GCP authentication (e.g., gcloud auth application-default login)"),...R(process.env.CLAUDE_CODE_ENABLE_XAA)?{xaaIdp:G.object({issuer:G.string().url().describe("IdP issuer URL for OIDC discovery"),clientId:G.string().describe("Claude Code's client_id registered at the IdP"),callbackPort:G.number().int().positive().optional().describe("Fixed loopback callback port for the IdP OIDC login. Only needed if the IdP does not honor RFC 8252 port-any matching.")}).optional().describe("XAA (SEP-990) IdP connection. Configure once; all XAA-enabled MCP servers reuse this.")}:{},fileSuggestion:G.object({type:G.literal("command"),command:G.string()}).optional().describe("Custom file suggestion configuration for @ mentions"),respectGitignore:G.boolean().optional().describe("Whether file picker should respect .gitignore files (default: true). Note: .ignore files are always respected."),cleanupPeriodDays:G.number().nonnegative().int().optional().describe("Number of days to retain chat transcripts (default: 30). Setting to 0 disables session persistence entirely: no transcripts are written and existing transcripts are deleted at startup."),env:EB().optional().describe("Environment variables to set for Claude Code sessions"),attribution:G.object({commit:G.string().optional().describe("Attribution text for git commits, including any trailers. Empty string hides attribution."),pr:G.string().optional().describe("Attribution text for pull request descriptions. Empty string hides attribution.")}).optional().describe("Customize attribution text for commits and PRs. Each field defaults to the standard Claude Code attribution if not set."),includeCoAuthoredBy:G.boolean().optional().describe("Deprecated: Use attribution instead. Whether to include Claude's co-authored by attribution in commits and PRs (defaults to true)"),includeGitInstructions:G.boolean().optional().describe("Include built-in commit and PR workflow instructions in Claude's system prompt (default: true)"),permissions:AB().optional().describe("Tool usage permissions configuration"),model:G.string().optional().describe("Override the default model used by Claude Code"),availableModels:G.array(G.string()).optional().describe('Allowlist of models that users can select. Accepts family aliases ("opus" allows any opus version), version prefixes ("opus-4-5" allows only that version), and full model IDs. If undefined, all models are available. If empty array, only the default model is available. Typically set in managed settings by enterprise administrators.'),modelOverrides:G.record(G.string(),G.string()).optional().describe('Override mapping from Anthropic model ID (e.g. "claude-opus-4-7") to provider-specific model ID (e.g. a Bedrock inference profile ARN). Typically set in managed settings by enterprise administrators.'),enableAllProjectMcpServers:G.boolean().optional().describe("Whether to automatically approve all MCP servers in the project"),enabledMcpjsonServers:G.array(G.string()).optional().describe("List of approved MCP servers from .mcp.json"),disabledMcpjsonServers:G.array(G.string()).optional().describe("List of rejected MCP servers from .mcp.json"),allowedMcpServers:G.array(kB()).optional().describe("Enterprise allowlist of MCP servers that can be used. Applies to all scopes including enterprise servers from managed-mcp.json. If undefined, all servers are allowed. If empty array, no servers are allowed. Denylist takes precedence - if a server is on both lists, it is denied."),deniedMcpServers:G.array(vB()).optional().describe("Enterprise denylist of MCP servers that are explicitly blocked. If a server is on the denylist, it will be blocked across all scopes including enterprise. Denylist takes precedence over allowlist - if a server is on both lists, it is denied."),hooks:l1().optional().describe("Custom commands to run before/after tool executions"),worktree:G.object({symlinkDirectories:G.array(G.string()).optional().describe('Directories to symlink from main repository to worktrees to avoid disk bloat. Must be explicitly configured - no directories are symlinked by default. Common examples: "node_modules", ".cache", ".bin"'),sparsePaths:G.array(G.string()).optional().describe("Directories to include when creating worktrees, via git sparse-checkout (cone mode). "+"Dramatically faster in large monorepos \u2014 only the listed paths are written to disk.")}).optional().describe("Git worktree configuration for --worktree flag."),disableAllHooks:G.boolean().optional().describe("Disable all hooks and statusLine execution"),defaultShell:G.enum(["bash","powershell"]).optional().describe("Default shell for input-box ! commands. Defaults to 'bash' on all platforms (no Windows auto-flip)."),allowManagedHooksOnly:G.boolean().optional().describe("When true (and set in managed settings), only hooks from managed settings run. User, project, and local hooks are ignored."),allowedHttpHookUrls:G.array(G.string()).optional().describe('Allowlist of URL patterns that HTTP hooks may target. Supports * as a wildcard (e.g. "https://hooks.example.com/*"). When set, HTTP hooks with non-matching URLs are blocked. If undefined, all URLs are allowed. If empty array, no HTTP hooks are allowed. Arrays merge across settings sources (same semantics as allowedMcpServers).'),httpHookAllowedEnvVars:G.array(G.string()).optional().describe("Allowlist of environment variable names HTTP hooks may interpolate into headers. When set, each hook's effective allowedEnvVars is the intersection with this list. If undefined, no restriction is applied. Arrays merge across settings sources (same semantics as allowedMcpServers)."),allowManagedPermissionRulesOnly:G.boolean().optional().describe("When true (and set in managed settings), only permission rules (allow/deny/ask) from managed settings are respected. User, project, local, and CLI argument permission rules are ignored."),allowManagedMcpServersOnly:G.boolean().optional().describe("When true (and set in managed settings), allowedMcpServers is only read from managed settings. deniedMcpServers still merges from all sources, so users can deny servers for themselves. Users can still add their own MCP servers, but only the admin-defined allowlist applies."),strictPluginOnlyCustomization:G.preprocess(($)=>Array.isArray($)?$.filter((J)=>HY.includes(J)):$,G.union([G.boolean(),G.array(G.enum(HY))])).optional().catch(void 0).describe('When set in managed settings, blocks non-plugin customization sources for the listed surfaces. Array form locks specific surfaces (e.g. ["skills", "hooks"]); `true` locks all four; `false` is an explicit no-op. Blocked: ~/.claude/{surface}/, .claude/{surface}/ (project), settings.json hooks, .mcp.json. NOT blocked: managed (policySettings) sources, plugin-provided customizations. '+"Composes with strictKnownMarketplaces for end-to-end admin control \u2014 plugins gated by "+"marketplace allowlist, everything else blocked here."),statusLine:G.object({type:G.literal("command"),command:G.string(),padding:G.number().optional()}).optional().describe("Custom status line display configuration"),enabledPlugins:G.record(G.string(),G.union([G.array(G.string()),G.boolean(),G.undefined()])).optional().describe('Enabled plugins using plugin-id@marketplace-id format. Example: { "formatter@anthropic-tools": true }. Also supports extended format with version constraints.'),extraKnownMarketplaces:G.record(G.string(),CB()).check(($)=>{for(let[J,Q]of Object.entries($.value))if(Q.source.source==="settings"&&Q.source.name!==J)$.issues.push({code:"custom",input:Q.source.name,path:[J,"source","name"],message:`Settings-sourced marketplace name must match its extraKnownMarketplaces key (got key "${J}" but source.name "${Q.source.name}")`})}).optional().describe("Additional marketplaces to make available for this repository. Typically used in repository .claude/settings.json to ensure team members have required plugin sources."),strictKnownMarketplaces:G.array(O4()).optional().describe("Enterprise strict list of allowed marketplace sources. When set in managed settings, ONLY these exact sources can be added as marketplaces. The check happens BEFORE downloading, so blocked sources never touch the filesystem. "+"Note: this is a policy gate only \u2014 it does NOT register marketplaces. "+"To pre-register allowed marketplaces for users, also set extraKnownMarketplaces."),blockedMarketplaces:G.array(O4()).optional().describe("Enterprise blocklist of marketplace sources. When set in managed settings, these exact sources are blocked from being added as marketplaces. The check happens BEFORE downloading, so blocked sources never touch the filesystem."),forceLoginMethod:G.enum(["claudeai","console"]).optional().describe('Force a specific login method: "claudeai" for Claude Pro/Max, "console" for Console billing'),forceLoginOrgUUID:G.string().optional().describe("Organization UUID to use for OAuth login"),otelHeadersHelper:G.string().optional().describe("Path to a script that outputs OpenTelemetry headers"),outputStyle:G.string().optional().describe("Controls the output style for assistant responses"),providerPromptStyle:G.enum(N6).optional().describe("Base system prompt style for non-Claude models. One of: "+N6.join(", ")),approvalPolicy:G.enum(oq).optional().describe("Codex-style approval policy, mapped onto permissions.defaultMode when that is unset. One of: untrusted, on-request, on-failure, never"),sandboxMode:G.enum(sq).optional().describe("Codex-style sandbox mode, mapped onto sandbox.enabled when that is unset. One of: read-only, workspace-write, danger-full-access"),language:G.string().optional().describe('Preferred language for Claude responses and voice dictation (e.g., "japanese", "spanish")'),skipWebFetchPreflight:G.boolean().optional().describe("Skip the WebFetch blocklist check for enterprise environments with restrictive security policies"),webSearch:G.object({mode:G.enum(["auto","anthropic","tavily","brave","disabled"]).optional().describe("WebSearch backend selection. auto uses native Claude web search for Claude model names, then Tavily, then Brave."),tavilyApiKey:G.string().optional().describe("Tavily API key for WebSearch fallback"),braveApiKey:G.string().optional().describe("Brave Search API key for WebSearch fallback")}).optional().describe("Configures native and external WebSearch backends"),sandbox:Iq().optional(),feedbackSurveyRate:G.number().min(0).max(1).optional().describe("Probability (0\u20131) that the session quality survey appears when eligible. 0.05 is a reasonable starting point."),spinnerTipsEnabled:G.boolean().optional().describe("Whether to show tips in the spinner"),spinnerVerbs:G.object({mode:G.enum(["append","replace"]),verbs:G.array(G.string())}).optional().describe('Customize spinner verbs. mode: "append" adds verbs to defaults, "replace" uses only your verbs.'),spinnerTipsOverride:G.object({excludeDefault:G.boolean().optional(),tips:G.array(G.string())}).optional().describe("Override spinner tips. tips: array of tip strings. excludeDefault: if true, only show custom tips (default: false)."),syntaxHighlightingDisabled:G.boolean().optional().describe("Whether to disable syntax highlighting in diffs"),terminalTitleFromRename:G.boolean().optional().describe("Whether /rename updates the terminal tab title (defaults to true). Set to false to keep auto-generated topic titles."),alwaysThinkingEnabled:G.boolean().optional().describe("When false, thinking is disabled. When absent or true, thinking is enabled automatically for supported models."),effortLevel:G.enum(process.env.USER_TYPE==="ant"?["low","medium","high","max"]:["low","medium","high"]).optional().catch(void 0).describe("Persisted effort level for supported models."),advisorModel:G.string().optional().describe("Advisor model for the server-side advisor tool."),fastMode:G.boolean().optional().describe("When true, fast mode is enabled. When absent or false, fast mode is off."),fastModePerSessionOptIn:G.boolean().optional().describe("When true, fast mode does not persist across sessions. Each session starts with fast mode off."),promptSuggestionEnabled:G.boolean().optional().describe("When false, prompt suggestions are disabled. When absent or true, prompt suggestions are enabled."),showClearContextOnPlanAccept:G.boolean().optional().describe('When true, the plan-approval dialog offers a "clear context" option. Defaults to false.'),agent:G.string().optional().describe("Name of an agent (built-in or custom) to use for the main thread. Applies the agent's system prompt, tool restrictions, and model."),companyAnnouncements:G.array(G.string()).optional().describe("Company announcements to display at startup (one will be randomly selected if multiple are provided)"),pluginConfigs:G.record(G.string(),G.object({mcpServers:G.record(G.string(),G.record(G.string(),G.union([G.string(),G.number(),G.boolean(),G.array(G.string())]))).optional().describe("User configuration values for MCP servers keyed by server name"),options:G.record(G.string(),G.union([G.string(),G.number(),G.boolean(),G.array(G.string())])).optional().describe("Non-sensitive option values from plugin manifest userConfig, keyed by option name. Sensitive values go to secure storage instead.")})).optional().describe("Per-plugin configuration including MCP server user configs, keyed by plugin ID (plugin@marketplace format)"),remote:G.object({defaultEnvironmentId:G.string().optional().describe("Default environment ID to use for remote sessions")}).optional().describe("Remote session configuration"),autoUpdatesChannel:G.enum(["latest","stable"]).optional().describe("Release channel for auto-updates (latest or stable)"),...{},minimumVersion:G.string().optional().describe("Minimum version to stay on - prevents downgrades when switching to stable channel"),plansDirectory:G.string().optional().describe("Custom directory for plan files, relative to project root. If not set, defaults to ~/.claude/plans/"),...process.env.USER_TYPE==="ant"?{classifierPermissionsEnabled:G.boolean().optional().describe("Enable AI-based classification for Bash(prompt:...) permission rules")}:{},...{},...{},...{},channelsEnabled:G.boolean().optional().describe("Teams/Enterprise opt-in for channel notifications (MCP servers with the claude/channel capability pushing inbound messages). Default off. Set true to allow; users then select servers via --channels."),allowedChannelPlugins:G.array(G.object({marketplace:G.string(),plugin:G.string()})).optional().describe("Teams/Enterprise allowlist of channel plugins. When set, "+"replaces the default Anthropic allowlist \u2014 admins decide which "+"plugins may push inbound messages. Undefined falls back to the default. Requires channelsEnabled: true."),...{},prefersReducedMotion:G.boolean().optional().describe("Reduce or disable animations for accessibility (spinner shimmer, flash effects, etc.)"),autoMemoryEnabled:G.boolean().optional().describe("Enable auto-memory for this project. When false, Claude will not read from or write to the auto-memory directory."),autoMemoryDirectory:G.string().optional().describe("Custom directory path for auto-memory storage. Supports ~/ prefix for home directory expansion. Ignored if set in projectSettings (checked-in .claude/settings.json) for security. When unset, defaults to ~/.claude/projects/<sanitized-cwd>/memory/."),autoDreamEnabled:G.boolean().optional().describe("Enable background memory consolidation (auto-dream). When set, overrides the server-side default."),showThinkingSummaries:G.boolean().optional().describe("Show thinking summaries in the transcript view (ctrl+o). Default: false."),skipDangerousModePermissionPrompt:G.boolean().optional().describe("Whether the user has accepted the bypass permissions mode dialog"),...{},disableAutoMode:G.enum(["disable"]).optional().describe("Disable auto mode"),sshConfigs:G.array(G.object({id:G.string().describe("Unique identifier for this SSH config. Used to match configs across settings sources."),name:G.string().describe("Display name for the SSH connection"),sshHost:G.string().describe('SSH host in format "user@hostname" or "hostname", or a host alias from ~/.ssh/config'),sshPort:G.number().int().optional().describe("SSH port (default: 22)"),sshIdentityFile:G.string().optional().describe("Path to SSH identity file (private key)"),startDirectory:G.string().optional().describe("Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory. Can be overridden by the [dir] positional argument in `claude ssh <config> [dir]`.")})).optional().describe("SSH connection configurations for remote environments. Typically set in managed settings by enterprise administrators to pre-configure SSH connections for team members."),claudeMdExcludes:G.array(G.string()).optional().describe('Glob patterns or absolute paths of CLAUDE.md files to exclude from loading. Patterns are matched against absolute file paths using picomatch. Only applies to User, Project, and Local memory types (Managed/policy files cannot be excluded). Examples: "/home/user/monorepo/CLAUDE.md", "**/code/CLAUDE.md", "**/some-dir/.claude/rules/**"'),pluginTrustMessage:G.string().optional().describe('Custom message to append to the plugin trust warning shown before installation. Only read from policy settings (managed-settings.json / MDM). Useful for enterprise administrators to add organization-specific context (e.g., "All plugins from our internal marketplace are vetted and approved.").')}).passthrough())});import{toJSONSchema as jB}from"zod/v4";function T6(){let $=jB(R0(),{unrepresentable:"any"});return A($,null,2)}var RY=U(()=>{X0();F4()});function _Y($){let J=yB.find((X)=>X.matches($));if(!J)return null;let Q={...J.tip};if($.code==="invalid_value"&&$.enumValues&&!Q.suggestion)Q.suggestion=`Valid values: ${$.enumValues.map((X)=>`"${X}"`).join(", ")}`;if(!Q.docLink&&$.path){let X=$.path.split(".")[0];if(X)Q.docLink=SB[X]}return Q}var yB,SB;var NY=U(()=>{yB=[{matches:($)=>$.path==="permissions.defaultMode"&&$.code==="invalid_value",tip:{suggestion:'Valid modes: "acceptEdits" (ask before file changes), "plan" (analysis only), "bypassPermissions" (auto-accept all), or "default" (standard behavior)',docLink:"https://code.claude.com/docs/en/iam#permission-modes"}},{matches:($)=>$.path==="apiKeyHelper"&&$.code==="invalid_type",tip:{suggestion:'Provide a shell command that outputs your API key to stdout. The script should output only the API key. Example: "/bin/generate_temp_api_key.sh"'}},{matches:($)=>$.path==="cleanupPeriodDays"&&$.code==="too_small"&&$.expected==="0",tip:{suggestion:"Must be 0 or greater. Set a positive number for days to retain transcripts (default is 30). Setting 0 disables session persistence entirely: no transcripts are written and existing transcripts are deleted at startup."}},{matches:($)=>$.path.startsWith("env.")&&$.code==="invalid_type",tip:{suggestion:'Environment variables must be strings. Wrap numbers and booleans in quotes. Example: "DEBUG": "true", "PORT": "3000"',docLink:"https://code.claude.com/docs/en/settings#environment-variables"}},{matches:($)=>($.path==="permissions.allow"||$.path==="permissions.deny")&&$.code==="invalid_type"&&$.expected==="array",tip:{suggestion:'Permission rules must be in an array. Format: ["Tool(specifier)"]. Examples: ["Bash(npm run build)", "Edit(docs/**)", "Read(~/.zshrc)"]. Use * for wildcards.'}},{matches:($)=>$.path.includes("hooks")&&$.code==="invalid_type",tip:{suggestion:'Hooks use a matcher + hooks array. The matcher is a string: a tool name ("Bash"), pipe-separated list ("Edit|Write"), or empty to match all. Example: {"PostToolUse": [{"matcher": "Edit|Write", "hooks": [{"type": "command", "command": "echo Done"}]}]}'}},{matches:($)=>$.code==="invalid_type"&&$.expected==="boolean",tip:{suggestion:'Use true or false without quotes. Example: "includeCoAuthoredBy": true'}},{matches:($)=>$.code==="unrecognized_keys",tip:{suggestion:"Check for typos or refer to the documentation for valid fields",docLink:"https://code.claude.com/docs/en/settings"}},{matches:($)=>$.code==="invalid_value"&&$.enumValues!==void 0,tip:{suggestion:void 0}},{matches:($)=>$.code==="invalid_type"&&$.expected==="object"&&$.received===null&&$.path==="",tip:{suggestion:"Check for missing commas, unmatched brackets, or trailing commas. Use a JSON validator to identify the exact syntax error."}},{matches:($)=>$.path==="permissions.additionalDirectories"&&$.code==="invalid_type",tip:{suggestion:'Must be an array of directory paths. Example: ["~/projects", "/tmp/workspace"]. You can also use --add-dir flag or /add-dir command',docLink:"https://code.claude.com/docs/en/iam#working-directories"}}],SB={permissions:"https://code.claude.com/docs/en/iam#configuring-permissions",env:"https://code.claude.com/docs/en/settings#environment-variables",hooks:"https://code.claude.com/docs/en/hooks"}});function DY($){return $.code==="invalid_type"}function OY($){return $.code==="invalid_value"}function fB($){return $.code==="unrecognized_keys"}function FY($){return $.code==="too_small"}function M6($){if($===null)return"null";if($===void 0)return"undefined";if(Array.isArray($))return"array";return typeof $}function zY($){let J=$.match(/received (\w+)/);return J?J[1]:void 0}function _2($,J){return $.issues.map((Q)=>{let X=Q.path.map(String).join("."),Z=Q.message,q,Y,W,K,B;if(OY(Q))Y=Q.values.map((H)=>String(H)),W=Y.join(" | "),K=void 0,B=void 0;else if(DY(Q)){W=Q.expected;let H=zY(Q.message);K=H??M6(Q.input),B=H??M6(Q.input)}else if(FY(Q))W=String(Q.minimum);else if(Q.code==="custom"&&"params"in Q)K=Q.params.received,B=K;let w=_Y({path:X,code:Q.code,expected:W,received:K,enumValues:Y,message:Q.message,value:K});if(OY(Q))q=Y?.map((H)=>`"${H}"`).join(", "),Z=`Invalid value. Expected one of: ${q}`;else if(DY(Q)){let H=zY(Q.message)??M6(Q.input);if(Q.expected==="object"&&H==="null"&&X==="")Z="Invalid or malformed JSON";else Z=`Expected ${Q.expected}, but received ${H}`}else if(fB(Q)){let H=Q.keys.join(", ");Z=`Unrecognized ${bQ(Q.keys.length,"field")}: ${H}`}else if(FY(Q))Z=`Number must be greater than or equal to ${Q.minimum}`,q=String(Q.minimum);return{file:J,path:X,message:Z,expected:q,invalidValue:B,suggestion:w?.suggestion,docLink:w?.docLink}})}function OM($){try{let J=a($),Q=R0().strict().safeParse(J);if(Q.success)return{isValid:!0};return{isValid:!1,error:`Settings validation failed:
|
|
127
|
+
`+_2(Q.error,"settings").map((q)=>`- ${q.path}: ${q.message}`).join(`
|
|
128
|
+
`),fullSchema:T6()}}catch(J){return{isValid:!1,error:`Invalid JSON: ${J instanceof Error?J.message:"Unknown parsing error"}`,fullSchema:T6()}}}function a$($,J){if(!$||typeof $!=="object")return[];let Q=$;if(!Q.permissions||typeof Q.permissions!=="object")return[];let X=Q.permissions,Z=[];for(let q of["allow","deny","ask"]){let Y=X[q];if(!Array.isArray(Y))continue;X[q]=Y.filter((W)=>{if(typeof W!=="string")return Z.push({file:J,path:`permissions.${q}`,message:`Non-string value in ${q} array was removed`,invalidValue:W}),!1;let K=z6(W);if(!K.valid){let B=`Invalid permission rule "${W}" was skipped`;if(K.error)B+=`: ${K.error}`;if(K.suggestion)B+=`. ${K.suggestion}`;return Z.push({file:J,path:`permissions.${q}`,message:B,invalidValue:W}),!1}return!0})}return Z}var P6=U(()=>{X0();q$();x6();RY();F4();NY()});import{homedir as bB,userInfo as hB}from"os";import{join as pB}from"path";function MY(){let $="";try{$=hB().username}catch{}let J=[];if($)J.push({path:`/Library/Managed Preferences/${$}/${E6}.plist`,label:"per-user managed preferences"});if(J.push({path:`/Library/Managed Preferences/${E6}.plist`,label:"device-level managed preferences"}),process.env.USER_TYPE==="ant")J.push({path:pB(bB(),"Library","Preferences",`${E6}.plist`),label:"user preferences (ant-only)"});return J}var E6="com.anthropic.claudecode",t$="HKLM\\SOFTWARE\\Policies\\ClaudeCode",e$="HKCU\\SOFTWARE\\Policies\\ClaudeCode",N2="Settings",xY="/usr/bin/plutil",IY,TY=5000;var A6=U(()=>{IY=["-convert","json","-o","-","--"]});import{execFile as gB}from"child_process";import{existsSync as mB}from"fs";function C6($,J){return new Promise((Q)=>{gB($,J,{encoding:"utf-8",timeout:TY},(X,Z)=>{Q({stdout:Z??"",code:X?1:0})})})}function $8(){return(async()=>{if(process.platform==="darwin"){let $=MY(),Q=(await Promise.all($.map(async({path:X,label:Z})=>{if(!mB(X))return{stdout:"",label:Z,ok:!1};let{stdout:q,code:Y}=await C6(xY,[...IY,X]);return{stdout:q,label:Z,ok:Y===0&&!!q}}))).find((X)=>X.ok);return{plistStdouts:Q?[{stdout:Q.stdout,label:Q.label}]:[],hklmStdout:null,hkcuStdout:null}}if(process.platform==="win32"){let[$,J]=await Promise.all([C6("reg",["query",t$,"/v",N2]),C6("reg",["query",e$,"/v",N2])]);return{plistStdouts:null,hklmStdout:$.code===0?$.stdout:null,hkcuStdout:J.code===0?J.stdout:null}}return{plistStdouts:null,hklmStdout:null,hkcuStdout:null}})()}function EM(){if(k6)return;k6=$8()}function PY(){return k6}var k6=null;var EY=U(()=>{A6()});import{join as AY}from"path";function uB(){if(J8)return;J8=(async()=>{n0("mdm_load_start");let $=Date.now(),J=PY()??$8(),{mdm:Q,hkcu:X}=kY(await J);j6=Q,y6=X,n0("mdm_load_end");let Z=Date.now()-$;if(L(`MDM settings load completed in ${Z}ms`),Object.keys(Q.settings).length>0){L(`MDM settings found: ${Object.keys(Q.settings).join(", ")}`);try{Y1("info","mdm_settings_loaded",{duration_ms:Z,key_count:Object.keys(Q.settings).length,error_count:Q.errors.length})}catch{}}})()}async function uM(){if(!J8)uB();await J8}function Q8(){return j6??a0}function X8(){return y6??a0}function dM($,J){j6=$,y6=J}async function cM(){let $=await $8();return kY($)}function v6($,J){let Q=V0($,!1);if(!Q||typeof Q!=="object")return{settings:{},errors:[]};let X=a$(Q,J),Z=R0().safeParse(Q);if(!Z.success){let q=_2(Z.error,J);return{settings:{},errors:[...X,...q]}}return{settings:Z.data,errors:X}}function CY($,J="Settings"){let Q=$.split(/\r?\n/),X=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Z=new RegExp(`^\\s+${X}\\s+REG_(?:EXPAND_)?SZ\\s+(.*)$`,"i");for(let q of Q){let Y=q.match(Z);if(Y&&Y[1])return Y[1].trimEnd()}return null}function kY($){if($.plistStdouts&&$.plistStdouts.length>0){let{stdout:J,label:Q}=$.plistStdouts[0],X=v6(J,Q);if(Object.keys(X.settings).length>0)return{mdm:X,hkcu:a0}}if($.hklmStdout){let J=CY($.hklmStdout);if(J){let Q=v6(J,`Registry: ${t$}\\${N2}`);if(Object.keys(Q.settings).length>0)return{mdm:Q,hkcu:a0}}}if(dB())return{mdm:a0,hkcu:a0};if($.hkcuStdout){let J=CY($.hkcuStdout);if(J){let Q=v6(J,`Registry: ${e$}\\${N2}`);return{mdm:a0,hkcu:Q}}}return{mdm:a0,hkcu:a0}}function dB(){try{let $=AY(X1(),"managed-settings.json"),J=v0($),Q=V0(J,!1);if(Q&&typeof Q==="object"&&Object.keys(Q).length>0)return!0}catch{}try{let $=M2(),J=x().readdirSync($);for(let Q of J){if(!(Q.isFile()||Q.isSymbolicLink())||!Q.name.endsWith(".json")||Q.name.startsWith("."))continue;try{let X=v0(AY($,Q.name)),Z=V0(X,!1);if(Z&&typeof Z==="object"&&Object.keys(Z).length>0)return!0}catch{}}}catch{}return!1}var a0,j6=null,y6=null,J8=null;var vY=U(()=>{p();N8();F2();$1();k2();q6();C4();F4();P6();A6();EY();a0=Object.freeze({settings:{},errors:[]})});import O1 from"lodash-es/mergeWith.js";import{dirname as dY,join as D2,resolve as z4}from"path";import"zod/v4";function g6(){return D2(X1(),"managed-settings.json")}function m6(){let $=[],J={},Q=!1,{settings:X,errors:Z}=x4(g6());if($.push(...Z),X&&Object.keys(X).length>0)J=O1(J,X,n1),Q=!0;let q=M2();try{let Y=x().readdirSync(q).filter((W)=>(W.isFile()||W.isSymbolicLink())&&W.name.endsWith(".json")&&!W.name.startsWith(".")).map((W)=>W.name).sort();for(let W of Y){let{settings:K,errors:B}=x4(D2(q,W));if($.push(...B),K&&Object.keys(K).length>0)J=O1(J,K,n1),Q=!0}}catch(Y){let W=Y0(Y);if(W!=="ENOENT"&&W!=="ENOTDIR")O(Y)}return{settings:Q?J:null,errors:$}}function DP(){let{settings:$}=x4(g6()),J=!!$&&Object.keys($).length>0,Q=!1,X=M2();try{Q=x().readdirSync(X).some((Z)=>(Z.isFile()||Z.isSymbolicLink())&&Z.name.endsWith(".json")&&!Z.name.startsWith("."))}catch{}return{hasBase:J,hasDropIns:Q}}function cY($,J){if(typeof $==="object"&&$&&"code"in $&&$.code==="ENOENT")L(`Broken symlink or missing file encountered for settings.json at path: ${J}`);else O($)}function x4($){let J=hY($);if(J)return{settings:J.settings?f6(J.settings):null,errors:J.errors};let Q=cB($);return pY($,Q),{settings:Q.settings?f6(Q.settings):null,errors:Q.errors}}function cB($){try{let{resolvedPath:J}=e0(x(),$),Q=v0(J);if(Q.trim()==="")return{settings:{},errors:[]};let X=V0(Q,!1),Z=a$(X,$),q=R0().safeParse(X);if(!q.success){let Y=_2(q.error,$);return{settings:null,errors:[...Z,...Y]}}return{settings:q.data,errors:Z}}catch(J){return cY(J,$),{settings:null,errors:[]}}}function jY($){switch($){case"userSettings":return z4(b());case"policySettings":case"projectSettings":case"localSettings":return z4(q1());case"flagSettings":{let J=b6();return J?dY(z4(J)):z4(q1())}}}function lB(){if(mY()||R(process.env.CLAUDE_CODE_USE_COWORK_PLUGINS))return"cowork_settings.json";return"settings.json"}function Z8($){switch($){case"userSettings":return D2(jY($),lB());case"projectSettings":case"localSettings":return D2(jY($),lY($));case"policySettings":return g6();case"flagSettings":return b6()}}function lY($){switch($){case"projectSettings":return D2(".claude","settings.json");case"localSettings":return D2(".claude","settings.local.json")}}function S($){let J=fY($);if(J!==void 0)return J;let Q=nY($);return bY($,Q),Q}function nY($){if($==="policySettings"){let X=I4();if(X&&Object.keys(X).length>0)return X;let Z=Q8();if(Object.keys(Z.settings).length>0)return Z.settings;let{settings:q}=m6();if(q)return q;let Y=X8();if(Object.keys(Y.settings).length>0)return Y.settings;return null}let J=Z8($),{settings:Q}=J?x4(J):{settings:null};if($==="flagSettings"){let X=h6();if(X){let Z=R0().safeParse(X);if(Z.success)return O1(Q||{},Z.data,n1)}}return Q}function OP(){let $=I4();if($&&Object.keys($).length>0)return"remote";let J=Q8();if(Object.keys(J.settings).length>0)return j0()==="macos"?"plist":"hklm";let{settings:Q}=m6();if(Q)return"file";let X=X8();if(Object.keys(X.settings).length>0)return"hkcu";return null}function Q$($,J){if($==="policySettings"||$==="flagSettings")return{error:null};let Q=Z8($);if(!Q)return{error:null};try{x().mkdirSync(dY(Q));let X=nY($);if(!X){let q=null;try{q=v0(Q)}catch(Y){if(!U1(Y))throw Y}if(q!==null){let Y=V0(q);if(Y===null)return{error:Error(`Invalid JSON syntax in settings file at ${Q}`)};if(Y&&typeof Y==="object")X=Y,L(`Using raw settings from ${Q} due to validation failure`)}}let Z=O1(X||{},J,(q,Y,W,K)=>{if(Y===void 0&&K&&typeof W==="string"){delete K[W];return}if(Array.isArray(Y))return Y;return});if(zq(Q),i1(Q,A(Z,null,2)+`
|
|
129
|
+
`),x2(),$==="localSettings")Nq(lY("localSettings"),q1())}catch(X){let Z=Error(`Failed to read raw settings from ${Q}: ${X}`);return O(Z),{error:Z}}return{error:null}}function nB($,J){return uY([...$,...J])}function n1($,J){if(Array.isArray($)&&Array.isArray(J))return nB($,J);return}function FP($){let J=R0().strip().parse($),Q=["permissions","sandbox","hooks"],X=[],Z={permissions:new Set(["allow","deny","ask","defaultMode","disableBypassPermissionsMode",...[],"additionalDirectories"]),sandbox:new Set(["enabled","failIfUnavailable","allowUnsandboxedCommands","network","filesystem","ignoreViolations","excludedCommands","autoAllowBashIfSandboxed","enableWeakerNestedSandbox","enableWeakerNetworkIsolation","ripgrep"]),hooks:new Set(["PreToolUse","PostToolUse","Notification","UserPromptSubmit","SessionStart","SessionEnd","Stop","SubagentStop","PreCompact","PostCompact","TeammateIdle","TaskCreated","TaskCompleted"])};for(let q of Object.keys(J))if(Q.includes(q)&&J[q]&&typeof J[q]==="object"){let Y=J[q],W=Z[q];if(W){for(let K of Object.keys(Y))if(W.has(K))X.push(`${q}.${K}`)}}else X.push(q);return X.sort()}function iB(){if(S6)return{settings:{},errors:[]};let $=Date.now();n0("loadSettingsFromDisk_start"),Y1("info","settings_load_started"),S6=!0;try{let J=gY(),Q={};if(J)Q=O1(Q,J,n1);let X=[],Z=new Set,q=new Set;for(let Y of N4()){if(Y==="policySettings"){let K=null,B=[],w=I4();if(w&&Object.keys(w).length>0){let H=R0().safeParse(w);if(H.success)K=H.data;else B.push(..._2(H.error,"remote managed settings"))}if(!K){let H=Q8();if(Object.keys(H.settings).length>0)K=H.settings;B.push(...H.errors)}if(!K){let{settings:H,errors:z}=m6();if(H)K=H;B.push(...z)}if(!K){let H=X8();if(Object.keys(H.settings).length>0)K=H.settings;B.push(...H.errors)}if(K)Q=O1(Q,K,n1);for(let H of B){let z=`${H.file}:${H.path}:${H.message}`;if(!Z.has(z))Z.add(z),X.push(H)}continue}let W=Z8(Y);if(W){let K=z4(W);if(!q.has(K)){q.add(K);let{settings:B,errors:w}=x4(W);for(let H of w){let z=`${H.file}:${H.path}:${H.message}`;if(!Z.has(z))Z.add(z),X.push(H)}if(B)Q=O1(Q,B,n1)}}if(Y==="flagSettings"){let K=h6();if(K){let B=R0().safeParse(K);if(B.success)Q=O1(Q,B.data,n1)}}}return Y1("info","settings_load_completed",{duration_ms:Date.now()-$,source_count:q.size,error_count:X.length}),{settings:Q,errors:X}}finally{S6=!1}}function _0(){let{settings:$}=rB();return $||{}}function zP(){x2();let $=[];for(let J of N4()){let Q=S(J);if(Q&&Object.keys(Q).length>0)$.push({source:J,settings:Q})}return{effective:_0(),sources:$}}function rB(){let $=yY();if($!==null)return $;let J=iB();return n0("loadSettingsFromDisk_end"),SY(J),J}function xP(){return!!(S("userSettings")?.skipDangerousModePermissionPrompt||S("localSettings")?.skipDangerousModePermissionPrompt||S("flagSettings")?.skipDangerousModePermissionPrompt||S("policySettings")?.skipDangerousModePermissionPrompt)}function IP(){return!1}function TP(){return!0}function MP(){return}function PP($){for(let J of N4()){if(J==="policySettings")continue;let Q=Z8(J);if(!Q)continue;try{let{resolvedPath:X}=e0(x(),Q),Z=v0(X);if(!Z.trim())continue;let q=V0(Z,!1);if(q&&typeof q==="object"&&$ in q)return!0}catch(X){cY(X,Q)}}return!1}var S6=!1,z0;var J1=U(()=>{n();c6();wY();p();N8();j();N0();f4();F2();$1();Dq();k2();W0();T2();X0();q6();B6();xq();C4();vY();u6();F4();P6();z0=_0});
|
|
130
|
+
export{K9 as wT,B9 as xT,W8 as yT,rY as zT,v0 as AT,F2 as BT,ZL as CT,qL as DT,YL as ET,aY as FT,I4 as GT,c6 as HT,yx as IT,EK as JT,Sx as KT,fx as LT,bx as MT,hx as NT,Gq as OT,px as PT,gx as QT,mx as RT,ux as ST,dx as TT,cx as UT,CK as VT,lx as WT,nx as XT,ix as YT,rx as ZT,ox as _T,sx as $T,Lq as aU,ax as bU,f4 as cU,hK as dU,Dq as eU,GI as fU,KI as gU,BI as hU,LI as iU,UI as jU,HI as kU,N4 as lU,wI as mU,RI as nU,B6 as oU,NI as pU,DI as qU,xq as rU,X1 as sU,M2 as tU,C4 as uU,RR as vU,_R as wU,NR as xU,DR as yU,kQ as zU,OR as AU,FR as BU,zR as CU,xR as DU,IR as EU,TR as FU,MR as GU,PR as HU,ER as IU,AR as JU,CR as KU,VJ as LU,D4 as MU,L6 as NU,Mq as OU,kI as PU,vI as QU,jI as RU,yI as SU,SI as TU,fI as UU,bI as VU,hI as WU,pI as XU,Aq as YU,kq as ZU,vq as _U,Sq as $U,iI as aV,bq as bV,l1 as cV,r$ as dV,ZT as eV,qT as fV,YT as gV,uq as hV,VB as iV,WT as jV,VT as kV,KB as lV,GT as mV,i$ as nV,HB as oV,_B as pV,LT as qV,iq as rV,N6 as sV,HT as tV,rq as uV,RT as vV,_T as wV,aq as xV,tq as yV,OB as zV,FB as AV,OT as BV,FT as CV,zT as DV,eq as EV,$Y as FV,IT as GV,TT as HV,MT as IV,JY as JV,D6 as KV,QY as LV,XY as MV,AT as NV,ZY as OV,R2 as PV,yT as QV,YY as RV,ST as SV,WY as TV,hR as UV,Z$ as VV,bQ as WV,pR as XV,gR as YV,mR as ZV,uR as _V,dR as $V,vW as aW,cR as bW,q$ as cW,HY as dW,R0 as eW,ZM as fW,qM as gW,YM as hW,F4 as iW,OM as jW,P6 as kW,EM as lW,EY as mW,uM as nW,Q8 as oW,X8 as pW,dM as qW,cM as rW,vY as sW,m6 as tW,DP as uW,x4 as vW,jY as wW,Z8 as xW,lY as yW,S as zW,OP as AW,Q$ as BW,n1 as CW,FP as DW,_0 as EW,z0 as FW,zP as GW,rB as HW,xP as IW,IP as JW,TP as KW,MP as LW,PP as MW,J1 as NW,CU as OW,kU as PW,M7 as QW,A7 as RW,vU as SW,_9 as TW,h4 as UW,r1 as VW,f8 as WW,P as XW,bU as YW,f0 as ZW,b0 as _W,v as $W,nU as aX,u4 as bX,aU as cX,tU as dX,x9 as eX,JH as fX,b7 as gX,QH as hX,XH as iX,ZH as jX,qH as kX,P9 as lX,p0 as mX,f2 as nX,DH as oX,v9 as pX,M0 as qX,u8 as rX,h2 as sX,r4 as tX,uH as uX,$2 as vX,n8 as wX,L1 as xX,$W as yX,aH as zX,tH as AX,i9 as BX,eH as CX,$w as DX,E1 as EX,JW as FX,Jw as GX,Qw as HX,c9 as IX,o4 as JX,Kw as KX,YW as LX,r9 as MX,$Q as NX,t4 as OX,QQ as PX,Rw as QX,qQ as RX,O0 as SX,YQ as TX,g2 as UX,VQ as VX,GQ as WX,Ow as XX,Fw as YX,LQ as ZX,zw as _X,UQ as $X,xw as aY,Iw as bY,Tw as cY,JJ as dY,Pw as eY,Ew as fY,Aw as gY,Cw as hY,QJ as iY,wQ as jY,m2 as kY,F0 as lY,DQ as mY,HW as nY,iw as oY,rw as pY,ow as qY,OQ as rY,sw as sY,aw as tY,wW as uY,tw as vY,ew as wY,$R as xY,JR as yY,QR as zY,NW as AY,XR as BY,ZR as CY,qR as DY,YR as EY,IQ as FY,l2 as GY,zW as HY,xW as IY,WJ as JY,MQ as KY,UR as LY,AQ as MY,CQ as NY,EW as OY,GJ as PY,SQ as QY,fQ as RY,mQ as SY,q_ as TY,n2 as UY,uQ as VY,jW as WY,v1 as XY,Y$ as YY,dQ as ZY,Y_ as _Y,k1 as $Y,cQ as aZ,J0 as bZ,Q0 as cZ,yW as dZ,lQ as eZ,pQ as fZ,d2 as gZ,W_ as hZ,nQ as iZ,iQ as jZ,V_ as kZ,K0 as lZ,G_ as mZ,hW as nZ,K_ as oZ,B_ as pZ,L_ as qZ,u0 as rZ,rQ as sZ,H_ as tZ,HJ as uZ,D_ as vZ,YX as wZ,O_ as xZ,WX as yZ,GX as zZ,KX as AZ,NJ as BZ,LX as CZ,UX as DZ,HX as EZ,wX as FZ,DJ as GZ,NX as HZ,OJ as IZ,FJ as JZ,zJ as KZ,xJ as LZ,DX as MZ,X5 as NZ,zX as OZ,QZ as PZ,R$ as QZ,XZ as RZ,iN as SZ,KZ as TZ,oN as UZ,LZ as VZ,ZD as WZ,qD as XZ,YD as YZ,j1 as ZZ,E0 as _Z,WD as $Z,JV as a0,VD as b0,GD as c0,QV as d0,KD as e0,BJ as f0,wZ as g0,RZ as h0,ED as i0,VV as j0,AD as k0,CD as l0,NZ as m0,kD as n0,D$ as o0,GV as p0,vD as q0,FZ as r0,jJ as s0,bD as t0,hD as u0,TZ as v0,gD as w0,PZ as x0,EZ as y0,Y2 as z0,M1 as A0,U0 as B0,NV as C0,h1 as D0,R1 as E0,uJ as F0,cJ as G0,pZ as H0,DV as I0,_$ as J0,bJ as K0,FV as L0,zV as M0,gZ as N0,G1 as O0,PV as P0,nJ as Q0,mZ as R0,uZ as S0,e2 as T0,vV as U0,jV as V0,yV as W0,x$ as X0,r8 as Y0,fV as Z0,bV as _0,hV as $0,cZ as a1,C as b1,I$ as c1,c2 as d1,Q4 as e1,A1 as f1,y as g1,g0 as h1,mV as i1,_1 as j1,uV as k1,dV as l1,d as m1,W$ as n1,cV as o1,V$ as p1,lV as q1,LJ as r1,T$ as s1,lZ as t1,M$ as u1,iZ as v1,iV as w1,oV as x1,rZ as y1,sV as z1,aV as A1,y1 as B1,tV as C1,eV as D1,$G as E1,e as F1,P$ as G1,iJ as H1,tZ as I1,IO as J1,eZ as K1,ZZ as L1,vO as M1,jO as N1,q4 as O1,yO as P1,N$ as Q1,cO as R1,lO as S1,Q3 as T1,rJ as U1,X3 as V1,oO as W1,Z3 as X1,YF as Y1,WF as Z1,VF as _1,K3 as $1,IG as a2,U3 as b2,H3 as c2,OF as d2,_3 as e2,EG as f2,N3 as g2,j$ as h2,PF as i2,EF as j2,AF as k2,O3 as l2,iF as m2,fG as n2,rF as o2,pG as p2,oF as q2,sF as r2,z3 as s2,aF as t2,S3 as u2,X6 as v2,p$ as w2,c3 as x2,KK as y2,gz as z2,mz as A2,V2 as B2,uz as C2,o3 as D2,RK as E2,dz as F2,s3 as G2,Zx as H2,qx as I2,Yx as J2,Wx as K2,Vx as L2,Gx as M2,NK as N2,g$ as O2,DK as P2,Z0 as Q2,Kx as R2,zZ as S2,Bx as T2,Lx as U2,Ux as V2,Zq as W2,FK as X2,zK as Y2,qq as Z2,Hx as _2,B4 as $2,Q1 as a3,DL as b3,Q7 as c3,OL as d3,s6 as e3,a6 as f3,FL as g3,t6 as h3,V7 as i3,G7 as j3,PL as k3,$9 as l3,F8 as m3,_7 as n3,$U as o3,N7 as p3,JU as q3,t as r3,QU as s3,qU as t3,l as u3,YU as v3,WU as w3,I as x3,VU as y3,GU as z3,KU as A3,I8 as B3,BU as C3,LU as D3,I7 as E3,UU as F3,HU as G3,T7 as H3,j2 as I3,wU as J3,RU as K3,_U as L3,NU as M3,DU as N3,OU as O3,FU as P3,D0 as Q3};
|