@pheem49/mint 1.17.0 → 1.18.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/Cargo.lock +6 -6
- package/Cargo.toml +2 -2
- package/README.md +8 -2
- package/Release_Note.md +222 -71
- package/crates/mint-cli/src/agent/diff_render.rs +66 -44
- package/crates/mint-cli/src/agent/live_status.rs +21 -4
- package/crates/mint-cli/src/agent/markdown_render.rs +342 -5
- package/crates/mint-cli/src/agent.rs +25 -10
- package/crates/mint-cli/src/commands/agent.rs +4 -92
- package/crates/mint-cli/src/commands/browser.rs +2 -15
- package/crates/mint-cli/src/commands/integrations.rs +3 -3
- package/crates/mint-cli/src/commands/mod.rs +0 -3
- package/crates/mint-cli/src/commands/tailnet_web.rs +1 -0
- package/crates/mint-cli/src/interactive/chat_tui/dialog.rs +572 -0
- package/crates/mint-cli/src/interactive/chat_tui/mod.rs +1427 -0
- package/crates/mint-cli/src/interactive/chat_tui/render.rs +1524 -0
- package/crates/mint-cli/src/interactive/chat_tui/selection.rs +401 -0
- package/crates/mint-cli/src/interactive/chat_tui/state.rs +1833 -0
- package/crates/mint-cli/src/interactive/chat_tui/tests.rs +3414 -0
- package/crates/mint-cli/src/interactive/chat_tui/thought.rs +202 -0
- package/crates/mint-cli/src/interactive/chat_tui/transcript.rs +728 -0
- package/crates/mint-cli/src/interactive/chat_tui/watermark.rs +148 -0
- package/crates/mint-cli/src/interactive/command_ui.rs +53 -5
- package/crates/mint-cli/src/interactive/composer.rs +186 -0
- package/crates/mint-cli/src/interactive/format.rs +78 -3
- package/crates/mint-cli/src/interactive/input_box.rs +61 -1
- package/crates/mint-cli/src/interactive/resume_picker.rs +367 -25
- package/crates/mint-cli/src/interactive/slash_commands.rs +648 -371
- package/crates/mint-cli/src/interactive/tool_activity.rs +93 -20
- package/crates/mint-cli/src/interactive.rs +37 -0
- package/crates/mint-cli/src/main.rs +6 -3
- package/crates/mint-cli/src/markdown.rs +2 -37
- package/crates/mint-cli/src/onboard.rs +700 -282
- package/crates/mint-cli/src/setup.rs +1342 -624
- package/crates/mint-cli/src/terminal_theme.rs +159 -35
- package/crates/mint-cli/tests/library_intake.rs +1 -0
- package/crates/mint-core/src/agent/chat/anthropic.rs +318 -0
- package/crates/mint-core/src/agent/chat/custom.rs +149 -0
- package/crates/mint-core/src/agent/chat/gemini.rs +518 -0
- package/crates/mint-core/src/agent/chat/mod.rs +857 -0
- package/crates/mint-core/src/agent/chat/ollama.rs +321 -0
- package/crates/mint-core/src/agent/chat/openai.rs +582 -0
- package/crates/mint-core/src/agent/chat/streaming.rs +469 -0
- package/crates/mint-core/src/agent/chat/tests.rs +1479 -0
- package/crates/mint-core/src/agent/memory.rs +56 -2
- package/crates/mint-core/src/agent/tasks.rs +2 -2
- package/crates/mint-core/src/api_server/routes/chat.rs +24 -2
- package/crates/mint-core/src/api_server/routes/gemini_live.rs +14 -1
- package/crates/mint-core/src/api_server/routes/html_preview.rs +1 -8
- package/crates/mint-core/src/api_server/routes/sessions.rs +21 -0
- package/crates/mint-core/src/avatar_bridge.rs +0 -22
- package/crates/mint-core/src/browser/cdp.rs +10 -4
- package/crates/mint-core/src/browser/headless.rs +582 -0
- package/crates/mint-core/src/browser/input.rs +7 -62
- package/crates/mint-core/src/browser/interact.rs +0 -14
- package/crates/mint-core/src/browser/mod.rs +8 -29
- package/crates/mint-core/src/browser/navigate.rs +2 -36
- package/crates/mint-core/src/browser/runtime.rs +2 -4
- package/crates/mint-core/src/browser/session.rs +50 -466
- package/crates/mint-core/src/browser/workflow.rs +142 -32
- package/crates/mint-core/src/cron/store.rs +2 -2
- package/crates/mint-core/src/integrations/mcp.rs +6 -8
- package/crates/mint-core/src/lib.rs +0 -5
- package/crates/mint-core/src/media/gemini_live.rs +636 -86
- package/crates/mint-core/src/media/library/migration.rs +26 -0
- package/crates/mint-core/src/media/library/tests.rs +1 -1
- package/crates/mint-core/src/media/library/thumbnails.rs +8 -2
- package/crates/mint-core/src/media/pictures.rs +1 -1
- package/crates/mint-core/src/media/tool_images.rs +92 -1
- package/crates/mint-core/src/mods/manager.rs +101 -35
- package/crates/mint-core/src/orchestration/context_render.rs +441 -24
- package/crates/mint-core/src/orchestration/decision_parsing.rs +531 -16
- package/crates/mint-core/src/orchestration/full_skill_result_tests.rs +12 -0
- package/crates/mint-core/src/orchestration/loop_guard.rs +145 -0
- package/crates/mint-core/src/orchestration/mcp_outcome_tests.rs +864 -0
- package/crates/mint-core/src/orchestration/memory_skill.rs +88 -28
- package/crates/mint-core/src/orchestration/mod.rs +320 -4249
- package/crates/mint-core/src/orchestration/reliability.rs +67 -27
- package/crates/mint-core/src/orchestration/review_regressions.rs +5 -0
- package/crates/mint-core/src/orchestration/tests.rs +1665 -0
- package/crates/mint-core/src/orchestration/tools/dispatch.rs +967 -0
- package/crates/mint-core/src/orchestration/tools/files.rs +1 -0
- package/crates/mint-core/src/orchestration/tools/mod.rs +5 -1
- package/crates/mint-core/src/orchestration/tools/planning.rs +102 -42
- package/crates/mint-core/src/orchestration/tools/shell.rs +129 -58
- package/crates/mint-core/src/orchestration/truncation.rs +170 -13
- package/crates/mint-core/src/orchestration/types.rs +648 -0
- package/crates/mint-core/src/orchestration/verification.rs +0 -3
- package/crates/mint-core/src/orchestration/workspace_helpers.rs +24 -6
- package/crates/mint-core/src/prompts/agent.rs +52 -76
- package/crates/mint-core/src/prompts/tool_catalog.rs +8 -151
- package/crates/mint-core/src/search/files.rs +20 -0
- package/crates/mint-core/src/slash/mod.rs +228 -265
- package/crates/mint-core/src/slash/models.rs +6 -1
- package/crates/mint-core/src/system/bg_shell.rs +1 -0
- package/crates/mint-core/src/system/config.rs +176 -34
- package/crates/mint-mod-runtime/src/lib.rs +37 -23
- package/out/web/assets/ArtifactPreviewPanel-Cx6BVOOF.js +2 -0
- package/out/web/assets/CalculationCard-D2E74u5q.js +1 -0
- package/out/web/assets/CliSessionsView-ZbdtSjvK.css +1 -0
- package/out/web/assets/{CliSessionsView-MI8kXMAb.js → CliSessionsView-z5i6qGyb.js} +1 -1
- package/out/web/assets/CodeReviewPage-BK2bOScd.css +1 -0
- package/out/web/assets/CodeReviewPage-Dp6zHuHu.js +2 -0
- package/out/web/assets/{CommandPalette-BD8SlTE5.js → CommandPalette-DaKlzbKs.js} +1 -1
- package/out/web/assets/ImageGenCard-BMCJHP9O.js +1 -0
- package/out/web/assets/ImageSearchCard-Cld_SOUg.js +1 -0
- package/out/web/assets/{ImageStudioPanel-BP7N4rLr.js → ImageStudioPanel-B5N7TjeB.js} +1 -1
- package/out/web/assets/LibraryPage-CMB89rJ0.css +1 -0
- package/out/web/assets/LibraryPage-DbZEi4W_.js +2 -0
- package/out/web/assets/LinkedFoldersView-9B9DIPoZ.js +1 -0
- package/out/web/assets/{McpRegistryPicker-CoS83vtc.js → McpRegistryPicker-DnXPlzI7.js} +1 -1
- package/out/web/assets/McpServersView-CiNBNUl4.js +1 -0
- package/out/web/assets/MermaidCard-BBDNEXbY.js +2 -0
- package/out/web/assets/MintDashboard-C_UYPoNV.js +119 -0
- package/out/web/assets/MintDashboard-DTd8C_c8.css +1 -0
- package/out/web/assets/PlanCard-C2x5pajq.js +1 -0
- package/out/web/assets/{PluginsView-jBYmcKh4.js → PluginsView-DoTg9MVa.js} +1 -1
- package/out/web/assets/RewindModal-B5oowrR0.js +1 -0
- package/out/web/assets/{ScheduledTasksView-5uw9-V9H.js → ScheduledTasksView-BD5DVPkZ.js} +1 -1
- package/out/web/assets/{SelectField-DXBQtrUK.js → SelectField-Cy6CghrU.js} +1 -1
- package/out/web/assets/SettingsWindow-BYl_oCFh.js +4 -0
- package/out/web/assets/SettingsWindow-Ckcgnjt8.css +1 -0
- package/out/web/assets/{SkillsView-C-gp9J7m.js → SkillsView-CIeWwq5z.js} +1 -1
- package/out/web/assets/StockCard-DxUciKyp.js +1 -0
- package/out/web/assets/ToolSurfacePage-qBgs_VHq.css +1 -0
- package/out/web/assets/ToolSurfacePage-saVbVrkE.js +38 -0
- package/out/web/assets/{UiFeatureCard-6BwxTOCe.js → UiFeatureCard-CdY0hGWy.js} +1 -1
- package/out/web/assets/{UiGridCard-DvZcLNxb.js → UiGridCard-BBK3I5hC.js} +1 -1
- package/out/web/assets/UiMockupWidget-CpR9EDuc.js +1 -0
- package/out/web/assets/{VeoStudioPanel-DOj7_WR3.css → VeoStudioPanel-9kU9YLEN.css} +1 -1
- package/out/web/assets/{VeoStudioPanel-DfsOJKv0.js → VeoStudioPanel-Co6-wEWM.js} +2 -2
- package/out/web/assets/WeatherCard-Buzi7Vfu.js +1 -0
- package/out/web/assets/WorkspacePdfPreview-Bi8Zzyir.js +2 -0
- package/out/web/assets/{abnfDiagram-VCTEODGH-BOo3Ckng.js → abnfDiagram-VCTEODGH-CMfR95N2.js} +1 -1
- package/out/web/assets/{architecture-7GRP2DOG-ZOwheW3n.js → architecture-7GRP2DOG-DhAM4HyO.js} +1 -1
- package/out/web/assets/{architectureDiagram-5GKGNRK7-DC2FDzVd.js → architectureDiagram-5GKGNRK7-Yk3TUJ_F.js} +1 -1
- package/out/web/assets/{blockDiagram-I7D4REHJ-BrKFWdAH.js → blockDiagram-I7D4REHJ-X9fBgJik.js} +1 -1
- package/out/web/assets/{c4Diagram-7LVT6UL2-BHTHK1Yd.js → c4Diagram-7LVT6UL2-Bk9x7N-8.js} +1 -1
- package/out/web/assets/{chunk-4HAMMTFA-BYFkZwNj.js → chunk-4HAMMTFA-Dx5fk1_0.js} +1 -1
- package/out/web/assets/{chunk-75Z2AOVW-BSKfSKSA.js → chunk-75Z2AOVW-BszTQoM4.js} +1 -1
- package/out/web/assets/{chunk-DU6HZSFF-vIhsiW6n.js → chunk-DU6HZSFF-DK-As3rk.js} +1 -1
- package/out/web/assets/{chunk-F27PBJKO-BlYpW9xq.js → chunk-F27PBJKO-LmncZZIS.js} +1 -1
- package/out/web/assets/{chunk-GMAD6QVW-BIBz_Ug5.js → chunk-GMAD6QVW-DSQ_sDRJ.js} +1 -1
- package/out/web/assets/{chunk-GVQU2GXP-NPSHxeqC.js → chunk-GVQU2GXP-Cno3ulje.js} +1 -1
- package/out/web/assets/{chunk-IMKFNOWR-YlJK8_Fp.js → chunk-IMKFNOWR-bIzfY9Jc.js} +1 -1
- package/out/web/assets/{chunk-L3NEJ4N5-DMYi4-af.js → chunk-L3NEJ4N5-Dl6eOa0D.js} +1 -1
- package/out/web/assets/{chunk-OSK3NFVY-Begd3-jA.js → chunk-OSK3NFVY-BaUGJ-cM.js} +1 -1
- package/out/web/assets/{chunk-P2QGCYS3-D1I4xFHN.js → chunk-P2QGCYS3-_066ndhH.js} +1 -1
- package/out/web/assets/{chunk-POPQ4Y6H-CafZZzNE.js → chunk-POPQ4Y6H-YT1AKhTv.js} +1 -1
- package/out/web/assets/{chunk-PWAF6VOD-Dwh6_Lnt.js → chunk-PWAF6VOD-CrEgDsxh.js} +1 -1
- package/out/web/assets/{chunk-SHT3W25Y-B0XrCSEb.js → chunk-SHT3W25Y-_KwaRLOl.js} +1 -1
- package/out/web/assets/{chunk-SVP7TREG-CxLsddxC.js → chunk-SVP7TREG-BQ1qb32L.js} +1 -1
- package/out/web/assets/{chunk-TICWLB2K-y156QInb.js → chunk-TICWLB2K-BDyehCtg.js} +1 -1
- package/out/web/assets/classDiagram-ZZMXUADV-BoSpzRCJ.js +1 -0
- package/out/web/assets/classDiagram-v2-VYDZK3BY-BoSpzRCJ.js +1 -0
- package/out/web/assets/{config-DqXJXeZM.css → config-2suVFPZg.css} +1 -1
- package/out/web/assets/config-CkRCdkxn.js +2 -0
- package/out/web/assets/{cynefin-OW5HDTMX-SMVvrLf-.js → cynefin-OW5HDTMX-Dl_31aaN.js} +1 -1
- package/out/web/assets/{cynefinDiagram-5FMLGOSQ-rZznN24T.js → cynefinDiagram-5FMLGOSQ-Bpir8jha.js} +1 -1
- package/out/web/assets/{dagre-GXQ25YYZ-BOToydFu.js → dagre-GXQ25YYZ-D9xu3nsq.js} +1 -1
- package/out/web/assets/{diagram-S7CK7UJ4-TMVaGQEJ.js → diagram-S7CK7UJ4-DeveoEeB.js} +1 -1
- package/out/web/assets/{diagram-UQ7AKVKN-C2JK-GP2.js → diagram-UQ7AKVKN-p4xWRESV.js} +1 -1
- package/out/web/assets/{diagram-VSXAHHWV-Cw8VSi2K.js → diagram-VSXAHHWV-C7qz9NDF.js} +1 -1
- package/out/web/assets/{diagram-VX7I27RA-DXp4fKk9.js → diagram-VX7I27RA-DRiCa3Vd.js} +1 -1
- package/out/web/assets/{diagram-Z3DM3KII-CzSicYiW.js → diagram-Z3DM3KII-Bt7zduQX.js} +1 -1
- package/out/web/assets/{ebnfDiagram-PWID7BFC-Dqj-zqPu.js → ebnfDiagram-PWID7BFC-DV9WpwdR.js} +1 -1
- package/out/web/assets/{erDiagram-RLTQ6QDP-DZwFZAuD.js → erDiagram-RLTQ6QDP-BJ_nwG2m.js} +1 -1
- package/out/web/assets/{eventmodeling-NTZA5JFV-C0O-Lvgp.js → eventmodeling-NTZA5JFV-BTBMrfVa.js} +1 -1
- package/out/web/assets/flowDiagram-HODETNUW-Cdlq3cJL.js +1 -0
- package/out/web/assets/{ganttDiagram-EL5Y4UJY-Da4ULXTl.js → ganttDiagram-EL5Y4UJY-DQLdsXrC.js} +1 -1
- package/out/web/assets/{gitGraph-4MIJSDKK-B9wNFZIP.js → gitGraph-4MIJSDKK-CL1OEOQ_.js} +1 -1
- package/out/web/assets/{gitGraphDiagram-WWUBYQGX-RjrhB0MP.js → gitGraphDiagram-WWUBYQGX-8cSi42H7.js} +1 -1
- package/out/web/assets/index-BocxnrDG.js +168 -0
- package/out/web/assets/index-yeh_r55a.css +1 -0
- package/out/web/assets/{info-A6RAGUB7-B3dfCpeY.js → info-A6RAGUB7-C1zsX5sc.js} +1 -1
- package/out/web/assets/{infoDiagram-27XIBGKW-QVWkLVx7.js → infoDiagram-27XIBGKW-DsRYtIyI.js} +1 -1
- package/out/web/assets/{ishikawaDiagram-5VMMS53U-CLFNIRI9.js → ishikawaDiagram-5VMMS53U-B2crwIXj.js} +1 -1
- package/out/web/assets/{journeyDiagram-3NMN7TZE-fgOQadYF.js → journeyDiagram-3NMN7TZE-BTH-GyVR.js} +1 -1
- package/out/web/assets/{kanban-definition-UXKFOSKX-G3Q_9g9O.js → kanban-definition-UXKFOSKX-BeRfCnuA.js} +1 -1
- package/out/web/assets/{mermaid-parser.core-v3Jm7nco.js → mermaid-parser.core-BJwgCBBc.js} +3 -3
- package/out/web/assets/{mermaid.core-DTEjLUA1.js → mermaid.core-CsDDodN8.js} +4 -4
- package/out/web/assets/{mindmap-definition-YA3MSWOX-C_D42_fF.js → mindmap-definition-YA3MSWOX-B42efOQ1.js} +1 -1
- package/out/web/assets/{modelManager-BPLycQrN.js → modelManager-B3ZFMh8v.js} +2 -2
- package/out/web/assets/{oauthManager-BUK7ic7q.js → oauthManager-Ch5Du2fF.js} +1 -1
- package/out/web/assets/{packet-AYTQ26CC-B-R-SHlF.js → packet-AYTQ26CC-B6xUyE6r.js} +1 -1
- package/out/web/assets/{pegDiagram-XKGWAZYB-Da2q_giz.js → pegDiagram-XKGWAZYB-1LabVycL.js} +1 -1
- package/out/web/assets/{pie-WAS4IAKB-BC8F0N7-.js → pie-WAS4IAKB-DJwo-nf_.js} +1 -1
- package/out/web/assets/{pieDiagram-E7YTZNPT-Iy9REJNC.js → pieDiagram-E7YTZNPT-icmAqzy4.js} +1 -1
- package/out/web/assets/{quadrantDiagram-AXDQQJYC-ztsiYw7h.js → quadrantDiagram-AXDQQJYC-CZ-wEx41.js} +1 -1
- package/out/web/assets/{radar-RG4KPBEZ-B_1P8Z_z.js → radar-RG4KPBEZ-D7d-Xriw.js} +1 -1
- package/out/web/assets/{railroad-74A4TZTK-DuTqczSo.js → railroad-74A4TZTK-viuhdYbs.js} +1 -1
- package/out/web/assets/{railroad-abnf-HS5TGJTU-Df29WLmp.js → railroad-abnf-HS5TGJTU-DNXiCNea.js} +1 -1
- package/out/web/assets/{railroad-ebnf-LZEXJU2U-ePFMo-qp.js → railroad-ebnf-LZEXJU2U-nkSu1-0C.js} +1 -1
- package/out/web/assets/{railroad-peg-WCYAUIDC-DYXLW4_E.js → railroad-peg-WCYAUIDC-BhbMeQzz.js} +1 -1
- package/out/web/assets/{railroadDiagram-O6MQD6OU-LStnZf2S.js → railroadDiagram-O6MQD6OU-CLpG1jUX.js} +1 -1
- package/out/web/assets/{requirementDiagram-BXWQKSXE-DmzonMH-.js → requirementDiagram-BXWQKSXE-kRDrvWrc.js} +1 -1
- package/out/web/assets/{sankeyDiagram-P5KCCOFB-B8vjmUU1.js → sankeyDiagram-P5KCCOFB-DxAwmq4x.js} +1 -1
- package/out/web/assets/{sequenceDiagram-WJ2MYXX4-CTnplOAX.js → sequenceDiagram-WJ2MYXX4-aLgY-6Wz.js} +1 -1
- package/out/web/assets/{stateDiagram-D77RDMKH-BFrIaLdI.js → stateDiagram-D77RDMKH-D5QWfOhp.js} +1 -1
- package/out/web/assets/stateDiagram-v2-MP3YSRHH-D6OiZoAP.js +1 -0
- package/out/web/assets/{swimlanes-42K2YHIH-BXGngUNU.js → swimlanes-42K2YHIH-CRs5UyA-.js} +1 -1
- package/out/web/assets/swimlanesDiagram-VR7AAH4N-UgEXIsV0.js +8 -0
- package/out/web/assets/syntaxHighlight-C-wAGT84.js +3 -0
- package/out/web/assets/{timeline-definition-24CTP7MA-CegH7n43.js → timeline-definition-24CTP7MA-Denqd9qb.js} +1 -1
- package/out/web/assets/{treeView-Q6P3EWNA-DTpJv2Tw.js → treeView-Q6P3EWNA-0my3Z3s4.js} +1 -1
- package/out/web/assets/{treemap-WGGIJYW6-i8M9iJU6.js → treemap-WGGIJYW6-B_EjkLYq.js} +1 -1
- package/out/web/assets/{vennDiagram-4TSXK5OY-Dpzo1S8U.js → vennDiagram-4TSXK5OY-DxVg3Ewr.js} +1 -1
- package/out/web/assets/{wardley-WFR3VGLG-BrNsgtfw.js → wardley-WFR3VGLG-CGD-Tj4p.js} +1 -1
- package/out/web/assets/{wardleyDiagram-VM6X3IG4-lQ92LFE1.js → wardleyDiagram-VM6X3IG4-CmfS39Xm.js} +1 -1
- package/out/web/assets/{xychartDiagram-S5SC5T6Z-BaOaEoBd.js → xychartDiagram-S5SC5T6Z-BVM9bKis.js} +1 -1
- package/out/web/index-web.html +2 -2
- package/out/web/index.html +2 -2
- package/package.json +2 -2
- package/shared-modules/CODEOWNERS +3 -3
- package/shared-modules/SDL2/SDL2_mixer.json +27 -0
- package/shared-modules/appstream/README.md +13 -0
- package/shared-modules/appstream/appstream-compose.json +111 -0
- package/shared-modules/dbus-glib/dbus-glib.json +2 -2
- package/shared-modules/libportal/libportal.json +23 -0
- package/shared-modules/linux-audio/fluidsynth2-static.json +2 -2
- package/shared-modules/linux-audio/fluidsynth2.json +2 -2
- package/shared-modules/linux-audio/libinstpatch.json +2 -2
- package/shared-modules/linux-audio/liblo-static.json +3 -0
- package/shared-modules/luajit/luajit.json +2 -2
- package/shared-modules/squashfs-tools/squashfs-tools.json +0 -3
- package/slash-commands.json +7 -2
- package/src/renderer/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/renderer/shared/agentProgress.ts +51 -3
- package/src/renderer/shared/components/Settings/AutomationTab.tsx +2 -56
- package/src/renderer/shared/components/Settings/AvatarCropModal.tsx +15 -1
- package/src/renderer/shared/components/Settings/GeneralTab.tsx +25 -12
- package/src/renderer/shared/components/Settings/ThemeTab.test.tsx +45 -0
- package/src/renderer/shared/components/Settings/ThemeTab.tsx +106 -3
- package/src/renderer/shared/components/activity/AgentActivityDrawer.tsx +67 -17
- package/src/renderer/shared/components/activity/AgentActivityTable.tsx +376 -134
- package/src/renderer/shared/components/activity/AskUserActivityCard.test.tsx +122 -0
- package/src/renderer/shared/components/activity/AskUserActivityCard.tsx +70 -0
- package/src/renderer/shared/components/activity/McpToolResults.tsx +39 -2
- package/src/renderer/shared/components/activity/SubagentDagView.tsx +7 -7
- package/src/renderer/shared/components/activity/ViewedImages.tsx +41 -2
- package/src/renderer/shared/components/app/ChunkErrorBoundary.tsx +3 -3
- package/src/renderer/shared/components/app/CommandPalette.tsx +7 -7
- package/src/renderer/shared/components/app/DesktopTitlebar.tsx +2 -2
- package/src/renderer/shared/components/app/MintDashboard.tsx +27 -17
- package/src/renderer/shared/components/app/ModalErrorBoundary.tsx +3 -3
- package/src/renderer/shared/components/cards/CalculationCard.tsx +3 -3
- package/src/renderer/shared/components/cards/ImageGenCard.tsx +2 -2
- package/src/renderer/shared/components/cards/ImageSearchCard.tsx +2 -2
- package/src/renderer/shared/components/cards/MermaidCard.tsx +1 -1
- package/src/renderer/shared/components/cards/PlanCard.test.tsx +41 -0
- package/src/renderer/shared/components/cards/PlanCard.tsx +32 -0
- package/src/renderer/shared/components/cards/ReleaseNotesCard.test.tsx +29 -0
- package/src/renderer/shared/components/cards/ReleaseNotesCard.tsx +137 -0
- package/src/renderer/shared/components/cards/StockCard.tsx +7 -7
- package/src/renderer/shared/components/cards/ToolResultCards.tsx +11 -3
- package/src/renderer/shared/components/cards/UiMockupWidget.tsx +4 -4
- package/src/renderer/shared/components/cards/WeatherCard.tsx +5 -5
- package/src/renderer/shared/components/chat/ApprovalCard.test.tsx +11 -0
- package/src/renderer/shared/components/chat/ApprovalCard.tsx +21 -2
- package/src/renderer/shared/components/chat/ArtifactCards.test.tsx +69 -0
- package/src/renderer/shared/components/chat/ArtifactCards.tsx +238 -0
- package/src/renderer/shared/components/chat/AttachedDocumentCard.test.tsx +39 -0
- package/src/renderer/shared/components/chat/AttachedDocumentCard.tsx +220 -0
- package/src/renderer/shared/components/chat/ChatCodeBlock.test.tsx +33 -0
- package/src/renderer/shared/components/chat/ChatCodeBlock.tsx +15 -1
- package/src/renderer/shared/components/chat/ChatMessageItem.test.tsx +40 -2
- package/src/renderer/shared/components/chat/ChatMessageItem.tsx +180 -34
- package/src/renderer/shared/components/chat/ChatModeSelector.css +227 -0
- package/src/renderer/shared/components/chat/ChatModeSelector.test.tsx +45 -0
- package/src/renderer/shared/components/chat/ChatModeSelector.tsx +198 -0
- package/src/renderer/shared/components/chat/ChatPanel.test.tsx +22 -0
- package/src/renderer/shared/components/chat/ChatPanel.tsx +227 -53
- package/src/renderer/shared/components/chat/DiffReviewModal.tsx +6 -6
- package/src/renderer/shared/components/chat/GeminiLiveOverlay.test.tsx +142 -1
- package/src/renderer/shared/components/chat/GeminiLiveOverlay.tsx +45 -3
- package/src/renderer/shared/components/chat/ModelSelectorPopover.tsx +42 -14
- package/src/renderer/shared/components/chat/RewindModal.tsx +10 -10
- package/src/renderer/shared/components/chat/SlashSuggestions.test.tsx +14 -0
- package/src/renderer/shared/components/chat/SourcesBlock.test.tsx +53 -0
- package/src/renderer/shared/components/chat/SourcesBlock.tsx +236 -90
- package/src/renderer/shared/components/chat/TurnFileChanges.test.tsx +45 -1
- package/src/renderer/shared/components/chat/TurnFileChanges.tsx +202 -169
- package/src/renderer/shared/components/extensions/CliSessionsView.tsx +5 -4
- package/src/renderer/shared/components/extensions/McpRegistryPicker.tsx +3 -3
- package/src/renderer/shared/components/studio/LibraryPage.tsx +48 -5
- package/src/renderer/shared/components/workspace/ArtifactPreviewPanel.tsx +125 -13
- package/src/renderer/shared/components/workspace/CodeReviewPage.test.tsx +50 -0
- package/src/renderer/shared/components/workspace/CodeReviewPage.tsx +77 -16
- package/src/renderer/shared/components/workspace/GitBranchSelector.tsx +78 -22
- package/src/renderer/shared/components/workspace/ToolSurfacePage.test.tsx +13 -0
- package/src/renderer/shared/components/workspace/ToolSurfacePage.tsx +48 -28
- package/src/renderer/shared/components/workspace/WorkspacePdfPreview.tsx +266 -47
- package/src/renderer/shared/components/workspace/WorkspacePreviewActions.test.tsx +18 -6
- package/src/renderer/shared/components/workspace/background-terminals.css +11 -11
- package/src/renderer/shared/constants/config.ts +1 -5
- package/src/renderer/shared/constants/models.test.ts +51 -0
- package/src/renderer/shared/constants/models.ts +139 -32
- package/src/renderer/shared/conversation/lifecycle.test.ts +91 -3
- package/src/renderer/shared/conversation/lifecycle.ts +104 -5
- package/src/renderer/shared/conversation/progressiveStream.test.ts +83 -0
- package/src/renderer/shared/conversation/progressiveStream.ts +219 -0
- package/src/renderer/shared/css/agent-observability.css +133 -0
- package/src/renderer/shared/css/chat-ui-cards.css +13 -13
- package/src/renderer/shared/css/code-review.css +63 -34
- package/src/renderer/shared/css/code-sessions.css +47 -18
- package/src/renderer/shared/css/collapsed-paste.css +1 -1
- package/src/renderer/shared/css/error-notice.css +1 -1
- package/src/renderer/shared/css/file-changes.css +165 -80
- package/src/renderer/shared/css/library.css +105 -10
- package/src/renderer/shared/css/management-views.css +1 -1
- package/src/renderer/shared/css/mcp-results.css +5 -5
- package/src/renderer/shared/css/model-selector.css +18 -18
- package/src/renderer/shared/css/mods.css +7 -7
- package/src/renderer/shared/css/notification-notice.css +2 -2
- package/src/renderer/shared/css/queued-messages.css +5 -5
- package/src/renderer/shared/css/settings/general.css +18 -13
- package/src/renderer/shared/css/settings/profile.css +5 -5
- package/src/renderer/shared/css/settings/theme.css +5 -5
- package/src/renderer/shared/css/slash-choice.css +2 -2
- package/src/renderer/shared/css/slash-suggestions.css +3 -3
- package/src/renderer/shared/css/sources-block.css +41 -2
- package/src/renderer/shared/css/tools-panel.css +2 -2
- package/src/renderer/shared/css/ui-tailwind.css +8 -0
- package/src/renderer/shared/css/veo-studio.css +2 -2
- package/src/renderer/shared/css/viewed-images.css +7 -7
- package/src/renderer/shared/platform.ts +2 -1
- package/src/renderer/shared/theme/themeManager.test.ts +17 -0
- package/src/renderer/shared/theme/themeManager.ts +21 -4
- package/src/renderer/shared/theme/themes.ts +54 -0
- package/src/renderer/shared/theme/tokens.css +6 -4
- package/src/renderer/shared/types.ts +1 -1
- package/src/renderer/shared/utils/agentActivity.test.ts +468 -2
- package/src/renderer/shared/utils/agentActivity.ts +602 -35
- package/src/renderer/shared/utils/artifactBrowser.test.ts +37 -32
- package/src/renderer/shared/utils/artifactBrowser.ts +17 -19
- package/src/renderer/shared/utils/attachedDocument.test.ts +73 -0
- package/src/renderer/shared/utils/attachedDocument.ts +49 -0
- package/src/renderer/shared/utils/fileIcons.test.ts +59 -0
- package/src/renderer/shared/utils/fileIcons.ts +149 -16
- package/src/renderer/shared/utils/markdown.tsx +72 -19
- package/src/renderer/shared/utils/markdown.webImages.test.tsx +16 -0
- package/src/renderer/shared/utils/mcpResults.test.tsx +29 -0
- package/src/renderer/shared/utils/slashCommandProcessor.ts +4 -1
- package/src/renderer/shared/utils/syntaxHighlight.test.tsx +11 -1
- package/src/renderer/shared/utils/syntaxHighlight.tsx +51 -3
- package/src/renderer/shared/utils/useGeminiLiveVoice.ts +324 -51
- package/src/renderer/shared/utils/workspaceDrag.test.ts +153 -0
- package/src/renderer/shared/utils/workspaceDrag.ts +142 -0
- package/src/renderer/shared/utils/workspaceMedia.ts +10 -2
- package/src/renderer/src/App.tsx +14 -8
- package/src/renderer/src/agentProgress.ts +1 -0
- package/src/renderer/src/components/ScreenPicker.css +1 -1
- package/src/renderer/src/components/WorkspacePanel.tsx +6 -5
- package/src/renderer/src/css/app-shell.css +4 -4
- package/src/renderer/src/css/chat.css +1261 -241
- package/src/renderer/src/css/desktop-tools.css +11 -11
- package/src/renderer/src/css/sidebar-workspace.css +2 -2
- package/src/renderer/src/css/tool-surfaces.css +12 -12
- package/src/renderer/src/index.css +38 -20
- package/src/renderer/src/tauri.ts +22 -2
- package/src/renderer/src-web/App.tsx +14 -0
- package/src/renderer/src-web/agentProgress.ts +1 -0
- package/src/renderer/src-web/css/app-shell.css +4 -4
- package/src/renderer/src-web/css/chat.css +1278 -190
- package/src/renderer/src-web/css/mobile.css +29 -13
- package/src/renderer/src-web/css/settings/mobile.css +2 -2
- package/src/renderer/src-web/css/sidebar-workspace.css +1 -1
- package/src/renderer/src-web/index.css +38 -20
- package/src/renderer/src-web/tauri.ts +22 -2
- package/src/renderer/tests/browserArtifacts.browser.tsx +1 -1
- package/src/renderer/tests/library.browser.tsx +3 -0
- package/src/renderer/tests/liveVoice.browser.html +1 -0
- package/src/renderer/tests/workspaceDrop.browser.tsx +1 -1
- package/src-tauri/src/app/lifecycle.rs +1 -14
- package/src-tauri/src/background/headless.rs +14 -8
- package/src-tauri/src/commands/conversation.rs +38 -0
- package/src-tauri/src/native/mod.rs +0 -1
- package/src-tauri/src/native/system.rs +4 -47
- package/crates/mint-cli/src/interactive/chat_tui.rs +0 -8855
- package/crates/mint-core/src/agent/chat.rs +0 -4394
- package/crates/mint-core/src/browser/lifecycle.rs +0 -291
- package/crates/mint-core/src/browser/logging.rs +0 -20
- package/crates/mint-core/src/orchestration/tools/browser.rs +0 -31
- package/out/web/assets/ArtifactPreviewPanel-S0dPfYFx.js +0 -2
- package/out/web/assets/CalculationCard-CRjP3E1j.js +0 -1
- package/out/web/assets/CliSessionsView-C3Br2v5Y.css +0 -1
- package/out/web/assets/CodeReviewPage-CUJceQme.css +0 -1
- package/out/web/assets/CodeReviewPage-VCUgPla_.js +0 -2
- package/out/web/assets/ImageGenCard-BCXxkVJX.js +0 -1
- package/out/web/assets/ImageSearchCard-N3yQOr8Z.js +0 -1
- package/out/web/assets/LibraryPage-DAxUTAg7.css +0 -1
- package/out/web/assets/LibraryPage-WlviRdR8.js +0 -2
- package/out/web/assets/LinkedFoldersView-CKRgroWK.js +0 -1
- package/out/web/assets/McpServersView-D3wHnuHg.js +0 -1
- package/out/web/assets/MermaidCard-NqrHdyJW.js +0 -2
- package/out/web/assets/MintDashboard-B2DJsDDO.css +0 -1
- package/out/web/assets/MintDashboard-COw_xol7.js +0 -63
- package/out/web/assets/RewindModal-DempuDod.js +0 -1
- package/out/web/assets/SettingsWindow-2YP3yj7s.js +0 -4
- package/out/web/assets/SettingsWindow-Dz8LQVgD.css +0 -1
- package/out/web/assets/StockCard-BDMCe7mx.js +0 -1
- package/out/web/assets/ToolSurfacePage-B0J_q0Jl.js +0 -38
- package/out/web/assets/ToolSurfacePage-CRIQ1owD.css +0 -1
- package/out/web/assets/UiMockupWidget-DD73QWg1.js +0 -1
- package/out/web/assets/WeatherCard-CPucIfq8.js +0 -1
- package/out/web/assets/WorkspacePdfPreview-Dx_lkjNu.js +0 -2
- package/out/web/assets/classDiagram-ZZMXUADV-BgJ5WtSp.js +0 -1
- package/out/web/assets/classDiagram-v2-VYDZK3BY-BgJ5WtSp.js +0 -1
- package/out/web/assets/config-CvIO5hkn.js +0 -2
- package/out/web/assets/flowDiagram-HODETNUW-uqCHJond.js +0 -1
- package/out/web/assets/index-BmpulIkg.js +0 -168
- package/out/web/assets/index-CkvBwhX_.css +0 -1
- package/out/web/assets/stateDiagram-v2-MP3YSRHH-uf3kdNW4.js +0 -1
- package/out/web/assets/swimlanesDiagram-VR7AAH4N-Y8q5bQce.js +0 -8
- package/shared-modules/libsecret/libsecret.json +0 -23
- package/shared-modules/libusb/libusb.json +0 -27
- package/shared-modules/lzo/lzo.json +0 -27
- package/src/renderer/src/components/BrowserShell.tsx +0 -108
- package/src/renderer/src/components/BrowserSuggestionsPopup.tsx +0 -91
- package/src/renderer/src/components/browser-shell.css +0 -185
- package/src-tauri/src/native/browser.rs +0 -252
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
use reqwest::Client;
|
|
2
|
+
use serde_json::Value;
|
|
3
|
+
|
|
4
|
+
use crate::MintConfig;
|
|
5
|
+
|
|
6
|
+
use super::{
|
|
7
|
+
ChatError, ChatRequest, ChatStreamEvent, ProviderReply,
|
|
8
|
+
openai::{openai_chat_payload, parse_openai_style_reply, send_openai_style_request},
|
|
9
|
+
provider_key, required_key,
|
|
10
|
+
streaming::{StreamFormat, collect_stream_reply},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
pub(super) fn resolve_custom_model(config: &MintConfig) -> String {
|
|
14
|
+
let provider_id = config
|
|
15
|
+
.ai_provider
|
|
16
|
+
.strip_prefix("custom:")
|
|
17
|
+
.unwrap_or(&config.ai_provider);
|
|
18
|
+
|
|
19
|
+
// Check if a per-provider model selection was persisted in extra config.
|
|
20
|
+
if let Some(selections) = config
|
|
21
|
+
.extra
|
|
22
|
+
.get("customModelSelections")
|
|
23
|
+
.and_then(|v| v.as_object())
|
|
24
|
+
&& let Some(model) = selections.get(provider_id).and_then(|v| v.as_str())
|
|
25
|
+
&& !model.is_empty()
|
|
26
|
+
{
|
|
27
|
+
return model.to_owned();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Fall back to the first model in the provider definition.
|
|
31
|
+
config
|
|
32
|
+
.resolve_custom_provider(&config.ai_provider)
|
|
33
|
+
.and_then(|cp| cp.models.first())
|
|
34
|
+
.map(|m| m.model_id.clone())
|
|
35
|
+
.unwrap_or_default()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
pub(super) async fn call_huggingface(
|
|
39
|
+
client: &Client,
|
|
40
|
+
config: &MintConfig,
|
|
41
|
+
request: &ChatRequest,
|
|
42
|
+
) -> Result<ProviderReply, ChatError> {
|
|
43
|
+
let api_key = provider_key(&config.hf_api_key, "HF_TOKEN");
|
|
44
|
+
required_key("huggingface", &api_key)?;
|
|
45
|
+
let model = config.hf_model.clone();
|
|
46
|
+
// Hugging Face's router is an OpenAI Chat Completions-compatible
|
|
47
|
+
// endpoint, so it can (and must) take the same native `messages`/`tools`
|
|
48
|
+
// payload `call_openai` builds — this used to hand-roll a bare
|
|
49
|
+
// `{system, user: request.message}` request instead, which ignored the
|
|
50
|
+
// agent loop's full tool-call history and `tools` catalog. `message` is
|
|
51
|
+
// deliberately left empty (see the step-loop in `orchestration/mod.rs`)
|
|
52
|
+
// whenever `messages` carries the real conversation, so any mid-task
|
|
53
|
+
// fallback onto this provider was silently losing all task context —
|
|
54
|
+
// the model would see an empty user turn and reply with generic
|
|
55
|
+
// small talk, which the agent loop then treated as the final answer.
|
|
56
|
+
let response: Value = send_openai_style_request(
|
|
57
|
+
client
|
|
58
|
+
.post("https://router.huggingface.co/v1/chat/completions")
|
|
59
|
+
.bearer_auth(api_key)
|
|
60
|
+
.json(&openai_chat_payload(config, &model, request, false)?),
|
|
61
|
+
"huggingface",
|
|
62
|
+
)
|
|
63
|
+
.await?;
|
|
64
|
+
parse_openai_style_reply(model, &response)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
pub(super) async fn stream_huggingface_reply<F>(
|
|
68
|
+
client: &Client,
|
|
69
|
+
config: &MintConfig,
|
|
70
|
+
request: &ChatRequest,
|
|
71
|
+
on_event: &mut F,
|
|
72
|
+
) -> Result<ProviderReply, ChatError>
|
|
73
|
+
where
|
|
74
|
+
F: FnMut(ChatStreamEvent),
|
|
75
|
+
{
|
|
76
|
+
let api_key = provider_key(&config.hf_api_key, "HF_TOKEN");
|
|
77
|
+
required_key("huggingface", &api_key)?;
|
|
78
|
+
let model = config.hf_model.clone();
|
|
79
|
+
let response = client
|
|
80
|
+
.post("https://router.huggingface.co/v1/chat/completions")
|
|
81
|
+
.bearer_auth(api_key)
|
|
82
|
+
.json(&openai_chat_payload(config, &model, request, true)?)
|
|
83
|
+
.send()
|
|
84
|
+
.await?
|
|
85
|
+
.error_for_status()?;
|
|
86
|
+
collect_stream_reply(response, StreamFormat::OpenAi, model, on_event).await
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pub(super) async fn call_custom_provider(
|
|
90
|
+
client: &Client,
|
|
91
|
+
config: &MintConfig,
|
|
92
|
+
request: &ChatRequest,
|
|
93
|
+
) -> Result<ProviderReply, ChatError> {
|
|
94
|
+
let provider = config
|
|
95
|
+
.resolve_custom_provider(&config.ai_provider)
|
|
96
|
+
.ok_or_else(|| ChatError::UnsupportedProvider(config.ai_provider.clone()))?;
|
|
97
|
+
|
|
98
|
+
let base_url = provider.base_url.trim_end_matches('/');
|
|
99
|
+
let model = resolve_custom_model(config);
|
|
100
|
+
let payload = openai_chat_payload(config, &model, request, false)?;
|
|
101
|
+
|
|
102
|
+
let mut builder = client
|
|
103
|
+
.post(format!("{base_url}/chat/completions"))
|
|
104
|
+
.json(&payload);
|
|
105
|
+
|
|
106
|
+
if !provider.api_key.is_empty() {
|
|
107
|
+
builder = builder.bearer_auth(&provider.api_key);
|
|
108
|
+
}
|
|
109
|
+
for h in &provider.headers {
|
|
110
|
+
if !h.name.is_empty() {
|
|
111
|
+
builder = builder.header(h.name.as_str(), h.value.as_str());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let response: serde_json::Value = builder.send().await?.error_for_status()?.json().await?;
|
|
116
|
+
|
|
117
|
+
parse_openai_style_reply(model, &response)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
pub(super) async fn stream_custom_provider_reply<F>(
|
|
121
|
+
client: &Client,
|
|
122
|
+
config: &MintConfig,
|
|
123
|
+
request: &ChatRequest,
|
|
124
|
+
on_event: &mut F,
|
|
125
|
+
) -> Result<ProviderReply, ChatError>
|
|
126
|
+
where
|
|
127
|
+
F: FnMut(ChatStreamEvent),
|
|
128
|
+
{
|
|
129
|
+
let provider = config
|
|
130
|
+
.resolve_custom_provider(&config.ai_provider)
|
|
131
|
+
.ok_or_else(|| ChatError::UnsupportedProvider(config.ai_provider.clone()))?;
|
|
132
|
+
let model = resolve_custom_model(config);
|
|
133
|
+
let mut builder = client
|
|
134
|
+
.post(format!(
|
|
135
|
+
"{}/chat/completions",
|
|
136
|
+
provider.base_url.trim_end_matches('/')
|
|
137
|
+
))
|
|
138
|
+
.json(&openai_chat_payload(config, &model, request, true)?);
|
|
139
|
+
if !provider.api_key.is_empty() {
|
|
140
|
+
builder = builder.bearer_auth(&provider.api_key);
|
|
141
|
+
}
|
|
142
|
+
for header in &provider.headers {
|
|
143
|
+
if !header.name.is_empty() {
|
|
144
|
+
builder = builder.header(header.name.as_str(), header.value.as_str());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
let response = builder.send().await?.error_for_status()?;
|
|
148
|
+
collect_stream_reply(response, StreamFormat::OpenAi, model, on_event).await
|
|
149
|
+
}
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
use reqwest::Client;
|
|
2
|
+
use serde_json::{Value, json};
|
|
3
|
+
|
|
4
|
+
use super::streaming::{StreamFormat, collect_stream_reply};
|
|
5
|
+
use super::{
|
|
6
|
+
ProviderReply, effective_system_instruction, effective_temperature, effective_thinking,
|
|
7
|
+
extract_think_tag, provider_key, required_key, split_data_uri, wants_agent_json,
|
|
8
|
+
};
|
|
9
|
+
use crate::{
|
|
10
|
+
ChatError, ChatMessage, ChatRequest, ChatRole, ChatStreamEvent, ContentBlock, MintConfig,
|
|
11
|
+
ToolCall,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
pub(super) async fn call_gemini(
|
|
15
|
+
client: &Client,
|
|
16
|
+
config: &MintConfig,
|
|
17
|
+
request: &ChatRequest,
|
|
18
|
+
) -> Result<ProviderReply, ChatError> {
|
|
19
|
+
let api_key = provider_key(&config.api_key, "GEMINI_API_KEY");
|
|
20
|
+
required_key("gemini", &api_key)?;
|
|
21
|
+
let model = config.gemini_model.clone();
|
|
22
|
+
let url =
|
|
23
|
+
format!("https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent");
|
|
24
|
+
|
|
25
|
+
let mut payload = if request.messages.is_some() {
|
|
26
|
+
let mut p = gemini_native_payload(request)?;
|
|
27
|
+
let sys = effective_system_instruction(config, request, "gemini", &model);
|
|
28
|
+
p["systemInstruction"] = json!({ "parts": [{ "text": sys }] });
|
|
29
|
+
let temp = effective_temperature(config, request);
|
|
30
|
+
let mut gen_cfg = json!({ "temperature": temp });
|
|
31
|
+
gemini_apply_thinking_config(&mut gen_cfg, config, request, &model);
|
|
32
|
+
p["generationConfig"] = gen_cfg;
|
|
33
|
+
p
|
|
34
|
+
} else {
|
|
35
|
+
gemini_chat_payload(config, request)?
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
let raw_resp = client
|
|
39
|
+
.post(&url)
|
|
40
|
+
.header("x-goog-api-key", &api_key)
|
|
41
|
+
.json(&payload)
|
|
42
|
+
.send()
|
|
43
|
+
.await?;
|
|
44
|
+
let response: Value = if raw_resp.status() == reqwest::StatusCode::BAD_REQUEST
|
|
45
|
+
&& payload["generationConfig"].get("thinkingConfig").is_some()
|
|
46
|
+
{
|
|
47
|
+
if let Some(gen_obj) = payload["generationConfig"].as_object_mut() {
|
|
48
|
+
gen_obj.remove("thinkingConfig");
|
|
49
|
+
}
|
|
50
|
+
client
|
|
51
|
+
.post(&url)
|
|
52
|
+
.header("x-goog-api-key", &api_key)
|
|
53
|
+
.json(&payload)
|
|
54
|
+
.send()
|
|
55
|
+
.await?
|
|
56
|
+
.error_for_status()?
|
|
57
|
+
.json()
|
|
58
|
+
.await?
|
|
59
|
+
} else {
|
|
60
|
+
raw_resp.error_for_status()?.json().await?
|
|
61
|
+
};
|
|
62
|
+
parse_gemini_reply(model, &response)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
pub(super) async fn stream_gemini_reply<F>(
|
|
66
|
+
client: &Client,
|
|
67
|
+
config: &MintConfig,
|
|
68
|
+
request: &ChatRequest,
|
|
69
|
+
on_event: &mut F,
|
|
70
|
+
) -> Result<ProviderReply, ChatError>
|
|
71
|
+
where
|
|
72
|
+
F: FnMut(ChatStreamEvent),
|
|
73
|
+
{
|
|
74
|
+
let api_key = provider_key(&config.api_key, "GEMINI_API_KEY");
|
|
75
|
+
required_key("gemini", &api_key)?;
|
|
76
|
+
let model = config.gemini_model.clone();
|
|
77
|
+
let mut payload = if request.messages.is_some() {
|
|
78
|
+
let mut p = gemini_native_payload(request)?;
|
|
79
|
+
let sys = effective_system_instruction(config, request, "gemini", &model);
|
|
80
|
+
p["systemInstruction"] = json!({ "parts": [{ "text": sys }] });
|
|
81
|
+
let temp = effective_temperature(config, request);
|
|
82
|
+
let mut gen_cfg = json!({ "temperature": temp });
|
|
83
|
+
gemini_apply_thinking_config(&mut gen_cfg, config, request, &model);
|
|
84
|
+
p["generationConfig"] = gen_cfg;
|
|
85
|
+
p
|
|
86
|
+
} else {
|
|
87
|
+
gemini_chat_payload(config, request)?
|
|
88
|
+
};
|
|
89
|
+
let url = format!(
|
|
90
|
+
"https://generativelanguage.googleapis.com/v1beta/models/{model}:streamGenerateContent?alt=sse"
|
|
91
|
+
);
|
|
92
|
+
let raw_resp = client
|
|
93
|
+
.post(&url)
|
|
94
|
+
.header("x-goog-api-key", &api_key)
|
|
95
|
+
.json(&payload)
|
|
96
|
+
.send()
|
|
97
|
+
.await?;
|
|
98
|
+
let response = if raw_resp.status() == reqwest::StatusCode::BAD_REQUEST
|
|
99
|
+
&& payload["generationConfig"].get("thinkingConfig").is_some()
|
|
100
|
+
{
|
|
101
|
+
if let Some(gen_obj) = payload["generationConfig"].as_object_mut() {
|
|
102
|
+
gen_obj.remove("thinkingConfig");
|
|
103
|
+
}
|
|
104
|
+
client
|
|
105
|
+
.post(&url)
|
|
106
|
+
.header("x-goog-api-key", &api_key)
|
|
107
|
+
.json(&payload)
|
|
108
|
+
.send()
|
|
109
|
+
.await?
|
|
110
|
+
.error_for_status()?
|
|
111
|
+
} else {
|
|
112
|
+
raw_resp.error_for_status()?
|
|
113
|
+
};
|
|
114
|
+
collect_stream_reply(response, StreamFormat::Gemini, model, on_event).await
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// Strips JSON Schema keywords that standard tool-parameter schemas use (built
|
|
118
|
+
/// once and shared across OpenAI/Anthropic/Gemini) but that Gemini's function-
|
|
119
|
+
/// calling `Schema` proto rejects outright.
|
|
120
|
+
pub(crate) fn gemini_sanitize_schema(schema: &Value) -> Value {
|
|
121
|
+
match schema {
|
|
122
|
+
Value::Object(map) => Value::Object(
|
|
123
|
+
map.iter()
|
|
124
|
+
.filter(|(key, _)| key.as_str() != "additionalProperties")
|
|
125
|
+
.map(|(key, value)| (key.clone(), gemini_sanitize_schema(value)))
|
|
126
|
+
.collect(),
|
|
127
|
+
),
|
|
128
|
+
Value::Array(items) => Value::Array(items.iter().map(gemini_sanitize_schema).collect()),
|
|
129
|
+
other => other.clone(),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// Builds a Gemini `generateContent` payload from structured history, using
|
|
134
|
+
/// native `functionDeclarations`/`functionCall`/`functionResponse` instead of
|
|
135
|
+
/// the legacy `responseSchema` JSON-prompt scheme.
|
|
136
|
+
pub(super) fn gemini_native_payload(request: &ChatRequest) -> Result<Value, ChatError> {
|
|
137
|
+
let messages = request.messages.as_deref().unwrap_or(&[]);
|
|
138
|
+
let mut payload = json!({
|
|
139
|
+
"systemInstruction": { "parts": [{ "text": request.system_instruction }] },
|
|
140
|
+
"contents": gemini_native_contents(messages)?,
|
|
141
|
+
});
|
|
142
|
+
if let Some(tools) = &request.tools {
|
|
143
|
+
payload["tools"] = json!([{
|
|
144
|
+
"functionDeclarations": tools.iter().map(|tool| json!({
|
|
145
|
+
"name": tool.name,
|
|
146
|
+
"description": tool.description,
|
|
147
|
+
"parameters": gemini_sanitize_schema(&tool.parameters),
|
|
148
|
+
})).collect::<Vec<_>>()
|
|
149
|
+
}]);
|
|
150
|
+
}
|
|
151
|
+
Ok(payload)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
pub(super) fn gemini_native_contents(messages: &[ChatMessage]) -> Result<Vec<Value>, ChatError> {
|
|
155
|
+
let mut tool_names: std::collections::HashMap<&str, &str> = std::collections::HashMap::new();
|
|
156
|
+
for message in messages {
|
|
157
|
+
for block in &message.content {
|
|
158
|
+
if let ContentBlock::ToolUse { id, name, .. } = block {
|
|
159
|
+
tool_names.insert(id.as_str(), name.as_str());
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
messages
|
|
164
|
+
.iter()
|
|
165
|
+
.filter(|message| message.role != ChatRole::System)
|
|
166
|
+
.map(|message| {
|
|
167
|
+
let role = match message.role {
|
|
168
|
+
ChatRole::Assistant => "model",
|
|
169
|
+
_ => "user",
|
|
170
|
+
};
|
|
171
|
+
let parts = message
|
|
172
|
+
.content
|
|
173
|
+
.iter()
|
|
174
|
+
.map(|block| gemini_native_part(block, &tool_names))
|
|
175
|
+
.collect::<Result<Vec<_>, _>>()?;
|
|
176
|
+
Ok(json!({ "role": role, "parts": parts }))
|
|
177
|
+
})
|
|
178
|
+
.collect()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
pub(super) fn gemini_native_part(
|
|
182
|
+
block: &ContentBlock,
|
|
183
|
+
tool_names: &std::collections::HashMap<&str, &str>,
|
|
184
|
+
) -> Result<Value, ChatError> {
|
|
185
|
+
Ok(match block {
|
|
186
|
+
ContentBlock::Text { text } => json!({ "text": text }),
|
|
187
|
+
ContentBlock::ToolUse {
|
|
188
|
+
name,
|
|
189
|
+
input,
|
|
190
|
+
thought_signature,
|
|
191
|
+
..
|
|
192
|
+
} => {
|
|
193
|
+
let mut part = json!({ "functionCall": { "name": name, "args": input } });
|
|
194
|
+
if let Some(signature) = thought_signature {
|
|
195
|
+
part["thoughtSignature"] = json!(signature);
|
|
196
|
+
}
|
|
197
|
+
part
|
|
198
|
+
}
|
|
199
|
+
ContentBlock::ToolResult {
|
|
200
|
+
tool_use_id,
|
|
201
|
+
content,
|
|
202
|
+
..
|
|
203
|
+
} => {
|
|
204
|
+
let name = tool_names
|
|
205
|
+
.get(tool_use_id.as_str())
|
|
206
|
+
.copied()
|
|
207
|
+
.unwrap_or(tool_use_id.as_str());
|
|
208
|
+
json!({ "functionResponse": { "name": name, "response": { "result": content } } })
|
|
209
|
+
}
|
|
210
|
+
ContentBlock::Image { data_uri } => {
|
|
211
|
+
let (mime_type, data) = split_data_uri(data_uri, "image/")?;
|
|
212
|
+
json!({ "inlineData": { "mimeType": mime_type, "data": data } })
|
|
213
|
+
}
|
|
214
|
+
ContentBlock::Audio { data_uri } => {
|
|
215
|
+
let (mime_type, data) = split_data_uri(data_uri, "audio/")?;
|
|
216
|
+
json!({ "inlineData": { "mimeType": mime_type, "data": data } })
|
|
217
|
+
}
|
|
218
|
+
ContentBlock::Video { data_uri } => {
|
|
219
|
+
let (mime_type, data) = split_data_uri(data_uri, "video/")?;
|
|
220
|
+
json!({ "inlineData": { "mimeType": mime_type, "data": data } })
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
pub(super) fn gemini_chat_payload(
|
|
226
|
+
config: &MintConfig,
|
|
227
|
+
request: &ChatRequest,
|
|
228
|
+
) -> Result<Value, ChatError> {
|
|
229
|
+
let temp = effective_temperature(config, request);
|
|
230
|
+
let sys_instruction =
|
|
231
|
+
effective_system_instruction(config, request, "gemini", &config.gemini_model);
|
|
232
|
+
let mut payload = json!({
|
|
233
|
+
"systemInstruction": { "parts": [{ "text": sys_instruction }] },
|
|
234
|
+
"contents": [{ "role": "user", "parts": gemini_parts(request)? }]
|
|
235
|
+
});
|
|
236
|
+
let mut gen_cfg = if wants_agent_json(request) {
|
|
237
|
+
let mut cfg = gemini_agent_generation_config(config);
|
|
238
|
+
cfg["temperature"] = json!(temp);
|
|
239
|
+
cfg
|
|
240
|
+
} else {
|
|
241
|
+
json!({ "temperature": temp })
|
|
242
|
+
};
|
|
243
|
+
gemini_apply_thinking_config(&mut gen_cfg, config, request, &config.gemini_model);
|
|
244
|
+
payload["generationConfig"] = gen_cfg;
|
|
245
|
+
Ok(payload)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
pub(super) fn gemini_agent_generation_config(config: &MintConfig) -> Value {
|
|
249
|
+
let mut allowed_actions = vec![
|
|
250
|
+
"list_files",
|
|
251
|
+
"read_file",
|
|
252
|
+
"search_code",
|
|
253
|
+
"symbols",
|
|
254
|
+
"find_definition",
|
|
255
|
+
"find_references",
|
|
256
|
+
"semantic_index",
|
|
257
|
+
"semantic_search",
|
|
258
|
+
"knowledge_search",
|
|
259
|
+
"web_search",
|
|
260
|
+
"weather",
|
|
261
|
+
"stock",
|
|
262
|
+
"calculation",
|
|
263
|
+
"memory_recall",
|
|
264
|
+
"git_status",
|
|
265
|
+
"git_diff",
|
|
266
|
+
"git_log",
|
|
267
|
+
"git_branch",
|
|
268
|
+
"create_plan",
|
|
269
|
+
"update_plan",
|
|
270
|
+
"request_user_approval",
|
|
271
|
+
"ask_user",
|
|
272
|
+
"detect_project",
|
|
273
|
+
"list_tests",
|
|
274
|
+
"read_diagnostics",
|
|
275
|
+
"view_image",
|
|
276
|
+
"note_write",
|
|
277
|
+
"run_plugin",
|
|
278
|
+
"mcp_tool",
|
|
279
|
+
"run_shell",
|
|
280
|
+
"verify",
|
|
281
|
+
"run_tests",
|
|
282
|
+
"run_typecheck",
|
|
283
|
+
"run_linter",
|
|
284
|
+
"apply_patch",
|
|
285
|
+
"write_file",
|
|
286
|
+
];
|
|
287
|
+
allowed_actions.retain(|action| !config.disabled_tools.contains(&action.to_string()));
|
|
288
|
+
allowed_actions.push("finish");
|
|
289
|
+
|
|
290
|
+
json!({
|
|
291
|
+
"responseMimeType": "application/json",
|
|
292
|
+
"responseSchema": {
|
|
293
|
+
"type": "OBJECT",
|
|
294
|
+
"properties": {
|
|
295
|
+
"thought": { "type": "STRING" },
|
|
296
|
+
"action": {
|
|
297
|
+
"type": "STRING",
|
|
298
|
+
"enum": allowed_actions
|
|
299
|
+
},
|
|
300
|
+
"input": {
|
|
301
|
+
"type": "OBJECT",
|
|
302
|
+
"properties": {
|
|
303
|
+
"path": { "type": "STRING", "description": "The target file or directory path" },
|
|
304
|
+
"query": { "type": "STRING", "description": "The search query string" },
|
|
305
|
+
"city": { "type": "STRING", "description": "The target city or location name" },
|
|
306
|
+
"expression": { "type": "STRING", "description": "The math expression or percentage calculation" },
|
|
307
|
+
"url": { "type": "STRING", "description": "The target website URL" },
|
|
308
|
+
"command": { "type": "STRING", "description": "The local read-only or test shell command to run" },
|
|
309
|
+
"commands": {
|
|
310
|
+
"type": "ARRAY",
|
|
311
|
+
"items": { "type": "STRING" },
|
|
312
|
+
"description": "List of verification commands"
|
|
313
|
+
},
|
|
314
|
+
"steps": {
|
|
315
|
+
"type": "ARRAY",
|
|
316
|
+
"items": { "type": "STRING" },
|
|
317
|
+
"description": "Plan steps"
|
|
318
|
+
},
|
|
319
|
+
"fileContent": { "type": "STRING", "description": "The complete new content of a new file" },
|
|
320
|
+
"summary": { "type": "STRING", "description": "The final detailed answer, explanation, or response to the user's query" },
|
|
321
|
+
"verification": { "type": "STRING", "description": "The description of checks to run before finishing" },
|
|
322
|
+
"title": { "type": "STRING", "description": "Short approval or plan title" },
|
|
323
|
+
"status": { "type": "STRING", "description": "Plan item status or project status" },
|
|
324
|
+
"startLine": { "type": "INTEGER", "description": "First line to read" },
|
|
325
|
+
"endLine": { "type": "INTEGER", "description": "Last line to read" },
|
|
326
|
+
"limit": { "type": "INTEGER", "description": "Max number of items/lines/files to return" },
|
|
327
|
+
"server": { "type": "STRING", "description": "MCP server name" },
|
|
328
|
+
"tool": { "type": "STRING", "description": "MCP tool name" },
|
|
329
|
+
"notePath": { "type": "STRING", "description": "The file path for note writing" },
|
|
330
|
+
"name": { "type": "STRING", "description": "Plugin name" },
|
|
331
|
+
"instruction": { "type": "STRING", "description": "Instruction to run the plugin" },
|
|
332
|
+
"patch": {
|
|
333
|
+
"type": "OBJECT",
|
|
334
|
+
"properties": {
|
|
335
|
+
"path": { "type": "STRING", "description": "The target file path" },
|
|
336
|
+
"hunks": {
|
|
337
|
+
"type": "ARRAY",
|
|
338
|
+
"items": {
|
|
339
|
+
"type": "OBJECT",
|
|
340
|
+
"properties": {
|
|
341
|
+
"oldText": { "type": "STRING", "description": "The exact block of code to replace" },
|
|
342
|
+
"newText": { "type": "STRING", "description": "The replacement block of code" }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"arguments": { "type": "OBJECT", "description": "MCP tool arguments" }
|
|
349
|
+
},
|
|
350
|
+
"required": ["path", "query", "command", "fileContent", "summary"]
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"required": ["thought", "action", "input"]
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
pub(super) fn gemini_apply_thinking_config(
|
|
359
|
+
gen_cfg: &mut Value,
|
|
360
|
+
config: &MintConfig,
|
|
361
|
+
request: &ChatRequest,
|
|
362
|
+
model: &str,
|
|
363
|
+
) {
|
|
364
|
+
if !MintConfig::has_native_thinking_api("gemini", model) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
let (enabled, effort) = effective_thinking(config, request, model);
|
|
368
|
+
if !enabled {
|
|
369
|
+
gen_cfg["thinkingConfig"] = json!({
|
|
370
|
+
"includeThoughts": false,
|
|
371
|
+
"thinkingBudget": 0
|
|
372
|
+
});
|
|
373
|
+
} else {
|
|
374
|
+
let budget = match effort.as_str() {
|
|
375
|
+
"low" => 1024,
|
|
376
|
+
"medium" => 4096,
|
|
377
|
+
"high" => 16384,
|
|
378
|
+
"extra_high" => 32768,
|
|
379
|
+
_ => 4096,
|
|
380
|
+
};
|
|
381
|
+
gen_cfg["thinkingConfig"] = json!({
|
|
382
|
+
"includeThoughts": true,
|
|
383
|
+
"thinkingBudget": budget
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
pub(super) fn gemini_parts(request: &ChatRequest) -> Result<Vec<Value>, ChatError> {
|
|
389
|
+
let mut parts = vec![json!({ "text": request.message })];
|
|
390
|
+
if let Some(ref image_data) = request.image_data_uri {
|
|
391
|
+
for img in image_data.split_whitespace() {
|
|
392
|
+
let payload = img
|
|
393
|
+
.strip_prefix("data:")
|
|
394
|
+
.and_then(|payload| payload.split_once(";base64,"))
|
|
395
|
+
.filter(|(mime_type, data)| mime_type.starts_with("image/") && !data.is_empty())
|
|
396
|
+
.ok_or(ChatError::InvalidAttachment)?;
|
|
397
|
+
parts.push(json!({
|
|
398
|
+
"inlineData": {
|
|
399
|
+
"mimeType": payload.0,
|
|
400
|
+
"data": payload.1
|
|
401
|
+
}
|
|
402
|
+
}));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if let Some(ref audio_data) = request.audio_data_uri {
|
|
406
|
+
for aud in audio_data.split_whitespace() {
|
|
407
|
+
let payload = aud
|
|
408
|
+
.strip_prefix("data:")
|
|
409
|
+
.and_then(|payload| payload.split_once(";base64,"))
|
|
410
|
+
.filter(|(mime_type, data)| mime_type.starts_with("audio/") && !data.is_empty())
|
|
411
|
+
.ok_or(ChatError::InvalidAttachment)?;
|
|
412
|
+
parts.push(json!({
|
|
413
|
+
"inlineData": {
|
|
414
|
+
"mimeType": payload.0,
|
|
415
|
+
"data": payload.1
|
|
416
|
+
}
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if let Some(ref video_data) = request.video_data_uri {
|
|
421
|
+
for vid in video_data.split_whitespace() {
|
|
422
|
+
let payload = vid
|
|
423
|
+
.strip_prefix("data:")
|
|
424
|
+
.and_then(|payload| payload.split_once(";base64,"))
|
|
425
|
+
.filter(|(mime_type, data)| mime_type.starts_with("video/") && !data.is_empty())
|
|
426
|
+
.ok_or(ChatError::InvalidAttachment)?;
|
|
427
|
+
parts.push(json!({
|
|
428
|
+
"inlineData": {
|
|
429
|
+
"mimeType": payload.0,
|
|
430
|
+
"data": payload.1
|
|
431
|
+
}
|
|
432
|
+
}));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
Ok(parts)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
pub(super) fn parse_gemini_reply(
|
|
439
|
+
model: String,
|
|
440
|
+
response: &Value,
|
|
441
|
+
) -> Result<ProviderReply, ChatError> {
|
|
442
|
+
let parts = response["candidates"][0]["content"]["parts"]
|
|
443
|
+
.as_array()
|
|
444
|
+
.cloned()
|
|
445
|
+
.unwrap_or_default();
|
|
446
|
+
let mut text = String::new();
|
|
447
|
+
let mut thought_parts: Vec<&str> = Vec::new();
|
|
448
|
+
let mut tool_calls = Vec::new();
|
|
449
|
+
for (index, part) in parts.iter().enumerate() {
|
|
450
|
+
let is_thought = part
|
|
451
|
+
.get("thought")
|
|
452
|
+
.and_then(Value::as_bool)
|
|
453
|
+
.unwrap_or(false);
|
|
454
|
+
if let Some(t) = part["text"].as_str() {
|
|
455
|
+
if is_thought {
|
|
456
|
+
thought_parts.push(t);
|
|
457
|
+
} else {
|
|
458
|
+
text.push_str(t);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if let Some(call) = part.get("functionCall") {
|
|
462
|
+
tool_calls.push(ToolCall {
|
|
463
|
+
id: format!("call_{index}"),
|
|
464
|
+
name: call["name"].as_str().unwrap_or_default().to_string(),
|
|
465
|
+
input: call["args"].clone(),
|
|
466
|
+
thought_signature: part
|
|
467
|
+
.get("thoughtSignature")
|
|
468
|
+
.and_then(Value::as_str)
|
|
469
|
+
.map(str::to_owned),
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
let direct_thought = if !thought_parts.is_empty() {
|
|
474
|
+
Some(thought_parts.join("").trim().to_string()).filter(|s| !s.is_empty())
|
|
475
|
+
} else {
|
|
476
|
+
None
|
|
477
|
+
};
|
|
478
|
+
let (thought, text) = if direct_thought.is_none() {
|
|
479
|
+
extract_think_tag(&text)
|
|
480
|
+
} else {
|
|
481
|
+
(direct_thought, text)
|
|
482
|
+
};
|
|
483
|
+
if text.is_empty() && tool_calls.is_empty() {
|
|
484
|
+
if let Some(th) = &thought {
|
|
485
|
+
return Ok(ProviderReply {
|
|
486
|
+
model,
|
|
487
|
+
text: th.clone(),
|
|
488
|
+
thought: Some(th.clone()),
|
|
489
|
+
tool_calls: None,
|
|
490
|
+
stop_reason: response["candidates"][0]["finishReason"]
|
|
491
|
+
.as_str()
|
|
492
|
+
.map(str::to_owned),
|
|
493
|
+
input_tokens: response["usageMetadata"]["promptTokenCount"]
|
|
494
|
+
.as_u64()
|
|
495
|
+
.map(|n| n as u32),
|
|
496
|
+
output_tokens: response["usageMetadata"]["candidatesTokenCount"]
|
|
497
|
+
.as_u64()
|
|
498
|
+
.map(|n| n as u32),
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
return Err(ChatError::MissingResponseText);
|
|
502
|
+
}
|
|
503
|
+
Ok(ProviderReply {
|
|
504
|
+
model,
|
|
505
|
+
text,
|
|
506
|
+
thought,
|
|
507
|
+
tool_calls: (!tool_calls.is_empty()).then_some(tool_calls),
|
|
508
|
+
stop_reason: response["candidates"][0]["finishReason"]
|
|
509
|
+
.as_str()
|
|
510
|
+
.map(str::to_owned),
|
|
511
|
+
input_tokens: response["usageMetadata"]["promptTokenCount"]
|
|
512
|
+
.as_u64()
|
|
513
|
+
.map(|n| n as u32),
|
|
514
|
+
output_tokens: response["usageMetadata"]["candidatesTokenCount"]
|
|
515
|
+
.as_u64()
|
|
516
|
+
.map(|n| n as u32),
|
|
517
|
+
})
|
|
518
|
+
}
|