profclaw 2.0.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +14 -2
- package/CHANGELOG.md +52 -0
- package/CONTRIBUTING.md +20 -0
- package/Dockerfile +39 -23
- package/README.md +178 -41
- package/config/pricing.yml +26 -2
- package/dist/agents/agent-summary.d.ts +44 -0
- package/dist/agents/agent-summary.js +176 -0
- package/dist/agents/auto-memory.d.ts +59 -0
- package/dist/agents/auto-memory.js +310 -0
- package/dist/agents/checkpoint-manager.d.ts +76 -0
- package/dist/agents/checkpoint-manager.js +156 -0
- package/dist/agents/circuit-breaker.d.ts +54 -0
- package/dist/agents/circuit-breaker.js +153 -0
- package/dist/agents/command-sandbox.d.ts +93 -0
- package/dist/agents/command-sandbox.js +235 -0
- package/dist/agents/context-compactor.d.ts +70 -0
- package/dist/agents/context-compactor.js +361 -0
- package/dist/agents/conversation-branch.d.ts +55 -0
- package/dist/agents/conversation-branch.js +115 -0
- package/dist/agents/error-recovery.d.ts +44 -0
- package/dist/agents/error-recovery.js +197 -0
- package/dist/agents/events.d.ts +76 -0
- package/dist/agents/events.js +8 -0
- package/dist/agents/executor-runner.d.ts +135 -0
- package/dist/agents/executor-runner.js +303 -0
- package/dist/agents/executor.d.ts +37 -1
- package/dist/agents/executor.js +606 -124
- package/dist/agents/file-snapshots.d.ts +72 -0
- package/dist/agents/file-snapshots.js +182 -0
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/orchestrator.d.ts +183 -0
- package/dist/agents/orchestrator.js +495 -0
- package/dist/agents/output-truncator.d.ts +59 -0
- package/dist/agents/output-truncator.js +128 -0
- package/dist/agents/permissions.d.ts +63 -0
- package/dist/agents/permissions.js +138 -0
- package/dist/agents/plan-mode.d.ts +71 -0
- package/dist/agents/plan-mode.js +186 -0
- package/dist/agents/prompt-suggestions.d.ts +33 -0
- package/dist/agents/prompt-suggestions.js +208 -0
- package/dist/agents/rate-limit-monitor.d.ts +56 -0
- package/dist/agents/rate-limit-monitor.js +224 -0
- package/dist/agents/receipt/receipt-cli.d.ts +43 -0
- package/dist/agents/receipt/receipt-cli.js +82 -0
- package/dist/agents/receipt/receipt-types.d.ts +136 -0
- package/dist/agents/receipt/receipt-types.js +19 -0
- package/dist/agents/receipt/receipt-verify.d.ts +19 -0
- package/dist/agents/receipt/receipt-verify.js +176 -0
- package/dist/agents/receipt/receipt-view.d.ts +29 -0
- package/dist/agents/receipt/receipt-view.js +227 -0
- package/dist/agents/receipt/receipt-writer.d.ts +47 -0
- package/dist/agents/receipt/receipt-writer.js +186 -0
- package/dist/agents/result-store.d.ts +43 -0
- package/dist/agents/result-store.js +145 -0
- package/dist/agents/session-diff.d.ts +49 -0
- package/dist/agents/session-diff.js +249 -0
- package/dist/agents/tool-loader.d.ts +65 -0
- package/dist/agents/tool-loader.js +273 -0
- package/dist/agents/tool-selector.d.ts +123 -0
- package/dist/agents/tool-selector.js +321 -0
- package/dist/agents/transcript.d.ts +96 -0
- package/dist/agents/transcript.js +267 -0
- package/dist/agents/verified-run-git.d.ts +49 -0
- package/dist/agents/verified-run-git.js +82 -0
- package/dist/agents/verified-run.d.ts +149 -0
- package/dist/agents/verified-run.js +402 -0
- package/dist/agents/verifier.d.ts +64 -0
- package/dist/agents/verifier.js +186 -0
- package/dist/agents/worktree-manager.d.ts +80 -0
- package/dist/agents/worktree-manager.js +203 -0
- package/dist/agents/worktree-tools.d.ts +47 -0
- package/dist/agents/worktree-tools.js +246 -0
- package/dist/auth/middleware.js +14 -0
- package/dist/chat/agentic-executor.d.ts +7 -0
- package/dist/chat/agentic-executor.js +263 -32
- package/dist/chat/conversations.d.ts +2 -0
- package/dist/chat/conversations.js +8 -0
- package/dist/chat/execution/executor.d.ts +8 -0
- package/dist/chat/execution/executor.js +157 -103
- package/dist/chat/execution/index.js +5 -1
- package/dist/chat/execution/sandbox.d.ts +8 -0
- package/dist/chat/execution/sandbox.js +25 -1
- package/dist/chat/execution/tool-router.js +40 -14
- package/dist/chat/execution/tools/canvas.d.ts +2 -2
- package/dist/chat/execution/tools/code-tools.d.ts +66 -0
- package/dist/chat/execution/tools/code-tools.js +353 -0
- package/dist/chat/execution/tools/complete-task.d.ts +2 -2
- package/dist/chat/execution/tools/cron-tool.d.ts +26 -10
- package/dist/chat/execution/tools/cron-tool.js +48 -3
- package/dist/chat/execution/tools/decompose-task.d.ts +58 -0
- package/dist/chat/execution/tools/decompose-task.js +166 -0
- package/dist/chat/execution/tools/exec.d.ts +5 -2
- package/dist/chat/execution/tools/exec.js +294 -155
- package/dist/chat/execution/tools/feed-tools.d.ts +77 -0
- package/dist/chat/execution/tools/feed-tools.js +142 -0
- package/dist/chat/execution/tools/file-ops.d.ts +1 -1
- package/dist/chat/execution/tools/github.d.ts +2 -2
- package/dist/chat/execution/tools/index.d.ts +14 -2
- package/dist/chat/execution/tools/index.js +86 -12
- package/dist/chat/execution/tools/integrations.d.ts +8 -8
- package/dist/chat/execution/tools/multi-patch.d.ts +53 -0
- package/dist/chat/execution/tools/multi-patch.js +373 -0
- package/dist/chat/execution/tools/openai-image-gen.d.ts +2 -2
- package/dist/chat/execution/tools/plan-tools.d.ts +80 -0
- package/dist/chat/execution/tools/plan-tools.js +134 -0
- package/dist/chat/execution/tools/profclaw-ops.d.ts +6 -6
- package/dist/chat/execution/tools/repl-tool.d.ts +46 -0
- package/dist/chat/execution/tools/repl-tool.js +207 -0
- package/dist/chat/execution/tools/sessions-send.d.ts +2 -2
- package/dist/chat/execution/tools/slack-actions.d.ts +2 -2
- package/dist/chat/execution/tools/system.d.ts +4 -4
- package/dist/chat/execution/tools/todo-tool.d.ts +72 -0
- package/dist/chat/execution/tools/todo-tool.js +152 -0
- package/dist/chat/execution/tools/tool-search.d.ts +50 -0
- package/dist/chat/execution/tools/tool-search.js +155 -0
- package/dist/chat/execution/tools/tts-speak.d.ts +2 -2
- package/dist/chat/execution/types.d.ts +21 -14
- package/dist/chat/execution/workflows/executor.d.ts +11 -0
- package/dist/chat/execution/workflows/executor.js +99 -1
- package/dist/chat/execution/workflows/types.d.ts +35 -2
- package/dist/chat/format/index.d.ts +1 -0
- package/dist/chat/format/index.js +1 -0
- package/dist/chat/format/markdown-convert.d.ts +23 -0
- package/dist/chat/format/markdown-convert.js +149 -0
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/chat/message-handler.js +58 -6
- package/dist/chat/meta-tool-handlers.d.ts +18 -0
- package/dist/chat/meta-tool-handlers.js +51 -0
- package/dist/chat/proactive/index.d.ts +62 -0
- package/dist/chat/proactive/index.js +147 -0
- package/dist/chat/prompt-adapter.js +2 -0
- package/dist/chat/providers/irc/index.d.ts +2 -2
- package/dist/chat/providers/telegram/index.d.ts +2 -0
- package/dist/chat/providers/telegram/index.js +21 -2
- package/dist/chat/system-prompts.d.ts +3 -3
- package/dist/chat/system-prompts.js +121 -61
- package/dist/chat/tool-handler.d.ts +2 -0
- package/dist/chat/tool-handler.js +47 -3
- package/dist/chat/tools.d.ts +6 -6
- package/dist/cli/commands/auth.js +64 -1
- package/dist/cli/commands/chat.js +1327 -138
- package/dist/cli/commands/doctor.js +222 -16
- package/dist/cli/commands/history.d.ts +3 -0
- package/dist/cli/commands/history.js +138 -0
- package/dist/cli/commands/import.d.ts +44 -0
- package/dist/cli/commands/import.js +526 -0
- package/dist/cli/commands/init.d.ts +13 -0
- package/dist/cli/commands/init.js +381 -0
- package/dist/cli/commands/onboard.js +210 -30
- package/dist/cli/commands/plan.d.ts +13 -0
- package/dist/cli/commands/plan.js +184 -0
- package/dist/cli/commands/receipt.d.ts +7 -0
- package/dist/cli/commands/receipt.js +90 -0
- package/dist/cli/commands/run.d.ts +28 -0
- package/dist/cli/commands/run.js +204 -0
- package/dist/cli/commands/serve.d.ts +7 -0
- package/dist/cli/commands/serve.js +77 -18
- package/dist/cli/commands/setup.js +84 -3
- package/dist/cli/commands/status.js +54 -0
- package/dist/cli/commands/tools.js +13 -13
- package/dist/cli/commands/tui.js +26 -1
- package/dist/cli/index.js +23 -0
- package/dist/cli/ink/App.d.ts +13 -0
- package/dist/cli/ink/App.js +6 -0
- package/dist/cli/ink/ChatApp.d.ts +60 -0
- package/dist/cli/ink/ChatApp.js +325 -0
- package/dist/cli/ink/DashboardApp.d.ts +3 -0
- package/dist/cli/ink/DashboardApp.js +143 -0
- package/dist/cli/ink/components/AgentStatus.d.ts +17 -0
- package/dist/cli/ink/components/AgentStatus.js +33 -0
- package/dist/cli/ink/components/ChannelList.d.ts +17 -0
- package/dist/cli/ink/components/ChannelList.js +33 -0
- package/dist/cli/ink/components/ConnectionStatus.d.ts +19 -0
- package/dist/cli/ink/components/ConnectionStatus.js +50 -0
- package/dist/cli/ink/components/CostBar.d.ts +19 -0
- package/dist/cli/ink/components/CostBar.js +35 -0
- package/dist/cli/ink/components/HookStatus.d.ts +15 -0
- package/dist/cli/ink/components/HookStatus.js +7 -0
- package/dist/cli/ink/components/PermissionPrompt.d.ts +21 -0
- package/dist/cli/ink/components/PermissionPrompt.js +51 -0
- package/dist/cli/ink/components/PlanView.d.ts +23 -0
- package/dist/cli/ink/components/PlanView.js +26 -0
- package/dist/cli/ink/components/ProviderList.d.ts +16 -0
- package/dist/cli/ink/components/ProviderList.js +16 -0
- package/dist/cli/ink/components/SessionHeader.d.ts +15 -0
- package/dist/cli/ink/components/SessionHeader.js +15 -0
- package/dist/cli/ink/components/StreamingMessage.d.ts +20 -0
- package/dist/cli/ink/components/StreamingMessage.js +27 -0
- package/dist/cli/ink/components/SuggestionBar.d.ts +15 -0
- package/dist/cli/ink/components/SuggestionBar.js +28 -0
- package/dist/cli/ink/components/SystemHealth.d.ts +20 -0
- package/dist/cli/ink/components/SystemHealth.js +39 -0
- package/dist/cli/ink/components/TaskList.d.ts +17 -0
- package/dist/cli/ink/components/TaskList.js +59 -0
- package/dist/cli/ink/components/ToolCall.d.ts +17 -0
- package/dist/cli/ink/components/ToolCall.js +43 -0
- package/dist/cli/ink/index.d.ts +23 -0
- package/dist/cli/ink/index.js +15 -0
- package/dist/cli/ink/keybindings.d.ts +35 -0
- package/dist/cli/ink/keybindings.js +105 -0
- package/dist/cli/ink/markdown-renderer.d.ts +47 -0
- package/dist/cli/ink/markdown-renderer.js +380 -0
- package/dist/cli/ink/output-styles.d.ts +39 -0
- package/dist/cli/ink/output-styles.js +119 -0
- package/dist/cli/interactive/auto-serve.d.ts +38 -0
- package/dist/cli/interactive/auto-serve.js +209 -0
- package/dist/cli/interactive/index.d.ts +25 -0
- package/dist/cli/interactive/index.js +23 -0
- package/dist/cli/interactive/picker.d.ts +28 -0
- package/dist/cli/interactive/picker.js +153 -0
- package/dist/cli/interactive/renderer.d.ts +26 -0
- package/dist/cli/interactive/renderer.js +555 -0
- package/dist/cli/interactive/repl.d.ts +14 -0
- package/dist/cli/interactive/repl.js +1516 -0
- package/dist/cli/interactive/stream-client.d.ts +59 -0
- package/dist/cli/interactive/stream-client.js +506 -0
- package/dist/cli/interactive/types.d.ts +121 -0
- package/dist/cli/interactive/types.js +10 -0
- package/dist/cli/utils/api.d.ts +9 -0
- package/dist/cli/utils/api.js +58 -2
- package/dist/costs/token-tracker.d.ts +10 -1
- package/dist/costs/token-tracker.js +37 -5
- package/dist/cron/natural-language.d.ts +54 -0
- package/dist/cron/natural-language.js +569 -0
- package/dist/cron/scheduler.d.ts +34 -4
- package/dist/cron/scheduler.js +141 -9
- package/dist/cron/templates.d.ts +1 -1
- package/dist/cron/templates.js +219 -0
- package/dist/feeds/feed-engine.d.ts +149 -0
- package/dist/feeds/feed-engine.js +600 -0
- package/dist/feeds/index.d.ts +9 -0
- package/dist/feeds/index.js +8 -0
- package/dist/gateway/router.js +6 -1
- package/dist/hooks/built-in/audit-log.d.ts +11 -0
- package/dist/hooks/built-in/audit-log.js +84 -0
- package/dist/hooks/built-in/cost-warning.d.ts +10 -0
- package/dist/hooks/built-in/cost-warning.js +59 -0
- package/dist/hooks/built-in/dangerous-tool.d.ts +32 -0
- package/dist/hooks/built-in/dangerous-tool.js +80 -0
- package/dist/hooks/built-in/index.d.ts +14 -0
- package/dist/hooks/built-in/index.js +20 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/loader.d.ts +17 -0
- package/dist/hooks/loader.js +142 -0
- package/dist/hooks/registry.d.ts +62 -0
- package/dist/hooks/registry.js +127 -0
- package/dist/integrations/web-search.js +6 -3
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.js +2 -0
- package/dist/memory/memory-service.js +14 -13
- package/dist/memory/observational.d.ts +62 -0
- package/dist/memory/observational.js +396 -0
- package/dist/middleware/content-filter.d.ts +22 -0
- package/dist/middleware/content-filter.js +69 -0
- package/dist/middleware/request-validator.d.ts +159 -0
- package/dist/middleware/request-validator.js +93 -0
- package/dist/plugins/sdk.d.ts +22 -0
- package/dist/plugins/sdk.js +17 -1
- package/dist/projects/types.d.ts +10 -10
- package/dist/providers/ai-sdk.d.ts +11 -0
- package/dist/providers/ai-sdk.js +111 -56
- package/dist/providers/core/models.js +114 -6
- package/dist/providers/core/types.d.ts +7 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/prompt-cache.d.ts +68 -0
- package/dist/providers/prompt-cache.js +165 -0
- package/dist/providers/smart-router.d.ts +118 -0
- package/dist/providers/smart-router.js +693 -0
- package/dist/providers/types.d.ts +16 -16
- package/dist/routes/agents.js +50 -0
- package/dist/routes/auth.js +8 -1
- package/dist/routes/chat.js +280 -18
- package/dist/routes/costs.js +32 -0
- package/dist/routes/cron.js +80 -5
- package/dist/routes/feeds.d.ts +10 -0
- package/dist/routes/feeds.js +168 -0
- package/dist/routes/mcp.js +21 -0
- package/dist/routes/memory.js +130 -0
- package/dist/routes/skills.js +129 -0
- package/dist/routes/teams.d.ts +9 -0
- package/dist/routes/teams.js +210 -0
- package/dist/routes/tools.js +14 -0
- package/dist/routes/users.js +2 -0
- package/dist/server/route-loader.js +3 -1
- package/dist/server/stream-bridge.d.ts +19 -0
- package/dist/server/stream-bridge.js +38 -0
- package/dist/server.js +313 -36
- package/dist/skills/marketplace.d.ts +87 -0
- package/dist/skills/marketplace.js +268 -0
- package/dist/storage/index.d.ts +14 -0
- package/dist/storage/index.js +64 -3
- package/dist/storage/schema.d.ts +4 -4
- package/dist/storage/schema.js +1 -1
- package/dist/teams/index.d.ts +110 -0
- package/dist/teams/index.js +365 -0
- package/dist/tickets/types.d.ts +39 -39
- package/dist/types/summary.d.ts +5 -5
- package/dist/utils/auto-update.d.ts +23 -0
- package/dist/utils/auto-update.js +157 -0
- package/dist/utils/offline-detect.d.ts +55 -0
- package/dist/utils/offline-detect.js +121 -0
- package/dist/utils/pid-file.d.ts +36 -0
- package/dist/utils/pid-file.js +125 -0
- package/dist/utils/prevent-sleep.d.ts +27 -0
- package/dist/utils/prevent-sleep.js +95 -0
- package/dist/utils/sanitizer.d.ts +57 -0
- package/dist/utils/sanitizer.js +174 -0
- package/docker-compose.yml +13 -137
- package/package.json +31 -6
- package/skills/deploy-cloudflare/SKILL.md +62 -0
- package/skills/deploy-vercel/SKILL.md +67 -0
- package/skills/docker-deploy/SKILL.md +158 -0
- package/skills/full-stack-builder/SKILL.md +92 -0
- package/skills/humanizer/SKILL.md +488 -0
- package/skills/profclaw-assistant/SKILL.md +85 -56
- package/ui/dist/assets/ActivityView-Da6HQ8ws.js +1 -0
- package/ui/dist/assets/AgentList-H58R0kX3.js +1 -0
- package/ui/dist/assets/AnalyticsDashboard-B28AeRsc.js +1 -0
- package/ui/dist/assets/AreaChart-DwLzeAQ8.js +1 -0
- package/ui/dist/assets/CartesianChart-piKQsTAR.js +36 -0
- package/ui/dist/assets/ChatView-Dbj8rxU5.js +10 -0
- package/ui/dist/assets/CostsDashboard-C6F5df0F.js +1 -0
- package/ui/dist/assets/EstimateSelect-wga0rUKX.js +1 -0
- package/ui/dist/assets/FeedDashboard-Ef6FEzEf.js +1 -0
- package/ui/dist/assets/FloatingChatbot-0yhkUeCq.js +2 -0
- package/ui/dist/assets/InviteCodeManagement-tUXfx4Bc.js +2 -0
- package/ui/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/ui/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/ui/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/ui/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/ui/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/ui/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/ui/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/ui/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/ui/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/ui/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/ui/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/ui/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/ui/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/ui/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/ui/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/ui/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/ui/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/ui/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/ui/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/ui/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/ui/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/ui/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/ui/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/ui/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/ui/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/ui/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/ui/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/ui/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/ui/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/ui/dist/assets/MarketplacePage-DGrLtolR.js +1 -0
- package/ui/dist/assets/{ProjectDetail--gPfvATB.js → ProjectDetail-BgWvA6UP.js} +2 -2
- package/ui/dist/assets/ProjectIcon-TDuliqwg.js +1 -0
- package/ui/dist/assets/ProjectList-DXgM4187.js +1 -0
- package/ui/dist/assets/{Settings-1kaf7VHE.js → Settings-xA8Zhi3p.js} +3 -3
- package/ui/dist/assets/StatusIndicator-B8vfFAxg.js +1 -0
- package/ui/dist/assets/{SummaryDetail-DV3AmONk.js → SummaryDetail-eedRfTtF.js} +2 -2
- package/ui/dist/assets/SummaryList-CLNX2P84.js +1 -0
- package/ui/dist/assets/TaskDetail-BtWclNiR.js +1 -0
- package/ui/dist/assets/TaskList-JjODAgSc.js +1 -0
- package/ui/dist/assets/TeamsPage-CBK5iAyx.js +1 -0
- package/ui/dist/assets/TicketBoard-C9aJNNYp.js +1 -0
- package/ui/dist/assets/TicketDetail-CV5JmL31.js +1 -0
- package/ui/dist/assets/TicketList-68V4lzUz.js +1 -0
- package/ui/dist/assets/UserManagement-DKTb6UpE.js +2 -0
- package/ui/dist/assets/ViewSwitcher-BvdQht2Y.js +1 -0
- package/ui/dist/assets/alert-dialog-O6qBOv_f.js +1 -0
- package/ui/dist/assets/{archive-BsLa7brF.js → archive-CX7UvZpf.js} +1 -1
- package/ui/dist/assets/badge-BbfnwDJP.js +1 -0
- package/ui/dist/assets/{bug-CmZI7jqM.js → bug-3WX0394-.js} +1 -1
- package/ui/dist/assets/{calendar-Bf0t2B82.js → calendar-buq77TaS.js} +1 -1
- package/ui/dist/assets/{chevron-up-CoUsOvZj.js → chevron-up-4ymsBJRo.js} +1 -1
- package/ui/dist/assets/{circle-x-Dgw11LgT.js → circle-x-ByXtwR6Y.js} +1 -1
- package/ui/dist/assets/constants-CVdDh7p0.js +1 -0
- package/ui/dist/assets/{cpu-DiPMQICV.js → cpu-CiuoCeDY.js} +1 -1
- package/ui/dist/assets/{database-BwTfupDi.js → database-BWXSBg5a.js} +1 -1
- package/ui/dist/assets/dialog-lDg4NvMV.js +1 -0
- package/ui/dist/assets/dollar-sign-Dmijd6DP.js +1 -0
- package/ui/dist/assets/{ellipsis-UJx4Xnf6.js → ellipsis-vT-5SVIp.js} +1 -1
- package/ui/dist/assets/{ellipsis-vertical-DoULYEKn.js → ellipsis-vertical-B4tAX_bL.js} +1 -1
- package/ui/dist/assets/feature-markdown-DBo5Q7uq.js +289 -0
- package/ui/dist/assets/{file-code-B2UrJLwi.js → file-code-ChOWdKXf.js} +1 -1
- package/ui/dist/assets/{folder-open-BJi577JH.js → folder-open-CkOUbIiP.js} +1 -1
- package/ui/dist/assets/{funnel-PkaD_HSR.js → funnel-uZkoSPP-.js} +1 -1
- package/ui/dist/assets/{git-branch-C_K30am0.js → git-branch-CwvUxj7C.js} +1 -1
- package/ui/dist/assets/{git-commit-horizontal-IT6ecxWQ.js → git-commit-horizontal-lxPzCvhD.js} +1 -1
- package/ui/dist/assets/{globe-f-jjCa_g.js → globe-D_WpJdsj.js} +1 -1
- package/ui/dist/assets/{hash-DNEv8Elo.js → hash-CA0hJ7vh.js} +1 -1
- package/ui/dist/assets/{history-BQSBo_1Q.js → history-CEWMLELs.js} +1 -1
- package/ui/dist/assets/inbox-ehtOptTV.js +1 -0
- package/ui/dist/assets/{index-nS3EErDg.js → index-C1rhbml4.js} +3 -3
- package/ui/dist/assets/index-CR8gfCHv.js +1 -0
- package/ui/dist/assets/index-DVXMpWai.js +1 -0
- package/ui/dist/assets/index-DaDJMM2v.js +1 -0
- package/ui/dist/assets/index-Djdq_0xu.js +1 -0
- package/ui/dist/assets/index-M46Gcb8K.css +1 -0
- package/ui/dist/assets/index-sEBN7w8J.js +109 -0
- package/ui/dist/assets/layers-C6Mhf8Nk.js +1 -0
- package/ui/dist/assets/{layout-dashboard-CcKt1hXw.js → layout-dashboard-BRUM0kpT.js} +1 -1
- package/ui/dist/assets/{lightbulb-Jhp7FvbU.js → lightbulb-CN2q1O5l.js} +1 -1
- package/ui/dist/assets/{link-2-DdO7ostF.js → link-2-CC4E28yJ.js} +1 -1
- package/ui/dist/assets/markdown-renderer-C6ENbB0u.js +10 -0
- package/ui/dist/assets/markdown-renderer-CfVKi3_s.css +1 -0
- package/ui/dist/assets/{message-square-CBgH65X7.js → message-square-Bbb241am.js} +1 -1
- package/ui/dist/assets/package-CwT3IzFx.js +1 -0
- package/ui/dist/assets/{pencil-CYXCEPQh.js → pencil-CDmiHzoj.js} +1 -1
- package/ui/dist/assets/{play-d1ONaH0-.js → play-tjy5jMQX.js} +1 -1
- package/ui/dist/assets/popover-CFHZf3pE.js +1 -0
- package/ui/dist/assets/progress-BboUHuLf.js +1 -0
- package/ui/dist/assets/{rocket-DhvUetsk.js → rocket--8ZHgdXJ.js} +1 -1
- package/ui/dist/assets/select-n108rXny.js +1 -0
- package/ui/dist/assets/{send-P0r5D7td.js → send-Cu7MR2Qh.js} +1 -1
- package/ui/dist/assets/server-DmodxZp-.js +1 -0
- package/ui/dist/assets/{settings-2-ocj5uHGx.js → settings-2-CkRNqkxj.js} +1 -1
- package/ui/dist/assets/sheet-7aUJkyzU.js +1 -0
- package/ui/dist/assets/{shield-check-DfVdE34l.js → shield-check-ViI3nMKE.js} +1 -1
- package/ui/dist/assets/{shield-off-8l0J6R-8.js → shield-off-DN3tagkn.js} +1 -1
- package/ui/dist/assets/skeleton-C0E1Nfro.js +1 -0
- package/ui/dist/assets/{smartphone-77_g3SQn.js → smartphone-5FghiXpA.js} +1 -1
- package/ui/dist/assets/{square-Ckzsr3Rn.js → square-DiNSx8K7.js} +1 -1
- package/ui/dist/assets/star-DhdFVidS.js +1 -0
- package/ui/dist/assets/switch-CIgVbZqQ.js +1 -0
- package/ui/dist/assets/table-BC56FVMV.js +1 -0
- package/ui/dist/assets/{tag-C35mgoEv.js → tag-CH_vQliw.js} +1 -1
- package/ui/dist/assets/textarea-CxDiKFXZ.js +1 -0
- package/ui/dist/assets/{timer-DHJBS2w1.js → timer-CdGVTb60.js} +1 -1
- package/ui/dist/assets/tooltip-BuW9A5UO.js +1 -0
- package/ui/dist/assets/{trash-2-keO5tKPE.js → trash-2-CucZJL0N.js} +1 -1
- package/ui/dist/assets/trending-down-BCezC1z2.js +1 -0
- package/ui/dist/assets/{trending-up-BBv8KbrY.js → trending-up-C5OYX2k2.js} +1 -1
- package/ui/dist/assets/vendor-query-C0p7b53x.js +4 -0
- package/ui/dist/assets/vendor-react-Mc5_kfYG.js +12 -0
- package/ui/dist/assets/vendor-ui-CXPAUBFv.js +51 -0
- package/ui/dist/assets/{wand-sparkles-BusQ52ZK.js → wand-sparkles-BaH6pJnc.js} +1 -1
- package/ui/dist/assets/{wrench-02YaOSiK.js → wrench-CjxjP6ok.js} +1 -1
- package/ui/dist/index.html +5 -2
- package/ui/dist/assets/ActivityView-BeshZXmE.js +0 -1
- package/ui/dist/assets/AgentList-QVHeldPi.js +0 -1
- package/ui/dist/assets/AnalyticsDashboard-C9R97dXE.js +0 -1
- package/ui/dist/assets/AreaChart-B73gaiVQ.js +0 -1
- package/ui/dist/assets/CartesianChart-CXYL2R-A.js +0 -36
- package/ui/dist/assets/ChatView-qjZErlrp.js +0 -10
- package/ui/dist/assets/CostsDashboard-O4DCLy1i.js +0 -1
- package/ui/dist/assets/EstimateSelect-1hQf4Osk.js +0 -1
- package/ui/dist/assets/FloatingChatbot-BZBzrJxd.js +0 -2
- package/ui/dist/assets/InviteCodeManagement-LEoGqYeA.js +0 -2
- package/ui/dist/assets/ProjectIcon-Chd_ofsw.js +0 -1
- package/ui/dist/assets/ProjectList-BvUfVB6c.js +0 -4
- package/ui/dist/assets/StatusIndicator-pRfkNcdV.js +0 -1
- package/ui/dist/assets/SummaryList-B6kXiTxL.js +0 -1
- package/ui/dist/assets/TaskDetail-CV6CzbOS.js +0 -1
- package/ui/dist/assets/TaskList-DL7brQKd.js +0 -1
- package/ui/dist/assets/TicketBoard-CrkkFj7C.js +0 -1
- package/ui/dist/assets/TicketDetail-hnnYclpD.js +0 -1
- package/ui/dist/assets/TicketList-CsDAyQCL.js +0 -1
- package/ui/dist/assets/UserManagement-BGFQyTSr.js +0 -2
- package/ui/dist/assets/ViewSwitcher-CnL0OqA8.js +0 -1
- package/ui/dist/assets/alert-dialog-SKM6Gjz4.js +0 -7
- package/ui/dist/assets/badge-CVHH1a-v.js +0 -1
- package/ui/dist/assets/brain-6o_RHVpe.js +0 -1
- package/ui/dist/assets/constants-Q5Zivl-a.js +0 -1
- package/ui/dist/assets/dialog-BUqN9Psj.js +0 -1
- package/ui/dist/assets/index-BUmnwPQr.js +0 -1
- package/ui/dist/assets/index-BfF5G4Cw.js +0 -1
- package/ui/dist/assets/index-C8N375c2.js +0 -1
- package/ui/dist/assets/index-CuxnqVVz.css +0 -1
- package/ui/dist/assets/index-CzMM3QOk.js +0 -1
- package/ui/dist/assets/index-lJlNPFVJ.js +0 -67
- package/ui/dist/assets/layers-jFqVrWMD.js +0 -1
- package/ui/dist/assets/markdown-renderer-n1ToC4XQ.js +0 -36
- package/ui/dist/assets/popover-CrmZgoWu.js +0 -1
- package/ui/dist/assets/progress-uv4SPkL5.js +0 -1
- package/ui/dist/assets/select-CeQ8AHGy.js +0 -1
- package/ui/dist/assets/server-CVHTZB72.js +0 -1
- package/ui/dist/assets/sheet-DuQExSho.js +0 -1
- package/ui/dist/assets/skeleton-TFiFJ3nB.js +0 -1
- package/ui/dist/assets/switch-CAePkd6k.js +0 -1
- package/ui/dist/assets/table-ZjAZ7hkt.js +0 -1
- package/ui/dist/assets/textarea-DsVPnSgR.js +0 -1
- package/ui/dist/assets/tooltip-BYmQ331W.js +0 -1
package/dist/providers/ai-sdk.js
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://sdk.vercel.ai/docs
|
|
8
8
|
*/
|
|
9
|
-
import { generateText, streamText, tool as createTool, jsonSchema } from 'ai';
|
|
9
|
+
import { generateText, streamText, stepCountIs, tool as createTool, jsonSchema } from 'ai';
|
|
10
10
|
// Provider SDKs are lazily imported inside ensureProvider() to reduce startup memory
|
|
11
11
|
// (each SDK is ~15MB; loading all 6 at startup costs ~100MB even if unused)
|
|
12
12
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
13
13
|
import { randomUUID } from 'node:crypto';
|
|
14
14
|
import { logger } from '../utils/logger.js';
|
|
15
15
|
import { normalizeToolSchema } from './schema-utils.js';
|
|
16
|
+
import { aggregateStepUsage, applyAnthropicMessageCache, applyAnthropicToolCache, calculateCachedInputCost, getCacheConfigForModel, extractCacheUsage, } from './prompt-cache.js';
|
|
16
17
|
// AI provider resilience settings (configurable via env)
|
|
17
18
|
const AI_TIMEOUT_MS = parseInt(process.env['AI_PROVIDER_TIMEOUT_MS'] ?? '120000', 10);
|
|
18
19
|
const AI_MAX_RETRIES = parseInt(process.env['AI_MAX_RETRIES'] ?? '2', 10);
|
|
@@ -26,8 +27,12 @@ async function withRetry(fn, maxRetries = AI_MAX_RETRIES) {
|
|
|
26
27
|
return await fn();
|
|
27
28
|
}
|
|
28
29
|
catch (error) {
|
|
29
|
-
const
|
|
30
|
-
|
|
30
|
+
const msg = error instanceof Error ? error.message : '';
|
|
31
|
+
// Don't retry quota exhaustion — it won't resolve with backoff
|
|
32
|
+
const isQuotaError = /quota|exceeded your current|billing/i.test(msg);
|
|
33
|
+
const isRetryable = !isQuotaError &&
|
|
34
|
+
error instanceof Error &&
|
|
35
|
+
(/429|503|rate.limit|too.many|service.unavailable|ECONNRESET|ETIMEDOUT|fetch.failed/i.test(msg));
|
|
31
36
|
if (!isRetryable || attempt === maxRetries)
|
|
32
37
|
throw error;
|
|
33
38
|
const delay = Math.min(1000 * 2 ** attempt, 10000);
|
|
@@ -49,7 +54,7 @@ const PROVIDER_DEFAULT_MODEL = {
|
|
|
49
54
|
anthropic: 'claude-sonnet-4-5-20250929',
|
|
50
55
|
openai: 'gpt-4o',
|
|
51
56
|
google: 'gemini-2.0-flash',
|
|
52
|
-
azure: 'gpt-4o',
|
|
57
|
+
azure: 'gpt-4o', // Resolved at runtime via deploymentName config
|
|
53
58
|
groq: 'llama-3.3-70b-versatile',
|
|
54
59
|
cerebras: 'llama-3.3-70b',
|
|
55
60
|
fireworks: 'accounts/fireworks/models/llama-v3p1-70b-instruct',
|
|
@@ -172,17 +177,17 @@ class AIProviderManager {
|
|
|
172
177
|
enabled: true,
|
|
173
178
|
});
|
|
174
179
|
}
|
|
175
|
-
// Azure OpenAI (supports both
|
|
180
|
+
// Azure OpenAI (supports both base URL and resource name modes)
|
|
176
181
|
if (process.env.AZURE_OPENAI_API_KEY) {
|
|
177
|
-
// Check if using Foundry (custom base URL) or standard (resource name)
|
|
178
182
|
const baseUrl = process.env.AZURE_OPENAI_BASE_URL || process.env.AZURE_OPENAI_ENDPOINT;
|
|
179
|
-
const resourceName = process.env.AZURE_OPENAI_RESOURCE_NAME;
|
|
183
|
+
const resourceName = process.env.AZURE_OPENAI_RESOURCE_NAME || process.env.AZURE_RESOURCE_NAME;
|
|
180
184
|
if (baseUrl || resourceName) {
|
|
181
185
|
this.configure('azure', {
|
|
182
186
|
type: 'azure',
|
|
183
187
|
apiKey: process.env.AZURE_OPENAI_API_KEY,
|
|
188
|
+
// Prefer explicit base URL over resource name (resource name constructs URL automatically)
|
|
184
189
|
baseUrl: baseUrl,
|
|
185
|
-
resourceName: resourceName,
|
|
190
|
+
resourceName: baseUrl ? undefined : resourceName, // Don't use resourceName if baseUrl is set
|
|
186
191
|
deploymentName: process.env.AZURE_OPENAI_DEPLOYMENT_NAME,
|
|
187
192
|
apiVersion: process.env.AZURE_OPENAI_API_VERSION,
|
|
188
193
|
enabled: true,
|
|
@@ -689,7 +694,7 @@ class AIProviderManager {
|
|
|
689
694
|
}
|
|
690
695
|
}
|
|
691
696
|
resolveModel(modelOrAlias) {
|
|
692
|
-
// Check if it's a full provider/model path
|
|
697
|
+
// Check if it's a full provider/model path (e.g. "azure/gpt4o", "ollama/llama3.2")
|
|
693
698
|
if (modelOrAlias.includes('/')) {
|
|
694
699
|
const [provider, model] = modelOrAlias.split('/');
|
|
695
700
|
return { provider: provider, model };
|
|
@@ -700,15 +705,35 @@ class AIProviderManager {
|
|
|
700
705
|
// For Azure, use the configured deployment name instead of the default alias model
|
|
701
706
|
if (alias.provider === 'azure') {
|
|
702
707
|
const azureConfig = this.configs.get('azure');
|
|
703
|
-
|
|
704
|
-
|
|
708
|
+
const azureModel = azureConfig?.defaultModel
|
|
709
|
+
|| azureConfig?.deploymentName
|
|
710
|
+
|| process.env.AZURE_OPENAI_DEPLOYMENT_NAME;
|
|
711
|
+
if (azureModel) {
|
|
712
|
+
return { provider: 'azure', model: azureModel };
|
|
705
713
|
}
|
|
706
714
|
}
|
|
707
|
-
|
|
715
|
+
// If the alias points to a configured provider, use it directly
|
|
716
|
+
if (this.isConfigured(alias.provider)) {
|
|
717
|
+
return alias;
|
|
718
|
+
}
|
|
719
|
+
// If the alias provider isn't configured, try Azure as a fallback
|
|
720
|
+
// (Azure can serve OpenAI models like gpt-4o via deployment names)
|
|
721
|
+
if (this.isConfigured('azure') && (alias.provider === 'openai')) {
|
|
722
|
+
return this.resolveToAzureDeployment(modelOrAlias);
|
|
723
|
+
}
|
|
708
724
|
}
|
|
709
725
|
// Try to find in catalog
|
|
710
726
|
const catalogModel = MODEL_CATALOG.find((m) => m.id === modelOrAlias);
|
|
711
727
|
if (catalogModel) {
|
|
728
|
+
// If the catalog provider is configured, use it
|
|
729
|
+
if (this.isConfigured(catalogModel.provider)) {
|
|
730
|
+
return { provider: catalogModel.provider, model: catalogModel.id };
|
|
731
|
+
}
|
|
732
|
+
// OpenAI models can be served by Azure via deployment names
|
|
733
|
+
if (catalogModel.provider === 'openai' && this.isConfigured('azure')) {
|
|
734
|
+
return this.resolveToAzureDeployment(modelOrAlias);
|
|
735
|
+
}
|
|
736
|
+
// Fallback: use catalog as-is (will fail at API call time with clear error)
|
|
712
737
|
return { provider: catalogModel.provider, model: catalogModel.id };
|
|
713
738
|
}
|
|
714
739
|
// Default to the auto-selected default provider
|
|
@@ -717,6 +742,38 @@ class AIProviderManager {
|
|
|
717
742
|
const defaultModel = defaultConfig?.defaultModel || modelOrAlias;
|
|
718
743
|
return { provider: this.defaultProvider, model: defaultModel };
|
|
719
744
|
}
|
|
745
|
+
/**
|
|
746
|
+
* Get the default model for a provider, respecting runtime config.
|
|
747
|
+
* For Azure, uses the deployment name instead of the static "gpt-4o".
|
|
748
|
+
*/
|
|
749
|
+
getDefaultModelForProvider(provider) {
|
|
750
|
+
if (provider === 'azure') {
|
|
751
|
+
const config = this.configs.get('azure');
|
|
752
|
+
return config?.deploymentName
|
|
753
|
+
|| config?.defaultModel
|
|
754
|
+
|| process.env.AZURE_OPENAI_DEPLOYMENT_NAME
|
|
755
|
+
|| PROVIDER_DEFAULT_MODEL.azure
|
|
756
|
+
|| 'gpt-4o';
|
|
757
|
+
}
|
|
758
|
+
return PROVIDER_DEFAULT_MODEL[provider] || 'llama3.2';
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Resolve a model name to an Azure deployment.
|
|
762
|
+
* Azure uses deployment names (e.g. "gpt4o") instead of model IDs (e.g. "gpt-4o").
|
|
763
|
+
* Checks: configured deployment name → env var → strip dashes from model name.
|
|
764
|
+
*/
|
|
765
|
+
resolveToAzureDeployment(modelOrAlias) {
|
|
766
|
+
const azureConfig = this.configs.get('azure');
|
|
767
|
+
// Use configured deployment name if it looks like it matches the requested model
|
|
768
|
+
const deployment = azureConfig?.deploymentName
|
|
769
|
+
|| process.env.AZURE_OPENAI_DEPLOYMENT_NAME;
|
|
770
|
+
if (deployment) {
|
|
771
|
+
return { provider: 'azure', model: deployment };
|
|
772
|
+
}
|
|
773
|
+
// Try stripping dashes (gpt-4o → gpt4o) as Azure often uses this convention
|
|
774
|
+
const stripped = modelOrAlias.replace(/-/g, '');
|
|
775
|
+
return { provider: 'azure', model: stripped };
|
|
776
|
+
}
|
|
720
777
|
async getModel(provider, modelId) {
|
|
721
778
|
await this.ensureProvider(provider);
|
|
722
779
|
const key = this.providerKey(provider);
|
|
@@ -758,9 +815,12 @@ class AIProviderManager {
|
|
|
758
815
|
// Azure uses .chat() method for deployment-based access
|
|
759
816
|
if (provider === 'azure') {
|
|
760
817
|
let deployment = modelId;
|
|
761
|
-
if (
|
|
818
|
+
if (deployment === 'default' || !deployment) {
|
|
762
819
|
const azureConfig = this.configs.get('azure');
|
|
763
|
-
deployment = azureConfig?.defaultModel
|
|
820
|
+
deployment = azureConfig?.defaultModel
|
|
821
|
+
|| azureConfig?.deploymentName
|
|
822
|
+
|| process.env.AZURE_OPENAI_DEPLOYMENT_NAME
|
|
823
|
+
|| 'default';
|
|
764
824
|
if (deployment === 'default') {
|
|
765
825
|
throw new Error('Azure deployment not configured. Set defaultModel in Azure config or AZURE_OPENAI_DEPLOYMENT_NAME.');
|
|
766
826
|
}
|
|
@@ -793,7 +853,7 @@ class AIProviderManager {
|
|
|
793
853
|
// Resolve model
|
|
794
854
|
const modelRef = request.model
|
|
795
855
|
? this.resolveModel(request.model)
|
|
796
|
-
: { provider: this.defaultProvider, model:
|
|
856
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
797
857
|
const model = await this.getModel(modelRef.provider, modelRef.model);
|
|
798
858
|
// Convert messages to AI SDK format
|
|
799
859
|
const messages = request.messages.map((msg) => ({
|
|
@@ -807,7 +867,7 @@ class AIProviderManager {
|
|
|
807
867
|
try {
|
|
808
868
|
const result = await withRetry(() => generateText({
|
|
809
869
|
model,
|
|
810
|
-
messages,
|
|
870
|
+
messages: applyAnthropicMessageCache(messages, modelRef.provider),
|
|
811
871
|
temperature: request.temperature ?? 0.7,
|
|
812
872
|
maxOutputTokens: request.maxTokens ?? 4096,
|
|
813
873
|
abortSignal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
|
@@ -815,12 +875,9 @@ class AIProviderManager {
|
|
|
815
875
|
const duration = Date.now() - startTime;
|
|
816
876
|
const modelInfo = this.getModelInfo(modelRef.model);
|
|
817
877
|
// Calculate cost - AI SDK v6 uses usage.totalTokens and similar
|
|
818
|
-
const promptTokens = result.usage
|
|
819
|
-
result.usage?.inputTokens ?? 0;
|
|
820
|
-
const completionTokens = result.usage?.completionTokens ??
|
|
821
|
-
result.usage?.outputTokens ?? 0;
|
|
878
|
+
const { promptTokens, completionTokens, cacheReadTokens, cacheWriteTokens } = extractCacheUsage(result.usage);
|
|
822
879
|
const cost = modelInfo
|
|
823
|
-
? (promptTokens
|
|
880
|
+
? calculateCachedInputCost(promptTokens, cacheReadTokens, cacheWriteTokens, modelInfo.costPer1MInput, getCacheConfigForModel(modelInfo.id)) +
|
|
824
881
|
(completionTokens / 1_000_000) * modelInfo.costPer1MOutput
|
|
825
882
|
: 0;
|
|
826
883
|
return {
|
|
@@ -834,6 +891,8 @@ class AIProviderManager {
|
|
|
834
891
|
completionTokens,
|
|
835
892
|
totalTokens: promptTokens + completionTokens,
|
|
836
893
|
cost,
|
|
894
|
+
cacheReadTokens,
|
|
895
|
+
cacheWriteTokens,
|
|
837
896
|
},
|
|
838
897
|
duration,
|
|
839
898
|
};
|
|
@@ -851,7 +910,7 @@ class AIProviderManager {
|
|
|
851
910
|
// Resolve model
|
|
852
911
|
const modelRef = request.model
|
|
853
912
|
? this.resolveModel(request.model)
|
|
854
|
-
: { provider: this.defaultProvider, model:
|
|
913
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
855
914
|
const model = await this.getModel(modelRef.provider, modelRef.model);
|
|
856
915
|
// Convert messages
|
|
857
916
|
const messages = request.messages.map((msg) => ({
|
|
@@ -864,7 +923,7 @@ class AIProviderManager {
|
|
|
864
923
|
try {
|
|
865
924
|
const result = streamText({
|
|
866
925
|
model,
|
|
867
|
-
messages,
|
|
926
|
+
messages: applyAnthropicMessageCache(messages, modelRef.provider),
|
|
868
927
|
temperature: request.temperature ?? 0.7,
|
|
869
928
|
maxOutputTokens: request.maxTokens ?? 4096,
|
|
870
929
|
abortSignal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
|
@@ -894,12 +953,9 @@ class AIProviderManager {
|
|
|
894
953
|
const usage = await result.usage;
|
|
895
954
|
const duration = Date.now() - startTime;
|
|
896
955
|
const modelInfo = this.getModelInfo(modelRef.model);
|
|
897
|
-
const promptTokens = usage
|
|
898
|
-
usage?.inputTokens ?? 0;
|
|
899
|
-
const completionTokens = usage?.completionTokens ??
|
|
900
|
-
usage?.outputTokens ?? 0;
|
|
956
|
+
const { promptTokens, completionTokens, cacheReadTokens, cacheWriteTokens } = extractCacheUsage(usage);
|
|
901
957
|
const cost = modelInfo
|
|
902
|
-
? (promptTokens
|
|
958
|
+
? calculateCachedInputCost(promptTokens, cacheReadTokens, cacheWriteTokens, modelInfo.costPer1MInput, getCacheConfigForModel(modelInfo.id)) +
|
|
903
959
|
(completionTokens / 1_000_000) * modelInfo.costPer1MOutput
|
|
904
960
|
: 0;
|
|
905
961
|
return {
|
|
@@ -913,6 +969,8 @@ class AIProviderManager {
|
|
|
913
969
|
completionTokens,
|
|
914
970
|
totalTokens: promptTokens + completionTokens,
|
|
915
971
|
cost,
|
|
972
|
+
cacheReadTokens,
|
|
973
|
+
cacheWriteTokens,
|
|
916
974
|
},
|
|
917
975
|
duration,
|
|
918
976
|
};
|
|
@@ -931,7 +989,7 @@ class AIProviderManager {
|
|
|
931
989
|
// Resolve model
|
|
932
990
|
const modelRef = request.model
|
|
933
991
|
? this.resolveModel(request.model)
|
|
934
|
-
: { provider: this.defaultProvider, model:
|
|
992
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
935
993
|
const model = await this.getModel(modelRef.provider, modelRef.model);
|
|
936
994
|
// Check if model supports native tools
|
|
937
995
|
const toolSupport = this.modelSupportsTools(modelRef.model || modelRef.provider + '/' + modelRef.model);
|
|
@@ -980,10 +1038,10 @@ class AIProviderManager {
|
|
|
980
1038
|
try {
|
|
981
1039
|
const result = await withRetry(() => generateText({
|
|
982
1040
|
model,
|
|
983
|
-
messages,
|
|
1041
|
+
messages: applyAnthropicMessageCache(messages, modelRef.provider),
|
|
984
1042
|
temperature: request.temperature ?? 0.7,
|
|
985
1043
|
maxOutputTokens: request.maxTokens ?? 4096,
|
|
986
|
-
tools: useNativeTools ? aiSdkTools : undefined,
|
|
1044
|
+
tools: useNativeTools ? applyAnthropicToolCache(aiSdkTools, modelRef.provider) : undefined,
|
|
987
1045
|
abortSignal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
|
988
1046
|
}));
|
|
989
1047
|
let finalContent = result.text;
|
|
@@ -1042,12 +1100,9 @@ class AIProviderManager {
|
|
|
1042
1100
|
}
|
|
1043
1101
|
const duration = Date.now() - startTime;
|
|
1044
1102
|
const modelInfo = this.getModelInfo(modelRef.model);
|
|
1045
|
-
const promptTokens = result.usage
|
|
1046
|
-
result.usage?.inputTokens ?? 0;
|
|
1047
|
-
const completionTokens = result.usage?.completionTokens ??
|
|
1048
|
-
result.usage?.outputTokens ?? 0;
|
|
1103
|
+
const { promptTokens, completionTokens, cacheReadTokens, cacheWriteTokens } = extractCacheUsage(result.usage);
|
|
1049
1104
|
const cost = modelInfo
|
|
1050
|
-
? (promptTokens
|
|
1105
|
+
? calculateCachedInputCost(promptTokens, cacheReadTokens, cacheWriteTokens, modelInfo.costPer1MInput, getCacheConfigForModel(modelInfo.id)) +
|
|
1051
1106
|
(completionTokens / 1_000_000) * modelInfo.costPer1MOutput
|
|
1052
1107
|
: 0;
|
|
1053
1108
|
return {
|
|
@@ -1061,6 +1116,8 @@ class AIProviderManager {
|
|
|
1061
1116
|
completionTokens,
|
|
1062
1117
|
totalTokens: promptTokens + completionTokens,
|
|
1063
1118
|
cost,
|
|
1119
|
+
cacheReadTokens,
|
|
1120
|
+
cacheWriteTokens,
|
|
1064
1121
|
},
|
|
1065
1122
|
duration,
|
|
1066
1123
|
toolCalls: detectedToolCalls.length > 0 ? detectedToolCalls : undefined,
|
|
@@ -1078,7 +1135,7 @@ class AIProviderManager {
|
|
|
1078
1135
|
modelSupportsTools(modelOrAlias) {
|
|
1079
1136
|
const modelRef = modelOrAlias
|
|
1080
1137
|
? this.resolveModel(modelOrAlias)
|
|
1081
|
-
: { provider: this.defaultProvider, model:
|
|
1138
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
1082
1139
|
// Azure OpenAI: All GPT-4, GPT-4o, and GPT-3.5-turbo models support function calling
|
|
1083
1140
|
// We check provider first since Azure deployment names won't be in MODEL_CATALOG
|
|
1084
1141
|
if (modelRef.provider === 'azure') {
|
|
@@ -1123,7 +1180,7 @@ class AIProviderManager {
|
|
|
1123
1180
|
// Resolve model
|
|
1124
1181
|
const modelRef = request.model
|
|
1125
1182
|
? this.resolveModel(request.model)
|
|
1126
|
-
: { provider: this.defaultProvider, model:
|
|
1183
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
1127
1184
|
const model = await this.getModel(modelRef.provider, modelRef.model);
|
|
1128
1185
|
// Check if model supports native tool calling
|
|
1129
1186
|
const toolSupport = this.modelSupportsTools(request.model);
|
|
@@ -1234,22 +1291,19 @@ class AIProviderManager {
|
|
|
1234
1291
|
try {
|
|
1235
1292
|
const result = await withRetry(() => generateText({
|
|
1236
1293
|
model,
|
|
1237
|
-
messages,
|
|
1238
|
-
tools: Object.keys(tools).length > 0 ? tools : undefined,
|
|
1294
|
+
messages: applyAnthropicMessageCache(messages, modelRef.provider),
|
|
1295
|
+
tools: Object.keys(tools).length > 0 ? applyAnthropicToolCache(tools, modelRef.provider) : undefined,
|
|
1239
1296
|
temperature: request.temperature ?? 0.7,
|
|
1240
1297
|
maxOutputTokens: request.maxTokens ?? 4096,
|
|
1241
|
-
|
|
1298
|
+
stopWhen: stepCountIs(request.maxToolRoundtrips ?? 5),
|
|
1242
1299
|
abortSignal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
|
1243
1300
|
}));
|
|
1244
1301
|
const duration = Date.now() - startTime;
|
|
1245
1302
|
const modelInfo = this.getModelInfo(modelRef.model);
|
|
1246
|
-
// Calculate usage
|
|
1247
|
-
const promptTokens = result.usage
|
|
1248
|
-
result.usage?.inputTokens ?? 0;
|
|
1249
|
-
const completionTokens = result.usage?.completionTokens ??
|
|
1250
|
-
result.usage?.outputTokens ?? 0;
|
|
1303
|
+
// Calculate usage, summed across all steps (result.usage is last-step only)
|
|
1304
|
+
const { promptTokens, completionTokens, cacheReadTokens, cacheWriteTokens } = aggregateStepUsage(result.steps, result.usage);
|
|
1251
1305
|
const cost = modelInfo
|
|
1252
|
-
? (promptTokens
|
|
1306
|
+
? calculateCachedInputCost(promptTokens, cacheReadTokens, cacheWriteTokens, modelInfo.costPer1MInput, getCacheConfigForModel(modelInfo.id)) +
|
|
1253
1307
|
(completionTokens / 1_000_000) * modelInfo.costPer1MOutput
|
|
1254
1308
|
: 0;
|
|
1255
1309
|
// Check if any tool calls require approval
|
|
@@ -1269,6 +1323,8 @@ class AIProviderManager {
|
|
|
1269
1323
|
completionTokens,
|
|
1270
1324
|
totalTokens: promptTokens + completionTokens,
|
|
1271
1325
|
cost,
|
|
1326
|
+
cacheReadTokens,
|
|
1327
|
+
cacheWriteTokens,
|
|
1272
1328
|
},
|
|
1273
1329
|
duration,
|
|
1274
1330
|
toolCalls: toolCallHistory.length > 0 ? toolCallHistory : undefined,
|
|
@@ -1297,7 +1353,7 @@ class AIProviderManager {
|
|
|
1297
1353
|
// Resolve model
|
|
1298
1354
|
const modelRef = request.model
|
|
1299
1355
|
? this.resolveModel(request.model)
|
|
1300
|
-
: { provider: this.defaultProvider, model:
|
|
1356
|
+
: { provider: this.defaultProvider, model: this.getDefaultModelForProvider(this.defaultProvider) };
|
|
1301
1357
|
const model = await this.getModel(modelRef.provider, modelRef.model);
|
|
1302
1358
|
// Convert messages
|
|
1303
1359
|
const messages = toAiMessages(request.messages);
|
|
@@ -1379,11 +1435,11 @@ class AIProviderManager {
|
|
|
1379
1435
|
try {
|
|
1380
1436
|
const result = streamText({
|
|
1381
1437
|
model,
|
|
1382
|
-
messages,
|
|
1383
|
-
tools: Object.keys(tools).length > 0 ? tools : undefined,
|
|
1438
|
+
messages: applyAnthropicMessageCache(messages, modelRef.provider),
|
|
1439
|
+
tools: Object.keys(tools).length > 0 ? applyAnthropicToolCache(tools, modelRef.provider) : undefined,
|
|
1384
1440
|
temperature: request.temperature ?? 0.7,
|
|
1385
1441
|
maxOutputTokens: request.maxTokens ?? 4096,
|
|
1386
|
-
|
|
1442
|
+
stopWhen: stepCountIs(request.maxToolRoundtrips ?? 5),
|
|
1387
1443
|
abortSignal: AbortSignal.timeout(AI_TIMEOUT_MS),
|
|
1388
1444
|
});
|
|
1389
1445
|
let fullText = '';
|
|
@@ -1394,12 +1450,9 @@ class AIProviderManager {
|
|
|
1394
1450
|
const usage = await result.usage;
|
|
1395
1451
|
const duration = Date.now() - startTime;
|
|
1396
1452
|
const modelInfo = this.getModelInfo(modelRef.model);
|
|
1397
|
-
const promptTokens = usage
|
|
1398
|
-
usage?.inputTokens ?? 0;
|
|
1399
|
-
const completionTokens = usage?.completionTokens ??
|
|
1400
|
-
usage?.outputTokens ?? 0;
|
|
1453
|
+
const { promptTokens, completionTokens, cacheReadTokens, cacheWriteTokens } = extractCacheUsage(usage);
|
|
1401
1454
|
const cost = modelInfo
|
|
1402
|
-
? (promptTokens
|
|
1455
|
+
? calculateCachedInputCost(promptTokens, cacheReadTokens, cacheWriteTokens, modelInfo.costPer1MInput, getCacheConfigForModel(modelInfo.id)) +
|
|
1403
1456
|
(completionTokens / 1_000_000) * modelInfo.costPer1MOutput
|
|
1404
1457
|
: 0;
|
|
1405
1458
|
const pendingApprovals = toolResultHistory.filter(r => r.approvalRequired);
|
|
@@ -1418,6 +1471,8 @@ class AIProviderManager {
|
|
|
1418
1471
|
completionTokens,
|
|
1419
1472
|
totalTokens: promptTokens + completionTokens,
|
|
1420
1473
|
cost,
|
|
1474
|
+
cacheReadTokens,
|
|
1475
|
+
cacheWriteTokens,
|
|
1421
1476
|
},
|
|
1422
1477
|
duration,
|
|
1423
1478
|
toolCalls: toolCallHistory.length > 0 ? toolCallHistory : undefined,
|
|
@@ -7,8 +7,11 @@ import { ProviderType } from './types.js';
|
|
|
7
7
|
// Model Aliases
|
|
8
8
|
export const MODEL_ALIASES = {
|
|
9
9
|
// Anthropic
|
|
10
|
-
opus: { provider: 'anthropic', model: 'claude-opus-
|
|
11
|
-
sonnet: { provider: 'anthropic', model: 'claude-sonnet-
|
|
10
|
+
opus: { provider: 'anthropic', model: 'claude-opus-5-5' },
|
|
11
|
+
sonnet: { provider: 'anthropic', model: 'claude-sonnet-5' },
|
|
12
|
+
fable: { provider: 'anthropic', model: 'claude-fable-5-1' },
|
|
13
|
+
'opus-legacy': { provider: 'anthropic', model: 'claude-opus-4-6' },
|
|
14
|
+
'sonnet-legacy': { provider: 'anthropic', model: 'claude-sonnet-4-5-20250929' },
|
|
12
15
|
haiku: { provider: 'anthropic', model: 'claude-haiku-4-5-20251001' },
|
|
13
16
|
// OpenAI
|
|
14
17
|
gpt: { provider: 'openai', model: 'gpt-4o' },
|
|
@@ -32,8 +35,11 @@ export const MODEL_ALIASES = {
|
|
|
32
35
|
local: { provider: 'ollama', model: 'llama3.2' },
|
|
33
36
|
llama: { provider: 'ollama', model: 'llama3.2' },
|
|
34
37
|
'deepseek-local': { provider: 'ollama', model: 'deepseek-r1:7b' },
|
|
35
|
-
qwen: { provider: 'ollama', model: '
|
|
38
|
+
qwen: { provider: 'ollama', model: 'qwen3:4b' },
|
|
39
|
+
'qwen-14b': { provider: 'ollama', model: 'qwen2.5:14b' },
|
|
36
40
|
'mistral-local': { provider: 'ollama', model: 'mistral:7b' },
|
|
41
|
+
gemma4: { provider: 'ollama', model: 'gemma4:e4b' },
|
|
42
|
+
'gemma4-26b': { provider: 'ollama', model: 'gemma4:26b' },
|
|
37
43
|
// xAI (Grok)
|
|
38
44
|
grok: { provider: 'xai', model: 'grok-2' },
|
|
39
45
|
'grok-3': { provider: 'xai', model: 'grok-3' },
|
|
@@ -110,6 +116,45 @@ export const MODEL_ALIASES = {
|
|
|
110
116
|
// Model Catalog
|
|
111
117
|
export const MODEL_CATALOG = [
|
|
112
118
|
// Anthropic - All support native function calling
|
|
119
|
+
// Current Anthropic models. ids, context, max output and prices verified against
|
|
120
|
+
// https://platform.claude.com/docs/en/about-claude/models/overview (2026-09-26).
|
|
121
|
+
{
|
|
122
|
+
id: 'claude-fable-5-1',
|
|
123
|
+
name: 'Claude Fable 5.1',
|
|
124
|
+
provider: 'anthropic',
|
|
125
|
+
contextWindow: 1000000,
|
|
126
|
+
maxOutput: 128000,
|
|
127
|
+
supportsVision: true,
|
|
128
|
+
supportsStreaming: true,
|
|
129
|
+
supportsTools: true,
|
|
130
|
+
costPer1MInput: 10,
|
|
131
|
+
costPer1MOutput: 50,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'claude-opus-5-5',
|
|
135
|
+
name: 'Claude Opus 5.5',
|
|
136
|
+
provider: 'anthropic',
|
|
137
|
+
contextWindow: 1000000,
|
|
138
|
+
maxOutput: 128000,
|
|
139
|
+
supportsVision: true,
|
|
140
|
+
supportsStreaming: true,
|
|
141
|
+
supportsTools: true,
|
|
142
|
+
costPer1MInput: 4,
|
|
143
|
+
costPer1MOutput: 20,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'claude-sonnet-5',
|
|
147
|
+
name: 'Claude Sonnet 5',
|
|
148
|
+
provider: 'anthropic',
|
|
149
|
+
contextWindow: 1000000,
|
|
150
|
+
maxOutput: 128000,
|
|
151
|
+
supportsVision: true,
|
|
152
|
+
supportsStreaming: true,
|
|
153
|
+
supportsTools: true,
|
|
154
|
+
costPer1MInput: 2,
|
|
155
|
+
costPer1MOutput: 10,
|
|
156
|
+
},
|
|
157
|
+
// Legacy entries kept because other code and tests reference them.
|
|
113
158
|
{
|
|
114
159
|
id: 'claude-opus-4-6',
|
|
115
160
|
name: 'Claude Opus 4.6',
|
|
@@ -139,12 +184,12 @@ export const MODEL_CATALOG = [
|
|
|
139
184
|
name: 'Claude Haiku 4.5',
|
|
140
185
|
provider: 'anthropic',
|
|
141
186
|
contextWindow: 200000,
|
|
142
|
-
maxOutput:
|
|
187
|
+
maxOutput: 64000,
|
|
143
188
|
supportsVision: true,
|
|
144
189
|
supportsStreaming: true,
|
|
145
190
|
supportsTools: true,
|
|
146
|
-
costPer1MInput:
|
|
147
|
-
costPer1MOutput:
|
|
191
|
+
costPer1MInput: 1,
|
|
192
|
+
costPer1MOutput: 5,
|
|
148
193
|
},
|
|
149
194
|
// OpenAI - GPT-4+ supports function calling
|
|
150
195
|
{
|
|
@@ -378,6 +423,44 @@ export const MODEL_CATALOG = [
|
|
|
378
423
|
costPer1MInput: 30.0,
|
|
379
424
|
costPer1MOutput: 60.0,
|
|
380
425
|
},
|
|
426
|
+
// Gemma 4 (local): supports native tool calling + multimodal
|
|
427
|
+
{
|
|
428
|
+
id: 'gemma4:e4b',
|
|
429
|
+
name: 'Gemma 4 E4B (Local)',
|
|
430
|
+
provider: 'ollama',
|
|
431
|
+
contextWindow: 128000,
|
|
432
|
+
maxOutput: 8192,
|
|
433
|
+
supportsVision: true,
|
|
434
|
+
supportsStreaming: true,
|
|
435
|
+
supportsTools: true,
|
|
436
|
+
costPer1MInput: 0,
|
|
437
|
+
costPer1MOutput: 0,
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: 'gemma4:26b',
|
|
441
|
+
name: 'Gemma 4 26B (Local)',
|
|
442
|
+
provider: 'ollama',
|
|
443
|
+
contextWindow: 128000,
|
|
444
|
+
maxOutput: 8192,
|
|
445
|
+
supportsVision: true,
|
|
446
|
+
supportsStreaming: true,
|
|
447
|
+
supportsTools: true,
|
|
448
|
+
costPer1MInput: 0,
|
|
449
|
+
costPer1MOutput: 0,
|
|
450
|
+
},
|
|
451
|
+
// Qwen 3 (local): best small model for tool calling
|
|
452
|
+
{
|
|
453
|
+
id: 'qwen3:4b',
|
|
454
|
+
name: 'Qwen 3 4B (Local)',
|
|
455
|
+
provider: 'ollama',
|
|
456
|
+
contextWindow: 32768,
|
|
457
|
+
maxOutput: 8192,
|
|
458
|
+
supportsVision: false,
|
|
459
|
+
supportsStreaming: true,
|
|
460
|
+
supportsTools: true,
|
|
461
|
+
costPer1MInput: 0,
|
|
462
|
+
costPer1MOutput: 0,
|
|
463
|
+
},
|
|
381
464
|
// Ollama (local) - Most models don't reliably support native tool calling
|
|
382
465
|
{
|
|
383
466
|
id: 'llama3.2',
|
|
@@ -884,6 +967,31 @@ export const MODEL_CATALOG = [
|
|
|
884
967
|
costPer1MInput: 0.40,
|
|
885
968
|
costPer1MOutput: 1.20,
|
|
886
969
|
},
|
|
970
|
+
// Cerebras (fast inference)
|
|
971
|
+
{
|
|
972
|
+
id: 'llama3.1-8b',
|
|
973
|
+
name: 'Llama 3.1 8B (Cerebras)',
|
|
974
|
+
provider: 'cerebras',
|
|
975
|
+
contextWindow: 8192,
|
|
976
|
+
maxOutput: 8192,
|
|
977
|
+
supportsVision: false,
|
|
978
|
+
supportsStreaming: true,
|
|
979
|
+
supportsTools: false,
|
|
980
|
+
costPer1MInput: 0.10,
|
|
981
|
+
costPer1MOutput: 0.10,
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
id: 'llama-3.3-70b',
|
|
985
|
+
name: 'Llama 3.3 70B (Cerebras)',
|
|
986
|
+
provider: 'cerebras',
|
|
987
|
+
contextWindow: 8192,
|
|
988
|
+
maxOutput: 8192,
|
|
989
|
+
supportsVision: false,
|
|
990
|
+
supportsStreaming: true,
|
|
991
|
+
supportsTools: true,
|
|
992
|
+
costPer1MInput: 0.60,
|
|
993
|
+
costPer1MOutput: 0.60,
|
|
994
|
+
},
|
|
887
995
|
// IBM Watsonx
|
|
888
996
|
{
|
|
889
997
|
id: 'watsonx/ibm/granite-13b-chat-v2',
|
|
@@ -55,13 +55,20 @@ export interface ChatResponse {
|
|
|
55
55
|
completionTokens: number;
|
|
56
56
|
totalTokens: number;
|
|
57
57
|
cost: number;
|
|
58
|
+
/** Prompt tokens served from the provider cache (subset of promptTokens) */
|
|
59
|
+
cacheReadTokens?: number;
|
|
60
|
+
/** Prompt tokens written to the provider cache (subset of promptTokens) */
|
|
61
|
+
cacheWriteTokens?: number;
|
|
58
62
|
};
|
|
59
63
|
duration: number;
|
|
60
64
|
}
|
|
65
|
+
export type ToolTier = 'essential' | 'standard' | 'full';
|
|
66
|
+
export type ModelCapabilityLevel = 'basic' | 'instruction' | 'reasoning';
|
|
61
67
|
export interface ToolDefinition {
|
|
62
68
|
name: string;
|
|
63
69
|
description: string;
|
|
64
70
|
parameters?: Record<string, unknown>;
|
|
71
|
+
tier?: ToolTier;
|
|
65
72
|
}
|
|
66
73
|
export interface ToolCall {
|
|
67
74
|
id: string;
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
* Multi-provider AI chat using Vercel AI SDK.
|
|
5
5
|
*/
|
|
6
6
|
export { aiProvider, chat, chatStream, ProviderType, MODEL_ALIASES, MODEL_CATALOG, type ProviderConfig, type ModelInfo, type ChatMessage, type ChatRequest, type ChatResponse, type NativeToolCall, type NativeToolResult, type NativeToolDefinition, type ToolExecutionResult, } from './ai-sdk.js';
|
|
7
|
+
export { routeQuery, classifyComplexity, selectModel, getRoutingStats, recordRoutingDecision, configureSmartRouter, isSmartRouterEnabled, getCostComparison, getCostOptimizationAdvice, resolveDefaultModel, type ComplexityTier, type ComplexityResult, type RoutingDecision, type SmartRouterConfig, type ProviderRecommendation, } from './smart-router.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/providers/index.js
CHANGED
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
* Multi-provider AI chat using Vercel AI SDK.
|
|
5
5
|
*/
|
|
6
6
|
export { aiProvider, chat, chatStream, ProviderType, MODEL_ALIASES, MODEL_CATALOG, } from './ai-sdk.js';
|
|
7
|
+
export { routeQuery, classifyComplexity, selectModel, getRoutingStats, recordRoutingDecision, configureSmartRouter, isSmartRouterEnabled, getCostComparison, getCostOptimizationAdvice, resolveDefaultModel, } from './smart-router.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt caching helpers
|
|
3
|
+
*
|
|
4
|
+
* Anthropic requires explicit cache breakpoints (providerOptions.anthropic.cacheControl).
|
|
5
|
+
* The cached prefix order is: tools, then system, then messages. A breakpoint on the
|
|
6
|
+
* last system message therefore caches tool schemas and the system prompt together;
|
|
7
|
+
* an extra breakpoint on the last tool lets the tool block hit even if the system
|
|
8
|
+
* prompt changes. OpenAI caches automatically and only reports cached token counts.
|
|
9
|
+
*
|
|
10
|
+
* Cache multipliers are relative to the base input price and are env-configurable.
|
|
11
|
+
*/
|
|
12
|
+
import type { ModelMessage, ToolSet } from 'ai';
|
|
13
|
+
export interface PromptCacheConfig {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
ttl: '5m' | '1h';
|
|
16
|
+
/** Cost of a cache read relative to base input price */
|
|
17
|
+
readMultiplier: number;
|
|
18
|
+
/** Cost of a cache write relative to base input price */
|
|
19
|
+
writeMultiplier: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CacheUsage {
|
|
22
|
+
/** Total prompt tokens, including cached reads and writes */
|
|
23
|
+
promptTokens: number;
|
|
24
|
+
completionTokens: number;
|
|
25
|
+
cacheReadTokens: number;
|
|
26
|
+
cacheWriteTokens: number;
|
|
27
|
+
}
|
|
28
|
+
/** Read cache settings from env on each call so tests and runtime changes apply. */
|
|
29
|
+
export declare function getPromptCacheConfig(env?: NodeJS.ProcessEnv): PromptCacheConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Cache config for one model. An explicit PROFCLAW_CACHE_READ_MULTIPLIER always wins,
|
|
32
|
+
* otherwise the model's documented read multiplier applies.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCacheConfigForModel(model: string, env?: NodeJS.ProcessEnv): PromptCacheConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Add cache breakpoints to the leading system block: one on the first system message
|
|
37
|
+
* (the stable prompt) and one on the last leading system message. Callers put volatile
|
|
38
|
+
* per-request context in a later system message so the first breakpoint still hits
|
|
39
|
+
* across requests. History after the system block stays outside the cached prefix.
|
|
40
|
+
* Returns a new array; inputs are not mutated.
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyAnthropicMessageCache<T extends ModelMessage>(messages: T[], provider: string, config?: PromptCacheConfig): T[];
|
|
43
|
+
/**
|
|
44
|
+
* Return tools in a deterministic (name-sorted) order with a cache breakpoint on the
|
|
45
|
+
* last one. Object key order in the request body affects the prefix bytes, so sorting
|
|
46
|
+
* keeps the tool block byte-stable across steps and sessions.
|
|
47
|
+
*/
|
|
48
|
+
export declare function applyAnthropicToolCache<T extends ToolSet>(tools: T, provider: string, config?: PromptCacheConfig): T;
|
|
49
|
+
/**
|
|
50
|
+
* Normalize AI SDK usage (v6 shape, legacy promptTokens shape, or raw provider
|
|
51
|
+
* counters) into total prompt tokens plus cache read/write counts.
|
|
52
|
+
* In AI SDK v6, inputTokens already includes cached reads and writes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function extractCacheUsage(usage: unknown): CacheUsage;
|
|
55
|
+
/**
|
|
56
|
+
* Sum usage across multi-step runs (tokens plus cache read/write). Falls back to
|
|
57
|
+
* `fallback` (the run-level usage) when there are no per-step usages, because
|
|
58
|
+
* result.usage only reflects the last step in AI SDK v6.
|
|
59
|
+
*/
|
|
60
|
+
export declare function aggregateStepUsage(steps: unknown, fallback: unknown): CacheUsage;
|
|
61
|
+
/**
|
|
62
|
+
* Input cost in USD for a prompt that may include cached tokens.
|
|
63
|
+
* Uncached tokens bill at the base rate, reads and writes at the multiplied rate.
|
|
64
|
+
*/
|
|
65
|
+
export declare function calculateCachedInputCost(promptTokens: number, cacheReadTokens: number, cacheWriteTokens: number, inputRatePer1M: number, config?: PromptCacheConfig): number;
|
|
66
|
+
/** Fraction of prompt tokens served from cache (0 when there were no prompt tokens). */
|
|
67
|
+
export declare function cacheHitRate(cacheReadTokens: number, promptTokens: number): number;
|
|
68
|
+
//# sourceMappingURL=prompt-cache.d.ts.map
|