@engenty/wizards-runtime 0.20.6 → 0.21.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/README.md +3 -3
- package/apps/runtime/dist/agents/studio-assistant.js +7 -3
- package/apps/runtime/dist/agents/subscription.js +4 -17
- package/apps/runtime/dist/app.js +4 -1
- package/apps/runtime/dist/cli/clients.js +6 -24
- package/apps/runtime/dist/cli/connect.js +2 -1
- package/apps/runtime/dist/cli/environment.js +3 -0
- package/apps/runtime/dist/cli/machine.js +1 -70
- package/apps/runtime/dist/cli/main.js +2 -1
- package/apps/runtime/dist/cli/ollama.js +1 -179
- package/apps/runtime/dist/cli/setup.js +8 -6
- package/apps/runtime/dist/docs/dev/licensing.md +15 -9
- package/apps/runtime/dist/docs/user-guide/command-line.md +3 -0
- package/apps/runtime/dist/elements/outside.js +2 -1
- package/apps/runtime/dist/engine/code-step.js +1 -1
- package/apps/runtime/dist/engine/decide.js +2 -2
- package/apps/runtime/dist/engine/input.js +1 -1
- package/apps/runtime/dist/engine/runner.js +1 -1
- package/apps/runtime/dist/engine/steps.js +27 -8
- package/apps/runtime/dist/engine/surface.js +1 -1
- package/apps/runtime/dist/engine/template.js +1 -1
- package/apps/runtime/dist/env.js +1 -0
- package/apps/runtime/dist/harness/clients.js +10 -1
- package/apps/runtime/dist/harness/index.js +15 -69
- package/apps/runtime/dist/harness/types.js +3 -2
- package/apps/runtime/dist/local-call.js +6 -0
- package/apps/runtime/dist/local-models.js +53 -157
- package/apps/runtime/dist/mcp/bridge.js +12 -55
- package/apps/runtime/dist/mcp/elements.js +39 -4
- package/apps/runtime/dist/mcp/handler.js +12 -0
- package/apps/runtime/dist/mcp/run-pages.js +238 -0
- package/apps/runtime/dist/mcp/run-tasks.js +157 -0
- package/apps/runtime/dist/mcp/runs.js +129 -0
- package/apps/runtime/dist/mcp/tools.js +4 -95
- package/apps/runtime/dist/models.js +74 -27
- package/apps/runtime/dist/prompts/mcp.md +4 -1
- package/apps/runtime/dist/render/downloads.js +1 -1
- package/apps/runtime/dist/render/shaped.js +1 -1
- package/apps/runtime/dist/routes/model-setup.js +77 -0
- package/apps/runtime/dist/routes/studio.js +8 -251
- package/apps/runtime/dist/services/space-categories.js +1 -1
- package/apps/runtime/dist/services/work-ai.js +10 -4
- package/apps/runtime/dist/texts.js +4 -6
- package/apps/runtime/dist/tools/connections.js +3 -0
- package/apps/runtime/dist/tools/harness.js +124 -0
- package/apps/web/dist/assets/AboutDialog-BSdAA4Wi.js +1 -0
- package/apps/web/dist/assets/{BlockEditor-CgjXTWly.js → BlockEditor-0noqMcAl.js} +1 -1
- package/apps/web/dist/assets/Bundle-Ctrq7lHH.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-CZlVhBmU.js +2 -0
- package/apps/web/dist/assets/ChangelogDialog-BLCYV4jT.js +1 -0
- package/apps/web/dist/assets/{CodeEditor-2LyHbSre.js → CodeEditor-CpRn9BZq.js} +1 -1
- package/apps/web/dist/assets/ConnectorsSection-B4rRDlFo.js +1 -0
- package/apps/web/dist/assets/EditorPage-CXN-_zzG.js +3 -0
- package/apps/web/dist/assets/FlowPreview-DjQvcWxs.js +1 -0
- package/apps/web/dist/assets/LangSwitch-BuzsLp16.js +1 -0
- package/apps/web/dist/assets/LocalModels-BDfP2v5-.js +1 -0
- package/apps/web/dist/assets/Marketplace-4baBNzEc.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-B_xHm-bI.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-BmZAY4zi.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-fZq3WiTk.js +1 -0
- package/apps/web/dist/assets/ProtocolSection-v9wIxisg.js +1 -0
- package/apps/web/dist/assets/PublicRunner-BCh0VzAT.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-CO3ndR23.js → ReadOnly-13stkvNz.js} +1 -1
- package/apps/web/dist/assets/Results-4gmguYzH.js +1 -0
- package/apps/web/dist/assets/RunDrawer-CeEldWRn.js +1 -0
- package/apps/web/dist/assets/SettingsPage-BsKRRlfP.js +2 -0
- package/apps/web/dist/assets/SetupPage-FgA5Kl8z.js +1 -0
- package/apps/web/dist/assets/SharePage-BlBW4oxl.js +1 -0
- package/apps/web/dist/assets/SkillEditor-9QSskfmY.js +1 -0
- package/apps/web/dist/assets/Skills-DdUAyNhR.js +9 -0
- package/apps/web/dist/assets/SpacePage-CHkNPuqt.js +2 -0
- package/apps/web/dist/assets/StudioHome-BwPD-inc.js +1 -0
- package/apps/web/dist/assets/TableEditor-Du1DhbEC.js +7 -0
- package/apps/web/dist/assets/UpdateCheck-DPr9NXq_.js +2 -0
- package/apps/web/dist/assets/brand-DY3lzrOd.js +2 -0
- package/apps/web/dist/assets/changelog-BSdb22c3.js +1 -0
- package/apps/web/dist/assets/code-editor-Bep_LzQ5.js +2 -0
- package/apps/web/dist/assets/host-DiZQ_uws.js +1 -0
- package/apps/web/dist/assets/host-Dw-sMUSd.js +54 -0
- package/apps/web/dist/assets/i18n-DVrYWJaj.js +55 -0
- package/apps/web/dist/assets/index-C2gxK14s.css +1 -0
- package/apps/web/dist/assets/index-lQ4JYHYQ.js +102 -0
- package/apps/web/dist/assets/oss-credits-BHy69wkx.js +1 -0
- package/apps/web/dist/assets/{read-aloud-CRFt5q6k.js → read-aloud-CBycd8TA.js} +1 -1
- package/apps/web/dist/assets/{session-RDdtfee2.js → session-BYLtgklo.js} +1 -1
- package/apps/web/dist/assets/terminal-DmGdMags.js +16 -0
- package/apps/web/dist/assets/texts-ClKS2xhh.js +1 -0
- package/apps/web/dist/assets/theme-DFDOMsVo.js +14 -0
- package/apps/web/dist/assets/ui-CW2I3ecu.js +1 -0
- package/apps/web/dist/assets/ui-DfVpZYIW.js +16 -0
- package/apps/web/dist/assets/{useMutation-BSffqL6W.js → useMutation-BnkuLlQC.js} +1 -1
- package/apps/web/dist/assets/viewers-C6FfRwG1.js +2 -0
- package/apps/web/dist/index.html +18 -16
- package/apps/web/dist/mcp/flow.html +129 -129
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.js +1 -1
- package/node_modules/@engenty/chatviews/dist/chat/a2ui.d.ts +48 -0
- package/node_modules/@engenty/chatviews/dist/chat/a2ui.js +514 -0
- package/node_modules/@engenty/chatviews/dist/chat/check.d.ts +18 -0
- package/node_modules/@engenty/chatviews/dist/chat/check.js +97 -0
- package/node_modules/@engenty/chatviews/dist/chat/index.d.ts +3 -0
- package/node_modules/@engenty/chatviews/dist/chat/index.js +4 -0
- package/node_modules/@engenty/chatviews/dist/chat/library.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/chat/library.js +314 -0
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.js +1 -1
- package/node_modules/@engenty/chatviews/dist/react/chat.d.ts +33 -0
- package/node_modules/@engenty/chatviews/dist/react/chat.js +150 -0
- package/node_modules/@engenty/chatviews/dist/react/field-looks.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/field-looks.js +47 -0
- package/node_modules/@engenty/chatviews/dist/react/markdown.d.ts +5 -0
- package/node_modules/@engenty/chatviews/dist/react/markdown.js +11 -0
- package/node_modules/@engenty/chatviews/dist/react/no-devtools.d.ts +0 -0
- package/node_modules/@engenty/chatviews/dist/react/no-devtools.js +8 -0
- package/node_modules/@engenty/chatviews/dist/react/surface.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/surface.js +552 -0
- package/node_modules/@engenty/chatviews/dist/react/texts.d.ts +39 -0
- package/node_modules/@engenty/chatviews/dist/react/texts.js +42 -0
- package/node_modules/@engenty/chatviews/dist/react/ui.d.ts +112 -0
- package/node_modules/@engenty/chatviews/dist/react/ui.js +212 -0
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.js +1 -1
- package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.js +1 -1
- package/node_modules/@engenty/chatviews/package.json +19 -0
- package/node_modules/@engenty/decision-model/dist/client.d.ts +76 -0
- package/node_modules/@engenty/decision-model/dist/client.js +188 -0
- package/node_modules/@engenty/decision-model/dist/index.d.ts +6 -0
- package/node_modules/@engenty/decision-model/dist/index.js +5 -0
- package/node_modules/@engenty/decision-model/dist/local.d.ts +11 -0
- package/node_modules/@engenty/decision-model/dist/local.js +116 -0
- package/node_modules/@engenty/decision-model/dist/resolve.d.ts +26 -0
- package/node_modules/@engenty/decision-model/dist/resolve.js +53 -0
- package/node_modules/@engenty/decision-model/dist/types.d.ts +80 -0
- package/node_modules/@engenty/decision-model/dist/types.js +6 -0
- package/node_modules/@engenty/decision-model/dist/validate.d.ts +9 -0
- package/node_modules/@engenty/decision-model/dist/validate.js +50 -0
- package/node_modules/@engenty/decision-model/dist/ways.d.ts +42 -0
- package/node_modules/@engenty/decision-model/dist/ways.js +72 -0
- package/node_modules/@engenty/decision-model/package.json +9 -0
- package/node_modules/@engenty/local-models/dist/bridge/index.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/bridge/index.js +117 -0
- package/node_modules/@engenty/local-models/dist/clients/antigravity.d.ts +37 -0
- package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/antigravity.js +68 -17
- package/node_modules/@engenty/local-models/dist/clients/claude.js +1 -0
- package/node_modules/@engenty/local-models/dist/clients/client.d.ts +3 -1
- package/node_modules/@engenty/local-models/dist/clients/client.js +1 -1
- package/node_modules/@engenty/local-models/dist/clients/codex.js +1 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +2 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.js +13 -1
- package/node_modules/@engenty/local-models/dist/clients/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/clients/index.js +4 -2
- package/node_modules/@engenty/local-models/dist/clients/model.d.ts +4 -1
- package/node_modules/@engenty/local-models/dist/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/index.js +2 -1
- package/node_modules/@engenty/local-models/dist/lmstudio/api.d.ts +49 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/api.js +101 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/load.d.ts +12 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/load.js +100 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/server.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/lmstudio/server.js +29 -0
- package/node_modules/@engenty/local-models/dist/mlx/helper.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/mlx/helper.js +149 -0
- package/node_modules/@engenty/local-models/dist/mlx/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/mlx/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/mlx/server.d.ts +19 -0
- package/node_modules/@engenty/local-models/dist/mlx/server.js +82 -0
- package/node_modules/@engenty/local-models/dist/mlx/store.d.ts +16 -0
- package/node_modules/@engenty/local-models/dist/mlx/store.js +153 -0
- package/node_modules/@engenty/local-models/dist/ollama/api.d.ts +4 -37
- package/node_modules/@engenty/local-models/dist/ollama/api.js +1 -18
- package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +2 -1
- package/node_modules/@engenty/local-models/dist/ollama/index.js +2 -1
- package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +2 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.js +1 -1
- package/node_modules/@engenty/local-models/dist/ollama/server.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/ollama/server.js +45 -0
- package/node_modules/@engenty/local-models/dist/probe.d.ts +11 -8
- package/node_modules/@engenty/local-models/dist/probe.js +16 -32
- package/node_modules/@engenty/local-models/dist/servers/index.d.ts +6 -0
- package/node_modules/@engenty/local-models/dist/servers/index.js +12 -0
- package/node_modules/@engenty/local-models/dist/servers/server.d.ts +84 -0
- package/node_modules/@engenty/local-models/dist/servers/server.js +38 -0
- package/node_modules/@engenty/local-models/package.json +5 -1
- package/node_modules/@engenty/model-setup/dist/catalog.d.ts +36 -0
- package/node_modules/@engenty/model-setup/dist/catalog.js +81 -0
- package/node_modules/@engenty/model-setup/dist/index.d.ts +3 -0
- package/node_modules/@engenty/model-setup/dist/index.js +3 -0
- package/node_modules/@engenty/model-setup/dist/offered.d.ts +7 -0
- package/node_modules/@engenty/model-setup/dist/offered.js +64 -0
- package/node_modules/@engenty/model-setup/dist/react/client.d.ts +46 -0
- package/node_modules/@engenty/model-setup/dist/react/client.js +147 -0
- package/node_modules/@engenty/model-setup/dist/react/columns.d.ts +78 -0
- package/node_modules/@engenty/model-setup/dist/react/columns.js +99 -0
- package/node_modules/@engenty/model-setup/dist/react/host.d.ts +31 -0
- package/node_modules/@engenty/model-setup/dist/react/host.js +48 -0
- package/node_modules/@engenty/model-setup/dist/react/index.d.ts +7 -0
- package/node_modules/@engenty/model-setup/dist/react/index.js +7 -0
- package/node_modules/@engenty/model-setup/dist/react/keys.d.ts +48 -0
- package/node_modules/@engenty/model-setup/dist/react/keys.js +74 -0
- package/node_modules/@engenty/model-setup/dist/react/local-models.d.ts +23 -0
- package/node_modules/@engenty/model-setup/dist/react/local-models.js +134 -0
- package/node_modules/@engenty/model-setup/dist/react/servers.d.ts +4 -0
- package/node_modules/@engenty/model-setup/dist/react/servers.js +13 -0
- package/node_modules/@engenty/model-setup/dist/react/terminal.d.ts +13 -0
- package/node_modules/@engenty/model-setup/dist/react/terminal.js +79 -0
- package/node_modules/@engenty/model-setup/dist/react/tone.d.ts +13 -0
- package/node_modules/@engenty/model-setup/dist/react/tone.js +66 -0
- package/node_modules/@engenty/model-setup/dist/server/apps.d.ts +12 -0
- package/node_modules/@engenty/model-setup/dist/server/apps.js +22 -0
- package/node_modules/@engenty/model-setup/dist/server/clients.d.ts +55 -0
- package/node_modules/@engenty/model-setup/dist/server/clients.js +96 -0
- package/node_modules/@engenty/model-setup/dist/server/index.d.ts +8 -0
- package/node_modules/@engenty/model-setup/dist/server/index.js +8 -0
- package/node_modules/@engenty/model-setup/dist/server/install.d.ts +24 -0
- package/node_modules/@engenty/model-setup/dist/server/install.js +68 -0
- package/node_modules/@engenty/model-setup/dist/server/lmstudio.d.ts +9 -0
- package/node_modules/@engenty/model-setup/dist/server/lmstudio.js +52 -0
- package/node_modules/@engenty/model-setup/dist/server/local-models.d.ts +47 -0
- package/node_modules/@engenty/model-setup/dist/server/local-models.js +164 -0
- package/node_modules/@engenty/model-setup/dist/server/models.d.ts +12 -0
- package/node_modules/@engenty/model-setup/dist/server/models.js +16 -0
- package/node_modules/@engenty/model-setup/dist/server/ollama.d.ts +22 -0
- package/node_modules/@engenty/model-setup/dist/server/ollama.js +146 -0
- package/node_modules/@engenty/model-setup/dist/server/routes.d.ts +51 -0
- package/node_modules/@engenty/model-setup/dist/server/routes.js +211 -0
- package/node_modules/@engenty/model-setup/dist/server/server-apps.d.ts +14 -0
- package/node_modules/@engenty/model-setup/dist/server/server-apps.js +24 -0
- package/node_modules/@engenty/model-setup/dist/server/terminal.d.ts +43 -0
- package/node_modules/@engenty/model-setup/dist/server/terminal.js +222 -0
- package/node_modules/@engenty/model-setup/dist/texts.d.ts +222 -0
- package/node_modules/@engenty/model-setup/dist/texts.js +222 -0
- package/node_modules/@engenty/model-setup/dist/types.d.ts +111 -0
- package/node_modules/@engenty/model-setup/dist/types.js +2 -0
- package/node_modules/@engenty/model-setup/package.json +12 -0
- package/node_modules/@engenty/search-index/dist/catalog-lexical.d.ts +14 -0
- package/node_modules/@engenty/search-index/dist/catalog-lexical.js +165 -0
- package/node_modules/@engenty/search-index/dist/catalog-rank.d.ts +33 -0
- package/node_modules/@engenty/search-index/dist/catalog-rank.js +99 -0
- package/node_modules/@engenty/search-index/dist/catalog-search.d.ts +40 -0
- package/node_modules/@engenty/search-index/dist/catalog-search.js +161 -0
- package/node_modules/@engenty/search-index/dist/chunks.d.ts +17 -0
- package/node_modules/@engenty/search-index/dist/chunks.js +164 -0
- package/node_modules/@engenty/search-index/dist/contracts.d.ts +135 -0
- package/node_modules/@engenty/search-index/dist/contracts.js +9 -0
- package/node_modules/@engenty/search-index/dist/embedder.d.ts +31 -0
- package/node_modules/@engenty/search-index/dist/embedder.js +82 -0
- package/node_modules/@engenty/search-index/dist/embedders/gemini.d.ts +11 -0
- package/node_modules/@engenty/search-index/dist/embedders/gemini.js +54 -0
- package/node_modules/@engenty/search-index/dist/embedders/index.d.ts +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/index.js +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/ollama.d.ts +12 -0
- package/node_modules/@engenty/search-index/dist/embedders/ollama.js +43 -0
- package/node_modules/@engenty/search-index/dist/embedders/openai.d.ts +11 -0
- package/node_modules/@engenty/search-index/dist/embedders/openai.js +36 -0
- package/node_modules/@engenty/search-index/dist/embedders/shared.d.ts +5 -0
- package/node_modules/@engenty/search-index/dist/embedders/shared.js +26 -0
- package/node_modules/@engenty/search-index/dist/embedders/ways.d.ts +16 -0
- package/node_modules/@engenty/search-index/dist/embedders/ways.js +90 -0
- package/node_modules/@engenty/search-index/dist/index.d.ts +10 -0
- package/node_modules/@engenty/search-index/dist/index.js +10 -0
- package/node_modules/@engenty/search-index/dist/payload.d.ts +13 -0
- package/node_modules/@engenty/search-index/dist/payload.js +51 -0
- package/node_modules/@engenty/search-index/dist/registry.d.ts +25 -0
- package/node_modules/@engenty/search-index/dist/registry.js +56 -0
- package/node_modules/@engenty/search-index/dist/scoring.d.ts +10 -0
- package/node_modules/@engenty/search-index/dist/scoring.js +45 -0
- package/node_modules/@engenty/search-index/dist/strategy.d.ts +6 -0
- package/node_modules/@engenty/search-index/dist/strategy.js +25 -0
- package/node_modules/@engenty/search-index/package.json +10 -0
- package/node_modules/@engenty/tool-harness/dist/harness.d.ts +70 -0
- package/node_modules/@engenty/tool-harness/dist/harness.js +170 -0
- package/node_modules/@engenty/tool-harness/dist/index.d.ts +5 -0
- package/node_modules/@engenty/tool-harness/dist/index.js +5 -0
- package/node_modules/@engenty/tool-harness/dist/judge.d.ts +8 -0
- package/node_modules/@engenty/tool-harness/dist/judge.js +39 -0
- package/node_modules/@engenty/tool-harness/dist/levels.d.ts +18 -0
- package/node_modules/@engenty/tool-harness/dist/levels.js +47 -0
- package/node_modules/@engenty/tool-harness/dist/model.d.ts +6 -0
- package/node_modules/@engenty/tool-harness/dist/model.js +60 -0
- package/node_modules/@engenty/tool-harness/dist/schema.d.ts +26 -0
- package/node_modules/@engenty/tool-harness/dist/schema.js +57 -0
- package/node_modules/@engenty/tool-harness/package.json +9 -0
- package/node_modules/@engenty/wizards-shared/dist/catalog-prompt.js +2 -1
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +10 -10
- package/node_modules/@engenty/wizards-shared/dist/definition.js +4 -4
- package/node_modules/@engenty/wizards-shared/dist/run-schema.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.js +4 -0
- package/node_modules/@engenty/wizards-shared/dist/store.js +2 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-agents.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-agents.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-text.js +2 -2
- package/package.json +11 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/runtime/dist/harness/terminal.js +0 -201
- package/apps/web/dist/assets/AboutDialog-BRUwrfQH.js +0 -1
- package/apps/web/dist/assets/Bundle-C0u5HUZL.js +0 -1
- package/apps/web/dist/assets/CapabilitiesPage-C30knXsS.js +0 -2
- package/apps/web/dist/assets/ChangelogDialog-BkZQOAdl.js +0 -1
- package/apps/web/dist/assets/ConnectorsSection-CmXQD7zu.js +0 -1
- package/apps/web/dist/assets/EditorPage-LEbyNWmG.js +0 -3
- package/apps/web/dist/assets/FlowPreview-BXf4EKjU.js +0 -1
- package/apps/web/dist/assets/LangSwitch-BLB7dDce.js +0 -1
- package/apps/web/dist/assets/Marketplace-B3NoH5Va.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-CSn-9zHr.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B4wPfClS.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-RawpCO9J.js +0 -1
- package/apps/web/dist/assets/ProtocolSection-s4mEL_pu.js +0 -1
- package/apps/web/dist/assets/PublicRunner-COatyxMi.js +0 -1
- package/apps/web/dist/assets/Results-CC1-mElv.js +0 -1
- package/apps/web/dist/assets/RunDrawer-DkmSXhad.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DKs_fkNL.js +0 -2
- package/apps/web/dist/assets/SetupPage-RvmKCzF2.js +0 -1
- package/apps/web/dist/assets/SharePage-Drntg_oj.js +0 -1
- package/apps/web/dist/assets/SkillEditor-Ca_bzmjD.js +0 -1
- package/apps/web/dist/assets/Skills-BcgxuD15.js +0 -9
- package/apps/web/dist/assets/SpacePage-aZqYFttF.js +0 -2
- package/apps/web/dist/assets/StudioHome-Doua9Lyl.js +0 -1
- package/apps/web/dist/assets/TableEditor-Dbq3HZZS.js +0 -7
- package/apps/web/dist/assets/UpdateCheck-B7etUbUf.js +0 -2
- package/apps/web/dist/assets/brand-BIT7AumL.js +0 -2
- package/apps/web/dist/assets/changelog-BW79cVbx.js +0 -1
- package/apps/web/dist/assets/code-editor-CufyaUFC.js +0 -2
- package/apps/web/dist/assets/host-BXSxBoOH.js +0 -69
- package/apps/web/dist/assets/i18n-WXeVnv7i.js +0 -55
- package/apps/web/dist/assets/index-D1iL3986.css +0 -1
- package/apps/web/dist/assets/index-kDKA6ddy.js +0 -102
- package/apps/web/dist/assets/oss-credits-B3PXhamW.js +0 -1
- package/apps/web/dist/assets/theme-23bNrOQh.js +0 -14
- package/apps/web/dist/assets/ui-DkEhb2Rt.js +0 -16
- package/apps/web/dist/assets/viewers-CmGDpBjn.js +0 -2
- /package/apps/web/dist/assets/{host-BrP-ENHg.css → terminal-BrP-ENHg.css} +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/calc.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/numbers.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/shape.d.ts +0 -0
- /package/node_modules/@engenty/{wizards-shared → chatviews}/dist/surface.d.ts +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { createReadStream, createWriteStream, existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, readdir, readFile, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
7
|
+
import { pipeline } from "node:stream/promises";
|
|
8
|
+
/**
|
|
9
|
+
* MLX's models on this computer: a folder per model, as Hugging Face names it
|
|
10
|
+
* (`mlx-community/Qwen3-4B-4bit`), shared by every app of engenty. Only weights as safetensors and
|
|
11
|
+
* the files beside them are taken, never code.
|
|
12
|
+
*/
|
|
13
|
+
const HUB = "https://huggingface.co";
|
|
14
|
+
/** Where the models are for this process: MLX_MODELS, else a folder of engenty's. */
|
|
15
|
+
export function mlxFolder(env = process.env) {
|
|
16
|
+
return env.MLX_MODELS?.trim() || join(homedir(), ".engenty", "models", "mlx");
|
|
17
|
+
}
|
|
18
|
+
/** A model as Hugging Face names it: `organization/name`. */
|
|
19
|
+
const NAME = /^[\w-][\w.-]*\/[\w-][\w.-]*$/;
|
|
20
|
+
export function modelFolder(root, model) {
|
|
21
|
+
if (!NAME.test(model)) {
|
|
22
|
+
throw new Error("A model of MLX is named as on Hugging Face: organization/name.");
|
|
23
|
+
}
|
|
24
|
+
return join(root, ...model.split("/"));
|
|
25
|
+
}
|
|
26
|
+
/** Written last: the model is whole. */
|
|
27
|
+
const DONE = ".engenty.json";
|
|
28
|
+
const FILE = /\.(safetensors|json|jinja|txt|model)$/;
|
|
29
|
+
/** The models in the folder, each with what it can do. */
|
|
30
|
+
export async function mlxModels(root, loaded) {
|
|
31
|
+
const models = [];
|
|
32
|
+
for (const org of await readdir(root).catch(() => [])) {
|
|
33
|
+
for (const name of await readdir(join(root, org)).catch(() => [])) {
|
|
34
|
+
const dir = join(root, org, name);
|
|
35
|
+
const done = await readFile(join(dir, DONE), "utf8").catch(() => null);
|
|
36
|
+
if (!done) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const { size, sha } = JSON.parse(done);
|
|
40
|
+
const { tools, vision, thinking, quantization } = await traits(dir);
|
|
41
|
+
models.push({
|
|
42
|
+
name: `${org}/${name}`,
|
|
43
|
+
size,
|
|
44
|
+
digest: sha,
|
|
45
|
+
capabilities: [
|
|
46
|
+
"completion",
|
|
47
|
+
...(tools ? ["tools"] : []),
|
|
48
|
+
...(vision ? ["vision"] : []),
|
|
49
|
+
...(thinking ? ["thinking"] : []),
|
|
50
|
+
],
|
|
51
|
+
completion: true,
|
|
52
|
+
tools,
|
|
53
|
+
vision,
|
|
54
|
+
thinking,
|
|
55
|
+
runner: "mlx",
|
|
56
|
+
quantization,
|
|
57
|
+
running: loaded === dir,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return models;
|
|
62
|
+
}
|
|
63
|
+
/** What a model can do, as its own files say: the chat template and the configuration. */
|
|
64
|
+
async function traits(dir) {
|
|
65
|
+
const json = async (file) => JSON.parse(await readFile(join(dir, file), "utf8").catch(() => "{}"));
|
|
66
|
+
const [config, tokenizer] = await Promise.all([
|
|
67
|
+
json("config.json"),
|
|
68
|
+
json("tokenizer_config.json"),
|
|
69
|
+
]);
|
|
70
|
+
const template = (await readFile(join(dir, "chat_template.jinja"), "utf8").catch(() => null)) ??
|
|
71
|
+
JSON.stringify(tokenizer.chat_template ?? (await json("chat_template.json")).chat_template ?? "");
|
|
72
|
+
const bits = config.quantization?.bits;
|
|
73
|
+
return {
|
|
74
|
+
tools: /\btools\b/.test(template),
|
|
75
|
+
vision: "vision_config" in config && existsSync(join(dir, "preprocessor_config.json")),
|
|
76
|
+
thinking: /enable_thinking/.test(template),
|
|
77
|
+
quantization: bits ? `${bits}bit` : null,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function sha256(file) {
|
|
81
|
+
const hash = createHash("sha256");
|
|
82
|
+
await pipeline(createReadStream(file), hash);
|
|
83
|
+
return hash.digest("hex");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Downloads a model from Hugging Face. A download that broke off goes on where it stopped; each
|
|
87
|
+
* weights file is checked against the hash Hugging Face names.
|
|
88
|
+
*/
|
|
89
|
+
export async function downloadModel(root, model, onProgress, { fetch: doFetch = fetch, signal, hub = HUB, } = {}) {
|
|
90
|
+
const dir = modelFolder(root, model);
|
|
91
|
+
const res = await doFetch(`${hub}/api/models/${model}?blobs=true`, { signal });
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
throw new Error(res.status === 401 || res.status === 404
|
|
94
|
+
? `Hugging Face has no open model ${model}.`
|
|
95
|
+
: `Hugging Face answered ${res.status}.`);
|
|
96
|
+
}
|
|
97
|
+
const info = (await res.json());
|
|
98
|
+
const files = (info.siblings ?? []).filter((f) => FILE.test(f.rfilename) && !f.rfilename.includes(".."));
|
|
99
|
+
if (!files.some((f) => f.rfilename.endsWith(".safetensors"))) {
|
|
100
|
+
throw new Error(`${model} has no weights MLX can read.`);
|
|
101
|
+
}
|
|
102
|
+
const total = files.reduce((sum, f) => sum + (f.size ?? 0), 0);
|
|
103
|
+
let before = 0;
|
|
104
|
+
let told = 0;
|
|
105
|
+
for (const file of files) {
|
|
106
|
+
const target = join(dir, ...file.rfilename.split("/"));
|
|
107
|
+
const part = `${target}.part`;
|
|
108
|
+
await mkdir(dirname(target), { recursive: true });
|
|
109
|
+
const there = await stat(target).catch(() => null);
|
|
110
|
+
if (!(there && there.size === file.size)) {
|
|
111
|
+
const have = (await stat(part).catch(() => null))?.size ?? 0;
|
|
112
|
+
let at = have;
|
|
113
|
+
if (file.size === undefined || have < file.size) {
|
|
114
|
+
const got = await doFetch(`${hub}/${model}/resolve/${info.sha ?? "main"}/${file.rfilename}`, { signal, ...(have ? { headers: { range: `bytes=${have}-` } } : {}) });
|
|
115
|
+
if (!(got.ok && got.body)) {
|
|
116
|
+
throw new Error(`Hugging Face answered ${got.status}.`);
|
|
117
|
+
}
|
|
118
|
+
const goesOn = have > 0 && got.status === 206;
|
|
119
|
+
at = goesOn ? have : 0;
|
|
120
|
+
const body = Readable.fromWeb(got.body);
|
|
121
|
+
body.on("data", (bytes) => {
|
|
122
|
+
at += bytes.length;
|
|
123
|
+
if (Date.now() - told > 250) {
|
|
124
|
+
told = Date.now();
|
|
125
|
+
onProgress(before + at, total);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
await pipeline(body, createWriteStream(part, { flags: goesOn ? "a" : "w" }), { signal });
|
|
129
|
+
}
|
|
130
|
+
const size = (await stat(part)).size;
|
|
131
|
+
const hash = file.lfs?.sha256;
|
|
132
|
+
if ((file.size !== undefined && size !== file.size) ||
|
|
133
|
+
(hash && (await sha256(part)) !== hash)) {
|
|
134
|
+
await rm(part, { force: true });
|
|
135
|
+
throw new Error(`${file.rfilename} arrived damaged. Try again.`);
|
|
136
|
+
}
|
|
137
|
+
await rename(part, target);
|
|
138
|
+
}
|
|
139
|
+
before += file.size ?? 0;
|
|
140
|
+
onProgress(before, total);
|
|
141
|
+
}
|
|
142
|
+
await writeFile(join(dir, DONE), JSON.stringify({ sha: info.sha ?? "", size: total }));
|
|
143
|
+
}
|
|
144
|
+
/** Removes a model and what its folder held. */
|
|
145
|
+
export async function removeModel(root, model) {
|
|
146
|
+
const dir = modelFolder(root, model);
|
|
147
|
+
if (!existsSync(dir)) {
|
|
148
|
+
throw new Error(`There is no model ${model}.`);
|
|
149
|
+
}
|
|
150
|
+
await rm(dir, { recursive: true });
|
|
151
|
+
// The organization's folder goes with its last model.
|
|
152
|
+
await rmdir(dirname(dir)).catch(() => undefined);
|
|
153
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Ollama on a computer, through its own API (`/api/…`): whether it runs, the models it holds and
|
|
3
3
|
* what each can do, which of them fits the computer's memory, and downloads.
|
|
4
4
|
*/
|
|
5
|
+
import { type InstalledModel, type ServerOptions } from "../servers/server.js";
|
|
5
6
|
/** Where Ollama answers when nothing names another address. */
|
|
6
7
|
export declare const OLLAMA_DEFAULT = "http://127.0.0.1:11434";
|
|
7
8
|
/**
|
|
@@ -13,10 +14,6 @@ export declare const OLLAMA_DEFAULT = "http://127.0.0.1:11434";
|
|
|
13
14
|
export declare function ollamaRoot(url: string): string;
|
|
14
15
|
/** Where Ollama answers for this process: OLLAMA_URL (a root or `…/v1`), else Ollama's default. */
|
|
15
16
|
export declare function ollamaAddress(env?: NodeJS.ProcessEnv): string;
|
|
16
|
-
export interface OllamaRequestOptions {
|
|
17
|
-
/** Another fetch, such as a test's. */
|
|
18
|
-
fetch?: typeof fetch;
|
|
19
|
-
}
|
|
20
17
|
export interface OllamaState {
|
|
21
18
|
/** The version of the Ollama that answers; null where none does. */
|
|
22
19
|
version: string | null;
|
|
@@ -24,47 +21,17 @@ export interface OllamaState {
|
|
|
24
21
|
models: string[];
|
|
25
22
|
}
|
|
26
23
|
/** Whether Ollama answers at `url`, and the models it holds. */
|
|
27
|
-
export declare function ollamaState(url: string, options?:
|
|
28
|
-
/** A model Ollama holds, as Ollama describes it. */
|
|
29
|
-
export interface InstalledModel {
|
|
30
|
-
name: string;
|
|
31
|
-
/** On disk, in bytes: about the memory it takes while it answers, too. */
|
|
32
|
-
size: number;
|
|
33
|
-
digest: string;
|
|
34
|
-
/** As Ollama says: `completion`, `tools`, `vision`, `thinking`, `audio`, `embedding`, … */
|
|
35
|
-
capabilities: string[];
|
|
36
|
-
/** It writes text. */
|
|
37
|
-
completion: boolean;
|
|
38
|
-
/** It takes tools. */
|
|
39
|
-
tools: boolean;
|
|
40
|
-
/** It takes pictures. */
|
|
41
|
-
vision: boolean;
|
|
42
|
-
/** It can think before it answers. */
|
|
43
|
-
thinking: boolean;
|
|
44
|
-
/** `mlx` or `llamacpp`; null where Ollama does not say. */
|
|
45
|
-
runner: string | null;
|
|
46
|
-
quantization: string | null;
|
|
47
|
-
/** In memory right now. */
|
|
48
|
-
running: boolean;
|
|
49
|
-
}
|
|
24
|
+
export declare function ollamaState(url: string, options?: ServerOptions): Promise<OllamaState>;
|
|
50
25
|
/**
|
|
51
26
|
* The models of the Ollama at `url`, each with what it can do and whether it is in memory.
|
|
52
27
|
* Ollama describes them all at once; a model it does not describe in time has no capabilities.
|
|
53
28
|
* Empty where Ollama does not answer.
|
|
54
29
|
*/
|
|
55
|
-
export declare function installedModels(url: string, options?:
|
|
56
|
-
/**
|
|
57
|
-
* Whether a model fits a computer: it takes at most `share` of the memory, and leaves the rest to
|
|
58
|
-
* everything else that runs there. Size and memory in the same unit; the model's size on disk
|
|
59
|
-
* is about what it takes while it answers.
|
|
60
|
-
*/
|
|
61
|
-
export declare function fits(model: number | {
|
|
62
|
-
size: number;
|
|
63
|
-
}, memory: number, share: number): boolean;
|
|
30
|
+
export declare function installedModels(url: string, options?: ServerOptions): Promise<InstalledModel[]>;
|
|
64
31
|
/**
|
|
65
32
|
* Pulls a model into the Ollama at `url`; `onProgress` hears the bytes so far and in all as they
|
|
66
33
|
* come, summed over the model's parts. Rejects with Ollama's own reason.
|
|
67
34
|
*/
|
|
68
|
-
export declare function pullModel(url: string, model: string, onProgress: (done: number, total: number) => void, options?:
|
|
35
|
+
export declare function pullModel(url: string, model: string, onProgress: (done: number, total: number) => void, options?: ServerOptions & {
|
|
69
36
|
signal?: AbortSignal;
|
|
70
37
|
}): Promise<void>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Ollama on a computer, through its own API (`/api/…`): whether it runs, the models it holds and
|
|
3
3
|
* what each can do, which of them fits the computer's memory, and downloads.
|
|
4
4
|
*/
|
|
5
|
+
import { getJson } from "../servers/server.js";
|
|
5
6
|
/** Where Ollama answers when nothing names another address. */
|
|
6
7
|
export const OLLAMA_DEFAULT = "http://127.0.0.1:11434";
|
|
7
8
|
/** Ollama's own port, for an address given without one. */
|
|
@@ -32,15 +33,6 @@ export function ollamaRoot(url) {
|
|
|
32
33
|
export function ollamaAddress(env = process.env) {
|
|
33
34
|
return ollamaRoot(env.OLLAMA_URL || OLLAMA_DEFAULT);
|
|
34
35
|
}
|
|
35
|
-
async function getJson(doFetch, url, init, timeoutMs = 2000) {
|
|
36
|
-
try {
|
|
37
|
-
const res = await doFetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) });
|
|
38
|
-
return res.ok ? (await res.json()) : null;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
36
|
/** Whether Ollama answers at `url`, and the models it holds. */
|
|
45
37
|
export async function ollamaState(url, options = {}) {
|
|
46
38
|
const doFetch = options.fetch ?? fetch;
|
|
@@ -95,15 +87,6 @@ export async function installedModels(url, options = {}) {
|
|
|
95
87
|
};
|
|
96
88
|
}));
|
|
97
89
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Whether a model fits a computer: it takes at most `share` of the memory, and leaves the rest to
|
|
100
|
-
* everything else that runs there. Size and memory in the same unit; the model's size on disk
|
|
101
|
-
* is about what it takes while it answers.
|
|
102
|
-
*/
|
|
103
|
-
export function fits(model, memory, share) {
|
|
104
|
-
const size = typeof model === "number" ? model : model.size;
|
|
105
|
-
return size <= memory * share;
|
|
106
|
-
}
|
|
107
90
|
/**
|
|
108
91
|
* Pulls a model into the Ollama at `url`; `onProgress` hears the bytes so far and in all as they
|
|
109
92
|
* come, summed over the model's parts. Rejects with Ollama's own reason.
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { installedModels, OLLAMA_DEFAULT, type OllamaState, ollamaAddress, ollamaRoot, ollamaState, pullModel, } from "./api.js";
|
|
2
2
|
export { base64Of, type CallOptions, type ChatModel, type GenerateResult, generateFrom, type OllamaSetup, ollamaMessages, ollamaModel, type StreamPart, type StreamResult, } from "./model.js";
|
|
3
|
+
export { ollama } from "./server.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { installedModels, OLLAMA_DEFAULT, ollamaAddress, ollamaRoot, ollamaState, pullModel, } from "./api.js";
|
|
2
2
|
export { base64Of, generateFrom, ollamaMessages, ollamaModel, } from "./model.js";
|
|
3
|
+
export { ollama } from "./server.js";
|
|
@@ -13,6 +13,8 @@ export type StreamResult = Awaited<ReturnType<ChatModel["doStream"]>>;
|
|
|
13
13
|
export type StreamPart = StreamResult["stream"] extends ReadableStream<infer P> ? P : never;
|
|
14
14
|
export type GenerateResult = Awaited<ReturnType<ChatModel["doGenerate"]>>;
|
|
15
15
|
export interface OllamaSetup {
|
|
16
|
+
/** Who answers, as the AI SDK names it. Default: `ollama`. */
|
|
17
|
+
provider?: string;
|
|
16
18
|
/** Ollama's address: its root, or the OpenAI-compatible `…/v1`. */
|
|
17
19
|
url: string;
|
|
18
20
|
model: string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsonBody, refusal } from "../servers/server.js";
|
|
2
|
+
import { installedModels, ollamaAddress, ollamaRoot, ollamaState, pullModel } from "./api.js";
|
|
3
|
+
/** Ollama as one of the servers on a computer. */
|
|
4
|
+
export const ollama = {
|
|
5
|
+
id: "ollama",
|
|
6
|
+
name: "Ollama",
|
|
7
|
+
address: ollamaAddress,
|
|
8
|
+
async state(url, options) {
|
|
9
|
+
const { version, models } = await ollamaState(url, options);
|
|
10
|
+
return { running: version !== null, version, models, trouble: null };
|
|
11
|
+
},
|
|
12
|
+
models: installedModels,
|
|
13
|
+
download: pullModel,
|
|
14
|
+
async remove(url, model, { fetch: doFetch = fetch } = {}) {
|
|
15
|
+
const res = await doFetch(`${ollamaRoot(url)}/api/delete`, {
|
|
16
|
+
method: "DELETE",
|
|
17
|
+
...jsonBody({ model }),
|
|
18
|
+
signal: AbortSignal.timeout(10_000),
|
|
19
|
+
});
|
|
20
|
+
if (!res.ok) {
|
|
21
|
+
throw await refusal(res, "Ollama");
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
async ask(url, model, prompt, { fetch: doFetch = fetch, signal } = {}) {
|
|
25
|
+
const res = await doFetch(`${ollamaRoot(url)}/api/chat`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
...jsonBody({
|
|
28
|
+
model: model.name,
|
|
29
|
+
messages: [{ role: "user", content: prompt }],
|
|
30
|
+
stream: false,
|
|
31
|
+
...(model.thinking ? { think: false } : {}),
|
|
32
|
+
options: { num_predict: 16 },
|
|
33
|
+
}),
|
|
34
|
+
signal,
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
throw await refusal(res, "Ollama");
|
|
38
|
+
}
|
|
39
|
+
const body = (await res.json().catch(() => ({})));
|
|
40
|
+
if (body.error) {
|
|
41
|
+
throw new Error(body.error);
|
|
42
|
+
}
|
|
43
|
+
return body.message?.content?.trim() ?? "";
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Client, type ClientId } from "./clients/index.js";
|
|
2
|
-
import { type InstalledModel } from "./
|
|
2
|
+
import { type InstalledModel, type ServerId, type ServerTrouble } from "./servers/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* One short, real call per source of models: a tiny prompt, a timeout, and what came of it. A
|
|
5
5
|
* call costs a few tokens, so a host makes it when the person asks or once at setup, never on a
|
|
@@ -7,17 +7,19 @@ import { type InstalledModel } from "./ollama/api.js";
|
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* - `ok`: it answered.
|
|
10
|
-
* - `absent`: the client is not installed, or
|
|
10
|
+
* - `absent`: the client is not installed, or the server does not answer at the address.
|
|
11
11
|
* - `signed_out`: the client is installed but not signed in.
|
|
12
|
-
* - `no_model`:
|
|
12
|
+
* - `no_model`: the server runs but holds no model to talk with (or not the one named).
|
|
13
13
|
* - `too_big`: the model takes more of the computer's memory than the share allows.
|
|
14
14
|
* - `failed`: it was asked and did not answer; `detail` says what it said.
|
|
15
15
|
*/
|
|
16
16
|
export type ProbeState = "ok" | "absent" | "signed_out" | "no_model" | "too_big" | "failed";
|
|
17
17
|
export interface ProbeResult {
|
|
18
18
|
state: ProbeState;
|
|
19
|
-
/** What the client or
|
|
19
|
+
/** What the client or the server said, as it said it. */
|
|
20
20
|
detail?: string;
|
|
21
|
+
/** Why a server that runs was not asked. */
|
|
22
|
+
trouble?: ServerTrouble;
|
|
21
23
|
/** The model that was asked, or that would have been. */
|
|
22
24
|
model?: string;
|
|
23
25
|
/** It did not answer within the timeout. */
|
|
@@ -31,8 +33,9 @@ export type ProbeSource = {
|
|
|
31
33
|
model?: string;
|
|
32
34
|
timeoutMs?: number;
|
|
33
35
|
} | {
|
|
34
|
-
kind: "
|
|
35
|
-
|
|
36
|
+
kind: "server";
|
|
37
|
+
server: ServerId;
|
|
38
|
+
/** The server's address: its root or `…/v1`. */
|
|
36
39
|
url: string;
|
|
37
40
|
/** The model to ask; left out, the one a host would pick first (see `preferredModel`). */
|
|
38
41
|
model?: string;
|
|
@@ -44,11 +47,11 @@ export type ProbeSource = {
|
|
|
44
47
|
};
|
|
45
48
|
export declare const PROMPT = "Answer with the single word ok.";
|
|
46
49
|
export declare const CLIENT_TIMEOUT = 90000;
|
|
47
|
-
export declare const
|
|
50
|
+
export declare const SERVER_TIMEOUT = 120000;
|
|
48
51
|
/** Whether the source answers a short call now. */
|
|
49
52
|
export declare function probe(source: ProbeSource): Promise<ProbeResult>;
|
|
50
53
|
/**
|
|
51
|
-
* The model a host asks first among
|
|
54
|
+
* The model a host asks first among a server's models that write text: one that takes tools, then
|
|
52
55
|
* the largest that fits the computer, then the smallest of those that do not.
|
|
53
56
|
*/
|
|
54
57
|
export declare function preferredModel(models: InstalledModel[], memory?: number, share?: number): InstalledModel | undefined;
|
|
@@ -5,14 +5,14 @@ import { createInterface } from "node:readline";
|
|
|
5
5
|
import spawn from "cross-spawn";
|
|
6
6
|
import { resolveEnv } from "./clients/env.js";
|
|
7
7
|
import { CLIENTS } from "./clients/index.js";
|
|
8
|
-
import { fits,
|
|
8
|
+
import { fits, SERVERS, } from "./servers/index.js";
|
|
9
9
|
export const PROMPT = "Answer with the single word ok.";
|
|
10
10
|
const SYSTEM = "You check whether you can answer. Answer with one word.";
|
|
11
11
|
export const CLIENT_TIMEOUT = 90_000;
|
|
12
|
-
export const
|
|
12
|
+
export const SERVER_TIMEOUT = 120_000;
|
|
13
13
|
/** Whether the source answers a short call now. */
|
|
14
14
|
export function probe(source) {
|
|
15
|
-
return source.kind === "client" ? probeClient(source) :
|
|
15
|
+
return source.kind === "client" ? probeClient(source) : probeServer(source);
|
|
16
16
|
}
|
|
17
17
|
async function probeClient(source) {
|
|
18
18
|
const client = typeof source.client === "string" ? CLIENTS[source.client] : source.client;
|
|
@@ -126,7 +126,7 @@ async function probeClient(source) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
* The model a host asks first among
|
|
129
|
+
* The model a host asks first among a server's models that write text: one that takes tools, then
|
|
130
130
|
* the largest that fits the computer, then the smallest of those that do not.
|
|
131
131
|
*/
|
|
132
132
|
export function preferredModel(models, memory = Number.POSITIVE_INFINITY, share = 1) {
|
|
@@ -137,15 +137,17 @@ export function preferredModel(models, memory = Number.POSITIVE_INFINITY, share
|
|
|
137
137
|
Number(leavesRoom(b)) - Number(leavesRoom(a)) ||
|
|
138
138
|
(leavesRoom(a) ? b.size - a.size : a.size - b.size))[0];
|
|
139
139
|
}
|
|
140
|
-
async function
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
if (!state.version) {
|
|
140
|
+
async function probeServer(source) {
|
|
141
|
+
const server = SERVERS[source.server];
|
|
142
|
+
const options = source.fetch ? { fetch: source.fetch } : {};
|
|
143
|
+
const { running, trouble } = await server.state(source.url, options);
|
|
144
|
+
if (!running) {
|
|
146
145
|
return { state: "absent" };
|
|
147
146
|
}
|
|
148
|
-
|
|
147
|
+
if (trouble) {
|
|
148
|
+
return { state: "failed", trouble };
|
|
149
|
+
}
|
|
150
|
+
const models = await server.models(source.url, options);
|
|
149
151
|
const sized = source.memory !== undefined && source.share !== undefined;
|
|
150
152
|
const model = source.model
|
|
151
153
|
? models.find((m) => m.name === source.model || m.name === `${source.model}:latest`)
|
|
@@ -157,27 +159,9 @@ async function probeOllama(source) {
|
|
|
157
159
|
return { state: "too_big", model: model.name };
|
|
158
160
|
}
|
|
159
161
|
try {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
body: JSON.stringify({
|
|
164
|
-
model: model.name,
|
|
165
|
-
messages: [{ role: "user", content: PROMPT }],
|
|
166
|
-
stream: false,
|
|
167
|
-
...(model.thinking ? { think: false } : {}),
|
|
168
|
-
options: { num_predict: 16 },
|
|
169
|
-
}),
|
|
170
|
-
signal: AbortSignal.timeout(timeout),
|
|
171
|
-
});
|
|
172
|
-
const body = (await response.json().catch(() => ({})));
|
|
173
|
-
if (!response.ok || body.error) {
|
|
174
|
-
return {
|
|
175
|
-
state: "failed",
|
|
176
|
-
model: model.name,
|
|
177
|
-
detail: body.error ?? `status ${response.status}`,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return { state: "ok", model: model.name, detail: body.message?.content?.trim() };
|
|
162
|
+
const signal = AbortSignal.timeout(source.timeoutMs ?? SERVER_TIMEOUT);
|
|
163
|
+
const detail = await server.ask(source.url, model, PROMPT, { ...options, signal });
|
|
164
|
+
return { state: "ok", model: model.name, detail };
|
|
181
165
|
}
|
|
182
166
|
catch (error) {
|
|
183
167
|
const timedOut = error.name === "TimeoutError";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type LocalServer, type ServerId } from "./server.js";
|
|
2
|
+
export { fits, type InstalledModel, type LocalServer, SERVER_IDS, type ServerId, type ServerOptions, type ServerState, type ServerTrouble, } from "./server.js";
|
|
3
|
+
/** The servers, by id. */
|
|
4
|
+
export declare const SERVERS: Record<ServerId, LocalServer>;
|
|
5
|
+
/** The servers this computer can run at all: MLX needs a Mac with Apple silicon and the helper. */
|
|
6
|
+
export declare function serversHere(): ServerId[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { lmStudio } from "../lmstudio/server.js";
|
|
2
|
+
import { mlxSupported } from "../mlx/helper.js";
|
|
3
|
+
import { mlx } from "../mlx/server.js";
|
|
4
|
+
import { ollama } from "../ollama/server.js";
|
|
5
|
+
import { SERVER_IDS } from "./server.js";
|
|
6
|
+
export { fits, SERVER_IDS, } from "./server.js";
|
|
7
|
+
/** The servers, by id. */
|
|
8
|
+
export const SERVERS = { ollama, lmstudio: lmStudio, mlx };
|
|
9
|
+
/** The servers this computer can run at all: MLX needs a Mac with Apple silicon and the helper. */
|
|
10
|
+
export function serversHere() {
|
|
11
|
+
return SERVER_IDS.filter((id) => id !== "mlx" || mlxSupported());
|
|
12
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** What runs open models on a computer. */
|
|
2
|
+
export declare const SERVER_IDS: readonly ["ollama", "lmstudio", "mlx"];
|
|
3
|
+
export type ServerId = (typeof SERVER_IDS)[number];
|
|
4
|
+
/** A model a server holds, as the server describes it. */
|
|
5
|
+
export interface InstalledModel {
|
|
6
|
+
name: string;
|
|
7
|
+
/** On disk, in bytes: about the memory it takes while it answers, too. */
|
|
8
|
+
size: number;
|
|
9
|
+
digest: string;
|
|
10
|
+
/** `completion`, `tools`, `vision`, `thinking`, `audio`, `embedding`, `decision`, … */
|
|
11
|
+
capabilities: string[];
|
|
12
|
+
/** It writes text. */
|
|
13
|
+
completion: boolean;
|
|
14
|
+
/** It takes tools. */
|
|
15
|
+
tools: boolean;
|
|
16
|
+
/** It takes pictures. */
|
|
17
|
+
vision: boolean;
|
|
18
|
+
/** It can think before it answers. */
|
|
19
|
+
thinking: boolean;
|
|
20
|
+
/** `mlx` or `llamacpp`; null where the server does not say. */
|
|
21
|
+
runner: string | null;
|
|
22
|
+
quantization: string | null;
|
|
23
|
+
/** In memory right now. */
|
|
24
|
+
running: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Why a server that is there gives nothing away: it wants a token (`locked`), or it is older than
|
|
28
|
+
* the API this package speaks (`old`).
|
|
29
|
+
*/
|
|
30
|
+
export type ServerTrouble = "locked" | "old";
|
|
31
|
+
export interface ServerState {
|
|
32
|
+
/** It answers at the address. */
|
|
33
|
+
running: boolean;
|
|
34
|
+
/** Null where the server does not say. */
|
|
35
|
+
version: string | null;
|
|
36
|
+
/** The names of the models it holds. */
|
|
37
|
+
models: string[];
|
|
38
|
+
trouble: ServerTrouble | null;
|
|
39
|
+
}
|
|
40
|
+
export interface ServerOptions {
|
|
41
|
+
/** Another fetch, such as a test's. */
|
|
42
|
+
fetch?: typeof fetch;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A server on a computer that runs open models, through its own API. Nothing but `ask` loads a
|
|
46
|
+
* model.
|
|
47
|
+
*/
|
|
48
|
+
export interface LocalServer {
|
|
49
|
+
id: ServerId;
|
|
50
|
+
/** The product name, as the person knows it. */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Where it answers for this process, when nothing names another address; MLX: its models' folder. */
|
|
53
|
+
address(env?: NodeJS.ProcessEnv): string;
|
|
54
|
+
state(url: string, options?: ServerOptions): Promise<ServerState>;
|
|
55
|
+
/** The models it holds; empty where it does not answer. */
|
|
56
|
+
models(url: string, options?: ServerOptions): Promise<InstalledModel[]>;
|
|
57
|
+
/** Downloads a model; `onProgress` hears the bytes so far and in all. Rejects with the server's reason. */
|
|
58
|
+
download(url: string, model: string, onProgress: (done: number, total: number) => void, options?: ServerOptions & {
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/** Removes a model; absent where the server's API does not. Rejects with the server's reason. */
|
|
62
|
+
remove?(url: string, model: string, options?: ServerOptions): Promise<void>;
|
|
63
|
+
/** One short answer of a model, which loads it. Rejects with the server's reason. */
|
|
64
|
+
ask(url: string, model: InstalledModel, prompt: string, options?: ServerOptions & {
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}): Promise<string>;
|
|
67
|
+
}
|
|
68
|
+
/** The JSON of a request; null where nothing answers, or not with 200. */
|
|
69
|
+
export declare function getJson<T>(doFetch: typeof fetch, url: string, init?: RequestInit, timeoutMs?: number): Promise<T | null>;
|
|
70
|
+
/** A JSON request's parts. */
|
|
71
|
+
export declare function jsonBody(body: unknown): {
|
|
72
|
+
headers: Record<string, string>;
|
|
73
|
+
body: string;
|
|
74
|
+
};
|
|
75
|
+
/** What a server said as it refused: its `error`, in any of the spellings, else the text. */
|
|
76
|
+
export declare function refusal(res: Response, name: string): Promise<Error>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether a model fits a computer: it takes at most `share` of the memory, and leaves the rest to
|
|
79
|
+
* everything else that runs there. Size and memory in the same unit; the model's size on disk
|
|
80
|
+
* is about what it takes while it answers.
|
|
81
|
+
*/
|
|
82
|
+
export declare function fits(model: number | {
|
|
83
|
+
size: number;
|
|
84
|
+
}, memory: number, share: number): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** What runs open models on a computer. */
|
|
2
|
+
export const SERVER_IDS = ["ollama", "lmstudio", "mlx"];
|
|
3
|
+
/** The JSON of a request; null where nothing answers, or not with 200. */
|
|
4
|
+
export async function getJson(doFetch, url, init, timeoutMs = 2000) {
|
|
5
|
+
try {
|
|
6
|
+
const res = await doFetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) });
|
|
7
|
+
return res.ok ? (await res.json()) : null;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** A JSON request's parts. */
|
|
14
|
+
export function jsonBody(body) {
|
|
15
|
+
return { headers: { "content-type": "application/json" }, body: JSON.stringify(body) };
|
|
16
|
+
}
|
|
17
|
+
/** What a server said as it refused: its `error`, in any of the spellings, else the text. */
|
|
18
|
+
export async function refusal(res, name) {
|
|
19
|
+
const text = (await res.text().catch(() => "")).trim();
|
|
20
|
+
let said = text;
|
|
21
|
+
try {
|
|
22
|
+
const { error } = JSON.parse(text);
|
|
23
|
+
said = (typeof error === "string" ? error : error?.message) ?? text;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// the text as it came
|
|
27
|
+
}
|
|
28
|
+
return new Error(said.slice(0, 400) || `${name} answered ${res.status}.`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether a model fits a computer: it takes at most `share` of the memory, and leaves the rest to
|
|
32
|
+
* everything else that runs there. Size and memory in the same unit; the model's size on disk
|
|
33
|
+
* is about what it takes while it answers.
|
|
34
|
+
*/
|
|
35
|
+
export function fits(model, memory, share) {
|
|
36
|
+
const size = typeof model === "number" ? model : model.size;
|
|
37
|
+
return size <= memory * share;
|
|
38
|
+
}
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js",
|
|
8
8
|
"./ollama": "./dist/ollama/index.js",
|
|
9
|
+
"./lmstudio": "./dist/lmstudio/index.js",
|
|
10
|
+
"./mlx": "./dist/mlx/index.js",
|
|
11
|
+
"./servers": "./dist/servers/index.js",
|
|
9
12
|
"./clients": "./dist/clients/index.js",
|
|
10
|
-
"./probe": "./dist/probe.js"
|
|
13
|
+
"./probe": "./dist/probe.js",
|
|
14
|
+
"./bridge": "./dist/bridge/index.js"
|
|
11
15
|
}
|
|
12
16
|
}
|