@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,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* `@openuidev/react-lang` mounts its devtools in a development build, and they load a script
|
|
5
|
+
* from cdn.jsdelivr.net. Its own flag says they are mounted already; set before react-lang loads
|
|
6
|
+
* (`react/chat.tsx` imports this module first), nothing is loaded from outside.
|
|
7
|
+
*/
|
|
8
|
+
globalThis[Symbol.for("openui.devtools.autoMount")] = true;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { Surface, SurfaceComponent } from "../surface.js";
|
|
3
|
+
/**
|
|
4
|
+
* A surface drawn with the runner's own components: the catalog in @engenty/chatviews/surface, nothing
|
|
5
|
+
* else. Unknown components render nothing; a prop that is not there shows empty.
|
|
6
|
+
*/
|
|
7
|
+
export type SurfaceAction = {
|
|
8
|
+
action: "regenerate" | "open" | "ask";
|
|
9
|
+
target?: unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* What a chat gives its views: where a Ref leads, and its Form drawn by the host, which knows how
|
|
13
|
+
* the answers are sent (the runner draws it with its own field kinds).
|
|
14
|
+
*/
|
|
15
|
+
export interface SurfaceChat {
|
|
16
|
+
/** Where a Ref's `open` leads; null: it shows without a link. */
|
|
17
|
+
href(open: string): string | null;
|
|
18
|
+
/** Follows an address of the host's own (its router), instead of loading the page. */
|
|
19
|
+
follow?(href: string): void;
|
|
20
|
+
/** Draws a Form and its Fields. */
|
|
21
|
+
form?(c: SurfaceComponent, byId: Map<string, SurfaceComponent>, data: Record<string, unknown>): ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/** What the person did in a view that is kept with the run: a checklist's ticks, by component id. */
|
|
24
|
+
export type SurfaceState = Record<string, unknown>;
|
|
25
|
+
export declare function SurfaceView({ surface, assetUrl, onAction, initial, onState, chat, field, slots, }: {
|
|
26
|
+
surface: Surface;
|
|
27
|
+
assetUrl: (id: string) => string;
|
|
28
|
+
onAction?: (a: SurfaceAction) => void;
|
|
29
|
+
/** A chat's view (Work): where its Refs lead, and how its Form is sent. */
|
|
30
|
+
chat?: SurfaceChat;
|
|
31
|
+
/** What the person did in the view last time (kept with the run). */
|
|
32
|
+
initial?: SurfaceState;
|
|
33
|
+
/** Keeps what the person did; without it, it lasts as long as the page. */
|
|
34
|
+
onState?: (next: SurfaceState) => void;
|
|
35
|
+
/** A page's layout: draws one of its fields where a `Field` places it. */
|
|
36
|
+
field?: (name: string) => React.ReactNode;
|
|
37
|
+
/** Ids drawn by the host instead of a component of the surface (a chat view's children). */
|
|
38
|
+
slots?: ReadonlyMap<string, ReactNode>;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { Check, ChevronRight, Clock, ExternalLink, FileText, Lightbulb, MessageSquare, Share2, Table2, Wand2, } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { calcTruthy } from "../calc.js";
|
|
6
|
+
import { bound as boundTo } from "../surface.js";
|
|
7
|
+
import { ListChoice, NumberSlider } from "./field-looks.js";
|
|
8
|
+
import { Markdown } from "./markdown.js";
|
|
9
|
+
import { t, viewLang } from "./texts.js";
|
|
10
|
+
import { cn, Dialog, Segmented, Tabs as Segments, Switch } from "./ui.js";
|
|
11
|
+
/** A prop's value, numbers written as the person's language writes them. */
|
|
12
|
+
const bound = (value, data, row) => boundTo(value, data, row, viewLang());
|
|
13
|
+
// A yes/no without words of its own reads as yes or no, never as true or false.
|
|
14
|
+
const text = (v) => v === null || v === undefined
|
|
15
|
+
? ""
|
|
16
|
+
: typeof v === "boolean"
|
|
17
|
+
? t(v ? "run.yes" : "run.no")
|
|
18
|
+
: typeof v === "object"
|
|
19
|
+
? JSON.stringify(v)
|
|
20
|
+
: String(v);
|
|
21
|
+
const num = (v) => {
|
|
22
|
+
const n = typeof v === "number" ? v : Number(String(v ?? "").replace(",", "."));
|
|
23
|
+
return Number.isFinite(n) ? n : 0;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A picture or file: an asset of the run by id, or an address. A chat's view shows the space's
|
|
27
|
+
* own files only: an address on the web could tell its owner who reads the chat.
|
|
28
|
+
*/
|
|
29
|
+
function src(v, ctx) {
|
|
30
|
+
const s = text(v);
|
|
31
|
+
if (!s) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (/^(https?:|data:|\/)/.test(s)) {
|
|
35
|
+
return ctx.chat ? null : s;
|
|
36
|
+
}
|
|
37
|
+
return ctx.assetUrl(s);
|
|
38
|
+
}
|
|
39
|
+
function prop(c, key, ctx, row) {
|
|
40
|
+
return bound(c[key], ctx.data, row);
|
|
41
|
+
}
|
|
42
|
+
/** Chart points from rows: their `label` and `value`, or the columns a chart names instead. */
|
|
43
|
+
function points(v, labelKey, valueKey) {
|
|
44
|
+
const l = text(labelKey) || "label";
|
|
45
|
+
const k = text(valueKey) || "value";
|
|
46
|
+
return Array.isArray(v)
|
|
47
|
+
? v.map((p) => ({ label: text(p?.[l]), value: num(p?.[k]) }))
|
|
48
|
+
: [];
|
|
49
|
+
}
|
|
50
|
+
function Children({ c, ctx, row }) {
|
|
51
|
+
const kids = c.children;
|
|
52
|
+
if (!kids) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(kids)) {
|
|
56
|
+
return (_jsx(_Fragment, { children: kids.map((id) => (_jsx(Node, { id: id, ctx: ctx, row: row }, id))) }));
|
|
57
|
+
}
|
|
58
|
+
const items = bound({ path: kids.path }, ctx.data, row);
|
|
59
|
+
return (_jsx(_Fragment, { children: (Array.isArray(items) ? items : []).map((item, i) => (_jsx(Node, { id: kids.componentId, ctx: ctx, row: item }, i))) }));
|
|
60
|
+
}
|
|
61
|
+
const TONES = {
|
|
62
|
+
success: "bg-second-tint text-second",
|
|
63
|
+
warning: "bg-amber-tint text-ink-2",
|
|
64
|
+
accent: "bg-ember-tint text-ember-strong",
|
|
65
|
+
default: "bg-paper-2 text-ink-2",
|
|
66
|
+
};
|
|
67
|
+
const rows = (v) => (Array.isArray(v) ? v : []);
|
|
68
|
+
/** A cell of an entry by its key; an entry that is itself a value is its own label. */
|
|
69
|
+
function cell(item, key) {
|
|
70
|
+
if (item === null || typeof item !== "object") {
|
|
71
|
+
return key === "" ? item : undefined;
|
|
72
|
+
}
|
|
73
|
+
return item[key];
|
|
74
|
+
}
|
|
75
|
+
/** What an entry is called: its `labelKey`, else the usual keys, else the entry itself. */
|
|
76
|
+
function labelOf(item, key) {
|
|
77
|
+
if (item === null || typeof item !== "object") {
|
|
78
|
+
return text(item);
|
|
79
|
+
}
|
|
80
|
+
const r = item;
|
|
81
|
+
return text(key ? r[key] : (r.label ?? r.name ?? r.title ?? r.text));
|
|
82
|
+
}
|
|
83
|
+
/** Entries under a heading per value of a key, in `order` first, the rest as they come. */
|
|
84
|
+
function grouped(items, by, order) {
|
|
85
|
+
const groups = new Map();
|
|
86
|
+
for (const item of items) {
|
|
87
|
+
const name = text(cell(item, by));
|
|
88
|
+
groups.set(name, [...(groups.get(name) ?? []), item]);
|
|
89
|
+
}
|
|
90
|
+
const rank = (name) => {
|
|
91
|
+
const i = order.indexOf(name);
|
|
92
|
+
return i < 0 ? order.length : i;
|
|
93
|
+
};
|
|
94
|
+
return [...groups.entries()].sort((a, b) => rank(a[0]) - rank(b[0]));
|
|
95
|
+
}
|
|
96
|
+
const minutes = (n) => (n ? `${text(n)} ${viewLang() === "de" ? "Min" : "min"}` : "");
|
|
97
|
+
function Metas({ items }) {
|
|
98
|
+
return items.length ? (_jsx("div", { className: "flex flex-wrap gap-1.5", children: items.map((m, i) => (_jsx("span", { className: "rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-2", children: m }, i))) })) : null;
|
|
99
|
+
}
|
|
100
|
+
/** `meta`: one value or a list of them, each a literal or a path. */
|
|
101
|
+
function metasOf(c, ctx, row) {
|
|
102
|
+
const raw = c.meta;
|
|
103
|
+
return (Array.isArray(raw) ? raw : [raw])
|
|
104
|
+
.map((m) => text(bound(m, ctx.data, row)))
|
|
105
|
+
.filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
function TabsView({ c, ctx, row }) {
|
|
108
|
+
const [on, setOn] = useState("0");
|
|
109
|
+
const tabs = rows(c.tabs);
|
|
110
|
+
const options = tabs.map((tab, i) => {
|
|
111
|
+
const count = bound(tab?.count, ctx.data, row);
|
|
112
|
+
const n = Array.isArray(count) ? count.length : count;
|
|
113
|
+
const label = text(bound(tab?.label, ctx.data, row));
|
|
114
|
+
return {
|
|
115
|
+
id: String(i),
|
|
116
|
+
label: n === undefined || n === null || n === "" ? label : `${label} (${text(n)})`,
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const child = tabs[Number(on)]?.child;
|
|
120
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx("div", { className: "sticky top-2 z-10 max-w-full self-start overflow-x-auto rounded-full", children: _jsx(Segments, { value: on, onChange: setOn, options: options }) }), typeof child === "string" ? _jsx(Node, { id: child, ctx: ctx, row: row }) : null] }));
|
|
121
|
+
}
|
|
122
|
+
function ChecklistView({ c, ctx, row }) {
|
|
123
|
+
const p = (key) => prop(c, key, ctx, row);
|
|
124
|
+
const [copied, setCopied] = useState(false);
|
|
125
|
+
const items = rows(p("items"));
|
|
126
|
+
const labelKey = text(p("labelKey"));
|
|
127
|
+
const detailKey = text(p("detailKey")) || "amount";
|
|
128
|
+
const noteKey = text(p("noteKey"));
|
|
129
|
+
const noteFormat = text(p("noteFormat"));
|
|
130
|
+
const groupKey = text(p("groupKey"));
|
|
131
|
+
const order = rows(p("groupOrder")).map(text);
|
|
132
|
+
const ticks = (ctx.state[c.id] ?? {});
|
|
133
|
+
const keyOf = (item, i) => `${i}:${labelOf(item, labelKey)}`;
|
|
134
|
+
const done = items.filter((item, i) => ticks[keyOf(item, i)]).length;
|
|
135
|
+
const indexed = items.map((item, i) => ({ item, i }));
|
|
136
|
+
const groups = groupKey
|
|
137
|
+
? grouped(items, groupKey, order).map(([name]) => [
|
|
138
|
+
name,
|
|
139
|
+
indexed.filter(({ item }) => text(cell(item, groupKey)) === name),
|
|
140
|
+
])
|
|
141
|
+
: [["", indexed]];
|
|
142
|
+
// `detail` is worked out per entry; `detailKey` names a column of it.
|
|
143
|
+
const detail = c.detail;
|
|
144
|
+
const detailOf = (item) => detail === undefined ? text(cell(item, detailKey)) : text(bound(detail, ctx.data, item));
|
|
145
|
+
const noteMap = p("noteMap");
|
|
146
|
+
const noteOf = (item) => {
|
|
147
|
+
const v = noteKey ? cell(item, noteKey) : undefined;
|
|
148
|
+
// A yes/no says something only in words of its own: "da", "einkaufen".
|
|
149
|
+
if (typeof v === "boolean") {
|
|
150
|
+
const words = noteMap && typeof noteMap === "object"
|
|
151
|
+
? noteMap[String(v)]
|
|
152
|
+
: "";
|
|
153
|
+
return text(words ?? "");
|
|
154
|
+
}
|
|
155
|
+
const words = Array.isArray(v) ? v.map(text).join(", ") : text(v);
|
|
156
|
+
return words && noteFormat ? noteFormat.replace("{}", words) : words;
|
|
157
|
+
};
|
|
158
|
+
const share = async () => {
|
|
159
|
+
const open = groups
|
|
160
|
+
.map(([name, list]) => {
|
|
161
|
+
const lines = list
|
|
162
|
+
.filter(({ item, i }) => !ticks[keyOf(item, i)])
|
|
163
|
+
.map(({ item }) => `☐ ${labelOf(item, labelKey)}${detailOf(item) ? ` – ${detailOf(item)}` : ""}`);
|
|
164
|
+
return lines.length ? [name, ...lines].filter(Boolean).join("\n") : "";
|
|
165
|
+
})
|
|
166
|
+
.filter(Boolean)
|
|
167
|
+
.join("\n\n");
|
|
168
|
+
try {
|
|
169
|
+
if (navigator.share) {
|
|
170
|
+
await navigator.share({ text: open });
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
await navigator.clipboard.writeText(open);
|
|
174
|
+
setCopied(true);
|
|
175
|
+
setTimeout(() => setCopied(false), 1600);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// Closed without sharing, or the clipboard refused: nothing to do.
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "h-1.5 flex-1 overflow-hidden rounded-full bg-paper-2", children: _jsx("div", { className: "h-full rounded-full bg-second transition-[width] duration-300", style: { width: `${items.length ? (done / items.length) * 100 : 0}%` } }) }), _jsx("span", { className: "text-[0.8125rem] text-ink-3 tabular-nums", children: done === items.length && items.length
|
|
183
|
+
? t("surface.allDone")
|
|
184
|
+
: t("surface.done", { done, total: items.length }) }), p("share") === false ? null : (_jsxs("button", { type: "button", onClick: share, className: "inline-flex h-8 items-center gap-1.5 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 hover:text-ink coarse:h-10", children: [copied ? _jsx(Check, { className: "size-3.5" }) : _jsx(Share2, { className: "size-3.5" }), copied ? t("share.copied") : t("run.share")] }))] }), groups.map(([name, list]) => (_jsxs("section", { className: "rounded-xl bg-card px-4 py-1 ring-1 ring-border-soft", children: [name ? (_jsx("h4", { className: "pt-3 pb-1 font-semibold text-[0.6875rem] text-second uppercase tracking-[0.14em]", children: name })) : null, list.map(({ item, i }) => {
|
|
185
|
+
const key = keyOf(item, i);
|
|
186
|
+
const on = Boolean(ticks[key]);
|
|
187
|
+
const note = noteOf(item);
|
|
188
|
+
return (_jsxs("label", { className: "flex cursor-pointer items-start gap-3 border-border-soft border-b border-dashed py-2.5 last:border-0", children: [_jsx("input", { type: "checkbox", checked: on, onChange: () => ctx.setState(c.id, { ...ticks, [key]: !on }), className: "mt-0.5 size-[1.125rem] shrink-0 accent-[var(--second)] coarse:size-6" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: cn("text-[0.9375rem]", on && "text-ink-3 line-through"), children: [labelOf(item, labelKey), detailOf(item) ? (_jsxs("span", { className: "text-ink-3", children: [" \u00B7 ", detailOf(item)] })) : null] }), note ? _jsx("span", { className: "block text-[0.75rem] text-ink-3", children: note }) : null] })] }, key));
|
|
189
|
+
})] }, name)))] }));
|
|
190
|
+
}
|
|
191
|
+
function Bars({ data }) {
|
|
192
|
+
const max = Math.max(1, ...data.map((d) => d.value));
|
|
193
|
+
return (_jsx("div", { className: "flex flex-col gap-1.5", children: data.map((d, i) => (_jsxs("div", { className: "grid grid-cols-[minmax(0,8rem)_1fr_auto] items-center gap-2", children: [_jsx("span", { className: "truncate text-[0.8125rem] text-ink-2", children: d.label }), _jsx("span", { className: "h-2.5 rounded-full bg-paper-2", children: _jsx("span", { className: "block h-full rounded-full bg-ember", style: { width: `${(d.value / max) * 100}%` } }) }), _jsx("span", { className: "text-[0.8125rem] tabular-nums", children: d.value.toLocaleString(viewLang()) })] }, i))) }));
|
|
194
|
+
}
|
|
195
|
+
function Line({ data }) {
|
|
196
|
+
if (data.length < 2) {
|
|
197
|
+
return _jsx(Bars, { data: data });
|
|
198
|
+
}
|
|
199
|
+
const w = 320;
|
|
200
|
+
const h = 120;
|
|
201
|
+
const max = Math.max(...data.map((d) => d.value));
|
|
202
|
+
const min = Math.min(...data.map((d) => d.value));
|
|
203
|
+
const span = max - min || 1;
|
|
204
|
+
const xy = data.map((d, i) => [
|
|
205
|
+
(i / (data.length - 1)) * (w - 8) + 4,
|
|
206
|
+
h - 4 - ((d.value - min) / span) * (h - 8),
|
|
207
|
+
]);
|
|
208
|
+
return (_jsxs("figure", { children: [_jsxs("svg", { viewBox: `0 0 ${w} ${h}`, className: "w-full text-ember", role: "img", children: [_jsx("polyline", { points: xy.map(([x, y]) => `${x},${y}`).join(" "), fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinejoin: "round" }), xy.map(([x, y], i) => (_jsx("circle", { cx: x, cy: y, r: "3", fill: "currentColor", children: _jsx("title", { children: `${data[i].label}: ${data[i].value}` }) }, i)))] }), _jsxs("figcaption", { className: "mt-1 flex justify-between text-[0.75rem] text-ink-3", children: [_jsx("span", { children: data[0].label }), _jsx("span", { children: data.at(-1)?.label })] })] }));
|
|
209
|
+
}
|
|
210
|
+
const DONUT = [
|
|
211
|
+
"var(--color-ember)",
|
|
212
|
+
"var(--color-cobalt)",
|
|
213
|
+
"var(--color-moss)",
|
|
214
|
+
"var(--color-amber)",
|
|
215
|
+
"var(--color-ink-3)",
|
|
216
|
+
];
|
|
217
|
+
function Donut({ data }) {
|
|
218
|
+
const total = data.reduce((a, d) => a + Math.max(0, d.value), 0) || 1;
|
|
219
|
+
let at = 0;
|
|
220
|
+
const r = 40;
|
|
221
|
+
const length = 2 * Math.PI * r;
|
|
222
|
+
return (_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("svg", { viewBox: "0 0 100 100", className: "size-28 shrink-0 -rotate-90", role: "img", children: data.map((d, i) => {
|
|
223
|
+
const part = (Math.max(0, d.value) / total) * length;
|
|
224
|
+
const el = (_jsx("circle", { cx: "50", cy: "50", r: r, fill: "none", stroke: DONUT[i % DONUT.length], strokeWidth: "16", strokeDasharray: `${part} ${length - part}`, strokeDashoffset: -at, children: _jsx("title", { children: `${d.label}: ${d.value}` }) }, i));
|
|
225
|
+
at += part;
|
|
226
|
+
return el;
|
|
227
|
+
}) }), _jsx("ul", { className: "flex flex-col gap-1 text-[0.8125rem]", children: data.map((d, i) => (_jsxs("li", { className: "flex items-center gap-2", children: [_jsx("span", { className: "size-2.5 rounded-full", style: { background: DONUT[i % DONUT.length] } }), _jsx("span", { className: "text-ink-2", children: d.label }), _jsx("span", { className: "tabular-nums", children: d.value.toLocaleString(viewLang()) })] }, i))) })] }));
|
|
228
|
+
}
|
|
229
|
+
/** What a file is, from its type or else its name: drawn as itself where the browser can. */
|
|
230
|
+
function fileType(mime, name) {
|
|
231
|
+
const m = mime.toLowerCase();
|
|
232
|
+
const ext = name.toLowerCase().split(".").at(-1) ?? "";
|
|
233
|
+
if (m === "application/pdf" || ext === "pdf") {
|
|
234
|
+
return "pdf";
|
|
235
|
+
}
|
|
236
|
+
if (m.startsWith("image/") || ["png", "jpg", "jpeg", "webp", "gif", "avif"].includes(ext)) {
|
|
237
|
+
return "image";
|
|
238
|
+
}
|
|
239
|
+
if (m.startsWith("video/") || ["mp4", "webm", "mov"].includes(ext)) {
|
|
240
|
+
return "video";
|
|
241
|
+
}
|
|
242
|
+
if (m.startsWith("audio/") || ["mp3", "m4a", "wav", "ogg", "webm"].includes(ext)) {
|
|
243
|
+
return "audio";
|
|
244
|
+
}
|
|
245
|
+
return "other";
|
|
246
|
+
}
|
|
247
|
+
/** A file: its name and a way to open it, and — for a PDF or a picture — the file itself. */
|
|
248
|
+
function FileView({ url, name, mime, preview, }) {
|
|
249
|
+
const type = fileType(mime, name);
|
|
250
|
+
return (_jsxs("div", { className: "overflow-hidden rounded-xl bg-card ring-1 ring-border-soft", children: [preview && type === "pdf" ? (_jsx("iframe", { src: `${url}#navpanes=0&view=FitH`, title: name, className: "block h-[28rem] w-full bg-paper-2" })) : preview && type === "image" ? (_jsx("img", { src: url, alt: name, className: "block max-h-[28rem] w-full object-contain" })) : null, _jsxs("a", { href: url, target: "_blank", rel: "noreferrer", className: "flex items-center gap-3 px-4 py-3 hover:bg-paper-2/70", children: [_jsx(FileText, { className: "size-5 shrink-0 text-ink-3" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-[0.9375rem]", children: name || t("surface.file") }), _jsx("span", { className: "shrink-0 text-[0.8125rem] text-ink-3", children: t("surface.openFile") })] })] }));
|
|
251
|
+
}
|
|
252
|
+
/** A Ref's mark, by what its `open` names: a page, a table, a file, a chat, a wizard. */
|
|
253
|
+
const REF_ICON = {
|
|
254
|
+
p: FileText,
|
|
255
|
+
t: Table2,
|
|
256
|
+
f: FileText,
|
|
257
|
+
chat: MessageSquare,
|
|
258
|
+
wizard: Wand2,
|
|
259
|
+
};
|
|
260
|
+
function RefView({ c, ctx, row }) {
|
|
261
|
+
const p = (key) => prop(c, key, ctx, row);
|
|
262
|
+
const open = text(p("open"));
|
|
263
|
+
const href = ctx.chat?.href(open) ?? null;
|
|
264
|
+
const Icon = REF_ICON[open.split(":")[0]] ?? FileText;
|
|
265
|
+
const body = (_jsxs(_Fragment, { children: [_jsx(Icon, { className: "size-4 shrink-0 text-ink-3" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-[0.9375rem]", children: text(p("title")) }), p("subtitle") ? (_jsx("span", { className: "block truncate text-[0.8125rem] text-ink-3", children: text(p("subtitle")) })) : null] }), p("meta") ? (_jsx("span", { className: "shrink-0 text-[0.8125rem] text-ink-3 tabular-nums", children: text(p("meta")) })) : null, href ? _jsx(ChevronRight, { className: "size-4 shrink-0 text-ink-3" }) : null] }));
|
|
266
|
+
const look = "flex items-center gap-3 rounded-xl bg-card px-4 py-3 ring-1 ring-border-soft";
|
|
267
|
+
if (!href) {
|
|
268
|
+
return _jsx("div", { className: look, children: body });
|
|
269
|
+
}
|
|
270
|
+
const follow = ctx.chat?.follow;
|
|
271
|
+
return (_jsx("a", { href: href, onClick: (e) => {
|
|
272
|
+
if (follow && !e.metaKey && !e.ctrlKey && !e.shiftKey) {
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
follow(href);
|
|
275
|
+
}
|
|
276
|
+
}, className: cn(look, "hover:ring-ink-4"), children: body }));
|
|
277
|
+
}
|
|
278
|
+
/** Where something was found: a page of the space (a Ref's `open`) or an address on the web. */
|
|
279
|
+
function SourcesView({ c, ctx, row }) {
|
|
280
|
+
const p = (key) => prop(c, key, ctx, row);
|
|
281
|
+
const titleKey = text(p("titleKey")) || "title";
|
|
282
|
+
const urlKey = text(p("urlKey")) || "url";
|
|
283
|
+
const items = rows(p("items"));
|
|
284
|
+
if (!items.length) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5 text-[0.8125rem]", children: [_jsx("span", { className: "text-ink-3", children: t("surface.foundIn") }), items.map((item, i) => {
|
|
288
|
+
const title = text(cell(item, titleKey)) || labelOf(item, "");
|
|
289
|
+
const url = text(cell(item, urlKey));
|
|
290
|
+
const open = text(cell(item, "open"));
|
|
291
|
+
const href = /^https?:\/\//.test(url) ? url : open ? (ctx.chat?.href(open) ?? null) : null;
|
|
292
|
+
const look = "inline-flex max-w-full items-center gap-1 rounded-full bg-paper-2 px-2.5 py-0.5 text-ink-2";
|
|
293
|
+
return href ? (_jsxs("a", { href: href, target: url ? "_blank" : undefined, rel: "noreferrer", onClick: (e) => {
|
|
294
|
+
const follow = ctx.chat?.follow;
|
|
295
|
+
if (!url && follow) {
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
follow(href);
|
|
298
|
+
}
|
|
299
|
+
}, className: cn(look, "hover:text-ink"), children: [_jsx("span", { className: "truncate", children: title }), url ? _jsx(ExternalLink, { className: "size-3 shrink-0" }) : null] }, i)) : (_jsx("span", { className: look, children: _jsx("span", { className: "truncate", children: title }) }, i));
|
|
300
|
+
})] }));
|
|
301
|
+
}
|
|
302
|
+
function Titled({ title, children }) {
|
|
303
|
+
return (_jsxs("div", { className: "rounded-xl bg-card p-4 ring-1 ring-border-soft", children: [title ? _jsx("div", { className: "mb-3 font-medium text-[0.875rem]", children: title }) : null, children] }));
|
|
304
|
+
}
|
|
305
|
+
/** A choice the person makes in a view; a value may be a number, and stays one. */
|
|
306
|
+
function ChoiceInput({ c, ctx }) {
|
|
307
|
+
const props = c;
|
|
308
|
+
const state = text(props.state);
|
|
309
|
+
const options = (Array.isArray(props.options) ? props.options : []).map((o) => {
|
|
310
|
+
const given = o;
|
|
311
|
+
return o && typeof o === "object"
|
|
312
|
+
? { label: text(given.label), value: given.value }
|
|
313
|
+
: { label: text(o), value: o };
|
|
314
|
+
});
|
|
315
|
+
const value = ctx.data[state];
|
|
316
|
+
const labels = new Map(options.map((o) => [String(o.value), o.label]));
|
|
317
|
+
const set = (picked) => ctx.setState(state, options.find((o) => String(o.value) === String(picked))?.value);
|
|
318
|
+
const label = (v) => labels.get(v) ?? v;
|
|
319
|
+
const values = options.map((o) => String(o.value));
|
|
320
|
+
const now = value === undefined || value === null ? "" : String(value);
|
|
321
|
+
return props.look === "list" ? (_jsx(ListChoice, { name: c.id, value: now, options: values, disabled: new Set(), label: label, onChange: set })) : (_jsx(Segmented, { value: now, options: values, label: label, onChange: set }));
|
|
322
|
+
}
|
|
323
|
+
function Node({ id, ctx, row }) {
|
|
324
|
+
const slot = ctx.slots?.get(id);
|
|
325
|
+
if (slot !== undefined) {
|
|
326
|
+
return _jsx(_Fragment, { children: slot });
|
|
327
|
+
}
|
|
328
|
+
const c = ctx.byId.get(id);
|
|
329
|
+
if (!c) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
const p = (key) => prop(c, key, ctx, row);
|
|
333
|
+
switch (c.component) {
|
|
334
|
+
case "Column":
|
|
335
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(Children, { c: c, ctx: ctx, row: row }) }));
|
|
336
|
+
case "Text": {
|
|
337
|
+
const variant = text(p("variant")) || "body";
|
|
338
|
+
return (_jsx("p", { className: cn(variant === "h3" && "font-display font-semibold text-[1.25rem] leading-tight", variant === "h4" && "font-semibold text-[1rem]", variant === "lead" && "font-display text-[1.0625rem] text-ink-2 leading-relaxed", variant === "body" && "text-[0.9375rem] leading-relaxed", variant === "muted" && "text-[0.8125rem] text-ink-3"), children: text(p("text")) }));
|
|
339
|
+
}
|
|
340
|
+
case "List":
|
|
341
|
+
return (_jsx("div", { className: "flex flex-col divide-y divide-border-soft overflow-hidden rounded-xl bg-card ring-1 ring-border-soft", children: _jsx(Children, { c: c, ctx: ctx, row: row }) }));
|
|
342
|
+
case "Row": {
|
|
343
|
+
const image = src(p("image"), ctx);
|
|
344
|
+
const badge = text(p("badge"));
|
|
345
|
+
return (_jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [image ? (_jsx("img", { src: image, alt: "", className: "size-10 shrink-0 rounded-lg object-cover" })) : null, _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "truncate text-[0.9375rem]", children: text(p("title")) }), p("subtitle") ? (_jsx("div", { className: "truncate text-[0.8125rem] text-ink-3", children: text(p("subtitle")) })) : null] }), p("meta") ? (_jsx("span", { className: "shrink-0 text-[0.8125rem] text-ink-3 tabular-nums", children: text(p("meta")) })) : null, badge ? (_jsx("span", { className: cn("shrink-0 rounded-full px-2 py-0.5 text-[0.75rem]", TONES[text(p("badgeTone"))] ?? TONES.default), children: badge })) : null] }));
|
|
346
|
+
}
|
|
347
|
+
case "DetailGrid": {
|
|
348
|
+
const rows = p("rows");
|
|
349
|
+
return (_jsx("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 rounded-xl bg-card p-4 text-[0.875rem] ring-1 ring-border-soft", children: (Array.isArray(rows) ? rows : []).map((r, i) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-ink-3", children: text(bound(r?.label, ctx.data, row)) }), _jsx("dd", { className: "break-words", children: text(bound(r?.value, ctx.data, row)) })] }, i))) }));
|
|
350
|
+
}
|
|
351
|
+
case "Badge":
|
|
352
|
+
return (_jsx("span", { className: cn("inline-flex w-fit rounded-full px-2.5 py-0.5 text-[0.75rem]", TONES[text(p("tone"))] ?? TONES.default), children: text(p("label")) }));
|
|
353
|
+
case "Grid": {
|
|
354
|
+
const columns = Math.min(4, Math.max(1, num(p("columns")) || 2));
|
|
355
|
+
// The narrowest a tile gets: small tiles (figures) sit two to a phone, cards one.
|
|
356
|
+
const min = Math.min(24, Math.max(6, num(p("min")) || (columns > 2 ? 9 : 12)));
|
|
357
|
+
return (_jsx("div", { className: "grid gap-3", style: {
|
|
358
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, ${min}rem), 1fr))`,
|
|
359
|
+
}, children: _jsx(Children, { c: c, ctx: ctx, row: row }) }));
|
|
360
|
+
}
|
|
361
|
+
case "Metric":
|
|
362
|
+
return (_jsxs("div", { className: "rounded-xl bg-card p-4 ring-1 ring-border-soft", children: [_jsx("div", { className: "text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]", children: text(p("label")) }), _jsx("div", { className: "mt-1 font-display font-semibold text-[1.5rem] tabular-nums", children: text(p("value")) }), p("caption") ? (_jsx("div", { className: "text-[0.8125rem] text-ink-3", children: text(p("caption")) })) : null] }));
|
|
363
|
+
case "Table": {
|
|
364
|
+
const rows = p("rows");
|
|
365
|
+
const list = (Array.isArray(rows) ? rows : []);
|
|
366
|
+
const declared = p("columns");
|
|
367
|
+
const cols = Array.isArray(declared)
|
|
368
|
+
? declared.map((d) => ({ key: text(d?.key), label: text(d?.label ?? d?.key) }))
|
|
369
|
+
: [...new Set(list.flatMap((r) => Object.keys(r ?? {})))].map((k) => ({
|
|
370
|
+
key: k,
|
|
371
|
+
label: k,
|
|
372
|
+
}));
|
|
373
|
+
return (_jsx("div", { className: "overflow-x-auto rounded-xl ring-1 ring-border-soft", children: _jsxs("table", { className: "w-full text-[0.8125rem]", children: [_jsx("thead", { className: "bg-paper-2 text-ink-2", children: _jsx("tr", { children: cols.map((col) => (_jsx("th", { className: "px-3 py-2 text-left font-medium", children: col.label }, col.key))) }) }), _jsx("tbody", { children: list.map((r, i) => (_jsx("tr", { className: "border-border-soft border-t", children: cols.map((col) => (_jsx("td", { className: "px-3 py-2 tabular-nums", children: text(r?.[col.key]) }, col.key))) }, i))) })] }) }));
|
|
374
|
+
}
|
|
375
|
+
case "Image": {
|
|
376
|
+
const url = src(p("src"), ctx);
|
|
377
|
+
return url ? _jsx("img", { src: url, alt: text(p("alt")), className: "w-full rounded-xl" }) : null;
|
|
378
|
+
}
|
|
379
|
+
case "BarChart":
|
|
380
|
+
return (_jsx(Titled, { title: text(p("title")), children: _jsx(Bars, { data: points(p("points"), p("labelKey"), p("valueKey")) }) }));
|
|
381
|
+
case "LineChart":
|
|
382
|
+
return (_jsx(Titled, { title: text(p("title")), children: _jsx(Line, { data: points(p("points"), p("labelKey"), p("valueKey")) }) }));
|
|
383
|
+
case "DonutChart":
|
|
384
|
+
return (_jsx(Titled, { title: text(p("title")), children: _jsx(Donut, { data: points(p("slices"), p("labelKey"), p("valueKey")) }) }));
|
|
385
|
+
case "Actions":
|
|
386
|
+
return (_jsx("div", { className: "flex flex-wrap gap-2", children: _jsx(Children, { c: c, ctx: ctx, row: row }) }));
|
|
387
|
+
case "Button": {
|
|
388
|
+
const action = text(p("action"));
|
|
389
|
+
if (!ctx.onAction && action !== "open") {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
return (_jsx("button", { type: "button", onClick: () => {
|
|
393
|
+
const target = p("target");
|
|
394
|
+
if (action === "open") {
|
|
395
|
+
const url = src(target, ctx);
|
|
396
|
+
if (url) {
|
|
397
|
+
window.open(url, "_blank", "noopener");
|
|
398
|
+
}
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
// Asking, the person says the button's prompt, or else its label.
|
|
402
|
+
ctx.onAction?.({
|
|
403
|
+
action,
|
|
404
|
+
target: action === "ask" ? text(p("prompt")) || text(p("label")) : target,
|
|
405
|
+
});
|
|
406
|
+
}, className: "inline-flex h-9 items-center rounded-full bg-paper-2 px-4 text-[0.875rem] text-ink-2 hover:text-ink coarse:h-11", children: text(p("label")) }));
|
|
407
|
+
}
|
|
408
|
+
case "Tabs":
|
|
409
|
+
return _jsx(TabsView, { c: c, ctx: ctx, row: row });
|
|
410
|
+
case "Card": {
|
|
411
|
+
const image = src(p("image"), ctx);
|
|
412
|
+
const eyebrow = text(p("eyebrow"));
|
|
413
|
+
const subtitle = text(p("subtitle"));
|
|
414
|
+
return (_jsxs("article", { className: "overflow-hidden rounded-xl bg-card ring-1 ring-border-soft", children: [image ? _jsx("img", { src: image, alt: "", className: "aspect-[16/9] w-full object-cover" }) : null, _jsxs("div", { className: cn("flex flex-col gap-1.5 px-4 py-3.5", c.children && "bg-paper-2/60"), children: [eyebrow ? (_jsx("div", { className: "font-medium text-[0.6875rem] text-ink-3 uppercase tracking-[0.14em]", children: eyebrow })) : null, _jsx("h3", { className: "text-balance font-display font-semibold text-[1.1875rem] leading-snug", children: text(p("title")) }), subtitle ? (_jsx("p", { className: "text-[0.875rem] text-ink-3 leading-relaxed", children: subtitle })) : null, _jsx(Metas, { items: metasOf(c, ctx, row) })] }), c.children ? (_jsx("div", { className: "flex flex-col gap-3 border-border-soft border-t px-4 py-3.5 empty:hidden", children: _jsx(Children, { c: c, ctx: ctx, row: row }) })) : null] }));
|
|
415
|
+
}
|
|
416
|
+
case "Fold":
|
|
417
|
+
return (_jsxs("details", { open: Boolean(p("open")), className: "group border-border-soft border-t pt-3 first:border-0 first:pt-0", children: [_jsxs("summary", { className: "flex cursor-pointer list-none items-center justify-between gap-3 font-display font-semibold text-[1rem] [&::-webkit-details-marker]:hidden", children: [text(p("title")), _jsx(ChevronRight, { className: "size-4 text-ink-3 transition-transform group-open:rotate-90 motion-reduce:transition-none" })] }), _jsx("div", { className: "flex flex-col gap-3 pt-3", children: _jsx(Children, { c: c, ctx: ctx, row: row }) })] }));
|
|
418
|
+
case "Group": {
|
|
419
|
+
const kids = c.children;
|
|
420
|
+
if (!kids || Array.isArray(kids)) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const items = rows(bound({ path: kids.path }, ctx.data, row));
|
|
424
|
+
return (_jsx("div", { className: "flex flex-col gap-5", children: grouped(items, text(p("by")), rows(p("order")).map(text)).map(([name, list]) => (_jsxs("section", { className: "flex flex-col gap-2", children: [name ? (_jsx("h4", { className: "font-semibold text-[0.6875rem] text-second uppercase tracking-[0.14em]", children: name })) : null, list.map((item, i) => (_jsx(Node, { id: kids.componentId, ctx: ctx, row: item }, i)))] }, name))) }));
|
|
425
|
+
}
|
|
426
|
+
case "Chips": {
|
|
427
|
+
const labelKey = text(p("labelKey"));
|
|
428
|
+
const flagKey = text(p("flagKey"));
|
|
429
|
+
const flag = text(p("flag"));
|
|
430
|
+
const title = text(p("title"));
|
|
431
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [title ? _jsx("div", { className: "text-[0.8125rem] text-ink-3", children: title }) : null, _jsx("div", { className: "flex flex-wrap gap-1.5", children: rows(p("items")).map((item, i) => {
|
|
432
|
+
const flagged = Boolean(flagKey && cell(item, flagKey));
|
|
433
|
+
return (_jsxs("span", { className: cn("rounded-full px-2.5 py-1 text-[0.8125rem]", flagged
|
|
434
|
+
? "bg-amber-tint font-medium text-ink ring-1 ring-amber/60"
|
|
435
|
+
: "bg-card text-ink-2 ring-1 ring-border-soft"), children: [labelOf(item, labelKey), flagged && flag ? ` · ${flag}` : ""] }, i));
|
|
436
|
+
}) })] }));
|
|
437
|
+
}
|
|
438
|
+
case "Checklist":
|
|
439
|
+
return _jsx(ChecklistView, { c: c, ctx: ctx, row: row });
|
|
440
|
+
case "Steps": {
|
|
441
|
+
const textKey = text(p("textKey")) || "text";
|
|
442
|
+
const minutesKey = text(p("minutesKey")) || "minutes";
|
|
443
|
+
return (_jsx("ol", { className: "flex flex-col gap-3", children: rows(p("items")).map((item, i) => {
|
|
444
|
+
const words = typeof item === "object" ? text(cell(item, textKey)) : text(item);
|
|
445
|
+
const time = minutes(cell(item, minutesKey));
|
|
446
|
+
return (_jsxs("li", { className: "grid grid-cols-[1.5rem_1fr] gap-2", children: [_jsx("span", { className: "font-display font-semibold text-[1.125rem] text-ember leading-snug", children: i + 1 }), _jsxs("span", { className: "text-[0.9375rem] leading-relaxed", children: [words, time ? (_jsxs("span", { className: "ml-1.5 inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-paper-2 px-2 py-0.5 align-[1px] text-[0.75rem] text-ink-2", children: [_jsx(Clock, { className: "size-3" }), time] })) : null] })] }, i));
|
|
447
|
+
}) }));
|
|
448
|
+
}
|
|
449
|
+
case "Link": {
|
|
450
|
+
// The entry it opens: title, subtitle and meta read it; the eyebrow reads the row it sits in.
|
|
451
|
+
const key = text(p("key")) || "id";
|
|
452
|
+
const value = text(p("value"));
|
|
453
|
+
const entry = rows(p("items")).find((item) => text(cell(item, key)) === value);
|
|
454
|
+
const view = c.view;
|
|
455
|
+
if (entry === undefined) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const at = (k) => bound(c[k], ctx.data, entry);
|
|
459
|
+
const eyebrow = text(p("eyebrow"));
|
|
460
|
+
const meta = metasOf(c, ctx, entry);
|
|
461
|
+
return (_jsxs("button", { type: "button", onClick: () => typeof view === "string" && ctx.open(view, entry), className: cn("group flex w-full items-center gap-3 text-left", text(p("look")) === "card"
|
|
462
|
+
? "rounded-xl bg-card p-4 ring-1 ring-border-soft hover:ring-ink-4"
|
|
463
|
+
: "-mx-2 w-[calc(100%+1rem)] rounded-lg px-2 py-2 hover:bg-paper-2/70 coarse:py-3"), children: [_jsxs("span", { className: "min-w-0 flex-1", children: [eyebrow ? (_jsx("span", { className: "block font-semibold text-[0.6875rem] text-second uppercase tracking-[0.14em]", children: eyebrow })) : null, _jsx("span", { className: "block font-display font-semibold text-[1rem] leading-snug group-hover:text-ember", children: text(at("title")) }), at("subtitle") ? (_jsx("span", { className: "block text-[0.8125rem] text-ink-3", children: text(at("subtitle")) })) : null, meta.length ? (_jsxs("span", { className: "mt-0.5 flex items-center gap-1 text-[0.75rem] text-ink-3", children: [_jsx(Clock, { className: "size-3" }), meta.join(" · ")] })) : null] }), _jsx(ChevronRight, { className: "size-4 shrink-0 text-ink-3" })] }));
|
|
464
|
+
}
|
|
465
|
+
case "Callout": {
|
|
466
|
+
const tone = text(p("tone")) || "tip";
|
|
467
|
+
const title = text(p("title"));
|
|
468
|
+
return (_jsxs("div", { className: cn("flex gap-2.5 rounded-xl px-4 py-3 text-[0.875rem] leading-relaxed", tone === "tip" && "bg-second-tint", tone === "note" && "bg-paper-2", tone === "warning" && "bg-amber-tint"), children: [_jsx(Lightbulb, { className: cn("mt-0.5 size-4 shrink-0", tone === "tip" ? "text-second" : "text-ink-3") }), _jsxs("p", { children: [title ? _jsxs("b", { className: "font-semibold", children: [title, " "] }) : null, text(p("text"))] })] }));
|
|
469
|
+
}
|
|
470
|
+
case "Markdown":
|
|
471
|
+
return _jsx(Markdown, { text: text(p("text")), className: "text-[0.9375rem]" });
|
|
472
|
+
case "Sources":
|
|
473
|
+
return _jsx(SourcesView, { c: c, ctx: ctx, row: row });
|
|
474
|
+
case "File": {
|
|
475
|
+
const url = src(p("file"), ctx);
|
|
476
|
+
return url ? (_jsx(FileView, { url: url, name: text(p("name")), mime: text(p("mime")), preview: p("preview") !== false })) : null;
|
|
477
|
+
}
|
|
478
|
+
case "Video": {
|
|
479
|
+
const url = src(p("src"), ctx);
|
|
480
|
+
const poster = src(p("poster"), ctx);
|
|
481
|
+
return url ? (_jsx("video", { src: url, poster: poster ?? undefined, controls: true, playsInline: true, preload: "metadata", className: "w-full rounded-xl bg-paper-2" })) : null;
|
|
482
|
+
}
|
|
483
|
+
case "Audio": {
|
|
484
|
+
const url = src(p("src"), ctx);
|
|
485
|
+
const title = text(p("title"));
|
|
486
|
+
return url ? (_jsxs("div", { className: "flex flex-col gap-2 rounded-xl bg-card p-3 ring-1 ring-border-soft", children: [title ? _jsx("div", { className: "text-[0.875rem]", children: title }) : null, _jsx("audio", { src: url, controls: true, preload: "metadata", className: "w-full" })] })) : null;
|
|
487
|
+
}
|
|
488
|
+
case "Gallery": {
|
|
489
|
+
const srcKey = text(p("srcKey"));
|
|
490
|
+
const captionKey = text(p("captionKey"));
|
|
491
|
+
const items = rows(p("items"))
|
|
492
|
+
.map((item) => ({
|
|
493
|
+
url: src(srcKey ? cell(item, srcKey) : item, ctx),
|
|
494
|
+
caption: captionKey ? text(cell(item, captionKey)) : "",
|
|
495
|
+
}))
|
|
496
|
+
.filter((item) => Boolean(item.url));
|
|
497
|
+
return (_jsx("div", { className: "grid gap-2", style: { gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 9rem), 1fr))" }, children: items.map((item, i) => (_jsxs("a", { href: item.url, target: "_blank", rel: "noreferrer", className: "group", children: [_jsx("img", { src: item.url, alt: item.caption, className: "aspect-square w-full rounded-lg object-cover ring-1 ring-border-soft group-hover:ring-ink-4" }), item.caption ? (_jsx("span", { className: "mt-1 block truncate text-[0.75rem] text-ink-3", children: item.caption })) : null] }, i))) }));
|
|
498
|
+
}
|
|
499
|
+
case "Ref":
|
|
500
|
+
return _jsx(RefView, { c: c, ctx: ctx, row: row });
|
|
501
|
+
case "Form":
|
|
502
|
+
return _jsx(_Fragment, { children: ctx.chat?.form?.(c, ctx.byId, ctx.data) });
|
|
503
|
+
case "Field":
|
|
504
|
+
return _jsx(_Fragment, { children: ctx.field?.(text(c.name)) });
|
|
505
|
+
case "Choice":
|
|
506
|
+
return _jsx(ChoiceInput, { c: c, ctx: ctx });
|
|
507
|
+
case "Toggle": {
|
|
508
|
+
const state = text(c.state);
|
|
509
|
+
const on = calcTruthy(ctx.data[state]);
|
|
510
|
+
return (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-[0.9375rem]", children: text(p("label")) }), _jsx(Switch, { checked: on, onChange: (next) => ctx.setState(state, next) })] }));
|
|
511
|
+
}
|
|
512
|
+
case "Slider": {
|
|
513
|
+
const props = c;
|
|
514
|
+
const state = text(props.state);
|
|
515
|
+
return (_jsx(NumberSlider, { label: text(p("label")) || state, value: ctx.data[state], min: Number(props.min), max: Number(props.max), increment: typeof props.increment === "number" ? props.increment : undefined, unit: typeof props.unit === "string" ? props.unit : undefined, onChange: (v) => ctx.setState(state, v) }));
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
/** The data a view reads: what the run gave it, and what its inputs hold, or start with. */
|
|
521
|
+
function withViewState(surface, state) {
|
|
522
|
+
const inputs = {};
|
|
523
|
+
for (const c of surface.components) {
|
|
524
|
+
const { state: name, default: start } = c;
|
|
525
|
+
if (typeof name === "string" &&
|
|
526
|
+
(c.component === "Choice" || c.component === "Toggle" || c.component === "Slider")) {
|
|
527
|
+
inputs[name] = state[name] ?? start;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return { ...surface.data, ...inputs };
|
|
531
|
+
}
|
|
532
|
+
export function SurfaceView({ surface, assetUrl, onAction, initial, onState, chat, field, slots, }) {
|
|
533
|
+
const [state, setState] = useState(initial ?? {});
|
|
534
|
+
const [sheet, setSheet] = useState(null);
|
|
535
|
+
const ctx = {
|
|
536
|
+
byId: new Map(surface.components.map((c) => [c.id, c])),
|
|
537
|
+
data: withViewState(surface, state),
|
|
538
|
+
assetUrl,
|
|
539
|
+
onAction,
|
|
540
|
+
state,
|
|
541
|
+
setState: (id, value) => {
|
|
542
|
+
const next = { ...state, [id]: value };
|
|
543
|
+
setState(next);
|
|
544
|
+
onState?.(next);
|
|
545
|
+
},
|
|
546
|
+
open: (view, row) => setSheet({ view, row }),
|
|
547
|
+
chat,
|
|
548
|
+
field,
|
|
549
|
+
slots,
|
|
550
|
+
};
|
|
551
|
+
return (_jsxs(_Fragment, { children: [_jsx(Node, { id: "root", ctx: ctx }), _jsx(Dialog, { open: sheet !== null, onClose: () => setSheet(null), height: "tall", children: sheet ? (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Node, { id: sheet.view, ctx: ctx, row: sheet.row }), _jsx("button", { type: "button", onClick: () => setSheet(null), className: "h-10 self-center rounded-full bg-paper-2 px-5 text-[0.875rem] text-ink-2 hover:text-ink", children: t("surface.close") })] })) : null })] }));
|
|
552
|
+
}
|