@cloudflare/think 0.9.0 → 0.10.0
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.md +1 -1
- package/dist/cli/index.js +498 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/{codegen-KnFnKp0C.js → codegen-CuPdJRpV.js} +2 -2
- package/dist/{codegen-KnFnKp0C.js.map → codegen-CuPdJRpV.js.map} +1 -1
- package/dist/framework/index.d.ts +4 -4
- package/dist/framework/index.js +3 -3
- package/dist/messengers/index.d.ts +54 -54
- package/dist/messengers/telegram.d.ts +4 -4
- package/dist/{project-D1o1-3dN.js → project-BHurFdu4.js} +2 -2
- package/dist/{project-D1o1-3dN.js.map → project-BHurFdu4.js.map} +1 -1
- package/dist/studio/assets/abap-CLvhMVsD.js +1 -0
- package/dist/studio/assets/actionscript-3--17pq3dv.js +1 -0
- package/dist/studio/assets/ada-C5qYipkI.js +1 -0
- package/dist/studio/assets/andromeeda-vGVdxbeo.js +1 -0
- package/dist/studio/assets/angular-html-z-TUogET.js +1 -0
- package/dist/studio/assets/angular-ts-DMGuEVeg.js +1 -0
- package/dist/studio/assets/apache-U0d_L8uA.js +1 -0
- package/dist/studio/assets/apex-CGTLDQj6.js +1 -0
- package/dist/studio/assets/apl-KvrEROqd.js +1 -0
- package/dist/studio/assets/applescript-CCn79oCD.js +1 -0
- package/dist/studio/assets/ara-4CJ0cIlV.js +1 -0
- package/dist/studio/assets/asciidoc-DE70LPWp.js +1 -0
- package/dist/studio/assets/asm-Cmm7eHzH.js +1 -0
- package/dist/studio/assets/astro-Bm_woEti.js +1 -0
- package/dist/studio/assets/aurora-x-CDeNXAV0.js +1 -0
- package/dist/studio/assets/awk-BWXHIvNe.js +1 -0
- package/dist/studio/assets/ayu-dark-DluEY0Gj.js +1 -0
- package/dist/studio/assets/ayu-light-C3h-C4tm.js +1 -0
- package/dist/studio/assets/ayu-mirage-Bqwy1Gya.js +1 -0
- package/dist/studio/assets/ballerina-B7ZEbQpA.js +1 -0
- package/dist/studio/assets/bat-Bo4NYOV-.js +1 -0
- package/dist/studio/assets/beancount-D-usSTwE.js +1 -0
- package/dist/studio/assets/berry-DKpUyyne.js +1 -0
- package/dist/studio/assets/bibtex-Ci_nEsc7.js +1 -0
- package/dist/studio/assets/bicep-CUHmPFLl.js +1 -0
- package/dist/studio/assets/bird2-C2hNVINV.js +1 -0
- package/dist/studio/assets/blade-BdCF3r89.js +1 -0
- package/dist/studio/assets/bsl-BkkzgIyY.js +1 -0
- package/dist/studio/assets/c-CDqDtkvZ.js +1 -0
- package/dist/studio/assets/c3-CnJL0r0V.js +1 -0
- package/dist/studio/assets/cadence-CQ2zXKGN.js +1 -0
- package/dist/studio/assets/cairo-DLTphjLi.js +1 -0
- package/dist/studio/assets/catppuccin-frappe-3VR1Za6u.js +1 -0
- package/dist/studio/assets/catppuccin-latte-DwIHMF0Q.js +1 -0
- package/dist/studio/assets/catppuccin-macchiato-DYnBP6_5.js +1 -0
- package/dist/studio/assets/catppuccin-mocha-DYhrFGRu.js +1 -0
- package/dist/studio/assets/clarity-SemFz856.js +1 -0
- package/dist/studio/assets/clojure-DqKBuwfJ.js +1 -0
- package/dist/studio/assets/cmake-Bj61d0ZC.js +1 -0
- package/dist/studio/assets/cobol-CeFM1vZz.js +1 -0
- package/dist/studio/assets/codeowners-C8r90Shi.js +1 -0
- package/dist/studio/assets/codeql-oeQT6MSM.js +1 -0
- package/dist/studio/assets/coffee-2ed6LBym.js +1 -0
- package/dist/studio/assets/common-lisp-Cv5bFMCO.js +1 -0
- package/dist/studio/assets/coq-BrsZFFmf.js +1 -0
- package/dist/studio/assets/cpp-Dj3nX0J4.js +1 -0
- package/dist/studio/assets/crystal-BsIYZMQ3.js +1 -0
- package/dist/studio/assets/csharp-Ct8U2NOr.js +1 -0
- package/dist/studio/assets/css-B48fnuoH.js +1 -0
- package/dist/studio/assets/csv-Dx-8-gkx.js +1 -0
- package/dist/studio/assets/cue-CE9AQfxI.js +1 -0
- package/dist/studio/assets/cypher-ClKdZ_lG.js +1 -0
- package/dist/studio/assets/d-qD-0Kul2.js +1 -0
- package/dist/studio/assets/dark-plus-Cs2F2srj.js +1 -0
- package/dist/studio/assets/dart-DkHntEIa.js +1 -0
- package/dist/studio/assets/dax-BkyTk9wS.js +1 -0
- package/dist/studio/assets/desktop-Dlh5hvp9.js +1 -0
- package/dist/studio/assets/diff-woXpYk--.js +1 -0
- package/dist/studio/assets/docker-IyjqRm3v.js +1 -0
- package/dist/studio/assets/dotenv-_5a1GRtc.js +1 -0
- package/dist/studio/assets/dracula-BHWKrbxM.js +1 -0
- package/dist/studio/assets/dracula-soft-5eyTD99u.js +1 -0
- package/dist/studio/assets/dream-maker-DW3nJb8Q.js +1 -0
- package/dist/studio/assets/edge-C7qt1aza.js +1 -0
- package/dist/studio/assets/elixir-CiTmwoQ3.js +1 -0
- package/dist/studio/assets/elm-exDZ-PRY.js +1 -0
- package/dist/studio/assets/emacs-lisp-C9PiwqqW.js +1 -0
- package/dist/studio/assets/erb-3fmfgt-Q.js +1 -0
- package/dist/studio/assets/erlang-Cphh6RMH.js +1 -0
- package/dist/studio/assets/everforest-dark-sB-x3p7T.js +1 -0
- package/dist/studio/assets/everforest-light-Df2xbC6M.js +1 -0
- package/dist/studio/assets/fennel-DQxkIbk2.js +1 -0
- package/dist/studio/assets/fish-BJitypiv.js +1 -0
- package/dist/studio/assets/fluent-C03EYrpw.js +1 -0
- package/dist/studio/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
- package/dist/studio/assets/fortran-free-form-CYNrtFtB.js +1 -0
- package/dist/studio/assets/fsharp-D13ZGOAj.js +1 -0
- package/dist/studio/assets/gdresource-C0sCabJj.js +1 -0
- package/dist/studio/assets/gdscript-Cp2uCuqX.js +1 -0
- package/dist/studio/assets/gdshader-CBce3t8t.js +1 -0
- package/dist/studio/assets/genie-CV2tkWYe.js +1 -0
- package/dist/studio/assets/gherkin-DExj1W_8.js +1 -0
- package/dist/studio/assets/git-commit-BSykSTBG.js +1 -0
- package/dist/studio/assets/git-rebase-75I-C7zW.js +1 -0
- package/dist/studio/assets/github-dark-C-LZuMrd.js +1 -0
- package/dist/studio/assets/github-dark-default-DXG-b-1a.js +1 -0
- package/dist/studio/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
- package/dist/studio/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
- package/dist/studio/assets/github-light-EUqPIrTm.js +1 -0
- package/dist/studio/assets/github-light-default-BXViO-2h.js +1 -0
- package/dist/studio/assets/github-light-high-contrast-B68TUdTA.js +1 -0
- package/dist/studio/assets/gleam-CSRkHgEL.js +1 -0
- package/dist/studio/assets/glimmer-js-JjRzYRv8.js +1 -0
- package/dist/studio/assets/glimmer-ts-DcC_g6bi.js +1 -0
- package/dist/studio/assets/glsl-CHo__hpu.js +1 -0
- package/dist/studio/assets/gn-ilITqXS6.js +1 -0
- package/dist/studio/assets/gnuplot-7GGW24-e.js +1 -0
- package/dist/studio/assets/go-BJwz_mda.js +1 -0
- package/dist/studio/assets/graphql-J3cHpSdo.js +1 -0
- package/dist/studio/assets/groovy-CacY0gHj.js +1 -0
- package/dist/studio/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
- package/dist/studio/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
- package/dist/studio/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
- package/dist/studio/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
- package/dist/studio/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
- package/dist/studio/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
- package/dist/studio/assets/hack-or1FCnPg.js +1 -0
- package/dist/studio/assets/haml-uv3vtlo6.js +1 -0
- package/dist/studio/assets/handlebars--xrOP0sp.js +1 -0
- package/dist/studio/assets/haskell-D8IpX4py.js +1 -0
- package/dist/studio/assets/haxe-OTjmBuCE.js +1 -0
- package/dist/studio/assets/hcl-Dh228itO.js +1 -0
- package/dist/studio/assets/highlighted-body-OFNGDK62-D5UBAw6b.js +1 -0
- package/dist/studio/assets/hjson-CxZEssPk.js +1 -0
- package/dist/studio/assets/hlsl-Cvrh5tZx.js +1 -0
- package/dist/studio/assets/horizon-CE9ld1lL.js +1 -0
- package/dist/studio/assets/horizon-bright-Br1oVSNq.js +1 -0
- package/dist/studio/assets/houston-CsvMBhTu.js +1 -0
- package/dist/studio/assets/html-CWnTqWKh.js +1 -0
- package/dist/studio/assets/html-derivative-DWyLco-z.js +1 -0
- package/dist/studio/assets/http-BGB8mLqf.js +1 -0
- package/dist/studio/assets/hurl-BWdvIVUG.js +1 -0
- package/dist/studio/assets/hxml-B0Qn7Nwc.js +1 -0
- package/dist/studio/assets/hy-CZbG8q4J.js +1 -0
- package/dist/studio/assets/imba-DsUTQ-LC.js +1 -0
- package/dist/studio/assets/index-Cbb3GlZY.js +496 -0
- package/dist/studio/assets/index-DN9_cL01.css +2 -0
- package/dist/studio/assets/ini-B5eOa1yu.js +1 -0
- package/dist/studio/assets/java-BqyrPpKF.js +1 -0
- package/dist/studio/assets/javascript-D8Aej0xg.js +1 -0
- package/dist/studio/assets/jinja-SIORrXov.js +1 -0
- package/dist/studio/assets/jison-B2T4v51n.js +1 -0
- package/dist/studio/assets/json-BFdVRj9r.js +1 -0
- package/dist/studio/assets/json5-BR5RXkoi.js +1 -0
- package/dist/studio/assets/jsonc-CYpm1nAK.js +1 -0
- package/dist/studio/assets/jsonl-CmCQp5Yx.js +1 -0
- package/dist/studio/assets/jsonnet-CJTPZ8u_.js +1 -0
- package/dist/studio/assets/jssm-DXw9l8Rf.js +1 -0
- package/dist/studio/assets/jsx-w4r1xieS.js +1 -0
- package/dist/studio/assets/julia-BFBtDmmM.js +1 -0
- package/dist/studio/assets/just-CjAPsU_y.js +1 -0
- package/dist/studio/assets/kanagawa-dragon-CXtmUGW6.js +1 -0
- package/dist/studio/assets/kanagawa-lotus-BN08jTvb.js +1 -0
- package/dist/studio/assets/kanagawa-wave-CTweb8Dz.js +1 -0
- package/dist/studio/assets/kdl-CsD5j6eV.js +1 -0
- package/dist/studio/assets/kotlin-DhhofPvG.js +1 -0
- package/dist/studio/assets/kusto-BUv0MjJC.js +1 -0
- package/dist/studio/assets/laserwave-C_8bwKvT.js +1 -0
- package/dist/studio/assets/latex-CghDKqKz.js +1 -0
- package/dist/studio/assets/lean-CewbzKMR.js +1 -0
- package/dist/studio/assets/less-DVTAwKKz.js +1 -0
- package/dist/studio/assets/light-plus-DVQuIRkW.js +1 -0
- package/dist/studio/assets/liquid-Cp9loVkE.js +1 -0
- package/dist/studio/assets/llvm-Cm23YOpf.js +1 -0
- package/dist/studio/assets/log-BNLmms1o.js +1 -0
- package/dist/studio/assets/logo-Cluzi2Zq.js +1 -0
- package/dist/studio/assets/lua-HNnIDxnY.js +1 -0
- package/dist/studio/assets/luau-CNKltnaQ.js +1 -0
- package/dist/studio/assets/make-Dixweg8N.js +1 -0
- package/dist/studio/assets/markdown-BYOwaDjH.js +1 -0
- package/dist/studio/assets/marko-BXT10Apm.js +1 -0
- package/dist/studio/assets/material-theme-Bm3Qr25_.js +1 -0
- package/dist/studio/assets/material-theme-darker-2IIEA8gg.js +1 -0
- package/dist/studio/assets/material-theme-lighter-uhdI0v04.js +1 -0
- package/dist/studio/assets/material-theme-ocean-CHQ94UKr.js +1 -0
- package/dist/studio/assets/material-theme-palenight-B5W6OYN7.js +1 -0
- package/dist/studio/assets/matlab-D7qyCx1q.js +1 -0
- package/dist/studio/assets/mdc-CaiOz4_A.js +1 -0
- package/dist/studio/assets/mdx-DQZ5AkYe.js +1 -0
- package/dist/studio/assets/mermaid-Bk4SNUv9.js +1 -0
- package/dist/studio/assets/mermaid-GHXKKRXX-I2ZcYo7k.js +1 -0
- package/dist/studio/assets/min-dark-BSWPekZh.js +1 -0
- package/dist/studio/assets/min-light-DDpmG2fV.js +1 -0
- package/dist/studio/assets/mipsasm-BMqwQI7S.js +1 -0
- package/dist/studio/assets/mojo-BgCJLMeH.js +1 -0
- package/dist/studio/assets/monokai-CdkpiU2Y.js +1 -0
- package/dist/studio/assets/moonbit-CaWjb8XO.js +1 -0
- package/dist/studio/assets/move-B1IS1UjX.js +1 -0
- package/dist/studio/assets/narrat-_X_XdTYD.js +1 -0
- package/dist/studio/assets/nextflow-Bbiyy34d.js +1 -0
- package/dist/studio/assets/nextflow-groovy-Dc_ddanL.js +1 -0
- package/dist/studio/assets/nginx-DgYZ5SY9.js +1 -0
- package/dist/studio/assets/night-owl-DhmEMT88.js +1 -0
- package/dist/studio/assets/night-owl-light-eJ-hLW7d.js +1 -0
- package/dist/studio/assets/nim-CAMVX-MV.js +1 -0
- package/dist/studio/assets/nix-IvuFDN5E.js +1 -0
- package/dist/studio/assets/nord-Cb4Vim4T.js +1 -0
- package/dist/studio/assets/nushell-DcLAeLz5.js +1 -0
- package/dist/studio/assets/objective-c-D1A_Heim.js +1 -0
- package/dist/studio/assets/objective-cpp-BsSzOQcm.js +1 -0
- package/dist/studio/assets/ocaml-O90oeIOV.js +1 -0
- package/dist/studio/assets/odin-B1RWQWA5.js +1 -0
- package/dist/studio/assets/one-dark-pro-CLwyXe_n.js +1 -0
- package/dist/studio/assets/one-light-D7Lr4KcI.js +1 -0
- package/dist/studio/assets/openscad-BUDT5pXO.js +1 -0
- package/dist/studio/assets/pascal-4ZHwLPI5.js +1 -0
- package/dist/studio/assets/perl-Dc6Wp7SD.js +1 -0
- package/dist/studio/assets/php-DgLi8LNU.js +1 -0
- package/dist/studio/assets/pkl-ot-7Btpt.js +1 -0
- package/dist/studio/assets/plastic-DQwYfKfQ.js +1 -0
- package/dist/studio/assets/plsql-DGHpHOYJ.js +1 -0
- package/dist/studio/assets/po-BiJDBrnU.js +1 -0
- package/dist/studio/assets/poimandres-DRFjx7u4.js +1 -0
- package/dist/studio/assets/polar-C7UOKdEL.js +1 -0
- package/dist/studio/assets/postcss-BXeXVLqQ.js +1 -0
- package/dist/studio/assets/powerquery-DNMTfnFr.js +1 -0
- package/dist/studio/assets/powershell-DshXNtvi.js +1 -0
- package/dist/studio/assets/prisma-BsRQq5mF.js +1 -0
- package/dist/studio/assets/prolog-iXnhIJG7.js +1 -0
- package/dist/studio/assets/proto-DB4EqR-F.js +1 -0
- package/dist/studio/assets/pug-ZHFv4Vgd.js +1 -0
- package/dist/studio/assets/puppet-CDv2pdJW.js +1 -0
- package/dist/studio/assets/purescript-9MfHhQsQ.js +1 -0
- package/dist/studio/assets/python-gzcpVVnB.js +1 -0
- package/dist/studio/assets/qml-DU62cSZp.js +1 -0
- package/dist/studio/assets/qmldir-DCQb3MpD.js +1 -0
- package/dist/studio/assets/qss-Fe1Jh2GI.js +1 -0
- package/dist/studio/assets/r-BwU69RSh.js +1 -0
- package/dist/studio/assets/racket-DcIDlBhZ.js +1 -0
- package/dist/studio/assets/raku-B3gFvitq.js +1 -0
- package/dist/studio/assets/razor-BUgi_XZM.js +1 -0
- package/dist/studio/assets/red-CJ3rzSJv.js +1 -0
- package/dist/studio/assets/reg-CRGYupPL.js +1 -0
- package/dist/studio/assets/regexp-DuNhqfkW.js +1 -0
- package/dist/studio/assets/rel-BtDbiS_P.js +1 -0
- package/dist/studio/assets/riscv-Ckw8ddFX.js +1 -0
- package/dist/studio/assets/ron-VUp2lXgN.js +1 -0
- package/dist/studio/assets/rose-pine-BthvhNj6.js +1 -0
- package/dist/studio/assets/rose-pine-dawn-Dg85fqjY.js +1 -0
- package/dist/studio/assets/rose-pine-moon-hon4tzzS.js +1 -0
- package/dist/studio/assets/rosmsg-CAekHB0j.js +1 -0
- package/dist/studio/assets/rst-BB3BeaSy.js +1 -0
- package/dist/studio/assets/ruby-T0tkEfUZ.js +1 -0
- package/dist/studio/assets/rust-Cfkwpbl8.js +1 -0
- package/dist/studio/assets/sas-CMhZa3S0.js +1 -0
- package/dist/studio/assets/sass-DXrisJhu.js +1 -0
- package/dist/studio/assets/scala-DKOlJaKm.js +1 -0
- package/dist/studio/assets/scheme-DQCgrYNe.js +1 -0
- package/dist/studio/assets/scss-DtXjZ3vZ.js +1 -0
- package/dist/studio/assets/sdbl-bTVj8UrX.js +1 -0
- package/dist/studio/assets/shaderlab-TOUzSsQk.js +1 -0
- package/dist/studio/assets/shellscript-BESt-FLs.js +1 -0
- package/dist/studio/assets/shellsession-8irtvYxL.js +1 -0
- package/dist/studio/assets/slack-dark-DnToyrRv.js +1 -0
- package/dist/studio/assets/slack-ochin-B2OO5cIa.js +1 -0
- package/dist/studio/assets/smalltalk-B16xEiuN.js +1 -0
- package/dist/studio/assets/snazzy-light-4G7pJPwS.js +1 -0
- package/dist/studio/assets/solarized-dark-DV17i1UV.js +1 -0
- package/dist/studio/assets/solarized-light-DSh2HLQt.js +1 -0
- package/dist/studio/assets/solidity-CKzVLygQ.js +1 -0
- package/dist/studio/assets/soy-CIvhOgLR.js +1 -0
- package/dist/studio/assets/sparql-D_iOobhT.js +1 -0
- package/dist/studio/assets/splunk-BC2Px7Mm.js +1 -0
- package/dist/studio/assets/sql-obAOXh1G.js +1 -0
- package/dist/studio/assets/ssh-config-BgfXC-Er.js +1 -0
- package/dist/studio/assets/stata-D3OCK8xW.js +1 -0
- package/dist/studio/assets/stylus-B6D30XZt.js +1 -0
- package/dist/studio/assets/surrealql-Dk_bguB0.js +1 -0
- package/dist/studio/assets/svelte-C0-KQt-t.js +1 -0
- package/dist/studio/assets/swift-DonLKvLd.js +1 -0
- package/dist/studio/assets/synthwave-84-nFMaYfgc.js +1 -0
- package/dist/studio/assets/system-verilog-DJ5XKQeo.js +1 -0
- package/dist/studio/assets/systemd-BxMlprV5.js +1 -0
- package/dist/studio/assets/talonscript-CohzipZa.js +1 -0
- package/dist/studio/assets/tasl-DMoTqEGO.js +1 -0
- package/dist/studio/assets/tcl-CZd0xW_V.js +1 -0
- package/dist/studio/assets/templ-lg4nvF9H.js +1 -0
- package/dist/studio/assets/terraform-DswuEJGm.js +1 -0
- package/dist/studio/assets/tex-BNcQSX7R.js +1 -0
- package/dist/studio/assets/tokyo-night-oM2G3aXe.js +1 -0
- package/dist/studio/assets/toml-CcmNWLt0.js +1 -0
- package/dist/studio/assets/ts-tags-AgW9jVv0.js +1 -0
- package/dist/studio/assets/tsv-sltzmVWM.js +1 -0
- package/dist/studio/assets/tsx-CL8XyR3d.js +1 -0
- package/dist/studio/assets/turtle-ByJddavk.js +1 -0
- package/dist/studio/assets/twig-VkSbsH0Y.js +1 -0
- package/dist/studio/assets/typescript-BfD1znAG.js +1 -0
- package/dist/studio/assets/typespec-B88KGewJ.js +1 -0
- package/dist/studio/assets/typst-DI99ib-x.js +1 -0
- package/dist/studio/assets/v-DETTlOr0.js +1 -0
- package/dist/studio/assets/vala-zf12oZj6.js +1 -0
- package/dist/studio/assets/vb-Djn5o6TS.js +1 -0
- package/dist/studio/assets/verilog-CiiDBU1e.js +1 -0
- package/dist/studio/assets/vesper-D5bVUKB1.js +1 -0
- package/dist/studio/assets/vhdl-BroJfC0k.js +1 -0
- package/dist/studio/assets/viml-DvXPmvsu.js +1 -0
- package/dist/studio/assets/vitesse-black-fwtXNY1n.js +1 -0
- package/dist/studio/assets/vitesse-dark-BZCL-v6S.js +1 -0
- package/dist/studio/assets/vitesse-light-VbXTXTou.js +1 -0
- package/dist/studio/assets/vue-gv_2i8Vk.js +1 -0
- package/dist/studio/assets/vue-html-w3sbjuft.js +1 -0
- package/dist/studio/assets/vue-vine-C9sgcRlL.js +1 -0
- package/dist/studio/assets/vyper-CgoNMtux.js +1 -0
- package/dist/studio/assets/wasm-BnjxR4X6.js +1 -0
- package/dist/studio/assets/wasm-ByWQv1Qj.js +1 -0
- package/dist/studio/assets/wenyan-C8pVoKbM.js +1 -0
- package/dist/studio/assets/wgsl-BsKzXJz4.js +1 -0
- package/dist/studio/assets/wikitext-ClFFjSW2.js +1 -0
- package/dist/studio/assets/wit-DdvCle-K.js +1 -0
- package/dist/studio/assets/wolfram-DLL8P-h_.js +1 -0
- package/dist/studio/assets/xml-nNPxMKnG.js +1 -0
- package/dist/studio/assets/xsl-C7iHP36x.js +1 -0
- package/dist/studio/assets/yaml-Cq3YaG6o.js +1 -0
- package/dist/studio/assets/zenscript-BnlCZFoB.js +1 -0
- package/dist/studio/assets/zig-CMLA9XwU.js +1 -0
- package/dist/studio/index.html +23 -0
- package/dist/{think-CK0xW_QY.js → think-BYZXQ-vm.js} +89 -5
- package/dist/think-BYZXQ-vm.js.map +1 -0
- package/dist/{think-Cike7VBF.d.ts → think-i1Pkgb1R.d.ts} +198 -115
- package/dist/think.d.ts +2 -2
- package/dist/think.js +1 -1
- package/dist/tools/browser.d.ts +60 -9
- package/dist/tools/browser.js +13 -9
- package/dist/tools/browser.js.map +1 -1
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +74 -2
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +1 -1
- package/package.json +22 -4
- package/dist/think-CK0xW_QY.js.map +0 -1
package/README.md
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as readWranglerConfig, c as createThinkWorkerConfig, h as discoverThinkApp, i as readProjectFiles, m as summarizeThinkManifest, n as createThinkProject, o as resolveThinkManifest, t as applyUserBindingNames } from "../project-
|
|
2
|
+
import { a as readWranglerConfig, c as createThinkWorkerConfig, h as discoverThinkApp, i as readProjectFiles, m as summarizeThinkManifest, n as createThinkProject, o as resolveThinkManifest, t as applyUserBindingNames } from "../project-BHurFdu4.js";
|
|
3
3
|
import { n as isThinkGeneratedFile, t as generateThinkTypes } from "../types-codegen-B6c5KpYH.js";
|
|
4
|
-
import {
|
|
4
|
+
import { CHAT_MESSAGE_TYPES } from "agents/chat";
|
|
5
|
+
import { access, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import yargs from "yargs";
|
|
7
8
|
import { hideBin } from "yargs/helpers";
|
|
8
9
|
import { spawn } from "node:child_process";
|
|
9
10
|
import { initCommand, looksLikeThinkApp } from "create-think";
|
|
11
|
+
import { AgentClient } from "agents/client";
|
|
12
|
+
import { createReadStream } from "node:fs";
|
|
13
|
+
import { createServer } from "node:http";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
10
15
|
//#region src/cli/init.ts
|
|
11
16
|
const VITE_CONFIG_FILES = [
|
|
12
17
|
"vite.config.ts",
|
|
@@ -200,7 +205,7 @@ const FRAMEWORK_DEPENDENCIES = {
|
|
|
200
205
|
};
|
|
201
206
|
const THIRD_PARTY_DEPENDENCIES = {
|
|
202
207
|
ai: "^6.0.202",
|
|
203
|
-
"workers-ai-provider": "^3.
|
|
208
|
+
"workers-ai-provider": "^3.2.0"
|
|
204
209
|
};
|
|
205
210
|
const THIRD_PARTY_DEV_DEPENDENCIES = {
|
|
206
211
|
"@cloudflare/vite-plugin": "^1.40.2",
|
|
@@ -253,7 +258,7 @@ function agentSource() {
|
|
|
253
258
|
"export class Assistant extends Think<Env> {",
|
|
254
259
|
" override getModel() {",
|
|
255
260
|
" return createWorkersAI({ binding: this.env.AI })(",
|
|
256
|
-
" \"@cf/moonshotai/kimi-k2.
|
|
261
|
+
" \"@cf/moonshotai/kimi-k2.7-code\",",
|
|
257
262
|
" { sessionAffinity: this.sessionAffinity }",
|
|
258
263
|
" );",
|
|
259
264
|
" }",
|
|
@@ -426,6 +431,417 @@ function severityLabel(severity) {
|
|
|
426
431
|
return severity.toUpperCase();
|
|
427
432
|
}
|
|
428
433
|
//#endregion
|
|
434
|
+
//#region src/cli/target.ts
|
|
435
|
+
/**
|
|
436
|
+
* Browser-safe, IO-free helpers for turning loose connection inputs (a remote
|
|
437
|
+
* `url` or a local `host`, an agent id, an instance, a token, extra query
|
|
438
|
+
* params) into the concrete `{ host, protocol, basePath, query }` an
|
|
439
|
+
* `AgentClient`/`useAgent` needs.
|
|
440
|
+
*
|
|
441
|
+
* This module is deliberately dependency-free so it can be imported by both the
|
|
442
|
+
* Node-side runtime CLI (`connect.ts`) and the browser Studio app. The
|
|
443
|
+
* manifest-aware resolution (friendly agent ids/aliases) lives in `connect.ts`;
|
|
444
|
+
* everything here is pure string math.
|
|
445
|
+
*/
|
|
446
|
+
/**
|
|
447
|
+
* Mirror the default `routeAgentRequest` segment derivation so a raw agent name
|
|
448
|
+
* (e.g. a class name) maps to the same route the server exposes.
|
|
449
|
+
*/
|
|
450
|
+
function camelCaseToKebabCase(str) {
|
|
451
|
+
if (str === str.toUpperCase() && str !== str.toLowerCase()) return str.toLowerCase().replace(/_/g, "-");
|
|
452
|
+
let kebabified = str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
453
|
+
kebabified = kebabified.startsWith("-") ? kebabified.slice(1) : kebabified;
|
|
454
|
+
return kebabified.replace(/_/g, "-").replace(/-$/, "");
|
|
455
|
+
}
|
|
456
|
+
/** Normalize a route prefix to a slash-free segment (default `agents`). */
|
|
457
|
+
function normalizeRoutePrefix(routePrefix) {
|
|
458
|
+
return (routePrefix ?? "/agents").replace(/^\/+|\/+$/g, "") || "agents";
|
|
459
|
+
}
|
|
460
|
+
function parseQuery(query, token) {
|
|
461
|
+
const result = {};
|
|
462
|
+
if (token) result.token = token;
|
|
463
|
+
if (!query) return result;
|
|
464
|
+
if (Array.isArray(query)) {
|
|
465
|
+
for (const pair of query) {
|
|
466
|
+
const eq = pair.indexOf("=");
|
|
467
|
+
if (eq <= 0) throw new Error(`Invalid query "${pair}" (expected key=value).`);
|
|
468
|
+
result[pair.slice(0, eq)] = pair.slice(eq + 1);
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
for (const [key, value] of Object.entries(query)) result[key] = value;
|
|
473
|
+
return result;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Resolve host/protocol/basePath/query from loose inputs. Pure (no IO), so it
|
|
477
|
+
* is safe in the browser and trivially unit-testable.
|
|
478
|
+
*/
|
|
479
|
+
function deriveWsTarget(input) {
|
|
480
|
+
const instance = input.instance?.trim() || "default";
|
|
481
|
+
const prefix = normalizeRoutePrefix(input.routePrefix);
|
|
482
|
+
let host;
|
|
483
|
+
let protocol;
|
|
484
|
+
if (input.url) {
|
|
485
|
+
let origin;
|
|
486
|
+
try {
|
|
487
|
+
origin = new URL(input.url);
|
|
488
|
+
} catch {
|
|
489
|
+
throw new Error(`Invalid url "${input.url}" (expected a full origin).`);
|
|
490
|
+
}
|
|
491
|
+
if (!origin.host) throw new Error(`Invalid url "${input.url}" (missing host — include a scheme, e.g. https://host).`);
|
|
492
|
+
host = origin.host;
|
|
493
|
+
protocol = input.protocol === "ws" || input.protocol === "wss" ? input.protocol : origin.protocol === "https:" || origin.protocol === "wss:" ? "wss" : "ws";
|
|
494
|
+
} else {
|
|
495
|
+
host = input.host?.trim() || "localhost:5173";
|
|
496
|
+
protocol = input.protocol === "wss" ? "wss" : "ws";
|
|
497
|
+
}
|
|
498
|
+
const segment = input.canonicalAgent ? input.agent : camelCaseToKebabCase(input.agent);
|
|
499
|
+
const basePath = [
|
|
500
|
+
prefix,
|
|
501
|
+
encodeURIComponent(segment),
|
|
502
|
+
encodeURIComponent(instance)
|
|
503
|
+
].join("/");
|
|
504
|
+
return {
|
|
505
|
+
host,
|
|
506
|
+
protocol,
|
|
507
|
+
basePath,
|
|
508
|
+
query: parseQuery(input.query, input.token),
|
|
509
|
+
instance,
|
|
510
|
+
segment
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/cli/connect.ts
|
|
515
|
+
function findTopLevelAgent(manifest, agent) {
|
|
516
|
+
return manifest.agents.find((entry) => entry.kind === "top-level" && (entry.id === agent || entry.bindingName === agent || entry.className === agent || entry.aliases.includes(agent)));
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Resolve target/URL/auth details from CLI options. Pure (no IO) so it can be
|
|
520
|
+
* unit-tested with a synthetic manifest. The manifest, when supplied, lets the
|
|
521
|
+
* CLI accept friendly agent ids/aliases and honor a custom route prefix; when
|
|
522
|
+
* the agent isn't found we treat it as a literal route segment (kebab-cased to
|
|
523
|
+
* match the default `routeAgentRequest` behavior) so the CLI also works against
|
|
524
|
+
* an arbitrary deployed worker. The browser-safe URL/query math lives in
|
|
525
|
+
* {@link deriveWsTarget}; this layer only adds manifest awareness.
|
|
526
|
+
*/
|
|
527
|
+
function resolveTarget(input) {
|
|
528
|
+
const topLevel = input.manifest ? findTopLevelAgent(input.manifest, input.agent) : void 0;
|
|
529
|
+
const matchedManifest = topLevel !== void 0;
|
|
530
|
+
const derived = deriveWsTarget({
|
|
531
|
+
agent: topLevel ? topLevel.id : input.agent,
|
|
532
|
+
canonicalAgent: topLevel !== void 0,
|
|
533
|
+
instance: input.instance,
|
|
534
|
+
url: input.url,
|
|
535
|
+
host: input.host,
|
|
536
|
+
protocol: input.protocol,
|
|
537
|
+
token: input.token,
|
|
538
|
+
query: input.query,
|
|
539
|
+
routePrefix: input.routePrefix
|
|
540
|
+
});
|
|
541
|
+
return {
|
|
542
|
+
host: derived.host,
|
|
543
|
+
protocol: derived.protocol,
|
|
544
|
+
basePath: derived.basePath,
|
|
545
|
+
query: derived.query,
|
|
546
|
+
agent: input.agent,
|
|
547
|
+
instance: derived.instance,
|
|
548
|
+
matchedManifest
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
async function loadManifest(root, routePrefix) {
|
|
552
|
+
try {
|
|
553
|
+
return await resolveThinkManifest({ routePrefix }, path.resolve(root ?? process.cwd()));
|
|
554
|
+
} catch {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 15e3;
|
|
559
|
+
/**
|
|
560
|
+
* Resolve once the client receives its identity handshake, or reject after
|
|
561
|
+
* `timeoutMs` (covers unreachable hosts, which otherwise retry silently).
|
|
562
|
+
*/
|
|
563
|
+
function waitForClientReady(client, timeoutMs = DEFAULT_CONNECT_TIMEOUT_MS) {
|
|
564
|
+
return new Promise((resolve, reject) => {
|
|
565
|
+
let settled = false;
|
|
566
|
+
const timer = setTimeout(() => {
|
|
567
|
+
if (settled) return;
|
|
568
|
+
settled = true;
|
|
569
|
+
reject(/* @__PURE__ */ new Error(`Timed out after ${timeoutMs}ms connecting to the agent. Check the host/url, that the dev server or worker is running, and the token.`));
|
|
570
|
+
}, timeoutMs);
|
|
571
|
+
client.ready.then(() => {
|
|
572
|
+
if (settled) return;
|
|
573
|
+
settled = true;
|
|
574
|
+
clearTimeout(timer);
|
|
575
|
+
resolve();
|
|
576
|
+
}, (error) => {
|
|
577
|
+
if (settled) return;
|
|
578
|
+
settled = true;
|
|
579
|
+
clearTimeout(timer);
|
|
580
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Resolve a target (loading the local manifest when present) and open a
|
|
586
|
+
* connected {@link AgentClient} backed by Node's global `WebSocket`.
|
|
587
|
+
*/
|
|
588
|
+
async function connectToThinkAgent(options) {
|
|
589
|
+
const WebSocketImpl = globalThis.WebSocket;
|
|
590
|
+
if (typeof WebSocketImpl !== "function") throw new Error("No global WebSocket found. The `think` runtime CLI requires Node.js 24+ (which provides a built-in WebSocket).");
|
|
591
|
+
const manifest = await loadManifest(options.root, options.routePrefix);
|
|
592
|
+
const target = resolveTarget({
|
|
593
|
+
...options,
|
|
594
|
+
manifest
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
client: new AgentClient({
|
|
598
|
+
agent: target.agent,
|
|
599
|
+
name: target.instance,
|
|
600
|
+
basePath: target.basePath,
|
|
601
|
+
host: target.host,
|
|
602
|
+
protocol: target.protocol,
|
|
603
|
+
query: target.query,
|
|
604
|
+
WebSocket: WebSocketImpl
|
|
605
|
+
}),
|
|
606
|
+
target
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/cli/state.ts
|
|
611
|
+
const SNAPSHOT_WAIT_MS = 1e3;
|
|
612
|
+
function delay(ms) {
|
|
613
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
614
|
+
}
|
|
615
|
+
function messageText(message) {
|
|
616
|
+
let text = "";
|
|
617
|
+
for (const part of message.parts) if (part.type === "text") text += part.text;
|
|
618
|
+
return text;
|
|
619
|
+
}
|
|
620
|
+
async function stateCommand(options) {
|
|
621
|
+
const { client, target } = await connectToThinkAgent(options);
|
|
622
|
+
const socket = client;
|
|
623
|
+
let messages = [];
|
|
624
|
+
let gotSnapshot = false;
|
|
625
|
+
const listener = (event) => {
|
|
626
|
+
if (typeof event.data !== "string") return;
|
|
627
|
+
let frame;
|
|
628
|
+
try {
|
|
629
|
+
frame = JSON.parse(event.data);
|
|
630
|
+
} catch {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (frame.type === CHAT_MESSAGE_TYPES.CHAT_MESSAGES && Array.isArray(frame.messages)) {
|
|
634
|
+
messages = frame.messages;
|
|
635
|
+
gotSnapshot = true;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
socket.addEventListener("message", listener);
|
|
639
|
+
try {
|
|
640
|
+
await waitForClientReady(client);
|
|
641
|
+
} catch (error) {
|
|
642
|
+
socket.removeEventListener("message", listener);
|
|
643
|
+
client.close();
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
const deadline = Date.now() + SNAPSHOT_WAIT_MS;
|
|
647
|
+
while (!gotSnapshot && Date.now() < deadline) await delay(50);
|
|
648
|
+
socket.removeEventListener("message", listener);
|
|
649
|
+
const limit = options.limit ?? 10;
|
|
650
|
+
const recent = limit > 0 ? messages.slice(-limit) : messages;
|
|
651
|
+
if (options.json) {
|
|
652
|
+
console.log(JSON.stringify({
|
|
653
|
+
agent: client.agent,
|
|
654
|
+
name: client.name,
|
|
655
|
+
state: client.state ?? null,
|
|
656
|
+
messages: recent
|
|
657
|
+
}, null, 2));
|
|
658
|
+
client.close();
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const lines = [
|
|
662
|
+
"Think state",
|
|
663
|
+
`Endpoint: ${target.protocol === "wss" ? "https" : "http"}://${target.host}/${target.basePath}`,
|
|
664
|
+
`Agent: ${client.agent}`,
|
|
665
|
+
`Instance: ${client.name}`,
|
|
666
|
+
"",
|
|
667
|
+
"State:",
|
|
668
|
+
client.state === void 0 ? "- none" : indent(JSON.stringify(client.state, null, 2)),
|
|
669
|
+
"",
|
|
670
|
+
`Recent messages (${recent.length}):`,
|
|
671
|
+
...recent.length === 0 ? ["- none"] : recent.map((message) => {
|
|
672
|
+
const text = messageText(message).trim();
|
|
673
|
+
return `- ${message.role}: ${text || "(no text)"}`;
|
|
674
|
+
})
|
|
675
|
+
];
|
|
676
|
+
console.log(lines.join("\n"));
|
|
677
|
+
client.close();
|
|
678
|
+
}
|
|
679
|
+
function indent(value) {
|
|
680
|
+
return value.split("\n").map((line) => ` ${line}`).join("\n");
|
|
681
|
+
}
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/cli/studio-config.ts
|
|
684
|
+
/**
|
|
685
|
+
* Build the `/__studio/config.json` payload from the resolved target and the
|
|
686
|
+
* (optional) local manifest. Pure so it can be unit-tested directly.
|
|
687
|
+
*/
|
|
688
|
+
function buildStudioConfig(input) {
|
|
689
|
+
const agents = (input.manifest?.agents ?? []).filter((entry) => entry.kind === "top-level").map((entry) => ({
|
|
690
|
+
id: entry.id,
|
|
691
|
+
label: entry.bindingName || entry.id
|
|
692
|
+
}));
|
|
693
|
+
return {
|
|
694
|
+
target: input.target,
|
|
695
|
+
agents
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/cli/studio.ts
|
|
700
|
+
const CONTENT_TYPES = {
|
|
701
|
+
".html": "text/html; charset=utf-8",
|
|
702
|
+
".js": "text/javascript; charset=utf-8",
|
|
703
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
704
|
+
".css": "text/css; charset=utf-8",
|
|
705
|
+
".json": "application/json; charset=utf-8",
|
|
706
|
+
".svg": "image/svg+xml",
|
|
707
|
+
".png": "image/png",
|
|
708
|
+
".jpg": "image/jpeg",
|
|
709
|
+
".jpeg": "image/jpeg",
|
|
710
|
+
".gif": "image/gif",
|
|
711
|
+
".ico": "image/x-icon",
|
|
712
|
+
".woff": "font/woff",
|
|
713
|
+
".woff2": "font/woff2",
|
|
714
|
+
".map": "application/json; charset=utf-8"
|
|
715
|
+
};
|
|
716
|
+
function studioDistDir() {
|
|
717
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../studio");
|
|
718
|
+
}
|
|
719
|
+
async function loadManifestAgents(root, routePrefix) {
|
|
720
|
+
try {
|
|
721
|
+
return await resolveThinkManifest({ routePrefix }, path.resolve(root ?? process.cwd()));
|
|
722
|
+
} catch {
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function buildTarget(options) {
|
|
727
|
+
const target = {};
|
|
728
|
+
if (options.url) target.url = options.url;
|
|
729
|
+
if (options.host) target.host = options.host;
|
|
730
|
+
if (options.protocol === "ws" || options.protocol === "wss") target.protocol = options.protocol;
|
|
731
|
+
if (options.token) target.token = options.token;
|
|
732
|
+
if (options.agent) target.agent = options.agent;
|
|
733
|
+
if (options.instance) target.instance = options.instance;
|
|
734
|
+
if (options.routePrefix) target.routePrefix = options.routePrefix;
|
|
735
|
+
return target;
|
|
736
|
+
}
|
|
737
|
+
function openBrowser(url) {
|
|
738
|
+
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
739
|
+
try {
|
|
740
|
+
const child = spawn(command, [url], {
|
|
741
|
+
stdio: "ignore",
|
|
742
|
+
detached: true,
|
|
743
|
+
shell: process.platform === "win32"
|
|
744
|
+
});
|
|
745
|
+
child.on("error", () => {});
|
|
746
|
+
child.unref();
|
|
747
|
+
} catch {}
|
|
748
|
+
}
|
|
749
|
+
/** Resolve a file under `root`, guarding against path traversal. */
|
|
750
|
+
function safeResolve(root, urlPath) {
|
|
751
|
+
let decoded;
|
|
752
|
+
try {
|
|
753
|
+
decoded = decodeURIComponent(urlPath.split("?")[0]);
|
|
754
|
+
} catch {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
const resolved = path.resolve(root, `.${decoded}`);
|
|
758
|
+
if (resolved !== root && !resolved.startsWith(root + path.sep)) return null;
|
|
759
|
+
return resolved;
|
|
760
|
+
}
|
|
761
|
+
async function studioCommand(options) {
|
|
762
|
+
const distDir = studioDistDir();
|
|
763
|
+
try {
|
|
764
|
+
await stat(path.join(distDir, "index.html"));
|
|
765
|
+
} catch {
|
|
766
|
+
throw new Error(`Think Studio assets were not found at ${distDir}. Reinstall @cloudflare/think (the published package ships the prebuilt Studio), or run the package build.`);
|
|
767
|
+
}
|
|
768
|
+
const manifest = await loadManifestAgents(options.root, options.routePrefix);
|
|
769
|
+
const config = buildStudioConfig({
|
|
770
|
+
target: buildTarget(options),
|
|
771
|
+
manifest
|
|
772
|
+
});
|
|
773
|
+
const configJson = JSON.stringify(config);
|
|
774
|
+
const server = createServer((req, res) => {
|
|
775
|
+
const urlPath = req.url ?? "/";
|
|
776
|
+
if (urlPath === "/__studio/config.json") {
|
|
777
|
+
res.writeHead(200, {
|
|
778
|
+
"content-type": "application/json; charset=utf-8",
|
|
779
|
+
"cache-control": "no-store"
|
|
780
|
+
});
|
|
781
|
+
res.end(configJson);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const rawPath = urlPath.split("?")[0];
|
|
785
|
+
const candidate = rawPath === "/" ? path.join(distDir, "index.html") : safeResolve(distDir, rawPath);
|
|
786
|
+
const serve = (filePath) => {
|
|
787
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
788
|
+
const stream = createReadStream(filePath);
|
|
789
|
+
stream.on("error", () => {
|
|
790
|
+
if (res.headersSent) res.destroy();
|
|
791
|
+
else {
|
|
792
|
+
res.writeHead(500);
|
|
793
|
+
res.end("Internal error");
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
stream.once("open", () => {
|
|
797
|
+
res.writeHead(200, { "content-type": CONTENT_TYPES[ext] ?? "application/octet-stream" });
|
|
798
|
+
stream.pipe(res);
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
if (!candidate) {
|
|
802
|
+
res.writeHead(404);
|
|
803
|
+
res.end("Not found");
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
stat(candidate).then((s) => {
|
|
807
|
+
if (s.isFile()) serve(candidate);
|
|
808
|
+
else serve(path.join(distDir, "index.html"));
|
|
809
|
+
}).catch(() => serve(path.join(distDir, "index.html")));
|
|
810
|
+
});
|
|
811
|
+
const studioUrl = `http://localhost:${await listen(server, options.port ?? 4321)}/`;
|
|
812
|
+
console.log(`Think Studio running at ${studioUrl}`);
|
|
813
|
+
console.log("Press Ctrl+C to stop.");
|
|
814
|
+
if (options.open !== false) openBrowser(studioUrl);
|
|
815
|
+
await new Promise((resolve) => {
|
|
816
|
+
const shutdown = () => {
|
|
817
|
+
server.close(() => resolve());
|
|
818
|
+
};
|
|
819
|
+
process.once("SIGINT", shutdown);
|
|
820
|
+
process.once("SIGTERM", shutdown);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
/** Listen on `startPort`, advancing on EADDRINUSE up to 20 ports. */
|
|
824
|
+
function listen(server, startPort) {
|
|
825
|
+
return new Promise((resolve, reject) => {
|
|
826
|
+
let attempt = 0;
|
|
827
|
+
const tryPort = (port) => {
|
|
828
|
+
const onError = (err) => {
|
|
829
|
+
if (err.code === "EADDRINUSE" && attempt < 20) {
|
|
830
|
+
attempt += 1;
|
|
831
|
+
tryPort(port + 1);
|
|
832
|
+
} else reject(err);
|
|
833
|
+
};
|
|
834
|
+
server.once("error", onError);
|
|
835
|
+
server.listen(port, "127.0.0.1", () => {
|
|
836
|
+
server.removeListener("error", onError);
|
|
837
|
+
const address = server.address();
|
|
838
|
+
resolve(typeof address === "object" && address ? address.port : port);
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
tryPort(startPort);
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
//#endregion
|
|
429
845
|
//#region src/cli/types.ts
|
|
430
846
|
async function typesCommand(options) {
|
|
431
847
|
const root = path.resolve(options.root ?? process.cwd());
|
|
@@ -533,6 +949,40 @@ function isMissingFileError(error) {
|
|
|
533
949
|
}
|
|
534
950
|
//#endregion
|
|
535
951
|
//#region src/cli/create.ts
|
|
952
|
+
function connectionOptions(cmd) {
|
|
953
|
+
return cmd.positional("agent", {
|
|
954
|
+
type: "string",
|
|
955
|
+
describe: "Agent id/alias (from the manifest) or a raw route segment"
|
|
956
|
+
}).positional("instance", {
|
|
957
|
+
type: "string",
|
|
958
|
+
describe: "Agent instance name",
|
|
959
|
+
default: "default"
|
|
960
|
+
}).option("url", {
|
|
961
|
+
type: "string",
|
|
962
|
+
describe: "Remote origin, e.g. https://app.example.com (implies wss)"
|
|
963
|
+
}).option("host", {
|
|
964
|
+
type: "string",
|
|
965
|
+
describe: "Local host[:port] (default: localhost:5173)"
|
|
966
|
+
}).option("protocol", {
|
|
967
|
+
type: "string",
|
|
968
|
+
choices: ["ws", "wss"],
|
|
969
|
+
describe: "Override the WebSocket protocol"
|
|
970
|
+
}).option("token", {
|
|
971
|
+
type: "string",
|
|
972
|
+
describe: "Auth token, sent as the `token` query param"
|
|
973
|
+
}).option("query", {
|
|
974
|
+
type: "string",
|
|
975
|
+
array: true,
|
|
976
|
+
describe: "Extra query params as key=value (repeatable)"
|
|
977
|
+
}).option("root", {
|
|
978
|
+
type: "string",
|
|
979
|
+
describe: "Project root used to discover the Think manifest",
|
|
980
|
+
default: process.cwd()
|
|
981
|
+
}).option("route-prefix", {
|
|
982
|
+
type: "string",
|
|
983
|
+
describe: "Override the Think route prefix"
|
|
984
|
+
});
|
|
985
|
+
}
|
|
536
986
|
function createCli(argv = process.argv) {
|
|
537
987
|
return yargs(hideBin(argv)).parserConfiguration({ "populate--": true }).scriptName("think").usage("$0 <command> [options]").command("init [directory]", "Scaffold a new Think app from a starter template, or add Think to the current project", (cmd) => cmd.positional("directory", {
|
|
538
988
|
type: "string",
|
|
@@ -638,6 +1088,50 @@ function createCli(argv = process.argv) {
|
|
|
638
1088
|
check: args.check,
|
|
639
1089
|
wranglerArgs: Array.isArray(args["--"]) ? args["--"].map(String) : []
|
|
640
1090
|
});
|
|
1091
|
+
}).command("studio [agent] [instance]", "Launch Think Studio — a local web app to chat with and inspect a running Think instance (local or remote)", (cmd) => connectionOptions(cmd).option("port", {
|
|
1092
|
+
type: "number",
|
|
1093
|
+
describe: "Port for the local Studio server",
|
|
1094
|
+
default: 4321
|
|
1095
|
+
}).option("open", {
|
|
1096
|
+
type: "boolean",
|
|
1097
|
+
describe: "Open the browser automatically",
|
|
1098
|
+
default: true
|
|
1099
|
+
}), async (args) => {
|
|
1100
|
+
await studioCommand({
|
|
1101
|
+
agent: args.agent,
|
|
1102
|
+
instance: args.instance,
|
|
1103
|
+
url: args.url,
|
|
1104
|
+
host: args.host,
|
|
1105
|
+
protocol: args.protocol,
|
|
1106
|
+
token: args.token,
|
|
1107
|
+
query: args.query,
|
|
1108
|
+
root: args.root,
|
|
1109
|
+
routePrefix: args.routePrefix,
|
|
1110
|
+
port: args.port,
|
|
1111
|
+
open: args.open
|
|
1112
|
+
});
|
|
1113
|
+
}).command("state <agent> [instance]", "Print a running Think agent's identity, state, and recent history (read-only)", (cmd) => connectionOptions(cmd).option("json", {
|
|
1114
|
+
type: "boolean",
|
|
1115
|
+
describe: "Print machine-readable JSON output",
|
|
1116
|
+
default: false
|
|
1117
|
+
}).option("limit", {
|
|
1118
|
+
type: "number",
|
|
1119
|
+
describe: "Number of recent messages to include",
|
|
1120
|
+
default: 10
|
|
1121
|
+
}), async (args) => {
|
|
1122
|
+
await stateCommand({
|
|
1123
|
+
agent: args.agent,
|
|
1124
|
+
instance: args.instance,
|
|
1125
|
+
url: args.url,
|
|
1126
|
+
host: args.host,
|
|
1127
|
+
protocol: args.protocol,
|
|
1128
|
+
token: args.token,
|
|
1129
|
+
query: args.query,
|
|
1130
|
+
root: args.root,
|
|
1131
|
+
routePrefix: args.routePrefix,
|
|
1132
|
+
json: args.json,
|
|
1133
|
+
limit: args.limit
|
|
1134
|
+
});
|
|
641
1135
|
}).demandCommand(1, "Please provide a command").strict().help();
|
|
642
1136
|
}
|
|
643
1137
|
//#endregion
|