@johpaz/hive-agents 0.0.35 → 0.0.37
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 +3231 -3189
- package/dist/tool-worker.js +218406 -0
- package/dist/ui/assets/{AgentCreateForm-B4eK7efF.js → AgentCreateForm-tJZv9FZC.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-BD2uoJWk.js → AgentDetailPage-Du-mRcAX.js} +1 -1
- package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +1 -0
- package/dist/ui/assets/{AgentsPage-4JUZXvkA.js → AgentsPage-YvSgWRiw.js} +6 -6
- package/dist/ui/assets/CanvasPage-DtMwGvxf.js +33 -0
- package/dist/ui/assets/{ChannelsPage-BUn7-nhV.js → ChannelsPage-BdBXWHjj.js} +1 -1
- package/dist/ui/assets/DashboardPage-ghl1ZguH.js +6 -0
- package/dist/ui/assets/{LoginPage-C8j_urUD.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-Drh-sJPN.js → NotFound-BMeQSGcG.js} +1 -1
- package/dist/ui/assets/ProvidersPage-Ct6HsAi1.js +1 -0
- package/dist/ui/assets/{RecoverPage-DNb1Pr8h.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-R-YOwA4F.js → WebChatPage-CVRcKept.js} +2 -2
- package/dist/ui/assets/accordion-C5d5Rm5z.js +1 -0
- package/dist/ui/assets/{alert-U8FsgWi7.js → alert-C-NE-P3s.js} +1 -1
- package/dist/ui/assets/{alert-dialog-CRdMkkmk.js → alert-dialog-C5mzbHdP.js} +1 -1
- package/dist/ui/assets/{badge-Cli1jnH5.js → badge-ChpACfWO.js} +1 -1
- package/dist/ui/assets/chevron-up-BYhk0K2J.js +1 -0
- package/dist/ui/assets/{dialog-DQ3s-LuO.js → dialog-QnZ0ad8O.js} +1 -1
- package/dist/ui/assets/dropdown-menu-BK-CO3Od.js +1 -0
- package/dist/ui/assets/{es-DcMjrpbA.js → es-NQNoaWDx.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/{label-0BvGVXvZ.js → label-D2H1IR_J.js} +1 -1
- package/dist/ui/assets/progress-BherYzY6.js +1 -0
- package/dist/ui/assets/scroll-area-DkeyX32e.js +1 -0
- package/dist/ui/assets/{slider-D47dOrRa.js → slider-CsiUDxc3.js} +1 -1
- package/dist/ui/assets/switch-BDwN8RYV.js +1 -0
- package/dist/ui/assets/{table-DhowbNxQ.js → table-CSc8ubon.js} +1 -1
- package/dist/ui/assets/terminal-DN38Q456.js +1 -0
- 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/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 +6 -6
- package/package.json +138 -13
- 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 +502 -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/AgentNewPage-GB-tVN50.js +0 -1
- package/dist/ui/assets/BridgePage-DDcDILKu.js +0 -1
- package/dist/ui/assets/CanvasPage-oOk2sGOD.js +0 -33
- package/dist/ui/assets/DashboardPage-DV_2qWYJ.js +0 -6
- package/dist/ui/assets/LogsPage-DayYjh01.js +0 -1
- package/dist/ui/assets/MeetingPage-C01uPuqj.js +0 -1
- package/dist/ui/assets/ProjectsPage-B8_am_Ib.js +0 -1
- package/dist/ui/assets/ProvidersPage-DBzi66e4.js +0 -1
- package/dist/ui/assets/SettingsPage-CFA_Tknl.js +0 -9
- package/dist/ui/assets/SetupPage-BrUWbhvT.js +0 -1
- package/dist/ui/assets/accordion-DdAEfIXR.js +0 -1
- package/dist/ui/assets/chevron-down-DIosfU_U.js +0 -1
- package/dist/ui/assets/chevron-up-CI-W21Fy.js +0 -1
- package/dist/ui/assets/circle-S0-ouLz-.js +0 -1
- package/dist/ui/assets/circle-minus-CE0iJrl8.js +0 -1
- package/dist/ui/assets/circle-x-jUJ5zZvQ.js +0 -1
- package/dist/ui/assets/dropdown-menu-C2CXM1VE.js +0 -1
- package/dist/ui/assets/index-BN0875JH.css +0 -2
- package/dist/ui/assets/index-CH6sBa3Q.js +0 -116
- package/dist/ui/assets/pencil-5VdSj-h5.js +0 -1
- package/dist/ui/assets/progress-JN30I5fF.js +0 -1
- package/dist/ui/assets/scroll-area-BQQPitM8.js +0 -1
- package/dist/ui/assets/search-ChPgnVKj.js +0 -1
- package/dist/ui/assets/switch-C7W2-KEx.js +0 -1
- package/dist/ui/assets/terminal-C-R5Fckz.js +0 -1
- package/dist/ui/assets/useProviders-TBnWn-Hq.js +0 -1
- /package/dist/ui/assets/{card-DFKnZ6ky.js → card-CNf6BS2e.js} +0 -0
- /package/dist/ui/assets/{circle-alert-KuAm2FWh.js → circle-alert-CyHDwUj8.js} +0 -0
- /package/dist/ui/assets/{circle-check-6Ard1-2z.js → circle-check-Bb54Ebmu.js} +0 -0
- /package/dist/ui/assets/{cpu-KDy6-FAI.js → cpu-Cdgc_B1K.js} +0 -0
- /package/dist/ui/assets/{download-Cjbk4Rek.js → download-C3ifGMjJ.js} +0 -0
- /package/dist/ui/assets/{external-link-HtrFM63g.js → external-link-BvxYeTP1.js} +0 -0
- /package/dist/ui/assets/{eye-D1dB40_o.js → eye-DqNTU_GD.js} +0 -0
- /package/dist/ui/assets/{file-text-CE58EfH0.js → file-text-BT_9S9SM.js} +0 -0
- /package/dist/ui/assets/{folder-open-DIPKeiI_.js → folder-open-BhH8y9ac.js} +0 -0
- /package/dist/ui/assets/{format-BwdV8bB5.js → format-GVHeOyWI.js} +0 -0
- /package/dist/ui/assets/{gateway-url-D5uj6Nxg.js → gateway-url-COCbW0IR.js} +0 -0
- /package/dist/ui/assets/{gauge-DmQmJHEg.js → gauge-D_TMa4i9.js} +0 -0
- /package/dist/ui/assets/{globe-_hUGxQF4.js → globe-DeCQTCDJ.js} +0 -0
- /package/dist/ui/assets/{hexagon-BaNGQlQj.js → hexagon-DsGOUl-H.js} +0 -0
- /package/dist/ui/assets/{history-BfZVGlZa.js → history-BSG-Ypqf.js} +0 -0
- /package/dist/ui/assets/{info-CBZ5-AlC.js → info-NwLoa2Mj.js} +0 -0
- /package/dist/ui/assets/{key-Bv5DdTPh.js → key-3EP0dhkT.js} +0 -0
- /package/dist/ui/assets/{loader-circle-C4hhXLgp.js → loader-circle-CZNax6kS.js} +0 -0
- /package/dist/ui/assets/{lock-CkZYexqw.js → lock-Ei1_J-Nq.js} +0 -0
- /package/dist/ui/assets/{pause-Bpy1_s7y.js → pause-BUqah9Bi.js} +0 -0
- /package/dist/ui/assets/{play-Cj4osqJZ.js → play-NcZ4swwL.js} +0 -0
- /package/dist/ui/assets/{plus-BQhgZN3A.js → plus-CX1xyhp5.js} +0 -0
- /package/dist/ui/assets/{refresh-cw-BfREHVQM.js → refresh-cw-DaYdjQFk.js} +0 -0
- /package/dist/ui/assets/{save-FFTD4dMp.js → save-CUdYyHNy.js} +0 -0
- /package/dist/ui/assets/{settings-BdHKUL92.js → settings-Ds4SqD8s.js} +0 -0
- /package/dist/ui/assets/{sparkles-r4uJbJAl.js → sparkles-yUEb-7oH.js} +0 -0
- /package/dist/ui/assets/{square-G7Hyufqm.js → square-BD81nFtN.js} +0 -0
- /package/dist/ui/assets/{textarea-5kyuD04X.js → textarea-CXgXWKrT.js} +0 -0
- /package/dist/ui/assets/{trash-2-DXVBRWfh.js → trash-2-CNjMkoq6.js} +0 -0
- /package/dist/ui/assets/{triangle-alert-Bu5seg9O.js → triangle-alert-C9Y8Ub4X.js} +0 -0
- /package/dist/ui/assets/{vendor-router-CCECILJ0.js → vendor-router-C9pIYwbJ.js} +0 -0
- /package/dist/ui/assets/{volume-2-s9DuS696.js → volume-2-CeSXNDv4.js} +0 -0
- /package/dist/ui/assets/{zap-BPHZzXKV.js → zap-hlXjpSeA.js} +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { getDb } from "../../storage/sqlite";
|
|
2
|
+
import { voiceService, type AudioInput } from "../../voice/index";
|
|
3
|
+
import { logger } from "../../utils/logger";
|
|
4
|
+
|
|
5
|
+
const log = logger.child("meeting-routes");
|
|
6
|
+
|
|
7
|
+
type CorsHelper = (r: Response, req: Request) => Response;
|
|
8
|
+
|
|
9
|
+
// POST /api/meetings — Crear sesión
|
|
10
|
+
export async function handleCreateMeeting(
|
|
11
|
+
req: Request,
|
|
12
|
+
addCorsHeaders: CorsHelper
|
|
13
|
+
): Promise<Response> {
|
|
14
|
+
try {
|
|
15
|
+
const body = await req.json().catch(() => ({})) as Record<string, unknown>;
|
|
16
|
+
const title = (body.title as string) || "Reunión sin título";
|
|
17
|
+
const sttModel = (body.stt_model as string) || "whisper-large-v3-turbo";
|
|
18
|
+
|
|
19
|
+
const db = getDb();
|
|
20
|
+
const result = db
|
|
21
|
+
.query(
|
|
22
|
+
`INSERT INTO meeting_sessions (title, stt_model)
|
|
23
|
+
VALUES (?, ?)
|
|
24
|
+
RETURNING id, title, status, stt_model, started_at`
|
|
25
|
+
)
|
|
26
|
+
.get(title, sttModel) as {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
status: string;
|
|
30
|
+
stt_model: string;
|
|
31
|
+
started_at: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
log.info(`Meeting session created: ${result.id}`);
|
|
35
|
+
return addCorsHeaders(Response.json({ ok: true, session: result }), req);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
log.error(`handleCreateMeeting: ${(error as Error).message}`);
|
|
38
|
+
return addCorsHeaders(
|
|
39
|
+
Response.json({ ok: false, error: (error as Error).message }, { status: 500 }),
|
|
40
|
+
req
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// GET /api/meetings — Listar sesiones
|
|
46
|
+
export async function handleListMeetings(
|
|
47
|
+
req: Request,
|
|
48
|
+
addCorsHeaders: CorsHelper
|
|
49
|
+
): Promise<Response> {
|
|
50
|
+
try {
|
|
51
|
+
const db = getDb();
|
|
52
|
+
const sessions = db
|
|
53
|
+
.query(
|
|
54
|
+
`SELECT ms.*, COUNT(seg.id) as segment_count
|
|
55
|
+
FROM meeting_sessions ms
|
|
56
|
+
LEFT JOIN meeting_segments seg ON seg.session_id = ms.id
|
|
57
|
+
GROUP BY ms.id
|
|
58
|
+
ORDER BY ms.started_at DESC
|
|
59
|
+
LIMIT 50`
|
|
60
|
+
)
|
|
61
|
+
.all() as Record<string, unknown>[];
|
|
62
|
+
|
|
63
|
+
return addCorsHeaders(Response.json({ ok: true, sessions }), req);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
log.error(`handleListMeetings: ${(error as Error).message}`);
|
|
66
|
+
return addCorsHeaders(
|
|
67
|
+
Response.json({ ok: false, error: (error as Error).message }, { status: 500 }),
|
|
68
|
+
req
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// GET /api/meetings/:id — Detalle + segmentos
|
|
74
|
+
export async function handleGetMeeting(
|
|
75
|
+
req: Request,
|
|
76
|
+
addCorsHeaders: CorsHelper,
|
|
77
|
+
sessionId: string
|
|
78
|
+
): Promise<Response> {
|
|
79
|
+
try {
|
|
80
|
+
const db = getDb();
|
|
81
|
+
const session = db
|
|
82
|
+
.query(`SELECT * FROM meeting_sessions WHERE id = ?`)
|
|
83
|
+
.get(sessionId) as Record<string, unknown> | undefined;
|
|
84
|
+
|
|
85
|
+
if (!session) {
|
|
86
|
+
return addCorsHeaders(
|
|
87
|
+
Response.json({ ok: false, error: "Sesión no encontrada" }, { status: 404 }),
|
|
88
|
+
req
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const segments = db
|
|
93
|
+
.query(
|
|
94
|
+
`SELECT seq, speaker, text, created_at FROM meeting_segments
|
|
95
|
+
WHERE session_id = ? ORDER BY seq ASC`
|
|
96
|
+
)
|
|
97
|
+
.all(sessionId) as Record<string, unknown>[];
|
|
98
|
+
|
|
99
|
+
return addCorsHeaders(Response.json({ ok: true, session, segments }), req);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
log.error(`handleGetMeeting: ${(error as Error).message}`);
|
|
102
|
+
return addCorsHeaders(
|
|
103
|
+
Response.json({ ok: false, error: (error as Error).message }, { status: 500 }),
|
|
104
|
+
req
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// POST /api/meetings/:id/segments — Agregar segmento con audio base64
|
|
110
|
+
export async function handleAddMeetingSegment(
|
|
111
|
+
req: Request,
|
|
112
|
+
addCorsHeaders: CorsHelper,
|
|
113
|
+
sessionId: string
|
|
114
|
+
): Promise<Response> {
|
|
115
|
+
try {
|
|
116
|
+
const body = await req.json().catch(() => ({})) as Record<string, unknown>;
|
|
117
|
+
const audioBase64 = body.audio_base64 as string;
|
|
118
|
+
const speaker = (body.speaker as string) || null;
|
|
119
|
+
const mimeType = (body.mime_type as string) || "audio/webm";
|
|
120
|
+
|
|
121
|
+
if (!audioBase64) {
|
|
122
|
+
return addCorsHeaders(
|
|
123
|
+
Response.json({ ok: false, error: "audio_base64 es requerido" }, { status: 400 }),
|
|
124
|
+
req
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const db = getDb();
|
|
129
|
+
const session = db
|
|
130
|
+
.query(`SELECT id, stt_model, status FROM meeting_sessions WHERE id = ?`)
|
|
131
|
+
.get(sessionId) as { id: string; stt_model: string; status: string } | undefined;
|
|
132
|
+
|
|
133
|
+
if (!session) {
|
|
134
|
+
return addCorsHeaders(
|
|
135
|
+
Response.json({ ok: false, error: "Sesión no encontrada" }, { status: 404 }),
|
|
136
|
+
req
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (session.status !== "active") {
|
|
140
|
+
return addCorsHeaders(
|
|
141
|
+
Response.json(
|
|
142
|
+
{ ok: false, error: `La sesión está ${session.status}` },
|
|
143
|
+
{ status: 409 }
|
|
144
|
+
),
|
|
145
|
+
req
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const audioInput: AudioInput = { type: "base64", data: audioBase64, mimeType };
|
|
150
|
+
const transcription = await voiceService.transcribe(audioInput, session.stt_model);
|
|
151
|
+
|
|
152
|
+
const seqResult = db
|
|
153
|
+
.query(
|
|
154
|
+
`SELECT COALESCE(MAX(seq) + 1, 0) as next_seq FROM meeting_segments WHERE session_id = ?`
|
|
155
|
+
)
|
|
156
|
+
.get(sessionId) as { next_seq: number };
|
|
157
|
+
|
|
158
|
+
const seq = seqResult.next_seq;
|
|
159
|
+
db.query(
|
|
160
|
+
`INSERT INTO meeting_segments (session_id, seq, speaker, text) VALUES (?, ?, ?, ?)`
|
|
161
|
+
).run(sessionId, seq, speaker, transcription);
|
|
162
|
+
|
|
163
|
+
return addCorsHeaders(
|
|
164
|
+
Response.json({ ok: true, seq, speaker, text: transcription }),
|
|
165
|
+
req
|
|
166
|
+
);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
log.error(`handleAddMeetingSegment: ${(error as Error).message}`);
|
|
169
|
+
return addCorsHeaders(
|
|
170
|
+
Response.json({ ok: false, error: (error as Error).message }, { status: 500 }),
|
|
171
|
+
req
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// POST /api/meetings/:id/stop — Detener sesión
|
|
177
|
+
export async function handleStopMeeting(
|
|
178
|
+
req: Request,
|
|
179
|
+
addCorsHeaders: CorsHelper,
|
|
180
|
+
sessionId: string
|
|
181
|
+
): Promise<Response> {
|
|
182
|
+
try {
|
|
183
|
+
const db = getDb();
|
|
184
|
+
const session = db
|
|
185
|
+
.query(`SELECT id, title, status FROM meeting_sessions WHERE id = ?`)
|
|
186
|
+
.get(sessionId) as { id: string; title: string; status: string } | undefined;
|
|
187
|
+
|
|
188
|
+
if (!session) {
|
|
189
|
+
return addCorsHeaders(
|
|
190
|
+
Response.json({ ok: false, error: "Sesión no encontrada" }, { status: 404 }),
|
|
191
|
+
req
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (session.status !== "active") {
|
|
196
|
+
const count = (
|
|
197
|
+
db
|
|
198
|
+
.query(`SELECT COUNT(*) as c FROM meeting_segments WHERE session_id = ?`)
|
|
199
|
+
.get(sessionId) as { c: number }
|
|
200
|
+
).c;
|
|
201
|
+
return addCorsHeaders(
|
|
202
|
+
Response.json({ ok: true, session_id: sessionId, segment_count: count }),
|
|
203
|
+
req
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
db.query(
|
|
208
|
+
`UPDATE meeting_sessions SET status = 'stopped', stopped_at = unixepoch() WHERE id = ?`
|
|
209
|
+
).run(sessionId);
|
|
210
|
+
|
|
211
|
+
const countResult = db
|
|
212
|
+
.query(`SELECT COUNT(*) as count FROM meeting_segments WHERE session_id = ?`)
|
|
213
|
+
.get(sessionId) as { count: number };
|
|
214
|
+
|
|
215
|
+
log.info(`Meeting stopped: ${sessionId} — ${countResult.count} segments`);
|
|
216
|
+
return addCorsHeaders(
|
|
217
|
+
Response.json({
|
|
218
|
+
ok: true,
|
|
219
|
+
session_id: sessionId,
|
|
220
|
+
title: session.title,
|
|
221
|
+
segment_count: countResult.count,
|
|
222
|
+
}),
|
|
223
|
+
req
|
|
224
|
+
);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
log.error(`handleStopMeeting: ${(error as Error).message}`);
|
|
227
|
+
return addCorsHeaders(
|
|
228
|
+
Response.json({ ok: false, error: (error as Error).message }, { status: 500 }),
|
|
229
|
+
req
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { getDb } from "../../storage/sqlite.ts"
|
|
2
|
+
import type { Config } from "../../config/loader.ts"
|
|
3
|
+
|
|
4
|
+
export async function handleGetModels(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
5
|
+
const url = new URL(req.url)
|
|
6
|
+
const providerId = url.searchParams.get("provider_id")
|
|
7
|
+
|
|
8
|
+
let models
|
|
9
|
+
if (providerId) {
|
|
10
|
+
models = getDb().query("SELECT * FROM models WHERE provider_id = ? ORDER BY name").all(providerId)
|
|
11
|
+
} else {
|
|
12
|
+
models = getDb().query("SELECT * FROM models ORDER BY name").all()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return addCorsHeaders(Response.json({ models }), req)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function handleCreateModel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
19
|
+
const body = await req.json().catch(() => ({}))
|
|
20
|
+
|
|
21
|
+
const providerId = body.provider_id || body.providerId
|
|
22
|
+
const name = body.name
|
|
23
|
+
const modelType = body.model_type || body.modelType || "llm"
|
|
24
|
+
const contextWindow = body.context_window || body.contextWindow || 50000
|
|
25
|
+
|
|
26
|
+
if (!name || !providerId) {
|
|
27
|
+
return addCorsHeaders(Response.json({ ok: false, error: "name and provider_id are required" }, { status: 400 }), req)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const id = body.id || name
|
|
31
|
+
|
|
32
|
+
const existing = getDb().query("SELECT * FROM models WHERE id = ?").get(id) as any
|
|
33
|
+
if (existing) {
|
|
34
|
+
return addCorsHeaders(Response.json({ ok: false, error: "Model already exists", id, model: existing }, { status: 409 }), req)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getDb().query(`
|
|
38
|
+
INSERT INTO models(id, name, provider_id, model_type, context_window, enabled, active)
|
|
39
|
+
VALUES(?, ?, ?, ?, ?, 1, 1)
|
|
40
|
+
`).run(id, name, providerId, modelType, contextWindow)
|
|
41
|
+
|
|
42
|
+
const model = getDb().query("SELECT * FROM models WHERE id = ?").get(id)
|
|
43
|
+
return addCorsHeaders(Response.json({ ok: true, id, model }, { status: 201 }), req)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function handleToggleModel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
47
|
+
const url = new URL(req.url)
|
|
48
|
+
// URL pattern: /api/models/:id/toggle — extract model id from path
|
|
49
|
+
const pathMatch = url.pathname.match(/^\/api\/models\/([^/]+)\/toggle$/)
|
|
50
|
+
const modelId = pathMatch ? decodeURIComponent(pathMatch[1]) : null
|
|
51
|
+
const body = await req.json().catch(() => ({}))
|
|
52
|
+
const { active } = body
|
|
53
|
+
|
|
54
|
+
if (!modelId || active === undefined) {
|
|
55
|
+
return addCorsHeaders(Response.json({ success: false, error: "model id and active required" }), req)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getDb().query(`UPDATE models SET active = ?, enabled = ? WHERE id = ?`).run(active ? 1 : 0, active ? 1 : 0, modelId)
|
|
59
|
+
|
|
60
|
+
return addCorsHeaders(Response.json({ success: true, active }), req)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function handleGetModelsConfig(
|
|
64
|
+
req: Request,
|
|
65
|
+
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
66
|
+
config: Config
|
|
67
|
+
): Promise<Response> {
|
|
68
|
+
return addCorsHeaders(Response.json({
|
|
69
|
+
config: config.models || {},
|
|
70
|
+
availableProviders: ["openai", "anthropic", "gemini", "kimi", "ollama", "openrouter", "deepseek"],
|
|
71
|
+
}), req);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function handleDeleteModel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
75
|
+
const url = new URL(req.url)
|
|
76
|
+
const pathMatch = url.pathname.match(/^\/api\/models\/([^/]+)$/)
|
|
77
|
+
const modelId = pathMatch ? decodeURIComponent(pathMatch[1]) : null
|
|
78
|
+
|
|
79
|
+
if (!modelId) {
|
|
80
|
+
return addCorsHeaders(Response.json({ ok: false, error: "model id required" }, { status: 400 }), req)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const existing = getDb().query("SELECT * FROM models WHERE id = ?").get(modelId) as any
|
|
84
|
+
if (!existing) {
|
|
85
|
+
return addCorsHeaders(Response.json({ ok: false, error: "Model not found" }, { status: 404 }), req)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const agents = getDb().query("SELECT id, name FROM agents WHERE model_id = ?").all(modelId) as any[]
|
|
89
|
+
if (agents.length > 0) {
|
|
90
|
+
const names = agents.map(a => a.name).join(", ")
|
|
91
|
+
return addCorsHeaders(Response.json({ ok: false, error: `En uso por agentes: ${names}` }, { status: 409 }), req)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getDb().query("DELETE FROM models WHERE id = ?").run(modelId)
|
|
95
|
+
return addCorsHeaders(Response.json({ ok: true }), req)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function handleUpdateModel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
99
|
+
const url = new URL(req.url)
|
|
100
|
+
const pathMatch = url.pathname.match(/^\/api\/models\/([^/]+)$/)
|
|
101
|
+
const oldId = pathMatch ? decodeURIComponent(pathMatch[1]) : null
|
|
102
|
+
|
|
103
|
+
if (!oldId) {
|
|
104
|
+
return addCorsHeaders(Response.json({ ok: false, error: "model id required" }, { status: 400 }), req)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const existing = getDb().query("SELECT * FROM models WHERE id = ?").get(oldId) as any
|
|
108
|
+
if (!existing) {
|
|
109
|
+
return addCorsHeaders(Response.json({ ok: false, error: "Model not found" }, { status: 404 }), req)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const body = await req.json().catch(() => ({}))
|
|
113
|
+
const newId: string | undefined = body.id
|
|
114
|
+
const newName: string | undefined = body.name
|
|
115
|
+
|
|
116
|
+
if (!newId || newId === oldId) {
|
|
117
|
+
// Only name change
|
|
118
|
+
const name = newName || existing.name
|
|
119
|
+
getDb().query("UPDATE models SET name = ? WHERE id = ?").run(name, oldId)
|
|
120
|
+
const model = getDb().query("SELECT * FROM models WHERE id = ?").get(oldId)
|
|
121
|
+
return addCorsHeaders(Response.json({ ok: true, model }), req)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ID is changing — use a transaction to migrate agents references
|
|
125
|
+
const checkConflict = getDb().query("SELECT id FROM models WHERE id = ?").get(newId) as any
|
|
126
|
+
if (checkConflict) {
|
|
127
|
+
return addCorsHeaders(Response.json({ ok: false, error: "Ya existe un modelo con ese ID" }, { status: 409 }), req)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const name = newName || existing.name
|
|
131
|
+
getDb().transaction(() => {
|
|
132
|
+
getDb().query(`
|
|
133
|
+
INSERT INTO models(id, name, provider_id, model_type, context_window, capabilities, enabled, active)
|
|
134
|
+
SELECT ?, ?, provider_id, model_type, context_window, capabilities, enabled, active FROM models WHERE id = ?
|
|
135
|
+
`).run(newId, name, oldId)
|
|
136
|
+
getDb().query("UPDATE agents SET model_id = ? WHERE model_id = ?").run(newId, oldId)
|
|
137
|
+
getDb().query("DELETE FROM models WHERE id = ?").run(oldId)
|
|
138
|
+
})()
|
|
139
|
+
|
|
140
|
+
const model = getDb().query("SELECT * FROM models WHERE id = ?").get(newId)
|
|
141
|
+
return addCorsHeaders(Response.json({ ok: true, model }), req)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function handleUpdateModelsConfig(
|
|
145
|
+
req: Request,
|
|
146
|
+
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
147
|
+
config: Config,
|
|
148
|
+
agent?: any
|
|
149
|
+
): Promise<Response> {
|
|
150
|
+
const body = await req.json().catch(() => ({}));
|
|
151
|
+
const { defaultProvider, defaults, providers } = body;
|
|
152
|
+
|
|
153
|
+
config.models = config.models || {};
|
|
154
|
+
if (defaultProvider) config.models.defaultProvider = defaultProvider;
|
|
155
|
+
if (defaults) config.models.defaults = { ...(config.models.defaults || {}), ...defaults };
|
|
156
|
+
if (providers) config.models.providers = { ...(config.models.providers || {}), ...providers };
|
|
157
|
+
|
|
158
|
+
if (agent) {
|
|
159
|
+
await agent.updateConfig(config);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return addCorsHeaders(Response.json({ success: true }), req);
|
|
163
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { multimodalService } from "../../multimodal/index"
|
|
2
|
+
import { getDb } from "../../storage/sqlite"
|
|
3
|
+
|
|
4
|
+
export async function handleGetVisionProviders(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
5
|
+
const configured = multimodalService.getConfiguredVisionProviders()
|
|
6
|
+
const db = getDb()
|
|
7
|
+
const visionModels = db.query(`
|
|
8
|
+
SELECT m.id, m.name, m.provider_id, m.capabilities
|
|
9
|
+
FROM models m
|
|
10
|
+
JOIN providers p ON m.provider_id = p.id
|
|
11
|
+
WHERE m.enabled = 1 AND p.enabled = 1 AND p.api_key_encrypted IS NOT NULL AND p.api_key_encrypted != ''
|
|
12
|
+
`).all() as Array<{ id: string; name: string; provider_id: string; capabilities: string }>
|
|
13
|
+
|
|
14
|
+
const modelsWithVision = visionModels.filter(m => {
|
|
15
|
+
try {
|
|
16
|
+
const caps = JSON.parse(m.capabilities || "[]") as string[]
|
|
17
|
+
return caps.includes("vision")
|
|
18
|
+
} catch { return false }
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return addCorsHeaders(Response.json({
|
|
22
|
+
configuredProviders: configured,
|
|
23
|
+
visionModels: modelsWithVision.map(m => ({
|
|
24
|
+
id: m.id,
|
|
25
|
+
name: m.name,
|
|
26
|
+
providerId: m.provider_id,
|
|
27
|
+
})),
|
|
28
|
+
}), req)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function handleGetChannelVision(req: Request, addCorsHeaders: (r: Response, req: Request) => Response, channelId: string): Promise<Response> {
|
|
32
|
+
const config = multimodalService.getChannelVisionConfig(channelId)
|
|
33
|
+
return addCorsHeaders(Response.json(config), req)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function handleUpdateChannelVision(req: Request, addCorsHeaders: (r: Response, req: Request) => Response, channelId: string): Promise<Response> {
|
|
37
|
+
const body = await req.json().catch(() => ({})) as {
|
|
38
|
+
visionEnabled?: boolean
|
|
39
|
+
ocrProvider?: string
|
|
40
|
+
visionProvider?: string
|
|
41
|
+
visionModelId?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const db = getDb()
|
|
45
|
+
const updates: string[] = []
|
|
46
|
+
const values: any[] = []
|
|
47
|
+
|
|
48
|
+
if (body.visionEnabled !== undefined) {
|
|
49
|
+
updates.push("vision_enabled = ?")
|
|
50
|
+
values.push(body.visionEnabled ? 1 : 0)
|
|
51
|
+
}
|
|
52
|
+
if (body.ocrProvider !== undefined) {
|
|
53
|
+
updates.push("ocr_provider = ?")
|
|
54
|
+
values.push(body.ocrProvider)
|
|
55
|
+
}
|
|
56
|
+
if (body.visionProvider !== undefined) {
|
|
57
|
+
updates.push("vision_provider = ?")
|
|
58
|
+
values.push(body.visionProvider)
|
|
59
|
+
}
|
|
60
|
+
if (body.visionModelId !== undefined) {
|
|
61
|
+
updates.push("vision_model_id = ?")
|
|
62
|
+
values.push(body.visionModelId)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (updates.length === 0) {
|
|
66
|
+
return addCorsHeaders(Response.json({ success: false, error: "No fields to update" }, { status: 400 }), req)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
values.push(channelId)
|
|
70
|
+
db.query(`UPDATE channels SET ${updates.join(", ")} WHERE id = ?`).run(...values)
|
|
71
|
+
|
|
72
|
+
const updated = multimodalService.getChannelVisionConfig(channelId)
|
|
73
|
+
return addCorsHeaders(Response.json({ success: true, config: updated }), req)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function handleOcrImage(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
77
|
+
const body = await req.json().catch(() => ({})) as {
|
|
78
|
+
image?: { url?: string; base64?: string; buffer?: string; mimeType?: string; caption?: string }
|
|
79
|
+
provider?: string
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!body.image) {
|
|
83
|
+
return addCorsHeaders(Response.json({ success: false, error: "image required" }, { status: 400 }), req)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const imageInput = multimodalService.normalizeImageFromChannel("api", body.image)
|
|
88
|
+
const text = await multimodalService.ocrImage(imageInput, body.provider)
|
|
89
|
+
return addCorsHeaders(Response.json({ success: true, text }), req)
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return addCorsHeaders(Response.json({ success: false, error: (error as Error).message }, { status: 500 }), req)
|
|
92
|
+
}
|
|
93
|
+
}
|