@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
|
@@ -11,6 +11,9 @@ import { serverText } from "../texts.js";
|
|
|
11
11
|
import { authenticate, principalOf } from "./auth.js";
|
|
12
12
|
import { registerElementTools } from "./elements.js";
|
|
13
13
|
import { registerFlowApp } from "./flow-app.js";
|
|
14
|
+
import { requestStateVerify } from "./run-pages.js";
|
|
15
|
+
import { runTaskRequest } from "./run-tasks.js";
|
|
16
|
+
import { registerRunTools } from "./runs.js";
|
|
14
17
|
import { appKind, clientNameOf, noteChecked, noteRequest } from "./seen.js";
|
|
15
18
|
import { registerPrompts, registerTools } from "./tools.js";
|
|
16
19
|
/**
|
|
@@ -73,10 +76,13 @@ export function mcpHandler() {
|
|
|
73
76
|
const server = new McpServer({ name: "engenty-wizards", version: "0.1.0" }, {
|
|
74
77
|
instructions: prompt("mcp", "instructions"),
|
|
75
78
|
capabilities: { tools: {}, prompts: {}, resources: {} },
|
|
79
|
+
// A run's page asked of the person comes back with its sealed state (mcp/run-pages.ts).
|
|
80
|
+
requestState: { verify: requestStateVerify },
|
|
76
81
|
});
|
|
77
82
|
const who = principalOf(ctx.authInfo);
|
|
78
83
|
registerTools(server, who);
|
|
79
84
|
registerElementTools(server, who);
|
|
85
|
+
registerRunTools(server, who);
|
|
80
86
|
registerPrompts(server);
|
|
81
87
|
registerFlowApp(server);
|
|
82
88
|
return server;
|
|
@@ -104,6 +110,12 @@ export function mcpHandler() {
|
|
|
104
110
|
if (refused) {
|
|
105
111
|
return refused;
|
|
106
112
|
}
|
|
113
|
+
// Runs followed as tasks: the SDK has no runtime for the Tasks extension (mcp/run-tasks.ts).
|
|
114
|
+
const tasked = await withTenant(who.tenantId, () => asRole(who.role, () => runTaskRequest(who, body)));
|
|
115
|
+
if (tasked) {
|
|
116
|
+
nudge(who.tenantId);
|
|
117
|
+
return tasked;
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
const answer = await withTenant(who.tenantId, () => asRole(who.role, () => handler.fetch(request, { authInfo })));
|
|
109
121
|
if (request.method === "POST") {
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
import { createRequestStateCodec, inputRequired, inputResponse, } from "@modelcontextprotocol/server";
|
|
3
|
+
import { env } from "../env.js";
|
|
4
|
+
import { ServiceError } from "../services/errors.js";
|
|
5
|
+
import { answerRunAsk, answerRunForm, answerRunQuestion, reviewRun, runReport, } from "../services/runs.js";
|
|
6
|
+
const PAGE = "page";
|
|
7
|
+
/** How long an answered page waits for the run to reach its next page. */
|
|
8
|
+
const AFTER_ANSWER_SECONDS = 20;
|
|
9
|
+
/** A page waits this long for the person; the run itself waits on. */
|
|
10
|
+
const PAGE_TTL_SECONDS = 60 * 60;
|
|
11
|
+
/** As many fields as a form question may have before the run page takes over. */
|
|
12
|
+
const MAX_FIELDS = 12;
|
|
13
|
+
const CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
14
|
+
const codec = createRequestStateCodec({
|
|
15
|
+
key: createHmac("sha256", env.authSecret).update("mcp.run-pages").digest(),
|
|
16
|
+
ttlSeconds: PAGE_TTL_SECONDS,
|
|
17
|
+
// A page's state is the person's own: it does not work for another token's person.
|
|
18
|
+
bind: (ctx) => {
|
|
19
|
+
const who = ctx.http?.authInfo?.extra;
|
|
20
|
+
return `${who?.tenantId ?? ""}\n${who?.userId ?? ""}`;
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
/** For the server's options: checks a page's state when it comes back. */
|
|
24
|
+
export const requestStateVerify = codec.verify;
|
|
25
|
+
/** The client shows forms the server asks for, on this request. */
|
|
26
|
+
export function asksPages(ctx) {
|
|
27
|
+
const envelope = ctx.mcpReq.envelope;
|
|
28
|
+
const caps = envelope?.[CLIENT_CAPABILITIES];
|
|
29
|
+
const elicitation = caps?.elicitation;
|
|
30
|
+
// An empty `elicitation` capability means forms (the url mode is declared on its own).
|
|
31
|
+
return Boolean(elicitation && (elicitation.form || Object.keys(elicitation).length === 0));
|
|
32
|
+
}
|
|
33
|
+
/** A form field as an elicitation property, or nothing when only the run page can ask it. */
|
|
34
|
+
function propertyOf(field) {
|
|
35
|
+
const base = { title: field.label, ...(field.help ? { description: field.help } : {}) };
|
|
36
|
+
switch (field.kind) {
|
|
37
|
+
case "text":
|
|
38
|
+
case "textarea":
|
|
39
|
+
return { type: "string", ...base };
|
|
40
|
+
case "email":
|
|
41
|
+
return { type: "string", format: "email", ...base };
|
|
42
|
+
case "url":
|
|
43
|
+
return { type: "string", format: "uri", ...base };
|
|
44
|
+
case "date":
|
|
45
|
+
return { type: "string", format: "date", ...base };
|
|
46
|
+
case "number":
|
|
47
|
+
return { type: "number", ...base };
|
|
48
|
+
case "toggle":
|
|
49
|
+
return { type: "boolean", ...base };
|
|
50
|
+
case "select":
|
|
51
|
+
return field.options?.length ? { type: "string", enum: field.options, ...base } : null;
|
|
52
|
+
case "slot":
|
|
53
|
+
return field.times?.length
|
|
54
|
+
? {
|
|
55
|
+
type: "string",
|
|
56
|
+
oneOf: field.times.map((t) => ({ const: t.value, title: t.label })),
|
|
57
|
+
...base,
|
|
58
|
+
}
|
|
59
|
+
: null;
|
|
60
|
+
case "multiselect":
|
|
61
|
+
return field.options?.length
|
|
62
|
+
? { type: "array", items: { type: "string", enum: field.options }, ...base }
|
|
63
|
+
: null;
|
|
64
|
+
default:
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** The run page in the person's browser, for what a form question cannot ask. */
|
|
69
|
+
function onThePage(report, title) {
|
|
70
|
+
return report.browserUrl
|
|
71
|
+
? inputRequired.elicitUrl({ message: title, url: report.browserUrl })
|
|
72
|
+
: null;
|
|
73
|
+
}
|
|
74
|
+
/** What the person is asked for the page the run waits on; nothing when it waits on no one. */
|
|
75
|
+
export function pageOf(report) {
|
|
76
|
+
const w = report.waitingFor;
|
|
77
|
+
if (!w) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const runId = report.runId;
|
|
81
|
+
if (w.question) {
|
|
82
|
+
return {
|
|
83
|
+
state: { runId, kind: "question", id: report.step?.id ?? "" },
|
|
84
|
+
request: inputRequired.elicit({
|
|
85
|
+
message: w.question,
|
|
86
|
+
requestedSchema: {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: { answer: { type: "string", title: w.title ?? "Answer" } },
|
|
89
|
+
required: ["answer"],
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (w.ask && w.kind === "confirm") {
|
|
95
|
+
const what = [w.reason, w.service && w.action ? `${w.service}: ${w.action}` : "", w.input]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join("\n\n");
|
|
98
|
+
return {
|
|
99
|
+
state: { runId, kind: "ask", id: w.ask },
|
|
100
|
+
request: inputRequired.elicit({
|
|
101
|
+
message: what,
|
|
102
|
+
requestedSchema: {
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: {
|
|
105
|
+
answer: {
|
|
106
|
+
type: "string",
|
|
107
|
+
title: "Allow this?",
|
|
108
|
+
oneOf: [
|
|
109
|
+
{ const: "allow", title: "Allow" },
|
|
110
|
+
{ const: "skip", title: "Skip" },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
required: ["answer"],
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (w.ask) {
|
|
120
|
+
const request = onThePage(report, w.reason ?? w.title ?? report.step?.title ?? "");
|
|
121
|
+
return request ? { state: { runId, kind: "page", id: w.ask }, request } : null;
|
|
122
|
+
}
|
|
123
|
+
if (w.review) {
|
|
124
|
+
const outputs = report.outputs
|
|
125
|
+
.map((o) => (o.text ? `${o.title}\n${o.text}` : o.title))
|
|
126
|
+
.join("\n\n");
|
|
127
|
+
return {
|
|
128
|
+
state: { runId, kind: "review", id: w.review },
|
|
129
|
+
request: inputRequired.elicit({
|
|
130
|
+
message: [w.title, outputs].filter(Boolean).join("\n\n"),
|
|
131
|
+
requestedSchema: {
|
|
132
|
+
type: "object",
|
|
133
|
+
properties: {
|
|
134
|
+
decision: {
|
|
135
|
+
type: "string",
|
|
136
|
+
title: w.title ?? "Review",
|
|
137
|
+
oneOf: [
|
|
138
|
+
{ const: "accept", title: "Accept" },
|
|
139
|
+
...(w.approve ? [{ const: "decline", title: "Decline" }] : []),
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
note: { type: "string", title: "Note" },
|
|
143
|
+
},
|
|
144
|
+
required: ["decision"],
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (w.form && w.fields) {
|
|
150
|
+
const title = w.title ?? report.step?.title ?? "";
|
|
151
|
+
const fields = w.fields;
|
|
152
|
+
const properties = fields.map((f) => [f.id, f.inChat && !f.when ? propertyOf(f) : null]);
|
|
153
|
+
// A page with a field only the run page asks, or fields that depend on each other, goes
|
|
154
|
+
// whole to the run page.
|
|
155
|
+
if (fields.length > MAX_FIELDS || properties.some(([, p]) => p === null)) {
|
|
156
|
+
const request = onThePage(report, title);
|
|
157
|
+
return request ? { state: { runId, kind: "page", id: w.form }, request } : null;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
state: { runId, kind: "form", id: w.form },
|
|
161
|
+
request: inputRequired.elicit({
|
|
162
|
+
message: title,
|
|
163
|
+
requestedSchema: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: Object.fromEntries(properties),
|
|
166
|
+
required: fields.filter((f) => f.required).map((f) => f.id),
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
/** Puts the person's answer into the run. Answered elsewhere meanwhile: nothing to do. */
|
|
174
|
+
export async function answerPage(userId, state, content) {
|
|
175
|
+
try {
|
|
176
|
+
if (state.kind === "form") {
|
|
177
|
+
await answerRunForm(userId, state.runId, state.id, content);
|
|
178
|
+
}
|
|
179
|
+
else if (state.kind === "question") {
|
|
180
|
+
await answerRunQuestion(userId, state.runId, String(content.answer ?? ""));
|
|
181
|
+
}
|
|
182
|
+
else if (state.kind === "ask") {
|
|
183
|
+
await answerRunAsk(userId, state.runId, state.id, content.answer === "allow" ? "allow" : "skip");
|
|
184
|
+
}
|
|
185
|
+
else if (state.kind === "review") {
|
|
186
|
+
const note = typeof content.note === "string" && content.note ? content.note : undefined;
|
|
187
|
+
await reviewRun(userId, state.runId, state.id, content.decision === "decline" ? { type: "decline", note } : { type: "accept", note });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
const now = await runReport(userId, state.runId);
|
|
192
|
+
const still = pageOf(now)?.state;
|
|
193
|
+
// The page was answered on the run page or in the widget: the run went on without this.
|
|
194
|
+
if (!(err instanceof ServiceError) || (still?.kind === state.kind && still.id === state.id)) {
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Runs a run tool with its pages asked of the person. `start` is what the tool does on its first
|
|
201
|
+
* call (start the run, answer a page) and gives the run's report; `finish` turns the report into
|
|
202
|
+
* the tool's answer once the run waits on no one the client can ask.
|
|
203
|
+
*/
|
|
204
|
+
export async function withPages(ctx, who, start, finish) {
|
|
205
|
+
if (!asksPages(ctx)) {
|
|
206
|
+
const first = await start();
|
|
207
|
+
return "failed" in first ? first.failed : finish(first);
|
|
208
|
+
}
|
|
209
|
+
const state = ctx.mcpReq.requestState();
|
|
210
|
+
let report;
|
|
211
|
+
if (state) {
|
|
212
|
+
const answer = inputResponse(ctx.mcpReq.inputResponses, PAGE);
|
|
213
|
+
if (answer.kind === "elicit" && answer.action !== "accept") {
|
|
214
|
+
// The person put the page off or said no: the run waits, the client hears it.
|
|
215
|
+
const now = await runReport(who.userId, state.runId);
|
|
216
|
+
return finish({ ...now, unanswered: true });
|
|
217
|
+
}
|
|
218
|
+
if (answer.kind === "elicit" && state.kind !== "page") {
|
|
219
|
+
await answerPage(who.userId, state, answer.content ?? {});
|
|
220
|
+
}
|
|
221
|
+
report = await runReport(who.userId, state.runId, AFTER_ANSWER_SECONDS);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const first = await start();
|
|
225
|
+
if ("failed" in first) {
|
|
226
|
+
return first.failed;
|
|
227
|
+
}
|
|
228
|
+
report = first;
|
|
229
|
+
}
|
|
230
|
+
const page = pageOf(report);
|
|
231
|
+
if (!page) {
|
|
232
|
+
return finish(report);
|
|
233
|
+
}
|
|
234
|
+
return inputRequired({
|
|
235
|
+
inputRequests: { [PAGE]: page.request },
|
|
236
|
+
requestState: await codec.mint(page.state, ctx),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { callOutside } from "../elements/outside.js";
|
|
4
|
+
import { ELEMENT_SPECS } from "../elements/specs.js";
|
|
5
|
+
import { controlRun, runReport } from "../services/runs.js";
|
|
6
|
+
import { answer, withFlow } from "./elements.js";
|
|
7
|
+
import { answerPage, pageOf } from "./run-pages.js";
|
|
8
|
+
/**
|
|
9
|
+
* Long runs as MCP tasks (the Tasks extension, SEP-2663, protocol 2026-07-28; experimental).
|
|
10
|
+
* A client that declares `io.modelcontextprotocol/tasks` gets `wizard_run` back as a task at
|
|
11
|
+
* once: the task is the run itself (its id is the run's), so nothing is kept for it beside the
|
|
12
|
+
* run, and a runtime that restarts keeps every task. The client asks `tasks/get` how it stands;
|
|
13
|
+
* a page the run waits on is the task's `input_required` with the page as an elicitation
|
|
14
|
+
* (mcp/run-pages.ts), the answer comes with `tasks/update`; `tasks/cancel` cancels the run.
|
|
15
|
+
*
|
|
16
|
+
* The MCP SDK has no runtime for the extension, so these requests are answered here, in front
|
|
17
|
+
* of it (mcp/handler.ts), after the token was checked. Everything else goes to the SDK.
|
|
18
|
+
*/
|
|
19
|
+
const EXTENSION = "io.modelcontextprotocol/tasks";
|
|
20
|
+
const CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
|
|
21
|
+
const POLL_MS = 3000;
|
|
22
|
+
const taskParams = z.object({ taskId: z.string().min(1) });
|
|
23
|
+
const updateParams = taskParams.extend({
|
|
24
|
+
inputResponses: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
|
|
25
|
+
});
|
|
26
|
+
function reply(id, result) {
|
|
27
|
+
return Response.json({ jsonrpc: "2.0", id: id ?? null, result });
|
|
28
|
+
}
|
|
29
|
+
function refuse(id, code, message) {
|
|
30
|
+
return Response.json({ jsonrpc: "2.0", id: id ?? null, error: { code, message } });
|
|
31
|
+
}
|
|
32
|
+
/** The client said, on this request, that it follows tasks. */
|
|
33
|
+
function followsTasks(rpc) {
|
|
34
|
+
const caps = rpc.params?._meta?.[CLIENT_CAPABILITIES];
|
|
35
|
+
return Boolean(caps?.extensions?.[EXTENSION]);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The key of the page a run waits on. The extension wants a key unique over the task's life: a
|
|
39
|
+
* client keeps the answers by it, so a later page under the same key would count as answered.
|
|
40
|
+
* The key names the page and what it holds now, so the same page again (after going back) is
|
|
41
|
+
* a new key.
|
|
42
|
+
*/
|
|
43
|
+
function pageKey(report, page) {
|
|
44
|
+
const fields = report
|
|
45
|
+
.waitingFor?.fields;
|
|
46
|
+
const values = JSON.stringify((fields ?? []).map((f) => [f.id, f.value ?? null]));
|
|
47
|
+
const digest = createHash("sha256").update(values).digest("base64url").slice(0, 12);
|
|
48
|
+
return `${page.state.kind}-${page.state.id}-${(report.passed ?? []).length}-${digest}`;
|
|
49
|
+
}
|
|
50
|
+
/** The run as a task: how it stands, what it asks, what it came to. */
|
|
51
|
+
async function taskOf(who, report) {
|
|
52
|
+
const now = new Date().toISOString();
|
|
53
|
+
const base = {
|
|
54
|
+
taskId: report.runId,
|
|
55
|
+
createdAt: now,
|
|
56
|
+
lastUpdatedAt: now,
|
|
57
|
+
// A run lives as long as the space keeps it.
|
|
58
|
+
ttlMs: null,
|
|
59
|
+
pollIntervalMs: POLL_MS,
|
|
60
|
+
};
|
|
61
|
+
const status = report.status;
|
|
62
|
+
if (status === "done") {
|
|
63
|
+
const result = await withFlow(who.userId, answer({ ok: true, result: report }), report);
|
|
64
|
+
return { ...base, status: "completed", result };
|
|
65
|
+
}
|
|
66
|
+
if (status === "failed") {
|
|
67
|
+
return {
|
|
68
|
+
...base,
|
|
69
|
+
status: "failed",
|
|
70
|
+
error: { code: -32603, message: String(report.error ?? "The run failed.") },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (status === "cancelled") {
|
|
74
|
+
return { ...base, status: "cancelled" };
|
|
75
|
+
}
|
|
76
|
+
const page = pageOf(report);
|
|
77
|
+
if (page) {
|
|
78
|
+
return {
|
|
79
|
+
...base,
|
|
80
|
+
status: "input_required",
|
|
81
|
+
statusMessage: report.step?.title,
|
|
82
|
+
inputRequests: { [pageKey(report, page)]: page.request },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return { ...base, status: "working", statusMessage: report.step?.title };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Answers a request of the Tasks extension, or `wizard_run` called as a task; nothing for every
|
|
89
|
+
* other request. Runs in the token's tenant and role.
|
|
90
|
+
*/
|
|
91
|
+
export async function runTaskRequest(who, body) {
|
|
92
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const rpc = body;
|
|
96
|
+
const method = rpc.method;
|
|
97
|
+
const mayRun = who.scopes.includes("elements:run") || who.scopes.includes("runs:test");
|
|
98
|
+
if (method === "tools/call" && rpc.params?.name === "wizard_run" && followsTasks(rpc)) {
|
|
99
|
+
if (!mayRun) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const input = ELEMENT_SPECS.wizard_run.input
|
|
103
|
+
.extend({ spaceId: z.string().optional() })
|
|
104
|
+
.safeParse(rpc.params.arguments ?? {});
|
|
105
|
+
if (!input.success) {
|
|
106
|
+
return refuse(rpc.id, -32602, "Invalid arguments for wizard_run.");
|
|
107
|
+
}
|
|
108
|
+
const { spaceId, ...args } = input.data;
|
|
109
|
+
const started = await callOutside({
|
|
110
|
+
userId: who.userId,
|
|
111
|
+
role: who.role,
|
|
112
|
+
client: who.client,
|
|
113
|
+
tenantId: who.tenantId,
|
|
114
|
+
scopes: who.scopes,
|
|
115
|
+
}, spaceId, "wizard_run", { ...args, waitSeconds: 0 }, AbortSignal.timeout(60_000));
|
|
116
|
+
if (!started.ok) {
|
|
117
|
+
// A run that never started is no task: the call fails as it would without one.
|
|
118
|
+
return reply(rpc.id, { resultType: "complete", ...answer(started) });
|
|
119
|
+
}
|
|
120
|
+
const task = await taskOf(who, started.result);
|
|
121
|
+
const { result: _result, inputRequests: _asks, ...handle } = task;
|
|
122
|
+
return reply(rpc.id, { resultType: "task", ...handle });
|
|
123
|
+
}
|
|
124
|
+
if (method !== "tasks/get" && method !== "tasks/update" && method !== "tasks/cancel") {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (!mayRun) {
|
|
128
|
+
return refuse(rpc.id, -32602, "Unknown task.");
|
|
129
|
+
}
|
|
130
|
+
const parsed = updateParams.safeParse(rpc.params ?? {});
|
|
131
|
+
if (!parsed.success) {
|
|
132
|
+
return refuse(rpc.id, -32602, "Invalid task request.");
|
|
133
|
+
}
|
|
134
|
+
const { taskId, inputResponses } = parsed.data;
|
|
135
|
+
// Another person's run, or none: the same answer, so a task's existence stays unknown.
|
|
136
|
+
const report = await runReport(who.userId, taskId).catch(() => null);
|
|
137
|
+
if (!report) {
|
|
138
|
+
return refuse(rpc.id, -32602, "Unknown task.");
|
|
139
|
+
}
|
|
140
|
+
if (method === "tasks/cancel") {
|
|
141
|
+
await controlRun(who.userId, taskId, "cancel").catch(() => undefined);
|
|
142
|
+
return reply(rpc.id, {
|
|
143
|
+
resultType: "complete",
|
|
144
|
+
...(await taskOf(who, await runReport(who.userId, taskId))),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (method === "tasks/update") {
|
|
148
|
+
const page = pageOf(report);
|
|
149
|
+
// The answer to the page the run waits on now; one to an earlier page finds it answered.
|
|
150
|
+
const response = (page ? inputResponses?.[pageKey(report, page)] : undefined);
|
|
151
|
+
if (page && response?.action === "accept" && page.state.kind !== "page") {
|
|
152
|
+
await answerPage(who.userId, page.state, response.content ?? {});
|
|
153
|
+
}
|
|
154
|
+
return reply(rpc.id, { resultType: "complete" });
|
|
155
|
+
}
|
|
156
|
+
return reply(rpc.id, { resultType: "complete", ...(await taskOf(who, report)) });
|
|
157
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { prompt } from "../prompts.js";
|
|
3
|
+
import { answerRunAsk, answerRunForm, answerRunQuestion, controlRun, reviewRun, runReport, } from "../services/runs.js";
|
|
4
|
+
import { withPages } from "./run-pages.js";
|
|
5
|
+
import { annotationsOf, failure, ok } from "./tools.js";
|
|
6
|
+
/**
|
|
7
|
+
* A run once it started: what it waits for, and the person's answers to it. For the wizard's
|
|
8
|
+
* author testing it (`runs:test`) and for anyone who runs the space's wizards (`elements:run`,
|
|
9
|
+
* `wizard_run`), a client of the organization too: the run decides who may answer it
|
|
10
|
+
* (`answerableRun`), never the token alone.
|
|
11
|
+
*/
|
|
12
|
+
export function registerRunTools(server, who) {
|
|
13
|
+
if (!(who.scopes.includes("runs:test") || who.scopes.includes("elements:run"))) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const tool = (name, config, run) => {
|
|
17
|
+
server.registerTool(name, {
|
|
18
|
+
title: config.title,
|
|
19
|
+
description: config.description,
|
|
20
|
+
inputSchema: config.input,
|
|
21
|
+
annotations: annotationsOf(config),
|
|
22
|
+
}, (async (args, ctx) => {
|
|
23
|
+
try {
|
|
24
|
+
if (config.pages) {
|
|
25
|
+
return await withPages(ctx, who, async () => (await run(args)), (report) => ok(report));
|
|
26
|
+
}
|
|
27
|
+
return ok(await run(args));
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
return failure(err);
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
const waitSeconds = z
|
|
35
|
+
.number()
|
|
36
|
+
.int()
|
|
37
|
+
.min(0)
|
|
38
|
+
.max(45)
|
|
39
|
+
.default(0)
|
|
40
|
+
.describe("Wait up to this long while the run is still working.");
|
|
41
|
+
tool("get_run", {
|
|
42
|
+
title: "Get run",
|
|
43
|
+
description: prompt("mcp", "tool.get_run"),
|
|
44
|
+
input: z.object({ runId: z.string(), waitSeconds }),
|
|
45
|
+
readOnly: true,
|
|
46
|
+
}, async ({ runId, waitSeconds }) => runReport(who.userId, runId, waitSeconds));
|
|
47
|
+
tool("answer_form", {
|
|
48
|
+
title: "Answer form",
|
|
49
|
+
description: prompt("mcp", "tool.answer_form"),
|
|
50
|
+
input: z.object({
|
|
51
|
+
runId: z.string(),
|
|
52
|
+
stepId: z.string().describe("waitingFor.form"),
|
|
53
|
+
values: z.record(z.string(), z.unknown()),
|
|
54
|
+
waitSeconds,
|
|
55
|
+
}),
|
|
56
|
+
openWorld: true,
|
|
57
|
+
pages: true,
|
|
58
|
+
}, async ({ runId, stepId, values, waitSeconds }) => {
|
|
59
|
+
await answerRunForm(who.userId, runId, stepId, values);
|
|
60
|
+
return runReport(who.userId, runId, waitSeconds);
|
|
61
|
+
});
|
|
62
|
+
tool("review_step", {
|
|
63
|
+
title: "Review step",
|
|
64
|
+
description: prompt("mcp", "tool.review_step"),
|
|
65
|
+
input: z.object({
|
|
66
|
+
runId: z.string(),
|
|
67
|
+
stepId: z.string().describe("waitingFor.review"),
|
|
68
|
+
action: z.discriminatedUnion("type", [
|
|
69
|
+
z.object({
|
|
70
|
+
type: z.literal("accept"),
|
|
71
|
+
edits: z.record(z.string(), z.string()).optional(),
|
|
72
|
+
note: z.string().max(2000).optional(),
|
|
73
|
+
}),
|
|
74
|
+
z.object({
|
|
75
|
+
type: z.literal("decline").describe("Only when waitingFor.approve is true."),
|
|
76
|
+
note: z.string().max(2000).optional(),
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
type: z.literal("regenerate"),
|
|
80
|
+
target: z.string().describe("One of waitingFor.show."),
|
|
81
|
+
note: z.string().max(2000),
|
|
82
|
+
}),
|
|
83
|
+
]),
|
|
84
|
+
waitSeconds,
|
|
85
|
+
}),
|
|
86
|
+
openWorld: true,
|
|
87
|
+
pages: true,
|
|
88
|
+
}, async ({ runId, stepId, action, waitSeconds }) => {
|
|
89
|
+
await reviewRun(who.userId, runId, stepId, action);
|
|
90
|
+
return runReport(who.userId, runId, waitSeconds);
|
|
91
|
+
});
|
|
92
|
+
tool("answer_ask", {
|
|
93
|
+
title: "Answer confirmation",
|
|
94
|
+
description: prompt("mcp", "tool.answer_ask"),
|
|
95
|
+
input: z.object({
|
|
96
|
+
runId: z.string(),
|
|
97
|
+
askId: z.string(),
|
|
98
|
+
answer: z.enum(["allow", "skip"]),
|
|
99
|
+
waitSeconds,
|
|
100
|
+
}),
|
|
101
|
+
destructive: true,
|
|
102
|
+
openWorld: true,
|
|
103
|
+
pages: true,
|
|
104
|
+
}, async ({ runId, askId, answer, waitSeconds }) => {
|
|
105
|
+
await answerRunAsk(who.userId, runId, askId, answer);
|
|
106
|
+
return runReport(who.userId, runId, waitSeconds);
|
|
107
|
+
});
|
|
108
|
+
tool("answer_question", {
|
|
109
|
+
title: "Answer a step's question",
|
|
110
|
+
description: prompt("mcp", "tool.answer_question"),
|
|
111
|
+
input: z.object({ runId: z.string(), answer: z.string().min(1), waitSeconds }),
|
|
112
|
+
destructive: false,
|
|
113
|
+
openWorld: true,
|
|
114
|
+
pages: true,
|
|
115
|
+
}, async ({ runId, answer, waitSeconds }) => {
|
|
116
|
+
await answerRunQuestion(who.userId, runId, answer);
|
|
117
|
+
return runReport(who.userId, runId, waitSeconds);
|
|
118
|
+
});
|
|
119
|
+
tool("control_run", {
|
|
120
|
+
title: "Control run",
|
|
121
|
+
description: prompt("mcp", "tool.control_run"),
|
|
122
|
+
input: z.object({ runId: z.string(), action: z.enum(["back", "retry", "cancel"]) }),
|
|
123
|
+
destructive: true,
|
|
124
|
+
openWorld: true,
|
|
125
|
+
}, async ({ runId, action }) => {
|
|
126
|
+
await controlRun(who.userId, runId, action);
|
|
127
|
+
return runReport(who.userId, runId);
|
|
128
|
+
});
|
|
129
|
+
}
|