mycode-cli 0.1.0__py3-none-any.whl
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.
- mycode/__init__.py +1 -0
- mycode/cli/__init__.py +1 -0
- mycode/cli/chat.py +650 -0
- mycode/cli/main.py +245 -0
- mycode/cli/render.py +693 -0
- mycode/cli/runtime.py +271 -0
- mycode/cli/theme.py +109 -0
- mycode/core/__init__.py +30 -0
- mycode/core/agent.py +515 -0
- mycode/core/config.py +551 -0
- mycode/core/messages.py +166 -0
- mycode/core/models.py +144 -0
- mycode/core/models_catalog.json +2090 -0
- mycode/core/providers/__init__.py +86 -0
- mycode/core/providers/anthropic_like.py +366 -0
- mycode/core/providers/base.py +351 -0
- mycode/core/providers/gemini.py +321 -0
- mycode/core/providers/openai_chat.py +356 -0
- mycode/core/providers/openai_responses.py +326 -0
- mycode/core/session.py +537 -0
- mycode/core/system_prompt.md +10 -0
- mycode/core/system_prompt.py +319 -0
- mycode/core/tools.py +898 -0
- mycode/server/__init__.py +1 -0
- mycode/server/app.py +52 -0
- mycode/server/deps.py +29 -0
- mycode/server/routers/__init__.py +7 -0
- mycode/server/routers/chat.py +320 -0
- mycode/server/routers/sessions.py +77 -0
- mycode/server/routers/workspaces.py +92 -0
- mycode/server/run_manager.py +195 -0
- mycode/server/schemas.py +66 -0
- mycode/server/static/assets/EditDiff-C1ql7kft.js +12 -0
- mycode/server/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- mycode/server/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- mycode/server/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- mycode/server/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- mycode/server/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- mycode/server/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- mycode/server/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- mycode/server/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- mycode/server/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- mycode/server/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- mycode/server/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- mycode/server/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- mycode/server/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- mycode/server/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- mycode/server/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- mycode/server/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- mycode/server/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- mycode/server/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- mycode/server/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- mycode/server/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- mycode/server/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- mycode/server/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- mycode/server/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- mycode/server/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- mycode/server/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- mycode/server/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- mycode/server/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- mycode/server/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- mycode/server/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- mycode/server/static/assets/abap-BdImnpbu.js +1 -0
- mycode/server/static/assets/actionscript-3-CoDkCxhg.js +1 -0
- mycode/server/static/assets/ada-bCR0ucgS.js +1 -0
- mycode/server/static/assets/andromeeda-C4gqWexZ.js +1 -0
- mycode/server/static/assets/angular-html-DA-rfuFy.js +1 -0
- mycode/server/static/assets/angular-ts-BrjP3tb8.js +1 -0
- mycode/server/static/assets/apache-Pmp26Uib.js +1 -0
- mycode/server/static/assets/apex-D8_7TLub.js +1 -0
- mycode/server/static/assets/apl-CORt7UWP.js +1 -0
- mycode/server/static/assets/applescript-Co6uUVPk.js +1 -0
- mycode/server/static/assets/ara-BRHolxvo.js +1 -0
- mycode/server/static/assets/asciidoc-Ve4PFQV2.js +1 -0
- mycode/server/static/assets/asm-D_Q5rh1f.js +1 -0
- mycode/server/static/assets/astro-HNnZUWAn.js +1 -0
- mycode/server/static/assets/aurora-x-D-2ljcwZ.js +1 -0
- mycode/server/static/assets/auto-render-xntwXHOX.js +261 -0
- mycode/server/static/assets/awk-DMzUqQB5.js +1 -0
- mycode/server/static/assets/ayu-dark-DYE7WIF3.js +1 -0
- mycode/server/static/assets/ayu-light-BA47KaF1.js +1 -0
- mycode/server/static/assets/ayu-mirage-32ctXXKs.js +1 -0
- mycode/server/static/assets/ballerina-BFfxhgS-.js +1 -0
- mycode/server/static/assets/bat-BkioyH1T.js +1 -0
- mycode/server/static/assets/beancount-k_qm7-4y.js +1 -0
- mycode/server/static/assets/berry-uYugtg8r.js +1 -0
- mycode/server/static/assets/bibtex-CHM0blh-.js +1 -0
- mycode/server/static/assets/bicep-Bmn6On1c.js +1 -0
- mycode/server/static/assets/bird2-BIv1doCn.js +1 -0
- mycode/server/static/assets/blade-BjGOyj-B.js +1 -0
- mycode/server/static/assets/bsl-BO_Y6i37.js +1 -0
- mycode/server/static/assets/c-BIGW1oBm.js +1 -0
- mycode/server/static/assets/c3-eo99z4R2.js +1 -0
- mycode/server/static/assets/cadence-Bv_4Rxtq.js +1 -0
- mycode/server/static/assets/cairo-KRGpt6FW.js +1 -0
- mycode/server/static/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- mycode/server/static/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- mycode/server/static/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- mycode/server/static/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- mycode/server/static/assets/clarity-D53aC0YG.js +1 -0
- mycode/server/static/assets/clojure-P80f7IUj.js +1 -0
- mycode/server/static/assets/cmake-D1j8_8rp.js +1 -0
- mycode/server/static/assets/cobol-nBiQ_Alo.js +1 -0
- mycode/server/static/assets/codeowners-Bp6g37R7.js +1 -0
- mycode/server/static/assets/codeql-DsOJ9woJ.js +1 -0
- mycode/server/static/assets/coffee-Ch7k5sss.js +1 -0
- mycode/server/static/assets/common-lisp-Cg-RD9OK.js +1 -0
- mycode/server/static/assets/coq-DkFqJrB1.js +1 -0
- mycode/server/static/assets/cpp-CofmeUqb.js +1 -0
- mycode/server/static/assets/crystal-DNxU26gB.js +1 -0
- mycode/server/static/assets/csharp-COcwbKMJ.js +1 -0
- mycode/server/static/assets/css-CLj8gQPS.js +1 -0
- mycode/server/static/assets/csv-fuZLfV_i.js +1 -0
- mycode/server/static/assets/cue-D82EKSYY.js +1 -0
- mycode/server/static/assets/cypher-COkxafJQ.js +1 -0
- mycode/server/static/assets/d-85-TOEBH.js +1 -0
- mycode/server/static/assets/dark-plus-C3mMm8J8.js +1 -0
- mycode/server/static/assets/dart-bE4Kk8sk.js +1 -0
- mycode/server/static/assets/dax-CEL-wOlO.js +1 -0
- mycode/server/static/assets/desktop-BmXAJ9_W.js +1 -0
- mycode/server/static/assets/diff-D97Zzqfu.js +1 -0
- mycode/server/static/assets/docker-BcOcwvcX.js +1 -0
- mycode/server/static/assets/dotenv-Da5cRb03.js +1 -0
- mycode/server/static/assets/dracula-BzJJZx-M.js +1 -0
- mycode/server/static/assets/dracula-soft-BXkSAIEj.js +1 -0
- mycode/server/static/assets/dream-maker-BtqSS_iP.js +1 -0
- mycode/server/static/assets/edge-FbVlp4U3.js +1 -0
- mycode/server/static/assets/elixir-CkH2-t6x.js +1 -0
- mycode/server/static/assets/elm-DbKCFpqz.js +1 -0
- mycode/server/static/assets/emacs-lisp-CXvaQtF9.js +1 -0
- mycode/server/static/assets/erb-BYCe7drp.js +1 -0
- mycode/server/static/assets/erlang-DsQrWhSR.js +1 -0
- mycode/server/static/assets/everforest-dark-BgDCqdQA.js +1 -0
- mycode/server/static/assets/everforest-light-C8M2exoo.js +1 -0
- mycode/server/static/assets/fennel-BYunw83y.js +1 -0
- mycode/server/static/assets/fish-BvzEVeQv.js +1 -0
- mycode/server/static/assets/fluent-C4IJs8-o.js +1 -0
- mycode/server/static/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
- mycode/server/static/assets/fortran-free-form-BxgE0vQu.js +1 -0
- mycode/server/static/assets/fsharp-CXgrBDvD.js +1 -0
- mycode/server/static/assets/gdresource-BOOCDP_w.js +1 -0
- mycode/server/static/assets/gdscript-C5YyOfLZ.js +1 -0
- mycode/server/static/assets/gdshader-DkwncUOv.js +1 -0
- mycode/server/static/assets/genie-D0YGMca9.js +1 -0
- mycode/server/static/assets/gherkin-DyxjwDmM.js +1 -0
- mycode/server/static/assets/git-commit-F4YmCXRG.js +1 -0
- mycode/server/static/assets/git-rebase-r7XF79zn.js +1 -0
- mycode/server/static/assets/github-dark-DHJKELXO.js +1 -0
- mycode/server/static/assets/github-dark-default-Cuk6v7N8.js +1 -0
- mycode/server/static/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- mycode/server/static/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- mycode/server/static/assets/github-light-DAi9KRSo.js +1 -0
- mycode/server/static/assets/github-light-default-D7oLnXFd.js +1 -0
- mycode/server/static/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- mycode/server/static/assets/gleam-BspZqrRM.js +1 -0
- mycode/server/static/assets/glimmer-js-ByusRIyA.js +1 -0
- mycode/server/static/assets/glimmer-ts-BfAWNZQY.js +1 -0
- mycode/server/static/assets/glsl-DplSGwfg.js +1 -0
- mycode/server/static/assets/gn-n2N0HUVH.js +1 -0
- mycode/server/static/assets/gnuplot-DdkO51Og.js +1 -0
- mycode/server/static/assets/go-C27-OAKa.js +1 -0
- mycode/server/static/assets/graphql-ChdNCCLP.js +1 -0
- mycode/server/static/assets/groovy-gcz8RCvz.js +1 -0
- mycode/server/static/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- mycode/server/static/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- mycode/server/static/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- mycode/server/static/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- mycode/server/static/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- mycode/server/static/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- mycode/server/static/assets/hack-i7_Ulhet.js +1 -0
- mycode/server/static/assets/haml-D5jkg6IW.js +1 -0
- mycode/server/static/assets/handlebars-BpdQsYii.js +1 -0
- mycode/server/static/assets/haskell-Df6bDoY_.js +1 -0
- mycode/server/static/assets/haxe-CzTSHFRz.js +1 -0
- mycode/server/static/assets/hcl-BWvSN4gD.js +1 -0
- mycode/server/static/assets/hjson-D5-asLiD.js +1 -0
- mycode/server/static/assets/hlsl-D3lLCCz7.js +1 -0
- mycode/server/static/assets/horizon-BUw7H-hv.js +1 -0
- mycode/server/static/assets/horizon-bright-CUuTKBJd.js +1 -0
- mycode/server/static/assets/houston-DnULxvSX.js +1 -0
- mycode/server/static/assets/html-derivative-DlHx6ybY.js +1 -0
- mycode/server/static/assets/html-pp8916En.js +1 -0
- mycode/server/static/assets/http-jrhK8wxY.js +1 -0
- mycode/server/static/assets/hurl-irOxFIW8.js +1 -0
- mycode/server/static/assets/hxml-Bvhsp5Yf.js +1 -0
- mycode/server/static/assets/hy-DFXneXwc.js +1 -0
- mycode/server/static/assets/imba-DGztddWO.js +1 -0
- mycode/server/static/assets/index-B4e4WQPq.css +1 -0
- mycode/server/static/assets/index-C2xTNJGd.js +203 -0
- mycode/server/static/assets/ini-BEwlwnbL.js +1 -0
- mycode/server/static/assets/java-CylS5w8V.js +1 -0
- mycode/server/static/assets/javascript-wDzz0qaB.js +1 -0
- mycode/server/static/assets/jinja-f2NsQr07.js +1 -0
- mycode/server/static/assets/jison-wvAkD_A8.js +1 -0
- mycode/server/static/assets/json-Cp-IABpG.js +1 -0
- mycode/server/static/assets/json5-C9tS-k6U.js +1 -0
- mycode/server/static/assets/jsonc-Des-eS-w.js +1 -0
- mycode/server/static/assets/jsonl-DcaNXYhu.js +1 -0
- mycode/server/static/assets/jsonnet-DFQXde-d.js +1 -0
- mycode/server/static/assets/jssm-C2t-YnRu.js +1 -0
- mycode/server/static/assets/jsx-g9-lgVsj.js +1 -0
- mycode/server/static/assets/julia-CxzCAyBv.js +1 -0
- mycode/server/static/assets/just-VxiPbLrw.js +1 -0
- mycode/server/static/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- mycode/server/static/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- mycode/server/static/assets/kanagawa-wave-DWedfzmr.js +1 -0
- mycode/server/static/assets/katex-DnJR2-55.css +1 -0
- mycode/server/static/assets/kdl-DV7GczEv.js +1 -0
- mycode/server/static/assets/kotlin-BdnUsdx6.js +1 -0
- mycode/server/static/assets/kusto-wEQ09or8.js +1 -0
- mycode/server/static/assets/laserwave-DUszq2jm.js +1 -0
- mycode/server/static/assets/latex-CWtU0Tv5.js +1 -0
- mycode/server/static/assets/lean-BZvkOJ9d.js +1 -0
- mycode/server/static/assets/less-B1dDrJ26.js +1 -0
- mycode/server/static/assets/light-plus-B7mTdjB0.js +1 -0
- mycode/server/static/assets/liquid-C0sCDyMI.js +1 -0
- mycode/server/static/assets/llvm-DjAJT7YJ.js +1 -0
- mycode/server/static/assets/log-2UxHyX5q.js +1 -0
- mycode/server/static/assets/logo-BtOb2qkB.js +1 -0
- mycode/server/static/assets/lua-BaeVxFsk.js +1 -0
- mycode/server/static/assets/luau-C-HG3fhB.js +1 -0
- mycode/server/static/assets/make-CHLpvVh8.js +1 -0
- mycode/server/static/assets/markdown-Cvjx9yec.js +1 -0
- mycode/server/static/assets/marko-DjSrsDqO.js +1 -0
- mycode/server/static/assets/material-theme-D5KoaKCx.js +1 -0
- mycode/server/static/assets/material-theme-darker-BfHTSMKl.js +1 -0
- mycode/server/static/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- mycode/server/static/assets/material-theme-ocean-CyktbL80.js +1 -0
- mycode/server/static/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- mycode/server/static/assets/matlab-D7o27uSR.js +1 -0
- mycode/server/static/assets/mdc-DTYItulj.js +1 -0
- mycode/server/static/assets/mdx-Cmh6b_Ma.js +1 -0
- mycode/server/static/assets/mermaid-mWjccvbQ.js +1 -0
- mycode/server/static/assets/min-dark-CafNBF8u.js +1 -0
- mycode/server/static/assets/min-light-CTRr51gU.js +1 -0
- mycode/server/static/assets/mipsasm-CKIfxQSi.js +1 -0
- mycode/server/static/assets/mojo-rZm6bMo-.js +1 -0
- mycode/server/static/assets/monokai-D4h5O-jR.js +1 -0
- mycode/server/static/assets/moonbit-_H4v1dQx.js +1 -0
- mycode/server/static/assets/move-IF9eRakj.js +1 -0
- mycode/server/static/assets/narrat-DRg8JJMk.js +1 -0
- mycode/server/static/assets/nextflow-C-mBbutL.js +1 -0
- mycode/server/static/assets/nextflow-groovy-vE_lwT2v.js +1 -0
- mycode/server/static/assets/nginx-BpAMiNFr.js +1 -0
- mycode/server/static/assets/night-owl-C39BiMTA.js +1 -0
- mycode/server/static/assets/night-owl-light-CMTm3GFP.js +1 -0
- mycode/server/static/assets/nim-BIad80T-.js +1 -0
- mycode/server/static/assets/nix-CwoSXNpI.js +1 -0
- mycode/server/static/assets/nord-Ddv68eIx.js +1 -0
- mycode/server/static/assets/nushell-Cz2AlsmD.js +1 -0
- mycode/server/static/assets/objective-c-DXmwc3jG.js +1 -0
- mycode/server/static/assets/objective-cpp-CLxacb5B.js +1 -0
- mycode/server/static/assets/ocaml-C0hk2d4L.js +1 -0
- mycode/server/static/assets/odin-BBf5iR-q.js +1 -0
- mycode/server/static/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- mycode/server/static/assets/one-light-C3Wv6jpd.js +1 -0
- mycode/server/static/assets/openscad-C4EeE6gA.js +1 -0
- mycode/server/static/assets/pascal-D93ZcfNL.js +1 -0
- mycode/server/static/assets/perl-NvoQZIq0.js +1 -0
- mycode/server/static/assets/php-R6g_5hLQ.js +1 -0
- mycode/server/static/assets/pkl-u5AG7uiY.js +1 -0
- mycode/server/static/assets/plastic-3e1v2bzS.js +1 -0
- mycode/server/static/assets/plsql-ChMvpjG-.js +1 -0
- mycode/server/static/assets/po-BTJTHyun.js +1 -0
- mycode/server/static/assets/poimandres-CS3Unz2-.js +1 -0
- mycode/server/static/assets/polar-C0HS_06l.js +1 -0
- mycode/server/static/assets/postcss-CXtECtnM.js +1 -0
- mycode/server/static/assets/powerquery-CEu0bR-o.js +1 -0
- mycode/server/static/assets/powershell-Dpen1YoG.js +1 -0
- mycode/server/static/assets/prisma-Dd19v3D-.js +1 -0
- mycode/server/static/assets/prolog-CbFg5uaA.js +1 -0
- mycode/server/static/assets/proto-C7zT0LnQ.js +1 -0
- mycode/server/static/assets/pug-DKIMFp6K.js +1 -0
- mycode/server/static/assets/puppet-BMWR74SV.js +1 -0
- mycode/server/static/assets/purescript-CklMAg4u.js +1 -0
- mycode/server/static/assets/python-B6aJPvgy.js +1 -0
- mycode/server/static/assets/qml-3beO22l8.js +1 -0
- mycode/server/static/assets/qmldir-C8lEn-DE.js +1 -0
- mycode/server/static/assets/qss-IeuSbFQv.js +1 -0
- mycode/server/static/assets/r-Dspwwk_N.js +1 -0
- mycode/server/static/assets/racket-BqYA7rlc.js +1 -0
- mycode/server/static/assets/raku-DXvB9xmW.js +1 -0
- mycode/server/static/assets/razor-BDqjjVU7.js +1 -0
- mycode/server/static/assets/red-bN70gL4F.js +1 -0
- mycode/server/static/assets/reg-C-SQnVFl.js +1 -0
- mycode/server/static/assets/regexp-CDVJQ6XC.js +1 -0
- mycode/server/static/assets/rel-C3B-1QV4.js +1 -0
- mycode/server/static/assets/riscv-BM1_JUlF.js +1 -0
- mycode/server/static/assets/ron-D8l8udqQ.js +1 -0
- mycode/server/static/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
- mycode/server/static/assets/rose-pine-moon-D4_iv3hh.js +1 -0
- mycode/server/static/assets/rose-pine-qdsjHGoJ.js +1 -0
- mycode/server/static/assets/rosmsg-BJDFO7_C.js +1 -0
- mycode/server/static/assets/rst-CRjBmOyv.js +1 -0
- mycode/server/static/assets/ruby-Wjq7vjNf.js +1 -0
- mycode/server/static/assets/rust-B1yitclQ.js +1 -0
- mycode/server/static/assets/sas-cz2c8ADy.js +1 -0
- mycode/server/static/assets/sass-Cj5Yp3dK.js +1 -0
- mycode/server/static/assets/scala-C151Ov-r.js +1 -0
- mycode/server/static/assets/scheme-C98Dy4si.js +1 -0
- mycode/server/static/assets/scss-D5BDwBP9.js +1 -0
- mycode/server/static/assets/sdbl-DVxCFoDh.js +1 -0
- mycode/server/static/assets/shaderlab-Dg9Lc6iA.js +1 -0
- mycode/server/static/assets/shellscript-Yzrsuije.js +1 -0
- mycode/server/static/assets/shellsession-BADoaaVG.js +1 -0
- mycode/server/static/assets/slack-dark-BthQWCQV.js +1 -0
- mycode/server/static/assets/slack-ochin-DqwNpetd.js +1 -0
- mycode/server/static/assets/smalltalk-BERRCDM3.js +1 -0
- mycode/server/static/assets/snazzy-light-Bw305WKR.js +1 -0
- mycode/server/static/assets/solarized-dark-DXbdFlpD.js +1 -0
- mycode/server/static/assets/solarized-light-L9t79GZl.js +1 -0
- mycode/server/static/assets/solidity-rGO070M0.js +1 -0
- mycode/server/static/assets/soy-8wufbnw4.js +1 -0
- mycode/server/static/assets/sparql-rVzFXLq3.js +1 -0
- mycode/server/static/assets/splunk-BtCnVYZw.js +1 -0
- mycode/server/static/assets/sql-BLtJtn59.js +1 -0
- mycode/server/static/assets/ssh-config-_ykCGR6B.js +1 -0
- mycode/server/static/assets/stata-BH5u7GGu.js +1 -0
- mycode/server/static/assets/stylus-BEDo0Tqx.js +1 -0
- mycode/server/static/assets/surrealql-Bq5Q-fJD.js +1 -0
- mycode/server/static/assets/svelte-Cy7k_4gC.js +1 -0
- mycode/server/static/assets/swift-D82vCrfD.js +1 -0
- mycode/server/static/assets/synthwave-84-CbfX1IO0.js +1 -0
- mycode/server/static/assets/system-verilog-CnnmHF94.js +1 -0
- mycode/server/static/assets/systemd-4A_iFExJ.js +1 -0
- mycode/server/static/assets/talonscript-CkByrt1z.js +1 -0
- mycode/server/static/assets/tasl-QIJgUcNo.js +1 -0
- mycode/server/static/assets/tcl-dwOrl1Do.js +1 -0
- mycode/server/static/assets/templ-DhtptRzy.js +1 -0
- mycode/server/static/assets/terraform-BETggiCN.js +1 -0
- mycode/server/static/assets/tex-idrVyKtj.js +1 -0
- mycode/server/static/assets/tokyo-night-hegEt444.js +1 -0
- mycode/server/static/assets/toml-vGWfd6FD.js +1 -0
- mycode/server/static/assets/ts-tags-DQrlYJgV.js +1 -0
- mycode/server/static/assets/tsv-B_m7g4N7.js +1 -0
- mycode/server/static/assets/tsx-COt5Ahok.js +1 -0
- mycode/server/static/assets/turtle-BsS91CYL.js +1 -0
- mycode/server/static/assets/twig-xg9kU7Mw.js +1 -0
- mycode/server/static/assets/typescript-BPQ3VLAy.js +1 -0
- mycode/server/static/assets/typespec-CAFt9gP4.js +1 -0
- mycode/server/static/assets/typst-DHCkPAjA.js +1 -0
- mycode/server/static/assets/v-BcVCzyr7.js +1 -0
- mycode/server/static/assets/vala-CsfeWuGM.js +1 -0
- mycode/server/static/assets/vb-D17OF-Vu.js +1 -0
- mycode/server/static/assets/verilog-BQ8w6xss.js +1 -0
- mycode/server/static/assets/vesper-DU1UobuO.js +1 -0
- mycode/server/static/assets/vhdl-CeAyd5Ju.js +1 -0
- mycode/server/static/assets/viml-CJc9bBzg.js +1 -0
- mycode/server/static/assets/vitesse-black-Bkuqu6BP.js +1 -0
- mycode/server/static/assets/vitesse-dark-D0r3Knsf.js +1 -0
- mycode/server/static/assets/vitesse-light-CVO1_9PV.js +1 -0
- mycode/server/static/assets/vue-D2xRrEX4.js +1 -0
- mycode/server/static/assets/vue-html-AaS7Mt5G.js +1 -0
- mycode/server/static/assets/vue-vine-BoDAl6tE.js +1 -0
- mycode/server/static/assets/vyper-CDx5xZoG.js +1 -0
- mycode/server/static/assets/wasm-CG6Dc4jp.js +1 -0
- mycode/server/static/assets/wasm-MzD3tlZU.js +1 -0
- mycode/server/static/assets/wenyan-BV7otONQ.js +1 -0
- mycode/server/static/assets/wgsl-Dx-B1_4e.js +1 -0
- mycode/server/static/assets/wikitext-BhOHFoWU.js +1 -0
- mycode/server/static/assets/wit-5i3qLPDT.js +1 -0
- mycode/server/static/assets/wolfram-lXgVvXCa.js +1 -0
- mycode/server/static/assets/xml-sdJ4AIDG.js +1 -0
- mycode/server/static/assets/xsl-CtQFsRM5.js +1 -0
- mycode/server/static/assets/yaml-Buea-lGh.js +1 -0
- mycode/server/static/assets/zenscript-DVFEvuxE.js +1 -0
- mycode/server/static/assets/zig-VOosw3JB.js +1 -0
- mycode/server/static/favicon_slashes.svg +12 -0
- mycode/server/static/index.html +35 -0
- mycode_cli-0.1.0.dist-info/METADATA +186 -0
- mycode_cli-0.1.0.dist-info/RECORD +404 -0
- mycode_cli-0.1.0.dist-info/WHEEL +4 -0
- mycode_cli-0.1.0.dist-info/entry_points.txt +2 -0
- mycode_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Provider adapter registry and public import surface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from mycode.core.providers.anthropic_like import AnthropicAdapter, MiniMaxAdapter, MoonshotAIAdapter
|
|
6
|
+
from mycode.core.providers.base import ProviderAdapter
|
|
7
|
+
from mycode.core.providers.gemini import GoogleGeminiAdapter
|
|
8
|
+
from mycode.core.providers.openai_chat import DeepSeekAdapter, OpenAIChatAdapter, OpenRouterAdapter, ZAIAdapter
|
|
9
|
+
from mycode.core.providers.openai_responses import OpenAIResponsesAdapter
|
|
10
|
+
|
|
11
|
+
_PROVIDERS: dict[str, ProviderAdapter] = {
|
|
12
|
+
adapter.provider_id: adapter
|
|
13
|
+
for adapter in (
|
|
14
|
+
AnthropicAdapter(),
|
|
15
|
+
OpenAIResponsesAdapter(),
|
|
16
|
+
GoogleGeminiAdapter(),
|
|
17
|
+
DeepSeekAdapter(),
|
|
18
|
+
ZAIAdapter(),
|
|
19
|
+
MoonshotAIAdapter(),
|
|
20
|
+
MiniMaxAdapter(),
|
|
21
|
+
OpenRouterAdapter(),
|
|
22
|
+
OpenAIChatAdapter(),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def list_supported_providers() -> list[str]:
|
|
28
|
+
"""Return all built-in provider ids."""
|
|
29
|
+
|
|
30
|
+
return sorted(_PROVIDERS)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def list_env_discoverable_providers() -> list[str]:
|
|
34
|
+
"""Return provider ids that can be discovered from env vars alone."""
|
|
35
|
+
|
|
36
|
+
return [provider_id for provider_id, adapter in _PROVIDERS.items() if adapter.auto_discoverable]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def is_supported_provider(provider_name: str | None) -> bool:
|
|
40
|
+
"""Return whether the given provider id is registered."""
|
|
41
|
+
|
|
42
|
+
return bool(provider_name and provider_name in _PROVIDERS)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_provider_adapter(provider_name: str) -> ProviderAdapter:
|
|
46
|
+
try:
|
|
47
|
+
return _PROVIDERS[provider_name]
|
|
48
|
+
except KeyError as exc:
|
|
49
|
+
supported = ", ".join(list_supported_providers())
|
|
50
|
+
raise ValueError(f"unsupported provider {provider_name!r}; supported: {supported}") from exc
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def provider_env_api_key_names(provider_name: str | None) -> tuple[str, ...]:
|
|
54
|
+
adapter = _PROVIDERS.get(provider_name) if provider_name else None
|
|
55
|
+
return adapter.env_api_key_names if adapter else ()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def provider_api_key_from_env(provider_name: str | None) -> str | None:
|
|
59
|
+
adapter = _PROVIDERS.get(provider_name) if provider_name else None
|
|
60
|
+
return adapter.api_key_from_env() if adapter else None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def provider_default_models(provider_name: str | None) -> tuple[str, ...]:
|
|
64
|
+
adapter = _PROVIDERS.get(provider_name) if provider_name else None
|
|
65
|
+
return adapter.default_models if adapter else ()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
"AnthropicAdapter",
|
|
70
|
+
"ProviderAdapter",
|
|
71
|
+
"GoogleGeminiAdapter",
|
|
72
|
+
"MiniMaxAdapter",
|
|
73
|
+
"MoonshotAIAdapter",
|
|
74
|
+
"DeepSeekAdapter",
|
|
75
|
+
"OpenAIChatAdapter",
|
|
76
|
+
"OpenAIResponsesAdapter",
|
|
77
|
+
"OpenRouterAdapter",
|
|
78
|
+
"ZAIAdapter",
|
|
79
|
+
"get_provider_adapter",
|
|
80
|
+
"list_env_discoverable_providers",
|
|
81
|
+
"is_supported_provider",
|
|
82
|
+
"list_supported_providers",
|
|
83
|
+
"provider_api_key_from_env",
|
|
84
|
+
"provider_default_models",
|
|
85
|
+
"provider_env_api_key_names",
|
|
86
|
+
]
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"""Anthropic Messages adapters built on the official Anthropic Python SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
from collections.abc import AsyncIterator
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from anthropic import APIError, AsyncAnthropic
|
|
10
|
+
|
|
11
|
+
from mycode.core.messages import (
|
|
12
|
+
ConversationMessage,
|
|
13
|
+
assistant_message,
|
|
14
|
+
text_block,
|
|
15
|
+
thinking_block,
|
|
16
|
+
tool_use_block,
|
|
17
|
+
)
|
|
18
|
+
from mycode.core.providers.base import (
|
|
19
|
+
DEFAULT_REQUEST_TIMEOUT,
|
|
20
|
+
ProviderAdapter,
|
|
21
|
+
ProviderRequest,
|
|
22
|
+
ProviderStreamEvent,
|
|
23
|
+
dump_model,
|
|
24
|
+
get_native_meta,
|
|
25
|
+
load_image_block_payload,
|
|
26
|
+
tool_result_content_blocks,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Maps reasoning_effort values to extended thinking budget_tokens.
|
|
30
|
+
_THINKING_BUDGETS: dict[str, int] = {"low": 2048, "medium": 8192, "high": 24576, "xhigh": 32768}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AnthropicLikeAdapter(ProviderAdapter):
|
|
34
|
+
"""Shared Messages adapter for Anthropic-compatible providers.
|
|
35
|
+
|
|
36
|
+
Anthropic, Moonshot, and MiniMax all document agent usage around the
|
|
37
|
+
Anthropic Messages protocol. The differences we care about are limited to:
|
|
38
|
+
|
|
39
|
+
- default base URL
|
|
40
|
+
- API key env var names
|
|
41
|
+
- optional thinking defaults
|
|
42
|
+
- provider-native metadata carried in content blocks
|
|
43
|
+
|
|
44
|
+
MiniMax requires the full assistant content (all blocks) to be sent on
|
|
45
|
+
multi-turn tool-loop requests — not just the text portion.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def thinking_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
def output_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
def manual_thinking_config(self, effort: str | None) -> dict[str, Any] | None:
|
|
55
|
+
if not effort:
|
|
56
|
+
return None
|
|
57
|
+
if effort == "none":
|
|
58
|
+
return {"type": "disabled"}
|
|
59
|
+
budget = _THINKING_BUDGETS.get(effort)
|
|
60
|
+
return {"type": "enabled", "budget_tokens": budget} if budget else None
|
|
61
|
+
|
|
62
|
+
def _build_request_payload(self, request: ProviderRequest) -> dict[str, Any]:
|
|
63
|
+
messages = [self._serialize_message(message) for message in self.prepare_messages(request)]
|
|
64
|
+
self._apply_cache_control(messages)
|
|
65
|
+
|
|
66
|
+
payload: dict[str, Any] = {
|
|
67
|
+
"model": request.model,
|
|
68
|
+
"max_tokens": request.max_tokens,
|
|
69
|
+
"messages": messages,
|
|
70
|
+
}
|
|
71
|
+
if request.system:
|
|
72
|
+
payload["system"] = [
|
|
73
|
+
{
|
|
74
|
+
"type": "text",
|
|
75
|
+
"text": request.system,
|
|
76
|
+
"cache_control": {"type": "ephemeral"},
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
if request.tools:
|
|
80
|
+
payload["tools"] = [self._serialize_tool(tool) for tool in request.tools]
|
|
81
|
+
payload["tool_choice"] = {"type": "auto"}
|
|
82
|
+
thinking = self.thinking_config(request)
|
|
83
|
+
if thinking is not None:
|
|
84
|
+
payload["thinking"] = thinking
|
|
85
|
+
output_config = self.output_config(request)
|
|
86
|
+
if output_config is not None:
|
|
87
|
+
payload["output_config"] = output_config
|
|
88
|
+
return payload
|
|
89
|
+
|
|
90
|
+
def project_tool_call_id(self, tool_call_id: str, used_tool_call_ids: set[str]) -> str:
|
|
91
|
+
"""Return a short ASCII ID without introducing collisions.
|
|
92
|
+
|
|
93
|
+
Anthropic-compatible endpoints only accept IDs containing letters,
|
|
94
|
+
numbers, underscores, and dashes. When projection changes the original
|
|
95
|
+
ID, append a short hash so distinct canonical IDs stay distinct.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
safe_id = "".join(char if char.isalnum() or char in "_-" else "_" for char in tool_call_id)
|
|
99
|
+
if safe_id == tool_call_id and len(safe_id) <= 64 and safe_id not in used_tool_call_ids:
|
|
100
|
+
return safe_id
|
|
101
|
+
|
|
102
|
+
prefix = (safe_id or "tool")[:55]
|
|
103
|
+
digest = hashlib.sha1(tool_call_id.encode("utf-8")).hexdigest()[:8]
|
|
104
|
+
candidate = f"{prefix}_{digest}"
|
|
105
|
+
if candidate not in used_tool_call_ids:
|
|
106
|
+
return candidate
|
|
107
|
+
|
|
108
|
+
counter = 2
|
|
109
|
+
while True:
|
|
110
|
+
suffix = f"_{digest}_{counter}"
|
|
111
|
+
candidate = f"{(safe_id or 'tool')[: 64 - len(suffix)]}{suffix}"
|
|
112
|
+
if candidate not in used_tool_call_ids:
|
|
113
|
+
return candidate
|
|
114
|
+
counter += 1
|
|
115
|
+
|
|
116
|
+
def _apply_cache_control(self, messages: list[dict[str, Any]]) -> None:
|
|
117
|
+
"""Mark the last replayed user content block as ephemeral."""
|
|
118
|
+
|
|
119
|
+
for message in reversed(messages):
|
|
120
|
+
if message.get("role") != "user":
|
|
121
|
+
continue
|
|
122
|
+
|
|
123
|
+
content = message.get("content")
|
|
124
|
+
if not isinstance(content, list):
|
|
125
|
+
return
|
|
126
|
+
|
|
127
|
+
for block in reversed(content):
|
|
128
|
+
if not isinstance(block, dict):
|
|
129
|
+
continue
|
|
130
|
+
if block.get("type") not in {"text", "image", "tool_result"}:
|
|
131
|
+
continue
|
|
132
|
+
|
|
133
|
+
block["cache_control"] = {"type": "ephemeral"}
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
return
|
|
137
|
+
|
|
138
|
+
async def stream_turn(self, request: ProviderRequest) -> AsyncIterator[ProviderStreamEvent]:
|
|
139
|
+
api_key = self.require_api_key(request.api_key)
|
|
140
|
+
client = AsyncAnthropic(
|
|
141
|
+
api_key=api_key,
|
|
142
|
+
base_url=self.resolve_base_url(request.api_base),
|
|
143
|
+
timeout=DEFAULT_REQUEST_TIMEOUT,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
async with client.messages.stream(**self._build_request_payload(request)) as stream:
|
|
148
|
+
async for event in stream:
|
|
149
|
+
if event.type == "thinking" and event.thinking:
|
|
150
|
+
yield ProviderStreamEvent("thinking_delta", {"text": event.thinking})
|
|
151
|
+
continue
|
|
152
|
+
if event.type == "text" and event.text:
|
|
153
|
+
yield ProviderStreamEvent("text_delta", {"text": event.text})
|
|
154
|
+
|
|
155
|
+
final_message = await stream.get_final_message()
|
|
156
|
+
except APIError as exc:
|
|
157
|
+
raise ValueError(str(exc)) from exc
|
|
158
|
+
|
|
159
|
+
yield ProviderStreamEvent(
|
|
160
|
+
"message_done",
|
|
161
|
+
{
|
|
162
|
+
"message": self._convert_final_message(final_message),
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
def _convert_final_message(self, message: Any) -> ConversationMessage:
|
|
167
|
+
blocks = []
|
|
168
|
+
for block in getattr(message, "content", []) or []:
|
|
169
|
+
block_type = getattr(block, "type", None)
|
|
170
|
+
|
|
171
|
+
if block_type == "thinking":
|
|
172
|
+
native_meta = {}
|
|
173
|
+
signature = getattr(block, "signature", None)
|
|
174
|
+
if signature:
|
|
175
|
+
native_meta["signature"] = signature
|
|
176
|
+
blocks.append(
|
|
177
|
+
thinking_block(
|
|
178
|
+
getattr(block, "thinking", ""),
|
|
179
|
+
meta={"native": native_meta} if native_meta else None,
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
continue
|
|
183
|
+
|
|
184
|
+
if block_type == "text":
|
|
185
|
+
native_meta = {}
|
|
186
|
+
citations = getattr(block, "citations", None)
|
|
187
|
+
if citations:
|
|
188
|
+
native_meta["citations"] = dump_model(citations)
|
|
189
|
+
blocks.append(
|
|
190
|
+
text_block(getattr(block, "text", ""), meta={"native": native_meta} if native_meta else None)
|
|
191
|
+
)
|
|
192
|
+
continue
|
|
193
|
+
|
|
194
|
+
if block_type == "tool_use":
|
|
195
|
+
native_meta = {}
|
|
196
|
+
caller = getattr(block, "caller", None)
|
|
197
|
+
if caller is not None:
|
|
198
|
+
native_meta["caller"] = caller
|
|
199
|
+
blocks.append(
|
|
200
|
+
tool_use_block(
|
|
201
|
+
tool_id=getattr(block, "id", ""),
|
|
202
|
+
name=getattr(block, "name", ""),
|
|
203
|
+
input=getattr(block, "input", None),
|
|
204
|
+
meta={"native": native_meta} if native_meta else None,
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
continue
|
|
208
|
+
|
|
209
|
+
native_meta: dict[str, Any] = {}
|
|
210
|
+
if stop_sequence := getattr(message, "stop_sequence", None):
|
|
211
|
+
native_meta["stop_sequence"] = stop_sequence
|
|
212
|
+
if service_tier := getattr(message, "service_tier", None):
|
|
213
|
+
native_meta["service_tier"] = service_tier
|
|
214
|
+
return assistant_message(
|
|
215
|
+
blocks,
|
|
216
|
+
provider=self.provider_id,
|
|
217
|
+
model=getattr(message, "model", None),
|
|
218
|
+
provider_message_id=getattr(message, "id", None),
|
|
219
|
+
stop_reason=getattr(message, "stop_reason", None),
|
|
220
|
+
usage=dump_model(getattr(message, "usage", None)),
|
|
221
|
+
native_meta=native_meta,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
def _serialize_tool(self, tool: dict[str, Any]) -> dict[str, Any]:
|
|
225
|
+
return {
|
|
226
|
+
"name": tool.get("name") or "",
|
|
227
|
+
"description": tool.get("description") or "",
|
|
228
|
+
"input_schema": tool.get("input_schema") or {"type": "object", "properties": {}},
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
def _serialize_message(self, message: ConversationMessage) -> dict[str, Any]:
|
|
232
|
+
return {
|
|
233
|
+
"role": str(message.get("role") or "user"),
|
|
234
|
+
"content": [
|
|
235
|
+
self._serialize_block(block) for block in message.get("content") or [] if isinstance(block, dict)
|
|
236
|
+
],
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
def _serialize_block(self, block: dict[str, Any]) -> dict[str, Any]:
|
|
240
|
+
block_type = block.get("type")
|
|
241
|
+
|
|
242
|
+
if block_type == "text":
|
|
243
|
+
return {"type": "text", "text": str(block.get("text") or "")}
|
|
244
|
+
|
|
245
|
+
if block_type == "thinking":
|
|
246
|
+
native_meta = get_native_meta(block)
|
|
247
|
+
payload: dict[str, Any] = {
|
|
248
|
+
"type": "thinking",
|
|
249
|
+
"thinking": str(block.get("text") or ""),
|
|
250
|
+
}
|
|
251
|
+
if native_meta.get("signature"):
|
|
252
|
+
payload["signature"] = native_meta["signature"]
|
|
253
|
+
return payload
|
|
254
|
+
|
|
255
|
+
if block_type == "tool_use":
|
|
256
|
+
native_meta = get_native_meta(block)
|
|
257
|
+
payload = {
|
|
258
|
+
"type": "tool_use",
|
|
259
|
+
"id": block.get("id"),
|
|
260
|
+
"name": block.get("name"),
|
|
261
|
+
"input": block.get("input") if isinstance(block.get("input"), dict) else {},
|
|
262
|
+
}
|
|
263
|
+
if native_meta.get("caller") is not None:
|
|
264
|
+
payload["caller"] = native_meta["caller"]
|
|
265
|
+
return payload
|
|
266
|
+
|
|
267
|
+
if block_type == "image":
|
|
268
|
+
mime_type, data = load_image_block_payload(block)
|
|
269
|
+
return {
|
|
270
|
+
"type": "image",
|
|
271
|
+
"source": {"type": "base64", "media_type": mime_type, "data": data},
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if block_type == "tool_result":
|
|
275
|
+
content_blocks = []
|
|
276
|
+
for item in tool_result_content_blocks(block):
|
|
277
|
+
if item.get("type") == "text":
|
|
278
|
+
content_blocks.append({"type": "text", "text": str(item.get("text") or "")})
|
|
279
|
+
continue
|
|
280
|
+
if item.get("type") == "image":
|
|
281
|
+
mime_type, data = load_image_block_payload(item)
|
|
282
|
+
content_blocks.append(
|
|
283
|
+
{"type": "image", "source": {"type": "base64", "media_type": mime_type, "data": data}}
|
|
284
|
+
)
|
|
285
|
+
return {
|
|
286
|
+
"type": "tool_result",
|
|
287
|
+
"tool_use_id": block.get("tool_use_id"),
|
|
288
|
+
"content": content_blocks or str(block.get("model_text") or ""),
|
|
289
|
+
"is_error": bool(block.get("is_error")),
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return dict(block)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class AnthropicAdapter(AnthropicLikeAdapter):
|
|
296
|
+
provider_id = "anthropic"
|
|
297
|
+
label = "Anthropic"
|
|
298
|
+
default_base_url = "https://api.anthropic.com"
|
|
299
|
+
env_api_key_names = ("ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN")
|
|
300
|
+
default_models = ("claude-sonnet-4-6", "claude-opus-4-6")
|
|
301
|
+
supports_reasoning_effort = True
|
|
302
|
+
|
|
303
|
+
def thinking_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
304
|
+
effort = request.reasoning_effort
|
|
305
|
+
if not effort:
|
|
306
|
+
return None
|
|
307
|
+
if effort == "none":
|
|
308
|
+
return {"type": "disabled"}
|
|
309
|
+
normalized = request.model.lower()
|
|
310
|
+
if normalized.startswith("claude-sonnet-4-6") or normalized.startswith("claude-opus-4-6"):
|
|
311
|
+
return {"type": "adaptive"}
|
|
312
|
+
return self.manual_thinking_config(effort)
|
|
313
|
+
|
|
314
|
+
def output_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
315
|
+
effort = request.reasoning_effort
|
|
316
|
+
if not effort or effort == "none":
|
|
317
|
+
return None
|
|
318
|
+
|
|
319
|
+
normalized = request.model.lower()
|
|
320
|
+
if normalized.startswith("claude-sonnet-4-6"):
|
|
321
|
+
mapped_effort = "high" if effort == "xhigh" else effort
|
|
322
|
+
return {"effort": mapped_effort}
|
|
323
|
+
|
|
324
|
+
if normalized.startswith("claude-opus-4-6"):
|
|
325
|
+
mapped_effort = "max" if effort == "xhigh" else effort
|
|
326
|
+
return {"effort": mapped_effort}
|
|
327
|
+
|
|
328
|
+
return None
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class MoonshotAIAdapter(AnthropicLikeAdapter):
|
|
332
|
+
"""Moonshot's Anthropic-compatible Messages endpoint.
|
|
333
|
+
|
|
334
|
+
kimi-k2.5 tool loops work through this endpoint. When thinking is enabled,
|
|
335
|
+
prior reasoning blocks must be replayed in the conversation history —
|
|
336
|
+
Moonshot does not strip them on the server side.
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
provider_id = "moonshotai"
|
|
340
|
+
label = "Moonshot"
|
|
341
|
+
default_base_url = "https://api.moonshot.ai/anthropic"
|
|
342
|
+
env_api_key_names = ("MOONSHOT_API_KEY",)
|
|
343
|
+
default_models = ("kimi-k2.5",)
|
|
344
|
+
supports_reasoning_effort = True
|
|
345
|
+
|
|
346
|
+
def thinking_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
347
|
+
return self.manual_thinking_config(request.reasoning_effort)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class MiniMaxAdapter(AnthropicLikeAdapter):
|
|
351
|
+
"""MiniMax's Anthropic-compatible Messages endpoint.
|
|
352
|
+
|
|
353
|
+
MiniMax reasoning models emit thinking signatures on this endpoint;
|
|
354
|
+
signatures are preserved in block.meta.native and replayed via
|
|
355
|
+
_serialize_block so multi-turn tool loops stay valid.
|
|
356
|
+
"""
|
|
357
|
+
|
|
358
|
+
provider_id = "minimax"
|
|
359
|
+
label = "MiniMax"
|
|
360
|
+
default_base_url = "https://api.minimax.io/anthropic"
|
|
361
|
+
env_api_key_names = ("MINIMAX_API_KEY",)
|
|
362
|
+
default_models = ("MiniMax-M2.7", "MiniMax-M2.7-highspeed")
|
|
363
|
+
supports_reasoning_effort = True
|
|
364
|
+
|
|
365
|
+
def thinking_config(self, request: ProviderRequest) -> dict[str, Any] | None:
|
|
366
|
+
return self.manual_thinking_config(request.reasoning_effort)
|