@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,375 @@
|
|
|
1
|
+
// The tunnel of a home at <name>.wizards.host: frpc to our relay, and its certificate.
|
|
2
|
+
//
|
|
3
|
+
// `wizards bot tunnel` (bin/bot.mjs) uses what this file exports, and copies the file into the
|
|
4
|
+
// home as `tunnel/run.mjs`; run there by the home's tunnel service, it keeps frpc running and
|
|
5
|
+
// renews the certificate before it ends. Like bot.mjs it needs nothing but Node.
|
|
6
|
+
//
|
|
7
|
+
// tunnel/claim.pem the tunnel's own Ed25519 key (0600): its name is made from it, and it
|
|
8
|
+
// claims the name again after --off; losing it loses the name
|
|
9
|
+
// tunnel/tunnel.json the API, the name, the key for it, frpc and the home's port (0600)
|
|
10
|
+
// tunnel/frpc.toml frpc's settings (0600: it holds the key)
|
|
11
|
+
// tunnel/key.pem this computer's private key for the name (0600); it never leaves it
|
|
12
|
+
// tunnel/cert.pem the certificate for the name, from Let's Encrypt through wizards.host
|
|
13
|
+
//
|
|
14
|
+
// The relay ends no TLS: frpc's https2http plugin ends it here, with key.pem and cert.pem, and
|
|
15
|
+
// hands plain HTTP to the home on 127.0.0.1.
|
|
16
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
17
|
+
import {
|
|
18
|
+
createHash,
|
|
19
|
+
createPrivateKey,
|
|
20
|
+
createPublicKey,
|
|
21
|
+
generateKeyPairSync,
|
|
22
|
+
sign,
|
|
23
|
+
X509Certificate,
|
|
24
|
+
} from "node:crypto";
|
|
25
|
+
import { chmodSync, existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
26
|
+
import { join } from "node:path";
|
|
27
|
+
import { pathToFileURL } from "node:url";
|
|
28
|
+
|
|
29
|
+
/** Where tunnels get their names and certificates: WIZARDS_TUNNEL_URL changes it. */
|
|
30
|
+
export const TUNNEL_URL = "https://wizards.host";
|
|
31
|
+
/** Renew this long before a certificate ends. */
|
|
32
|
+
export const RENEW_BEFORE = 30 * 24 * 3600_000;
|
|
33
|
+
/** How often the running tunnel looks at its certificate. */
|
|
34
|
+
const CHECK_EVERY = 12 * 3600_000;
|
|
35
|
+
|
|
36
|
+
// --- the tunnel's own key, and the name it gets ---------------------------------------------
|
|
37
|
+
|
|
38
|
+
const BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
39
|
+
|
|
40
|
+
/** RFC 4648 base32, lower case, without padding. */
|
|
41
|
+
function base32(bytes) {
|
|
42
|
+
let bits = 0;
|
|
43
|
+
let value = 0;
|
|
44
|
+
let out = "";
|
|
45
|
+
for (const byte of bytes) {
|
|
46
|
+
value = (value << 8) | byte;
|
|
47
|
+
bits += 8;
|
|
48
|
+
while (bits >= 5) {
|
|
49
|
+
out += BASE32[(value >>> (bits - 5)) & 31];
|
|
50
|
+
bits -= 5;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (bits > 0) {
|
|
54
|
+
out += BASE32[(value << (5 - bits)) & 31];
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The name a key claims: the first 10 characters of base32(sha256(raw public key)). */
|
|
60
|
+
export function claimName(publicKeyRaw) {
|
|
61
|
+
return base32(createHash("sha256").update(publicKeyRaw).digest()).slice(0, 10);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The tunnel's Ed25519 key in `claim.pem`, made the first time; it stays for you alone. */
|
|
65
|
+
export function claimKey(file) {
|
|
66
|
+
if (!existsSync(file)) {
|
|
67
|
+
const { privateKey } = generateKeyPairSync("ed25519");
|
|
68
|
+
writeFileAtomic(file, privateKey.export({ type: "pkcs8", format: "pem" }), true);
|
|
69
|
+
}
|
|
70
|
+
return createPrivateKey(readFileSync(file, "utf8"));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A key's raw 32-byte public half, base64url. */
|
|
74
|
+
export function publicKeyOf(privateKey) {
|
|
75
|
+
return createPublicKey(privateKey).export({ format: "jwk" }).x;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What a claim signs. */
|
|
79
|
+
export const claimText = (publicKey, timestamp) => `wizards.host claim ${publicKey} ${timestamp}`;
|
|
80
|
+
|
|
81
|
+
/** The body of `POST /v1/tunnels/claim`: the public key, now, and the signature over both. */
|
|
82
|
+
export function claimBody(privateKey, now = Date.now()) {
|
|
83
|
+
const publicKey = publicKeyOf(privateKey);
|
|
84
|
+
const signature = sign(null, Buffer.from(claimText(publicKey, now)), privateKey).toString(
|
|
85
|
+
"base64url",
|
|
86
|
+
);
|
|
87
|
+
return { publicKey, timestamp: now, signature };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Claims the name of the key in `file`: no account, no browser. Every claim gives a fresh key
|
|
92
|
+
* for the relay; the name stays the key's.
|
|
93
|
+
*/
|
|
94
|
+
export async function claim(api, file, computer) {
|
|
95
|
+
const { data } = await call(api, "/v1/tunnels/claim", {
|
|
96
|
+
method: "POST",
|
|
97
|
+
body: { ...claimBody(claimKey(file)), ...(computer ? { computer } : {}) },
|
|
98
|
+
});
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// --- a key and a certificate request ---------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
/** A new EC P-256 private key, as PEM. */
|
|
105
|
+
export function makeKey() {
|
|
106
|
+
const { privateKey } = generateKeyPairSync("ec", { namedCurve: "P-256" });
|
|
107
|
+
return privateKey.export({ type: "pkcs8", format: "pem" });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function length(n) {
|
|
111
|
+
if (n < 0x80) {
|
|
112
|
+
return Buffer.from([n]);
|
|
113
|
+
}
|
|
114
|
+
const bytes = [];
|
|
115
|
+
for (let rest = n; rest > 0; rest >>= 8) {
|
|
116
|
+
bytes.unshift(rest & 0xff);
|
|
117
|
+
}
|
|
118
|
+
return Buffer.from([0x80 | bytes.length, ...bytes]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const tlv = (tag, ...parts) => {
|
|
122
|
+
const body = Buffer.concat(parts);
|
|
123
|
+
return Buffer.concat([Buffer.from([tag]), length(body.length), body]);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function oid(text) {
|
|
127
|
+
const [a, b, ...rest] = text.split(".").map(Number);
|
|
128
|
+
const bytes = [a * 40 + b];
|
|
129
|
+
for (const n of rest) {
|
|
130
|
+
const chunk = [n & 0x7f];
|
|
131
|
+
for (let v = n >> 7; v > 0; v >>= 7) {
|
|
132
|
+
chunk.unshift((v & 0x7f) | 0x80);
|
|
133
|
+
}
|
|
134
|
+
bytes.push(...chunk);
|
|
135
|
+
}
|
|
136
|
+
return tlv(0x06, Buffer.from(bytes));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const sequence = (...parts) => tlv(0x30, ...parts);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* A PKCS#10 certificate request for one name, signed with the key: the name as the subject's
|
|
143
|
+
* common name and as the only DNS name. Built by hand, since Node has no API for it.
|
|
144
|
+
*/
|
|
145
|
+
export function csrFor(name, keyPem) {
|
|
146
|
+
const key = createPrivateKey(keyPem);
|
|
147
|
+
const spki = createPublicKey(key).export({ type: "spki", format: "der" });
|
|
148
|
+
const subject = sequence(tlv(0x31, sequence(oid("2.5.4.3"), tlv(0x0c, Buffer.from(name)))));
|
|
149
|
+
const san = sequence(tlv(0x82, Buffer.from(name, "ascii")));
|
|
150
|
+
const extensions = sequence(sequence(oid("2.5.29.17"), tlv(0x04, san)));
|
|
151
|
+
const attributes = tlv(0xa0, sequence(oid("1.2.840.113549.1.9.14"), tlv(0x31, extensions)));
|
|
152
|
+
const info = sequence(tlv(0x02, Buffer.from([0])), subject, spki, attributes);
|
|
153
|
+
const signature = sign("sha256", info, { key, dsaEncoding: "der" });
|
|
154
|
+
const der = sequence(
|
|
155
|
+
info,
|
|
156
|
+
sequence(oid("1.2.840.10045.4.3.2")),
|
|
157
|
+
tlv(0x03, Buffer.from([0]), signature),
|
|
158
|
+
);
|
|
159
|
+
const lines = der
|
|
160
|
+
.toString("base64")
|
|
161
|
+
.match(/.{1,64}/g)
|
|
162
|
+
.join("\n");
|
|
163
|
+
return `-----BEGIN CERTIFICATE REQUEST-----\n${lines}\n-----END CERTIFICATE REQUEST-----\n`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// --- the certificate -------------------------------------------------------------------------
|
|
167
|
+
|
|
168
|
+
/** When a certificate ends, or null when the text isn't one. */
|
|
169
|
+
export function notAfter(certPem) {
|
|
170
|
+
try {
|
|
171
|
+
return new Date(new X509Certificate(certPem).validTo);
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Whether a certificate is missing, unreadable, or ends within RENEW_BEFORE. */
|
|
178
|
+
export function needsRenewal(certPem, now = Date.now()) {
|
|
179
|
+
const end = certPem ? notAfter(certPem) : null;
|
|
180
|
+
return !end || end.getTime() - now < RENEW_BEFORE;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Something the tunnel API said no to, with its sentence for people and its code. */
|
|
184
|
+
export class AccountError extends Error {
|
|
185
|
+
constructor(message, code, status) {
|
|
186
|
+
super(message);
|
|
187
|
+
this.code = code;
|
|
188
|
+
this.status = status;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A call to the tunnel API at `api` (wizards.host): its JSON, or an AccountError. */
|
|
193
|
+
export async function call(api, path, { method = "GET", key, body } = {}) {
|
|
194
|
+
let res;
|
|
195
|
+
try {
|
|
196
|
+
res = await fetch(`${api}${path}`, {
|
|
197
|
+
method,
|
|
198
|
+
headers: {
|
|
199
|
+
...(body ? { "content-type": "application/json" } : {}),
|
|
200
|
+
...(key ? { authorization: `Bearer ${key}` } : {}),
|
|
201
|
+
"user-agent": "wizards-bot-tunnel",
|
|
202
|
+
},
|
|
203
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
204
|
+
signal: AbortSignal.timeout(30_000),
|
|
205
|
+
});
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw new AccountError(`${api} didn’t answer: ${error.message}`, "unreachable", 0);
|
|
208
|
+
}
|
|
209
|
+
const data = res.status === 204 ? {} : await res.json().catch(() => ({}));
|
|
210
|
+
if (!res.ok) {
|
|
211
|
+
throw new AccountError(
|
|
212
|
+
data.error || `${api} answered ${res.status}.`,
|
|
213
|
+
data.code || "error",
|
|
214
|
+
res.status,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return { status: res.status, data };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const pause = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* A certificate for the key's name: posts the request, then asks every `every` ms until the
|
|
224
|
+
* API has it (Let's Encrypt checks the name's DNS meanwhile). Returns the PEM chain.
|
|
225
|
+
*/
|
|
226
|
+
export async function orderCertificate(api, key, csr, { every = 3000, within = 300_000 } = {}) {
|
|
227
|
+
const { data: order } = await call(api, "/v1/tunnels/cert", {
|
|
228
|
+
method: "POST",
|
|
229
|
+
key,
|
|
230
|
+
body: { csr },
|
|
231
|
+
});
|
|
232
|
+
const until = Date.now() + within;
|
|
233
|
+
while (Date.now() < until) {
|
|
234
|
+
const { data } = await call(api, `/v1/tunnels/cert/${encodeURIComponent(order.id)}`, {
|
|
235
|
+
key,
|
|
236
|
+
});
|
|
237
|
+
if (data.state === "ready" && data.cert) {
|
|
238
|
+
return data.cert;
|
|
239
|
+
}
|
|
240
|
+
if (data.state === "failed") {
|
|
241
|
+
throw new AccountError(data.error || "The certificate couldn’t be made.", "failed", 200);
|
|
242
|
+
}
|
|
243
|
+
await pause(every);
|
|
244
|
+
}
|
|
245
|
+
throw new AccountError("The certificate took too long. Try again in a few minutes.", "slow", 0);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Writes a file in one move, readable only by you where `secret`. */
|
|
249
|
+
export function writeFileAtomic(file, text, secret = false) {
|
|
250
|
+
const next = `${file}.next`;
|
|
251
|
+
writeFileSync(next, text, { mode: secret ? 0o600 : 0o644 });
|
|
252
|
+
if (secret) {
|
|
253
|
+
chmodSync(next, 0o600);
|
|
254
|
+
}
|
|
255
|
+
renameSync(next, file);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// --- frpc's settings -------------------------------------------------------------------------
|
|
259
|
+
|
|
260
|
+
const toml = (text) => JSON.stringify(String(text));
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* frpc.toml for a home: one https proxy for the name, TLS ended here by the https2http plugin,
|
|
264
|
+
* the control connection over wss to the relay, the key as metadata, and frpc's admin API on
|
|
265
|
+
* 127.0.0.1 so `frpc reload` can read a renewed certificate.
|
|
266
|
+
*/
|
|
267
|
+
export function frpcConfig(tunnel) {
|
|
268
|
+
return [
|
|
269
|
+
"# Written by `wizards bot tunnel`; `wizards bot update` writes it again.",
|
|
270
|
+
`serverAddr = ${toml(tunnel.server)}`,
|
|
271
|
+
`serverPort = ${Number(tunnel.serverPort)}`,
|
|
272
|
+
"loginFailExit = false",
|
|
273
|
+
'transport.protocol = "wss"',
|
|
274
|
+
"transport.tls.useSystemCa = true",
|
|
275
|
+
"transport.heartbeatInterval = 30",
|
|
276
|
+
"transport.heartbeatTimeout = 90",
|
|
277
|
+
`metadatas.token = ${toml(tunnel.key)}`,
|
|
278
|
+
'webServer.addr = "127.0.0.1"',
|
|
279
|
+
`webServer.port = ${Number(tunnel.adminPort)}`,
|
|
280
|
+
'webServer.user = "wizards"',
|
|
281
|
+
`webServer.password = ${toml(tunnel.adminPassword)}`,
|
|
282
|
+
"",
|
|
283
|
+
"[[proxies]]",
|
|
284
|
+
`name = ${toml(tunnel.name)}`,
|
|
285
|
+
'type = "https"',
|
|
286
|
+
`customDomains = [${toml(tunnel.name)}]`,
|
|
287
|
+
"",
|
|
288
|
+
"[proxies.plugin]",
|
|
289
|
+
'type = "https2http"',
|
|
290
|
+
`localAddr = ${toml(`127.0.0.1:${Number(tunnel.port)}`)}`,
|
|
291
|
+
`crtPath = ${toml(join(tunnel.dir, "cert.pem"))}`,
|
|
292
|
+
`keyPath = ${toml(join(tunnel.dir, "key.pem"))}`,
|
|
293
|
+
"",
|
|
294
|
+
].join("\n");
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// --- running -------------------------------------------------------------------------------
|
|
298
|
+
|
|
299
|
+
const stamp = () => new Date().toISOString();
|
|
300
|
+
const say = (text) => console.log(`${stamp()} ${text}`);
|
|
301
|
+
|
|
302
|
+
/** Renews the certificate when it's due; true when there's a new one. */
|
|
303
|
+
export async function renewIfDue(tunnel, now = Date.now()) {
|
|
304
|
+
const certFile = join(tunnel.dir, "cert.pem");
|
|
305
|
+
const current = existsSync(certFile) ? readFileSync(certFile, "utf8") : null;
|
|
306
|
+
if (!needsRenewal(current, now)) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
const keyPem = readFileSync(join(tunnel.dir, "key.pem"), "utf8");
|
|
310
|
+
const cert = await orderCertificate(tunnel.api, tunnel.key, csrFor(tunnel.name, keyPem));
|
|
311
|
+
writeFileAtomic(certFile, cert);
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The tunnel's service: frpc, started again when it ends (after 1 s, then longer, up to a
|
|
317
|
+
* minute), and the certificate looked at every 12 hours.
|
|
318
|
+
*/
|
|
319
|
+
export async function run(dir) {
|
|
320
|
+
const tunnel = { ...JSON.parse(readFileSync(join(dir, "tunnel.json"), "utf8")), dir };
|
|
321
|
+
const config = join(dir, "frpc.toml");
|
|
322
|
+
let child = null;
|
|
323
|
+
let wait = 1000;
|
|
324
|
+
let stopping = false;
|
|
325
|
+
const startFrpc = () => {
|
|
326
|
+
const started = Date.now();
|
|
327
|
+
say(`frpc for https://${tunnel.name}`);
|
|
328
|
+
child = spawn(tunnel.frpc, ["-c", config], { stdio: "inherit" });
|
|
329
|
+
child.on("exit", (code, signal) => {
|
|
330
|
+
child = null;
|
|
331
|
+
if (stopping) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
wait = Date.now() - started > 300_000 ? 1000 : Math.min(wait * 2, 60_000);
|
|
335
|
+
say(`frpc ended (${signal || code}); again in ${Math.round(wait / 1000)} s`);
|
|
336
|
+
setTimeout(startFrpc, wait);
|
|
337
|
+
});
|
|
338
|
+
child.on("error", (error) => say(`frpc didn’t start: ${error.message}`));
|
|
339
|
+
};
|
|
340
|
+
const check = async () => {
|
|
341
|
+
try {
|
|
342
|
+
if (await renewIfDue(tunnel)) {
|
|
343
|
+
say(
|
|
344
|
+
`New certificate for ${tunnel.name}, until ${notAfter(readFileSync(join(dir, "cert.pem"), "utf8"))?.toISOString()}`,
|
|
345
|
+
);
|
|
346
|
+
const reload = spawnSync(tunnel.frpc, ["reload", "-c", config], { encoding: "utf8" });
|
|
347
|
+
if (reload.status !== 0) {
|
|
348
|
+
say(`frpc reload failed (${(reload.stderr || reload.stdout).trim()}); restarting frpc`);
|
|
349
|
+
child?.kill("SIGTERM");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} catch (error) {
|
|
353
|
+
say(`The certificate wasn’t renewed: ${error.message}`);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
357
|
+
process.on(signal, () => {
|
|
358
|
+
stopping = true;
|
|
359
|
+
child?.kill("SIGTERM");
|
|
360
|
+
process.exit(0);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
await check();
|
|
364
|
+
startFrpc();
|
|
365
|
+
setInterval(check, CHECK_EVERY);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
369
|
+
const dir = process.argv[2];
|
|
370
|
+
if (!dir) {
|
|
371
|
+
console.error("Usage: node run.mjs <the home's tunnel folder>");
|
|
372
|
+
process.exit(2);
|
|
373
|
+
}
|
|
374
|
+
await run(dir);
|
|
375
|
+
}
|