@johpaz/hive-agents 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -39
- package/dist/hive.js +4539 -4586
- package/dist/ui/assets/AgentCreateForm-tJZv9FZC.js +1 -0
- package/dist/ui/assets/AgentDetailPage-Du-mRcAX.js +1 -0
- package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +1 -0
- package/dist/ui/assets/{AgentsPage-DhCjvDNa.js → AgentsPage-YvSgWRiw.js} +7 -7
- package/dist/ui/assets/CanvasPage-DtMwGvxf.js +33 -0
- package/dist/ui/assets/ChannelsPage-BdBXWHjj.js +8 -0
- package/dist/ui/assets/DashboardPage-ghl1ZguH.js +6 -0
- package/dist/ui/assets/{LoginPage-B30OrEBy.js → LoginPage-CAmSI9Vy.js} +1 -1
- package/dist/ui/assets/LogsPage-DAPBHkwK.js +1 -0
- package/dist/ui/assets/MeetingPage-WjjGOqqU.js +1 -0
- package/dist/ui/assets/{NotFound-HD1Yp9yK.js → NotFound-BMeQSGcG.js} +1 -1
- package/dist/ui/assets/ProvidersPage-Ct6HsAi1.js +1 -0
- package/dist/ui/assets/{RecoverPage-CLF6buGP.js → RecoverPage-DpW3l-yv.js} +1 -1
- package/dist/ui/assets/SettingsPage-DBJ7_E6C.js +9 -0
- package/dist/ui/assets/SetupPage-DKmLVUaj.js +1 -0
- package/dist/ui/assets/{WebChatPage-Um3VANzn.js → WebChatPage-CVRcKept.js} +2 -2
- package/dist/ui/assets/accordion-C5d5Rm5z.js +1 -0
- package/dist/ui/assets/{activity-SfJ6UDF2.js → activity-c3pNngT_.js} +1 -1
- package/dist/ui/assets/alert-C-NE-P3s.js +1 -0
- package/dist/ui/assets/{alert-dialog-M893TdvF.js → alert-dialog-C5mzbHdP.js} +1 -1
- package/dist/ui/assets/arrow-left-CBcbX5EZ.js +1 -0
- package/dist/ui/assets/badge-ChpACfWO.js +1 -0
- package/dist/ui/assets/{calendar-CMMeWsP-.js → calendar-B-KZ9RQO.js} +1 -1
- package/dist/ui/assets/{card-C7P3W6_y.js → card-CNf6BS2e.js} +1 -1
- package/dist/ui/assets/chevron-left-D4U-5A27.js +1 -0
- package/dist/ui/assets/chevron-right-CR4Skrf3.js +1 -0
- package/dist/ui/assets/chevron-up-BYhk0K2J.js +1 -0
- package/dist/ui/assets/{circle-alert-7koABcbO.js → circle-alert-CyHDwUj8.js} +1 -1
- package/dist/ui/assets/circle-check-Bb54Ebmu.js +1 -0
- package/dist/ui/assets/{cpu-mBJgRJzM.js → cpu-Cdgc_B1K.js} +1 -1
- package/dist/ui/assets/dialog-QnZ0ad8O.js +1 -0
- package/dist/ui/assets/{download-oaofq4K1.js → download-C3ifGMjJ.js} +1 -1
- package/dist/ui/assets/dropdown-menu-BK-CO3Od.js +1 -0
- package/dist/ui/assets/{es-eUrU2hyB.js → es-NQNoaWDx.js} +1 -1
- package/dist/ui/assets/{external-link-SkkF2Z7B.js → external-link-BvxYeTP1.js} +1 -1
- package/dist/ui/assets/{eye-B8lq7sWG.js → eye-DqNTU_GD.js} +1 -1
- package/dist/ui/assets/{file-text-0oYol8Bb.js → file-text-BT_9S9SM.js} +1 -1
- package/dist/ui/assets/{folder-open-DVYu2lgk.js → folder-open-BhH8y9ac.js} +1 -1
- package/dist/ui/assets/gauge-D_TMa4i9.js +1 -0
- package/dist/ui/assets/{globe-BVPd5DRa.js → globe-DeCQTCDJ.js} +1 -1
- package/dist/ui/assets/{hexagon-BIAFUAlQ.js → hexagon-DsGOUl-H.js} +1 -1
- package/dist/ui/assets/{history-BUAnaMQo.js → history-BSG-Ypqf.js} +1 -1
- package/dist/ui/assets/index-B2fCYtTS.css +2 -0
- package/dist/ui/assets/index-DMCjjdqf.js +116 -0
- package/dist/ui/assets/{info-DWioleen.js → info-NwLoa2Mj.js} +1 -1
- package/dist/ui/assets/{key-BCGwSKKc.js → key-3EP0dhkT.js} +1 -1
- package/dist/ui/assets/label-D2H1IR_J.js +1 -0
- package/dist/ui/assets/loader-circle-CZNax6kS.js +1 -0
- package/dist/ui/assets/{lock-D7PCO7GC.js → lock-Ei1_J-Nq.js} +1 -1
- package/dist/ui/assets/{pause-CI1JFH6r.js → pause-BUqah9Bi.js} +1 -1
- package/dist/ui/assets/play-NcZ4swwL.js +1 -0
- package/dist/ui/assets/plus-CX1xyhp5.js +1 -0
- package/dist/ui/assets/progress-BherYzY6.js +1 -0
- package/dist/ui/assets/{refresh-cw-BLmKlO4J.js → refresh-cw-DaYdjQFk.js} +1 -1
- package/dist/ui/assets/{save-M1nv6H3P.js → save-CUdYyHNy.js} +1 -1
- package/dist/ui/assets/scroll-area-DkeyX32e.js +1 -0
- package/dist/ui/assets/{send-ijRfR0gp.js → send-B0H5SEIE.js} +1 -1
- package/dist/ui/assets/{settings-BvXhlJCF.js → settings-Ds4SqD8s.js} +1 -1
- package/dist/ui/assets/{slider-DrDFLwXh.js → slider-CsiUDxc3.js} +1 -1
- package/dist/ui/assets/{sparkles-C4MACMbE.js → sparkles-yUEb-7oH.js} +1 -1
- package/dist/ui/assets/{square-D_-gRT1l.js → square-BD81nFtN.js} +1 -1
- package/dist/ui/assets/switch-BDwN8RYV.js +1 -0
- package/dist/ui/assets/{table-DWEJJiuF.js → table-CSc8ubon.js} +1 -1
- package/dist/ui/assets/terminal-DN38Q456.js +1 -0
- package/dist/ui/assets/{textarea-CwPvQVAG.js → textarea-CXgXWKrT.js} +1 -1
- package/dist/ui/assets/{trash-2-Blkv31Dz.js → trash-2-CNjMkoq6.js} +1 -1
- package/dist/ui/assets/{triangle-alert-BKgbd30k.js → triangle-alert-C9Y8Ub4X.js} +1 -1
- package/dist/ui/assets/useProviders-C6_QHsEi.js +1 -0
- package/dist/ui/assets/{vendor-radix-JY4ncZrD.js → vendor-radix-cw1bQaVC.js} +4 -4
- package/dist/ui/assets/{vendor-react-CscwQerf.js → vendor-react-D4s9E-zj.js} +1 -1
- package/dist/ui/assets/{volume-2-BiUgObeI.js → volume-2-CeSXNDv4.js} +1 -1
- package/dist/ui/assets/{zap-CpyuQJEC.js → zap-hlXjpSeA.js} +1 -1
- package/dist/ui/dist/assets/AgentCreateForm-tJZv9FZC.js +1 -0
- package/dist/ui/dist/assets/AgentDetailPage-Du-mRcAX.js +1 -0
- package/dist/ui/dist/assets/AgentNewPage-DIFYd_Ys.js +1 -0
- package/dist/ui/dist/assets/AgentsPage-YvSgWRiw.js +10 -0
- package/dist/ui/dist/assets/CanvasPage-DtMwGvxf.js +33 -0
- package/dist/ui/dist/assets/ChannelsPage-BdBXWHjj.js +8 -0
- package/dist/ui/dist/assets/DashboardPage-ghl1ZguH.js +6 -0
- package/dist/ui/dist/assets/LoginPage-CAmSI9Vy.js +1 -0
- package/dist/ui/dist/assets/LogsPage-DAPBHkwK.js +1 -0
- package/dist/ui/dist/assets/MeetingPage-WjjGOqqU.js +1 -0
- package/dist/ui/dist/assets/NotFound-BMeQSGcG.js +1 -0
- package/dist/ui/dist/assets/ProvidersPage-Ct6HsAi1.js +1 -0
- package/dist/ui/dist/assets/RecoverPage-DpW3l-yv.js +1 -0
- package/dist/ui/dist/assets/SettingsPage-DBJ7_E6C.js +9 -0
- package/dist/ui/dist/assets/SetupPage-DKmLVUaj.js +1 -0
- package/dist/ui/dist/assets/WebChatPage-CVRcKept.js +16 -0
- package/dist/ui/dist/assets/accordion-C5d5Rm5z.js +1 -0
- package/dist/ui/dist/assets/activity-c3pNngT_.js +1 -0
- package/dist/ui/dist/assets/alert-C-NE-P3s.js +1 -0
- package/dist/ui/dist/assets/alert-dialog-C5mzbHdP.js +1 -0
- package/dist/ui/dist/assets/arrow-left-CBcbX5EZ.js +1 -0
- package/dist/ui/dist/assets/badge-ChpACfWO.js +1 -0
- package/dist/ui/dist/assets/calendar-B-KZ9RQO.js +1 -0
- package/dist/ui/dist/assets/card-CNf6BS2e.js +1 -0
- package/dist/ui/dist/assets/chevron-left-D4U-5A27.js +1 -0
- package/dist/ui/dist/assets/chevron-right-CR4Skrf3.js +1 -0
- package/dist/ui/dist/assets/chevron-up-BYhk0K2J.js +1 -0
- package/dist/ui/dist/assets/circle-alert-CyHDwUj8.js +1 -0
- package/dist/ui/dist/assets/circle-check-Bb54Ebmu.js +1 -0
- package/dist/ui/dist/assets/cpu-Cdgc_B1K.js +1 -0
- package/dist/ui/dist/assets/dialog-QnZ0ad8O.js +1 -0
- package/dist/ui/dist/assets/download-C3ifGMjJ.js +1 -0
- package/dist/ui/dist/assets/dropdown-menu-BK-CO3Od.js +1 -0
- package/dist/ui/dist/assets/es-NQNoaWDx.js +1 -0
- package/dist/ui/dist/assets/external-link-BvxYeTP1.js +1 -0
- package/dist/ui/dist/assets/eye-DqNTU_GD.js +1 -0
- package/dist/ui/dist/assets/file-text-BT_9S9SM.js +1 -0
- package/dist/ui/dist/assets/folder-open-BhH8y9ac.js +1 -0
- package/dist/ui/dist/assets/format-GVHeOyWI.js +1 -0
- package/dist/ui/dist/assets/gateway-url-COCbW0IR.js +1 -0
- package/dist/ui/dist/assets/gauge-D_TMa4i9.js +1 -0
- package/dist/ui/dist/assets/globe-DeCQTCDJ.js +1 -0
- package/dist/ui/dist/assets/hexagon-DsGOUl-H.js +1 -0
- package/dist/ui/dist/assets/history-BSG-Ypqf.js +1 -0
- package/dist/ui/dist/assets/index-B2fCYtTS.css +2 -0
- package/dist/ui/dist/assets/index-DMCjjdqf.js +116 -0
- package/dist/ui/dist/assets/info-NwLoa2Mj.js +1 -0
- package/dist/ui/dist/assets/key-3EP0dhkT.js +1 -0
- package/dist/ui/dist/assets/label-D2H1IR_J.js +1 -0
- package/dist/ui/dist/assets/loader-circle-CZNax6kS.js +1 -0
- package/dist/ui/dist/assets/lock-Ei1_J-Nq.js +1 -0
- package/dist/ui/dist/assets/pause-BUqah9Bi.js +1 -0
- package/dist/ui/dist/assets/play-NcZ4swwL.js +1 -0
- package/dist/ui/dist/assets/plus-CX1xyhp5.js +1 -0
- package/dist/ui/dist/assets/progress-BherYzY6.js +1 -0
- package/dist/ui/dist/assets/refresh-cw-DaYdjQFk.js +1 -0
- package/dist/ui/dist/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/ui/dist/assets/save-CUdYyHNy.js +1 -0
- package/dist/ui/dist/assets/scroll-area-DkeyX32e.js +1 -0
- package/dist/ui/dist/assets/send-B0H5SEIE.js +1 -0
- package/dist/ui/dist/assets/settings-Ds4SqD8s.js +1 -0
- package/dist/ui/dist/assets/slider-CsiUDxc3.js +14 -0
- package/dist/ui/dist/assets/sparkles-yUEb-7oH.js +1 -0
- package/dist/ui/dist/assets/square-BD81nFtN.js +1 -0
- package/dist/ui/dist/assets/switch-BDwN8RYV.js +1 -0
- package/dist/ui/dist/assets/table-CSc8ubon.js +1 -0
- package/dist/ui/dist/assets/terminal-DN38Q456.js +1 -0
- package/dist/ui/dist/assets/textarea-CXgXWKrT.js +1 -0
- package/dist/ui/dist/assets/trash-2-CNjMkoq6.js +1 -0
- package/dist/ui/dist/assets/triangle-alert-C9Y8Ub4X.js +1 -0
- package/dist/ui/dist/assets/useProviders-C6_QHsEi.js +1 -0
- package/dist/ui/dist/assets/utils-3pnRFmFe.js +1 -0
- package/dist/ui/dist/assets/vendor-charts-Bu2lyBKP.js +65 -0
- package/dist/ui/dist/assets/vendor-query-DsWPbQdG.js +1 -0
- package/dist/ui/dist/assets/vendor-radix-cw1bQaVC.js +63 -0
- package/dist/ui/dist/assets/vendor-react-D4s9E-zj.js +1 -0
- package/dist/ui/dist/assets/vendor-router-C9pIYwbJ.js +3 -0
- package/dist/ui/dist/assets/volume-2-CeSXNDv4.js +1 -0
- package/dist/ui/dist/assets/zap-hlXjpSeA.js +1 -0
- package/dist/ui/dist/favicon.ico +0 -0
- package/dist/ui/dist/index.html +40 -0
- package/dist/ui/dist/placeholder.svg +1 -0
- package/dist/ui/index.html +7 -11
- package/package.json +137 -15
- package/packages/cli/src/adapters/binary.ts +461 -0
- package/packages/cli/src/adapters/bun-global.ts +378 -0
- package/packages/cli/src/adapters/config.ts +314 -0
- package/packages/cli/src/adapters/docker.ts +308 -0
- package/packages/cli/src/adapters/factory.ts +168 -0
- package/packages/cli/src/adapters/index.ts +80 -0
- package/packages/cli/src/adapters/types.ts +218 -0
- package/packages/cli/src/commands/agent-run.ts +168 -0
- package/packages/cli/src/commands/agents.ts +398 -0
- package/packages/cli/src/commands/chat.ts +142 -0
- package/packages/cli/src/commands/config.ts +49 -0
- package/packages/cli/src/commands/cron.ts +487 -0
- package/packages/cli/src/commands/dev.ts +58 -0
- package/packages/cli/src/commands/doctor.ts +320 -0
- package/packages/cli/src/commands/gateway.ts +719 -0
- package/packages/cli/src/commands/logs.ts +57 -0
- package/packages/cli/src/commands/mcp.ts +175 -0
- package/packages/cli/src/commands/message.ts +77 -0
- package/packages/cli/src/commands/migrate.ts +90 -0
- package/packages/cli/src/commands/onboard.ts +1656 -0
- package/packages/cli/src/commands/security.ts +144 -0
- package/packages/cli/src/commands/service.ts +50 -0
- package/packages/cli/src/commands/sessions.ts +116 -0
- package/packages/cli/src/commands/skills.ts +215 -0
- package/packages/cli/src/commands/update.ts +203 -0
- package/packages/cli/src/index.ts +210 -0
- package/packages/cli/src/ui-bundle.generated.ts +3 -0
- package/packages/cli/src/utils/token.ts +6 -0
- package/packages/core/src/agent/agent-loop.ts +691 -0
- package/packages/core/src/agent/compaction.ts +240 -0
- package/packages/core/src/agent/context-compiler.ts +467 -0
- package/packages/core/src/agent/context-guard.ts +91 -0
- package/packages/core/src/agent/conversation-store.ts +244 -0
- package/packages/core/src/agent/curator.ts +158 -0
- package/packages/core/src/agent/hooks.ts +166 -0
- package/packages/core/src/agent/llm-client.ts +167 -0
- package/packages/core/src/agent/llm-providers/anthropic.ts +212 -0
- package/packages/core/src/agent/llm-providers/deepseek.ts +8 -0
- package/packages/core/src/agent/llm-providers/gemini.ts +215 -0
- package/packages/core/src/agent/llm-providers/groq.ts +5 -0
- package/packages/core/src/agent/llm-providers/interface.ts +195 -0
- package/packages/core/src/agent/llm-providers/kimi.ts +8 -0
- package/packages/core/src/agent/llm-providers/local-llama.ts +37 -0
- package/packages/core/src/agent/llm-providers/mistral.ts +5 -0
- package/packages/core/src/agent/llm-providers/nvidia.ts +5 -0
- package/packages/core/src/agent/llm-providers/ollama.ts +175 -0
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +379 -0
- package/packages/core/src/agent/llm-providers/openai.ts +5 -0
- package/packages/core/src/agent/llm-providers/openrouter.ts +5 -0
- package/packages/core/src/agent/llm-providers/qwen.ts +5 -0
- package/packages/core/src/agent/native-tools.ts +31 -0
- package/packages/core/src/agent/playbook-selector.ts +147 -0
- package/packages/core/src/agent/prompt-builder.ts +169 -0
- package/packages/core/src/agent/providers/index.ts +204 -0
- package/packages/core/src/agent/providers.ts +1 -0
- package/packages/core/src/agent/reflector.ts +200 -0
- package/packages/core/src/agent/service.ts +267 -0
- package/packages/core/src/agent/skill-selector.ts +479 -0
- package/packages/core/src/agent/stuck-loop.ts +133 -0
- package/packages/core/src/agent/tool-selector.ts +569 -0
- package/packages/core/src/agent/tracer.ts +100 -0
- package/packages/core/src/auth/auth.ts +108 -0
- package/packages/core/src/auth/index.ts +1 -0
- package/packages/core/src/canvas/a2ui-tools.ts +255 -0
- package/packages/core/src/canvas/canvas-manager.ts +390 -0
- package/packages/core/src/canvas/canvas-tools.ts +448 -0
- package/packages/core/src/canvas/emitter.ts +149 -0
- package/packages/core/src/canvas/index.ts +3 -0
- package/packages/core/src/channels/base.ts +154 -0
- package/packages/core/src/channels/discord.ts +273 -0
- package/packages/core/src/channels/index.ts +7 -0
- package/packages/core/src/channels/manager.ts +450 -0
- package/packages/core/src/channels/slack.ts +323 -0
- package/packages/core/src/channels/telegram.ts +612 -0
- package/packages/core/src/channels/webchat.ts +139 -0
- package/packages/core/src/channels/whatsapp.ts +548 -0
- package/packages/core/src/config/index.ts +12 -0
- package/packages/core/src/config/loader.ts +569 -0
- package/packages/core/src/events/agent-bus.ts +460 -0
- package/packages/core/src/events/event-bus.ts +169 -0
- package/packages/core/src/gateway/channel-notify.ts +64 -0
- package/packages/core/src/gateway/helpers/cors.ts +32 -0
- package/packages/core/src/gateway/helpers/index.ts +4 -0
- package/packages/core/src/gateway/helpers/narration.ts +57 -0
- package/packages/core/src/gateway/helpers/path.ts +13 -0
- package/packages/core/src/gateway/helpers/redact.ts +61 -0
- package/packages/core/src/gateway/index.ts +5 -0
- package/packages/core/src/gateway/initializer.ts +363 -0
- package/packages/core/src/gateway/lane-queue.ts +169 -0
- package/packages/core/src/gateway/llm-local/client.ts +94 -0
- package/packages/core/src/gateway/llm-local/detector.ts +321 -0
- package/packages/core/src/gateway/llm-local/downloader.ts +216 -0
- package/packages/core/src/gateway/llm-local/index.ts +34 -0
- package/packages/core/src/gateway/llm-local/manager.ts +186 -0
- package/packages/core/src/gateway/llm-local/models.ts +149 -0
- package/packages/core/src/gateway/llm-local/server.ts +179 -0
- package/packages/core/src/gateway/resolver.ts +108 -0
- package/packages/core/src/gateway/router.ts +124 -0
- package/packages/core/src/gateway/routes/agents.ts +210 -0
- package/packages/core/src/gateway/routes/auth.ts +244 -0
- package/packages/core/src/gateway/routes/channels.ts +484 -0
- package/packages/core/src/gateway/routes/chat.ts +241 -0
- package/packages/core/src/gateway/routes/config.ts +12 -0
- package/packages/core/src/gateway/routes/cron-api.ts +544 -0
- package/packages/core/src/gateway/routes/ethics.ts +46 -0
- package/packages/core/src/gateway/routes/llm-local.ts +271 -0
- package/packages/core/src/gateway/routes/mcp.ts +319 -0
- package/packages/core/src/gateway/routes/meeting.ts +232 -0
- package/packages/core/src/gateway/routes/models.ts +163 -0
- package/packages/core/src/gateway/routes/multimodal.ts +93 -0
- package/packages/core/src/gateway/routes/providers.ts +220 -0
- package/packages/core/src/gateway/routes/setup.ts +441 -0
- package/packages/core/src/gateway/routes/skills.ts +115 -0
- package/packages/core/src/gateway/routes/system.ts +469 -0
- package/packages/core/src/gateway/routes/tasks.ts +44 -0
- package/packages/core/src/gateway/routes/tools.ts +59 -0
- package/packages/core/src/gateway/routes/tts-local.ts +388 -0
- package/packages/core/src/gateway/routes/users.ts +122 -0
- package/packages/core/src/gateway/routes/voice.ts +189 -0
- package/packages/core/src/gateway/routes/workspace.ts +281 -0
- package/packages/core/src/gateway/server.ts +2744 -0
- package/packages/core/src/gateway/session.ts +95 -0
- package/packages/core/src/gateway/slash-commands.ts +207 -0
- package/packages/core/src/gateway/tts/README.md +94 -0
- package/packages/core/src/gateway/tts/package.json +25 -0
- package/packages/core/src/gateway/tts/src/client.ts +59 -0
- package/packages/core/src/gateway/tts/src/detect.ts +42 -0
- package/packages/core/src/gateway/tts/src/index.ts +15 -0
- package/packages/core/src/gateway/tts/src/install.ts +129 -0
- package/packages/core/src/gateway/tts/src/models.ts +50 -0
- package/packages/core/src/gateway/tts/src/server.ts +252 -0
- package/packages/core/src/gateway/tts/voices/.gitkeep +0 -0
- package/packages/core/src/heartbeat/index.ts +157 -0
- package/packages/core/src/index.ts +56 -0
- package/packages/core/src/mcp/hot-reload.ts +148 -0
- package/packages/core/src/mcp/singleton.ts +21 -0
- package/packages/core/src/mcp/tool-sync.ts +176 -0
- package/packages/core/src/multimodal/index.ts +2 -0
- package/packages/core/src/multimodal/types.ts +28 -0
- package/packages/core/src/multimodal/vision-service.ts +283 -0
- package/packages/core/src/plugins/api.ts +128 -0
- package/packages/core/src/plugins/index.ts +2 -0
- package/packages/core/src/plugins/loader.ts +365 -0
- package/packages/core/src/resilience/circuit-breaker.ts +225 -0
- package/packages/core/src/scheduler/CronScheduler.ts +699 -0
- package/packages/core/src/scheduler/dag/AgentExecutor.ts +53 -0
- package/packages/core/src/scheduler/dag/DAGScheduler.ts +250 -0
- package/packages/core/src/scheduler/dag/EventBridge.ts +122 -0
- package/packages/core/src/scheduler/dag/TaskGraph.ts +192 -0
- package/packages/core/src/scheduler/dag/TaskNode.ts +97 -0
- package/packages/core/src/scheduler/dag/TaskResult.ts +22 -0
- package/packages/core/src/scheduler/dag/errors.ts +37 -0
- package/packages/core/src/scheduler/dag/index.ts +26 -0
- package/packages/core/src/scheduler/dag/presets/ResearchPreset.ts +97 -0
- package/packages/core/src/scheduler/dag/strategies/ParallelStrategy.ts +21 -0
- package/packages/core/src/scheduler/dag/strategies/PriorityStrategy.ts +46 -0
- package/packages/core/src/scheduler/index.ts +22 -0
- package/packages/core/src/scheduler/integration.ts +237 -0
- package/packages/core/src/scheduler/types.ts +164 -0
- package/packages/core/src/security/google-chat.ts +269 -0
- package/packages/core/src/security/index.ts +192 -0
- package/packages/core/src/security/pairing.ts +250 -0
- package/packages/core/src/security/rate-limit.ts +270 -0
- package/packages/core/src/security/signal.ts +321 -0
- package/packages/core/src/state/store.ts +312 -0
- package/packages/core/src/storage/crypto.ts +197 -0
- package/packages/core/src/storage/migrate.ts +147 -0
- package/packages/core/src/storage/onboarding.ts +1506 -0
- package/packages/core/src/storage/schema.ts +666 -0
- package/packages/core/src/storage/seed.ts +628 -0
- package/packages/core/src/storage/sqlite.ts +407 -0
- package/packages/core/src/storage/usage.ts +374 -0
- package/packages/core/src/tool-runtime/index.ts +476 -0
- package/packages/core/src/tool-runtime/tool-worker.ts +125 -0
- package/packages/core/src/tools/agents/get-available-models.ts +118 -0
- package/packages/core/src/tools/agents/index.ts +610 -0
- package/packages/core/src/tools/canvas/index.ts +420 -0
- package/packages/core/src/tools/cli/index.ts +142 -0
- package/packages/core/src/tools/core/index.ts +478 -0
- package/packages/core/src/tools/cron/index.ts +635 -0
- package/packages/core/src/tools/filesystem/fs-delete.ts +78 -0
- package/packages/core/src/tools/filesystem/fs-edit.ts +106 -0
- package/packages/core/src/tools/filesystem/fs-exists.ts +63 -0
- package/packages/core/src/tools/filesystem/fs-glob.ts +108 -0
- package/packages/core/src/tools/filesystem/fs-list.ts +129 -0
- package/packages/core/src/tools/filesystem/fs-read.ts +72 -0
- package/packages/core/src/tools/filesystem/fs-write.ts +67 -0
- package/packages/core/src/tools/filesystem/index.ts +34 -0
- package/packages/core/src/tools/filesystem/workspace-guard.ts +62 -0
- package/packages/core/src/tools/index.ts +197 -0
- package/packages/core/src/tools/meeting/index.ts +363 -0
- package/packages/core/src/tools/office/index.ts +47 -0
- package/packages/core/src/tools/office/office-escribir-docx.ts +192 -0
- package/packages/core/src/tools/office/office-escribir-pdf.ts +172 -0
- package/packages/core/src/tools/office/office-escribir-pptx.ts +174 -0
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +116 -0
- package/packages/core/src/tools/office/office-leer-docx.ts +93 -0
- package/packages/core/src/tools/office/office-leer-pdf.ts +114 -0
- package/packages/core/src/tools/office/office-leer-pptx.ts +136 -0
- package/packages/core/src/tools/office/office-leer-xlsx.ts +124 -0
- package/packages/core/src/tools/types.ts +39 -0
- package/packages/core/src/tools/voice/index.ts +104 -0
- package/packages/core/src/tools/web/browser-click.ts +78 -0
- package/packages/core/src/tools/web/browser-extract.ts +139 -0
- package/packages/core/src/tools/web/browser-navigate.ts +106 -0
- package/packages/core/src/tools/web/browser-screenshot.ts +87 -0
- package/packages/core/src/tools/web/browser-script.ts +88 -0
- package/packages/core/src/tools/web/browser-service.ts +554 -0
- package/packages/core/src/tools/web/browser-type.ts +101 -0
- package/packages/core/src/tools/web/browser-wait.ts +136 -0
- package/packages/core/src/tools/web/index.ts +41 -0
- package/packages/core/src/tools/web/web-fetch.ts +78 -0
- package/packages/core/src/tools/web/web-search.ts +123 -0
- package/packages/core/src/utils/benchmark.ts +80 -0
- package/packages/core/src/utils/crypto.ts +73 -0
- package/packages/core/src/utils/date.ts +42 -0
- package/packages/core/src/utils/index.ts +5 -0
- package/packages/core/src/utils/logger.ts +389 -0
- package/packages/core/src/utils/retry.ts +70 -0
- package/packages/core/src/utils/toon.ts +253 -0
- package/packages/core/src/voice/index.ts +643 -0
- package/packages/mcp/src/config.ts +13 -0
- package/packages/mcp/src/index.ts +1 -0
- package/packages/mcp/src/logger.ts +47 -0
- package/packages/mcp/src/manager.ts +439 -0
- package/packages/mcp/src/transports/index.ts +67 -0
- package/packages/mcp/src/transports/sse.ts +238 -0
- package/packages/mcp/src/transports/websocket.ts +159 -0
- package/packages/skills/src/bundled/agents/agent_spawner/SKILL.md +167 -0
- package/packages/skills/src/bundled/agents/code_delegator/SKILL.md +156 -0
- package/packages/skills/src/bundled/agents/memory_manager/SKILL.md +143 -0
- package/packages/skills/src/bundled/agents/research_and_remember/SKILL.md +139 -0
- package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +198 -0
- package/packages/skills/src/bundled/canvas/a2ui_dashboard/SKILL.md +176 -0
- package/packages/skills/src/bundled/canvas/a2ui_form/SKILL.md +202 -0
- package/packages/skills/src/bundled/canvas/a2ui_interactive/SKILL.md +206 -0
- package/packages/skills/src/bundled/canvas/canvas_dashboard/SKILL.md +146 -0
- package/packages/skills/src/bundled/canvas/canvas_interact/SKILL.md +148 -0
- package/packages/skills/src/bundled/canvas/canvas_report/SKILL.md +146 -0
- package/packages/skills/src/bundled/cli/cli_pipeline/SKILL.md +136 -0
- package/packages/skills/src/bundled/cli/cli_safe_exec/SKILL.md +125 -0
- package/packages/skills/src/bundled/cron_manager/SKILL.md +188 -0
- package/packages/skills/src/bundled/cron_reminder/SKILL.md +112 -0
- package/packages/skills/src/bundled/filesystem/file_manager/SKILL.md +118 -0
- package/packages/skills/src/bundled/filesystem/file_read_and_summarize/SKILL.md +108 -0
- package/packages/skills/src/bundled/filesystem/file_writer/SKILL.md +135 -0
- package/packages/skills/src/bundled/meeting/meeting_transcription/SKILL.md +213 -0
- package/packages/skills/src/bundled/office/office_document_manager/SKILL.md +262 -0
- package/packages/skills/src/bundled/search_knowledge/busqueda_fts5/SKILL.md +74 -0
- package/packages/skills/src/bundled/voice/voice_assistant/SKILL.md +174 -0
- package/packages/skills/src/bundled/voice/voice_input/SKILL.md +146 -0
- package/packages/skills/src/bundled/voice/voice_output/SKILL.md +151 -0
- package/packages/skills/src/bundled/web/browser_automate/SKILL.md +120 -0
- package/packages/skills/src/bundled/web/browser_scrape/SKILL.md +109 -0
- package/packages/skills/src/bundled/web/web_monitor/SKILL.md +127 -0
- package/packages/skills/src/bundled/web/web_research/SKILL.md +119 -0
- package/packages/skills/src/bundled-data.generated.ts +1964 -0
- package/packages/skills/src/index.ts +1 -0
- package/packages/skills/src/loader.ts +388 -0
- package/dist/ui/assets/AgentCreateForm-DS6yXjGV.js +0 -1
- package/dist/ui/assets/AgentDetailPage-Ud552U7_.js +0 -1
- package/dist/ui/assets/AgentNewPage-DWWs1P7s.js +0 -1
- package/dist/ui/assets/BridgePage-BD93aBKM.js +0 -1
- package/dist/ui/assets/CanvasPage-CM35yj0Q.js +0 -33
- package/dist/ui/assets/ChannelsPage-CtsWtJdc.js +0 -8
- package/dist/ui/assets/DashboardPage-BpiwR5Jg.js +0 -6
- package/dist/ui/assets/LogsPage-DqUsG3MW.js +0 -1
- package/dist/ui/assets/MeetingPage-C5B8-IzE.js +0 -1
- package/dist/ui/assets/ProjectsPage-zic2sjUf.js +0 -1
- package/dist/ui/assets/ProvidersPage-BxyIGKzh.js +0 -1
- package/dist/ui/assets/SettingsPage-CNFm3nun.js +0 -9
- package/dist/ui/assets/SetupPage-RBcjQtv7.js +0 -1
- package/dist/ui/assets/accordion-BEVqJf2A.js +0 -1
- package/dist/ui/assets/alert-BeGcM0nb.js +0 -1
- package/dist/ui/assets/api-q5Ax-vD2.js +0 -63
- package/dist/ui/assets/arrow-left-B_jlw8X_.js +0 -1
- package/dist/ui/assets/badge-pNhtItyt.js +0 -1
- package/dist/ui/assets/chevron-down-B16UVNlu.js +0 -1
- package/dist/ui/assets/chevron-left-_8ly7Fz0.js +0 -1
- package/dist/ui/assets/chevron-right-yzZLjezG.js +0 -1
- package/dist/ui/assets/chevron-up-CxKDQEE5.js +0 -1
- package/dist/ui/assets/circle-CFKiO9Ds.js +0 -1
- package/dist/ui/assets/circle-check-E2u7ZS2r.js +0 -1
- package/dist/ui/assets/circle-minus-1-TZF2pu.js +0 -1
- package/dist/ui/assets/circle-x-Cm3Sr-xb.js +0 -1
- package/dist/ui/assets/dialog-BaJbZsQF.js +0 -1
- package/dist/ui/assets/dist-DB-fE0Co.js +0 -1
- package/dist/ui/assets/dropdown-menu-DJoOchfz.js +0 -1
- package/dist/ui/assets/gauge-BTpFKuAj.js +0 -1
- package/dist/ui/assets/index-BN0875JH.css +0 -2
- package/dist/ui/assets/index-D4pdc0Uw.js +0 -54
- package/dist/ui/assets/label-C6tqnnKd.js +0 -1
- package/dist/ui/assets/loader-circle-CK3qRV3f.js +0 -1
- package/dist/ui/assets/pencil-BF2_XX-i.js +0 -1
- package/dist/ui/assets/play-DidATMfT.js +0 -1
- package/dist/ui/assets/plus-DXm1XDhQ.js +0 -1
- package/dist/ui/assets/progress-B1HC9cB_.js +0 -1
- package/dist/ui/assets/scroll-area-DKNpYkRA.js +0 -1
- package/dist/ui/assets/search-Co6mulZS.js +0 -1
- package/dist/ui/assets/switch-7AuR7x2g.js +0 -1
- package/dist/ui/assets/terminal-CjZu0OZ0.js +0 -1
- package/dist/ui/assets/useProviders-Bxsnav4y.js +0 -1
- package/dist/ui/assets/useWebSocketStore-ZCW_Nt1w.js +0 -1
- package/dist/ui/assets/x-5cXW_1ZS.js +0 -1
- /package/dist/ui/assets/{format-C0EOLKvf.js → format-GVHeOyWI.js} +0 -0
- /package/dist/ui/assets/{gateway-url-OqLaEDK-.js → gateway-url-COCbW0IR.js} +0 -0
- /package/dist/ui/assets/{utils-_qMjiZaF.js → utils-3pnRFmFe.js} +0 -0
- /package/dist/ui/assets/{vendor-router-DhLEd920.js → vendor-router-C9pIYwbJ.js} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and utilities for LLM providers.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { LLMCallOptions, LLMMessage, LLMResponse, LLMToolCall, ContentPart } from "../llm-client"
|
|
6
|
+
export type { LLMCallOptions, LLMMessage, LLMResponse, LLMToolCall, ContentPart }
|
|
7
|
+
|
|
8
|
+
import { logger } from "../../utils/logger"
|
|
9
|
+
const log = logger.child("llm-client")
|
|
10
|
+
|
|
11
|
+
// ─── Provider interface ────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export interface LLMProvider {
|
|
14
|
+
call(options: LLMCallOptions): Promise<LLMResponse>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ─── Shared constants ─────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
// Models that only accept temperature=1 (reasoning/thinking models).
|
|
20
|
+
export const FIXED_TEMPERATURE_1_MODELS = new Set(["kimi-k2.5", "kimi-k2", "kimi-k2-5"])
|
|
21
|
+
|
|
22
|
+
export const OPENAI_COMPAT_BASE_URLS: Record<string, string> = {
|
|
23
|
+
groq: "https://api.groq.com/openai/v1",
|
|
24
|
+
mistral: "https://api.mistral.ai/v1",
|
|
25
|
+
openrouter: "https://openrouter.ai/api/v1",
|
|
26
|
+
deepseek: "https://api.deepseek.com/v1",
|
|
27
|
+
kimi: "https://api.moonshot.ai/v1",
|
|
28
|
+
"local-llama": "http://localhost:8081/v1",
|
|
29
|
+
nvidia: "https://integrate.api.nvidia.com/v1",
|
|
30
|
+
qwen: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ─── Provider profiles ────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
export interface ProviderProfile {
|
|
36
|
+
/** Normalize tool names to strict OpenAI format: [a-zA-Z0-9_-]{1,64} */
|
|
37
|
+
normalizeToolNames: boolean
|
|
38
|
+
/** Replacement string for invalid tool name chars, e.g. "__" */
|
|
39
|
+
toolNameReplacement: string
|
|
40
|
+
/** Value for the tool_choice parameter ("auto" | "any" for Mistral) */
|
|
41
|
+
toolChoiceAuto: string
|
|
42
|
+
/** Send parallel_tool_calls: false when true */
|
|
43
|
+
disableParallelToolCalls: boolean
|
|
44
|
+
/** Strip additionalProperties: false from tool parameter schemas */
|
|
45
|
+
stripAdditionalProperties: boolean
|
|
46
|
+
/** Retry the call without tools when these HTTP status codes are returned */
|
|
47
|
+
retryWithoutToolsOnCodes: number[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const DEFAULT_PROFILE: ProviderProfile = {
|
|
51
|
+
normalizeToolNames: false,
|
|
52
|
+
toolNameReplacement: "__",
|
|
53
|
+
toolChoiceAuto: "auto",
|
|
54
|
+
disableParallelToolCalls: false,
|
|
55
|
+
stripAdditionalProperties: false,
|
|
56
|
+
retryWithoutToolsOnCodes: [],
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const PROVIDER_PROFILES: Record<string, ProviderProfile> = {
|
|
60
|
+
openai: { ...DEFAULT_PROFILE, normalizeToolNames: true },
|
|
61
|
+
kimi: { ...DEFAULT_PROFILE, normalizeToolNames: true, disableParallelToolCalls: true, retryWithoutToolsOnCodes: [422] },
|
|
62
|
+
deepseek: { ...DEFAULT_PROFILE, normalizeToolNames: true },
|
|
63
|
+
groq: { ...DEFAULT_PROFILE, normalizeToolNames: true, retryWithoutToolsOnCodes: [400, 422] },
|
|
64
|
+
mistral: { ...DEFAULT_PROFILE, normalizeToolNames: true, toolChoiceAuto: "any", stripAdditionalProperties: true },
|
|
65
|
+
openrouter: { ...DEFAULT_PROFILE, normalizeToolNames: true, retryWithoutToolsOnCodes: [400, 422] },
|
|
66
|
+
nvidia: { ...DEFAULT_PROFILE, normalizeToolNames: true },
|
|
67
|
+
qwen: { ...DEFAULT_PROFILE, normalizeToolNames: true, retryWithoutToolsOnCodes: [400, 422] },
|
|
68
|
+
"local-llama": { ...DEFAULT_PROFILE },
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getProviderProfile(provider: string): ProviderProfile {
|
|
72
|
+
return PROVIDER_PROFILES[provider] ?? DEFAULT_PROFILE
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ─── Models that don't support tool calling ───────────────────────────────────
|
|
76
|
+
|
|
77
|
+
export const NO_TOOL_MODELS = new Set([
|
|
78
|
+
"deepseek-reasoner",
|
|
79
|
+
"deepseek/deepseek-r1:free",
|
|
80
|
+
])
|
|
81
|
+
|
|
82
|
+
export function modelSupportsTools(provider: string, model: string): boolean {
|
|
83
|
+
if (NO_TOOL_MODELS.has(model)) return false
|
|
84
|
+
// DeepSeek R1 and OpenRouter-routed R1 variants don't support tools
|
|
85
|
+
if ((provider === "deepseek" || provider === "openrouter") && /[-/]r1\b/i.test(model)) return false
|
|
86
|
+
return true
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ─── Tool name & schema normalization ────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
const OPENAI_TOOL_NAME_RE = /^[a-zA-Z0-9_-]{1,64}$/
|
|
92
|
+
const NORMALIZE_CHARS_RE = /[^a-zA-Z0-9_-]/g
|
|
93
|
+
|
|
94
|
+
/** Normalize a tool name to pass strict [a-zA-Z0-9_-]{1,64} validation. */
|
|
95
|
+
export function normalizeToolName(name: string, replacement: string): string {
|
|
96
|
+
if (OPENAI_TOOL_NAME_RE.test(name)) return name
|
|
97
|
+
const escapedReplacement = replacement.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
98
|
+
const collapseRE = new RegExp(`(${escapedReplacement}){2,}`, "g")
|
|
99
|
+
let n = name.replace(NORMALIZE_CHARS_RE, replacement).replace(collapseRE, replacement)
|
|
100
|
+
if (!/^[a-zA-Z_]/.test(n)) n = "_" + n
|
|
101
|
+
return n.slice(0, 64)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Strip provider-incompatible fields from a tool parameter schema. */
|
|
105
|
+
export function normalizeToolSchema(
|
|
106
|
+
schema: Record<string, unknown>,
|
|
107
|
+
profile: ProviderProfile
|
|
108
|
+
): Record<string, unknown> {
|
|
109
|
+
if (!profile.stripAdditionalProperties) return schema
|
|
110
|
+
return deepStripSchema(schema)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function deepStripSchema(obj: unknown): any {
|
|
114
|
+
if (typeof obj !== "object" || obj === null) return obj
|
|
115
|
+
if (Array.isArray(obj)) return obj.map(deepStripSchema)
|
|
116
|
+
const result: any = {}
|
|
117
|
+
for (const [k, v] of Object.entries(obj as Record<string, unknown>)) {
|
|
118
|
+
if (k === "additionalProperties" && v === false) continue
|
|
119
|
+
result[k] = deepStripSchema(v)
|
|
120
|
+
}
|
|
121
|
+
return result
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ─── Temperature constraints ──────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns true when the model requires temperature=1.
|
|
128
|
+
* Used for Kimi K2 thinking mode which rejects any other temperature.
|
|
129
|
+
*/
|
|
130
|
+
export function requiresTemperature1(provider: string, model: string): boolean {
|
|
131
|
+
if (FIXED_TEMPERATURE_1_MODELS.has(model)) return true
|
|
132
|
+
if (provider === "kimi") {
|
|
133
|
+
const m = model.toLowerCase()
|
|
134
|
+
if (m.includes("k2")) return true
|
|
135
|
+
}
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ─── Message sanitization ─────────────────────────────────────────────────────
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Remove tool_calls from assistant messages whose corresponding tool results
|
|
143
|
+
* are missing from the history (e.g. cleared by compaction). Providers like
|
|
144
|
+
* Kimi reject message sequences with orphaned tool_calls.
|
|
145
|
+
*/
|
|
146
|
+
export function sanitizeMessages(messages: LLMMessage[]): LLMMessage[] {
|
|
147
|
+
// Pass 0: collect all tool_call_ids that appear in assistant messages.
|
|
148
|
+
const knownToolCallIds = new Set<string>()
|
|
149
|
+
for (const m of messages) {
|
|
150
|
+
if (m.role === "assistant" && m.tool_calls?.length) {
|
|
151
|
+
for (const tc of m.tool_calls) knownToolCallIds.add(tc.id)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Pass 1: determine which tool_call_ids are "dead"
|
|
156
|
+
const deadIds = new Set<string>()
|
|
157
|
+
|
|
158
|
+
for (let i = 0; i < messages.length; i++) {
|
|
159
|
+
const m = messages[i]
|
|
160
|
+
if (m.role !== "assistant" || !m.tool_calls?.length) continue
|
|
161
|
+
|
|
162
|
+
const neededIds = new Set(m.tool_calls.map((tc) => tc.id))
|
|
163
|
+
let j = i + 1
|
|
164
|
+
while (j < messages.length && messages[j].role === "tool") {
|
|
165
|
+
if (messages[j].tool_call_id) neededIds.delete(messages[j].tool_call_id!)
|
|
166
|
+
j++
|
|
167
|
+
}
|
|
168
|
+
if (neededIds.size > 0) {
|
|
169
|
+
log.warn(`[llm-client] Stripping orphaned tool_calls (missing results for: ${[...neededIds].join(", ")})`)
|
|
170
|
+
for (const tc of m.tool_calls) deadIds.add(tc.id)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Pass 2: rebuild message list, dropping/fixing affected messages
|
|
175
|
+
const result: LLMMessage[] = []
|
|
176
|
+
for (const m of messages) {
|
|
177
|
+
if (m.role === "tool" && m.tool_call_id) {
|
|
178
|
+
if (deadIds.has(m.tool_call_id) || !knownToolCallIds.has(m.tool_call_id)) {
|
|
179
|
+
log.warn(`[llm-client] Dropping orphaned tool result (tool_call_id: ${m.tool_call_id})`)
|
|
180
|
+
continue
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (m.role === "assistant" && m.tool_calls?.some((tc) => deadIds.has(tc.id))) {
|
|
184
|
+
const { tool_calls, ...rest } = m
|
|
185
|
+
const hasContent = typeof rest.content === "string"
|
|
186
|
+
? rest.content.trim()
|
|
187
|
+
: Array.isArray(rest.content) && rest.content.length > 0
|
|
188
|
+
if (hasContent) result.push(rest as LLMMessage)
|
|
189
|
+
continue
|
|
190
|
+
}
|
|
191
|
+
result.push(m)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return result
|
|
195
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OpenAICompatBase } from "./openai-compat-base"
|
|
2
|
+
|
|
3
|
+
export class KimiProvider extends OpenAICompatBase {
|
|
4
|
+
constructor() { super("kimi") }
|
|
5
|
+
|
|
6
|
+
/** Kimi K2 thinking mode returns reasoning_content that must be round-tripped. */
|
|
7
|
+
protected needsReasoningRoundtrip(): boolean { return true }
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { logger } from "../../utils/logger"
|
|
2
|
+
import { OpenAICompatBase } from "./openai-compat-base"
|
|
3
|
+
import type { LLMCallOptions } from "./interface"
|
|
4
|
+
|
|
5
|
+
const log = logger.child("llm-client")
|
|
6
|
+
|
|
7
|
+
export class LocalLlamaProvider extends OpenAICompatBase {
|
|
8
|
+
constructor() { super("local-llama") }
|
|
9
|
+
|
|
10
|
+
protected isLocalProvider(): boolean { return true }
|
|
11
|
+
|
|
12
|
+
/** Auto-start the local llama server if not already running. */
|
|
13
|
+
protected async beforeCall(options: LLMCallOptions): Promise<void> {
|
|
14
|
+
try {
|
|
15
|
+
const { llamaManager } = await import("../../gateway/llm-local/manager")
|
|
16
|
+
const modelId = options.model.replace(/^local-llama\//i, "")
|
|
17
|
+
await llamaManager.start("TEXT", modelId as any)
|
|
18
|
+
} catch (err) {
|
|
19
|
+
log.warn(`[llm-client] local-llama auto-start failed or skipped: ${err}`)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Many GGUF chat templates don't support native tool calling via body.tools,
|
|
25
|
+
* so we inject tool descriptions into the system prompt as a fallback.
|
|
26
|
+
*/
|
|
27
|
+
protected injectToolsIntoPrompt(body: any, preparedTools: any[]): void {
|
|
28
|
+
const toolDescriptions = preparedTools.map(t => JSON.stringify(t.function)).join("\n")
|
|
29
|
+
const instruction = `You have access to the following tools. To call a tool, output a JSON block like: <tool_call>{"name": "tool_name", "arguments": {"arg1": "value"}}</tool_call>\n\nTools:\n${toolDescriptions}`
|
|
30
|
+
const sysMsg = body.messages.find((m: any) => m.role === "system")
|
|
31
|
+
if (sysMsg) {
|
|
32
|
+
sysMsg.content += "\n\n" + instruction
|
|
33
|
+
} else {
|
|
34
|
+
body.messages.unshift({ role: "system", content: instruction })
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { logger } from "../../utils/logger"
|
|
2
|
+
import { sanitizeMessages } from "./interface"
|
|
3
|
+
import type { LLMCallOptions, LLMProvider, LLMResponse, LLMToolCall } from "./interface"
|
|
4
|
+
import type { ContentPart, LLMMessage } from "../llm-client"
|
|
5
|
+
|
|
6
|
+
const log = logger.child("llm-client")
|
|
7
|
+
|
|
8
|
+
export class OllamaProvider implements LLMProvider {
|
|
9
|
+
private _convertMessage(msg: LLMMessage): any {
|
|
10
|
+
if (typeof msg.content === "string") {
|
|
11
|
+
return { role: msg.role, content: msg.content }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let textContent = ""
|
|
15
|
+
const images: string[] = []
|
|
16
|
+
|
|
17
|
+
for (const part of msg.content) {
|
|
18
|
+
if (part.type === "text") {
|
|
19
|
+
textContent += part.text
|
|
20
|
+
} else if (part.type === "image_base64") {
|
|
21
|
+
images.push(part.base64)
|
|
22
|
+
} else if (part.type === "document") {
|
|
23
|
+
textContent += `\n[Document: ${part.fileName || "file"}] (base64 content not displayed)`
|
|
24
|
+
} else if (part.type === "image_url") {
|
|
25
|
+
const url = part.image_url.url
|
|
26
|
+
if (url.startsWith("data:")) {
|
|
27
|
+
const match = url.match(/^data:([^;]+);base64,(.+)$/)
|
|
28
|
+
if (match) images.push(match[2])
|
|
29
|
+
} else {
|
|
30
|
+
textContent += `\n[Image URL: ${url}]`
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { role: msg.role, content: textContent.trim(), ...(images.length > 0 ? { images } : {}) }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async call(options: LLMCallOptions): Promise<LLMResponse> {
|
|
39
|
+
const { Ollama } = await import("ollama")
|
|
40
|
+
|
|
41
|
+
const modelName = options.model.replace(/^ollama\//, "")
|
|
42
|
+
const host = options.baseUrl?.trim() || process.env.OLLAMA_HOST || "http://localhost:11434"
|
|
43
|
+
const isCloud = host.includes("ollama.com")
|
|
44
|
+
const headers: Record<string, string> = {}
|
|
45
|
+
if (isCloud && options.apiKey) headers["Authorization"] = `Bearer ${options.apiKey}`
|
|
46
|
+
|
|
47
|
+
const client = new Ollama({
|
|
48
|
+
host,
|
|
49
|
+
...(Object.keys(headers).length ? { headers } : {}),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const messages = sanitizeMessages(options.messages).map((m): any => {
|
|
53
|
+
if (m.role === "assistant" && m.tool_calls?.length) {
|
|
54
|
+
return {
|
|
55
|
+
role: "assistant",
|
|
56
|
+
content: typeof m.content === "string" ? m.content : m.content.map(p => (p as any).text || "").join(""),
|
|
57
|
+
tool_calls: m.tool_calls.map((tc) => ({
|
|
58
|
+
function: {
|
|
59
|
+
name: tc.function.name,
|
|
60
|
+
arguments: (() => {
|
|
61
|
+
try { return JSON.parse(tc.function.arguments) } catch { return {} }
|
|
62
|
+
})(),
|
|
63
|
+
},
|
|
64
|
+
})),
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (m.role === "tool") return { role: "tool", content: typeof m.content === "string" ? m.content : JSON.stringify(m.content) }
|
|
68
|
+
return this._convertMessage(m)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const tools = options.tools?.map((t) => ({
|
|
72
|
+
type: "function" as const,
|
|
73
|
+
function: {
|
|
74
|
+
name: t.function.name,
|
|
75
|
+
description: t.function.description,
|
|
76
|
+
parameters: t.function.parameters,
|
|
77
|
+
},
|
|
78
|
+
}))
|
|
79
|
+
|
|
80
|
+
// Default num_ctx to 4096 for local models — prevents OOM on small models (2B-7B)
|
|
81
|
+
// when Ollama's default (32k+) is too large for available RAM/VRAM.
|
|
82
|
+
// Users can override via providers.num_ctx in DB.
|
|
83
|
+
const runtimeOptions: Record<string, unknown> = {
|
|
84
|
+
num_ctx: options.numCtx ?? 4096,
|
|
85
|
+
}
|
|
86
|
+
if (options.numGpu !== undefined) runtimeOptions.num_gpu = options.numGpu
|
|
87
|
+
if (options.temperature !== undefined) runtimeOptions.temperature = options.temperature
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
|
|
91
|
+
log.info(
|
|
92
|
+
`[llm-client] ollama/${modelName} @ ${isCloud ? "ollama.com" : host} stream=true` +
|
|
93
|
+
` — ${messages.length} msgs, ${tools?.length ?? 0} tools` +
|
|
94
|
+
` num_ctx=${runtimeOptions.num_ctx}`
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
const stream = await client.chat({
|
|
98
|
+
model: modelName,
|
|
99
|
+
messages,
|
|
100
|
+
tools: tools?.length ? tools : undefined,
|
|
101
|
+
options: Object.keys(runtimeOptions).length ? runtimeOptions : undefined,
|
|
102
|
+
stream: true,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
let content = ""
|
|
106
|
+
let promptEvalCount = 0
|
|
107
|
+
let evalCount = 0
|
|
108
|
+
const tool_calls: LLMToolCall[] = []
|
|
109
|
+
|
|
110
|
+
for await (const part of stream) {
|
|
111
|
+
const delta = part.message?.content ?? ""
|
|
112
|
+
if (delta) {
|
|
113
|
+
content += delta
|
|
114
|
+
if (options.onToken) options.onToken(delta)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (part.message?.tool_calls?.length) {
|
|
118
|
+
for (const tc of part.message.tool_calls) {
|
|
119
|
+
tool_calls.push({
|
|
120
|
+
id: crypto.randomUUID(),
|
|
121
|
+
type: "function" as const,
|
|
122
|
+
function: {
|
|
123
|
+
name: (tc as any).function.name,
|
|
124
|
+
arguments: JSON.stringify((tc as any).function.arguments ?? {}),
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (part.prompt_eval_count !== undefined) promptEvalCount = part.prompt_eval_count
|
|
131
|
+
if (part.eval_count !== undefined) evalCount = part.eval_count
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
content,
|
|
136
|
+
tool_calls: tool_calls.length ? tool_calls : undefined,
|
|
137
|
+
stop_reason: tool_calls.length > 0 ? "tool_calls" : "stop",
|
|
138
|
+
usage:
|
|
139
|
+
evalCount > 0
|
|
140
|
+
? { input_tokens: promptEvalCount, output_tokens: evalCount }
|
|
141
|
+
: undefined,
|
|
142
|
+
}
|
|
143
|
+
} catch (error: any) {
|
|
144
|
+
log.error(`[llm-client] FAILED call to ollama/${modelName} at ${host}`)
|
|
145
|
+
log.error(`[llm-client] Error details: ${error.message || error}`)
|
|
146
|
+
if (options.numCtx) log.error(`[llm-client] Context requested: num_ctx=${options.numCtx}`)
|
|
147
|
+
if (options.tools?.length) log.error(`[llm-client] Tools defined: ${options.tools.length}`)
|
|
148
|
+
|
|
149
|
+
// If the model runner crashed (likely OOM) and tools were sent, retry without tools.
|
|
150
|
+
// The model can still answer conversationally — tools will be unavailable this turn.
|
|
151
|
+
// Match by error message string OR HTTP 500 with tools (resilient to Ollama message changes).
|
|
152
|
+
if (
|
|
153
|
+
(error.message?.includes("model runner has unexpectedly stopped") || error.status === 500) &&
|
|
154
|
+
tools?.length
|
|
155
|
+
) {
|
|
156
|
+
log.warn(`[llm-client] OOM with tools — retrying without tools (num_ctx=${runtimeOptions.num_ctx})`)
|
|
157
|
+
const stream2 = await client.chat({
|
|
158
|
+
model: modelName,
|
|
159
|
+
messages,
|
|
160
|
+
tools: undefined,
|
|
161
|
+
options: runtimeOptions,
|
|
162
|
+
stream: true,
|
|
163
|
+
})
|
|
164
|
+
let content = ""
|
|
165
|
+
for await (const part of stream2) {
|
|
166
|
+
const delta = part.message?.content ?? ""
|
|
167
|
+
if (delta) { content += delta; if (options.onToken) options.onToken(delta) }
|
|
168
|
+
}
|
|
169
|
+
return { content, tool_calls: undefined, stop_reason: "stop" }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
throw error
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|