mindweave 0.0.1 → 2.1.2
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/LICENSE +190 -0
- package/README.md +171 -14
- package/dist/alternator/chassis/cache.js +47 -0
- package/dist/alternator/chassis/cache.js.map +1 -0
- package/dist/alternator/chassis/domRefs.js +53 -0
- package/dist/alternator/chassis/domRefs.js.map +1 -0
- package/dist/alternator/chassis/extractWorker.js +65 -0
- package/dist/alternator/chassis/extractWorker.js.map +1 -0
- package/dist/alternator/chassis/graph.js +221 -0
- package/dist/alternator/chassis/graph.js.map +1 -0
- package/dist/alternator/chassis/index.js +463 -0
- package/dist/alternator/chassis/index.js.map +1 -0
- package/dist/alternator/chassis/isolation.js +336 -0
- package/dist/alternator/chassis/isolation.js.map +1 -0
- package/dist/alternator/chassis/langCases.js +69 -0
- package/dist/alternator/chassis/langCases.js.map +1 -0
- package/dist/alternator/chassis/lsp.js +469 -0
- package/dist/alternator/chassis/lsp.js.map +1 -0
- package/dist/alternator/chassis/markup.js +262 -0
- package/dist/alternator/chassis/markup.js.map +1 -0
- package/dist/alternator/chassis/provision.js +198 -0
- package/dist/alternator/chassis/provision.js.map +1 -0
- package/dist/alternator/chassis/rank.js +72 -0
- package/dist/alternator/chassis/rank.js.map +1 -0
- package/dist/alternator/chassis/servers.js +215 -0
- package/dist/alternator/chassis/servers.js.map +1 -0
- package/dist/alternator/chassis/treesitter.js +608 -0
- package/dist/alternator/chassis/treesitter.js.map +1 -0
- package/dist/alternator/chassis/types.js +24 -0
- package/dist/alternator/chassis/types.js.map +1 -0
- package/dist/alternator/lane.js +67 -0
- package/dist/alternator/lane.js.map +1 -0
- package/dist/cli/App.js +2586 -0
- package/dist/cli/App.js.map +1 -0
- package/dist/cli/altScreen.js +67 -0
- package/dist/cli/altScreen.js.map +1 -0
- package/dist/cli/approvalChannel.js +72 -0
- package/dist/cli/approvalChannel.js.map +1 -0
- package/dist/cli/attachments.js +188 -0
- package/dist/cli/attachments.js.map +1 -0
- package/dist/cli/bootstrap.js +279 -0
- package/dist/cli/bootstrap.js.map +1 -0
- package/dist/cli/chatAnchor.js +94 -0
- package/dist/cli/chatAnchor.js.map +1 -0
- package/dist/cli/commandArgs.js +79 -0
- package/dist/cli/commandArgs.js.map +1 -0
- package/dist/cli/commandRoute.js +78 -0
- package/dist/cli/commandRoute.js.map +1 -0
- package/dist/cli/compaction.js +69 -0
- package/dist/cli/compaction.js.map +1 -0
- package/dist/cli/components/ApprovalBox.js +100 -0
- package/dist/cli/components/ApprovalBox.js.map +1 -0
- package/dist/cli/components/BlockView.js +128 -0
- package/dist/cli/components/BlockView.js.map +1 -0
- package/dist/cli/components/FirstRunFrame.js +41 -0
- package/dist/cli/components/FirstRunFrame.js.map +1 -0
- package/dist/cli/components/KeyManager.js +197 -0
- package/dist/cli/components/KeyManager.js.map +1 -0
- package/dist/cli/components/KeySetup.js +125 -0
- package/dist/cli/components/KeySetup.js.map +1 -0
- package/dist/cli/components/MenuFrame.js +24 -0
- package/dist/cli/components/MenuFrame.js.map +1 -0
- package/dist/cli/components/Picker.js +82 -0
- package/dist/cli/components/Picker.js.map +1 -0
- package/dist/cli/components/PromptInput.js +509 -0
- package/dist/cli/components/PromptInput.js.map +1 -0
- package/dist/cli/components/SubagentView.js +86 -0
- package/dist/cli/components/SubagentView.js.map +1 -0
- package/dist/cli/components/ToolGroup.js +60 -0
- package/dist/cli/components/ToolGroup.js.map +1 -0
- package/dist/cli/components/ToolLine.js +123 -0
- package/dist/cli/components/ToolLine.js.map +1 -0
- package/dist/cli/components/TrustGate.js +37 -0
- package/dist/cli/components/TrustGate.js.map +1 -0
- package/dist/cli/costView.js +40 -0
- package/dist/cli/costView.js.map +1 -0
- package/dist/cli/frameRate.js +30 -0
- package/dist/cli/frameRate.js.map +1 -0
- package/dist/cli/framebuffer/paint.js +165 -0
- package/dist/cli/framebuffer/paint.js.map +1 -0
- package/dist/cli/framebuffer/parse.js +266 -0
- package/dist/cli/framebuffer/parse.js.map +1 -0
- package/dist/cli/framebuffer/screen.js +196 -0
- package/dist/cli/framebuffer/screen.js.map +1 -0
- package/dist/cli/framebuffer/writer.js +139 -0
- package/dist/cli/framebuffer/writer.js.map +1 -0
- package/dist/cli/groupReveal.js +51 -0
- package/dist/cli/groupReveal.js.map +1 -0
- package/dist/cli/help.js +55 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/inputView.js +105 -0
- package/dist/cli/inputView.js.map +1 -0
- package/dist/cli/keyManager.js +65 -0
- package/dist/cli/keyManager.js.map +1 -0
- package/dist/cli/keySetup.js +35 -0
- package/dist/cli/keySetup.js.map +1 -0
- package/dist/cli/keyStore.js +73 -0
- package/dist/cli/keyStore.js.map +1 -0
- package/dist/cli/markdown.js +460 -0
- package/dist/cli/markdown.js.map +1 -0
- package/dist/cli/messageQueue.js +96 -0
- package/dist/cli/messageQueue.js.map +1 -0
- package/dist/cli/modes.js +90 -0
- package/dist/cli/modes.js.map +1 -0
- package/dist/cli/mouse.js +78 -0
- package/dist/cli/mouse.js.map +1 -0
- package/dist/cli/pasteAssembler.js +44 -0
- package/dist/cli/pasteAssembler.js.map +1 -0
- package/dist/cli/pathComplete.js +39 -0
- package/dist/cli/pathComplete.js.map +1 -0
- package/dist/cli/perfLog.js +90 -0
- package/dist/cli/perfLog.js.map +1 -0
- package/dist/cli/reveal.js +32 -0
- package/dist/cli/reveal.js.map +1 -0
- package/dist/cli/revealPace.js +59 -0
- package/dist/cli/revealPace.js.map +1 -0
- package/dist/cli/sessionCarry.js +19 -0
- package/dist/cli/sessionCarry.js.map +1 -0
- package/dist/cli/smoothScroll.js +74 -0
- package/dist/cli/smoothScroll.js.map +1 -0
- package/dist/cli/startupArgs.js +96 -0
- package/dist/cli/startupArgs.js.map +1 -0
- package/dist/cli/terminalRestore.js +34 -0
- package/dist/cli/terminalRestore.js.map +1 -0
- package/dist/cli/toolDisplay.js +219 -0
- package/dist/cli/toolDisplay.js.map +1 -0
- package/dist/cli/toolItems.js +65 -0
- package/dist/cli/toolItems.js.map +1 -0
- package/dist/cli/transcript.js +351 -0
- package/dist/cli/transcript.js.map +1 -0
- package/dist/cli/trust.js +79 -0
- package/dist/cli/trust.js.map +1 -0
- package/dist/cli/updateCheck.js +107 -0
- package/dist/cli/updateCheck.js.map +1 -0
- package/dist/cli/version.js +39 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/viewport.js +179 -0
- package/dist/cli/viewport.js.map +1 -0
- package/dist/cli/virtualWindow.js +103 -0
- package/dist/cli/virtualWindow.js.map +1 -0
- package/dist/cli/workingVerb.js +37 -0
- package/dist/cli/workingVerb.js.map +1 -0
- package/dist/cli/wrap.js +145 -0
- package/dist/cli/wrap.js.map +1 -0
- package/dist/drivers/anthropic/cachePoints.js +77 -0
- package/dist/drivers/anthropic/cachePoints.js.map +1 -0
- package/dist/drivers/anthropic/client.js +432 -0
- package/dist/drivers/anthropic/client.js.map +1 -0
- package/dist/drivers/anthropic/index.js +10 -0
- package/dist/drivers/anthropic/index.js.map +1 -0
- package/dist/drivers/anthropic/manifest.js +221 -0
- package/dist/drivers/anthropic/manifest.js.map +1 -0
- package/dist/drivers/cerebras/client.js +69 -0
- package/dist/drivers/cerebras/client.js.map +1 -0
- package/dist/drivers/cerebras/index.js +5 -0
- package/dist/drivers/cerebras/index.js.map +1 -0
- package/dist/drivers/cerebras/manifest.js +140 -0
- package/dist/drivers/cerebras/manifest.js.map +1 -0
- package/dist/drivers/clientId.js +41 -0
- package/dist/drivers/clientId.js.map +1 -0
- package/dist/drivers/contextOverflow.js +77 -0
- package/dist/drivers/contextOverflow.js.map +1 -0
- package/dist/drivers/deepseek/client.js +168 -0
- package/dist/drivers/deepseek/client.js.map +1 -0
- package/dist/drivers/deepseek/index.js +16 -0
- package/dist/drivers/deepseek/index.js.map +1 -0
- package/dist/drivers/deepseek/inlineTools.js +46 -0
- package/dist/drivers/deepseek/inlineTools.js.map +1 -0
- package/dist/drivers/deepseek/manifest.js +166 -0
- package/dist/drivers/deepseek/manifest.js.map +1 -0
- package/dist/drivers/gemini/client.js +38 -0
- package/dist/drivers/gemini/client.js.map +1 -0
- package/dist/drivers/gemini/index.js +5 -0
- package/dist/drivers/gemini/index.js.map +1 -0
- package/dist/drivers/gemini/manifest.js +150 -0
- package/dist/drivers/gemini/manifest.js.map +1 -0
- package/dist/drivers/glm/client.js +90 -0
- package/dist/drivers/glm/client.js.map +1 -0
- package/dist/drivers/glm/index.js +9 -0
- package/dist/drivers/glm/index.js.map +1 -0
- package/dist/drivers/glm/manifest.js +183 -0
- package/dist/drivers/glm/manifest.js.map +1 -0
- package/dist/drivers/groq/client.js +80 -0
- package/dist/drivers/groq/client.js.map +1 -0
- package/dist/drivers/groq/index.js +5 -0
- package/dist/drivers/groq/index.js.map +1 -0
- package/dist/drivers/groq/manifest.js +160 -0
- package/dist/drivers/groq/manifest.js.map +1 -0
- package/dist/drivers/kimi/client.js +82 -0
- package/dist/drivers/kimi/client.js.map +1 -0
- package/dist/drivers/kimi/index.js +9 -0
- package/dist/drivers/kimi/index.js.map +1 -0
- package/dist/drivers/kimi/manifest.js +168 -0
- package/dist/drivers/kimi/manifest.js.map +1 -0
- package/dist/drivers/meta/client.js +30 -0
- package/dist/drivers/meta/client.js.map +1 -0
- package/dist/drivers/meta/index.js +5 -0
- package/dist/drivers/meta/index.js.map +1 -0
- package/dist/drivers/meta/manifest.js +101 -0
- package/dist/drivers/meta/manifest.js.map +1 -0
- package/dist/drivers/minimax/client.js +36 -0
- package/dist/drivers/minimax/client.js.map +1 -0
- package/dist/drivers/minimax/index.js +5 -0
- package/dist/drivers/minimax/index.js.map +1 -0
- package/dist/drivers/minimax/manifest.js +120 -0
- package/dist/drivers/minimax/manifest.js.map +1 -0
- package/dist/drivers/mistral/client.js +54 -0
- package/dist/drivers/mistral/client.js.map +1 -0
- package/dist/drivers/mistral/index.js +5 -0
- package/dist/drivers/mistral/index.js.map +1 -0
- package/dist/drivers/mistral/manifest.js +118 -0
- package/dist/drivers/mistral/manifest.js.map +1 -0
- package/dist/drivers/openai/client.js +290 -0
- package/dist/drivers/openai/client.js.map +1 -0
- package/dist/drivers/openai/index.js +9 -0
- package/dist/drivers/openai/index.js.map +1 -0
- package/dist/drivers/openai/manifest.js +133 -0
- package/dist/drivers/openai/manifest.js.map +1 -0
- package/dist/drivers/openaiCompat/wire.js +493 -0
- package/dist/drivers/openaiCompat/wire.js.map +1 -0
- package/dist/drivers/partialTurn.js +23 -0
- package/dist/drivers/partialTurn.js.map +1 -0
- package/dist/drivers/providerError.js +181 -0
- package/dist/drivers/providerError.js.map +1 -0
- package/dist/drivers/qwen/client.js +93 -0
- package/dist/drivers/qwen/client.js.map +1 -0
- package/dist/drivers/qwen/index.js +9 -0
- package/dist/drivers/qwen/index.js.map +1 -0
- package/dist/drivers/qwen/manifest.js +146 -0
- package/dist/drivers/qwen/manifest.js.map +1 -0
- package/dist/drivers/registry.js +177 -0
- package/dist/drivers/registry.js.map +1 -0
- package/dist/drivers/retryPolicy.js +129 -0
- package/dist/drivers/retryPolicy.js.map +1 -0
- package/dist/drivers/searchBlocks.js +61 -0
- package/dist/drivers/searchBlocks.js.map +1 -0
- package/dist/drivers/types.js +2 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/drivers/xai/client.js +63 -0
- package/dist/drivers/xai/client.js.map +1 -0
- package/dist/drivers/xai/index.js +5 -0
- package/dist/drivers/xai/index.js.map +1 -0
- package/dist/drivers/xai/manifest.js +137 -0
- package/dist/drivers/xai/manifest.js.map +1 -0
- package/dist/dynamo/_probe.tmp.js +20 -0
- package/dist/dynamo/_probe.tmp.js.map +1 -0
- package/dist/dynamo/cacheBreak.js +88 -0
- package/dist/dynamo/cacheBreak.js.map +1 -0
- package/dist/dynamo/contextWindow.js +243 -0
- package/dist/dynamo/contextWindow.js.map +1 -0
- package/dist/dynamo/engine.js +2011 -0
- package/dist/dynamo/engine.js.map +1 -0
- package/dist/dynamo/guard.js +132 -0
- package/dist/dynamo/guard.js.map +1 -0
- package/dist/dynamo/liveMeter.js +58 -0
- package/dist/dynamo/liveMeter.js.map +1 -0
- package/dist/dynamo/model.js +172 -0
- package/dist/dynamo/model.js.map +1 -0
- package/dist/dynamo/planArtifact.js +125 -0
- package/dist/dynamo/planArtifact.js.map +1 -0
- package/dist/dynamo/pricing.js +140 -0
- package/dist/dynamo/pricing.js.map +1 -0
- package/dist/dynamo/prompt.js +264 -0
- package/dist/dynamo/prompt.js.map +1 -0
- package/dist/dynamo/spend.js +45 -0
- package/dist/dynamo/spend.js.map +1 -0
- package/dist/dynamo/verify.js +483 -0
- package/dist/dynamo/verify.js.map +1 -0
- package/dist/governor/forbidden.js +181 -0
- package/dist/governor/forbidden.js.map +1 -0
- package/dist/governor/freshness.js +83 -0
- package/dist/governor/freshness.js.map +1 -0
- package/dist/governor/frontmatter.js +38 -0
- package/dist/governor/frontmatter.js.map +1 -0
- package/dist/governor/glob.js +75 -0
- package/dist/governor/glob.js.map +1 -0
- package/dist/governor/index.js +87 -0
- package/dist/governor/index.js.map +1 -0
- package/dist/governor/rules.js +80 -0
- package/dist/governor/rules.js.map +1 -0
- package/dist/governor/scope.js +91 -0
- package/dist/governor/scope.js.map +1 -0
- package/dist/governor/skills.js +176 -0
- package/dist/governor/skills.js.map +1 -0
- package/dist/governor/types.js +16 -0
- package/dist/governor/types.js.map +1 -0
- package/dist/governor/write.js +182 -0
- package/dist/governor/write.js.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/catalog.js +232 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/config.js +116 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/configWrite.js +254 -0
- package/dist/mcp/configWrite.js.map +1 -0
- package/dist/mcp/connection.js +504 -0
- package/dist/mcp/connection.js.map +1 -0
- package/dist/mcp/deferred.js +104 -0
- package/dist/mcp/deferred.js.map +1 -0
- package/dist/mcp/discover.js +128 -0
- package/dist/mcp/discover.js.map +1 -0
- package/dist/mcp/manager.js +679 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/paramHeaders.js +163 -0
- package/dist/mcp/paramHeaders.js.map +1 -0
- package/dist/mcp/prompts.js +136 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/protocol.js +171 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/resources.js +119 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/resultStore.js +180 -0
- package/dist/mcp/resultStore.js.map +1 -0
- package/dist/mcp/subscriptions.js +74 -0
- package/dist/mcp/subscriptions.js.map +1 -0
- package/dist/mcp/transport/headerValue.js +40 -0
- package/dist/mcp/transport/headerValue.js.map +1 -0
- package/dist/mcp/transport/http.js +321 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/stdio.js +234 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/transport/types.js +27 -0
- package/dist/mcp/transport/types.js.map +1 -0
- package/dist/mcp/trust.js +98 -0
- package/dist/mcp/trust.js.map +1 -0
- package/dist/mcp/trustStore.js +55 -0
- package/dist/mcp/trustStore.js.map +1 -0
- package/dist/memory/autoMemory.js +340 -0
- package/dist/memory/autoMemory.js.map +1 -0
- package/dist/memory/compaction.js +513 -0
- package/dist/memory/compaction.js.map +1 -0
- package/dist/memory/images.js +173 -0
- package/dist/memory/images.js.map +1 -0
- package/dist/memory/presence.js +59 -0
- package/dist/memory/presence.js.map +1 -0
- package/dist/memory/projectNotes.js +247 -0
- package/dist/memory/projectNotes.js.map +1 -0
- package/dist/memory/restore.js +72 -0
- package/dist/memory/restore.js.map +1 -0
- package/dist/memory/session.js +472 -0
- package/dist/memory/session.js.map +1 -0
- package/dist/memory/sessionMemory.js +142 -0
- package/dist/memory/sessionMemory.js.map +1 -0
- package/dist/memory/sessionMemoryCompact.js +136 -0
- package/dist/memory/sessionMemoryCompact.js.map +1 -0
- package/dist/memory/store.js +217 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/types.js +14 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/workingSet.js +383 -0
- package/dist/memory/workingSet.js.map +1 -0
- package/dist/project/context.js +425 -0
- package/dist/project/context.js.map +1 -0
- package/dist/tools/approval.js +189 -0
- package/dist/tools/approval.js.map +1 -0
- package/dist/tools/askUser.js +103 -0
- package/dist/tools/askUser.js.map +1 -0
- package/dist/tools/atomicWrite.js +151 -0
- package/dist/tools/atomicWrite.js.map +1 -0
- package/dist/tools/backgroundShells.js +468 -0
- package/dist/tools/backgroundShells.js.map +1 -0
- package/dist/tools/captureSweep.js +77 -0
- package/dist/tools/captureSweep.js.map +1 -0
- package/dist/tools/chassisMux.js +92 -0
- package/dist/tools/chassisMux.js.map +1 -0
- package/dist/tools/checkpoints.js +328 -0
- package/dist/tools/checkpoints.js.map +1 -0
- package/dist/tools/codeIntel.js +267 -0
- package/dist/tools/codeIntel.js.map +1 -0
- package/dist/tools/deferredNative.js +121 -0
- package/dist/tools/deferredNative.js.map +1 -0
- package/dist/tools/detail.js +135 -0
- package/dist/tools/detail.js.map +1 -0
- package/dist/tools/diagnostics.js +174 -0
- package/dist/tools/diagnostics.js.map +1 -0
- package/dist/tools/edit.js +167 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/editCore.js +283 -0
- package/dist/tools/editCore.js.map +1 -0
- package/dist/tools/editFile.js +183 -0
- package/dist/tools/editFile.js.map +1 -0
- package/dist/tools/editRipple.js +126 -0
- package/dist/tools/editRipple.js.map +1 -0
- package/dist/tools/editTarget.js +131 -0
- package/dist/tools/editTarget.js.map +1 -0
- package/dist/tools/editWindow.js +49 -0
- package/dist/tools/editWindow.js.map +1 -0
- package/dist/tools/eol.js +56 -0
- package/dist/tools/eol.js.map +1 -0
- package/dist/tools/exitPlan.js +175 -0
- package/dist/tools/exitPlan.js.map +1 -0
- package/dist/tools/focus.js +42 -0
- package/dist/tools/focus.js.map +1 -0
- package/dist/tools/gitignore.js +148 -0
- package/dist/tools/gitignore.js.map +1 -0
- package/dist/tools/glob.js +134 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/governorTools.js +258 -0
- package/dist/tools/governorTools.js.map +1 -0
- package/dist/tools/grep.js +450 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/guard.js +220 -0
- package/dist/tools/guard.js.map +1 -0
- package/dist/tools/killTree.js +215 -0
- package/dist/tools/killTree.js.map +1 -0
- package/dist/tools/listDir.js +143 -0
- package/dist/tools/listDir.js.map +1 -0
- package/dist/tools/mcpAdd.js +176 -0
- package/dist/tools/mcpAdd.js.map +1 -0
- package/dist/tools/mcpResources.js +116 -0
- package/dist/tools/mcpResources.js.map +1 -0
- package/dist/tools/mcpSearch.js +123 -0
- package/dist/tools/mcpSearch.js.map +1 -0
- package/dist/tools/multiEdit.js +168 -0
- package/dist/tools/multiEdit.js.map +1 -0
- package/dist/tools/paths.js +225 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/posixShell.js +123 -0
- package/dist/tools/posixShell.js.map +1 -0
- package/dist/tools/readFile.js +371 -0
- package/dist/tools/readFile.js.map +1 -0
- package/dist/tools/readSymbol.js +145 -0
- package/dist/tools/readSymbol.js.map +1 -0
- package/dist/tools/registry.js +120 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/replaceSymbol.js +141 -0
- package/dist/tools/replaceSymbol.js.map +1 -0
- package/dist/tools/results.js +15 -0
- package/dist/tools/results.js.map +1 -0
- package/dist/tools/ripgrep.js +145 -0
- package/dist/tools/ripgrep.js.map +1 -0
- package/dist/tools/runCommand.js +633 -0
- package/dist/tools/runCommand.js.map +1 -0
- package/dist/tools/saveMemory.js +102 -0
- package/dist/tools/saveMemory.js.map +1 -0
- package/dist/tools/screenshot.js +200 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/screenshotWin.js +227 -0
- package/dist/tools/screenshotWin.js.map +1 -0
- package/dist/tools/search.js +121 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/sessionTools.js +187 -0
- package/dist/tools/sessionTools.js.map +1 -0
- package/dist/tools/shellCheckpoint.js +123 -0
- package/dist/tools/shellCheckpoint.js.map +1 -0
- package/dist/tools/shellLint.js +102 -0
- package/dist/tools/shellLint.js.map +1 -0
- package/dist/tools/shellTools.js +203 -0
- package/dist/tools/shellTools.js.map +1 -0
- package/dist/tools/spanCore.js +78 -0
- package/dist/tools/spanCore.js.map +1 -0
- package/dist/tools/subagent.js +224 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/subagentReport.js +114 -0
- package/dist/tools/subagentReport.js.map +1 -0
- package/dist/tools/tempSweep.js +118 -0
- package/dist/tools/tempSweep.js.map +1 -0
- package/dist/tools/todo.js +117 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/untrusted.js +46 -0
- package/dist/tools/untrusted.js.map +1 -0
- package/dist/tools/useSkill.js +62 -0
- package/dist/tools/useSkill.js.map +1 -0
- package/dist/tools/walk.js +152 -0
- package/dist/tools/walk.js.map +1 -0
- package/dist/tools/web.js +61 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/webFetch.js +444 -0
- package/dist/tools/webFetch.js.map +1 -0
- package/dist/tools/webSearch.js +130 -0
- package/dist/tools/webSearch.js.map +1 -0
- package/dist/tools/workspace.js +212 -0
- package/dist/tools/workspace.js.map +1 -0
- package/dist/tools/workspaceDiscover.js +216 -0
- package/dist/tools/workspaceDiscover.js.map +1 -0
- package/dist/tools/writeFile.js +162 -0
- package/dist/tools/writeFile.js.map +1 -0
- package/package.json +74 -28
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export const MEDIUM = "mistral-medium-3-5-26-04";
|
|
2
|
+
export const LARGE = "mistral-large-3-25-12";
|
|
3
|
+
export const SMALL = "mistral-small-4-0-26-03";
|
|
4
|
+
export const MINISTRAL_8B = "ministral-3-8b-25-12";
|
|
5
|
+
/** The model used when nothing is saved and no env override is set. */
|
|
6
|
+
export const DEFAULT_MODEL = MEDIUM;
|
|
7
|
+
/** The models offered by `/model`. First entry is this provider's default. */
|
|
8
|
+
export const MODELS = [
|
|
9
|
+
{ id: MEDIUM, label: "Mistral Medium 3.5", description: "the flagship, tuned for agents and code — the default" },
|
|
10
|
+
{ id: LARGE, label: "Mistral Large 3", description: "open weights, and much cheaper than the flagship" },
|
|
11
|
+
{ id: SMALL, label: "Mistral Small 4", description: "small and capable, with a reasoning dial" },
|
|
12
|
+
{ id: MINISTRAL_8B, label: "Ministral 8B", description: "cheapest tier, for simple work" },
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Whether a model takes the `reasoning_effort` dial. Mistral serves it on the
|
|
16
|
+
* flagship and on Small 4, and not on the rest of the lineup.
|
|
17
|
+
*/
|
|
18
|
+
export function takesEffort(model) {
|
|
19
|
+
return model === MEDIUM || model === SMALL;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The reasoning levels offered by `/think`.
|
|
23
|
+
*
|
|
24
|
+
* `reasoning_effort` is a ROOT-LEVEL field here, and `none` is its off switch: at
|
|
25
|
+
* `none` the model thinks minimally and the thinking chunk is omitted, at `high` a
|
|
26
|
+
* full thinking chunk precedes the answer. Those two are the documented ends, so
|
|
27
|
+
* those two are what is offered — inventing intermediate rungs whose behaviour is
|
|
28
|
+
* undocumented would be a menu making promises the API has not made.
|
|
29
|
+
*/
|
|
30
|
+
export function thinkLevels(model) {
|
|
31
|
+
if (takesEffort(model)) {
|
|
32
|
+
return [
|
|
33
|
+
{ label: "Standard", description: "answer directly — fastest", thinking: false, effort: "low" },
|
|
34
|
+
{ label: "Thinking", description: "think first, then answer", thinking: true, effort: "high" },
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
return [{ label: "Standard", description: "this model has no reasoning dial", thinking: false, effort: "low" }];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* List prices (USD / 1M tokens).
|
|
41
|
+
*
|
|
42
|
+
* Note the lineup is not priced in name order: Medium 3.5 is the newer flagship and
|
|
43
|
+
* costs several times Large 3, which is the older open-weight workhorse. That reads
|
|
44
|
+
* as a mistake and is not one.
|
|
45
|
+
*
|
|
46
|
+
* Cached input bills at a TENTH of the standard input rate, which is why `cacheHit`
|
|
47
|
+
* is a real discount here rather than a mirror of `cacheMiss`. An earlier version of
|
|
48
|
+
* this file asserted Mistral published no cached rate; it does.
|
|
49
|
+
*/
|
|
50
|
+
const PRICES = {
|
|
51
|
+
[MEDIUM]: { cacheHit: 0.15, cacheMiss: 1.5, output: 7.5 },
|
|
52
|
+
[LARGE]: { cacheHit: 0.05, cacheMiss: 0.5, output: 1.5 },
|
|
53
|
+
[SMALL]: { cacheHit: 0.015, cacheMiss: 0.15, output: 0.6 },
|
|
54
|
+
[MINISTRAL_8B]: { cacheHit: 0.015, cacheMiss: 0.15, output: 0.15 },
|
|
55
|
+
};
|
|
56
|
+
/** Cache-aware list price for a model, falling back to the default model's. */
|
|
57
|
+
export function price(model) {
|
|
58
|
+
return PRICES[model] ?? PRICES[DEFAULT_MODEL];
|
|
59
|
+
}
|
|
60
|
+
/** The model's USABLE context window — the sharp span rather than the storage cap,
|
|
61
|
+
* for the same BYOK reason as every other driver here. */
|
|
62
|
+
export function contextWindow(_model) {
|
|
63
|
+
return 128_000;
|
|
64
|
+
}
|
|
65
|
+
/** The ceiling this driver puts on a single BUFFERED call. Core reserves exactly
|
|
66
|
+
* this much room below the window, and `client.ts` sends the same constant. */
|
|
67
|
+
export const BUFFERED_OUTPUT_TOKENS = 8_000;
|
|
68
|
+
export function bufferedOutputTokens(_model) {
|
|
69
|
+
return BUFFERED_OUTPUT_TOKENS;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Vision is deliberately NOT declared. Medium 3.5 and Large 3 are described as
|
|
73
|
+
* multimodal and Ministral 8B carries vision, but Small 4's image support is not
|
|
74
|
+
* something this driver has confirmed. A capability true for some of a list and
|
|
75
|
+
* unverified for the rest cannot be reported as a flat yes: core would attach bytes
|
|
76
|
+
* a session might silently be unable to read. Add it per model once confirmed.
|
|
77
|
+
*/
|
|
78
|
+
/** The effort rungs this driver uses. `none` is expressed as thinking-off. */
|
|
79
|
+
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
80
|
+
/** Coerce a stored or unknown config onto a model this provider actually serves,
|
|
81
|
+
* then snap onto a rung `/think` lists so no unlisted setting can persist. */
|
|
82
|
+
export function normalize(config) {
|
|
83
|
+
const model = PRICES[config.model] ? config.model : DEFAULT_MODEL;
|
|
84
|
+
const thinking = takesEffort(model) ? config.thinking === true : false;
|
|
85
|
+
const effort = EFFORTS.includes(config.effort) ? config.effort : "low";
|
|
86
|
+
return { model, thinking, effort: snapToOfferedRung(model, thinking, effort) };
|
|
87
|
+
}
|
|
88
|
+
/** Move an effort onto the nearest rung this model's ladder offers, ties downward. */
|
|
89
|
+
function snapToOfferedRung(model, thinking, effort) {
|
|
90
|
+
const offered = thinkLevels(model).filter((l) => l.thinking === thinking);
|
|
91
|
+
if (offered.length === 0)
|
|
92
|
+
return thinkLevels(model)[0].effort;
|
|
93
|
+
if (offered.some((l) => l.effort === effort))
|
|
94
|
+
return effort;
|
|
95
|
+
const want = EFFORTS.indexOf(effort);
|
|
96
|
+
let best = offered[0];
|
|
97
|
+
for (const level of offered) {
|
|
98
|
+
const d = Math.abs(EFFORTS.indexOf(level.effort) - want);
|
|
99
|
+
const bestD = Math.abs(EFFORTS.indexOf(best.effort) - want);
|
|
100
|
+
if (d < bestD || (d === bestD && EFFORTS.indexOf(level.effort) < EFFORTS.indexOf(best.effort)))
|
|
101
|
+
best = level;
|
|
102
|
+
}
|
|
103
|
+
return best.effort;
|
|
104
|
+
}
|
|
105
|
+
/** The cheap metadata half of this driver — see `index.ts` for the wire half. */
|
|
106
|
+
export const mistralManifest = {
|
|
107
|
+
id: "mistral",
|
|
108
|
+
label: "Mistral",
|
|
109
|
+
apiKeyEnv: "MISTRAL_API_KEY",
|
|
110
|
+
keysUrl: "https://console.mistral.ai/api-keys",
|
|
111
|
+
models: MODELS,
|
|
112
|
+
thinkLevels,
|
|
113
|
+
price,
|
|
114
|
+
contextWindow,
|
|
115
|
+
bufferedOutputTokens,
|
|
116
|
+
normalize,
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/drivers/mistral/manifest.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,MAAM,GAAG,0BAA0B,CAAC;AACjD,MAAM,CAAC,MAAM,KAAK,GAAG,uBAAuB,CAAC;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAG,yBAAyB,CAAC;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD,uEAAuE;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAkB;IACnC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,uDAAuD,EAAE;IACjH,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,kDAAkD,EAAE;IACxG,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,0CAA0C,EAAE;IAChG,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gCAAgC,EAAE;CAC3F,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,KAAK,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,WAAW,CAAC,KAAK,CAAC,E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AAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;IACvB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAAE,IAAI,GAAG,KAAK,CAAC;IAC/G,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,EAAE,EAAE,SAAS;IACb,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,iBAAiB;IAC5B,OAAO,EAAE,qCAAqC;IAC9C,MAAM,EAAE,MAAM;IACd,WAAW;IACX,KAAK;IACL,aAAa;IACb,oBAAoB;IACpB,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { clientId } from "../clientId.js";
|
|
3
|
+
import { RETRY_MAX_ATTEMPTS } from "../retryPolicy.js";
|
|
4
|
+
import { BUFFERED_OUTPUT_TOKENS, DEFAULT_MODEL } from "./manifest.js";
|
|
5
|
+
const MODEL = process.env.MINDWEAVE_MODEL ?? DEFAULT_MODEL;
|
|
6
|
+
/** Output ceiling for a streamed turn. This caps reasoning AND answer together, so
|
|
7
|
+
* it needs headroom at the higher rungs; the family accepts up to 128K. */
|
|
8
|
+
const MAX_TOKENS_STREAM = 64_000;
|
|
9
|
+
/** Buffered calls are the small internal ones (summaries, page distillation), and a
|
|
10
|
+
* non-streaming request that runs long risks an HTTP timeout. The value lives in
|
|
11
|
+
* the manifest because core reserves room for it when setting the compaction bars. */
|
|
12
|
+
const MAX_TOKENS_BUFFERED = BUFFERED_OUTPUT_TOKENS;
|
|
13
|
+
let client = null;
|
|
14
|
+
/** The shared SDK client, or a clear setup error if no key is configured yet. */
|
|
15
|
+
async function api() {
|
|
16
|
+
if (!client) {
|
|
17
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
|
18
|
+
if (!apiKey) {
|
|
19
|
+
throw new Error("No OPENAI_API_KEY found. Add your key to the global config so Mindweave works " +
|
|
20
|
+
"in every project:\n" +
|
|
21
|
+
" ~/.mindweave/.env → OPENAI_API_KEY=your-key-here\n" +
|
|
22
|
+
"(A per-project .env or an exported shell variable also works.)");
|
|
23
|
+
}
|
|
24
|
+
const { default: OpenAIClient } = await import("openai");
|
|
25
|
+
// Retries made explicit rather than inherited. These two drivers reach their
|
|
26
|
+
// provider through a vendor SDK that retries on its own, while the other eleven
|
|
27
|
+
// go through `openaiCompat/wire.ts` and use `retryPolicy.ts`. Pinning the count
|
|
28
|
+
// here means a session behaves the same way whichever provider it is pointed at,
|
|
29
|
+
// and that an SDK upgrade changing its default cannot quietly change ours.
|
|
30
|
+
client = new OpenAIClient({ apiKey, maxRetries: RETRY_MAX_ATTEMPTS - 1, defaultHeaders: { "User-Agent": clientId() } });
|
|
31
|
+
}
|
|
32
|
+
return client;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert the stored transcript into Responses input items.
|
|
36
|
+
*
|
|
37
|
+
* Two shapes have no direct equivalent and are converted rather than passed
|
|
38
|
+
* through: an assistant message's `tool_calls` become sibling `function_call`
|
|
39
|
+
* items, and a `role: "tool"` message becomes a `function_call_output`. A stray
|
|
40
|
+
* in-conversation system message is pulled out and returned separately, because
|
|
41
|
+
* the Responses API carries system text in `instructions` and dropping it would
|
|
42
|
+
* silently lose instructions.
|
|
43
|
+
*/
|
|
44
|
+
export function renderInput(req) {
|
|
45
|
+
const input = [];
|
|
46
|
+
const extraSystem = [];
|
|
47
|
+
for (const msg of req.messages) {
|
|
48
|
+
if (msg.role === "system") {
|
|
49
|
+
if (msg.content.trim())
|
|
50
|
+
extraSystem.push(msg.content);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (msg.role === "tool") {
|
|
54
|
+
input.push({
|
|
55
|
+
type: "function_call_output",
|
|
56
|
+
call_id: msg.tool_call_id ?? "",
|
|
57
|
+
output: msg.content || "(no output)",
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (msg.role === "user") {
|
|
62
|
+
// Images first: the model reads an image-then-text message more reliably
|
|
63
|
+
// than the reverse, and each is labelled so a later turn can name it.
|
|
64
|
+
const content = [];
|
|
65
|
+
for (const img of msg.images ?? []) {
|
|
66
|
+
content.push({ type: "input_text", text: `Image (${basename(img.path)}):` });
|
|
67
|
+
content.push({
|
|
68
|
+
type: "input_image",
|
|
69
|
+
detail: "auto",
|
|
70
|
+
image_url: `data:${img.mediaType};base64,${img.data}`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (msg.content.trim())
|
|
74
|
+
content.push({ type: "input_text", text: msg.content });
|
|
75
|
+
if (content.length > 0)
|
|
76
|
+
input.push({ role: "user", content });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Assistant: prose first, then each tool call as its own item. Plain-string
|
|
80
|
+
// content is the simple input form; the block form is the OUTPUT shape and
|
|
81
|
+
// requires an id and status we neither have nor should invent.
|
|
82
|
+
if (msg.content.trim())
|
|
83
|
+
input.push({ role: "assistant", content: msg.content });
|
|
84
|
+
for (const call of msg.tool_calls ?? []) {
|
|
85
|
+
input.push({
|
|
86
|
+
type: "function_call",
|
|
87
|
+
call_id: call.id,
|
|
88
|
+
name: call.function.name,
|
|
89
|
+
arguments: call.function.arguments || "{}",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { input, extraSystem };
|
|
94
|
+
}
|
|
95
|
+
/** Translate the tool schemas from their stored OpenAI CHAT shape (nested under
|
|
96
|
+
* `function`) into the Responses shape (flat). The two are not interchangeable —
|
|
97
|
+
* sending the nested form here is a validation error, not a tolerated variant. */
|
|
98
|
+
function renderTools(req) {
|
|
99
|
+
return (req.tools ?? []).map((t) => ({
|
|
100
|
+
type: "function",
|
|
101
|
+
name: t.function.name,
|
|
102
|
+
description: t.function.description,
|
|
103
|
+
parameters: (t.function.parameters ?? {}),
|
|
104
|
+
// Loose schema validation: the tool schemas are hand-written and some carry
|
|
105
|
+
// shapes strict mode rejects. The engine validates arguments itself anyway.
|
|
106
|
+
strict: false,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Build the request body shared by both paths.
|
|
111
|
+
*
|
|
112
|
+
* `store: false` is deliberate and load-bearing: by default OpenAI RETAINS the
|
|
113
|
+
* response server-side for later retrieval. Mindweave is a local-first tool whose
|
|
114
|
+
* transcript lives on the user's disk, so leaving a copy of every turn on a vendor's
|
|
115
|
+
* servers is not a default it should inherit silently.
|
|
116
|
+
*
|
|
117
|
+
* The volatile `context` is appended as the LAST input item so a changing code map
|
|
118
|
+
* or todo list never invalidates the cached prefix — OpenAI caches the longest
|
|
119
|
+
* identical prefix from the start, which is the property the ModelRequest split
|
|
120
|
+
* exists to guarantee.
|
|
121
|
+
*/
|
|
122
|
+
export function buildBody(req, maxTokens) {
|
|
123
|
+
const cfg = req.model;
|
|
124
|
+
const { input, extraSystem } = renderInput(req);
|
|
125
|
+
if (req.context && req.context.trim()) {
|
|
126
|
+
input.push({
|
|
127
|
+
role: "user",
|
|
128
|
+
content: [{ type: "input_text", text: `<current_context>\n${req.context}\n</current_context>` }],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// The API rejects an empty conversation; the engine never sends one, but a
|
|
132
|
+
// tool-less internal call could in principle.
|
|
133
|
+
if (input.length === 0) {
|
|
134
|
+
input.push({ role: "user", content: [{ type: "input_text", text: "(no input)" }] });
|
|
135
|
+
}
|
|
136
|
+
const body = {
|
|
137
|
+
model: cfg?.model ?? MODEL,
|
|
138
|
+
instructions: [req.system, ...extraSystem].filter((s) => s.trim()).join("\n\n"),
|
|
139
|
+
input,
|
|
140
|
+
max_output_tokens: maxTokens,
|
|
141
|
+
// Reasoning is ONE dial here: `none` is the off switch rather than a separate
|
|
142
|
+
// flag, so the shared thinking/effort pair collapses into a single rung.
|
|
143
|
+
reasoning: { effort: cfg?.thinking ? cfg.effort : "none" },
|
|
144
|
+
store: false,
|
|
145
|
+
};
|
|
146
|
+
const tools = renderTools(req);
|
|
147
|
+
if (tools.length > 0) {
|
|
148
|
+
body.tools = tools;
|
|
149
|
+
body.tool_choice = "auto";
|
|
150
|
+
}
|
|
151
|
+
return body;
|
|
152
|
+
}
|
|
153
|
+
/** Fold the Responses usage into the shared shape. `input_tokens` here is the FULL
|
|
154
|
+
* prompt including the cached part, unlike Anthropic's, so the miss side is the
|
|
155
|
+
* remainder after cache reads rather than a sum. */
|
|
156
|
+
export function toUsage(usage) {
|
|
157
|
+
if (!usage)
|
|
158
|
+
return undefined;
|
|
159
|
+
const promptTokens = usage.input_tokens ?? 0;
|
|
160
|
+
const cacheHit = usage.input_tokens_details?.cached_tokens ?? 0;
|
|
161
|
+
const completionTokens = usage.output_tokens ?? 0;
|
|
162
|
+
return {
|
|
163
|
+
promptTokens,
|
|
164
|
+
completionTokens,
|
|
165
|
+
totalTokens: usage.total_tokens ?? promptTokens + completionTokens,
|
|
166
|
+
cacheHitTokens: cacheHit,
|
|
167
|
+
cacheMissTokens: Math.max(0, promptTokens - cacheHit),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Map a finished response onto the shared stop reason.
|
|
172
|
+
*
|
|
173
|
+
* The signal lives in two places: an unfinished response says WHY in
|
|
174
|
+
* `incomplete_details`, and a refusal arrives as a content part rather than a
|
|
175
|
+
* status. Both have to be read, or a cut-off reply and a declined one both look
|
|
176
|
+
* like a clean finish and the loop carries on with half an answer.
|
|
177
|
+
*/
|
|
178
|
+
export function toStop(response) {
|
|
179
|
+
if (response.status === "incomplete") {
|
|
180
|
+
return response.incomplete_details?.reason === "content_filter" ? "refused" : "truncated";
|
|
181
|
+
}
|
|
182
|
+
if (response.status === "failed")
|
|
183
|
+
return "overloaded";
|
|
184
|
+
for (const item of response.output ?? []) {
|
|
185
|
+
if (item.type !== "message")
|
|
186
|
+
continue;
|
|
187
|
+
for (const part of item.content ?? []) {
|
|
188
|
+
if (part.type === "refusal")
|
|
189
|
+
return "refused";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return "end";
|
|
193
|
+
}
|
|
194
|
+
/** Pull the assembled reply and tool calls out of a finished response. */
|
|
195
|
+
export function toTurn(response) {
|
|
196
|
+
let content = "";
|
|
197
|
+
const toolCalls = [];
|
|
198
|
+
for (const item of response.output ?? []) {
|
|
199
|
+
if (item.type === "message") {
|
|
200
|
+
for (const part of item.content ?? []) {
|
|
201
|
+
if (part.type === "output_text")
|
|
202
|
+
content += part.text;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (item.type === "function_call") {
|
|
206
|
+
toolCalls.push({
|
|
207
|
+
// The engine echoes this back as the result's key, and the API matches
|
|
208
|
+
// results on `call_id` — NOT on the item's own `id`. Sending the wrong
|
|
209
|
+
// one is an unmatched-result error on the following turn.
|
|
210
|
+
id: item.call_id,
|
|
211
|
+
name: item.name,
|
|
212
|
+
arguments: item.arguments || "{}",
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// `reasoning` items are deliberately dropped — see the note in the file header.
|
|
216
|
+
}
|
|
217
|
+
return { content, toolCalls, stop: toStop(response) };
|
|
218
|
+
}
|
|
219
|
+
/** Ask the model for one turn. Usage rides back with it: these are core's internal
|
|
220
|
+
* calls, and they spend real tokens that the meter would otherwise never see. */
|
|
221
|
+
export async function toolTurn(req, options = {}) {
|
|
222
|
+
const response = await (await api()).responses.create(buildBody(req, MAX_TOKENS_BUFFERED), {
|
|
223
|
+
signal: options.signal,
|
|
224
|
+
});
|
|
225
|
+
return { ...toTurn(response), usage: toUsage(response.usage) };
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Ask the model for one turn, STREAMING. Deltas go to `options.onEvent` for the
|
|
229
|
+
* live UI; the assembled turn is the return value, in the same shape the engine
|
|
230
|
+
* records either way. The SDK assembles the final response (including each tool
|
|
231
|
+
* call's JSON), so nothing here reassembles fragmented arguments by hand.
|
|
232
|
+
*/
|
|
233
|
+
export async function streamTurn(req, options = {}) {
|
|
234
|
+
const stream = (await api()).responses.stream({ ...buildBody(req, MAX_TOKENS_STREAM), stream: true }, { signal: options.signal });
|
|
235
|
+
if (options.onEvent) {
|
|
236
|
+
// Tool calls are announced by item index, and the shared event shape keys on a
|
|
237
|
+
// dense index — so map the API's `output_index` onto one.
|
|
238
|
+
const indexOf = new Map();
|
|
239
|
+
for await (const event of stream) {
|
|
240
|
+
emit(event, options.onEvent, indexOf);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const response = await stream.finalResponse();
|
|
244
|
+
return { ...toTurn(response), usage: toUsage(response.usage) };
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Map one streaming event onto the shared event shape.
|
|
248
|
+
*
|
|
249
|
+
* Reasoning arrives on two different channels depending on how the model was
|
|
250
|
+
* asked — `reasoning_text` when the raw stream is available, `reasoning_summary_text`
|
|
251
|
+
* when only a summary is. Both are handled: whichever one the provider sends, the
|
|
252
|
+
* UI shows reasoning rather than an unexplained pause.
|
|
253
|
+
*/
|
|
254
|
+
export function emit(event, onEvent, indexOf) {
|
|
255
|
+
switch (event.type) {
|
|
256
|
+
case "response.output_text.delta":
|
|
257
|
+
if (event.delta)
|
|
258
|
+
onEvent({ type: "text", delta: event.delta });
|
|
259
|
+
return;
|
|
260
|
+
case "response.reasoning_text.delta":
|
|
261
|
+
case "response.reasoning_summary_text.delta":
|
|
262
|
+
if (event.delta)
|
|
263
|
+
onEvent({ type: "reasoning", delta: event.delta });
|
|
264
|
+
return;
|
|
265
|
+
case "response.output_item.added": {
|
|
266
|
+
const item = event.item;
|
|
267
|
+
if (item.type !== "function_call")
|
|
268
|
+
return;
|
|
269
|
+
const index = indexOf.size;
|
|
270
|
+
indexOf.set(event.output_index, index);
|
|
271
|
+
onEvent({ type: "tool_start", index, id: item.call_id, name: item.name });
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
case "response.function_call_arguments.delta": {
|
|
275
|
+
const index = indexOf.get(event.output_index);
|
|
276
|
+
// A fragment before its item was announced has nowhere to go; the final
|
|
277
|
+
// response still carries the whole call, so dropping the delta only costs
|
|
278
|
+
// the live preview, never the call itself.
|
|
279
|
+
if (index === undefined || !event.delta)
|
|
280
|
+
return;
|
|
281
|
+
onEvent({ type: "tool_args", index, delta: event.delta });
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
default:
|
|
285
|
+
// Every other event (created, in_progress, content_part.*, done, usage) has
|
|
286
|
+
// no shared equivalent — the assembled response carries what they describe.
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/drivers/openai/client.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAYvD,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;A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OAAO,CAAC,IAAI,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YACvC,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,KAAK,wCAAwC,CAAC,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC9C,wEAAwE;YACxE,0EAA0E;YAC1E,2CAA2C;YAC3C,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,KAAK;gBAAE,OAAO;YAChD,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC1D,OAAO;QACT,CAAC;QAED;YACE,4EAA4E;YAC5E,4EAA4E;YAC5E,OAAO;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drivers/openai/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,GAAG,cAAc;IACjB,QAAQ;IACR,UAAU;CACX,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export const SOL = "gpt-5.6-sol";
|
|
2
|
+
export const TERRA = "gpt-5.6-terra";
|
|
3
|
+
export const LUNA = "gpt-5.6-luna";
|
|
4
|
+
/** The model used when nothing is saved and no env override is set. */
|
|
5
|
+
export const DEFAULT_MODEL = TERRA;
|
|
6
|
+
/**
|
|
7
|
+
* The models offered by `/model`. First entry is this provider's default, which is
|
|
8
|
+
* also where `/provider` lands when someone switches to OpenAI.
|
|
9
|
+
*
|
|
10
|
+
* Terra leads because it is the balanced tier — Sol is roughly 2.5x its rate and
|
|
11
|
+
* Luna a tenth of it, so Terra is the one that is rarely the wrong answer.
|
|
12
|
+
*/
|
|
13
|
+
export const MODELS = [
|
|
14
|
+
{ id: TERRA, label: "GPT-5.6 Terra", description: "balanced intelligence and cost — the default" },
|
|
15
|
+
{ id: SOL, label: "GPT-5.6 Sol", description: "the frontier tier, for the hardest problems" },
|
|
16
|
+
{ id: LUNA, label: "GPT-5.6 Luna", description: "cheap and quick, for high-volume work" },
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* The reasoning levels offered by `/think`.
|
|
20
|
+
*
|
|
21
|
+
* OpenAI expresses reasoning as a single `effort` rung with `none` as its off
|
|
22
|
+
* switch, rather than a separate on/off flag plus a budget. That maps onto the
|
|
23
|
+
* shared shape cleanly: `thinking: false` becomes `none` on the wire, and the four
|
|
24
|
+
* thinking rungs are sent as themselves. All three models take the same ladder.
|
|
25
|
+
*
|
|
26
|
+
* The provider also accepts `minimal` between `none` and `low`. It is not offered:
|
|
27
|
+
* it would be a fifth rung whose difference from `low` no user could predict, and
|
|
28
|
+
* the ladder is more useful short.
|
|
29
|
+
*/
|
|
30
|
+
export function thinkLevels(_model) {
|
|
31
|
+
return [
|
|
32
|
+
{ label: "Standard", description: "answer directly — fastest", thinking: false, effort: "high" },
|
|
33
|
+
{ label: "Thinking", description: "think first, then answer", thinking: true, effort: "medium" },
|
|
34
|
+
{ label: "Deep", description: "more reasoning, more tool work", thinking: true, effort: "high" },
|
|
35
|
+
{ label: "Maximum", description: "maximum reasoning budget", thinking: true, effort: "max" },
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List prices (USD / 1M tokens). Cached input bills at a tenth of fresh input,
|
|
40
|
+
* which is what keeps a re-sent conversation cheap.
|
|
41
|
+
*/
|
|
42
|
+
const PRICES = {
|
|
43
|
+
[SOL]: { cacheHit: 0.5, cacheMiss: 5, output: 30 },
|
|
44
|
+
[TERRA]: { cacheHit: 0.2, cacheMiss: 2, output: 12 },
|
|
45
|
+
[LUNA]: { cacheHit: 0.02, cacheMiss: 0.2, output: 1.2 },
|
|
46
|
+
};
|
|
47
|
+
/** Cache-aware list price for a model, falling back to the default model's. */
|
|
48
|
+
export function price(model) {
|
|
49
|
+
return PRICES[model] ?? PRICES[DEFAULT_MODEL];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The model's USABLE context window. All three STORE 1.05M tokens (922K of it
|
|
53
|
+
* input), but this is deliberately the sharp window rather than the storage cap:
|
|
54
|
+
* on BYOK every token in the window is the user's money on every turn, so
|
|
55
|
+
* anchoring compaction at 1M would mean carrying an enormous prompt long after it
|
|
56
|
+
* stopped earning its cost. Same reasoning, and the same number, as Anthropic's.
|
|
57
|
+
*/
|
|
58
|
+
export function contextWindow(_model) {
|
|
59
|
+
return 200_000;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The ceiling this driver puts on a single BUFFERED (non-streaming) call.
|
|
63
|
+
*
|
|
64
|
+
* All three models accept 128K output, but a non-streaming request that runs that
|
|
65
|
+
* long risks an HTTP timeout, so the buffered path — core's small internal calls,
|
|
66
|
+
* like a compaction summary — is capped far lower. `client.ts` sends this value and
|
|
67
|
+
* `dynamo/contextWindow.ts` reserves it; one exported constant means the request
|
|
68
|
+
* and the reservation cannot drift apart.
|
|
69
|
+
*/
|
|
70
|
+
export const BUFFERED_OUTPUT_TOKENS = 16_000;
|
|
71
|
+
export function bufferedOutputTokens(_model) {
|
|
72
|
+
return BUFFERED_OUTPUT_TOKENS;
|
|
73
|
+
}
|
|
74
|
+
/** The effort rungs this provider accepts, weakest first. */
|
|
75
|
+
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
76
|
+
/** Every model in this family takes image input alongside text. */
|
|
77
|
+
export function acceptsImages(_model) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Coerce a stored or unknown config onto a model this provider actually serves.
|
|
82
|
+
*
|
|
83
|
+
* There is no per-model rule to enforce here — the family shares one ladder, so an
|
|
84
|
+
* unknown model id falls back and an unknown effort clamps, and that is all. The
|
|
85
|
+
* result is then snapped onto a rung `/think` actually lists, so a config carried
|
|
86
|
+
* in from another provider by `/model` cannot leave the user on a setting the menu
|
|
87
|
+
* has no tick beside.
|
|
88
|
+
*/
|
|
89
|
+
export function normalize(config) {
|
|
90
|
+
const model = PRICES[config.model] ? config.model : DEFAULT_MODEL;
|
|
91
|
+
const thinking = config.thinking === true;
|
|
92
|
+
const effort = EFFORTS.includes(config.effort) ? config.effort : "high";
|
|
93
|
+
return { model, thinking, effort: snapToOfferedRung(model, thinking, effort) };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Move an effort onto the nearest rung this model's `/think` ladder offers.
|
|
97
|
+
*
|
|
98
|
+
* Ties break DOWNWARD: an unlisted setting resolves to the cheaper neighbour, never
|
|
99
|
+
* the dearer one, because silently spending more of the user's money than the level
|
|
100
|
+
* they were on is the worse of the two ways to be wrong.
|
|
101
|
+
*/
|
|
102
|
+
function snapToOfferedRung(model, thinking, effort) {
|
|
103
|
+
const offered = thinkLevels(model).filter((l) => l.thinking === thinking);
|
|
104
|
+
if (offered.length === 0)
|
|
105
|
+
return effort;
|
|
106
|
+
if (offered.some((l) => l.effort === effort))
|
|
107
|
+
return effort;
|
|
108
|
+
const want = EFFORTS.indexOf(effort);
|
|
109
|
+
let best = offered[0];
|
|
110
|
+
for (const level of offered) {
|
|
111
|
+
const d = Math.abs(EFFORTS.indexOf(level.effort) - want);
|
|
112
|
+
const bestD = Math.abs(EFFORTS.indexOf(best.effort) - want);
|
|
113
|
+
if (d < bestD || (d === bestD && EFFORTS.indexOf(level.effort) < EFFORTS.indexOf(best.effort))) {
|
|
114
|
+
best = level;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return best.effort;
|
|
118
|
+
}
|
|
119
|
+
/** The cheap metadata half of this driver — see `index.ts` for the wire half. */
|
|
120
|
+
export const openaiManifest = {
|
|
121
|
+
id: "openai",
|
|
122
|
+
label: "OpenAI",
|
|
123
|
+
apiKeyEnv: "OPENAI_API_KEY",
|
|
124
|
+
keysUrl: "https://platform.openai.com/api-keys",
|
|
125
|
+
models: MODELS,
|
|
126
|
+
thinkLevels,
|
|
127
|
+
price,
|
|
128
|
+
contextWindow,
|
|
129
|
+
bufferedOutputTokens,
|
|
130
|
+
acceptsImages,
|
|
131
|
+
normalize,
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/drivers/openai/manifest.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;AACrC,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC;AAEnC,uEAAuE;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkB;IACnC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,8CAA8C,EAAE;IAClG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,6CAA6C,EAAE;IAC7F,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,uCAAuC,EAAE;CAC1F,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,OAAO;QACL,EAAE,KAAK,EAAE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