@engenty/wizards-runtime 0.20.5 → 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 +20 -25
- 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 +7 -254
- package/apps/runtime/dist/cli/setup.js +12 -9
- package/apps/runtime/dist/decision-model.js +1 -4
- package/apps/runtime/dist/docs/dev/licensing.md +20 -9
- package/apps/runtime/dist/docs/user-guide/command-line.md +5 -2
- 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/device.js +3 -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/apple.js +4 -3
- package/apps/runtime/dist/harness/clients.js +117 -0
- package/apps/runtime/dist/harness/index.js +32 -87
- package/apps/runtime/dist/harness/model.js +32 -270
- package/apps/runtime/dist/harness/prompt.js +6 -120
- package/apps/runtime/dist/harness/types.js +5 -3
- package/apps/runtime/dist/local-call.js +6 -0
- package/apps/runtime/dist/local-models.js +53 -177
- 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 +82 -32
- package/apps/runtime/dist/motion-graphics/step.js +2 -2
- 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 +11 -5
- 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-CbvEK0rz.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/bin/bot-tunnel.mjs +375 -0
- package/bin/bot.mjs +494 -69
- 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 +72 -17
- package/node_modules/@engenty/local-models/dist/clients/chat.d.ts +89 -0
- package/node_modules/@engenty/local-models/dist/clients/chat.js +22 -0
- package/node_modules/@engenty/local-models/dist/clients/claude.d.ts +32 -0
- package/node_modules/@engenty/local-models/dist/clients/claude.js +239 -0
- package/node_modules/@engenty/local-models/dist/clients/client.d.ts +31 -0
- package/node_modules/@engenty/local-models/dist/clients/client.js +2 -0
- package/node_modules/@engenty/local-models/dist/clients/codex.d.ts +35 -0
- package/node_modules/@engenty/local-models/dist/clients/codex.js +254 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +35 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.js +192 -0
- package/node_modules/@engenty/local-models/dist/clients/detect.d.ts +18 -0
- package/node_modules/@engenty/local-models/dist/clients/detect.js +34 -0
- package/node_modules/@engenty/local-models/dist/clients/env.d.ts +66 -0
- package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/env.js +62 -31
- package/node_modules/@engenty/local-models/dist/clients/failure.d.ts +26 -0
- package/node_modules/@engenty/local-models/dist/clients/failure.js +35 -0
- package/node_modules/@engenty/local-models/dist/clients/index.d.ts +15 -0
- package/node_modules/@engenty/local-models/dist/clients/index.js +18 -0
- package/node_modules/@engenty/local-models/dist/clients/model.d.ts +129 -0
- package/node_modules/@engenty/local-models/dist/clients/model.js +225 -0
- package/node_modules/@engenty/local-models/dist/clients/prompt.d.ts +36 -0
- package/node_modules/@engenty/local-models/dist/clients/prompt.js +123 -0
- package/node_modules/@engenty/local-models/dist/clients/run.d.ts +15 -0
- package/node_modules/@engenty/local-models/dist/clients/run.js +41 -0
- package/node_modules/@engenty/local-models/dist/index.d.ts +4 -0
- package/node_modules/@engenty/local-models/dist/index.js +4 -0
- 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 +37 -0
- package/node_modules/@engenty/local-models/dist/ollama/api.js +147 -0
- package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/ollama/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.js +302 -0
- 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 +57 -0
- package/node_modules/@engenty/local-models/dist/probe.js +174 -0
- 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 +16 -0
- 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 +13 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/runtime/dist/agents/chat-clients.js +0 -344
- package/apps/runtime/dist/harness/claude.js +0 -141
- package/apps/runtime/dist/harness/codex.js +0 -222
- package/apps/runtime/dist/harness/cursor.js +0 -89
- package/apps/runtime/dist/harness/terminal.js +0 -201
- package/apps/web/dist/assets/AboutDialog-DM_2-iLP.js +0 -1
- package/apps/web/dist/assets/Bundle-C0u5HUZL.js +0 -1
- package/apps/web/dist/assets/CapabilitiesPage-DxRUERr-.js +0 -2
- package/apps/web/dist/assets/ChangelogDialog-Cyn3LAch.js +0 -1
- package/apps/web/dist/assets/ConnectorsSection-BYOrwccO.js +0 -1
- package/apps/web/dist/assets/EditorPage-BFUQzJpN.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-DhmYe2C8.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-MGKJVDp2.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-RawpCO9J.js +0 -1
- package/apps/web/dist/assets/ProtocolSection-B1MshkAx.js +0 -1
- package/apps/web/dist/assets/PublicRunner-COatyxMi.js +0 -1
- package/apps/web/dist/assets/Results-DI4EHtkh.js +0 -1
- package/apps/web/dist/assets/RunDrawer-xXcbQ9wP.js +0 -1
- package/apps/web/dist/assets/SettingsPage-BcqqYDqw.js +0 -2
- package/apps/web/dist/assets/SetupPage-DG3fJ6fk.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-CzQAEQj8.js +0 -2
- package/apps/web/dist/assets/StudioHome-DWTDTslp.js +0 -1
- package/apps/web/dist/assets/TableEditor-DirMDIGk.js +0 -7
- package/apps/web/dist/assets/UpdateCheck-C6GlE6Am.js +0 -2
- package/apps/web/dist/assets/brand-BIT7AumL.js +0 -2
- package/apps/web/dist/assets/changelog-CMovB3yB.js +0 -1
- package/apps/web/dist/assets/code-editor-CufyaUFC.js +0 -2
- package/apps/web/dist/assets/host-DNvnJXoi.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-DOq0CvXM.js +0 -102
- package/apps/web/dist/assets/oss-credits-C4SGbRkz.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,129 @@
|
|
|
1
|
+
import type { ImageModel, LanguageModel } from "ai";
|
|
2
|
+
import { ClientFailure, type ClientMeta } from "./failure.js";
|
|
3
|
+
import { type PromptWords } from "./prompt.js";
|
|
4
|
+
/**
|
|
5
|
+
* An installed AI client as a model: every call runs the client once, headless, on the person's
|
|
6
|
+
* own sign-in. A call with tools hands them to the client over MCP (the host's `bridge`) and lets
|
|
7
|
+
* it work through them itself; a call that wants structured output has the client validate it
|
|
8
|
+
* against the schema where it can, else asks for JSON and parses it. A client that makes images
|
|
9
|
+
* on the sign-in is an image model as well (ClientImageModel).
|
|
10
|
+
*/
|
|
11
|
+
type V3 = Extract<LanguageModel, {
|
|
12
|
+
specificationVersion: "v3";
|
|
13
|
+
}>;
|
|
14
|
+
type ImageV3 = Extract<ImageModel, {
|
|
15
|
+
specificationVersion: "v3";
|
|
16
|
+
}>;
|
|
17
|
+
type ImageCallOptions = Parameters<ImageV3["doGenerate"]>[0];
|
|
18
|
+
type ImageResult = Awaited<ReturnType<ImageV3["doGenerate"]>>;
|
|
19
|
+
type CallOptions = Parameters<V3["doGenerate"]>[0];
|
|
20
|
+
type GenerateResult = Awaited<ReturnType<V3["doGenerate"]>>;
|
|
21
|
+
type StreamResult = Awaited<ReturnType<V3["doStream"]>>;
|
|
22
|
+
/** How hard the client works on a call, where it takes a hint. */
|
|
23
|
+
export type Effort = "low" | "medium" | "high";
|
|
24
|
+
/** A tool of the call, served to the client over MCP while it answers. */
|
|
25
|
+
export interface BridgeTool {
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
/** JSON Schema of the input, as the model call declares it. */
|
|
29
|
+
inputSchema: Record<string, unknown>;
|
|
30
|
+
/** `signal`: aborted when the bridge closes or the client gives the call up. */
|
|
31
|
+
execute(input: unknown, options?: {
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}): Promise<unknown>;
|
|
34
|
+
/** What the model gets to see of a result where a tool shapes it (a screenshot, say). */
|
|
35
|
+
toModelOutput?: (output: unknown) => unknown;
|
|
36
|
+
}
|
|
37
|
+
/** Serves a call's tools over MCP at `url` until `close`. */
|
|
38
|
+
export type Bridge = (tools: BridgeTool[]) => {
|
|
39
|
+
url: string;
|
|
40
|
+
close(): void;
|
|
41
|
+
};
|
|
42
|
+
export interface ClientModelOptions {
|
|
43
|
+
effort?: Effort;
|
|
44
|
+
/** Where each call gets a folder of its own, deleted afterwards. Default: the system's temp folder. */
|
|
45
|
+
workDir?: string;
|
|
46
|
+
/** Serves a call's tools to the client; without it a call's tools are left out, with a warning. */
|
|
47
|
+
bridge?: Bridge;
|
|
48
|
+
/** The sentences the client reads besides the call's messages. */
|
|
49
|
+
words?: PromptWords;
|
|
50
|
+
/** What a client's failure becomes for the host, such as an error that names it in the person's language. */
|
|
51
|
+
error?: (failure: ClientFailure) => Error;
|
|
52
|
+
}
|
|
53
|
+
/** One call, as the client is asked for it. */
|
|
54
|
+
export interface ClientCall {
|
|
55
|
+
/** A folder of this call alone: attachments, config files; deleted afterwards. */
|
|
56
|
+
dir: string;
|
|
57
|
+
system: string;
|
|
58
|
+
prompt: string;
|
|
59
|
+
files: string[];
|
|
60
|
+
/** The MCP server holding this call's tools, when it has any. */
|
|
61
|
+
bridgeUrl: string | null;
|
|
62
|
+
/** The schema the answer must match — only for a client that validates it itself. */
|
|
63
|
+
schema: unknown | null;
|
|
64
|
+
webSearch: boolean;
|
|
65
|
+
effort?: Effort;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}
|
|
68
|
+
export interface ClientAnswer {
|
|
69
|
+
text: string;
|
|
70
|
+
usage?: {
|
|
71
|
+
input?: number;
|
|
72
|
+
cacheRead?: number;
|
|
73
|
+
cacheWrite?: number;
|
|
74
|
+
output?: number;
|
|
75
|
+
};
|
|
76
|
+
meta?: Record<string, string | number | boolean | null>;
|
|
77
|
+
sessionId?: string;
|
|
78
|
+
stopReason?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare abstract class ClientModel implements V3 {
|
|
81
|
+
readonly specificationVersion: "v3";
|
|
82
|
+
abstract readonly provider: string;
|
|
83
|
+
readonly modelId: string;
|
|
84
|
+
readonly supportedUrls: {};
|
|
85
|
+
/** Whether the client validates structured output against the schema itself. */
|
|
86
|
+
protected readonly nativeSchema: boolean;
|
|
87
|
+
/** Whether the client runs a call's tools (over the bridge); else they are left out, with a warning. */
|
|
88
|
+
protected readonly usesTools: boolean;
|
|
89
|
+
/** The same, for whoever builds the call: a caller tells such a client no tools exist. */
|
|
90
|
+
get takesTools(): boolean;
|
|
91
|
+
/** Whether the client searches the web with a tool of its own, tools of the call or not. */
|
|
92
|
+
protected readonly searchesWeb: boolean;
|
|
93
|
+
protected readonly effort?: Effort;
|
|
94
|
+
protected readonly client: ClientMeta;
|
|
95
|
+
protected readonly options: ClientModelOptions;
|
|
96
|
+
private readonly executors;
|
|
97
|
+
constructor(client: ClientMeta, alias: string, options?: ClientModelOptions);
|
|
98
|
+
/** The tools a call may name, by the names the agent gives them: the client runs them over the bridge. */
|
|
99
|
+
attach(tools: Record<string, unknown>): void;
|
|
100
|
+
/** Runs the client once for this call. */
|
|
101
|
+
protected abstract invoke(call: ClientCall): Promise<ClientAnswer>;
|
|
102
|
+
doGenerate(options: CallOptions): Promise<GenerateResult>;
|
|
103
|
+
/** The answer as one piece: the client prints it when it is done. */
|
|
104
|
+
doStream(options: CallOptions): Promise<StreamResult>;
|
|
105
|
+
}
|
|
106
|
+
/** One image call, as the client is asked for it. */
|
|
107
|
+
export interface ClientImageCall {
|
|
108
|
+
/** A folder of this call alone, with the reference images in it; deleted afterwards. */
|
|
109
|
+
dir: string;
|
|
110
|
+
prompt: string;
|
|
111
|
+
/** The reference images, as paths in `dir`. */
|
|
112
|
+
files: string[];
|
|
113
|
+
aspectRatio?: string;
|
|
114
|
+
signal?: AbortSignal;
|
|
115
|
+
}
|
|
116
|
+
/** A client that makes images on the person's sign-in: one client run per image. */
|
|
117
|
+
export declare abstract class ClientImageModel implements ImageV3 {
|
|
118
|
+
readonly specificationVersion: "v3";
|
|
119
|
+
abstract readonly provider: string;
|
|
120
|
+
readonly modelId: string;
|
|
121
|
+
readonly maxImagesPerCall = 1;
|
|
122
|
+
protected readonly client: ClientMeta;
|
|
123
|
+
protected readonly options: ClientModelOptions;
|
|
124
|
+
constructor(client: ClientMeta, alias: string, options?: ClientModelOptions);
|
|
125
|
+
/** Runs the client once and hands back the image it made. */
|
|
126
|
+
protected abstract invoke(call: ClientImageCall): Promise<Uint8Array>;
|
|
127
|
+
doGenerate(options: ImageCallOptions): Promise<ImageResult>;
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { ClientFailure } from "./failure.js";
|
|
6
|
+
import { DEFAULT_WORDS, extensionOf, jsonInstruction, parseJsonAnswer, renderPrompt, } from "./prompt.js";
|
|
7
|
+
const callDir = (workDir) => join(workDir ?? join(tmpdir(), "engenty-local-models"), randomBytes(8).toString("hex"));
|
|
8
|
+
/** A failure as the host wants it: ENOENT is a client that is not installed. */
|
|
9
|
+
function hostError(err, client, error) {
|
|
10
|
+
const failure = err?.code === "ENOENT" && !(err instanceof ClientFailure)
|
|
11
|
+
? new ClientFailure("not_installed", client, err.message)
|
|
12
|
+
: err;
|
|
13
|
+
return failure instanceof ClientFailure && error ? error(failure) : failure;
|
|
14
|
+
}
|
|
15
|
+
export class ClientModel {
|
|
16
|
+
specificationVersion = "v3";
|
|
17
|
+
modelId;
|
|
18
|
+
supportedUrls = {};
|
|
19
|
+
/** Whether the client validates structured output against the schema itself. */
|
|
20
|
+
nativeSchema = false;
|
|
21
|
+
/** Whether the client runs a call's tools (over the bridge); else they are left out, with a warning. */
|
|
22
|
+
usesTools = true;
|
|
23
|
+
/** The same, for whoever builds the call: a caller tells such a client no tools exist. */
|
|
24
|
+
get takesTools() {
|
|
25
|
+
return this.usesTools;
|
|
26
|
+
}
|
|
27
|
+
/** Whether the client searches the web with a tool of its own, tools of the call or not. */
|
|
28
|
+
searchesWeb = true;
|
|
29
|
+
effort;
|
|
30
|
+
client;
|
|
31
|
+
options;
|
|
32
|
+
executors = new Map();
|
|
33
|
+
constructor(client, alias, options = {}) {
|
|
34
|
+
this.client = client;
|
|
35
|
+
this.modelId = alias;
|
|
36
|
+
this.effort = options.effort;
|
|
37
|
+
this.options = options;
|
|
38
|
+
}
|
|
39
|
+
/** The tools a call may name, by the names the agent gives them: the client runs them over the bridge. */
|
|
40
|
+
attach(tools) {
|
|
41
|
+
for (const [name, tool] of Object.entries(tools)) {
|
|
42
|
+
const t = tool;
|
|
43
|
+
if (typeof t?.execute === "function") {
|
|
44
|
+
this.executors.set(name, t);
|
|
45
|
+
if (t.id) {
|
|
46
|
+
this.executors.set(t.id, t);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async doGenerate(options) {
|
|
52
|
+
const dir = callDir(this.options.workDir);
|
|
53
|
+
mkdirSync(dir, { recursive: true });
|
|
54
|
+
const words = this.options.words ?? DEFAULT_WORDS;
|
|
55
|
+
const { system, prompt, files, warnings } = renderPrompt(options.prompt, dir, words);
|
|
56
|
+
const bridged = [];
|
|
57
|
+
let webSearch = false;
|
|
58
|
+
for (const tool of options.tools ?? []) {
|
|
59
|
+
// The client searches with its own tool; naming `web_search` is what switches it on.
|
|
60
|
+
if (tool.type === "function" && tool.name === "web_search" && this.searchesWeb) {
|
|
61
|
+
webSearch = true;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (tool.type !== "function" || !this.usesTools || !this.options.bridge) {
|
|
65
|
+
warnings.push({ type: "unsupported", feature: `tool ${tool.name}` });
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const executor = this.executors.get(tool.name);
|
|
69
|
+
if (!executor?.execute) {
|
|
70
|
+
warnings.push({
|
|
71
|
+
type: "unsupported",
|
|
72
|
+
feature: `tool ${tool.name}`,
|
|
73
|
+
details: "no executor",
|
|
74
|
+
});
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
bridged.push({
|
|
78
|
+
name: tool.name,
|
|
79
|
+
description: tool.description,
|
|
80
|
+
inputSchema: tool.inputSchema,
|
|
81
|
+
execute: (input) => executor.execute(input),
|
|
82
|
+
toModelOutput: executor.toModelOutput,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
for (const key of ["temperature", "topP", "topK", "seed", "stopSequences"]) {
|
|
86
|
+
if (options[key] !== undefined) {
|
|
87
|
+
warnings.push({ type: "unsupported", feature: key });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const structured = options.responseFormat?.type === "json";
|
|
91
|
+
const schema = structured && options.responseFormat?.type === "json"
|
|
92
|
+
? (options.responseFormat.schema ?? null)
|
|
93
|
+
: null;
|
|
94
|
+
const bridge = bridged.length && this.options.bridge ? this.options.bridge(bridged) : null;
|
|
95
|
+
try {
|
|
96
|
+
const answer = await this.invoke({
|
|
97
|
+
dir,
|
|
98
|
+
system: structured && !this.nativeSchema
|
|
99
|
+
? [system, jsonInstruction(schema, words)].filter(Boolean).join("\n\n")
|
|
100
|
+
: system,
|
|
101
|
+
prompt,
|
|
102
|
+
files,
|
|
103
|
+
bridgeUrl: bridge?.url ?? null,
|
|
104
|
+
schema: this.nativeSchema ? schema : null,
|
|
105
|
+
webSearch,
|
|
106
|
+
effort: this.effort,
|
|
107
|
+
signal: options.abortSignal,
|
|
108
|
+
});
|
|
109
|
+
const u = answer.usage ?? {};
|
|
110
|
+
const cacheRead = u.cacheRead ?? 0;
|
|
111
|
+
const cacheWrite = u.cacheWrite ?? 0;
|
|
112
|
+
const input = u.input ?? 0;
|
|
113
|
+
return {
|
|
114
|
+
content: [
|
|
115
|
+
{
|
|
116
|
+
type: "text",
|
|
117
|
+
text: structured ? JSON.stringify(parseJsonAnswer(answer.text)) : answer.text,
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
finishReason: { unified: "stop", raw: answer.stopReason },
|
|
121
|
+
usage: {
|
|
122
|
+
inputTokens: {
|
|
123
|
+
total: input,
|
|
124
|
+
noCache: Math.max(0, input - cacheRead - cacheWrite),
|
|
125
|
+
cacheRead,
|
|
126
|
+
cacheWrite,
|
|
127
|
+
},
|
|
128
|
+
outputTokens: { total: u.output ?? 0, text: u.output ?? 0, reasoning: undefined },
|
|
129
|
+
raw: u,
|
|
130
|
+
},
|
|
131
|
+
providerMetadata: { [this.provider]: answer.meta ?? {} },
|
|
132
|
+
response: { id: answer.sessionId, modelId: this.modelId },
|
|
133
|
+
warnings,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
throw hostError(err, this.client, this.options.error);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
bridge?.close();
|
|
141
|
+
rmSync(dir, { recursive: true, force: true });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** The answer as one piece: the client prints it when it is done. */
|
|
145
|
+
async doStream(options) {
|
|
146
|
+
const result = await this.doGenerate(options);
|
|
147
|
+
const text = result.content.find((c) => c.type === "text");
|
|
148
|
+
const parts = [
|
|
149
|
+
{ type: "stream-start", warnings: result.warnings },
|
|
150
|
+
{ type: "response-metadata", ...result.response },
|
|
151
|
+
{ type: "text-start", id: "0" },
|
|
152
|
+
{ type: "text-delta", id: "0", delta: text?.type === "text" ? text.text : "" },
|
|
153
|
+
{ type: "text-end", id: "0" },
|
|
154
|
+
{
|
|
155
|
+
type: "finish",
|
|
156
|
+
usage: result.usage,
|
|
157
|
+
finishReason: result.finishReason,
|
|
158
|
+
providerMetadata: result.providerMetadata,
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
return {
|
|
162
|
+
stream: new ReadableStream({
|
|
163
|
+
start(controller) {
|
|
164
|
+
for (const part of parts) {
|
|
165
|
+
controller.enqueue(part);
|
|
166
|
+
}
|
|
167
|
+
controller.close();
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** A client that makes images on the person's sign-in: one client run per image. */
|
|
174
|
+
export class ClientImageModel {
|
|
175
|
+
specificationVersion = "v3";
|
|
176
|
+
modelId;
|
|
177
|
+
maxImagesPerCall = 1;
|
|
178
|
+
client;
|
|
179
|
+
options;
|
|
180
|
+
constructor(client, alias, options = {}) {
|
|
181
|
+
this.client = client;
|
|
182
|
+
this.modelId = alias;
|
|
183
|
+
this.options = options;
|
|
184
|
+
}
|
|
185
|
+
async doGenerate(options) {
|
|
186
|
+
const dir = callDir(this.options.workDir);
|
|
187
|
+
mkdirSync(dir, { recursive: true });
|
|
188
|
+
const warnings = [];
|
|
189
|
+
const files = [];
|
|
190
|
+
for (const file of options.files ?? []) {
|
|
191
|
+
if (file.type !== "file") {
|
|
192
|
+
warnings.push({ type: "unsupported", feature: "image url" });
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const path = join(dir, `ref-${files.length + 1}.${extensionOf(file.mediaType)}`);
|
|
196
|
+
writeFileSync(path, typeof file.data === "string" ? Buffer.from(file.data, "base64") : file.data);
|
|
197
|
+
files.push(path);
|
|
198
|
+
}
|
|
199
|
+
for (const key of ["size", "seed", "mask"]) {
|
|
200
|
+
if (options[key] !== undefined) {
|
|
201
|
+
warnings.push({ type: "unsupported", feature: key });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const image = await this.invoke({
|
|
206
|
+
dir,
|
|
207
|
+
prompt: options.prompt ?? "",
|
|
208
|
+
files,
|
|
209
|
+
aspectRatio: options.aspectRatio,
|
|
210
|
+
signal: options.abortSignal,
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
images: [image],
|
|
214
|
+
warnings,
|
|
215
|
+
response: { timestamp: new Date(), modelId: this.modelId, headers: undefined },
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
throw hostError(err, this.client, this.options.error);
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
rmSync(dir, { recursive: true, force: true });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LanguageModel } from "ai";
|
|
2
|
+
type V3 = Extract<LanguageModel, {
|
|
3
|
+
specificationVersion: "v3";
|
|
4
|
+
}>;
|
|
5
|
+
type CallOptions = Parameters<V3["doGenerate"]>[0];
|
|
6
|
+
type GenerateResult = Awaited<ReturnType<V3["doGenerate"]>>;
|
|
7
|
+
export type Message = CallOptions["prompt"][number];
|
|
8
|
+
export type Warning = GenerateResult["warnings"][number];
|
|
9
|
+
/** The sentences a client reads besides the call's own messages; a host may word them itself. */
|
|
10
|
+
export interface PromptWords {
|
|
11
|
+
/** Where a saved attachment stood in the prompt. */
|
|
12
|
+
attachedFile(path: string): string;
|
|
13
|
+
/** Added to the system prompt when the client gets a whole thread as one prompt. */
|
|
14
|
+
conversationNote(): string;
|
|
15
|
+
/** For a client without a schema option; `schema` is the JSON Schema, as JSON. */
|
|
16
|
+
jsonInstruction(schema: string): string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_WORDS: PromptWords;
|
|
19
|
+
/** The extension a saved attachment gets, so the client reads it as what it is. */
|
|
20
|
+
export declare function extensionOf(mediaType: string, filename?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The conversation as a client takes it: one system prompt and one prompt on stdin. A single
|
|
23
|
+
* user message goes as it is; a longer thread is written out with its speakers, and the client
|
|
24
|
+
* is asked to answer its last message. Attachments are saved to `dir` and named in the prompt.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderPrompt(messages: Message[], dir?: string, words?: PromptWords): {
|
|
27
|
+
system: string;
|
|
28
|
+
prompt: string;
|
|
29
|
+
files: string[];
|
|
30
|
+
warnings: Warning[];
|
|
31
|
+
};
|
|
32
|
+
/** What a client without a schema option is told so its answer parses. */
|
|
33
|
+
export declare function jsonInstruction(schema: unknown, words?: PromptWords): string;
|
|
34
|
+
/** A client's answer as JSON: the fences and prose some wrap around it are taken off. */
|
|
35
|
+
export declare function parseJsonAnswer(text: string): unknown;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export const DEFAULT_WORDS = {
|
|
4
|
+
attachedFile: (path) => `[Attached file — open it to read it: ${path}]`,
|
|
5
|
+
conversationNote: () => "The prompt holds the conversation so far, each message headed by its speaker. Answer the last message as the assistant — the answer only, no speaker label.",
|
|
6
|
+
jsonInstruction: (schema) => `Answer with one JSON value only — no prose, no code fence — that matches this JSON Schema:\n${schema}`,
|
|
7
|
+
};
|
|
8
|
+
/** The extension a saved attachment gets, so the client reads it as what it is. */
|
|
9
|
+
export function extensionOf(mediaType, filename) {
|
|
10
|
+
const own = filename?.match(/\.([a-z0-9]{1,5})$/i)?.[1];
|
|
11
|
+
if (own) {
|
|
12
|
+
return own.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
const sub = mediaType.split("/")[1] ?? "bin";
|
|
15
|
+
return { jpeg: "jpg", "svg+xml": "svg", plain: "txt", markdown: "md" }[sub] ?? sub;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The conversation as a client takes it: one system prompt and one prompt on stdin. A single
|
|
19
|
+
* user message goes as it is; a longer thread is written out with its speakers, and the client
|
|
20
|
+
* is asked to answer its last message. Attachments are saved to `dir` and named in the prompt.
|
|
21
|
+
*/
|
|
22
|
+
export function renderPrompt(messages, dir, words = DEFAULT_WORDS) {
|
|
23
|
+
const warnings = [];
|
|
24
|
+
const files = [];
|
|
25
|
+
const system = [];
|
|
26
|
+
const turns = [];
|
|
27
|
+
const saveFile = (input) => {
|
|
28
|
+
// A file's content comes tagged: { type: "data", data } | { type: "url", url } | { type: "text", text }.
|
|
29
|
+
const tagged = input.data;
|
|
30
|
+
const data = tagged && typeof tagged === "object" && typeof tagged.type === "string"
|
|
31
|
+
? tagged.type === "url"
|
|
32
|
+
? tagged.url
|
|
33
|
+
: tagged.type === "text"
|
|
34
|
+
? Buffer.from(tagged.text ?? "", "utf8")
|
|
35
|
+
: tagged.data
|
|
36
|
+
: input.data;
|
|
37
|
+
const part = { ...input, data };
|
|
38
|
+
if (part.data instanceof URL) {
|
|
39
|
+
return `[Attachment at ${part.data.href} (${part.mediaType})]`;
|
|
40
|
+
}
|
|
41
|
+
if (typeof part.data !== "string" && !(part.data instanceof Uint8Array)) {
|
|
42
|
+
warnings.push({ type: "unsupported", feature: "file parts" });
|
|
43
|
+
return `[Attachment: ${part.filename ?? part.mediaType}]`;
|
|
44
|
+
}
|
|
45
|
+
if (!dir) {
|
|
46
|
+
warnings.push({ type: "unsupported", feature: "file parts" });
|
|
47
|
+
return `[Attachment: ${part.filename ?? part.mediaType}]`;
|
|
48
|
+
}
|
|
49
|
+
const path = join(dir, `${files.length + 1}.${extensionOf(part.mediaType, part.filename)}`);
|
|
50
|
+
const bytes = typeof part.data === "string" ? Buffer.from(part.data, "base64") : part.data;
|
|
51
|
+
writeFileSync(path, bytes);
|
|
52
|
+
files.push(path);
|
|
53
|
+
return words.attachedFile(path);
|
|
54
|
+
};
|
|
55
|
+
for (const m of messages) {
|
|
56
|
+
if (m.role === "system") {
|
|
57
|
+
system.push(m.content);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const text = m.content
|
|
61
|
+
.map((part) => {
|
|
62
|
+
switch (part.type) {
|
|
63
|
+
case "text":
|
|
64
|
+
return part.text;
|
|
65
|
+
case "file":
|
|
66
|
+
return saveFile(part);
|
|
67
|
+
case "reasoning":
|
|
68
|
+
return "";
|
|
69
|
+
case "tool-call":
|
|
70
|
+
return `[Called ${part.toolName} with ${JSON.stringify(part.input)}]`;
|
|
71
|
+
case "tool-result": {
|
|
72
|
+
const out = part.output;
|
|
73
|
+
const value = out.type === "text" || out.type === "error-text"
|
|
74
|
+
? String(out.value)
|
|
75
|
+
: out.type === "json" || out.type === "error-json"
|
|
76
|
+
? JSON.stringify(out.value)
|
|
77
|
+
: out.type === "execution-denied"
|
|
78
|
+
? `denied${out.reason ? `: ${out.reason}` : ""}`
|
|
79
|
+
: JSON.stringify(out.value ?? out);
|
|
80
|
+
return `[Result of ${part.toolName}: ${value}]`;
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.join("\n");
|
|
88
|
+
turns.push({ role: m.role, text });
|
|
89
|
+
}
|
|
90
|
+
const request = turns.length === 1 && turns[0].role === "user"
|
|
91
|
+
? turns[0].text
|
|
92
|
+
: turns
|
|
93
|
+
.map((t) => `${t.role === "user" ? "User" : t.role === "tool" ? "Tool" : "Assistant"}:\n${t.text}`)
|
|
94
|
+
.join("\n\n");
|
|
95
|
+
if (turns.length > 1) {
|
|
96
|
+
system.push(words.conversationNote());
|
|
97
|
+
}
|
|
98
|
+
return { system: system.join("\n\n"), prompt: request, files, warnings };
|
|
99
|
+
}
|
|
100
|
+
/** What a client without a schema option is told so its answer parses. */
|
|
101
|
+
export function jsonInstruction(schema, words = DEFAULT_WORDS) {
|
|
102
|
+
return words.jsonInstruction(JSON.stringify(schema ?? { type: "object" }));
|
|
103
|
+
}
|
|
104
|
+
/** A client's answer as JSON: the fences and prose some wrap around it are taken off. */
|
|
105
|
+
export function parseJsonAnswer(text) {
|
|
106
|
+
const trimmed = text.trim();
|
|
107
|
+
const unfenced = trimmed
|
|
108
|
+
.replace(/^\s*```(?:json)?\s*/i, "")
|
|
109
|
+
.replace(/\s*```\s*$/, "")
|
|
110
|
+
.trim();
|
|
111
|
+
try {
|
|
112
|
+
return JSON.parse(unfenced);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Prose around the value: take the outermost object or array.
|
|
116
|
+
const start = unfenced.search(/[{[]/);
|
|
117
|
+
const end = Math.max(unfenced.lastIndexOf("}"), unfenced.lastIndexOf("]"));
|
|
118
|
+
if (start >= 0 && end > start) {
|
|
119
|
+
return JSON.parse(unfenced.slice(start, end + 1));
|
|
120
|
+
}
|
|
121
|
+
throw new Error("The answer is not JSON.");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** What one run of a client printed, and how it ended. */
|
|
2
|
+
export interface ClientOutput {
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
code: number | null;
|
|
6
|
+
}
|
|
7
|
+
/** Runs a client once with the prompt on stdin; a client that is not there raises ENOENT. */
|
|
8
|
+
export declare function runClient(bin: string, args: string[], opts: {
|
|
9
|
+
cwd: string;
|
|
10
|
+
env: NodeJS.ProcessEnv;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
stdin?: string;
|
|
13
|
+
}): Promise<ClientOutput>;
|
|
14
|
+
/** The last line of an output that is a JSON object. */
|
|
15
|
+
export declare function lastJson<T>(stdout: string): T | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import spawn from "cross-spawn";
|
|
2
|
+
/** Runs a client once with the prompt on stdin; a client that is not there raises ENOENT. */
|
|
3
|
+
export function runClient(bin, args, opts) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const child = spawn(bin, args, {
|
|
6
|
+
cwd: opts.cwd,
|
|
7
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
8
|
+
signal: opts.signal,
|
|
9
|
+
env: opts.env,
|
|
10
|
+
});
|
|
11
|
+
let stdout = "";
|
|
12
|
+
let stderr = "";
|
|
13
|
+
child.stdout.on("data", (chunk) => {
|
|
14
|
+
stdout += String(chunk);
|
|
15
|
+
});
|
|
16
|
+
child.stderr.on("data", (chunk) => {
|
|
17
|
+
stderr = (stderr + String(chunk)).slice(-4000);
|
|
18
|
+
});
|
|
19
|
+
child.on("error", reject);
|
|
20
|
+
child.on("close", (code) => resolve({ stdout, stderr, code }));
|
|
21
|
+
child.stdin.on("error", () => {
|
|
22
|
+
// The client went away before reading the prompt; `close` reports it.
|
|
23
|
+
});
|
|
24
|
+
child.stdin.end(opts.stdin ?? "");
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** The last line of an output that is a JSON object. */
|
|
28
|
+
export function lastJson(stdout) {
|
|
29
|
+
for (const line of stdout.trim().split("\n").reverse()) {
|
|
30
|
+
try {
|
|
31
|
+
const value = JSON.parse(line);
|
|
32
|
+
if (value && typeof value === "object") {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// not it
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CLIENT_IDS, CLIENTS, type Client, type ClientId, detectClient } from "./clients/index.js";
|
|
2
|
+
export { ollamaModel } from "./ollama/index.js";
|
|
3
|
+
export { type ProbeResult, type ProbeSource, type ProbeState, probe } from "./probe.js";
|
|
4
|
+
export { fits, type InstalledModel, type LocalServer, SERVER_IDS, SERVERS, type ServerId, } from "./servers/index.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type InstalledModel, type ServerOptions, type ServerState } from "../servers/server.js";
|
|
2
|
+
/**
|
|
3
|
+
* LM Studio on a computer, through its own REST API (`/api/v1/…`, LM Studio 0.4.0 and newer): the
|
|
4
|
+
* models it holds, downloads, and a model loaded with the context length a caller needs. Where
|
|
5
|
+
* its server wants a token, LM_API_TOKEN is it.
|
|
6
|
+
*/
|
|
7
|
+
/** Where LM Studio answers when nothing names another address. */
|
|
8
|
+
export declare const LMSTUDIO_DEFAULT = "http://127.0.0.1:1234";
|
|
9
|
+
/** LM Studio's root address, from its root or the OpenAI-compatible `…/v1`. */
|
|
10
|
+
export declare function lmStudioRoot(url: string): string;
|
|
11
|
+
/** Where LM Studio answers for this process: LMSTUDIO_URL (a root or `…/v1`), else its default. */
|
|
12
|
+
export declare function lmStudioAddress(env?: NodeJS.ProcessEnv): string;
|
|
13
|
+
/** A request's headers: the token, where there is one. */
|
|
14
|
+
export declare function lmStudioHeaders(env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
15
|
+
/** A model as `GET /api/v1/models` lists it. */
|
|
16
|
+
export interface ListedModel {
|
|
17
|
+
type: "llm" | "embedding" | "decision";
|
|
18
|
+
key: string;
|
|
19
|
+
quantization?: {
|
|
20
|
+
name?: string | null;
|
|
21
|
+
} | null;
|
|
22
|
+
size_bytes: number;
|
|
23
|
+
loaded_instances?: {
|
|
24
|
+
id: string;
|
|
25
|
+
config?: {
|
|
26
|
+
context_length?: number;
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
max_context_length?: number | null;
|
|
30
|
+
format?: "gguf" | "mlx" | null;
|
|
31
|
+
capabilities?: {
|
|
32
|
+
vision?: boolean;
|
|
33
|
+
trained_for_tool_use?: boolean;
|
|
34
|
+
reasoning?: {
|
|
35
|
+
allowed_options?: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
decision_type?: string;
|
|
39
|
+
}
|
|
40
|
+
/** The models as LM Studio lists them; null where it does not answer. */
|
|
41
|
+
export declare function listedModels(url: string, { fetch: doFetch }?: ServerOptions): Promise<ListedModel[] | null>;
|
|
42
|
+
export declare function lmStudioState(url: string, { fetch: doFetch }?: ServerOptions): Promise<ServerState>;
|
|
43
|
+
/** The models of the LM Studio at `url`; empty where it does not answer. */
|
|
44
|
+
export declare function lmStudioModels(url: string, options?: ServerOptions): Promise<InstalledModel[]>;
|
|
45
|
+
/** Downloads a model of LM Studio's catalog, or by its Hugging Face address; asked again each second. */
|
|
46
|
+
export declare function lmStudioDownload(url: string, model: string, onProgress: (done: number, total: number) => void, { fetch: doFetch, signal, every, }?: ServerOptions & {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
every?: number;
|
|
49
|
+
}): Promise<void>;
|